1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix battle startup with "no intro sound" mod

This commit is contained in:
Ivan Savenko 2023-03-25 16:31:35 +02:00
parent 339bbce7b7
commit 2167cb2a68
2 changed files with 25 additions and 22 deletions

View File

@ -54,6 +54,7 @@ BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet *
, attackerInt(att)
, defenderInt(defen)
, curInt(att)
, battleOpeningDelayActive(true)
{
if(spectatorInt)
{
@ -112,7 +113,7 @@ void BattleInterface::playIntroSoundAndUnlockInterface()
}
};
battleIntroSoundChannel = CCS->soundh->playSoundFromSet(CCS->soundh->battleIntroSounds);
int battleIntroSoundChannel = CCS->soundh->playSoundFromSet(CCS->soundh->battleIntroSounds);
if (battleIntroSoundChannel != -1)
{
CCS->soundh->setCallback(battleIntroSoundChannel, onIntroPlayed);
@ -120,8 +121,15 @@ void BattleInterface::playIntroSoundAndUnlockInterface()
if (settings["gameTweaks"]["skipBattleIntroMusic"].Bool())
openingEnd();
}
else
else // failed to play sound
{
onIntroSoundPlayed();
}
}
bool BattleInterface::openingPlaying()
{
return battleOpeningDelayActive;
}
void BattleInterface::onIntroSoundPlayed()
@ -132,6 +140,19 @@ void BattleInterface::onIntroSoundPlayed()
CCS->musich->playMusicFromSet("battle", true, true);
}
void BattleInterface::openingEnd()
{
assert(openingPlaying());
if (!openingPlaying())
return;
onAnimationsFinished();
if(tacticsMode)
tacticNextStack(nullptr);
activateStack();
battleOpeningDelayActive = false;
}
BattleInterface::~BattleInterface()
{
CPlayerInterface::battleInt = nullptr;
@ -530,24 +551,6 @@ void BattleInterface::activateStack()
GH.fakeMouseMove();
}
bool BattleInterface::openingPlaying()
{
return battleIntroSoundChannel != -1;
}
void BattleInterface::openingEnd()
{
assert(openingPlaying());
if (!openingPlaying())
return;
onAnimationsFinished();
if(tacticsMode)
tacticNextStack(nullptr);
activateStack();
battleIntroSoundChannel = -1;
}
bool BattleInterface::makingTurn() const
{
return stacksController->getActiveStack() != nullptr;

View File

@ -111,8 +111,8 @@ class BattleInterface
/// defender interface, not null if attacker is human in our vcmiclient
std::shared_ptr<CPlayerInterface> defenderInt;
/// ID of channel on which battle opening sound is playing, or -1 if none
int battleIntroSoundChannel;
/// if set to true, battle is still starting and waiting for intro sound to end / key press from player
bool battleOpeningDelayActive;
void playIntroSoundAndUnlockInterface();
void onIntroSoundPlayed();