ScummVM API documentation
time_event_info.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TITANIC_TIMER_H
23 #define TITANIC_TIMER_H
24 
25 #include "common/algorithm.h"
26 #include "titanic/core/list.h"
27 
28 namespace Titanic {
29 
30 class CTreeItem;
31 class CProjectItem;
32 
33 class CTimeEventInfo : public ListItem {
34 private:
38  void lock() { ++_lockCounter; }
39 
43  void unlock() {
44  _lockCounter = MAX(_lockCounter - 1, 0);
45  }
46 public:
47  static uint _nextId;
48 public:
49  int _lockCounter;
50  uint _id;
51  bool _repeated;
52  uint _firstDuration;
53  uint _repeatDuration;
54  CTreeItem *_target;
55  uint _actionVal;
56  CString _action;
57  uint _timerCtr;
58  uint _lastTimerTicks;
59  uint _relativeTicks;
60  bool _done;
61  bool _persisent;
62  CString _targetName;
63 public:
64  CLASSDEF;
66  CTimeEventInfo(uint ticks, bool repeated, uint firstDuration, uint repeatDuration,
67  CTreeItem *target, int endVal, const CString &action);
68 
72  void save(SimpleFile *file, int indent) override;
73 
77  void load(SimpleFile *file) override;
78 
82  void postLoad(uint ticks, CProjectItem *project);
83 
87  void preSave(uint ticks);
88 
92  void postSave();
93 
94  bool update(uint ticks);
95 
99  void setPersisent(bool val) { _persisent = val; }
100 };
101 
102 class CTimeEventInfoList : public List<CTimeEventInfo> {
103 public:
107  void postLoad(uint ticks, CProjectItem *project);
108 
112  void preSave(uint ticks);
113 
117  void postSave();
118 
122  void update(uint ticks);
123 
127  void stop(uint id);
128 
132  void setPersisent(uint id, bool flag);
133 };
134 
135 } // End of namespace Titanic
136 
137 #endif /* TITANIC_TIMER_H */
void load(SimpleFile *file) override
void save(SimpleFile *file, int indent) override
Definition: list.h:35
Definition: simple_file.h:49
void preSave(uint ticks)
void setPersisent(bool val)
Definition: time_event_info.h:99
Definition: tree_item.h:37
Definition: list.h:71
Definition: arm.h:30
Definition: string.h:40
Definition: project_item.h:84
Definition: time_event_info.h:33
T MAX(T a, T b)
Definition: util.h:62
void postLoad(uint ticks, CProjectItem *project)
Definition: time_event_info.h:102