diff --git a/Mods/vcmi/config/vcmi/english.json b/Mods/vcmi/config/vcmi/english.json index f95d16989..4bd2ef296 100644 --- a/Mods/vcmi/config/vcmi/english.json +++ b/Mods/vcmi/config/vcmi/english.json @@ -58,13 +58,13 @@ "vcmi.battleOptions.showQueue.hover": "Show queue", "vcmi.battleOptions.showQueue.help": "{Show queue}\n\n Show queue that displays movement order of creature stacks.", - "vcmi.battleOptions.queueSizeLabel.hover": "Queue size", + "vcmi.battleOptions.queueSizeLabel.hover": "Queue size (takes effect on next battle)", "vcmi.battleOptions.queueSizeAutoButton.hover": "AUTO", - "vcmi.battleOptions.queueSizeAutoButton.help": "Sets queue size depending on game resolution", + "vcmi.battleOptions.queueSizeAutoButton.help": "Sets queue size depending on game resolution (small if width < 700 pixels, big otherwise)", "vcmi.battleOptions.queueSizeSmallButton.hover": "SMALL", "vcmi.battleOptions.queueSizeSmallButton.help": "Sets queue size to small", "vcmi.battleOptions.queueSizeBigButton.hover": "BIG", - "vcmi.battleOptions.queueSizeBigButton.help": "Sets queue size to big", + "vcmi.battleOptions.queueSizeBigButton.help": "Sets queue size to big (not supported if game resolution width < 700 pixels)", "vcmi.battleOptions.animationsSpeed4.hover": "4", "vcmi.battleOptions.animationsSpeed4.help": "Sets animation speed to very fast", "vcmi.battleOptions.animationsSpeed5.hover": "5", diff --git a/client/battle/BattleInterface.cpp b/client/battle/BattleInterface.cpp index d40ee7c4f..227a54fe1 100644 --- a/client/battle/BattleInterface.cpp +++ b/client/battle/BattleInterface.cpp @@ -97,7 +97,17 @@ BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet * CCS->musich->stopMusic(); setAnimationCondition(EAnimationEvents::OPENING, true); - battleIntroSoundChannel = CCS->soundh->playSoundFromSet(CCS->soundh->battleIntroSounds); + + GH.pushInt(windowObject); + windowObject->blockUI(true); + windowObject->updateQueue(); + + if(settings["gameTweaks"]["skipBattleIntroMusic"].Bool()) + { + onIntroSoundPlayed(); + return; + } + auto onIntroPlayed = [this]() { if(LOCPLINT->battleInt) @@ -107,10 +117,7 @@ BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet * } }; - GH.pushInt(windowObject); - windowObject->blockUI(true); - windowObject->updateQueue(); - + battleIntroSoundChannel = CCS->soundh->playSoundFromSet(CCS->soundh->battleIntroSounds); if (battleIntroSoundChannel != -1) CCS->soundh->setCallback(battleIntroSoundChannel, onIntroPlayed); else @@ -734,3 +741,11 @@ void BattleInterface::executeOnAnimationCondition( EAnimationEvents event, bool { awaitingEvents.push_back({action, event, state}); } + +void BattleInterface::setBattleQueueVisibility(bool visible) +{ + if(visible) + windowObject->showQueue(); + else + windowObject->hideQueue(); +} \ No newline at end of file diff --git a/client/battle/BattleInterface.h b/client/battle/BattleInterface.h index e000d5f19..ff811172a 100644 --- a/client/battle/BattleInterface.h +++ b/client/battle/BattleInterface.h @@ -175,6 +175,8 @@ public: void tacticNextStack(const CStack *current); void tacticPhaseEnd(); + void setBattleQueueVisibility(bool visible); + /// sets condition to targeted state and executes any awaiting actions void setAnimationCondition( EAnimationEvents event, bool state); diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index 4a3ac8454..d6f2b67e6 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -111,8 +111,19 @@ std::shared_ptr BattleWindow::buildBattleConsole(const JsonNode & return std::make_shared(background, rect.topLeft(), offset, rect.dimensions() ); } +void BattleWindow::toggleQueueVisibility() +{ + if(settings["battle"]["showQueue"].Bool()) + hideQueue(); + else + showQueue(); +} + void BattleWindow::hideQueue() { + if(settings["battle"]["showQueue"].Bool() == false) + return; + Settings showQueue = settings.write["battle"]["showQueue"]; showQueue->Bool() = false; @@ -130,6 +141,9 @@ void BattleWindow::hideQueue() void BattleWindow::showQueue() { + if(settings["battle"]["showQueue"].Bool() == true) + return; + Settings showQueue = settings.write["battle"]["showQueue"]; showQueue->Bool() = true; @@ -167,11 +181,7 @@ void BattleWindow::keyPressed(const SDL_Keycode & key) { if(key == SDLK_q) { - if(settings["battle"]["showQueue"].Bool()) //hide queue - hideQueue(); - else - showQueue(); - + toggleQueueVisibility(); } else if(key == SDLK_f) { diff --git a/client/battle/BattleWindow.h b/client/battle/BattleWindow.h index 702684104..32df209a6 100644 --- a/client/battle/BattleWindow.h +++ b/client/battle/BattleWindow.h @@ -55,9 +55,9 @@ class BattleWindow : public InterfaceObjectConfigurable PossiblePlayerBattleAction defaultAction; void showAlternativeActionIcon(PossiblePlayerBattleAction); - /// Toggle StackQueue visibility - void hideQueue(); - void showQueue(); + /// flip battle queue visibility to opposite + void toggleQueueVisibility(); + std::shared_ptr buildBattleConsole(const JsonNode &) const; @@ -68,6 +68,10 @@ public: /// Closes window once battle finished void close(); + /// Toggle StackQueue visibility + void hideQueue(); + void showQueue(); + /// block all UI elements when player is not allowed to act, e.g. during enemy turn void blockUI(bool on); diff --git a/client/windows/settings/BattleOptionsTab.cpp b/client/windows/settings/BattleOptionsTab.cpp index 04ccf1d62..42ef9a4d1 100644 --- a/client/windows/settings/BattleOptionsTab.cpp +++ b/client/windows/settings/BattleOptionsTab.cpp @@ -28,7 +28,7 @@ BattleOptionsTab::BattleOptionsTab(BattleInterface * owner): addCallback("movementShadowChanged", std::bind(&BattleOptionsTab::movementShadowChangedCallback, this, _1, owner)); addCallback("mouseShadowChanged", std::bind(&BattleOptionsTab::mouseShadowChangedCallback, this, _1)); addCallback("animationSpeedChanged", std::bind(&BattleOptionsTab::animationSpeedChangedCallback, this, _1)); - addCallback("showQueueChanged", std::bind(&BattleOptionsTab::showQueueChangedCallback, this, _1)); + addCallback("showQueueChanged", std::bind(&BattleOptionsTab::showQueueChangedCallback, this, _1, owner)); addCallback("queueSizeChanged", std::bind(&BattleOptionsTab::queueSizeChangedCallback, this, _1)); addCallback("skipBattleIntroMusicChanged", std::bind(&BattleOptionsTab::skipBattleIntroMusicChangedCallback, this, _1)); build(config); @@ -119,10 +119,17 @@ void BattleOptionsTab::animationSpeedChangedCallback(int value) speed->Float() = float(value); } -void BattleOptionsTab::showQueueChangedCallback(bool value) +void BattleOptionsTab::showQueueChangedCallback(bool value, BattleInterface * parentBattleInterface) { - Settings shadow = settings.write["battle"]["showQueue"]; - shadow->Bool() = value; + if(!parentBattleInterface) + { + Settings showQueue = settings.write["battle"]["showQueue"]; + showQueue->Bool() = value; + } + else + { + parentBattleInterface->setBattleQueueVisibility(value); + } } void BattleOptionsTab::queueSizeChangedCallback(int value) diff --git a/client/windows/settings/BattleOptionsTab.h b/client/windows/settings/BattleOptionsTab.h index 12db8fd01..6056de1ac 100644 --- a/client/windows/settings/BattleOptionsTab.h +++ b/client/windows/settings/BattleOptionsTab.h @@ -25,7 +25,7 @@ private: void movementShadowChangedCallback(bool value, BattleInterface * parentBattleInterface = nullptr); void mouseShadowChangedCallback(bool value); void animationSpeedChangedCallback(int value); - void showQueueChangedCallback(bool value); + void showQueueChangedCallback(bool value, BattleInterface * parentBattleInterface = nullptr); void queueSizeChangedCallback(int value); void skipBattleIntroMusicChangedCallback(bool value); public: