OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GameTime.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_GAMETIME_H
20 #define OPENXCOM_GAMETIME_H
21 
22 #include <string>
23 #include <yaml-cpp/yaml.h>
24 
25 namespace OpenXcom
26 {
27 
28 class Language;
29 
33 enum TimeTrigger { TIME_5SEC, TIME_10MIN, TIME_30MIN, TIME_1HOUR, TIME_1DAY, TIME_1MONTH };
34 
40 class GameTime
41 {
42 private:
43  int _second, _minute, _hour, _weekday, _day, _month, _year;
44 public:
46  GameTime(int weekday, int day, int month, int year, int hour, int minute, int second);
48  ~GameTime();
50  void load(const YAML::Node& node);
52  YAML::Node save() const;
56  int getSecond() const;
58  int getMinute() const;
60  int getHour() const;
62  int getWeekday() const;
63  // Gets a string version of the ingame weekday.
64  std::string getWeekdayString() const;
66  int getDay() const;
67  // Gets a string version of the ingame day.
68  std::wstring getDayString(Language *lang) const;
70  int getMonth() const;
71  // Gets a string version of the ingame month.
72  std::string getMonthString() const;
74  int getYear() const;
76  double getDaylight() const;
77 };
78 
79 }
80 
81 #endif
GameTime(int weekday, int day, int month, int year, int hour, int minute, int second)
Creates a new ingame time at a certain point.
Definition: GameTime.cpp:35
int getMonth() const
Gets the ingame month.
Definition: GameTime.cpp:229
YAML::Node save() const
Saves the time to YAML.
Definition: GameTime.cpp:65
int getYear() const
Gets the ingame year.
Definition: GameTime.cpp:249
void load(const YAML::Node &node)
Loads the time from YAML.
Definition: GameTime.cpp:50
TimeTrigger
Enumerator for time periods.
Definition: GameTime.h:33
int getSecond() const
Gets the ingame second.
Definition: GameTime.cpp:143
~GameTime()
Cleans up the ingame time.
Definition: GameTime.cpp:42
Contains strings used throughout the game for localization.
Definition: Language.h:42
std::wstring getDayString(Language *lang) const
Returns the localized representation of the current ingame day with the cardinal operator.
Definition: GameTime.cpp:201
int getWeekday() const
Gets the ingame weekday.
Definition: GameTime.cpp:170
Stores the current ingame time/date according to GMT.
Definition: GameTime.h:40
int getDay() const
Gets the ingame day.
Definition: GameTime.cpp:190
int getHour() const
Gets the ingame hour.
Definition: GameTime.cpp:161
std::string getMonthString() const
Returns a localizable-string representation of the current ingame month.
Definition: GameTime.cpp:239
double getDaylight() const
Gets the position of the daylight according to the ingame time.
Definition: GameTime.cpp:260
int getMinute() const
Gets the ingame minute.
Definition: GameTime.cpp:152
std::string getWeekdayString() const
Returns a localizable-string representation of the current ingame weekday.
Definition: GameTime.cpp:180
TimeTrigger advance()
Advances the time by 5 seconds.
Definition: GameTime.cpp:84