Working on loading

This commit is contained in:
Vladislav Khorev committed 2026-10-23 23:49:54 +06:00
1 parent d38a75ea72
commit 9b71ee447a
11 files changed
+268 -55

No files matched your search

+21 -1
View File
@@ -325,6 +325,11 @@ namespace FRG {
languageScreenRoot = loadLocalizedUi("resources/w/ui/screen_language.json", zipFile);
loadSavedGameScreenRoot = loadLocalizedUi("resources/w/ui/screen_load.json", zipFile);
campaignScreenRoot = loadLocalizedUi("resources/w/ui/screen_campaign.json", zipFile);
loadingScreenRoots_.clear();
for (const CampaignConfig& campaign : CampaignRegistry::instance().all()) {
if (!loadingScreenRoots_.count(campaign.loadingScreenPath))
loadingScreenRoots_[campaign.loadingScreenPath] = loadLocalizedUi(campaign.loadingScreenPath, zipFile);
}
saveGameScreenRoot = loadLocalizedUi("resources/w/ui/screen_save.json", zipFile);
}
@@ -385,6 +390,21 @@ namespace FRG {
if (startGameFunc) startGameFunc(campaignId);
}
void MenuManager::showLoadingScreen(const std::string& layoutPath) {
auto it = loadingScreenRoots_.find(layoutPath);
if (it == loadingScreenRoots_.end() || !it->second) {
std::cerr << "[menu] Loading screen not preloaded: " << layoutPath << std::endl;
return; // Game falls back to the startup loading image
}
loadingUiManager.replaceRoot(it->second);
loadingScreenShown_ = true;
}
void MenuManager::hideLoadingScreen() {
loadingUiManager.replaceRoot(nullptr);
loadingScreenShown_ = false;
}
void MenuManager::enterGameplay(bool isFromLoad) {
if (isFromLoad) {
uiManager.clearMenuStack();
@@ -1080,8 +1100,8 @@ namespace FRG {
}
uiManager.setTextButtonCallback(kSlotButtons[i], [this, slot](const std::string&) {
audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
// Game enters gameplay itself once the save (and its campaign) is loaded.
if (onLoadGame) onLoadGame(slot);
enterGameplay(true);
});
}
}