浏览代码

extended statistic: Window

Laserlicht 1 年之前
父节点
当前提交
299ee35c48

+ 2 - 0
Mods/vcmi/config/vcmi/english.json

@@ -162,6 +162,8 @@
 	"vcmi.systemOptions.otherGroup" : "Other Settings", // unused right now
 	"vcmi.systemOptions.townsGroup" : "Town Screen",
 
+	"vcmi.statisticWindow.statistic" : "Statistic",
+
 	"vcmi.systemOptions.fullscreenBorderless.hover" : "Fullscreen (borderless)",
 	"vcmi.systemOptions.fullscreenBorderless.help"  : "{Borderless Fullscreen}\n\nIf selected, VCMI will run in borderless fullscreen mode. In this mode, game will always use same resolution as desktop, ignoring selected resolution.",
 	"vcmi.systemOptions.fullscreenExclusive.hover"  : "Fullscreen (exclusive)",

+ 2 - 0
Mods/vcmi/config/vcmi/german.json

@@ -162,6 +162,8 @@
 	"vcmi.systemOptions.otherGroup" : "Andere Einstellungen", // unused right now
 	"vcmi.systemOptions.townsGroup" : "Stadt-Bildschirm",
 
+	"vcmi.statisticWindow.statistic" : "Statistik",
+
 	"vcmi.systemOptions.fullscreenBorderless.hover" : "Vollbild (randlos)",
 	"vcmi.systemOptions.fullscreenBorderless.help"  : "{Randloses Vollbild}\n\nWenn diese Option ausgewählt ist, wird VCMI im randlosen Vollbildmodus ausgeführt. In diesem Modus wird das Spiel immer dieselbe Auflösung wie der Desktop verwenden und die gewählte Auflösung ignorieren.",
 	"vcmi.systemOptions.fullscreenExclusive.hover"  : "Vollbild (exklusiv)",

+ 2 - 0
client/CMakeLists.txt

@@ -64,6 +64,7 @@ set(client_SRCS
 	mainmenu/CPrologEpilogVideo.cpp
 	mainmenu/CreditsScreen.cpp
 	mainmenu/CHighScoreScreen.cpp
+	mainmenu/CStatisticScreen.cpp
 
 	mapView/MapRenderer.cpp
 	mapView/MapRendererContext.cpp
@@ -254,6 +255,7 @@ set(client_HEADERS
 	mainmenu/CPrologEpilogVideo.h
 	mainmenu/CreditsScreen.h
 	mainmenu/CHighScoreScreen.h
+	mainmenu/CStatisticScreen.h
 
 	mapView/IMapRendererContext.h
 	mapView/IMapRendererObserver.h

+ 4 - 3
client/mainmenu/CHighScoreScreen.cpp

@@ -11,6 +11,7 @@
 #include "StdInc.h"
 
 #include "CHighScoreScreen.h"
+#include "CStatisticScreen.h"
 #include "../gui/CGuiHandler.h"
 #include "../gui/WindowHandler.h"
 #include "../gui/Shortcut.h"
@@ -172,7 +173,7 @@ void CHighScoreScreen::buttonExitClick()
 }
 
 CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc, StatisticDataSet statistic)
-	: CWindowObject(BORDERED), won(won), calc(calc)
+	: CWindowObject(BORDERED), won(won), calc(calc), stat(statistic)
 {
 	addUsedEvents(LCLICK | KEYBOARD);
 
@@ -206,8 +207,8 @@ CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc
 		CCS->musich->playMusic(AudioPath::builtin("music/UltimateLose"), false, true);
 	}
 
-	statisticButton = std::make_shared<CButton>(Point(736, 0), AnimationPath::builtin("TPTAV02.DEF"), CButton::tooltip("bla"), [](){});
-	texts.push_back(std::make_shared<CMultiLineLabel>(Rect(0, 0, 726, 32), FONT_HIGH_SCORE, ETextAlignment::CENTERRIGHT, Colors::WHITE, "Statistik:"));
+	statisticButton = std::make_shared<CButton>(Point(736, 0), AnimationPath::builtin("TPTAV02.DEF"), CButton::tooltip(CGI->generaltexth->translate("vcmi.statisticWindow.statistic")), [this](){ GH.windows().createAndPushWindow<CStatisticScreen>(stat); });
+	texts.push_back(std::make_shared<CMultiLineLabel>(Rect(0, 0, 726, 32), FONT_HIGH_SCORE, ETextAlignment::CENTERRIGHT, Colors::WHITE, CGI->generaltexth->translate("vcmi.statisticWindow.statistic") + ":"));
 }
 
 int CHighScoreInputScreen::addEntry(std::string text) {

+ 2 - 2
client/mainmenu/CHighScoreScreen.h

@@ -10,6 +10,7 @@
 #pragma once
 #include "../windows/CWindowObject.h"
 #include "../../lib/gameState/HighScore.h"
+#include "../../lib/gameState/GameStatistics.h"
 
 class CButton;
 class CLabel;
@@ -21,8 +22,6 @@ class CFilledTexture;
 
 class TransparentFilledRectangle;
 
-class StatisticDataSet;
-
 class CHighScoreScreen : public CWindowObject
 {
 public:
@@ -79,6 +78,7 @@ class CHighScoreInputScreen : public CWindowObject
 	std::shared_ptr<CFilledTexture> backgroundAroundMenu;
 
 	std::shared_ptr<CButton> statisticButton;
+	StatisticDataSet stat;
 
 	bool won;
 	HighScoreCalculation calc;

+ 34 - 0
client/mainmenu/CStatisticScreen.cpp

@@ -0,0 +1,34 @@
+/*
+ * CStatisticScreen.cpp, part of VCMI engine
+ *
+ * Authors: listed in file AUTHORS in main folder
+ *
+ * License: GNU General Public License v2.0 or later
+ * Full text of license available in license.txt file, in main folder
+ *
+ */
+
+#include "StdInc.h"
+
+#include "CStatisticScreen.h"
+#include "../gui/CGuiHandler.h"
+#include "../gui/WindowHandler.h"
+
+#include "../widgets/Images.h"
+
+#include "../../lib/gameState/GameStatistics.h"
+
+CStatisticScreen::CStatisticScreen(StatisticDataSet statistic)
+	: CWindowObject(BORDERED)
+{
+	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
+	pos = center(Rect(0, 0, 800, 600));
+	filledBackground = std::make_shared<FilledTexturePlayerColored>(ImagePath::builtin("DiBoxBck"), Rect(0, 0, pos.w, pos.h));
+
+	addUsedEvents(LCLICK);
+}
+
+void CStatisticScreen::clickPressed(const Point & cursorPosition)
+{
+	close();
+}

+ 24 - 0
client/mainmenu/CStatisticScreen.h

@@ -0,0 +1,24 @@
+/*
+ * CStatisticScreen.h, part of VCMI engine
+ *
+ * Authors: listed in file AUTHORS in main folder
+ *
+ * License: GNU General Public License v2.0 or later
+ * Full text of license available in license.txt file, in main folder
+ *
+ */
+#pragma once
+#include "../windows/CWindowObject.h"
+
+class FilledTexturePlayerColored;
+
+class StatisticDataSet;
+
+class CStatisticScreen : public CWindowObject
+{
+	std::shared_ptr<FilledTexturePlayerColored> filledBackground;
+public:
+	CStatisticScreen(StatisticDataSet statistic);
+	
+	void clickPressed(const Point & cursorPosition) override;
+};