OpenXcom  1.0
Open-source clone of the original X-Com
GameTime.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom 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  * OpenXcom 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 OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <string>
21 #include <yaml-cpp/yaml.h>
22 
23 namespace OpenXcom
24 {
25 
26 class Language;
27 
31 enum TimeTrigger { TIME_5SEC, TIME_10MIN, TIME_30MIN, TIME_1HOUR, TIME_1DAY, TIME_1MONTH };
32 
38 class GameTime
39 {
40 private:
41  int _second, _minute, _hour, _weekday, _day, _month, _year;
42 public:
44  GameTime(int weekday, int day, int month, int year, int hour, int minute, int second);
46  ~GameTime();
48  void load(const YAML::Node& node);
50  YAML::Node save() const;
52  TimeTrigger advance();
54  int getSecond() const;
56  int getMinute() const;
58  int getHour() const;
60  int getWeekday() const;
61  // Gets a string version of the ingame weekday.
62  std::string getWeekdayString() const;
64  int getDay() const;
65  // Gets a string version of the ingame day.
66  std::string getDayString(Language *lang) const;
68  int getMonth() const;
69  // Gets a string version of the ingame month.
70  std::string getMonthString() const;
72  int getYear() const;
74  double getDaylight() const;
75 };
76 
77 }
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 getYear() const
Gets the ingame year.
Definition: GameTime.cpp:249
int getSecond() const
Gets the ingame second.
Definition: GameTime.cpp:143
std::string 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
void load(const YAML::Node &node)
Loads the time from YAML.
Definition: GameTime.cpp:50
std::string getMonthString() const
Returns a localizable-string representation of the current ingame month.
Definition: GameTime.cpp:239
~GameTime()
Cleans up the ingame time.
Definition: GameTime.cpp:42
Contains strings used throughout the game for localization.
Definition: Language.h:39
Stores the current ingame time/date according to GMT.
Definition: GameTime.h:38
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 getDay() const
Gets the ingame day.
Definition: GameTime.cpp:190
int getMinute() const
Gets the ingame minute.
Definition: GameTime.cpp:152
double getDaylight() const
Gets the position of the daylight according to the ingame time.
Definition: GameTime.cpp:260
int getHour() const
Gets the ingame hour.
Definition: GameTime.cpp:161
TimeTrigger advance()
Advances the time by 5 seconds.
Definition: GameTime.cpp:84
std::string getWeekdayString() const
Returns a localizable-string representation of the current ingame weekday.
Definition: GameTime.cpp:180
Definition: BaseInfoState.cpp:40