SuperTuxKart
Loading...
Searching...
No Matches
story_mode_timer.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2006-2019 SuperTuxKart-Team
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_STORY_MODE_TIMER_HPP
20#define HEADER_STORY_MODE_TIMER_HPP
21
22#include "utils/types.hpp"
23#include <iomanip>
24
26{
27private:
28 bool m_valid_speedrun_started, m_valid_speedrun_ended;
29 bool m_story_mode_started, m_story_mode_ended;
30 bool m_speedrun_pause_active, m_story_mode_pause_active;
31 bool m_loading_pause;
32 bool m_player_tested;
33 bool m_player_can_speedrun;
34
35 //This stores the number of milliseconds to display with the counter
36 int m_speedrun_milliseconds;
37 int m_story_mode_milliseconds;
38
39 int m_stored_speedrun_milliseconds;
40 int m_stored_story_mode_milliseconds;
41
42 uint64_t m_speedrun_start;
43 uint64_t m_speedrun_end;
44 uint64_t m_speedrun_pause_start;
45
46 uint64_t m_story_mode_start;
47 uint64_t m_story_mode_end;
48 uint64_t m_story_mode_pause_start;
49
50 uint64_t m_speedrun_total_pause_time;
51 uint64_t m_story_mode_total_pause_time;
52
53 void testPlayerRun();
54
55 void pauseSpeedrunTimer();
56 void pauseStoryModeTimer();
57 void unpauseSpeedrunTimer();
58 void unpauseStoryModeTimer();
59 void updateSpeedrunTimer();
60 void updateStoryModeTimer();
61public:
62
64
65 // ------------------------------------------------------------------------
67 void startTimer();
68 void stopTimer();
69 void pauseTimer(bool loading);
70 void unpauseTimer(bool loading);
71 void updateTimer();
72 void reset();
73
74 void playerHasChanged();
75 std::string getTimerString();
76 bool playerLoaded() const { return m_player_tested; }
77 bool isStoryModePaused() const { return m_story_mode_pause_active; }
78 bool playerCanRun() const { return m_player_can_speedrun; }
79 bool isSpeedrunning() const { return m_valid_speedrun_started; }
80 bool speedrunIsFinished() const { return m_valid_speedrun_ended; }
81 int getStoryModeTime() const { return m_story_mode_milliseconds; }
82 int getSpeedrunTime() const { return m_speedrun_milliseconds; }
83}; // StoryModeTimer
84
85extern StoryModeTimer* story_mode_timer;
86
87#endif
88
89/* EOF */
Definition: story_mode_timer.hpp:26
void startTimer()
Speedrun timer functions.
Definition: story_mode_timer.cpp:102
Declares the general types that are used by the network.