From f3d48ecc3a12669067553abbe4772e93ece1df19 Mon Sep 17 00:00:00 2001 From: George King <98261225+GeorgeK1ng@users.noreply.github.com> Date: Wed, 8 Jan 2025 00:16:55 +0100 Subject: [PATCH] Ability to use random progress bar --- client/mainmenu/CMainMenu.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/client/mainmenu/CMainMenu.cpp b/client/mainmenu/CMainMenu.cpp index 45c8195df..34232cdcf 100644 --- a/client/mainmenu/CMainMenu.cpp +++ b/client/mainmenu/CMainMenu.cpp @@ -688,22 +688,31 @@ CLoadingScreen::CLoadingScreen(ImagePath background) : CWindowObject(BORDERED, background) { OBJECT_CONSTRUCTION; - + addUsedEvents(TIME); - + CCS->musich->stopMusic(5000); - - const auto & conf = CMainMenuConfig::get().getConfig()["loading"]; - if(conf.isStruct()) + + const auto& conf = CMainMenuConfig::get().getConfig()["loading"]; + const auto& nameConfig = conf["name"]; + + AnimationPath animationPath; + if (nameConfig.isVector() && !nameConfig.Vector().empty()) + animationPath = AnimationPath::fromJson(*RandomGeneratorUtil::nextItem(nameConfig.Vector(), CRandomGenerator::getDefault())); + + if (nameConfig.isString()) + animationPath = AnimationPath::fromJson(nameConfig); + + if (conf.isStruct()) { const int posx = conf["x"].Integer(); const int posy = conf["y"].Integer(); const int blockSize = conf["size"].Integer(); const int blocksAmount = conf["amount"].Integer(); - for(int i = 0; i < blocksAmount; ++i) + for (int i = 0; i < blocksAmount; ++i) { - progressBlocks.push_back(std::make_shared(AnimationPath::fromJson(conf["name"]), i, 0, posx + i * blockSize, posy)); + progressBlocks.push_back(std::make_shared(animationPath, i, 0, posx + i * blockSize, posy)); progressBlocks.back()->deactivate(); progressBlocks.back()->visible = false; }