2
0
Эх сурвалжийг харах

removed CAdvMapInt::handleRightClick method

Ivan Savenko 2 жил өмнө
parent
commit
f8c1c46562

+ 6 - 3
client/CPlayerInterface.cpp

@@ -251,6 +251,9 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose)
 			return;
 	}
 
+	adventureInt->minimap.updateTile(hero->convertToVisitablePos(details.start));
+	adventureInt->minimap.updateTile(hero->convertToVisitablePos(details.end));
+
 	bool directlyAttackingCreature =
 		details.attackedFrom
 		&& adventureInt->terrain.currentPath					//in case if movement has been canceled in the meantime and path was already erased
@@ -1194,7 +1197,7 @@ void CPlayerInterface::tileRevealed(const std::unordered_set<int3, ShashInt3> &p
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	//FIXME: wait for dialog? Magi hut/eye would benefit from this but may break other areas
 	for (auto & po : pos)
-		adventureInt->minimap.showTile(po);
+		adventureInt->minimap.updateTile(po);
 	if (!pos.empty())
 		GH.totalRedraw();
 }
@@ -1203,7 +1206,7 @@ void CPlayerInterface::tileHidden(const std::unordered_set<int3, ShashInt3> &pos
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	for (auto & po : pos)
-		adventureInt->minimap.hideTile(po);
+		adventureInt->minimap.updateTile(po);
 	if (!pos.empty())
 		GH.totalRedraw();
 }
@@ -1409,7 +1412,7 @@ void CPlayerInterface::objectPropertyChanged(const SetObjectProperty * sop)
 		for(auto & po : pos)
 		{
 			if(cb->isVisible(po))
-				adventureInt->minimap.showTile(po);
+				adventureInt->minimap.updateTile(po);
 		}
 		if(obj->ID == Obj::TOWN)
 		{

+ 5 - 12
client/adventureMap/CAdvMapInt.cpp

@@ -256,17 +256,17 @@ void CAdvMapInt::fworldViewBack()
 void CAdvMapInt::fworldViewScale1x()
 {
 	// TODO set corresponding scale button to "selected" mode
-	changeMode(EAdvMapMode::WORLD_VIEW, 0.22f);
+	changeMode(EAdvMapMode::WORLD_VIEW, 0.22f); // 7 pixels per tile
 }
 
 void CAdvMapInt::fworldViewScale2x()
 {
-	changeMode(EAdvMapMode::WORLD_VIEW, 0.36f);
+	changeMode(EAdvMapMode::WORLD_VIEW, 0.36f); // 11 pixels per tile
 }
 
 void CAdvMapInt::fworldViewScale4x()
 {
-	changeMode(EAdvMapMode::WORLD_VIEW, 0.5f);
+	changeMode(EAdvMapMode::WORLD_VIEW, 0.5f); // 16 pixels per tile
 }
 
 void CAdvMapInt::fswitchLevel()
@@ -928,13 +928,6 @@ boost::optional<Point> CAdvMapInt::keyToMoveDirection(const SDL_Keycode & key)
 	return boost::none;
 }
 
-void CAdvMapInt::handleRightClick(std::string text, tribool down)
-{
-	if(down)
-	{
-		CRClickPopup::createAndPush(text);
-	}
-}
 int3 CAdvMapInt::verifyPos(int3 ver)
 {
 	if (ver.x<0)
@@ -1274,7 +1267,7 @@ void CAdvMapInt::tileHovered(const int3 &mapPos)
 
 		if(GH.isKeyboardAltDown() && pathNode->reachable()) //overwrite status bar text with movement info
 		{
-			ShowMoveDetailsInStatusbar(*hero, *pathNode);
+			showMoveDetailsInStatusbar(*hero, *pathNode);
 		}
 
 		int turns = pathNode->turns;
@@ -1340,7 +1333,7 @@ void CAdvMapInt::tileHovered(const int3 &mapPos)
 	}
 }
 
-void CAdvMapInt::ShowMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode)
+void CAdvMapInt::showMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode)
 {
 	const int maxMovementPointsAtStartOfLastTurn = pathNode.turns > 0 ? hero.maxMovePoints(pathNode.layer == EPathfindingLayer::LAND) : hero.movement;
 	const int movementPointsLastTurnCost = maxMovementPointsAtStartOfLastTurn - pathNode.moveRemains;

+ 1 - 2
client/adventureMap/CAdvMapInt.h

@@ -159,7 +159,6 @@ public:
 	void centerOn(int3 on, bool fade = false);
 	void centerOn(const CGObjectInstance *obj, bool fade = false);
 	int3 verifyPos(int3 ver);
-	void handleRightClick(std::string text, tribool down);
 	void keyPressed(const SDL_Keycode & key) override;
 	void keyReleased(const SDL_Keycode & key) override;
 	void mouseMoved (const Point & cursorPosition) override;
@@ -199,7 +198,7 @@ public:
 	void handleSwipeUpdate();
 
 private:
-	void ShowMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode);
+	void showMoveDetailsInStatusbar(const CGHeroInstance & hero, const CGPathNode & pathNode);
 };
 
 extern std::shared_ptr<CAdvMapInt> adventureInt;

+ 3 - 1
client/adventureMap/CInfoBar.cpp

@@ -17,6 +17,7 @@
 #include "../widgets/Images.h"
 #include "../widgets/TextControls.h"
 #include "../widgets/MiscWidgets.h"
+#include "../windows/InfoWindows.h"
 #include "../CGameInfo.h"
 #include "../CMusicHandler.h"
 #include "../CPlayerInterface.h"
@@ -234,7 +235,8 @@ void CInfoBar::clickLeft(tribool down, bool previousState)
 
 void CInfoBar::clickRight(tribool down, bool previousState)
 {
-	adventureInt->handleRightClick(CGI->generaltexth->allTexts[109], down);
+	if (down)
+		CRClickPopup::createAndPush(CGI->generaltexth->allTexts[109]);
 }
 
 void CInfoBar::hover(bool on)

+ 3 - 3
client/widgets/CComponent.cpp

@@ -20,8 +20,8 @@
 #include "../gui/CursorHandler.h"
 #include "../gui/TextAlignment.h"
 #include "../renderSDL/SDL_Extensions.h"
-#include "../adventureMap/CAdvMapInt.h"
 #include "../windows/CMessage.h"
+#include "../windows/InfoWindows.h"
 #include "../widgets/TextControls.h"
 #include "../CGameInfo.h"
 
@@ -250,8 +250,8 @@ void CComponent::setSurface(std::string defName, int imgPos)
 
 void CComponent::clickRight(tribool down, bool previousState)
 {
-	if(!getDescription().empty())
-		adventureInt->handleRightClick(getDescription(), down);
+	if(down && !getDescription().empty())
+		CRClickPopup::createAndPush(getDescription());
 }
 
 void CSelectableComponent::clickLeft(tribool down, bool previousState)

+ 2 - 3
client/widgets/MiscWidgets.cpp

@@ -21,7 +21,6 @@
 #include "../windows/CCastleInterface.h"
 #include "../windows/InfoWindows.h"
 #include "../renderSDL/SDL_Extensions.h"
-#include "../adventureMap/CAdvMapInt.h"
 
 #include "../../CCallback.h"
 
@@ -57,8 +56,8 @@ void LRClickableAreaWText::clickLeft(tribool down, bool previousState)
 }
 void LRClickableAreaWText::clickRight(tribool down, bool previousState)
 {
-	if (!text.empty())
-		adventureInt->handleRightClick(text, down);
+	if (down && !text.empty())
+		CRClickPopup::createAndPush(text);
 }
 
 LRClickableAreaWText::LRClickableAreaWText()

+ 3 - 2
client/windows/CKingdomInterface.cpp

@@ -15,12 +15,13 @@
 
 #include "../CGameInfo.h"
 #include "../CPlayerInterface.h"
+#include "../adventureMap/CResDataBar.h"
 #include "../gui/CGuiHandler.h"
 #include "../widgets/CComponent.h"
 #include "../widgets/TextControls.h"
 #include "../widgets/MiscWidgets.h"
 #include "../widgets/Buttons.h"
-#include "../adventureMap/CAdvMapInt.h"
+#include "../widgets/ObjectLists.h"
 #include "../renderSDL/SDL_Extensions.h"
 
 #include "../../CCallback.h"
@@ -95,7 +96,7 @@ void InfoBox::clickRight(tribool down, bool previousState)
 		if (comp)
 			CRClickPopup::createAndPush(text, CInfoWindow::TCompsInfo(1, comp));
 		else if (!text.empty())
-			adventureInt->handleRightClick(text, down);
+			CRClickPopup::createAndPush(text);
 	}
 }
 

+ 2 - 1
client/windows/CSpellWindow.cpp

@@ -57,7 +57,8 @@ void CSpellWindow::InteractiveArea::clickLeft(tribool down, bool previousState)
 
 void CSpellWindow::InteractiveArea::clickRight(tribool down, bool previousState)
 {
-	adventureInt->handleRightClick(helpText, down);
+	if (down)
+		CRClickPopup::createAndPush(helpText);
 }
 
 void CSpellWindow::InteractiveArea::hover(bool on)

+ 2 - 2
client/windows/CTradeWindow.cpp

@@ -13,11 +13,11 @@
 #include "../gui/CGuiHandler.h"
 #include "../gui/CursorHandler.h"
 #include "../widgets/Images.h"
-#include "../adventureMap/CAdvMapInt.h"
 #include "../renderSDL/SDL_Extensions.h"
 #include "../gui/TextAlignment.h"
 #include "../widgets/Buttons.h"
 #include "../widgets/TextControls.h"
+#include "../windows/InfoWindows.h"
 
 #include "../CGameInfo.h"
 #include "../CPlayerInterface.h"
@@ -272,7 +272,7 @@ void CTradeWindow::CTradeableItem::clickRight(tribool down, bool previousState)
 		case ARTIFACT_PLACEHOLDER:
 			//TODO: it's would be better for market to contain actual CArtifactInstance and not just ids of certain artifact type so we can use getEffectiveDescription.
 			if(id >= 0)
-				adventureInt->handleRightClick(CGI->artifacts()->getByIndex(id)->getDescriptionTranslated(), down);
+				CRClickPopup::createAndPush(CGI->artifacts()->getByIndex(id)->getDescriptionTranslated());
 			break;
 		}
 	}