summaryrefslogtreecommitdiff
path: root/core/bind
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-01-13 12:51:14 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-01-13 12:51:14 -0300
commite53c247cb16b25b828461f32533da64f4fab0e0b (patch)
tree985328cee0387b987889ecccb65293bf87883dec /core/bind
parent0ad9939603a3d659f3f9cfba095a2e0c082483e8 (diff)
Created new Engine singleton, and moved engine related OS functions to it.
Diffstat (limited to 'core/bind')
-rw-r--r--core/bind/core_bind.cpp178
-rw-r--r--core/bind/core_bind.h57
2 files changed, 168 insertions, 67 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 8f1c1779bd..80fe8b7c85 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -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;
+}
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index d491483d82..3401435c68 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -169,12 +169,6 @@ public:
void native_video_unpause();
void native_video_stop();
- void set_iterations_per_second(int p_ips);
- int get_iterations_per_second() const;
-
- void set_target_fps(int p_fps);
- float get_target_fps() const;
-
void set_low_processor_usage_mode(bool p_enabled);
bool is_in_low_processor_usage_mode() const;
@@ -196,11 +190,7 @@ public:
String get_latin_keyboard_variant() const;
String get_model_name() const;
- MainLoop *get_main_loop() const;
- String get_custom_level() const;
-
- float get_frames_per_second() const;
void dump_memory_to_file(const String& p_file);
void dump_resources_to_file(const String& p_file);
@@ -271,8 +261,6 @@ public:
bool can_draw() const;
- int get_frames_drawn();
-
bool is_stdout_verbose() const;
int get_processor_count() const;
@@ -313,8 +301,6 @@ public:
void set_keep_screen_on(bool p_enabled);
bool is_keep_screen_on() const;
- void set_time_scale(float p_scale);
- float get_time_scale();
bool is_ok_left_and_cancel_right() const;
@@ -632,4 +618,47 @@ public:
~_ClassDB();
};
+
+class _Engine : public Object {
+ GDCLASS(_Engine,Object);
+
+protected:
+
+ static void _bind_methods();
+ static _Engine *singleton;
+
+public:
+
+ static _Engine* get_singleton() { return singleton; }
+ void set_iterations_per_second(int p_ips);
+ int get_iterations_per_second() const;
+
+ void set_target_fps(int p_fps);
+ float get_target_fps() const;
+
+ float get_frames_per_second() const;
+
+ int get_frames_drawn();
+
+ void set_time_scale(float p_scale);
+ float get_time_scale();
+
+ String get_custom_level() const;
+
+ MainLoop *get_main_loop() const;
+
+ String get_version() const;
+ String get_version_name() const;
+ String get_version_short_name() const;
+ int get_version_major() const;
+ int get_version_minor() const;
+ String get_version_revision() const;
+ String get_version_status() const;
+ int get_version_year() const;
+
+
+ _Engine();
+};
+
+
#endif // CORE_BIND_H