- some bug fixes
- added race details
This commit is contained in:
parent
9a81d87451
commit
ef8ceff27e
4 changed files with 37 additions and 21 deletions
|
@ -62,7 +62,8 @@ public:
|
|||
TimersChanged = 9001,
|
||||
ExtensionsChanged = 9002,
|
||||
CurrentStartDelayChanged = 9003, /*, ProfilesChanged*/
|
||||
SettingChanged = 9004
|
||||
SettingChanged = 9004,
|
||||
RaceDetailsChanged = 9005
|
||||
};
|
||||
Q_ENUM(SignalKey)
|
||||
|
||||
|
@ -82,7 +83,7 @@ public:
|
|||
CancelRaceCommand = 1003,
|
||||
|
||||
GetRaceStateCommand = 2000,
|
||||
GetNextStartActionCommand = 2005,
|
||||
GetRaceDetailsCommand = 2001,
|
||||
GetExtensionsCommand = 2006,
|
||||
GetTimersCommand = 2007,
|
||||
GetCurrentStartDelayCommand = 2009,
|
||||
|
|
|
@ -52,6 +52,7 @@ class ScStwRace : public QObject
|
|||
Q_PROPERTY(RaceState state READ getState NOTIFY stateChanged)
|
||||
Q_PROPERTY(QVariantList timers READ getTimerDetailList NOTIFY timersChanged)
|
||||
Q_PROPERTY(QVariantList currentStartDelay READ getCurrentStartDelay NOTIFY currentStartDelayChanged)
|
||||
Q_PROPERTY(QVariantMap details READ getDetails NOTIFY detailsChanged)
|
||||
|
||||
public:
|
||||
explicit ScStwRace(QObject *parent = nullptr);
|
||||
|
@ -133,6 +134,7 @@ public slots:
|
|||
virtual QVariantList getCurrentStartDelay();
|
||||
QList<ScStwTimer*> getTimers();
|
||||
QVariantList getTimerDetailList();
|
||||
QVariantMap getDetails();
|
||||
|
||||
protected slots:
|
||||
|
||||
|
@ -152,6 +154,7 @@ private slots:
|
|||
|
||||
bool isStarting();
|
||||
bool isReadyForNextState();
|
||||
void handleTimerReadyStateChange(ScStwTimer::ReadyState readyState);
|
||||
|
||||
signals:
|
||||
void startTimers();
|
||||
|
@ -160,6 +163,7 @@ signals:
|
|||
void stateChanged(RaceState state);
|
||||
void currentStartDelayChanged();
|
||||
void timersChanged();
|
||||
void detailsChanged();
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -32,6 +32,9 @@ ScStwRace::ScStwRace(QObject *parent) : QObject(parent)
|
|||
|
||||
connect(this->startDelayTimer, &QTimer::timeout, this->startWaitLoop, &QEventLoop::quit);
|
||||
|
||||
connect(this, &ScStwRace::currentStartDelayChanged, this, &ScStwRace::detailsChanged);
|
||||
connect(this, &ScStwRace::timersChanged, this, &ScStwRace::detailsChanged);
|
||||
|
||||
// write default settings
|
||||
this->startSoundSettings.insert(ScStwSoundPlayer::Start, {{"Enabled", true}, {"Delay", 1}});
|
||||
this->writeStartSoundSetting(ScStwSoundPlayer::AtYourMarks, false, 0);
|
||||
|
@ -198,7 +201,8 @@ int ScStwRace::handleFalseStart() {
|
|||
}
|
||||
|
||||
this->setState(STOPPED);
|
||||
this->soundPlayer->cancel(this->soundVolume);
|
||||
this->soundPlayer->cancel();
|
||||
this->soundPlayer->play(ScStwSoundPlayer::FalseStart, this->soundVolume);
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
@ -597,10 +601,11 @@ bool ScStwRace::addTimer(ScStwTimer *timer) {
|
|||
this->timers.append(timer);
|
||||
|
||||
connect(timer, &ScStwTimer::stateChanged, this, &ScStwRace::refreshTimerStates);
|
||||
connect(timer, &ScStwTimer::wantsToBeDisabledChanged, this, &ScStwRace::handleTimerWantsToBeDisabledChange);
|
||||
connect(timer, &ScStwTimer::stateChanged, this, &ScStwRace::timersChanged);
|
||||
connect(timer, &ScStwTimer::wantsToBeDisabledChanged, this, &ScStwRace::handleTimerWantsToBeDisabledChange);
|
||||
connect(timer, &ScStwTimer::reactionTimeChanged, this, &ScStwRace::timersChanged);
|
||||
connect(timer, &ScStwTimer::readyStateChanged, this->startWaitLoop, &QEventLoop::quit);
|
||||
connect(timer, &ScStwTimer::readyStateChanged, this, &ScStwRace::handleTimerReadyStateChange);
|
||||
|
||||
if(this->competitionMode && timer->getState() == ScStwTimer::DISABLED)
|
||||
timer->setDisabled(false);
|
||||
|
@ -628,12 +633,35 @@ QVariantList ScStwRace::getTimerDetailList() {
|
|||
tmpTimer.insert("reactionTime", timer->getReactionTime());
|
||||
tmpTimer.insert("text", timer->getText());
|
||||
tmpTimer.insert("letter", timer->getLetter());
|
||||
tmpTimer.insert("readyState", timer->getReadyState());
|
||||
tmpTimers.append(tmpTimer);
|
||||
}
|
||||
|
||||
return tmpTimers;
|
||||
}
|
||||
|
||||
QVariantMap ScStwRace::getDetails() {
|
||||
QVariantMap tmpDetails;
|
||||
|
||||
tmpDetails.insert("timers", this->getTimerDetailList());
|
||||
tmpDetails.insert("currentStartDelay", this->getCurrentStartDelay());
|
||||
tmpDetails.insert("competitionMode", this->competitionMode);
|
||||
tmpDetails.insert("readySoundEnabled", this->startSoundSettings[ScStwSoundPlayer::Ready]["Enabled"].toBool());
|
||||
|
||||
if(this->state == WAITING)
|
||||
tmpDetails.insert("isReady", this->isReadyForNextState());
|
||||
|
||||
return tmpDetails;
|
||||
}
|
||||
|
||||
bool ScStwRace::isStarting() {
|
||||
return this->state == PREPAIRING || this->state == WAITING || this->state == STARTING;
|
||||
}
|
||||
|
||||
void ScStwRace::handleTimerReadyStateChange(ScStwTimer::ReadyState readyState) {
|
||||
Q_UNUSED(readyState)
|
||||
|
||||
// only continue if the current state is waiting
|
||||
if(this->state == WAITING)
|
||||
emit this->timersChanged();
|
||||
}
|
||||
|
|
|
@ -39,9 +39,6 @@ bool ScStwSoundPlayer::play(ScStwSoundPlayer::StartSound sound, double volume, d
|
|||
if(!this->soundFiles.contains(sound))
|
||||
return false;
|
||||
|
||||
if(sound > Start || sound < AtYourMarks)
|
||||
return false;
|
||||
|
||||
// stop playback
|
||||
if(this->soundEffect->isPlaying())
|
||||
this->soundEffect->stop();
|
||||
|
@ -89,20 +86,6 @@ bool ScStwSoundPlayer::cancel(double volume) {
|
|||
// stop playback
|
||||
this->soundEffect->stop();
|
||||
this->waitLoop->quit();
|
||||
|
||||
if(this->currentlyPlayingSound != Start)
|
||||
return true;
|
||||
|
||||
// update volume
|
||||
this->soundEffect->setVolume(volume);
|
||||
|
||||
// load
|
||||
this->soundEffect->setSource(this->soundFiles[FalseStart]["path"].toString());
|
||||
|
||||
// play
|
||||
this->soundEffect->play();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScStwSoundPlayer::waitForSoundFinish(double *timeOfStop) {
|
||||
|
|
Reference in a new issue