Browse Source

Show creature popup window on right-click in town fort

Ivan Savenko 2 years ago
parent
commit
5d2dd4c633
2 changed files with 11 additions and 0 deletions
  1. 9 0
      client/windows/CCastleInterface.cpp
  2. 2 0
      client/windows/CCastleInterface.h

+ 9 - 0
client/windows/CCastleInterface.cpp

@@ -15,6 +15,7 @@
 #include "InfoWindows.h"
 #include "GUIClasses.h"
 #include "QuickRecruitmentWindow.h"
+#include "CCreatureWindow.h"
 
 #include "../CGameInfo.h"
 #include "../CMusicHandler.h"
@@ -1653,6 +1654,8 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
 	if(!town->creatures[level].second.empty())
 		addUsedEvents(LCLICK | HOVER);//Activate only if dwelling is present
 
+	addUsedEvents(SHOW_POPUP);
+
 	icons = std::make_shared<CPicture>("TPCAINFO", 261, 3);
 
 	if(getMyBuilding() != nullptr)
@@ -1740,6 +1743,12 @@ void CFortScreen::RecruitArea::clickPressed(const Point & cursorPosition)
 	LOCPLINT->castleInt->builds->enterDwelling(level);
 }
 
+void CFortScreen::RecruitArea::showPopupWindow(const Point & cursorPosition)
+{
+	if (getMyCreature() != nullptr)
+		GH.windows().createAndPushWindow<CStackWindow>(getMyCreature(), true);
+}
+
 CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner,std::string imagem)
 	: CStatusbarWindow(BORDERED, imagem)
 {

+ 2 - 0
client/windows/CCastleInterface.h

@@ -347,6 +347,8 @@ class CFortScreen : public CStatusbarWindow
 		void creaturesChangedEventHandler();
 		void hover(bool on) override;
 		void clickPressed(const Point & cursorPosition) override;
+		void showPopupWindow(const Point & cursorPosition) override;
+
 	};
 	std::shared_ptr<CLabel> title;
 	std::vector<std::shared_ptr<RecruitArea>> recAreas;