OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::GameTime Class Reference

Stores the current ingame time/date according to GMT. More...

#include <GameTime.h>

Public Member Functions

 GameTime (int weekday, int day, int month, int year, int hour, int minute, int second)
 Creates a new ingame time at a certain point. More...
 
 ~GameTime ()
 Cleans up the ingame time.
 
void load (const YAML::Node &node)
 Loads the time from YAML. More...
 
YAML::Node save () const
 Saves the time to YAML. More...
 
TimeTrigger advance ()
 Advances the time by 5 seconds. More...
 
int getSecond () const
 Gets the ingame second. More...
 
int getMinute () const
 Gets the ingame minute. More...
 
int getHour () const
 Gets the ingame hour. More...
 
int getWeekday () const
 Gets the ingame weekday. More...
 
std::string getWeekdayString () const
 Returns a localizable-string representation of the current ingame weekday. More...
 
int getDay () const
 Gets the ingame day. More...
 
std::wstring getDayString (Language *lang) const
 Returns the localized representation of the current ingame day with the cardinal operator. More...
 
int getMonth () const
 Gets the ingame month. More...
 
std::string getMonthString () const
 Returns a localizable-string representation of the current ingame month. More...
 
int getYear () const
 Gets the ingame year. More...
 
double getDaylight () const
 Gets the position of the daylight according to the ingame time. More...
 

Detailed Description

Stores the current ingame time/date according to GMT.

Takes care of managing and representing each component, as well as common time operations.

Constructor & Destructor Documentation

OpenXcom::GameTime::GameTime ( int  weekday,
int  day,
int  month,
int  year,
int  hour,
int  minute,
int  second 
)

Creates a new ingame time at a certain point.

Initializes a new ingame time with a certain starting point.

Parameters
weekdayStarting weekday.
dayStarting day.
monthStarting month.
yearStarting year.
hourStarting hour.
minuteStarting minute.
secondStarting second.

Member Function Documentation

TimeTrigger OpenXcom::GameTime::advance ( )

Advances the time by 5 seconds.

Advances the ingame time by 5 seconds, automatically correcting the other components when necessary and sending out a trigger when a certain time span has elapsed for time-dependent events.

Returns
Time span trigger.
int OpenXcom::GameTime::getDay ( ) const

Gets the ingame day.

Returns the current ingame day.

Returns
Day (1-31).
double OpenXcom::GameTime::getDaylight ( ) const

Gets the position of the daylight according to the ingame time.

Returns the current position of the daylight emitted on the globe according to the current ingame time, so the value is 0 when the light starts at 0º longitude (6h) and 1 when the light ends at 0º longitude (18h).

Returns
Daylight position (0-1).
std::wstring OpenXcom::GameTime::getDayString ( Language lang) const

Returns the localized representation of the current ingame day with the cardinal operator.

Parameters
langPointer to current language.
Returns
Localized day string.
int OpenXcom::GameTime::getHour ( ) const

Gets the ingame hour.

Returns the current ingame hour.

Returns
Hour (0-23).
int OpenXcom::GameTime::getMinute ( ) const

Gets the ingame minute.

Returns the current ingame minute.

Returns
Minute (0-59).
int OpenXcom::GameTime::getMonth ( ) const

Gets the ingame month.

Returns the current ingame month.

Returns
Month (1-12).
std::string OpenXcom::GameTime::getMonthString ( ) const

Returns a localizable-string representation of the current ingame month.

Returns
Month string ID.
int OpenXcom::GameTime::getSecond ( ) const

Gets the ingame second.

Returns the current ingame second.

Returns
Second (0-59).
int OpenXcom::GameTime::getWeekday ( ) const

Gets the ingame weekday.

Returns the current ingame weekday.

Returns
Weekday (1-7), starts on Sunday.
std::string OpenXcom::GameTime::getWeekdayString ( ) const

Returns a localizable-string representation of the current ingame weekday.

Returns
Weekday string ID.
int OpenXcom::GameTime::getYear ( ) const

Gets the ingame year.

Returns the current ingame year.

Returns
Year.
void OpenXcom::GameTime::load ( const YAML::Node &  node)

Loads the time from YAML.

Loads the time from a YAML file.

Parameters
nodeYAML node.
YAML::Node OpenXcom::GameTime::save ( ) const

Saves the time to YAML.

Saves the time to a YAML file.

Returns
YAML node.

The documentation for this class was generated from the following files: