1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Created new Engine singleton, and moved engine related OS functions to it.

This commit is contained in:
Juan Linietsky
2017-01-13 12:51:14 -03:00
parent 0ad9939603
commit e53c247cb1
17 changed files with 393 additions and 186 deletions

View File

@@ -340,24 +340,6 @@ Array _OS::get_fullscreen_mode_list(int p_screen) const {
return vmarr;
}
void _OS::set_iterations_per_second(int p_ips) {
OS::get_singleton()->set_iterations_per_second(p_ips);
}
int _OS::get_iterations_per_second() const {
return OS::get_singleton()->get_iterations_per_second();
}
void _OS::set_target_fps(int p_fps) {
OS::get_singleton()->set_target_fps(p_fps);
}
float _OS::get_target_fps() const {
return OS::get_singleton()->get_target_fps();
}
void _OS::set_low_processor_usage_mode(bool p_enabled) {
OS::get_singleton()->set_low_processor_usage_mode(p_enabled);
@@ -452,19 +434,7 @@ String _OS::get_model_name() const {
return OS::get_singleton()->get_model_name();
}
MainLoop *_OS::get_main_loop() const {
return OS::get_singleton()->get_main_loop();
}
void _OS::set_time_scale(float p_scale) {
OS::get_singleton()->set_time_scale(p_scale);
}
float _OS::get_time_scale() {
return OS::get_singleton()->get_time_scale();
}
bool _OS::is_ok_left_and_cancel_right() const {
@@ -804,10 +774,6 @@ bool _OS::can_draw() const {
return OS::get_singleton()->can_draw();
}
int _OS::get_frames_drawn() {
return OS::get_singleton()->get_frames_drawn();
}
int _OS::get_processor_count() const {
@@ -936,11 +902,6 @@ String _OS::get_data_dir() const {
return OS::get_singleton()->get_data_dir();
};
float _OS::get_frames_per_second() const {
return OS::get_singleton()->get_frames_per_second();
}
Error _OS::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
return OS::get_singleton()->native_video_play(p_path, p_volume, p_audio_track, p_subtitle_track);
@@ -1005,10 +966,7 @@ String _OS::get_system_dir(SystemDir p_dir) const {
return OS::get_singleton()->get_system_dir(OS::SystemDir(p_dir));
}
String _OS::get_custom_level() const {
return OS::get_singleton()->get_custom_level();
}
String _OS::get_scancode_string(uint32_t p_code) const {
@@ -1079,13 +1037,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(_MD("set_keep_screen_on","enabled"),&_OS::set_keep_screen_on);
ClassDB::bind_method(_MD("is_keep_screen_on"),&_OS::is_keep_screen_on);
ClassDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second);
ClassDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second);
ClassDB::bind_method(_MD("set_target_fps","target_fps"),&_OS::set_target_fps);
ClassDB::bind_method(_MD("get_target_fps"),&_OS::get_target_fps);
ClassDB::bind_method(_MD("set_time_scale","time_scale"),&_OS::set_time_scale);
ClassDB::bind_method(_MD("get_time_scale"),&_OS::get_time_scale);
ClassDB::bind_method(_MD("has_touchscreen_ui_hint"),&_OS::has_touchscreen_ui_hint);
@@ -1107,7 +1058,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(_MD("get_name"),&_OS::get_name);
ClassDB::bind_method(_MD("get_cmdline_args"),&_OS::get_cmdline_args);
ClassDB::bind_method(_MD("get_main_loop"),&_OS::get_main_loop);
ClassDB::bind_method(_MD("get_datetime","utc"),&_OS::get_datetime,DEFVAL(false));
ClassDB::bind_method(_MD("get_date","utc"),&_OS::get_date,DEFVAL(false));
@@ -1133,10 +1083,8 @@ void _OS::_bind_methods() {
ClassDB::bind_method(_MD("get_latin_keyboard_variant"),&_OS::get_latin_keyboard_variant);
ClassDB::bind_method(_MD("get_model_name"),&_OS::get_model_name);
ClassDB::bind_method(_MD("get_custom_level"),&_OS::get_custom_level);
ClassDB::bind_method(_MD("can_draw"),&_OS::can_draw);
ClassDB::bind_method(_MD("get_frames_drawn"),&_OS::get_frames_drawn);
ClassDB::bind_method(_MD("is_stdout_verbose"),&_OS::is_stdout_verbose);
ClassDB::bind_method(_MD("can_use_threads"),&_OS::can_use_threads);
@@ -1163,7 +1111,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(_MD("is_ok_left_and_cancel_right"),&_OS::is_ok_left_and_cancel_right);
ClassDB::bind_method(_MD("get_frames_per_second"),&_OS::get_frames_per_second);
ClassDB::bind_method(_MD("print_all_textures_by_size"),&_OS::print_all_textures_by_size);
ClassDB::bind_method(_MD("print_resources_by_type","types"),&_OS::print_resources_by_type);
@@ -2596,3 +2543,128 @@ _ClassDB::~_ClassDB(){
}
///////////////////////////////
void _Engine::set_iterations_per_second(int p_ips) {
Engine::get_singleton()->set_iterations_per_second(p_ips);
}
int _Engine::get_iterations_per_second() const {
return Engine::get_singleton()->get_iterations_per_second();
}
void _Engine::set_target_fps(int p_fps) {
Engine::get_singleton()->set_target_fps(p_fps);
}
float _Engine::get_target_fps() const {
return Engine::get_singleton()->get_target_fps();
}
float _Engine::get_frames_per_second() const {
return Engine::get_singleton()->get_frames_per_second();
}
String _Engine::get_custom_level() const {
return Engine::get_singleton()->get_custom_level();
}
void _Engine::set_time_scale(float p_scale) {
Engine::get_singleton()->set_time_scale(p_scale);
}
float _Engine::get_time_scale() {
return Engine::get_singleton()->get_time_scale();
}
int _Engine::get_frames_drawn() {
return Engine::get_singleton()->get_frames_drawn();
}
MainLoop *_Engine::get_main_loop() const {
//needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here
return OS::get_singleton()->get_main_loop();
}
String _Engine::get_version() const {
return Engine::get_singleton()->get_version();
}
String _Engine::get_version_name() const{
return Engine::get_singleton()->get_version_name();
}
String _Engine::get_version_short_name() const{
return Engine::get_singleton()->get_version_short_name();
}
int _Engine::get_version_major() const{
return Engine::get_singleton()->get_version_major();
}
int _Engine::get_version_minor() const{
return Engine::get_singleton()->get_version_minor();
}
String _Engine::get_version_revision() const{
return Engine::get_singleton()->get_version_revision();
}
String _Engine::get_version_status() const{
return Engine::get_singleton()->get_version_status();
}
int _Engine::get_version_year() const{
return Engine::get_singleton()->get_version_year();
}
void _Engine::_bind_methods() {
ClassDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_Engine::set_iterations_per_second);
ClassDB::bind_method(_MD("get_iterations_per_second"),&_Engine::get_iterations_per_second);
ClassDB::bind_method(_MD("set_target_fps","target_fps"),&_Engine::set_target_fps);
ClassDB::bind_method(_MD("get_target_fps"),&_Engine::get_target_fps);
ClassDB::bind_method(_MD("set_time_scale","time_scale"),&_Engine::set_time_scale);
ClassDB::bind_method(_MD("get_time_scale"),&_Engine::get_time_scale);
ClassDB::bind_method(_MD("get_custom_level"),&_Engine::get_custom_level);
ClassDB::bind_method(_MD("get_frames_drawn"),&_Engine::get_frames_drawn);
ClassDB::bind_method(_MD("get_frames_per_second"),&_Engine::get_frames_per_second);
ClassDB::bind_method(_MD("get_main_loop:MainLoop"),&_Engine::get_main_loop);
ClassDB::bind_method(_MD("get_version"),&_Engine::get_version);
ClassDB::bind_method(_MD("get_version_name"),&_Engine::get_version_name);
ClassDB::bind_method(_MD("get_version_short_name"),&_Engine::get_version_short_name);
ClassDB::bind_method(_MD("get_version_major"),&_Engine::get_version_major);
ClassDB::bind_method(_MD("get_version_minor"),&_Engine::get_version_minor);
ClassDB::bind_method(_MD("get_version_revision"),&_Engine::get_version_revision);
ClassDB::bind_method(_MD("get_version_status"),&_Engine::get_version_status);
ClassDB::bind_method(_MD("get_version_year"),&_Engine::get_version_year);
}
_Engine *_Engine::singleton = NULL;
_Engine::_Engine() {
singleton=this;
}