2020-06-03 11:32:28 +04:00
|
|
|
#ifndef GAME_MWWORLD_DATETIMEMANAGER_H
|
|
|
|
#define GAME_MWWORLD_DATETIMEMANAGER_H
|
|
|
|
|
2022-08-27 13:07:59 +02:00
|
|
|
#include <string_view>
|
2020-06-03 11:32:28 +04:00
|
|
|
|
2023-02-07 00:37:55 +01:00
|
|
|
#include "globalvariablename.hpp"
|
|
|
|
|
2020-06-03 11:32:28 +04:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct EpochTimeStamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class Globals;
|
|
|
|
class TimeStamp;
|
2023-08-06 14:46:15 +02:00
|
|
|
class World;
|
2020-06-03 11:32:28 +04:00
|
|
|
|
|
|
|
class DateTimeManager
|
|
|
|
{
|
|
|
|
public:
|
2023-08-06 14:46:15 +02:00
|
|
|
// Game time.
|
|
|
|
// Note that game time generally goes faster than the simulation time.
|
|
|
|
std::string_view getMonthName(int month = -1) const; // -1: current month
|
2020-06-03 11:32:28 +04:00
|
|
|
TimeStamp getTimeStamp() const;
|
|
|
|
ESM::EpochTimeStamp getEpochTimeStamp() const;
|
2023-08-06 14:46:15 +02:00
|
|
|
double getGameTime() const { return (static_cast<double>(mDaysPassed) * 24 + mGameHour) * 3600.0; }
|
|
|
|
float getGameTimeScale() const { return mGameTimeScale; }
|
|
|
|
void setGameTimeScale(float scale); // game time to simulation time ratio
|
|
|
|
|
|
|
|
// Simulation time (the number of seconds passed from the beginning of the game).
|
|
|
|
double getSimulationTime() const { return mSimulationTime; }
|
|
|
|
void setSimulationTime(double t) { mSimulationTime = t; }
|
|
|
|
float getSimulationTimeScale() const { return mSimulationTimeScale; }
|
|
|
|
void setSimulationTimeScale(float scale); // simulation time to real time ratio
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class World;
|
2020-06-03 11:32:28 +04:00
|
|
|
void setup(Globals& globalVariables);
|
2023-02-07 00:37:55 +01:00
|
|
|
bool updateGlobalInt(GlobalVariableName name, int value);
|
|
|
|
bool updateGlobalFloat(GlobalVariableName name, float value);
|
2023-08-06 14:46:15 +02:00
|
|
|
void advanceTime(double hours, Globals& globalVariables);
|
|
|
|
|
|
|
|
void setHour(double hour);
|
|
|
|
void setDay(int day);
|
|
|
|
void setMonth(int month);
|
|
|
|
|
|
|
|
int mDaysPassed = 0;
|
|
|
|
int mDay = 0;
|
|
|
|
int mMonth = 0;
|
|
|
|
int mYear = 0;
|
|
|
|
float mGameHour = 0.f;
|
|
|
|
float mGameTimeScale = 0.f;
|
|
|
|
float mSimulationTimeScale = 1.0;
|
|
|
|
double mSimulationTime = 0.0;
|
2020-06-03 11:32:28 +04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|