1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

show statistics ingame

This commit is contained in:
Laserlicht
2025-11-22 13:14:50 +01:00
parent f3fd5c05af
commit afb045ef14
26 changed files with 119 additions and 0 deletions

View File

@@ -37,6 +37,7 @@
#include "mainmenu/CMainMenu.h"
#include "mainmenu/CHighScoreScreen.h"
#include "mainmenu/CStatisticScreen.h"
#include "mapView/mapHandler.h"
@@ -1847,3 +1848,8 @@ void CPlayerInterface::unregisterBattleInterface(std::shared_ptr<CBattleGameInte
GAME->server().client->unregisterBattleInterface(autofightingAI, playerID);
autofightingAI.reset();
}
void CPlayerInterface::responseStatistic(StatisticDataSet & statistic)
{
ENGINE->windows().createAndPushWindow<CStatisticScreen>(statistic);
}

View File

@@ -12,6 +12,7 @@
#include "ArtifactsUIController.h"
#include "../lib/callback/CGameInterface.h"
#include "../lib/gameState/GameStatistics.h"
#include "../lib/FunctionList.h"
#include "gui/CIntObject.h"
@@ -147,6 +148,7 @@ protected: // Call-ins from server, should not be called directly, but only via
void playerEndsTurn(PlayerColor player) override;
void showWorldViewEx(const std::vector<ObjectPosInfo> & objectPositions, bool showTerrain) override;
void setColorScheme(ColorScheme scheme) override;
void responseStatistic(StatisticDataSet & statistic) override;
//for battles
void actionFinished(const BattleID & battleID, const BattleAction& action) override;//occurs AFTER action taken by active stack or by the hero

View File

@@ -106,6 +106,7 @@ public:
void visitEntitiesChanged(EntitiesChanged & pack) override;
void visitPlayerCheated(PlayerCheated & pack) override;
void visitChangeTownName(ChangeTownName & pack) override;
void visitResponseStatistic(ResponseStatistic & pack) override;
};
class ApplyFirstClientNetPackVisitor : public VCMI_LIB_WRAP_NAMESPACE(ICPackVisitor)

View File

@@ -1098,3 +1098,8 @@ void ApplyClientNetPackVisitor::visitChangeTownName(ChangeTownName & pack)
ENGINE->windows().totalRedraw();
}
}
void ApplyClientNetPackVisitor::visitResponseStatistic(ResponseStatistic & pack)
{
callInterfaceIfPresent(cl, pack.player, &IGameEventsReceiver::responseStatistic, pack.statistic);
}

View File

@@ -73,6 +73,7 @@ std::vector<AdventureMapShortcutState> AdventureMapShortcuts::getShortcuts()
{ EShortcut::ADVENTURE_VIEW_WORLD_X1, optionInWorldView(), [this]() { this->worldViewScale1x(); } },
{ EShortcut::ADVENTURE_VIEW_WORLD_X2, optionInWorldView(), [this]() { this->worldViewScale2x(); } },
{ EShortcut::ADVENTURE_VIEW_WORLD_X4, optionInWorldView(), [this]() { this->worldViewScale4x(); } },
{ EShortcut::ADVENTURE_VIEW_STATISTIC, optionViewStatistic(), [this]() { this->viewStatistic(); } },
{ EShortcut::ADVENTURE_TOGGLE_MAP_LEVEL, optionCanToggleLevel(), [this]() { this->switchMapLevel(); } },
{ EShortcut::ADVENTURE_QUEST_LOG, optionCanViewQuests(), [this]() { this->showQuestlog(); } },
{ EShortcut::ADVENTURE_TOGGLE_SLEEP, optionHeroSelected(), [this]() { this->toggleSleepWake(); } },
@@ -153,6 +154,11 @@ void AdventureMapShortcuts::worldViewScale4x()
owner.openWorldView(16);
}
void AdventureMapShortcuts::viewStatistic()
{
GAME->interface()->cb->requestStatistic();
}
void AdventureMapShortcuts::switchMapLevel()
{
owner.hotkeySwitchMapLevel();
@@ -677,3 +683,11 @@ bool AdventureMapShortcuts::optionHeroDig()
auto hero = GAME->interface()->localState->getCurrentHero();
return optionInMapView() && hero && hero->diggingStatus() == EDiggingStatus::CAN_DIG;
}
bool AdventureMapShortcuts::optionViewStatistic()
{
if(!GAME->interface()->makingTurn)
return false;
auto day = GAME->interface()->cb->getDate(Date::DAY);
return optionInMapView() && day > 1;
}

View File

@@ -43,6 +43,7 @@ class AdventureMapShortcuts
void worldViewScale1x();
void worldViewScale2x();
void worldViewScale4x();
void viewStatistic();
void switchMapLevel();
void showQuestlog();
void toggleTrackHero();
@@ -103,6 +104,7 @@ public:
bool optionMarketplace();
bool optionHeroBoat(EPathfindingLayer layer);
bool optionHeroDig();
bool optionViewStatistic();
void setState(EAdventureState newState);
EAdventureState getState() const;

View File

@@ -149,6 +149,7 @@ enum class EShortcut
ADVENTURE_VIEW_WORLD_X1,
ADVENTURE_VIEW_WORLD_X2,
ADVENTURE_VIEW_WORLD_X4,
ADVENTURE_VIEW_STATISTIC,
ADVENTURE_TRACK_HERO,
ADVENTURE_TOGGLE_MAP_LEVEL,
ADVENTURE_KINGDOM_OVERVIEW,

View File

@@ -203,6 +203,7 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const
{"adventureViewWorld1", EShortcut::ADVENTURE_VIEW_WORLD_X1 },
{"adventureViewWorld2", EShortcut::ADVENTURE_VIEW_WORLD_X2 },
{"adventureViewWorld4", EShortcut::ADVENTURE_VIEW_WORLD_X4 },
{"adventureViewStatistic", EShortcut::ADVENTURE_VIEW_STATISTIC },
{"adventureTrackHero", EShortcut::ADVENTURE_TRACK_HERO, },
{"adventureToggleMapLevel", EShortcut::ADVENTURE_TOGGLE_MAP_LEVEL},
{"adventureKingdomOverview", EShortcut::ADVENTURE_KINGDOM_OVERVIEW},

View File

@@ -55,6 +55,7 @@ class NetworkLagPredictionTestVisitor final : public ICPackVisitor
//void visitMakeAction(MakeAction & pack) override;
//void visitDigWithHero(DigWithHero & pack) override;
//void visitCastAdvSpell(CastAdvSpell & pack) override;
//void visitRequestStatistic(RequestStatistic & pack) override;
//void visitPlayerMessage(PlayerMessage & pack) override;
//void visitSaveLocalState(SaveLocalState & pack) override;

View File

@@ -102,6 +102,7 @@ private:
//void visitBattleResultsApplied(BattleResultsApplied & pack) override;
//void visitBattleResultAccepted(BattleResultAccepted & pack) override;
//void visitTurnTimeUpdate(TurnTimeUpdate & pack) override;
//void visitResponseStatistic(ResponseStatistic & pack) override;
public:
PackRollbackGeneratorVisitor(const CGameState & gs)