mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
extended statistic: Button and data transfer
This commit is contained in:
@@ -673,13 +673,13 @@ void CServerHandler::startGameplay(VCMI_LIB_WRAP_NAMESPACE(CGameState) * gameSta
|
|||||||
setState(EClientState::GAMEPLAY);
|
setState(EClientState::GAMEPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerHandler::showHighScoresAndEndGameplay(PlayerColor player, bool victory)
|
void CServerHandler::showHighScoresAndEndGameplay(PlayerColor player, bool victory, StatisticDataSet statistic)
|
||||||
{
|
{
|
||||||
HighScoreParameter param = HighScore::prepareHighScores(client->gameState(), player, victory);
|
HighScoreParameter param = HighScore::prepareHighScores(client->gameState(), player, victory);
|
||||||
|
|
||||||
if(victory && client->gameState()->getStartInfo()->campState)
|
if(victory && client->gameState()->getStartInfo()->campState)
|
||||||
{
|
{
|
||||||
startCampaignScenario(param, client->gameState()->getStartInfo()->campState);
|
startCampaignScenario(param, client->gameState()->getStartInfo()->campState, statistic);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -690,7 +690,7 @@ void CServerHandler::showHighScoresAndEndGameplay(PlayerColor player, bool victo
|
|||||||
endGameplay();
|
endGameplay();
|
||||||
GH.defActionsDef = 63;
|
GH.defActionsDef = 63;
|
||||||
CMM->menu->switchToTab("main");
|
CMM->menu->switchToTab("main");
|
||||||
GH.windows().createAndPushWindow<CHighScoreInputScreen>(victory, scenarioHighScores);
|
GH.windows().createAndPushWindow<CHighScoreInputScreen>(victory, scenarioHighScores, statistic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,7 +723,7 @@ void CServerHandler::restartGameplay()
|
|||||||
logicConnection->enterLobbyConnectionMode();
|
logicConnection->enterLobbyConnectionMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerHandler::startCampaignScenario(HighScoreParameter param, std::shared_ptr<CampaignState> cs)
|
void CServerHandler::startCampaignScenario(HighScoreParameter param, std::shared_ptr<CampaignState> cs, StatisticDataSet statistic)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CampaignState> ourCampaign = cs;
|
std::shared_ptr<CampaignState> ourCampaign = cs;
|
||||||
|
|
||||||
@@ -739,7 +739,7 @@ void CServerHandler::startCampaignScenario(HighScoreParameter param, std::shared
|
|||||||
endGameplay();
|
endGameplay();
|
||||||
|
|
||||||
auto & epilogue = ourCampaign->scenario(*ourCampaign->lastScenario()).epilog;
|
auto & epilogue = ourCampaign->scenario(*ourCampaign->lastScenario()).epilog;
|
||||||
auto finisher = [ourCampaign, campaignScoreCalculator]()
|
auto finisher = [ourCampaign, campaignScoreCalculator, statistic]()
|
||||||
{
|
{
|
||||||
if(ourCampaign->campaignSet != "" && ourCampaign->isCampaignFinished())
|
if(ourCampaign->campaignSet != "" && ourCampaign->isCampaignFinished())
|
||||||
{
|
{
|
||||||
@@ -755,7 +755,7 @@ void CServerHandler::startCampaignScenario(HighScoreParameter param, std::shared
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
CMM->openCampaignScreen(ourCampaign->campaignSet);
|
CMM->openCampaignScreen(ourCampaign->campaignSet);
|
||||||
GH.windows().createAndPushWindow<CHighScoreInputScreen>(true, *campaignScoreCalculator);
|
GH.windows().createAndPushWindow<CHighScoreInputScreen>(true, *campaignScoreCalculator, statistic);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ class GlobalLobbyClient;
|
|||||||
class GameChatHandler;
|
class GameChatHandler;
|
||||||
class IServerRunner;
|
class IServerRunner;
|
||||||
|
|
||||||
|
class StatisticDataSet;
|
||||||
|
|
||||||
enum class ESelectionScreen : ui8;
|
enum class ESelectionScreen : ui8;
|
||||||
enum class ELoadMode : ui8;
|
enum class ELoadMode : ui8;
|
||||||
|
|
||||||
@@ -204,11 +206,11 @@ public:
|
|||||||
void debugStartTest(std::string filename, bool save = false);
|
void debugStartTest(std::string filename, bool save = false);
|
||||||
|
|
||||||
void startGameplay(VCMI_LIB_WRAP_NAMESPACE(CGameState) * gameState = nullptr);
|
void startGameplay(VCMI_LIB_WRAP_NAMESPACE(CGameState) * gameState = nullptr);
|
||||||
void showHighScoresAndEndGameplay(PlayerColor player, bool victory);
|
void showHighScoresAndEndGameplay(PlayerColor player, bool victory, StatisticDataSet statistic);
|
||||||
void endNetwork();
|
void endNetwork();
|
||||||
void endGameplay();
|
void endGameplay();
|
||||||
void restartGameplay();
|
void restartGameplay();
|
||||||
void startCampaignScenario(HighScoreParameter param, std::shared_ptr<CampaignState> cs = {});
|
void startCampaignScenario(HighScoreParameter param, std::shared_ptr<CampaignState> cs, StatisticDataSet statistic);
|
||||||
void showServerError(const std::string & txt) const;
|
void showServerError(const std::string & txt) const;
|
||||||
|
|
||||||
// TODO: LobbyState must be updated within game so we should always know how many player interfaces our client handle
|
// TODO: LobbyState must be updated within game so we should always know how many player interfaces our client handle
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ void ApplyClientNetPackVisitor::visitPlayerEndsGame(PlayerEndsGame & pack)
|
|||||||
adventureInt.reset();
|
adventureInt.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSH->showHighScoresAndEndGameplay(pack.player, pack.victoryLossCheckResult.victory());
|
CSH->showHighScoresAndEndGameplay(pack.player, pack.victoryLossCheckResult.victory(), pack.statistic);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In auto testing pack.mode we always close client if red pack.player won or lose
|
// In auto testing pack.mode we always close client if red pack.player won or lose
|
||||||
|
|||||||
1
client/lib/F2Native
Submodule
1
client/lib/F2Native
Submodule
Submodule client/lib/F2Native added at b1f3f4e817
@@ -33,6 +33,7 @@
|
|||||||
#include "../../lib/CCreatureHandler.h"
|
#include "../../lib/CCreatureHandler.h"
|
||||||
#include "../../lib/constants/EntityIdentifiers.h"
|
#include "../../lib/constants/EntityIdentifiers.h"
|
||||||
#include "../../lib/gameState/HighScore.h"
|
#include "../../lib/gameState/HighScore.h"
|
||||||
|
#include "../../lib/gameState/GameStatistics.h"
|
||||||
|
|
||||||
CHighScoreScreen::CHighScoreScreen(HighScorePage highscorepage, int highlighted)
|
CHighScoreScreen::CHighScoreScreen(HighScorePage highscorepage, int highlighted)
|
||||||
: CWindowObject(BORDERED), highscorepage(highscorepage), highlighted(highlighted)
|
: CWindowObject(BORDERED), highscorepage(highscorepage), highlighted(highlighted)
|
||||||
@@ -170,7 +171,7 @@ void CHighScoreScreen::buttonExitClick()
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc)
|
CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc, StatisticDataSet statistic)
|
||||||
: CWindowObject(BORDERED), won(won), calc(calc)
|
: CWindowObject(BORDERED), won(won), calc(calc)
|
||||||
{
|
{
|
||||||
addUsedEvents(LCLICK | KEYBOARD);
|
addUsedEvents(LCLICK | KEYBOARD);
|
||||||
@@ -204,6 +205,9 @@ CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc
|
|||||||
videoPlayer = std::make_shared<VideoWidgetOnce>(Point(0, 0), VideoPath::builtin("LOSEGAME.SMK"), true, [this](){close();});
|
videoPlayer = std::make_shared<VideoWidgetOnce>(Point(0, 0), VideoPath::builtin("LOSEGAME.SMK"), true, [this](){close();});
|
||||||
CCS->musich->playMusic(AudioPath::builtin("music/UltimateLose"), false, true);
|
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:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int CHighScoreInputScreen::addEntry(std::string text) {
|
int CHighScoreInputScreen::addEntry(std::string text) {
|
||||||
@@ -253,6 +257,9 @@ void CHighScoreInputScreen::show(Canvas & to)
|
|||||||
|
|
||||||
void CHighScoreInputScreen::clickPressed(const Point & cursorPosition)
|
void CHighScoreInputScreen::clickPressed(const Point & cursorPosition)
|
||||||
{
|
{
|
||||||
|
if(statisticButton->pos.isInside(cursorPosition))
|
||||||
|
return;
|
||||||
|
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||||
|
|
||||||
if(!won)
|
if(!won)
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class CFilledTexture;
|
|||||||
|
|
||||||
class TransparentFilledRectangle;
|
class TransparentFilledRectangle;
|
||||||
|
|
||||||
|
class StatisticDataSet;
|
||||||
|
|
||||||
class CHighScoreScreen : public CWindowObject
|
class CHighScoreScreen : public CWindowObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -76,10 +78,12 @@ class CHighScoreInputScreen : public CWindowObject
|
|||||||
std::shared_ptr<VideoWidgetBase> videoPlayer;
|
std::shared_ptr<VideoWidgetBase> videoPlayer;
|
||||||
std::shared_ptr<CFilledTexture> backgroundAroundMenu;
|
std::shared_ptr<CFilledTexture> backgroundAroundMenu;
|
||||||
|
|
||||||
|
std::shared_ptr<CButton> statisticButton;
|
||||||
|
|
||||||
bool won;
|
bool won;
|
||||||
HighScoreCalculation calc;
|
HighScoreCalculation calc;
|
||||||
public:
|
public:
|
||||||
CHighScoreInputScreen(bool won, HighScoreCalculation calc);
|
CHighScoreInputScreen(bool won, HighScoreCalculation calc, StatisticDataSet statistic);
|
||||||
|
|
||||||
int addEntry(std::string text);
|
int addEntry(std::string text);
|
||||||
|
|
||||||
|
|||||||
@@ -330,6 +330,7 @@ Rect CMultiLineLabel::getTextLocation()
|
|||||||
case ETextAlignment::TOPLEFT: return Rect(pos.topLeft(), textSize);
|
case ETextAlignment::TOPLEFT: return Rect(pos.topLeft(), textSize);
|
||||||
case ETextAlignment::TOPCENTER: return Rect(pos.topLeft(), textSize);
|
case ETextAlignment::TOPCENTER: return Rect(pos.topLeft(), textSize);
|
||||||
case ETextAlignment::CENTER: return Rect(pos.topLeft() + textOffset / 2, textSize);
|
case ETextAlignment::CENTER: return Rect(pos.topLeft() + textOffset / 2, textSize);
|
||||||
|
case ETextAlignment::CENTERRIGHT: return Rect(pos.topLeft() + Point(textOffset.x, textOffset.y / 2), textSize);
|
||||||
case ETextAlignment::BOTTOMRIGHT: return Rect(pos.topLeft() + textOffset, textSize);
|
case ETextAlignment::BOTTOMRIGHT: return Rect(pos.topLeft() + textOffset, textSize);
|
||||||
}
|
}
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "../gameState/RumorState.h"
|
#include "../gameState/RumorState.h"
|
||||||
#include "../gameState/QuestInfo.h"
|
#include "../gameState/QuestInfo.h"
|
||||||
#include "../gameState/TavernSlot.h"
|
#include "../gameState/TavernSlot.h"
|
||||||
|
#include "../gameState/GameStatistics.h"
|
||||||
#include "../int3.h"
|
#include "../int3.h"
|
||||||
#include "../mapping/CMapDefines.h"
|
#include "../mapping/CMapDefines.h"
|
||||||
#include "../spells/ViewSpellInt.h"
|
#include "../spells/ViewSpellInt.h"
|
||||||
@@ -435,6 +436,7 @@ struct DLL_LINKAGE PlayerEndsGame : public CPackForClient
|
|||||||
|
|
||||||
PlayerColor player;
|
PlayerColor player;
|
||||||
EVictoryLossCheckResult victoryLossCheckResult;
|
EVictoryLossCheckResult victoryLossCheckResult;
|
||||||
|
StatisticDataSet statistic;
|
||||||
|
|
||||||
void visitTyped(ICPackVisitor & visitor) override;
|
void visitTyped(ICPackVisitor & visitor) override;
|
||||||
|
|
||||||
@@ -442,6 +444,8 @@ struct DLL_LINKAGE PlayerEndsGame : public CPackForClient
|
|||||||
{
|
{
|
||||||
h & player;
|
h & player;
|
||||||
h & victoryLossCheckResult;
|
h & victoryLossCheckResult;
|
||||||
|
if (h.version >= Handler::Version::STATISTICS)
|
||||||
|
h & statistic;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3774,6 +3774,7 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
|
|||||||
PlayerEndsGame peg;
|
PlayerEndsGame peg;
|
||||||
peg.player = player;
|
peg.player = player;
|
||||||
peg.victoryLossCheckResult = victoryLossCheckResult;
|
peg.victoryLossCheckResult = victoryLossCheckResult;
|
||||||
|
peg.statistic = gameState()->statistic;
|
||||||
sendAndApply(&peg);
|
sendAndApply(&peg);
|
||||||
|
|
||||||
turnOrder->onPlayerEndsGame(player);
|
turnOrder->onPlayerEndsGame(player);
|
||||||
|
|||||||
Reference in New Issue
Block a user