浏览代码

simple resource show on right click

Laserlicht 1 月之前
父节点
当前提交
0cc9c62e8a
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. 15 0
      client/adventureMap/CResDataBar.cpp
  2. 1 0
      client/adventureMap/CResDataBar.h

+ 15 - 0
client/adventureMap/CResDataBar.cpp

@@ -18,15 +18,21 @@
 #include "../GameInstance.h"
 #include "../gui/TextAlignment.h"
 #include "../widgets/Images.h"
+#include "../widgets/CComponent.h"
+#include "../windows/InfoWindows.h"
 
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/ResourceSet.h"
 #include "../../lib/GameLibrary.h"
+#include "../../lib/entities/ResourceTypeHandler.h"
+#include "../../lib/networkPacks/Component.h"
 
 CResDataBar::CResDataBar(const ImagePath & imageName, const Point & position)
 {
+	addUsedEvents(SHOW_POPUP);
+
 	pos.x += position.x;
 	pos.y += position.y;
 
@@ -89,3 +95,12 @@ void CResDataBar::setPlayerColor(PlayerColor player)
 {
 	background->setPlayerColor(player);
 }
+
+void CResDataBar::showPopupWindow(const Point & cursorPosition)
+{
+	std::vector<std::shared_ptr<CComponent>> comp;
+	for (auto & i : LIBRARY->resourceTypeHandler->getAllObjects())
+		comp.push_back(std::make_shared<CComponent>(ComponentType::RESOURCE, i, GAME->interface()->cb->getResourceAmount(i)));
+	
+	CRClickPopup::createAndPush(LIBRARY->generaltexth->translate("core.genrltxt.270"), comp);
+}

+ 1 - 0
client/adventureMap/CResDataBar.h

@@ -35,6 +35,7 @@ public:
 	void setResourcePosition(const GameResID & resource, const Point & position);
 
 	void setPlayerColor(PlayerColor player);
+	void showPopupWindow(const Point & cursorPosition) override;
 	void showAll(Canvas & to) override;
 };