#ifndef SCSTWRACE_H #define SCSTWRACE_H #include #include #include #include #include "scstwtimer.h" #include "scstwsoundplayer.h" class ScStwRace : public QObject { Q_OBJECT Q_PROPERTY(RaceState state READ getState NOTIFY stateChanged) public: explicit ScStwRace(QObject *parent = nullptr); enum RaceState { IDLE, STARTING, WAITING, RUNNING, STOPPED }; Q_ENUM(RaceState) enum StartAction { None = -1, AtYourMarks, Ready, Start }; Q_ENUM(StartAction) private: RaceState state; QList timers; QList timerEnableQueque; QTimer *nextActionTimer; QEventLoop *nextActionLoop; // sounds ScStwSoundPlayer * soundPlayer; StartAction nextStartAction; // some settings double soundVolume; /*! * \brief stores the start action settings * * \details Stores the settings for the action ScStwRace::AtYourMarks and ScStwRace::Ready. The settings keys are: "Enabled" and "Delay" */ QMap startActionSettings; void setState(RaceState newState); public slots: int start(); int stop(); void handleTimerStop(); int reset(); void cancelStart(bool falseStart); QVariantMap getNextStartActionDetails(); bool writeStartActionSetting(StartAction action, bool enabled, int delay); bool setSoundVolume(double volume); bool addTimer(ScStwTimer *timer); RaceState getState(); StartAction getNextStartAction(); QVariantList getTimerDetailList(); private slots: void refreshTimerStates(); void handleTimerEnable(ScStwTimer* timer); bool playSoundsAndStartTimers(StartAction thisAction); signals: void startTimers(); void stopTimers(int type); void resetTimers(); void stateChanged(RaceState state); void nextStartActionChanged(); }; #endif // SCSTWRACE_H