1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Initial part of dynamically-sized adventure map:

- removed no longer used CConfigHandler
- remove no longer use resolutions.json
- moved widget management from adventure map to a separate class
- adventure map layout is now loaded from config
This commit is contained in:
Ivan Savenko
2023-04-26 15:44:10 +03:00
parent cb8201876b
commit a015bf6507
28 changed files with 1335 additions and 884 deletions

View File

@ -17,10 +17,7 @@
VCMI_LIB_NAMESPACE_BEGIN
using namespace config;
SettingsStorage settings;
CConfigHandler conf;
template<typename Accessor>
SettingsStorage::NodeAccessor<Accessor>::NodeAccessor(SettingsStorage & _parent, std::vector<std::string> _path):
@ -178,123 +175,6 @@ JsonNode & Settings::operator[](const std::string & value)
{
return node[value];
}
//
// template DLL_LINKAGE struct SettingsStorage::NodeAccessor<SettingsListener>;
// template DLL_LINKAGE struct SettingsStorage::NodeAccessor<Settings>;
static void setButton(ButtonInfo &button, const JsonNode &g)
{
button.x = static_cast<int>(g["x"].Float());
button.y = static_cast<int>(g["y"].Float());
button.playerColoured = g["playerColoured"].Float();
button.defName = g["graphic"].String();
if (!g["additionalDefs"].isNull()) {
const JsonVector &defs_vec = g["additionalDefs"].Vector();
for(const JsonNode &def : defs_vec) {
button.additionalDefs.push_back(def.String());
}
}
}
static void setGem(AdventureMapConfig &ac, const int gem, const JsonNode &g)
{
ac.gemX[gem] = static_cast<int>(g["x"].Float());
ac.gemY[gem] = static_cast<int>(g["y"].Float());
ac.gemG.push_back(g["graphic"].String());
}
CConfigHandler::CConfigHandler()
: current(nullptr)
{
}
void config::CConfigHandler::init()
{
/* Read resolutions. */
const JsonNode config(ResourceID("config/resolutions.json"));
const JsonVector &guisettings_vec = config["GUISettings"].Vector();
for(const JsonNode &g : guisettings_vec)
{
std::pair<int, int> curRes(static_cast<int>(g["resolution"]["x"].Float()), static_cast<int>(g["resolution"]["y"].Float()));
GUIOptions *current = &conf.guiOptions[curRes];
current->ac.inputLineLength = static_cast<int>(g["InGameConsole"]["maxInputPerLine"].Float());
current->ac.outputLineLength = static_cast<int>(g["InGameConsole"]["maxOutputPerLine"].Float());
current->ac.advmapX = static_cast<int>(g["AdvMap"]["x"].Float());
current->ac.advmapY = static_cast<int>(g["AdvMap"]["y"].Float());
current->ac.advmapW = static_cast<int>(g["AdvMap"]["width"].Float());
current->ac.advmapH = static_cast<int>(g["AdvMap"]["height"].Float());
current->ac.smoothMove = g["AdvMap"]["smoothMove"].Float();
current->ac.puzzleSepia = g["AdvMap"]["puzzleSepia"].Float();
current->ac.screenFading = g["AdvMap"]["screenFading"].isNull() ? true : g["AdvMap"]["screenFading"].Float(); // enabled by default
current->ac.objectFading = g["AdvMap"]["objectFading"].isNull() ? true : g["AdvMap"]["objectFading"].Float();
current->ac.infoboxX = static_cast<int>(g["InfoBox"]["x"].Float());
current->ac.infoboxY = static_cast<int>(g["InfoBox"]["y"].Float());
setGem(current->ac, 0, g["gem0"]);
setGem(current->ac, 1, g["gem1"]);
setGem(current->ac, 2, g["gem2"]);
setGem(current->ac, 3, g["gem3"]);
current->ac.mainGraphic = g["background"].String();
current->ac.worldViewGraphic = g["backgroundWorldView"].String();
current->ac.hlistX = static_cast<int>(g["HeroList"]["x"].Float());
current->ac.hlistY = static_cast<int>(g["HeroList"]["y"].Float());
current->ac.hlistSize = static_cast<int>(g["HeroList"]["size"].Float());
current->ac.hlistMB = g["HeroList"]["movePoints"].String();
current->ac.hlistMN = g["HeroList"]["manaPoints"].String();
current->ac.hlistAU = g["HeroList"]["arrowUp"].String();
current->ac.hlistAD = g["HeroList"]["arrowDown"].String();
current->ac.tlistX = static_cast<int>(g["TownList"]["x"].Float());
current->ac.tlistY = static_cast<int>(g["TownList"]["y"].Float());
current->ac.tlistSize = static_cast<int>(g["TownList"]["size"].Float());
current->ac.tlistAU = g["TownList"]["arrowUp"].String();
current->ac.tlistAD = g["TownList"]["arrowDown"].String();
current->ac.minimapW = static_cast<int>(g["Minimap"]["width"].Float());
current->ac.minimapH = static_cast<int>(g["Minimap"]["height"].Float());
current->ac.minimapX = static_cast<int>(g["Minimap"]["x"].Float());
current->ac.minimapY = static_cast<int>(g["Minimap"]["y"].Float());
current->ac.overviewPics = static_cast<int>(g["Overview"]["pics"].Float());
current->ac.overviewSize = static_cast<int>(g["Overview"]["size"].Float());
current->ac.overviewBg = g["Overview"]["graphic"].String();
current->ac.statusbarX = static_cast<int>(g["Statusbar"]["x"].Float());
current->ac.statusbarY = static_cast<int>(g["Statusbar"]["y"].Float());
current->ac.statusbarG = g["Statusbar"]["graphic"].String();
current->ac.resdatabarX = static_cast<int>(g["ResDataBar"]["x"].Float());
current->ac.resdatabarY = static_cast<int>(g["ResDataBar"]["y"].Float());
current->ac.resOffsetX = static_cast<int>(g["ResDataBar"]["offsetX"].Float());
current->ac.resOffsetY = static_cast<int>(g["ResDataBar"]["offsetY"].Float());
current->ac.resDist = static_cast<int>(g["ResDataBar"]["resSpace"].Float());
current->ac.resDateDist = static_cast<int>(g["ResDataBar"]["resDateSpace"].Float());
current->ac.resdatabarG = g["ResDataBar"]["graphic"].String();
setButton(current->ac.kingOverview, g["ButtonKingdomOv"]);
setButton(current->ac.underground, g["ButtonUnderground"]);
setButton(current->ac.questlog, g["ButtonQuestLog"]);
setButton(current->ac.sleepWake, g["ButtonSleepWake"]);
setButton(current->ac.moveHero, g["ButtonMoveHero"]);
setButton(current->ac.spellbook, g["ButtonSpellbook"]);
setButton(current->ac.advOptions, g["ButtonAdvOptions"]);
setButton(current->ac.sysOptions, g["ButtonSysOptions"]);
setButton(current->ac.nextHero, g["ButtonNextHero"]);
setButton(current->ac.endTurn, g["ButtonEndTurn"]);
}
const JsonNode& screenRes = settings["video"]["screenRes"];
SetResolution(static_cast<int>(screenRes["width"].Float()), static_cast<int>(screenRes["height"].Float()));
}
// Force instantiation of the SettingsStorage::NodeAccessor class template.
// That way method definitions can sit in the cpp file