1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

make configurable

This commit is contained in:
Laserlicht
2025-07-05 16:27:20 +02:00
parent d81e035c98
commit 15a1373911
4 changed files with 16 additions and 8 deletions

View File

@@ -279,15 +279,17 @@ int CHighScoreInputScreen::addEntry(std::string text) {
ser.serializeStruct("statistic", stat); ser.serializeStruct("statistic", stat);
} }
if (baseNode.size() > HIGHSCORE_ROW_SAVE - 1) int highscoreEntriesCap = settings["general"]["highscoreEntriesCap"].Integer();
baseNode.resize(HIGHSCORE_ROW_SAVE - 1); if (baseNode.size() > highscoreEntriesCap - 1)
baseNode.resize(highscoreEntriesCap - 1);
baseNode.push_back(newNode); baseNode.push_back(newNode);
boost::range::sort(baseNode, sortFunctor); boost::range::sort(baseNode, sortFunctor);
int pos = -1; int pos = -1;
for (int i = 0; i < baseNode.size(); i++) for (int i = 0; i < baseNode.size(); i++)
{ {
if(!baseNode[i]["statistic"].isNull() && i >= Statistic::STAT_ROW_SAVE && baseNode[i]["posFlag"].isNull()) if(!baseNode[i]["statistic"].isNull() && i >= settings["general"]["highscoreStatisticEntriesCap"].Integer() && baseNode[i]["posFlag"].isNull())
baseNode[i]["statistic"].clear(); baseNode[i]["statistic"].clear();
if(!baseNode[i]["posFlag"].isNull()) if(!baseNode[i]["posFlag"].isNull())

View File

@@ -76,8 +76,6 @@ public:
class CHighScoreInputScreen : public CWindowObject, public IVideoHolder class CHighScoreInputScreen : public CWindowObject, public IVideoHolder
{ {
const int HIGHSCORE_ROW_SAVE = 100;
std::vector<std::shared_ptr<CLabel>> texts; std::vector<std::shared_ptr<CLabel>> texts;
std::shared_ptr<CHighScoreInput> input; std::shared_ptr<CHighScoreInput> input;
std::shared_ptr<TransparentFilledRectangle> background; std::shared_ptr<TransparentFilledRectangle> background;

View File

@@ -46,7 +46,9 @@
"enableOverlay", "enableOverlay",
"lastKindomInterface", "lastKindomInterface",
"enableSubtitle", "enableSubtitle",
"ignoreMuteSwitch" "ignoreMuteSwitch",
"highscoreEntriesCap",
"highscoreStatisticEntriesCap"
], ],
"properties" : { "properties" : {
"playerName" : { "playerName" : {
@@ -166,6 +168,14 @@
"ignoreMuteSwitch" : { "ignoreMuteSwitch" : {
"type": "boolean", "type": "boolean",
"default": true "default": true
},
"highscoreEntriesCap" : {
"type" : "number",
"default" : 100
},
"highscoreStatisticEntriesCap" : {
"type" : "number",
"default" : 15
} }
} }
}, },

View File

@@ -155,8 +155,6 @@ public:
class DLL_LINKAGE Statistic class DLL_LINKAGE Statistic
{ {
public: public:
static const int STAT_ROW_SAVE = 15;
static int getNumberOfArts(const PlayerState * ps); static int getNumberOfArts(const PlayerState * ps);
static int getNumberOfDwellings(const PlayerState * ps); static int getNumberOfDwellings(const PlayerState * ps);
static si64 getArmyStrength(const PlayerState * ps, bool withTownGarrison = false); static si64 getArmyStrength(const PlayerState * ps, bool withTownGarrison = false);