diff options
36 files changed, 346 insertions, 317 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index c2ed637b79..3e2f8ff263 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -955,6 +955,11 @@ void _OS::native_video_stop() { OS::get_singleton()->native_video_stop(); }; +void _OS::request_attention() { + + OS::get_singleton()->request_attention(); +} + bool _OS::is_debug_build() const { #ifdef DEBUG_ENABLED @@ -1053,6 +1058,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_window_minimized"),&_OS::is_window_minimized); ObjectTypeDB::bind_method(_MD("set_window_maximized", "enabled"),&_OS::set_window_maximized); ObjectTypeDB::bind_method(_MD("is_window_maximized"),&_OS::is_window_maximized); + ObjectTypeDB::bind_method(_MD("request_attention"), &_OS::request_attention); ObjectTypeDB::bind_method(_MD("set_borderless_window", "borderless"), &_OS::set_borderless_window); ObjectTypeDB::bind_method(_MD("get_borderless_window"), &_OS::get_borderless_window); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 64ecd48db1..14203ae863 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -158,6 +158,7 @@ public: virtual bool is_window_minimized() const; virtual void set_window_maximized(bool p_enabled); virtual bool is_window_maximized() const; + virtual void request_attention(); virtual void set_borderless_window(bool p_borderless); virtual bool get_borderless_window() const; diff --git a/core/os/os.h b/core/os/os.h index 40f3989a55..2521d67e29 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -174,6 +174,7 @@ public: virtual bool is_window_minimized() const { return false; } virtual void set_window_maximized(bool p_enabled) {} virtual bool is_window_maximized() const { return true; } + virtual void request_attention() { } virtual void set_borderless_window(int p_borderless) {} virtual bool get_borderless_window() { return 0; } diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 3a33fb9b3b..d9f524e614 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -22889,6 +22889,11 @@ <description> </description> </method> + <method name="request_attention"> + <description> + Request the user attention to the window. It'll flash the taskbar button on Windows or bounce the dock icon on OSX. + </description> + </method> <method name="set_borderless_window"> <argument index="0" name="borderless" type="bool"> </argument> @@ -31113,24 +31118,29 @@ Simple regular expression matcher. </brief_description> <description> - Class for finding text patterns in a string using regular expressions. Regular expressions are a way to define patterns of text to be searched. - This class only finds patterns in a string. It can not perform replacements. - Usage of regular expressions is too long to be explained here, but Internet is full of tutorials and detailed explanations. + Class for finding text patterns in a string using regular expressions. It can not perform replacements. Regular expressions are a way to define patterns of text to be searched. Details on writing patterns are too long to explain here but the Internet is full of tutorials and detailed explanations. + Once created, the RegEx object needs to be compiled with the pattern before it can be used. The pattern must be escaped first for gdscript before it is escaped for the expression. For example: + [code]var exp = RegEx.new()[/code] + [code]exp.compile("\\d+")[/code] + would be read by RegEx as [code]\d+[/code] + Similarly: + [code]exp.compile("\"(?:\\\\.|[^\"])*\"")[/code] + would be read as [code]"(?:\\.|[^"])*"[/code] Currently supported features: - Capturing [code]()[/code] and non-capturing [code](?:)[/code] groups - Any character [code].[/code] - Shorthand character classes [code]\w \W \s \S \d \D[/code] - User-defined character classes such as [code][A-Za-z][/code] - Simple quantifiers [code]?[/code], [code]*[/code] and [code]+[/code] - Range quantifiers [code]{x,y}[/code] - Lazy (non-greedy) quantifiers [code]*?[/code] - Beginning [code]^[/code] and end [code]$[/code] anchors - Alternation [code]|[/code] - Backreferences [code]\1[/code] and [code]\g{1}[/code] - POSIX character classes [code][[:alnum:]][/code] - Lookahead [code](?=)[/code], [code](?!)[/code] and lookbehind [code](?<=)[/code], [code](?<!)[/code] - ASCII [code]\xFF[/code] and Unicode [code]\uFFFF[/code] code points (in a style similar to Python) - Word boundaries [code]\b[/code], [code]\B[/code] + * Capturing [code]()[/code] and non-capturing [code](?:)[/code] groups + * Any character [code].[/code] + * Shorthand character classes [code]\w \W \s \S \d \D[/code] + * User-defined character classes such as [code][A-Za-z][/code] + * Simple quantifiers [code]?[/code], [code]*[/code] and [code]+[/code] + * Range quantifiers [code]{x,y}[/code] + * Lazy (non-greedy) quantifiers [code]*?[/code] + * Beginning [code]^[/code] and end [code]$[/code] anchors + * Alternation [code]|[/code] + * Backreferences [code]\1[/code] and [code]\g{1}[/code] + * POSIX character classes [code][[:alnum:]][/code] + * Lookahead [code](?=)[/code], [code](?!)[/code] and lookbehind [code](?<=)[/code], [code](?<!)[/code] + * ASCII [code]\xFF[/code] and Unicode [code]\uFFFF[/code] code points (in a style similar to Python) + * Word boundaries [code]\b[/code], [code]\B[/code] </description> <methods> <method name="clear"> diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index 6d428e3fe5..419ed977b5 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -192,29 +192,31 @@ void AudioDriverAndroid::thread_func(JNIEnv *env) { env->CallVoidMethod(gob, _write_buffer, (jshortArray)audioBuffer); } - - } int AudioDriverAndroid::get_mix_rate() const { return mix_rate; } + AudioDriverSW::OutputFormat AudioDriverAndroid::get_output_format() const{ return OUTPUT_STEREO; } + void AudioDriverAndroid::lock(){ if (mutex) mutex->lock(); } + void AudioDriverAndroid::unlock() { if (mutex) mutex->unlock(); } + void AudioDriverAndroid::finish(){ JNIEnv *env = ThreadAndroid::get_env(); @@ -236,13 +238,11 @@ void AudioDriverAndroid::set_pause(bool p_pause) { } -AudioDriverAndroid::AudioDriverAndroid() -{ +AudioDriverAndroid::AudioDriverAndroid() { + s_ad=this; active=false; - - } #endif diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index a908f6193e..b7ef1424e5 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -207,6 +207,7 @@ Error AudioDriverOpenSL::init(){ return OK; } + void AudioDriverOpenSL::start(){ @@ -366,26 +367,31 @@ void AudioDriverOpenSL::start(){ active=true; } + int AudioDriverOpenSL::get_mix_rate() const { return 44100; } + AudioDriverSW::OutputFormat AudioDriverOpenSL::get_output_format() const{ return OUTPUT_STEREO; } + void AudioDriverOpenSL::lock(){ if (active && mutex) mutex->lock(); } + void AudioDriverOpenSL::unlock() { if (active && mutex) mutex->unlock(); } + void AudioDriverOpenSL::finish(){ (*sl)->Destroy(sl); diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp index 85df5dc37a..79ba83b3ee 100644 --- a/platform/android/dir_access_android.cpp +++ b/platform/android/dir_access_android.cpp @@ -61,6 +61,7 @@ String DirAccessAndroid::get_next(){ } + bool DirAccessAndroid::current_is_dir() const{ String sd; @@ -79,9 +80,11 @@ bool DirAccessAndroid::current_is_dir() const{ return false; } + bool DirAccessAndroid::current_is_hidden() const{ return current!="." && current!=".." && current.begins_with("."); } + void DirAccessAndroid::list_dir_end(){ if (aad==NULL) @@ -96,6 +99,7 @@ int DirAccessAndroid::get_drive_count(){ return 0; } + String DirAccessAndroid::get_drive(int p_drive){ return ""; @@ -164,6 +168,7 @@ Error DirAccessAndroid::rename(String p_from, String p_to){ ERR_FAIL_V(ERR_UNAVAILABLE); } + Error DirAccessAndroid::remove(String p_name){ ERR_FAIL_V(ERR_UNAVAILABLE); diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 8b7cb992d9..be2ffde2cd 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -76,6 +76,7 @@ String DirAccessJAndroid::get_next(){ return ret; } + bool DirAccessJAndroid::current_is_dir() const{ @@ -106,6 +107,7 @@ int DirAccessJAndroid::get_drive_count(){ return 0; } + String DirAccessJAndroid::get_drive(int p_drive){ return ""; @@ -215,6 +217,7 @@ Error DirAccessJAndroid::rename(String p_from, String p_to){ ERR_FAIL_V(ERR_UNAVAILABLE); } + Error DirAccessJAndroid::remove(String p_name){ ERR_FAIL_V(ERR_UNAVAILABLE); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index f4fafc4fab..10d77aba6c 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1482,6 +1482,7 @@ int EditorExportPlatformAndroid::get_device_count() const { return dc; } + String EditorExportPlatformAndroid::get_device_name(int p_device) const { ERR_FAIL_INDEX_V(p_device,devices.size(),""); @@ -1490,6 +1491,7 @@ String EditorExportPlatformAndroid::get_device_name(int p_device) const { device_lock->unlock(); return s; } + String EditorExportPlatformAndroid::get_device_info(int p_device) const { ERR_FAIL_INDEX_V(p_device,devices.size(),""); @@ -1883,7 +1885,6 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const { EditorExportPlatformAndroid::~EditorExportPlatformAndroid() { - quit_request=true; Thread::wait_to_finish(device_thread); memdelete(device_lock); @@ -1912,6 +1913,5 @@ void register_android_exporter() { Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>( memnew(EditorExportPlatformAndroid) ); EditorImportExport::get_singleton()->add_export_platform(exporter); - } diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index 334d32de0c..aefa16ca9c 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -74,6 +74,7 @@ void FileAccessAndroid::close() { AAsset_close(a); a=NULL; } + bool FileAccessAndroid::is_open() const { return a!=NULL; @@ -92,6 +93,7 @@ void FileAccessAndroid::seek(size_t p_position) { } } + void FileAccessAndroid::seek_end(int64_t p_position) { ERR_FAIL_COND(!a); @@ -99,10 +101,12 @@ void FileAccessAndroid::seek_end(int64_t p_position) { pos=len+p_position; } + size_t FileAccessAndroid::get_pos() const { return pos; } + size_t FileAccessAndroid::get_len() const { return len; @@ -128,6 +132,7 @@ uint8_t FileAccessAndroid::get_8() const { return byte; } + int FileAccessAndroid::get_buffer(uint8_t *p_dst, int p_length) const { diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp index ea33e9a67b..3d2e525bbc 100644 --- a/platform/android/file_access_jandroid.cpp +++ b/platform/android/file_access_jandroid.cpp @@ -90,6 +90,7 @@ void FileAccessJAndroid::close() { id=0; } + bool FileAccessJAndroid::is_open() const { return id!=0; @@ -102,6 +103,7 @@ void FileAccessJAndroid::seek(size_t p_position) { ERR_FAIL_COND(!is_open()); env->CallVoidMethod(io,_file_seek,id,p_position); } + void FileAccessJAndroid::seek_end(int64_t p_position) { ERR_FAIL_COND(!is_open()); @@ -109,6 +111,7 @@ void FileAccessJAndroid::seek_end(int64_t p_position) { seek(get_len()); } + size_t FileAccessJAndroid::get_pos() const { JNIEnv *env = ThreadAndroid::get_env(); @@ -116,13 +119,13 @@ size_t FileAccessJAndroid::get_pos() const { return env->CallIntMethod(io,_file_tell,id); } + size_t FileAccessJAndroid::get_len() const { JNIEnv *env = ThreadAndroid::get_env(); ERR_FAIL_COND_V(!is_open(),0); return env->CallIntMethod(io,_file_get_size,id); - } bool FileAccessJAndroid::eof_reached() const { @@ -167,7 +170,6 @@ Error FileAccessJAndroid::get_error() const { void FileAccessJAndroid::store_8(uint8_t p_dest) { - } bool FileAccessJAndroid::file_exists(const String& p_path) { @@ -195,7 +197,6 @@ bool FileAccessJAndroid::file_exists(const String& p_path) { void FileAccessJAndroid::setup( jobject p_io) { - io=p_io; JNIEnv *env = ThreadAndroid::get_env(); @@ -239,14 +240,12 @@ void FileAccessJAndroid::setup( jobject p_io) { } -FileAccessJAndroid::FileAccessJAndroid() -{ +FileAccessJAndroid::FileAccessJAndroid() { id=0; } -FileAccessJAndroid::~FileAccessJAndroid() -{ +FileAccessJAndroid::~FileAccessJAndroid() { if (is_open()) close(); diff --git a/platform/android/ifaddrs_android.cpp b/platform/android/ifaddrs_android.cpp index c1e9eb3584..f6d5cdbe77 100644 --- a/platform/android/ifaddrs_android.cpp +++ b/platform/android/ifaddrs_android.cpp @@ -38,13 +38,16 @@ #include <errno.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> + struct netlinkrequest { nlmsghdr header; ifaddrmsg msg; }; + namespace { const int kMaxReadSize = 4096; -}; +} + static int set_ifname(struct ifaddrs* ifaddr, int interface) { char buf[IFNAMSIZ] = {0}; char* name = if_indextoname(interface, buf); @@ -55,6 +58,7 @@ static int set_ifname(struct ifaddrs* ifaddr, int interface) { strncpy(ifaddr->ifa_name, name, strlen(name) + 1); return 0; } + static int set_flags(struct ifaddrs* ifaddr) { int fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd == -1) { @@ -71,6 +75,7 @@ static int set_flags(struct ifaddrs* ifaddr) { ifaddr->ifa_flags = ifr.ifr_flags; return 0; } + static int set_addresses(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* data, size_t len) { if (msg->ifa_family == AF_INET) { @@ -89,6 +94,7 @@ static int set_addresses(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* data, } return 0; } + static int make_prefixes(struct ifaddrs* ifaddr, int family, int prefixlen) { char* prefix = NULL; if (family == AF_INET) { @@ -120,6 +126,7 @@ static int make_prefixes(struct ifaddrs* ifaddr, int family, int prefixlen) { *prefix = remainder; return 0; } + static int populate_ifaddrs(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* bytes, size_t len) { if (set_ifname(ifaddr, msg->ifa_index) != 0) { @@ -136,6 +143,7 @@ static int populate_ifaddrs(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* bytes, } return 0; } + int getifaddrs(struct ifaddrs** result) { int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (fd < 0) { @@ -207,6 +215,7 @@ int getifaddrs(struct ifaddrs** result) { freeifaddrs(start); return -1; } + void freeifaddrs(struct ifaddrs* addrs) { struct ifaddrs* last = NULL; struct ifaddrs* cursor = addrs; diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index 4fda13fec0..cc1e5b61d1 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -540,25 +540,21 @@ Variant JavaClass::call(const StringName& p_method,const Variant** p_args,int p_ JavaClass::JavaClass() { - } ///////////////////// Variant JavaObject::call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error){ - return Variant(); } JavaObject::JavaObject(const Ref<JavaClass>& p_base,jobject *p_instance) { - } JavaObject::~JavaObject(){ - } @@ -1356,5 +1352,4 @@ JavaClassWrapper::JavaClassWrapper(jobject p_activity) { bclass = env->FindClass("java/lang/Double"); Double_doubleValue = env->GetMethodID(bclass, "doubleValue", "()D"); - } diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 96e6b85230..e5b655e5d5 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -215,7 +215,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a } return v; -}; +} String _get_class_name(JNIEnv * env, jclass cls, bool* array) { @@ -233,7 +233,7 @@ String _get_class_name(JNIEnv * env, jclass cls, bool* array) { return name; -}; +} Variant _jobject_to_variant(JNIEnv * env, jobject obj) { @@ -406,7 +406,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { env->DeleteLocalRef(c); return Variant(); -}; +} class JNISingleton : public Object { @@ -731,27 +731,27 @@ static void _show_vk(const String& p_existing) { JNIEnv* env = ThreadAndroid::get_env(); jstring jStr = env->NewStringUTF(p_existing.utf8().get_data()); env->CallVoidMethod(godot_io, _showKeyboard, jStr); -}; +} static void _set_screen_orient(int p_orient) { JNIEnv* env = ThreadAndroid::get_env(); env->CallVoidMethod(godot_io, _setScreenOrientation, p_orient ); -}; +} static String _get_system_dir(int p_dir) { JNIEnv *env = ThreadAndroid::get_env(); jstring s =(jstring)env->CallObjectMethod(godot_io,_getSystemDir,p_dir); return String(env->GetStringUTFChars( s, NULL )); -}; +} static void _hide_vk() { JNIEnv* env = ThreadAndroid::get_env(); env->CallVoidMethod(godot_io, _hideKeyboard); -}; +} // virtual Error native_video_play(String p_path); // virtual bool native_video_is_playing(); @@ -953,7 +953,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv * e os_android->reload_gfx(); } - } @@ -968,7 +967,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_quit(JNIEnv * env, jo static void _initialize_java_modules() { - String modules = Globals::get_singleton()->get("android/modules"); Vector<String> mods = modules.split(",",false); print_line("ANDROID MODULES : " + modules); @@ -1417,7 +1415,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv * en input_mutex->lock(); joy_events.push_back(jevent); input_mutex->unlock(); -}; +} JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv * env, jobject obj, jint p_device, jint p_axis, jfloat p_value) { @@ -1430,7 +1428,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv * env, input_mutex->lock(); joy_events.push_back(jevent); input_mutex->unlock(); -}; +} JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv * env, jobject obj, jint p_device, jint p_hat_x, jint p_hat_y) { OS_Android::JoystickEvent jevent; @@ -1493,7 +1491,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv * env, job input_mutex->lock(); key_events.push_back(ievent); input_mutex->unlock(); -}; +} JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z) { @@ -1722,7 +1720,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv * e env->PopLocalFrame(NULL); -}; +} JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env, jobject p_obj, jint ID, jstring method, jobjectArray params) { @@ -1757,7 +1755,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * // something env->PopLocalFrame(NULL); -}; +} //Main::cleanup(); diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index ae7ced45ee..f1c83f01e8 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -58,7 +58,7 @@ extern "C" { JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv * env, jobject obj, jstring path); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv * env, jobject obj, jint ID, jstring method, jobjectArray params); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env, jobject obj, jint ID, jstring method, jobjectArray params); -}; +} #endif diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 1bddf13ad1..4e395a6f9f 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -53,6 +53,7 @@ int OS_Android::get_video_driver_count() const { return 1; } + const char * OS_Android::get_video_driver_name(int p_driver) const { return "GLES2"; @@ -271,17 +272,18 @@ bool OS_Android::is_mouse_grab_enabled() const { //*sigh* technology has evolved so much since i was a kid.. return false; } + Point2 OS_Android::get_mouse_pos() const { return Point2(); } + int OS_Android::get_mouse_button_state() const { return 0; } void OS_Android::set_window_title(const String& p_title) { - } //interesting byt not yet @@ -290,13 +292,13 @@ void OS_Android::set_window_title(const String& p_title) { void OS_Android::set_video_mode(const VideoMode& p_video_mode,int p_screen) { - } OS::VideoMode OS_Android::get_video_mode(int p_screen) const { return default_videomode; } + void OS_Android::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { p_list->push_back(default_videomode); @@ -340,6 +342,7 @@ void OS_Android::main_loop_begin() { if (main_loop) main_loop->init(); } + bool OS_Android::main_loop_iterate() { if (!main_loop) @@ -394,7 +397,7 @@ void OS_Android::process_event(InputEvent p_event) { p_event.ID = last_id++; input->parse_input_event(p_event); -}; +} void OS_Android::process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points) { @@ -627,7 +630,7 @@ bool OS_Android::has_touchscreen_ui_hint() const { bool OS_Android::has_virtual_keyboard() const { return true; -}; +} void OS_Android::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) { @@ -637,7 +640,7 @@ void OS_Android::show_virtual_keyboard(const String& p_existing_text,const Rect2 ERR_PRINT("Virtual keyboard not available"); }; -}; +} void OS_Android::hide_virtual_keyboard() { @@ -648,7 +651,7 @@ void OS_Android::hide_virtual_keyboard() { ERR_PRINT("Virtual keyboard not available"); }; -}; +} void OS_Android::init_video_mode(int p_video_width,int p_video_height) { @@ -684,7 +687,7 @@ Error OS_Android::shell_open(String p_uri) { if (open_uri_func) return open_uri_func(p_uri)?ERR_CANT_OPEN:OK; return ERR_UNAVAILABLE; -}; +} String OS_Android::get_resource_dir() const { @@ -749,12 +752,11 @@ String OS_Android::get_data_dir() const { return "."; //return Globals::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir"); -}; +} void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) { - if (set_screen_orientation_func) set_screen_orientation_func(p_orientation); } @@ -817,7 +819,6 @@ String OS_Android::get_joy_guid(int p_device) const { OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, bool p_use_apk_expansion) { - use_apk_expansion=p_use_apk_expansion; default_videomode.width=800; default_videomode.height=600; @@ -856,5 +857,4 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu OS_Android::~OS_Android() { - } diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp index 61ee237586..73818b282f 100644 --- a/platform/android/thread_jandroid.cpp +++ b/platform/android/thread_jandroid.cpp @@ -64,10 +64,12 @@ Thread* ThreadAndroid::create_func_jandroid(ThreadCreateCallback p_callback,void return tr; } + Thread::ID ThreadAndroid::get_thread_ID_func_jandroid() { return (ID)pthread_self(); } + void ThreadAndroid::wait_to_finish_func_jandroid(Thread* p_thread) { ThreadAndroid *tp=static_cast<ThreadAndroid*>(p_thread); diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index e1c33cb018..8f89695a68 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -202,7 +202,7 @@ public: virtual bool is_window_minimized() const; virtual void set_window_maximized(bool p_enabled); virtual bool is_window_maximized() const; - + virtual void request_attention(); void run(); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 45c500ec39..dc87f767f6 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1577,6 +1577,11 @@ void OS_OSX::move_window_to_foreground() { [window_object orderFrontRegardless]; } +void OS_OSX::request_attention() { + + [NSApp requestUserAttention:NSCriticalRequest]; +} + String OS_OSX::get_executable_path() const { int ret; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index b0a50ca4b8..6aee0d2399 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -581,11 +581,14 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { } } else if (mouse_mode!=MOUSE_MODE_CAPTURED) { // for reasons unknown to mankind, wheel comes in screen cordinates - RECT rect; - GetWindowRect(hWnd,&rect); - mb.x-=rect.left; - mb.y-=rect.top; + POINT coords; + coords.x = mb.x; + coords.y = mb.y; + ScreenToClient(hWnd, &coords); + + mb.x = coords.x; + mb.y = coords.y; } if (main_loop) { @@ -1683,6 +1686,17 @@ bool OS_Windows::get_borderless_window() { return video_mode.borderless_window; } +void OS_Windows::request_attention() { + + FLASHWINFO info; + info.cbSize = sizeof(FLASHWINFO); + info.hwnd = hWnd; + info.dwFlags = FLASHW_TRAY; + info.dwTimeout = 0; + info.uCount = 2; + FlashWindowEx(&info); +} + void OS_Windows::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) { HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 5acb300c0f..e3e037e57b 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -230,6 +230,7 @@ public: virtual bool is_window_minimized() const; virtual void set_window_maximized(bool p_enabled); virtual bool is_window_maximized() const; + virtual void request_attention(); virtual void set_borderless_window(int p_borderless); virtual bool get_borderless_window(); diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 2be8b01dc3..356de7b2bc 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -62,7 +62,6 @@ def get_opts(): ('use_leak_sanitizer','Use llvm compiler sanitize memory leaks','no'), ('pulseaudio','Detect & Use pulseaudio','yes'), ('udev','Use udev for gamepad connection callbacks','no'), - ('new_wm_api', 'Use experimental window management API','no'), ('debug_release', 'Add debug symbols to release version','no'), ] @@ -204,10 +203,6 @@ def configure(env): env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) - if(env["new_wm_api"]=="yes"): - env.Append(CPPFLAGS=['-DNEW_WM_API']) - env.ParseConfig('pkg-config xinerama --cflags --libs') - if (env["use_static_cpp"]=="yes"): env.Append(LINKFLAGS=['-static-libstdc++']) diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp index 4a6a4f3a52..3b854a8d46 100644 --- a/platform/x11/joystick_linux.cpp +++ b/platform/x11/joystick_linux.cpp @@ -259,7 +259,7 @@ void joystick_linux::close_joystick(int p_id) { attached_devices.remove(attached_devices.find(joy.devpath)); input->joy_connection_changed(p_id, false, ""); }; -}; +} static String _hex_str(uint8_t p_byte) { @@ -271,7 +271,7 @@ static String _hex_str(uint8_t p_byte) { ret[1] = dict[p_byte & 0xF]; return ret; -}; +} void joystick_linux::setup_joystick_properties(int p_id) { diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp index 190d6925dd..6443d14897 100644 --- a/platform/x11/key_mapping_x11.cpp +++ b/platform/x11/key_mapping_x11.cpp @@ -197,6 +197,7 @@ unsigned int KeyMappingX11::get_keycode(KeySym p_keysym) { return 0; } + KeySym KeyMappingX11::get_keysym(unsigned int p_code) { // kinda bruteforce.. could optimize. diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 20fae72abd..490030398e 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -216,8 +216,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); } -#if 1 - // NEW_WM_API // borderless fullscreen window mode if (current_videomode.fullscreen) { // needed for lxde/openbox, possibly others @@ -267,22 +265,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XSetWMNormalHints(x11_display, x11_window, xsh); XFree(xsh); } -#else - capture_idle = 0; - minimized = false; - maximized = false; - - if (current_videomode.fullscreen) { - //set_wm_border(false); - set_wm_fullscreen(true); - } - if (!current_videomode.resizable) { - int screen = get_current_screen(); - Size2i screen_size = get_screen_size(screen); - set_window_size(screen_size); - set_window_resizable(false); - } -#endif AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); @@ -440,7 +422,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XFreeGC(x11_display, gc); - if (cursor == None) { ERR_PRINT("FAILED CREATING CURSOR"); @@ -579,7 +560,7 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) { ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime) != - GrabSuccess) { + GrabSuccess) { ERR_PRINT("NO GRAB"); } @@ -643,22 +624,6 @@ OS::VideoMode OS_X11::get_video_mode(int p_screen) const { void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { } -//#ifdef NEW_WM_API -#if 0 -// Just now not needed. Can be used for a possible OS.set_border(bool) method -void OS_X11::set_wm_border(bool p_enabled) { - // needed for lxde/openbox, possibly others - Hints hints; - Atom property; - hints.flags = 2; - hints.decorations = p_enabled ? 1L : 0L; - property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); - XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); - XMapRaised(x11_display, x11_window); - //XMoveResizeWindow(x11_display, x11_window, 0, 0, 800, 800); -} -#endif - void OS_X11::set_wm_fullscreen(bool p_enabled) { // Using EWMH -- Extened Window Manager Hints XEvent xev; @@ -811,54 +776,7 @@ Point2 OS_X11::get_window_position() const { } void OS_X11::set_window_position(const Point2& p_position) { - // Using EWMH -- Extended Window Manager Hints - // to get the size of the decoration -#if 0 - Atom property = XInternAtom(x11_display,"_NET_FRAME_EXTENTS", True); - Atom type; - int format; - unsigned long len; - unsigned long remaining; - unsigned char *data = NULL; - int result; - - result = XGetWindowProperty( - x11_display, - x11_window, - property, - 0, - 32, - False, - AnyPropertyType, - &type, - &format, - &len, - &remaining, - &data - ); - - long left = 0L; - long top = 0L; - - if( result == Success ) { - long *extends = (long *) data; - - left = extends[0]; - top = extends[2]; - - XFree(data); - } - - int screen = get_current_screen(); - Point2i screen_position = get_screen_position(screen); - - left -= screen_position.x; - top -= screen_position.y; - - XMoveWindow(x11_display,x11_window,p_position.x - left,p_position.y - top); -#else XMoveWindow(x11_display,x11_window,p_position.x,p_position.y); -#endif } Size2 OS_X11::get_window_size() const { @@ -902,20 +820,19 @@ bool OS_X11::is_window_resizable() const { } void OS_X11::set_window_minimized(bool p_enabled) { - // Using ICCCM -- Inter-Client Communication Conventions Manual - XEvent xev; - Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False); + // Using ICCCM -- Inter-Client Communication Conventions Manual + XEvent xev; + Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False); - memset(&xev, 0, sizeof(xev)); - xev.type = ClientMessage; - xev.xclient.window = x11_window; - xev.xclient.message_type = wm_change; - xev.xclient.format = 32; - xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState; + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = x11_window; + xev.xclient.message_type = wm_change; + xev.xclient.format = 32; + xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState; - XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); + XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); - //XEvent xev; Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); Atom wm_hidden = XInternAtom(x11_display, "_NET_WM_STATE_HIDDEN", False); @@ -979,47 +896,33 @@ void OS_X11::set_window_maximized(bool p_enabled) { xev.xclient.data.l[2] = wm_max_vert; XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); -/* sorry this does not fix it, fails on multi monitor - XWindowAttributes xwa; - XGetWindowAttributes(x11_display,DefaultRootWindow(x11_display),&xwa); - current_videomode.width = xwa.width; - current_videomode.height = xwa.height; -//*/ - -// current_videomode.width = wm_max_horz; -// current_videomode.height = wm_max_vert; - - //Size2 ss = get_screen_size(get_current_screen()); - //current_videomode.width=ss.width; - //current_videomode.height=ss.height; - maximized = p_enabled; } bool OS_X11::is_window_maximized() const { // Using EWMH -- Extended Window Manager Hints - Atom property = XInternAtom(x11_display,"_NET_WM_STATE",False ); - Atom type; - int format; - unsigned long len; - unsigned long remaining; - unsigned char *data = NULL; + Atom property = XInternAtom(x11_display,"_NET_WM_STATE",False ); + Atom type; + int format; + unsigned long len; + unsigned long remaining; + unsigned char *data = NULL; - int result = XGetWindowProperty( - x11_display, - x11_window, - property, - 0, - 1024, - False, - XA_ATOM, - &type, - &format, - &len, - &remaining, - &data - ); + int result = XGetWindowProperty( + x11_display, + x11_window, + property, + 0, + 1024, + False, + XA_ATOM, + &type, + &format, + &len, + &remaining, + &data + ); if(result == Success) { Atom *atoms = (Atom*) data; @@ -1043,6 +946,26 @@ bool OS_X11::is_window_maximized() const { return false; } +void OS_X11::request_attention() { + // Using EWMH -- Extended Window Manager Hints + // + // Sets the _NET_WM_STATE_DEMANDS_ATTENTION atom for WM_STATE + // Will be unset by the window manager after user react on the request for attention + // + XEvent xev; + Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); + Atom wm_attention = XInternAtom(x11_display, "_NET_WM_STATE_DEMANDS_ATTENTION", False); + + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = x11_window; + xev.xclient.message_type = wm_state; + xev.xclient.format = 32; + xev.xclient.data.l[0] = _NET_WM_STATE_ADD; + xev.xclient.data.l[1] = wm_attention; + + XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); +} InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) { @@ -1363,11 +1286,6 @@ void OS_X11::process_xevents() { } break; case FocusIn: minimized = false; -#ifdef NEW_WM_API - if(current_videomode.fullscreen) { - set_wm_fullscreen(true); - } -#endif main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN); if (mouse_mode==MOUSE_MODE_CAPTURED) { XGrabPointer(x11_display, x11_window, True, @@ -1378,12 +1296,6 @@ void OS_X11::process_xevents() { break; case FocusOut: -#ifdef NEW_WM_API - if(current_videomode.fullscreen) { - set_wm_fullscreen(false); - set_window_minimized(true); - } -#endif main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT); if (mouse_mode==MOUSE_MODE_CAPTURED) { //dear X11, I try, I really try, but you never work, you do whathever you want. @@ -1527,13 +1439,6 @@ void OS_X11::process_xevents() { Point2i rel = pos - last_mouse_pos; -#ifdef NEW_WM_API - if (mouse_mode==MOUSE_MODE_CAPTURED) { - pos.x = current_videomode.width / 2; - pos.y = current_videomode.height / 2; - } -#endif - InputEvent motion_event; motion_event.ID=++event_id; motion_event.type=InputEvent::MOUSE_MOTION; @@ -1816,7 +1721,7 @@ static String _get_clipboard(Atom p_source, Window x11_window, ::Display* x11_di return ret; -}; +} String OS_X11::get_clipboard() const { @@ -1828,7 +1733,7 @@ String OS_X11::get_clipboard() const { }; return ret; -}; +} String OS_X11::get_name() { @@ -2075,4 +1980,4 @@ OS_X11::OS_X11() { minimized = false; xim_style=0L; mouse_mode=MOUSE_MODE_VISIBLE; -}; +} diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 71bbe726dd..b27f71406a 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -253,6 +253,7 @@ public: virtual bool is_window_minimized() const; virtual void set_window_maximized(bool p_enabled); virtual bool is_window_maximized() const; + virtual void request_attention(); virtual void move_window_to_foreground(); virtual void alert(const String& p_alert,const String& p_title="ALERT!"); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index d63c483ef9..2f4f79904d 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -191,7 +191,7 @@ void ItemList::set_item_disabled(int p_idx,bool p_disabled){ ERR_FAIL_INDEX(p_idx,items.size()); items[p_idx].disabled=p_disabled; - + update(); } @@ -225,7 +225,7 @@ void ItemList::select(int p_idx,bool p_single){ if (p_single || select_mode==SELECT_SINGLE) { - if (!items[p_idx].selectable) { + if (!items[p_idx].selectable || items[p_idx].disabled) { return; } @@ -237,7 +237,7 @@ void ItemList::select(int p_idx,bool p_single){ ensure_selected_visible=false; } else { - if (items[p_idx].selectable) { + if (items[p_idx].selectable && !items[p_idx].disabled) { items[p_idx].selected=true; } } @@ -510,7 +510,7 @@ void ItemList::_input_event(const InputEvent& p_event) { } } else { - if (!mb.doubleclick && !mb.mod.command && select_mode==SELECT_MULTI && items[i].selectable && items[i].selected && p_event.mouse_button.button_index==BUTTON_LEFT) { + if (!mb.doubleclick && !mb.mod.command && select_mode==SELECT_MULTI && items[i].selectable && !items[i].disabled && items[i].selected && p_event.mouse_button.button_index==BUTTON_LEFT) { defer_select_single=i; return; } @@ -694,7 +694,7 @@ void ItemList::_input_event(const InputEvent& p_event) { if (select_mode==SELECT_MULTI && current>=0 && current<items.size()) { - if (items[current].selectable && !items[current].selected) { + if (items[current].selectable && !items[current].disabled && !items[current].selected) { select(current,false); emit_signal("multi_selected",current,true); } else if (items[current].selected) { @@ -1029,10 +1029,14 @@ void ItemList::_notification(int p_what) { draw_rect.size=adj.size; } + Color modulate=Color(1,1,1,1); + if (items[i].disabled) + modulate.a*=0.5; + if (items[i].icon_region.has_no_area()) - draw_texture_rect(items[i].icon, draw_rect ); + draw_texture_rect(items[i].icon, draw_rect,false,modulate ); else - draw_texture_rect_region(items[i].icon, draw_rect, items[i].icon_region); + draw_texture_rect_region(items[i].icon, draw_rect, items[i].icon_region,modulate); } @@ -1053,6 +1057,10 @@ void ItemList::_notification(int p_what) { else max_len=size.x; + Color modulate=items[i].selected?font_color_selected:font_color; + if (items[i].disabled) + modulate.a*=0.5; + if (icon_mode==ICON_MODE_TOP && max_text_lines>0) { int ss = items[i].text.length(); @@ -1090,7 +1098,7 @@ void ItemList::_notification(int p_what) { if (line>=max_text_lines) break; } - ofs+=font->draw_char(get_canvas_item(),text_ofs+Vector2(ofs+(max_len-line_size_cache[line])/2,line*(font_height+line_separation)).floor(),items[i].text[j],items[i].text[j+1],items[i].selected?font_color_selected:font_color); + ofs+=font->draw_char(get_canvas_item(),text_ofs+Vector2(ofs+(max_len-line_size_cache[line])/2,line*(font_height+line_separation)).floor(),items[i].text[j],items[i].text[j+1],modulate); } //special multiline mode @@ -1110,7 +1118,7 @@ void ItemList::_notification(int p_what) { text_ofs+=base_ofs; text_ofs+=items[i].rect_cache.pos; - draw_string(font,text_ofs,items[i].text,items[i].selected?font_color_selected:font_color,max_len+1); + draw_string(font,text_ofs,items[i].text,modulate,max_len+1); } @@ -1203,8 +1211,11 @@ String ItemList::get_tooltip(const Point2& p_pos) const { } void ItemList::sort_items_by_text() { + items.sort(); update(); + shape_changed=true; + if (select_mode==SELECT_SINGLE) { for(int i=0;i<items.size();i++) { if (items[i].selected) { @@ -1296,7 +1307,7 @@ void ItemList::_bind_methods(){ ObjectTypeDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item); ObjectTypeDB::bind_method(_MD("clear"),&ItemList::clear); - ObjectTypeDB::bind_method(_MD("sort_items_by_text"),&ItemList::clear); + ObjectTypeDB::bind_method(_MD("sort_items_by_text"),&ItemList::sort_items_by_text); ObjectTypeDB::bind_method(_MD("set_fixed_column_width","width"),&ItemList::set_fixed_column_width); ObjectTypeDB::bind_method(_MD("get_fixed_column_width"),&ItemList::get_fixed_column_width); diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index ae3f4c94a1..e1769d099b 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -860,6 +860,7 @@ void SurfaceTool::_bind_methods() { ObjectTypeDB::bind_method(_MD("deindex"),&SurfaceTool::deindex); ///ObjectTypeDB::bind_method(_MD("generate_flat_normals"),&SurfaceTool::generate_flat_normals); ObjectTypeDB::bind_method(_MD("generate_normals"),&SurfaceTool::generate_normals); + ObjectTypeDB::bind_method(_MD("add_index", "index"), &SurfaceTool::add_index); ObjectTypeDB::bind_method(_MD("commit:Mesh","existing:Mesh"),&SurfaceTool::commit,DEFVAL(Variant())); ObjectTypeDB::bind_method(_MD("clear"),&SurfaceTool::clear); diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index e96cac170b..6b329a1a73 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -235,19 +235,20 @@ struct SpatialIndexer2D { List<VisibilityNotifier2D*> added; List<VisibilityNotifier2D*> removed; - for(int i=begin.x;i<=end.x;i++) { + int visible_cells=(end.x-begin.x)*(end.y-begin.y); - for(int j=begin.y;j<=end.y;j++) { + if (visible_cells>10000) { - CellKey ck; - ck.x=i; - ck.y=j; + //well you zoomed out a lot, it's your problem. To avoid freezing in the for loops below, we'll manually check cell by cell - Map<CellKey,CellData>::Element *F=cells.find(ck); - if (!F) { - continue; - } + for (Map<CellKey,CellData>::Element *F=cells.front();F;F=F->next()) { + + const CellKey &ck=F->key(); + if (ck.x<begin.x || ck.x>end.x) + continue; + if (ck.y<begin.y || ck.y>end.y) + continue; //notifiers in cell for (Map<VisibilityNotifier2D*,CellRef>::Element *G=F->get().notifiers.front();G;G=G->next()) { @@ -262,6 +263,38 @@ struct SpatialIndexer2D { } } } + + } else { + + //check cells in grid fashion + for(int i=begin.x;i<=end.x;i++) { + + for(int j=begin.y;j<=end.y;j++) { + + CellKey ck; + ck.x=i; + ck.y=j; + + Map<CellKey,CellData>::Element *F=cells.find(ck); + if (!F) { + continue; + } + + + //notifiers in cell + for (Map<VisibilityNotifier2D*,CellRef>::Element *G=F->get().notifiers.front();G;G=G->next()) { + + Map<VisibilityNotifier2D*,uint64_t>::Element *H=E->get().notifiers.find(G->key()); + if (!H) { + + H=E->get().notifiers.insert(G->key(),pass); + added.push_back(G->key()); + } else { + H->get()=pass; + } + } + } + } } for (Map<VisibilityNotifier2D*,uint64_t>::Element *F=E->get().notifiers.front();F;F=F->next()) { diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index 07d1566ab8..3ab2e35242 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -164,8 +164,11 @@ void CreateDialog::_update_search() { for(;I;I=I->next()) { + String type=I->get(); + if (base_type=="Node" && type.begins_with("Editor")) + continue; // do not show editor nodes if (!ObjectTypeDB::can_instance(type)) continue; // cant create what can't be instanced diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index d843b6ef6a..3f93c05919 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3822,7 +3822,7 @@ void EditorNode::request_instance_scene(const String &p_path) { } -ScenesDock *EditorNode::get_scenes_dock() { +FileSystemDock *EditorNode::get_scenes_dock() { return scenes_dock; } @@ -6162,7 +6162,7 @@ EditorNode::EditorNode() { //node_dock->set_undoredo(&editor_data.get_undo_redo()); dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(node_dock); - scenes_dock = memnew( ScenesDock(this) ); + scenes_dock = memnew( FileSystemDock(this) ); scenes_dock->set_name(TTR("FileSystem")); scenes_dock->set_use_thumbnails(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_THUMBNAILS); dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scenes_dock); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index d18de1c531..9a227d3644 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -42,7 +42,7 @@ #include "scene/gui/split_container.h" #include "scene/gui/center_container.h" #include "scene/gui/texture_progress.h" -#include "tools/editor/scenes_dock.h" +#include "tools/editor/filesystem_dock.h" #include "tools/editor/scene_tree_editor.h" #include "tools/editor/property_editor.h" #include "tools/editor/create_dialog.h" @@ -275,7 +275,7 @@ private: PropertyEditor *property_editor; NodeDock *node_dock; VBoxContainer *prop_editor_vb; - ScenesDock *scenes_dock; + FileSystemDock *scenes_dock; EditorRunNative *run_native; HBoxContainer *search_bar; @@ -666,7 +666,7 @@ public: static VSplitContainer *get_top_split() { return singleton->top_split; } void request_instance_scene(const String &p_path); - ScenesDock *get_scenes_dock(); + FileSystemDock *get_scenes_dock(); SceneTreeDock *get_scene_tree_dock(); static UndoRedo* get_undo_redo() { return &singleton->editor_data.get_undo_redo(); } diff --git a/tools/editor/editor_profiler.cpp b/tools/editor/editor_profiler.cpp index c9ee60cd54..13327f0be9 100644 --- a/tools/editor/editor_profiler.cpp +++ b/tools/editor/editor_profiler.cpp @@ -135,6 +135,8 @@ void EditorProfiler::_item_edited() { frame_delay->set_wait_time(0.1); frame_delay->start(); } + + _update_plot(); } void EditorProfiler::_update_plot() { diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/filesystem_dock.cpp index 75c983994e..3be122cc7d 100644 --- a/tools/editor/scenes_dock.cpp +++ b/tools/editor/filesystem_dock.cpp @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scenes_dock.h" +#include "filesystem_dock.h" #include "os/dir_access.h" #include "os/file_access.h" #include "globals.h" @@ -39,7 +39,7 @@ #include "scene/main/viewport.h" -bool ScenesDock::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) { +bool FileSystemDock::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) { TreeItem *item = tree->create_item(p_parent); @@ -66,7 +66,7 @@ bool ScenesDock::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_di } -void ScenesDock::_update_tree() { +void FileSystemDock::_update_tree() { tree->clear(); updating_tree=true; @@ -97,7 +97,7 @@ void ScenesDock::_update_tree() { } -void ScenesDock::_notification(int p_what) { +void FileSystemDock::_notification(int p_what) { switch(p_what) { @@ -208,7 +208,7 @@ void ScenesDock::_notification(int p_what) { -void ScenesDock::_dir_selected() { +void FileSystemDock::_dir_selected() { TreeItem *ti = tree->get_selected(); if (!ti) @@ -241,7 +241,7 @@ void ScenesDock::_dir_selected() { } -void ScenesDock::_favorites_pressed() { +void FileSystemDock::_favorites_pressed() { TreeItem *sel = tree->get_selected(); if (!sel) @@ -270,7 +270,7 @@ void ScenesDock::_favorites_pressed() { } -String ScenesDock::get_selected_path() const { +String FileSystemDock::get_selected_path() const { TreeItem *sel = tree->get_selected(); if (!sel) @@ -279,12 +279,12 @@ String ScenesDock::get_selected_path() const { return "res://"+path; } -String ScenesDock::get_current_path() const { +String FileSystemDock::get_current_path() const { return path; } -void ScenesDock::_thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) { +void FileSystemDock::_thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) { bool valid=false; @@ -312,7 +312,7 @@ void ScenesDock::_thumbnail_done(const String& p_path,const Ref<Texture>& p_prev } -void ScenesDock::_change_file_display() { +void FileSystemDock::_change_file_display() { if (display_mode->is_pressed()) { display_mode->set_icon( get_icon("FileThumbnail","EditorIcons")); @@ -324,7 +324,7 @@ void ScenesDock::_change_file_display() { _update_files(true); } -void ScenesDock::_search(EditorFileSystemDirectory *p_path,List<FileInfo>* matches,int p_max_items) { +void FileSystemDock::_search(EditorFileSystemDirectory *p_path,List<FileInfo>* matches,int p_max_items) { if (matches->size()>p_max_items) return; @@ -371,7 +371,7 @@ void ScenesDock::_search(EditorFileSystemDirectory *p_path,List<FileInfo>* match } } -void ScenesDock::_update_files(bool p_keep_selection) { +void FileSystemDock::_update_files(bool p_keep_selection) { Set<String> cselection; @@ -584,13 +584,13 @@ void ScenesDock::_update_files(bool p_keep_selection) { } -void ScenesDock::_select_file(int p_idx) { +void FileSystemDock::_select_file(int p_idx) { files->select(p_idx,true); _file_option(FILE_OPEN); } -void ScenesDock::_go_to_tree() { +void FileSystemDock::_go_to_tree() { tree->show(); file_list_vb->hide(); @@ -602,7 +602,7 @@ void ScenesDock::_go_to_tree() { //file_options->hide(); } -void ScenesDock::_go_to_dir(const String& p_dir){ +void FileSystemDock::_go_to_dir(const String& p_dir){ DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (da->change_dir(p_dir)==OK) { @@ -615,7 +615,7 @@ void ScenesDock::_go_to_dir(const String& p_dir){ } -void ScenesDock::_preview_invalidated(const String& p_path) { +void FileSystemDock::_preview_invalidated(const String& p_path) { if (p_path.get_base_dir()==path && search_box->get_text()==String() && file_list_vb->is_visible()) { @@ -635,7 +635,7 @@ void ScenesDock::_preview_invalidated(const String& p_path) { } } -void ScenesDock::_fs_changed() { +void FileSystemDock::_fs_changed() { button_hist_prev->set_disabled(history_pos==0); button_hist_next->set_disabled(history_pos+1==history.size()); @@ -656,7 +656,7 @@ void ScenesDock::_fs_changed() { set_process(false); } -void ScenesDock::_set_scannig_mode() { +void FileSystemDock::_set_scannig_mode() { split_box->hide(); button_hist_prev->set_disabled(true); @@ -671,7 +671,7 @@ void ScenesDock::_set_scannig_mode() { } -void ScenesDock::_fw_history() { +void FileSystemDock::_fw_history() { if (history_pos<history.size()-1) history_pos++; @@ -695,7 +695,7 @@ void ScenesDock::_fw_history() { } -void ScenesDock::_bw_history() { +void FileSystemDock::_bw_history() { if (history_pos>0) history_pos--; @@ -719,7 +719,7 @@ void ScenesDock::_bw_history() { } -void ScenesDock::_push_to_history() { +void FileSystemDock::_push_to_history() { history.resize(history_pos+1); if (history[history_pos]!=path) { @@ -733,7 +733,7 @@ void ScenesDock::_push_to_history() { } -void ScenesDock::_find_inside_move_files(EditorFileSystemDirectory *efsd,Vector<String>& files) { +void FileSystemDock::_find_inside_move_files(EditorFileSystemDirectory *efsd,Vector<String>& files) { for(int i=0;i<efsd->get_subdir_count();i++) { _find_inside_move_files(efsd->get_subdir(i),files); @@ -744,7 +744,7 @@ void ScenesDock::_find_inside_move_files(EditorFileSystemDirectory *efsd,Vector< } -void ScenesDock::_find_remaps(EditorFileSystemDirectory *efsd,Map<String,String> &renames,List<String>& to_remaps) { +void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd,Map<String,String> &renames,List<String>& to_remaps) { for(int i=0;i<efsd->get_subdir_count();i++) { _find_remaps(efsd->get_subdir(i),renames,to_remaps); @@ -761,7 +761,7 @@ void ScenesDock::_find_remaps(EditorFileSystemDirectory *efsd,Map<String,String> } -void ScenesDock::_rename_operation(const String& p_to_path) { +void FileSystemDock::_rename_operation(const String& p_to_path) { if (move_files[0]==p_to_path) { EditorNode::get_singleton()->show_warning(TTR("Same source and destination files, doing nothing.")); @@ -808,7 +808,7 @@ void ScenesDock::_rename_operation(const String& p_to_path) { } -void ScenesDock::_move_operation(const String& p_to_path) { +void FileSystemDock::_move_operation(const String& p_to_path) { if (p_to_path==path) { EditorNode::get_singleton()->show_warning(TTR("Same source and destination paths, doing nothing.")); @@ -901,7 +901,7 @@ void ScenesDock::_move_operation(const String& p_to_path) { } -void ScenesDock::_file_option(int p_option) { +void FileSystemDock::_file_option(int p_option) { switch(p_option) { @@ -951,7 +951,8 @@ void ScenesDock::_file_option(int p_option) { case FILE_INSTANCE: { for (int i = 0; i<files->get_item_count(); i++) { - + if (!files->is_selected(i)) + continue; String path =files->get_item_metadata(i); if (EditorFileSystem::get_singleton()->get_file_type(path)=="PackedScene") { emit_signal("instance",path); @@ -1085,7 +1086,7 @@ void ScenesDock::_file_option(int p_option) { } } -void ScenesDock::_open_pressed(){ +void FileSystemDock::_open_pressed(){ TreeItem *sel = tree->get_selected(); @@ -1116,7 +1117,7 @@ void ScenesDock::_open_pressed(){ } -void ScenesDock::_search_changed(const String& p_text) { +void FileSystemDock::_search_changed(const String& p_text) { if (!search_box->is_visible()) return; //wtf @@ -1124,29 +1125,29 @@ void ScenesDock::_search_changed(const String& p_text) { _update_files(false); } -void ScenesDock::_rescan() { +void FileSystemDock::_rescan() { _set_scannig_mode(); EditorFileSystem::get_singleton()->scan(); } -void ScenesDock::fix_dependencies(const String& p_for_file) { +void FileSystemDock::fix_dependencies(const String& p_for_file) { deps_editor->edit(p_for_file); } -void ScenesDock::focus_on_filter() { +void FileSystemDock::focus_on_filter() { } -void ScenesDock::set_use_thumbnails(bool p_use) { +void FileSystemDock::set_use_thumbnails(bool p_use) { display_mode->set_pressed(!p_use); } -Variant ScenesDock::get_drag_data_fw(const Point2& p_point,Control* p_from) { +Variant FileSystemDock::get_drag_data_fw(const Point2& p_point,Control* p_from) { if (p_from==tree) { @@ -1223,7 +1224,7 @@ Variant ScenesDock::get_drag_data_fw(const Point2& p_point,Control* p_from) { return Variant(); } -bool ScenesDock::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{ +bool FileSystemDock::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{ Dictionary drag_data = p_data; @@ -1289,7 +1290,7 @@ bool ScenesDock::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Co return false; } -void ScenesDock::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){ +void FileSystemDock::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){ if (!can_drop_data_fw(p_point,p_data,p_from)) return; @@ -1441,7 +1442,7 @@ void ScenesDock::drop_data_fw(const Point2& p_point,const Variant& p_data,Contro } -void ScenesDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) { +void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) { Vector<String> filenames; @@ -1564,35 +1565,35 @@ void ScenesDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) { } -void ScenesDock::_bind_methods() { +void FileSystemDock::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_update_tree"),&ScenesDock::_update_tree); - ObjectTypeDB::bind_method(_MD("_rescan"),&ScenesDock::_rescan); - ObjectTypeDB::bind_method(_MD("_favorites_pressed"),&ScenesDock::_favorites_pressed); + ObjectTypeDB::bind_method(_MD("_update_tree"),&FileSystemDock::_update_tree); + ObjectTypeDB::bind_method(_MD("_rescan"),&FileSystemDock::_rescan); + ObjectTypeDB::bind_method(_MD("_favorites_pressed"),&FileSystemDock::_favorites_pressed); // ObjectTypeDB::bind_method(_MD("_instance_pressed"),&ScenesDock::_instance_pressed); - ObjectTypeDB::bind_method(_MD("_open_pressed"),&ScenesDock::_open_pressed); + ObjectTypeDB::bind_method(_MD("_open_pressed"),&FileSystemDock::_open_pressed); - ObjectTypeDB::bind_method(_MD("_thumbnail_done"),&ScenesDock::_thumbnail_done); - ObjectTypeDB::bind_method(_MD("_select_file"), &ScenesDock::_select_file); - ObjectTypeDB::bind_method(_MD("_go_to_tree"), &ScenesDock::_go_to_tree); - ObjectTypeDB::bind_method(_MD("_go_to_dir"), &ScenesDock::_go_to_dir); - ObjectTypeDB::bind_method(_MD("_change_file_display"), &ScenesDock::_change_file_display); - ObjectTypeDB::bind_method(_MD("_fw_history"), &ScenesDock::_fw_history); - ObjectTypeDB::bind_method(_MD("_bw_history"), &ScenesDock::_bw_history); - ObjectTypeDB::bind_method(_MD("_fs_changed"), &ScenesDock::_fs_changed); - ObjectTypeDB::bind_method(_MD("_dir_selected"), &ScenesDock::_dir_selected); - ObjectTypeDB::bind_method(_MD("_file_option"), &ScenesDock::_file_option); - ObjectTypeDB::bind_method(_MD("_move_operation"), &ScenesDock::_move_operation); - ObjectTypeDB::bind_method(_MD("_rename_operation"), &ScenesDock::_rename_operation); + ObjectTypeDB::bind_method(_MD("_thumbnail_done"),&FileSystemDock::_thumbnail_done); + ObjectTypeDB::bind_method(_MD("_select_file"), &FileSystemDock::_select_file); + ObjectTypeDB::bind_method(_MD("_go_to_tree"), &FileSystemDock::_go_to_tree); + ObjectTypeDB::bind_method(_MD("_go_to_dir"), &FileSystemDock::_go_to_dir); + ObjectTypeDB::bind_method(_MD("_change_file_display"), &FileSystemDock::_change_file_display); + ObjectTypeDB::bind_method(_MD("_fw_history"), &FileSystemDock::_fw_history); + ObjectTypeDB::bind_method(_MD("_bw_history"), &FileSystemDock::_bw_history); + ObjectTypeDB::bind_method(_MD("_fs_changed"), &FileSystemDock::_fs_changed); + ObjectTypeDB::bind_method(_MD("_dir_selected"), &FileSystemDock::_dir_selected); + ObjectTypeDB::bind_method(_MD("_file_option"), &FileSystemDock::_file_option); + ObjectTypeDB::bind_method(_MD("_move_operation"), &FileSystemDock::_move_operation); + ObjectTypeDB::bind_method(_MD("_rename_operation"), &FileSystemDock::_rename_operation); - ObjectTypeDB::bind_method(_MD("_search_changed"), &ScenesDock::_search_changed); + ObjectTypeDB::bind_method(_MD("_search_changed"), &FileSystemDock::_search_changed); - ObjectTypeDB::bind_method(_MD("get_drag_data_fw"), &ScenesDock::get_drag_data_fw); - ObjectTypeDB::bind_method(_MD("can_drop_data_fw"), &ScenesDock::can_drop_data_fw); - ObjectTypeDB::bind_method(_MD("drop_data_fw"), &ScenesDock::drop_data_fw); - ObjectTypeDB::bind_method(_MD("_files_list_rmb_select"),&ScenesDock::_files_list_rmb_select); + ObjectTypeDB::bind_method(_MD("get_drag_data_fw"), &FileSystemDock::get_drag_data_fw); + ObjectTypeDB::bind_method(_MD("can_drop_data_fw"), &FileSystemDock::can_drop_data_fw); + ObjectTypeDB::bind_method(_MD("drop_data_fw"), &FileSystemDock::drop_data_fw); + ObjectTypeDB::bind_method(_MD("_files_list_rmb_select"),&FileSystemDock::_files_list_rmb_select); - ObjectTypeDB::bind_method(_MD("_preview_invalidated"),&ScenesDock::_preview_invalidated); + ObjectTypeDB::bind_method(_MD("_preview_invalidated"),&FileSystemDock::_preview_invalidated); ADD_SIGNAL(MethodInfo("instance")); @@ -1600,7 +1601,7 @@ void ScenesDock::_bind_methods() { } -ScenesDock::ScenesDock(EditorNode *p_editor) { +FileSystemDock::FileSystemDock(EditorNode *p_editor) { editor=p_editor; @@ -1766,6 +1767,6 @@ ScenesDock::ScenesDock(EditorNode *p_editor) { add_constant_override("separation",3); } -ScenesDock::~ScenesDock() { +FileSystemDock::~FileSystemDock() { } diff --git a/tools/editor/scenes_dock.h b/tools/editor/filesystem_dock.h index 0973fce250..171dbd16e9 100644 --- a/tools/editor/scenes_dock.h +++ b/tools/editor/filesystem_dock.h @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SCENES_DOCK_H -#define SCENES_DOCK_H +#ifndef FILESYSTEM_DOCK_H +#define FILESYSTEM_DOCK_H #include "scene/main/timer.h" #include "scene/gui/control.h" @@ -51,8 +51,8 @@ class EditorNode; -class ScenesDock : public VBoxContainer { - OBJ_TYPE( ScenesDock, VBoxContainer ); +class FileSystemDock : public VBoxContainer { + OBJ_TYPE( FileSystemDock, VBoxContainer ); enum FileMenu { FILE_OPEN, @@ -184,8 +184,8 @@ public: void set_use_thumbnails(bool p_use); - ScenesDock(EditorNode *p_editor); - ~ScenesDock(); + FileSystemDock(EditorNode *p_editor); + ~FileSystemDock(); }; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index ec5ac8592b..02a24f8ddb 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -41,6 +41,11 @@ #include "tools/editor/plugins/animation_player_editor_plugin.h" #include "scene/resources/packed_scene.h" + +#define MIN_ZOOM 0.01 +#define MAX_ZOOM 100 + + class SnapDialog : public ConfirmationDialog { OBJ_TYPE(SnapDialog,ConfirmationDialog); @@ -1062,6 +1067,9 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { if (b.button_index==BUTTON_WHEEL_DOWN) { + if (zoom<MIN_ZOOM) + return; + float prev_zoom=zoom; zoom=zoom*0.95; { @@ -1077,6 +1085,9 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { if (b.button_index==BUTTON_WHEEL_UP) { + if (zoom>MAX_ZOOM) + return; + float prev_zoom=zoom; zoom=zoom*(1.0/0.95); { @@ -2526,12 +2537,17 @@ void CanvasItemEditor::_popup_callback(int p_op) { snap_dialog->popup_centered(Size2(220,160)); } break; case ZOOM_IN: { + if (zoom>MAX_ZOOM) + return; zoom=zoom*(1.0/0.5); _update_scroll(0); viewport->update(); return; } break; case ZOOM_OUT: { + if (zoom<MIN_ZOOM) + return; + zoom=zoom*0.5; _update_scroll(0); viewport->update(); |