The Battle for Wesnoth
1.21.0-dev
Loading...
Searching...
No Matches
countdown_clock.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2017 - 2025
3
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY.
11
12
See the COPYING file for more details.
13
*/
14
15
#pragma once
16
17
#include "
events.hpp
"
18
#include <chrono>
19
20
class
team
;
21
class
countdown_clock
:
public
events::pump_monitor
22
{
23
using
clock
= std::chrono::steady_clock;
24
25
public
:
26
countdown_clock
(
team
&
team
);
27
~countdown_clock
();
28
29
/** @returns ticks passed since last update */
30
std::chrono::milliseconds
update_timestamp
();
31
32
void
update_team
();
33
34
/** Inherited from pump_monitor */
35
virtual
void
process
()
override
;
36
37
/** @returns whether there is time left */
38
bool
update
();
39
40
void
maybe_play_sound
();
41
42
private
:
43
team
&
team_
;
44
clock::time_point
last_timestamp_
;
45
bool
playing_sound_
;
46
};
countdown_clock
Definition
countdown_clock.hpp:22
countdown_clock::maybe_play_sound
void maybe_play_sound()
Definition
countdown_clock.cpp:73
countdown_clock::playing_sound_
bool playing_sound_
Definition
countdown_clock.hpp:45
countdown_clock::clock
std::chrono::steady_clock clock
Definition
countdown_clock.hpp:23
countdown_clock::last_timestamp_
clock::time_point last_timestamp_
Definition
countdown_clock.hpp:44
countdown_clock::~countdown_clock
~countdown_clock()
Definition
countdown_clock.cpp:37
countdown_clock::process
virtual void process() override
Inherited from pump_monitor.
Definition
countdown_clock.cpp:59
countdown_clock::update
bool update()
Definition
countdown_clock.cpp:66
countdown_clock::update_timestamp
std::chrono::milliseconds update_timestamp()
Definition
countdown_clock.cpp:45
countdown_clock::update_team
void update_team()
Definition
countdown_clock.cpp:52
countdown_clock::team_
team & team_
Definition
countdown_clock.hpp:43
events::pump_monitor
Definition
events.hpp:159
team
This class stores all the data for a single 'side' (in game nomenclature).
Definition
team.hpp:74
events.hpp
Generated by
1.9.8