diff options
-rw-r--r-- | doc/base/classes.xml | 9 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 18 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 6 | ||||
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/GodotIO.java | 6 | ||||
-rw-r--r-- | platform/android/java_glue.cpp | 10 | ||||
-rw-r--r-- | platform/android/os_android.cpp | 10 | ||||
-rw-r--r-- | platform/android/os_android.h | 5 | ||||
-rw-r--r-- | scene/gui/base_button.cpp | 2 | ||||
-rw-r--r-- | tools/editor/plugins/canvas_item_editor_plugin.cpp | 19 |
9 files changed, 69 insertions, 16 deletions
diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 9eff657577..b8156133de 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -22557,6 +22557,15 @@ <argument index="0" name="screen" type="int" default="0"> </argument> <description> + Returns the dots per inch density of the specified screen. + + On Android Devices, the actual screen densities are grouped into six generalized densities: + ldpi - 120 dpi + mdpi - 160 dpi + hdpi - 240 dpi + xhdpi - 320 dpi + xxhdpi - 480 dpi + xxxhdpi - 640 dpi </description> </method> <method name="get_screen_orientation" qualifiers="const"> diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index d9783c218a..d1946e2a63 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1643,13 +1643,16 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script>& p_script,bool p_sof } #endif + for(Map<ObjectID,List<Pair<StringName,Variant> > >::Element *F=E->get()->pending_reload_state.front();F;F=F->next()) { + map[F->key()]=F->get(); //pending to reload, use this one instead + } } } for(Map< Ref<GDScript>, Map<ObjectID,List<Pair<StringName,Variant> > > >::Element *E=to_reload.front();E;E=E->next()) { Ref<GDScript> scr = E->key(); - scr->reload(true); + scr->reload(p_soft_reload); //restore state if saved for (Map<ObjectID,List<Pair<StringName,Variant> > >::Element *F=E->get().front();F;F=F->next()) { @@ -1658,13 +1661,24 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script>& p_script,bool p_sof if (!obj) continue; + if (!p_soft_reload) { + //clear it just in case (may be a pending reload state) + obj->set_script(RefPtr()); + } obj->set_script(scr.get_ref_ptr()); - if (!obj->get_script_instance()) + if (!obj->get_script_instance()) { + //failed, save reload state for next time if not saved + if (!scr->pending_reload_state.has(obj->get_instance_ID())) { + scr->pending_reload_state[obj->get_instance_ID()]=F->get(); + } continue; + } for (List<Pair<StringName,Variant> >::Element *G=F->get().front();G;G=G->next()) { obj->get_script_instance()->set(G->get().first,G->get().second); } + + scr->pending_reload_state.erase(obj->get_instance_ID()); //as it reloaded, remove pending state } //if instance states were saved, set them! diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 723761c3a9..f0b6b7103c 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -120,7 +120,11 @@ friend class GDScriptLanguage; virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder); #endif +#ifdef DEBUG_ENABLED + + Map<ObjectID,List<Pair<StringName,Variant> > > pending_reload_state; +#endif bool _update_exports(); @@ -265,6 +269,8 @@ class GDScriptLanguage : public ScriptLanguage { Mutex *lock; + + friend class GDScript; SelfList<GDScript>::List script_list; diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java index 3e6919c2ad..55e330924a 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java @@ -40,6 +40,7 @@ import android.view.*; import android.view.inputmethod.InputMethodManager; import android.os.*; import android.util.Log; +import android.util.DisplayMetrics; import android.graphics.*; import android.text.method.*; import android.text.*; @@ -513,6 +514,11 @@ public class GodotIO { return Build.MODEL; } + public int getScreenDPI() { + DisplayMetrics metrics = applicationContext.getResources().getDisplayMetrics(); + return (int)(metrics.density * 160f); + } + public boolean needsReloadHooks() { return android.os.Build.VERSION.SDK_INT < 11; diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index b9d178280c..96e6b85230 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -668,6 +668,7 @@ static jmethodID _openURI=0; static jmethodID _getDataDir=0; static jmethodID _getLocale=0; static jmethodID _getModel=0; +static jmethodID _getScreenDPI=0; static jmethodID _showKeyboard=0; static jmethodID _hideKeyboard=0; static jmethodID _setScreenOrientation=0; @@ -712,6 +713,12 @@ static String _get_model() { return String(env->GetStringUTFChars( s, NULL )); } +static int _get_screen_dpi() { + + JNIEnv *env = ThreadAndroid::get_env(); + return env->CallIntMethod(godot_io,_getScreenDPI); +} + static String _get_unique_id() { JNIEnv *env = ThreadAndroid::get_env(); @@ -821,6 +828,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv * e _getDataDir = env->GetMethodID(c,"getDataDir","()Ljava/lang/String;"); _getLocale = env->GetMethodID(c,"getLocale","()Ljava/lang/String;"); _getModel = env->GetMethodID(c,"getModel","()Ljava/lang/String;"); + _getScreenDPI = env->GetMethodID(c, "getScreenDPI","()I"); _getUniqueID = env->GetMethodID(c,"getUniqueID","()Ljava/lang/String;"); _showKeyboard = env->GetMethodID(c,"showKeyboard","(Ljava/lang/String;)V"); _hideKeyboard = env->GetMethodID(c,"hideKeyboard","()V"); @@ -875,7 +883,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv * e __android_log_print(ANDROID_LOG_INFO,"godot","CMDLINE LEN %i - APK EXPANSION %I\n",cmdlen,int(use_apk_expansion)); - os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _get_system_dir, _play_video,_is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, use_apk_expansion); + os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _get_system_dir, _play_video,_is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, use_apk_expansion); os_android->set_need_reload_hooks(p_need_reload_hook); char wd[500]; diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 3c2b4c22e7..1bddf13ad1 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -705,6 +705,13 @@ String OS_Android::get_model_name() const { return OS_Unix::get_model_name(); } +int OS_Android::get_screen_dpi(int p_screen) const { + + if (get_screen_dpi_func) { + return get_screen_dpi_func(); + } + return 160; +} void OS_Android::set_need_reload_hooks(bool p_needs_them) { @@ -808,7 +815,7 @@ String OS_Android::get_joy_guid(int p_device) const { return input->get_joy_guid_remapped(p_device); } -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, 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) { +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; @@ -829,6 +836,7 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu get_data_dir_func=p_get_data_dir_func; get_locale_func=p_get_locale_func; get_model_func=p_get_model_func; + get_screen_dpi_func = p_get_screen_dpi_func; get_unique_id_func=p_get_unique_id; get_system_dir_func=p_get_sdir_func; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 7f39784a74..d383fd2036 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -63,6 +63,7 @@ typedef int (*OpenURIFunc)(const String&); typedef String (*GetDataDirFunc)(); typedef String (*GetLocaleFunc)(); typedef String (*GetModelFunc)(); +typedef int (*GetScreenDPIFunc)(); typedef String (*GetUniqueIDFunc)(); typedef void (*ShowVirtualKeyboardFunc)(const String&); typedef void (*HideVirtualKeyboardFunc)(); @@ -141,6 +142,7 @@ private: GetDataDirFunc get_data_dir_func; GetLocaleFunc get_locale_func; GetModelFunc get_model_func; + GetScreenDPIFunc get_screen_dpi_func; ShowVirtualKeyboardFunc show_virtual_keyboard_func; HideVirtualKeyboardFunc hide_virtual_keyboard_func; SetScreenOrientationFunc set_screen_orientation_func; @@ -234,6 +236,7 @@ public: virtual String get_resource_dir() const; virtual String get_locale() const; virtual String get_model_name() const; + virtual int get_screen_dpi(int p_screen=0) const; virtual String get_unique_ID() const; @@ -257,7 +260,7 @@ public: virtual String get_joy_guid(int p_device) const; void joy_connection_changed(int p_device, bool p_connected, String p_name); - 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, 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); + 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); ~OS_Android(); }; diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 699062fee4..41d766c1b7 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -416,7 +416,7 @@ Ref<ShortCut> BaseButton:: get_shortcut() const { void BaseButton::_unhandled_input(InputEvent p_event) { - if (!is_disabled() && is_visible() && p_event.is_pressed() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) { + if (!is_disabled() && is_visible() && p_event.is_pressed() && !p_event.is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) { if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this)) return; //ignore because of modal window diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index f9499904db..ec5ac8592b 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -199,16 +199,12 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) { if (!is_visible() || get_viewport()->gui_has_modal_stack()) return; + if (p_ev.key.mod.control) - // prevent to change tool mode when control key is pressed return; - if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_Q) - _tool_select(TOOL_SELECT); - if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_W) - _tool_select(TOOL_MOVE); - if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_E) - _tool_select(TOOL_ROTATE); + if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_V && drag==DRAG_NONE && can_move_pivot) { + if (p_ev.key.mod.shift) { //move drag pivot drag=DRAG_PIVOT; @@ -3296,20 +3292,23 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { hb->add_child(select_button); select_button->connect("pressed",this,"_tool_select",make_binds(TOOL_SELECT)); select_button->set_pressed(true); - select_button->set_tooltip(TTR("Select Mode (Q)")+"\n"+keycode_get_string(KEY_MASK_CMD)+TTR("Drag: Rotate")+"\n"+TTR("Alt+Drag: Move")+"\n"+TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).")+"\n"+TTR("Alt+RMB: Depth list selection")); + select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode",TTR("Select Mode"),KEY_Q)); + select_button->set_tooltip(TTR("Select Mode")+" $sc\n"+keycode_get_string(KEY_MASK_CMD)+TTR("Drag: Rotate")+"\n"+TTR("Alt+Drag: Move")+"\n"+TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).")+"\n"+TTR("Alt+RMB: Depth list selection")); move_button = memnew( ToolButton ); move_button->set_toggle_mode(true); hb->add_child(move_button); move_button->connect("pressed",this,"_tool_select",make_binds(TOOL_MOVE)); - move_button->set_tooltip(TTR("Move Mode (W)")); + move_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/move_mode",TTR("Move Mode"),KEY_W)); + move_button->set_tooltip(TTR("Move Mode")); rotate_button = memnew( ToolButton ); rotate_button->set_toggle_mode(true); hb->add_child(rotate_button); rotate_button->connect("pressed",this,"_tool_select",make_binds(TOOL_ROTATE)); - rotate_button->set_tooltip(TTR("Rotate Mode (E)")); + rotate_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/rotate_mode",TTR("Rotate Mode"),KEY_E)); + rotate_button->set_tooltip(TTR("Rotate Mode")); hb->add_child(memnew(VSeparator)); |