diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/file_access.cpp | 24 | ||||
-rw-r--r-- | core/os/file_access.h | 3 | ||||
-rw-r--r-- | core/os/input.cpp | 7 | ||||
-rw-r--r-- | core/os/input.h | 2 | ||||
-rw-r--r-- | core/os/mutex.h | 2 | ||||
-rw-r--r-- | core/os/os.cpp | 11 | ||||
-rw-r--r-- | core/os/os.h | 4 |
7 files changed, 49 insertions, 4 deletions
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 23250a7345..31e7d19bae 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -428,8 +428,30 @@ void FileAccess::store_string(const String& p_string) { CharString cs=p_string.utf8(); store_buffer((uint8_t*)&cs[0],cs.length()); - } + +void FileAccess::store_pascal_string(const String& p_string) { + + CharString cs = p_string.utf8(); + store_32(cs.length()); + store_buffer((uint8_t*)&cs[0], cs.length()); +}; + +String FileAccess::get_pascal_string() { + + uint32_t sl = get_32(); + CharString cs; + cs.resize(sl+1); + get_buffer((uint8_t*)cs.ptr(),sl); + cs[sl]=0; + + String ret; + ret.parse_utf8(cs.ptr()); + + return ret; +}; + + void FileAccess::store_line(const String& p_line) { store_string(p_line); diff --git a/core/os/file_access.h b/core/os/file_access.h index bcdae61487..793e971a4c 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -125,6 +125,9 @@ public: virtual void store_string(const String& p_string); virtual void store_line(const String& p_string); + virtual void store_pascal_string(const String& p_string); + virtual String get_pascal_string(); + virtual void store_buffer(const uint8_t *p_src,int p_length); ///< store an array of bytes virtual bool file_exists(const String& p_name)=0; ///< return true if a file exists diff --git a/core/os/input.cpp b/core/os/input.cpp index 3266e4cc10..e732eac323 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -56,6 +56,7 @@ void Input::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer); ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); ObjectTypeDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed); + ObjectTypeDB::bind_method(_MD("get_mouse_button_mask"),&Input::get_mouse_button_mask); ObjectTypeDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode); ObjectTypeDB::bind_method(_MD("get_mouse_mode"),&Input::get_mouse_mode); @@ -280,6 +281,12 @@ Point2 InputDefault::get_mouse_speed() const { return mouse_speed_track.speed; } +int InputDefault::get_mouse_button_mask() const { + + OS::get_singleton()->get_mouse_button_state(); +} + + void InputDefault::iteration(float p_step) { diff --git a/core/os/input.h b/core/os/input.h index 5987d6ef6c..cc51dbf42f 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -64,6 +64,7 @@ public: virtual Point2 get_mouse_pos() const=0; virtual Point2 get_mouse_speed() const=0; + virtual int get_mouse_button_mask() const=0; virtual Vector3 get_accelerometer()=0; @@ -120,6 +121,7 @@ public: virtual Point2 get_mouse_pos() const; virtual Point2 get_mouse_speed() const; + virtual int get_mouse_button_mask() const; void parse_input_event(const InputEvent& p_event); void set_accelerometer(const Vector3& p_accel); diff --git a/core/os/mutex.h b/core/os/mutex.h index 512180d6c7..241d70e232 100644 --- a/core/os/mutex.h +++ b/core/os/mutex.h @@ -50,7 +50,7 @@ public: virtual void lock()=0; ///< Lock the mutex, block if locked by someone else virtual void unlock()=0; ///< Unlock the mutex, let other threads continue - virtual Error try_lock()=0; ///< Attempt to lock the mutex, true on success, false means it can't lock. + virtual Error try_lock()=0; ///< Attempt to lock the mutex, OK on success, ERROR means it can't lock. static Mutex * create(bool p_recursive=true); ///< Create a mutex diff --git a/core/os/os.cpp b/core/os/os.cpp index 141d5f2b58..c9a5cb1af8 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -430,7 +430,7 @@ Error OS::native_video_play(String p_path) { return FAILED; }; -bool OS::native_video_is_playing() { +bool OS::native_video_is_playing() const { return false; }; @@ -447,6 +447,15 @@ void OS::set_mouse_mode(MouseMode p_mode) { } +bool OS::can_use_threads() const { + +#ifdef NO_THREADS + return false; +#else + return true; +#endif +} + OS::MouseMode OS::get_mouse_mode() const{ return MOUSE_MODE_VISIBLE; diff --git a/core/os/os.h b/core/os/os.h index d77d9bee7f..c790b38635 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -316,10 +316,12 @@ public: virtual String get_unique_ID() const; virtual Error native_video_play(String p_path); - virtual bool native_video_is_playing(); + virtual bool native_video_is_playing() const; virtual void native_video_pause(); virtual void native_video_stop(); + virtual bool can_use_threads() const; + virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, Object* p_obj, String p_callback); virtual Error dialog_input_text(String p_title, String p_description, String p_partial, Object* p_obj, String p_callback); |