Browse Source

Fixes for new battle settings

Dydzio 2 years ago
parent
commit
9101f05835

+ 3 - 3
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",

+ 20 - 5
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();
+}

+ 2 - 0
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);
 

+ 15 - 5
client/battle/BattleWindow.cpp

@@ -111,8 +111,19 @@ std::shared_ptr<BattleConsole> BattleWindow::buildBattleConsole(const JsonNode &
 	return std::make_shared<BattleConsole>(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)
 	{

+ 7 - 3
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<BattleConsole> 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);
 

+ 11 - 4
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)

+ 1 - 1
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: