From 97d290e466bfdf1bb0fa68d828c3a3cb13f138de Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 10 Jan 2015 15:47:34 +0800 Subject: x11-fullscreen support through GDScript( OS.set_fullscreen(bool) ) --- core/bind/core_bind.cpp | 12 ++++++++++++ core/bind/core_bind.h | 4 ++++ core/os/os.h | 4 ++++ 3 files changed, 20 insertions(+) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 0c5d21b4f6..0d24486e90 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,6 +176,14 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } +void _OS::set_fullscreen(bool p_fullscreen) { + OS::get_singleton()->set_fullscreen(p_fullscreen); +} + +bool _OS::is_fullscreen() const { + return OS::get_singleton()->is_fullscreen(); +} + void _OS::set_use_file_access_save_and_swap(bool p_enable) { FileAccess::set_backup_save(p_enable); @@ -632,6 +640,10 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); + //MSC + ObjectTypeDB::bind_method(_MD("set_fullscreen","fullscreen"),&_OS::set_fullscreen); + ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); + ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); ObjectTypeDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second); ObjectTypeDB::bind_method(_MD("set_target_fps","target_fps"),&_OS::set_target_fps); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 12a4ae86eb..97aff87bca 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,6 +108,10 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; + //MSC + void set_fullscreen(bool p_fullscreen); + bool is_fullscreen() const; + Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); bool native_video_is_playing(); void native_video_pause(); diff --git a/core/os/os.h b/core/os/os.h index d4deff2f5e..e8de28e86a 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -149,6 +149,10 @@ public: virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0)=0; virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; + + //MSC + virtual void set_fullscreen(bool fullscreen)=0; + virtual bool is_fullscreen() const=0; virtual void set_iterations_per_second(int p_ips); virtual int get_iterations_per_second() const; -- cgit v1.2.3 From 0d2ec19082e9ebff07ab1ab8e365e2db9ee3268b Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 10 Jan 2015 18:38:30 +0800 Subject: API change to set_fullscreen(enabled,screen) --- core/bind/core_bind.cpp | 6 +++--- core/bind/core_bind.h | 2 +- core/os/os.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 0d24486e90..62d93745a0 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,8 +176,8 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } -void _OS::set_fullscreen(bool p_fullscreen) { - OS::get_singleton()->set_fullscreen(p_fullscreen); +void _OS::set_fullscreen(bool p_enabled,int p_screen) { + OS::get_singleton()->set_fullscreen(p_enabled, p_screen); } bool _OS::is_fullscreen() const { @@ -641,7 +641,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); //MSC - ObjectTypeDB::bind_method(_MD("set_fullscreen","fullscreen"),&_OS::set_fullscreen); + ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 97aff87bca..fedd03c3a9 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -109,7 +109,7 @@ public: Array get_fullscreen_mode_list(int p_screen=0) const; //MSC - void set_fullscreen(bool p_fullscreen); + void set_fullscreen(bool p_enabled, int p_screen=0); bool is_fullscreen() const; Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); diff --git a/core/os/os.h b/core/os/os.h index e8de28e86a..b86b122623 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -151,7 +151,7 @@ public: virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; //MSC - virtual void set_fullscreen(bool fullscreen)=0; + virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; virtual bool is_fullscreen() const=0; virtual void set_iterations_per_second(int p_ips); -- cgit v1.2.3 From a8e3c5c0b7fb202bcceb06b9373b5b6a4ff8f9b8 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 01:07:23 +0800 Subject: First attempt of restoring the window at the old position --- core/os/os.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/os/os.h b/core/os/os.h index b86b122623..9de2e3556b 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -69,11 +69,12 @@ public: }; struct VideoMode { - int width,height; + int x,y,width,height; bool fullscreen; bool resizable; float get_aspect() const { return (float)width/(float)height; } - VideoMode(int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) { width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } + VideoMode(int p_x=0, int p_y=0,int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) + { x=p_x; y=p_y; width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } }; protected: friend class Main; -- cgit v1.2.3 From ac558c15eaeb45b3e7ae2604e26ca1dffb60b779 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 15:47:27 +0800 Subject: get_window_position() + set_window_position() added --- core/bind/core_bind.cpp | 10 ++++++++++ core/bind/core_bind.h | 2 ++ core/os/os.h | 7 ++++--- 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 62d93745a0..3109b8bc84 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,6 +176,14 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } +Point2 _OS::get_window_position() const { + return OS::get_singleton()->get_window_position(); +} + +void _OS::set_window_position(const Point2& p_position) { + OS::get_singleton()->set_window_position(p_position); +} + void _OS::set_fullscreen(bool p_enabled,int p_screen) { OS::get_singleton()->set_fullscreen(p_enabled, p_screen); } @@ -641,6 +649,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); //MSC + ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); + ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index fedd03c3a9..92056aa0d6 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -109,6 +109,8 @@ public: Array get_fullscreen_mode_list(int p_screen=0) const; //MSC + virtual Point2 get_window_position() const; + virtual void set_window_position(const Point2& p_position); void set_fullscreen(bool p_enabled, int p_screen=0); bool is_fullscreen() const; diff --git a/core/os/os.h b/core/os/os.h index 9de2e3556b..9089e7de76 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -69,12 +69,11 @@ public: }; struct VideoMode { - int x,y,width,height; + int width,height; bool fullscreen; bool resizable; float get_aspect() const { return (float)width/(float)height; } - VideoMode(int p_x=0, int p_y=0,int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) - { x=p_x; y=p_y; width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } + VideoMode(int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) {width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } }; protected: friend class Main; @@ -152,6 +151,8 @@ public: virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; //MSC + virtual Point2 get_window_position() const=0; + virtual void set_window_position(const Point2& p_position)=0; virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; virtual bool is_fullscreen() const=0; -- cgit v1.2.3 From 466e251abecf3686f0caac40ab886155e43cc0a6 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 17:36:56 +0800 Subject: get_window_size() + set_window_size() added --- core/bind/core_bind.cpp | 11 ++++++++++- core/bind/core_bind.h | 3 ++- core/os/os.h | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 3109b8bc84..2b4e2e1239 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -184,6 +184,14 @@ void _OS::set_window_position(const Point2& p_position) { OS::get_singleton()->set_window_position(p_position); } +Size2 _OS::get_window_size() const { + return OS::get_singleton()->get_window_size(); +} + +void _OS::set_window_size(const Size2& p_size) { + OS::get_singleton()->set_window_size(p_size); +} + void _OS::set_fullscreen(bool p_enabled,int p_screen) { OS::get_singleton()->set_fullscreen(p_enabled, p_screen); } @@ -648,9 +656,10 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); - //MSC ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); + ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); + ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size); ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 92056aa0d6..e60bb5e66a 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,9 +108,10 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; - //MSC virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); + virtual Size2 get_window_size() const; + virtual void set_window_size(const Size2& p_size); void set_fullscreen(bool p_enabled, int p_screen=0); bool is_fullscreen() const; diff --git a/core/os/os.h b/core/os/os.h index 9089e7de76..7e9fdcc579 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -150,9 +150,10 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; - //MSC virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; + virtual Size2 get_window_size() const=0; + virtual void set_window_size(const Size2 p_size)=0; virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; virtual bool is_fullscreen() const=0; -- cgit v1.2.3 From 3c8b047b111cf20b3823851e298ce42bdf941871 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 18:52:42 +0800 Subject: get_screen_count() added --- core/bind/core_bind.cpp | 5 +++++ core/bind/core_bind.h | 1 + core/os/os.h | 1 + 3 files changed, 7 insertions(+) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 2b4e2e1239..3f86efc879 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,6 +176,10 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } +int _OS::get_screen_count() const { + return OS::get_singleton()->get_screen_count(); +} + Point2 _OS::get_window_position() const { return OS::get_singleton()->get_window_position(); } @@ -656,6 +660,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); + ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index e60bb5e66a..cb9a5da479 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,6 +108,7 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; + virtual int get_screen_count() const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; diff --git a/core/os/os.h b/core/os/os.h index 7e9fdcc579..68769e7ad4 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -150,6 +150,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; + virtual int get_screen_count() const=0; virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; virtual Size2 get_window_size() const=0; -- cgit v1.2.3 From f9d0de0d2a82456f3553499fcbc1c487b59fed1c Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 19:35:53 +0800 Subject: get_screen_size() added --- core/bind/core_bind.cpp | 5 +++++ core/bind/core_bind.h | 1 + core/os/os.h | 1 + 3 files changed, 7 insertions(+) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 3f86efc879..47bfba1cbb 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -180,6 +180,10 @@ int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } +Size2 _OS::get_screen_size(int p_screen) const { + return OS::get_singleton()->get_screen_size(p_screen); +} + Point2 _OS::get_window_position() const { return OS::get_singleton()->get_window_position(); } @@ -661,6 +665,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); + ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index cb9a5da479..2a87f85ec7 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -109,6 +109,7 @@ public: Array get_fullscreen_mode_list(int p_screen=0) const; virtual int get_screen_count() const; + virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; diff --git a/core/os/os.h b/core/os/os.h index 68769e7ad4..edb5d57c5f 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -151,6 +151,7 @@ public: virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; virtual int get_screen_count() const=0; + virtual Size2 get_screen_size(int p_screen=0) const=0; virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; virtual Size2 get_window_size() const=0; -- cgit v1.2.3 From c0d363266755de3ac87f61600f23921d881d99e2 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Tue, 13 Jan 2015 15:44:39 +0800 Subject: introduced the scons experimental_wm_api switch: ================================================ Usage: scons p=x11 experimental_wm_api=yes --- core/bind/core_bind.cpp | 4 ++++ core/bind/core_bind.h | 2 ++ core/os/os.h | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 47bfba1cbb..b8fc63dc43 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,6 +176,7 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } +#ifdef EXPERIMENTAL_WM_API int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } @@ -207,6 +208,7 @@ void _OS::set_fullscreen(bool p_enabled,int p_screen) { bool _OS::is_fullscreen() const { return OS::get_singleton()->is_fullscreen(); } +#endif void _OS::set_use_file_access_save_and_swap(bool p_enable) { @@ -664,6 +666,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); +#ifdef EXPERIMENTAL_WM_API ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); @@ -672,6 +675,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size); ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); +#endif ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); ObjectTypeDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 2a87f85ec7..62f9913556 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,6 +108,7 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; +#ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const; virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; @@ -116,6 +117,7 @@ public: virtual void set_window_size(const Size2& p_size); void set_fullscreen(bool p_enabled, int p_screen=0); bool is_fullscreen() const; +#endif Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); bool native_video_is_playing(); diff --git a/core/os/os.h b/core/os/os.h index edb5d57c5f..c2534287bc 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -150,6 +150,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; +#ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const=0; virtual Size2 get_screen_size(int p_screen=0) const=0; virtual Point2 get_window_position() const=0; @@ -158,7 +159,8 @@ public: virtual void set_window_size(const Size2 p_size)=0; virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; virtual bool is_fullscreen() const=0; - +#endif + virtual void set_iterations_per_second(int p_ips); virtual int get_iterations_per_second() const; -- cgit v1.2.3 From ce7c7a862ebe37fada7708c342c07d70fa80465a Mon Sep 17 00:00:00 2001 From: hurikhan Date: Tue, 13 Jan 2015 17:25:50 +0800 Subject: get_screen_position() added --- core/bind/core_bind.cpp | 5 +++++ core/bind/core_bind.h | 1 + core/os/os.h | 1 + 3 files changed, 7 insertions(+) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index b8fc63dc43..a2aca7e11f 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -181,6 +181,10 @@ int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } +Point2 _OS::get_screen_position(int p_screen) const { + return OS::get_singleton()->get_screen_position(p_screen); +} + Size2 _OS::get_screen_size(int p_screen) const { return OS::get_singleton()->get_screen_size(p_screen); } @@ -668,6 +672,7 @@ void _OS::_bind_methods() { #ifdef EXPERIMENTAL_WM_API ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); + ObjectTypeDB::bind_method(_MD("get_screen_position"),&_OS::get_screen_position,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 62f9913556..9d9f25691e 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -110,6 +110,7 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const; + virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); diff --git a/core/os/os.h b/core/os/os.h index c2534287bc..1ef05e45c8 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -152,6 +152,7 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const=0; + virtual Point2 get_screen_position(int p_screen=0) const=0; virtual Size2 get_screen_size(int p_screen=0) const=0; virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; -- cgit v1.2.3 From 790d8ecbb9a0a0ac67520b84fc621c34f910d817 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Wed, 14 Jan 2015 12:02:59 +0800 Subject: get_screen() + set_screen() added --- core/bind/core_bind.cpp | 16 +++++++++++++--- core/bind/core_bind.h | 4 +++- core/os/os.h | 4 +++- 3 files changed, 19 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index a2aca7e11f..48cd43ccdc 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -181,6 +181,14 @@ int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } +int _OS::get_screen() const { + return OS::get_singleton()->get_screen(); +} + +void _OS::set_screen(int p_screen) { + OS::get_singleton()->set_screen(p_screen); +} + Point2 _OS::get_screen_position(int p_screen) const { return OS::get_singleton()->get_screen_position(p_screen); } @@ -205,8 +213,8 @@ void _OS::set_window_size(const Size2& p_size) { OS::get_singleton()->set_window_size(p_size); } -void _OS::set_fullscreen(bool p_enabled,int p_screen) { - OS::get_singleton()->set_fullscreen(p_enabled, p_screen); +void _OS::set_fullscreen(bool p_enabled) { + OS::get_singleton()->set_fullscreen(p_enabled); } bool _OS::is_fullscreen() const { @@ -672,13 +680,15 @@ void _OS::_bind_methods() { #ifdef EXPERIMENTAL_WM_API ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); + ObjectTypeDB::bind_method(_MD("get_screen"),&_OS::get_screen); + ObjectTypeDB::bind_method(_MD("set_screen"),&_OS::set_screen); ObjectTypeDB::bind_method(_MD("get_screen_position"),&_OS::get_screen_position,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size); - ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); + ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled"),&_OS::set_fullscreen); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); #endif diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 9d9f25691e..99ecb765c7 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -110,13 +110,15 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const; + virtual int get_screen() const; + virtual void set_screen(int p_screen); virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; virtual void set_window_size(const Size2& p_size); - void set_fullscreen(bool p_enabled, int p_screen=0); + void set_fullscreen(bool p_enabled); bool is_fullscreen() const; #endif diff --git a/core/os/os.h b/core/os/os.h index 1ef05e45c8..2d4e937974 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -152,13 +152,15 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const=0; + virtual int get_screen() const=0; + virtual void set_screen(int p_screen)=0; virtual Point2 get_screen_position(int p_screen=0) const=0; virtual Size2 get_screen_size(int p_screen=0) const=0; virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; virtual Size2 get_window_size() const=0; virtual void set_window_size(const Size2 p_size)=0; - virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; + virtual void set_fullscreen(bool p_enabled)=0; virtual bool is_fullscreen() const=0; #endif -- cgit v1.2.3 From d269344bbd19d9653fff3c2a230261b8fa00d7f6 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Thu, 15 Jan 2015 22:50:23 +0900 Subject: WIP -- set_resizable() + is_resizable added --- core/bind/core_bind.cpp | 11 ++++++++++- core/bind/core_bind.h | 2 ++ core/os/os.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 48cd43ccdc..1fb6f96e71 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -220,6 +220,14 @@ void _OS::set_fullscreen(bool p_enabled) { bool _OS::is_fullscreen() const { return OS::get_singleton()->is_fullscreen(); } + +void _OS::set_resizable(bool p_enabled) { + OS::get_singleton()->set_resizable(p_enabled); +} + +bool _OS::is_resizable() const { + return OS::get_singleton()->is_resizable(); +} #endif void _OS::set_use_file_access_save_and_swap(bool p_enable) { @@ -232,7 +240,6 @@ bool _OS::is_video_mode_resizable(int p_screen) const { OS::VideoMode vm; vm = OS::get_singleton()->get_video_mode(p_screen); return vm.resizable; - } Array _OS::get_fullscreen_mode_list(int p_screen) const { @@ -690,6 +697,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size); ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled"),&_OS::set_fullscreen); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); + ObjectTypeDB::bind_method(_MD("set_resizable","enabled"),&_OS::set_resizable); + ObjectTypeDB::bind_method(_MD("is_resizable"),&_OS::is_resizable); #endif ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 99ecb765c7..7ffd7e9e7c 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -120,6 +120,8 @@ public: virtual void set_window_size(const Size2& p_size); void set_fullscreen(bool p_enabled); bool is_fullscreen() const; + void set_resizable(bool p_enabled); + bool is_resizable() const; #endif Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); diff --git a/core/os/os.h b/core/os/os.h index 2d4e937974..f1a9de1edf 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -162,6 +162,8 @@ public: virtual void set_window_size(const Size2 p_size)=0; virtual void set_fullscreen(bool p_enabled)=0; virtual bool is_fullscreen() const=0; + virtual void set_resizable(bool p_enabled)=0; + virtual bool is_resizable() const=0; #endif virtual void set_iterations_per_second(int p_ips); -- cgit v1.2.3 From 716971655eb9ab7909447e2f5d4911b6f45164bb Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 17 Jan 2015 00:18:45 +0900 Subject: added the following methods: * set_minimized(bool) * bool is_minimized() * set_maximized(bool) * bool is_maximized() --- core/bind/core_bind.cpp | 22 +++++++++++++++++++++- core/bind/core_bind.h | 12 ++++++++---- core/os/os.h | 4 ++++ 3 files changed, 33 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 1fb6f96e71..6919c70a5f 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -228,6 +228,22 @@ void _OS::set_resizable(bool p_enabled) { bool _OS::is_resizable() const { return OS::get_singleton()->is_resizable(); } + +void _OS::set_minimized(bool p_enabled) { + OS::get_singleton()->set_minimized(p_enabled); +} + +bool _OS::is_minimized() const { + return OS::get_singleton()->is_minimized(); +} + +void _OS::set_maximized(bool p_enabled) { + OS::get_singleton()->set_maximized(p_enabled); +} + +bool _OS::is_maximized() const { + return OS::get_singleton()->is_maximized(); +} #endif void _OS::set_use_file_access_save_and_swap(bool p_enable) { @@ -698,7 +714,11 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled"),&_OS::set_fullscreen); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); ObjectTypeDB::bind_method(_MD("set_resizable","enabled"),&_OS::set_resizable); - ObjectTypeDB::bind_method(_MD("is_resizable"),&_OS::is_resizable); + ObjectTypeDB::bind_method(_MD("is_resizable"),&_OS::is_resizable); + ObjectTypeDB::bind_method(_MD("set_minimized", "enabled"),&_OS::set_minimized); + ObjectTypeDB::bind_method(_MD("is_minimized"),&_OS::is_minimized); + ObjectTypeDB::bind_method(_MD("set_maximized", "enabled"),&_OS::set_maximized); + ObjectTypeDB::bind_method(_MD("is_maximized"),&_OS::is_maximized); #endif ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 7ffd7e9e7c..b6f4f8eef4 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -118,10 +118,14 @@ public: virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; virtual void set_window_size(const Size2& p_size); - void set_fullscreen(bool p_enabled); - bool is_fullscreen() const; - void set_resizable(bool p_enabled); - bool is_resizable() const; + virtual void set_fullscreen(bool p_enabled); + virtual bool is_fullscreen() const; + virtual void set_resizable(bool p_enabled); + virtual bool is_resizable() const; + virtual void set_minimized(bool p_enabled); + virtual bool is_minimized() const; + virtual void set_maximized(bool p_enabled); + virtual bool is_maximized() const; #endif Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); diff --git a/core/os/os.h b/core/os/os.h index f1a9de1edf..c04a91e302 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -164,6 +164,10 @@ public: virtual bool is_fullscreen() const=0; virtual void set_resizable(bool p_enabled)=0; virtual bool is_resizable() const=0; + virtual void set_minimized(bool p_enabled)=0; + virtual bool is_minimized() const=0; + virtual void set_maximized(bool p_enabled)=0; + virtual bool is_maximized() const=0; #endif virtual void set_iterations_per_second(int p_ips); -- cgit v1.2.3 From f5d2e1f42cca1c5b078073133fccda63c556a0da Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 15 Feb 2015 18:26:49 +0800 Subject: Renamed EXPERIMENTAL_WM_API to NEW_WM_API --- core/bind/core_bind.cpp | 4 ++-- core/bind/core_bind.h | 2 +- core/os/os.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 39c5761d67..858f5cec27 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,7 +176,7 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } @@ -706,7 +706,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); ObjectTypeDB::bind_method(_MD("get_screen"),&_OS::get_screen); ObjectTypeDB::bind_method(_MD("set_screen"),&_OS::set_screen); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index e77ed9e40f..1a80e35221 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,7 +108,7 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API virtual int get_screen_count() const; virtual int get_screen() const; virtual void set_screen(int p_screen); diff --git a/core/os/os.h b/core/os/os.h index c04a91e302..6301bd495f 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -150,7 +150,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API virtual int get_screen_count() const=0; virtual int get_screen() const=0; virtual void set_screen(int p_screen)=0; -- cgit v1.2.3 From 0e1f34b49da3066bed94b316f22e6dd805509bf3 Mon Sep 17 00:00:00 2001 From: ElectricSolstice Date: Mon, 16 Feb 2015 18:58:41 -0800 Subject: Changed code to remove gcc -Wparentheses warnings. --- core/math/geometry.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/math/geometry.h b/core/math/geometry.h index 7e0cc01a22..4ad4db8523 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -519,9 +519,9 @@ public: bool s_ab = (b.x-a.x)*as_y-(b.y-a.y)*as_x > 0; - if((c.x-a.x)*as_y-(c.y-a.y)*as_x > 0 == s_ab) return false; + if(((c.x-a.x)*as_y-(c.y-a.y)*as_x > 0) == s_ab) return false; - if((c.x-b.x)*(s.y-b.y)-(c.y-b.y)*(s.x-b.x) > 0 != s_ab) return false; + if(((c.x-b.x)*(s.y-b.y)-(c.y-b.y)*(s.x-b.x) > 0) != s_ab) return false; return true; } -- cgit v1.2.3 From db2381de7afffc932d051ec9fc853bfe06645060 Mon Sep 17 00:00:00 2001 From: "Bil Bas (Spooner)" Date: Thu, 19 Feb 2015 15:45:49 +0000 Subject: Correctly halt on error in sprintf parsing (fixes #1393) --- core/ustring.cpp | 54 ++++++++++++++++++++--------------------------------- core/ustring.h | 2 +- core/variant_op.cpp | 16 ++++++++++------ 3 files changed, 31 insertions(+), 41 deletions(-) (limited to 'core') diff --git a/core/ustring.cpp b/core/ustring.cpp index 476ab3f936..09d3d95b68 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3550,8 +3550,8 @@ String String::lpad(int min_length, const String& character) const { // sprintf is implemented in GDScript via: // "fish %s pie" % "frog" // "fish %s %d pie" % ["frog", 12] -String String::sprintf(const Array& values) const { - +// In case of an error, the string returned is the error description and "error" is true. +String String::sprintf(const Array& values, bool* error) const { String formatted; CharType* self = (CharType*)c_str(); int num_items = values.size(); @@ -3564,6 +3564,7 @@ String String::sprintf(const Array& values) const { bool left_justified; bool show_sign; + *error = true; for (; *self; self++) { const CharType c = *self; @@ -3580,13 +3581,11 @@ String String::sprintf(const Array& values) const { case 'x': // Hexadecimal (lowercase) case 'X': { // Hexadecimal (uppercase) if (value_index >= values.size()) { - ERR_EXPLAIN("not enough arguments for format string"); - ERR_FAIL_V(""); + return "not enough arguments for format string"; } if (!values[value_index].is_num()) { - ERR_EXPLAIN("a number is required"); - ERR_FAIL_V(""); + return "a number is required"; } int64_t value = values[value_index]; @@ -3622,13 +3621,11 @@ String String::sprintf(const Array& values) const { } case 'f': { // Float if (value_index >= values.size()) { - ERR_EXPLAIN("not enough arguments for format string"); - ERR_FAIL_V(""); + return "not enough arguments for format string"; } if (!values[value_index].is_num()) { - ERR_EXPLAIN("a number is required"); - ERR_FAIL_V(""); + return "a number is required"; } double value = values[value_index]; @@ -3657,8 +3654,7 @@ String String::sprintf(const Array& values) const { } case 's': { // String if (value_index >= values.size()) { - ERR_EXPLAIN("not enough arguments for format string"); - ERR_FAIL_V(""); + return "not enough arguments for format string"; } String str = values[value_index]; @@ -3676,8 +3672,7 @@ String String::sprintf(const Array& values) const { } case 'c': { if (value_index >= values.size()) { - ERR_EXPLAIN("not enough arguments for format string"); - ERR_FAIL_V(""); + return "not enough arguments for format string"; } // Convert to character. @@ -3685,22 +3680,18 @@ String String::sprintf(const Array& values) const { if (values[value_index].is_num()) { int value = values[value_index]; if (value < 0) { - ERR_EXPLAIN("unsigned byte integer is lower than maximum") - ERR_FAIL_V(""); + return "unsigned byte integer is lower than maximum"; } else if (value > 255) { - ERR_EXPLAIN("unsigned byte integer is greater than maximum") - ERR_FAIL_V(""); + return "unsigned byte integer is greater than maximum"; } str = chr(values[value_index]); } else if (values[value_index].get_type() == Variant::STRING) { str = values[value_index]; if (str.length() != 1) { - ERR_EXPLAIN("%c requires number or single-character string"); - ERR_FAIL_V(""); + return "%c requires number or single-character string"; } } else { - ERR_EXPLAIN("%c requires number or single-character string"); - ERR_FAIL_V(""); + return "%c requires number or single-character string"; } // Padding. @@ -3741,8 +3732,7 @@ String String::sprintf(const Array& values) const { } case '.': { // Float separtor. if (in_decimals) { - ERR_EXPLAIN("too many decimal points in format"); - ERR_FAIL_V(""); + return "too many decimal points in format"; } in_decimals = true; min_decimals = 0; // We want to add the value manually. @@ -3751,13 +3741,11 @@ String String::sprintf(const Array& values) const { case '*': { // Dyanmic width, based on value. if (value_index >= values.size()) { - ERR_EXPLAIN("not enough arguments for format string"); - ERR_FAIL_V(""); + return "not enough arguments for format string"; } if (!values[value_index].is_num()) { - ERR_EXPLAIN("* wants number"); - ERR_FAIL_V(""); + return "* wants number"; } int size = values[value_index]; @@ -3773,8 +3761,7 @@ String String::sprintf(const Array& values) const { } default: { - ERR_EXPLAIN("unsupported format character"); - ERR_FAIL_V(""); + return "unsupported format character"; } } } else { // Not in format string. @@ -3796,14 +3783,13 @@ String String::sprintf(const Array& values) const { } if (in_format) { - ERR_EXPLAIN("incomplete format"); - ERR_FAIL_V(""); + return "incomplete format"; } if (value_index != values.size()) { - ERR_EXPLAIN("not all arguments converted during string formatting"); - ERR_FAIL_V(""); + return "not all arguments converted during string formatting"; } + *error = false; return formatted; } diff --git a/core/ustring.h b/core/ustring.h index af5ffb7c35..d4b854ea76 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -130,7 +130,7 @@ public: String pad_zeros(int p_digits) const; String lpad(int min_length,const String& character=" ") const; String rpad(int min_length,const String& character=" ") const; - String sprintf(const Array& values) const; + String sprintf(const Array& values, bool* error) const; static String num(double p_num,int p_decimals=-1); static String num_scientific(double p_num); static String num_real(double p_num); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 21bbc8c7ee..10b9a67da2 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -738,18 +738,22 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& _RETURN( p_a._data._int % p_b._data._int ); } else if (p_a.type==STRING) { - const String *str=reinterpret_cast(p_a._data._mem); + const String* format=reinterpret_cast(p_a._data._mem); + String result; + bool error; if (p_b.type==ARRAY) { // e.g. "frog %s %d" % ["fish", 12] - const Array *arr=reinterpret_cast(p_b._data._mem); - _RETURN(str->sprintf(*arr)); + const Array* args=reinterpret_cast(p_b._data._mem); + result=format->sprintf(*args, &error); } else { // e.g. "frog %d" % 12 - Array arr; - arr.push_back(p_b); - _RETURN(str->sprintf(arr)); + Array args; + args.push_back(p_b); + result=format->sprintf(args, &error); } + r_valid = !error; + _RETURN(result); } r_valid=false; -- cgit v1.2.3 From 8f5bf2a2ef96ea2d189d09a8cdd8d0a15deceb00 Mon Sep 17 00:00:00 2001 From: Nathan Warden Date: Thu, 19 Feb 2015 19:35:04 -0500 Subject: Camelcased script variables will now capitalize in the inspector. --- core/ustring.cpp | 25 ++++++++++++++++++++++++- core/ustring.h | 3 +-- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/ustring.cpp b/core/ustring.cpp index 476ab3f936..8ad1d434d4 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -482,7 +482,7 @@ void String::erase(int p_pos, int p_chars) { String String::capitalize() const { - String aux=this->replace("_"," ").to_lower(); + String aux=this->camelcase_to_underscore().replace("_"," ").to_lower(); String cap; for (int i=0;isize()-1; i++ ) { + bool isCapital = cstr[i] >= A && cstr[i] <= Z; + + if ( isCapital ) { + newString += "_" + this->substr(startIndex, i-startIndex); + startIndex = i; + } + } + + newString += "_" + this->substr(startIndex, this->size()-startIndex); + + return newString; +} + + int String::get_slice_count(String p_splitter) const{ if (empty()) diff --git a/core/ustring.h b/core/ustring.h index af5ffb7c35..c7da26a695 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -149,6 +149,7 @@ public: static double to_double(const CharType* p_str, const CharType **r_end=NULL); static int64_t to_int(const CharType* p_str,int p_len=-1); String capitalize() const; + String camelcase_to_underscore() const; int get_slice_count(String p_splitter) const; String get_slice(String p_splitter,int p_slice) const; @@ -225,8 +226,6 @@ public: String(const char *p_str); String(const CharType *p_str,int p_clip_to_len=-1); String(const StrRange& p_range); - - }; -- cgit v1.2.3 From e2c0caf41e8ae2c992c81ceed89a95a5c0d0cbfa Mon Sep 17 00:00:00 2001 From: theuserbl Date: Fri, 27 Feb 2015 11:19:55 +0100 Subject: Update global_constants.cpp Making KEY_MASK_CMD usable in GDScript --- core/global_constants.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'core') diff --git a/core/global_constants.cpp b/core/global_constants.cpp index ae4abc627d..fc48a105db 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -313,6 +313,7 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( KEY_MASK_ALT ), BIND_GLOBAL_CONSTANT( KEY_MASK_META ), BIND_GLOBAL_CONSTANT( KEY_MASK_CTRL ), + BIND_GLOBAL_CONSTANT( KEY_MASK_CMD ), BIND_GLOBAL_CONSTANT( KEY_MASK_KPAD ), BIND_GLOBAL_CONSTANT( KEY_MASK_GROUP_SWITCH ), -- cgit v1.2.3 From a1f715a4da71fbc2b7d6fad68624bf8b22c6da17 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 2 Mar 2015 00:54:10 -0300 Subject: support for 2D shadow casters Added support for 2D shadow casters. *DANGER* Shaders in CanvasItem CHANGED, if you are using shader in a CanvasItem and pull this, you will lose them. Shaders now work through a 2D material system similar to 3D. If you don't want to lose the 2D shader code, save the shader as a .shd, then create a material in CanvasItem and re-assign the shader. --- core/io/resource_format_binary.cpp | 10 ++++++++++ core/io/resource_format_xml.cpp | 5 +++++ core/math/camera_matrix.cpp | 19 ++++++++++++++++++- core/variant_op.cpp | 3 +++ 4 files changed, 36 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index e2371fe24f..ead6984650 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1778,6 +1778,11 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ f->store_32(VERSION_MINOR); f->store_32(FORMAT_VERSION); + if (f->get_error()!=OK && f->get_error()!=ERR_FILE_EOF) { + f->close(); + return ERR_CANT_CREATE; + } + //f->store_32(saved_resources.size()+external_resources.size()); // load steps -not needed save_unicode_string(p_resource->get_type()); uint64_t md_at = f->get_pos(); @@ -1910,6 +1915,11 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ f->store_buffer((const uint8_t*)"RSRC",4); //magic at end + if (f->get_error()!=OK && f->get_error()!=ERR_FILE_EOF) { + f->close(); + return ERR_CANT_CREATE; + } + f->close(); diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 75384d4ab6..033b4d5e5a 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -2592,6 +2592,11 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res } exit_tag("resource_file"); + if (f->get_error()!=OK && f->get_error()!=ERR_FILE_EOF) { + f->close(); + return ERR_CANT_CREATE; + } + f->close(); //memdelete(f); diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index a60dea7379..fbe5f8c741 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -121,7 +121,7 @@ void CameraMatrix::set_orthogonal(float p_size, float p_aspect, float p_znear, f void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, float p_top, float p_near, float p_far) { - +#if 0 ///@TODO, give a check to this. I'm not sure if it's working. set_identity(); @@ -133,10 +133,27 @@ void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, floa matrix[2][3]=-(2*p_far*p_near) / (p_far-p_near); matrix[3][2]=-1; matrix[3][3]=0; +#else + float *te = &matrix[0][0]; + float x = 2 * p_near / ( p_right - p_left ); + float y = 2 * p_near / ( p_top - p_bottom ); + + float a = ( p_right + p_left ) / ( p_right - p_left ); + float b = ( p_top + p_bottom ) / ( p_top - p_bottom ); + float c = - ( p_far + p_near ) / ( p_far - p_near ); + float d = - 2 * p_far * p_near / ( p_far - p_near ); + + te[0] = x; te[4] = 0; te[8] = a; te[12] = 0; + te[1] = 0; te[5] = y; te[9] = b; te[13] = 0; + te[2] = 0; te[6] = 0; te[10] = c; te[14] = d; + te[3] = 0; te[7] = 0; te[11] = - 1; te[15] = 0; + +#endif } + float CameraMatrix::get_z_far() const { const float * matrix = (const float*)this->matrix; diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 21bbc8c7ee..d6129e150c 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -552,6 +552,9 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& if (p_b.type==MATRIX32) { _RETURN( *p_a._data._matrix32 * *p_b._data._matrix32 ); }; + if (p_b.type==VECTOR2) { + _RETURN( p_a._data._matrix32->xform( *(const Vector2*)p_b._data._mem) ); + }; r_valid=false; return; } break; -- cgit v1.2.3 From 4d2198110b4af7f203eeef95697255569e49bce7 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 3 Mar 2015 14:39:13 -0300 Subject: merges from okam repo --- core/object.cpp | 8 ++++++++ core/object.h | 1 + 2 files changed, 9 insertions(+) (limited to 'core') diff --git a/core/object.cpp b/core/object.cpp index 82144ab4be..2b83f728d1 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1033,6 +1033,13 @@ void Object::add_user_signal(const MethodInfo& p_signal) { signal_map[p_signal.name]=s; } +bool Object::_has_user_signal(const StringName& p_name) const { + + if (!signal_map.has(p_name)) + return false; + return signal_map[p_name].user.name.length()>0; +} + struct _ObjectSignalDisconnectData { StringName signal; @@ -1431,6 +1438,7 @@ void Object::_bind_methods() { // ObjectTypeDB::bind_method(_MD("call_deferred","method","arg1","arg2","arg3","arg4"),&Object::_call_deferred_bind,DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant())); ObjectTypeDB::bind_method(_MD("add_user_signal","signal","arguments"),&Object::_add_user_signal,DEFVAL(Array())); + ObjectTypeDB::bind_method(_MD("has_user_signal","signal"),&Object::_has_user_signal); // ObjectTypeDB::bind_method(_MD("emit_signal","signal","arguments"),&Object::_emit_signal,DEFVAL(Array())); diff --git a/core/object.h b/core/object.h index 97ca50cb1a..eb885f5d20 100644 --- a/core/object.h +++ b/core/object.h @@ -386,6 +386,7 @@ friend void postinitialize_handler(Object*); Dictionary metadata; void _add_user_signal(const String& p_name, const Array& p_pargs=Array()); + bool _has_user_signal(const StringName& p_name) const; Variant _emit_signal(const Variant** p_args, int p_argcount, Variant::CallError& r_error); Array _get_signal_list() const; Array _get_signal_connection_list(const String& p_signal) const; -- cgit v1.2.3 From 2d4cad705728c0b9d531bf6088513830f6e08bcc Mon Sep 17 00:00:00 2001 From: Alex Bonfim Date: Sun, 15 Mar 2015 23:17:48 -0300 Subject: Fix for InputEvent::set_as_action --- core/variant_call.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 50a60390e5..c6b498ff28 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -511,7 +511,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(ColorArray,append_array); #define VCALL_PTR0(m_type,m_method)\ -static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast(p_self._data._ptr)->m_method(); } +static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast(p_self._data._ptr)->m_method(); } #define VCALL_PTR0R(m_type,m_method)\ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast(p_self._data._ptr)->m_method(); } #define VCALL_PTR1(m_type,m_method)\ @@ -519,7 +519,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var #define VCALL_PTR1R(m_type,m_method)\ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0]); } #define VCALL_PTR2(m_type,m_method)\ -static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0],*p_args[1]); } +static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0],*p_args[1]); } #define VCALL_PTR2R(m_type,m_method)\ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0],*p_args[1]); } #define VCALL_PTR3(m_type,m_method)\ @@ -531,7 +531,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var #define VCALL_PTR4R(m_type,m_method)\ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); } #define VCALL_PTR5(m_type,m_method)\ -static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3],*p_args[4]); } +static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3],*p_args[4]); } #define VCALL_PTR5R(m_type,m_method)\ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3],*p_args[4]); } @@ -685,7 +685,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_PTR0R( InputEvent, is_pressed ); VCALL_PTR1R( InputEvent, is_action ); VCALL_PTR0R( InputEvent, is_echo ); - //VCALL_PTR2( InputEvent, set_as_action ); + VCALL_PTR2( InputEvent, set_as_action ); struct ConstructData { @@ -1496,7 +1496,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_pressed,varray()); ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action,STRING,"action",varray()); ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_echo,varray()); - //ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray()); + ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray()); /* REGISTER CONSTRUCTORS */ -- cgit v1.2.3 From db0a71fc58137da99137e9fbea3ee982679c9afd Mon Sep 17 00:00:00 2001 From: rollenrolm Date: Sat, 21 Mar 2015 18:33:32 +0100 Subject: New option to show/hide hidden files --- core/io/file_access_pack.cpp | 4 ++++ core/io/file_access_pack.h | 1 + core/os/dir_access.h | 1 + 3 files changed, 6 insertions(+) (limited to 'core') diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 6e03819aac..afbd7e3d46 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -362,6 +362,10 @@ bool DirAccessPack::current_is_dir() const{ return cdir; } +bool DirAccessPack::current_is_hidden() const{ + + return false; +} void DirAccessPack::list_dir_end() { list_dirs.clear(); diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 5fcc79aaf4..2d0cf5b32e 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -208,6 +208,7 @@ public: virtual bool list_dir_begin(); virtual String get_next(); virtual bool current_is_dir() const; + virtual bool current_is_hidden() const; virtual void list_dir_end(); virtual int get_drive_count(); diff --git a/core/os/dir_access.h b/core/os/dir_access.h index d8672218bd..dc56f2308e 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -78,6 +78,7 @@ public: virtual String get_next(bool* p_is_dir); // compatibility virtual String get_next()=0; virtual bool current_is_dir() const=0; + virtual bool current_is_hidden() const=0; virtual void list_dir_end()=0; ///< -- cgit v1.2.3