From 46c62ba1873da9120af2cf9ec0b98a7f4cd28c79 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Sat, 3 Oct 2020 13:49:56 +0200 Subject: [PATCH] fixed getCUrrentStartDelay returning crap --- ScStwLibraries/headers/scstwsoundplayer.h | 2 ++ ScStwLibraries/sources/scstwrace.cpp | 8 +++++--- ScStwLibraries/sources/scstwsoundplayer.cpp | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ScStwLibraries/headers/scstwsoundplayer.h b/ScStwLibraries/headers/scstwsoundplayer.h index 82a8436..3356a51 100644 --- a/ScStwLibraries/headers/scstwsoundplayer.h +++ b/ScStwLibraries/headers/scstwsoundplayer.h @@ -112,6 +112,8 @@ public slots: */ bool cancel(); + bool isPlaying(); + private slots: signals: diff --git a/ScStwLibraries/sources/scstwrace.cpp b/ScStwLibraries/sources/scstwrace.cpp index be715c1..86a60af 100644 --- a/ScStwLibraries/sources/scstwrace.cpp +++ b/ScStwLibraries/sources/scstwrace.cpp @@ -556,6 +556,7 @@ QVariantMap ScStwRace::getCurrentStartDelay() { currentStartDelay["progress"] = 0; return currentStartDelay; } + break; case PREPAIRING: { if(!this->startSoundSettings[ScStwSoundPlayer::AtYourMarks]["Enabled"].toBool()) return currentStartDelay; @@ -571,10 +572,11 @@ QVariantMap ScStwRace::getCurrentStartDelay() { // get the total delay and the delay progress of the next action timer double remaining = this->startDelayTimer->remainingTime(); + + if(remaining < 0) + return currentStartDelay; + currentStartDelay["total"] = this->startDelayTimer->interval(); - if(remaining < 0) { - remaining = currentStartDelay["total"].toDouble(); - } currentStartDelay["progress"] = 1 - (remaining / currentStartDelay["total"].toDouble()); if(currentStartDelay["progress"].toDouble() < 0) diff --git a/ScStwLibraries/sources/scstwsoundplayer.cpp b/ScStwLibraries/sources/scstwsoundplayer.cpp index 943513b..e68caee 100644 --- a/ScStwLibraries/sources/scstwsoundplayer.cpp +++ b/ScStwLibraries/sources/scstwsoundplayer.cpp @@ -115,3 +115,7 @@ bool ScStwSoundPlayer::waitForSoundFinish(double *timeOfStop) { return true; } + +bool ScStwSoundPlayer::isPlaying() { + return this->soundEffect->isPlaying(); +}