[3.x] Add a Time singleton

This commit is contained in:
Aaron Franke 2021-10-20 22:14:41 -05:00
parent 964c6ec4d9
commit 035a84fe92
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
7 changed files with 798 additions and 0 deletions

View file

@ -41,6 +41,7 @@
#include "core/message_queue.h"
#include "core/os/dir_access.h"
#include "core/os/os.h"
#include "core/os/time.h"
#include "core/project_settings.h"
#include "core/register_core_types.h"
#include "core/script_debugger_local.h"
@ -91,6 +92,7 @@ static InputMap *input_map = nullptr;
static TranslationServer *translation_server = nullptr;
static Performance *performance = nullptr;
static PackedData *packed_data = nullptr;
static Time *time_singleton = nullptr;
#ifdef MINIZIP_ENABLED
static ZipArchive *zip_packed_data = nullptr;
#endif
@ -378,6 +380,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
globals = memnew(ProjectSettings);
input_map = memnew(InputMap);
time_singleton = memnew(Time);
register_core_settings(); //here globals is present
@ -1260,6 +1263,9 @@ error:
if (input_map) {
memdelete(input_map);
}
if (time_singleton) {
memdelete(time_singleton);
}
if (translation_server) {
memdelete(translation_server);
}
@ -2406,6 +2412,9 @@ void Main::cleanup(bool p_force) {
if (input_map) {
memdelete(input_map);
}
if (time_singleton) {
memdelete(time_singleton);
}
if (translation_server) {
memdelete(translation_server);
}