diff options
-rw-r--r-- | doc/classes/EditorInspectorPlugin.xml | 2 | ||||
-rw-r--r-- | doc/classes/EditorPlugin.xml | 4 | ||||
-rw-r--r-- | editor/editor_inspector.h | 2 | ||||
-rw-r--r-- | editor/editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/editor_plugin.h | 4 | ||||
-rw-r--r-- | editor/plugins/sprite_frames_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | platform/android/display_server_android.cpp | 2 | ||||
-rw-r--r-- | platform/linuxbsd/x11/display_server_x11.cpp | 2 | ||||
-rw-r--r-- | platform/macos/display_server_macos.mm | 2 | ||||
-rw-r--r-- | platform/web/display_server_web.cpp | 1 | ||||
-rw-r--r-- | platform/windows/display_server_windows.cpp | 2 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 14 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 4 |
13 files changed, 32 insertions, 19 deletions
diff --git a/doc/classes/EditorInspectorPlugin.xml b/doc/classes/EditorInspectorPlugin.xml index 7ffd7f9426..bbd383edc0 100644 --- a/doc/classes/EditorInspectorPlugin.xml +++ b/doc/classes/EditorInspectorPlugin.xml @@ -18,7 +18,7 @@ <methods> <method name="_can_handle" qualifiers="virtual const"> <return type="bool" /> - <param index="0" name="object" type="Variant" /> + <param index="0" name="object" type="Object" /> <description> Returns [code]true[/code] if this object can be handled by this plugin. </description> diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index f4b912de9e..95c0f8efe1 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -38,7 +38,7 @@ </method> <method name="_edit" qualifiers="virtual"> <return type="void" /> - <param index="0" name="object" type="Variant" /> + <param index="0" name="object" type="Object" /> <description> This function is used for plugins that edit specific object types (nodes or resources). It requests the editor to edit the given object. [param object] can be [code]null[/code] if the plugin was editing an object, but there is no longer any selected object handled by this plugin. It can be used to cleanup editing state. @@ -295,7 +295,7 @@ </method> <method name="_handles" qualifiers="virtual const"> <return type="bool" /> - <param index="0" name="object" type="Variant" /> + <param index="0" name="object" type="Object" /> <description> Implement this function if your plugin edits a specific type of object (Resource or Node). If you return [code]true[/code], then you will get the functions [method _edit] and [method _make_visible] called when the editor requests them. If you have declared the methods [method _forward_canvas_gui_input] and [method _forward_3d_gui_input] these will be called too. </description> diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 4ffba18181..01231108d8 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -225,7 +225,7 @@ public: protected: static void _bind_methods(); - GDVIRTUAL1RC(bool, _can_handle, Variant) + GDVIRTUAL1RC(bool, _can_handle, Object *) GDVIRTUAL1(_parse_begin, Object *) GDVIRTUAL2(_parse_category, Object *, String) GDVIRTUAL2(_parse_group, Object *, String) diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 14cdbc364e..7b01ae69bf 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -662,11 +662,7 @@ void EditorPlugin::make_visible(bool p_visible) { } void EditorPlugin::edit(Object *p_object) { - if (Object::cast_to<Resource>(p_object)) { - GDVIRTUAL_CALL(_edit, Ref<Resource>(Object::cast_to<Resource>(p_object))); - } else { - GDVIRTUAL_CALL(_edit, p_object); - } + GDVIRTUAL_CALL(_edit, p_object); } bool EditorPlugin::handles(Object *p_object) const { diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index a5a17acdf1..74f46b2d0b 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -164,8 +164,8 @@ protected: GDVIRTUAL0RC(Ref<Texture2D>, _get_plugin_icon) GDVIRTUAL0RC(bool, _has_main_screen) GDVIRTUAL1(_make_visible, bool) - GDVIRTUAL1(_edit, Variant) - GDVIRTUAL1RC(bool, _handles, Variant) + GDVIRTUAL1(_edit, Object *) + GDVIRTUAL1RC(bool, _handles, Object *) GDVIRTUAL0RC(Dictionary, _get_state) GDVIRTUAL1(_set_state, Dictionary) GDVIRTUAL0(_clear) diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index c41bf4b8cc..20b3cf3618 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -807,13 +807,17 @@ void SpriteFramesEditor::_animation_name_edited() { return; } + if (new_name.is_empty()) { + new_name = "new_animation"; + } + new_name = new_name.replace("/", "_").replace(",", " "); String name = new_name; int counter = 0; while (frames->has_animation(name)) { counter++; - name = new_name + " " + itos(counter); + name = new_name + "_" + itos(counter); } EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 3fcb926f86..af4ba1255b 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -656,6 +656,7 @@ void DisplayServerAndroid::_cursor_set_shape_helper(CursorShape p_shape, bool fo } void DisplayServerAndroid::cursor_set_shape(DisplayServer::CursorShape p_shape) { + ERR_FAIL_INDEX(p_shape, CURSOR_MAX); _cursor_set_shape_helper(p_shape); } @@ -664,6 +665,7 @@ DisplayServer::CursorShape DisplayServerAndroid::cursor_get_shape() const { } void DisplayServerAndroid::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { + ERR_FAIL_INDEX(p_shape, CURSOR_MAX); String cursor_path = p_cursor.is_valid() ? p_cursor->get_path() : ""; if (!cursor_path.is_empty()) { cursor_path = ProjectSettings::get_singleton()->globalize_path(cursor_path); diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index 30ab59dfd1..dff2f536a8 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -2615,6 +2615,8 @@ DisplayServerX11::CursorShape DisplayServerX11::cursor_get_shape() const { void DisplayServerX11::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { _THREAD_SAFE_METHOD_ + ERR_FAIL_INDEX(p_shape, CURSOR_MAX); + if (p_cursor.is_valid()) { HashMap<CursorShape, Vector<Variant>>::Iterator cursor_c = cursors_cache.find(p_shape); diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 65546392c1..14778b5f03 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -3284,6 +3284,8 @@ DisplayServerMacOS::CursorShape DisplayServerMacOS::cursor_get_shape() const { void DisplayServerMacOS::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { _THREAD_SAFE_METHOD_ + ERR_FAIL_INDEX(p_shape, CURSOR_MAX); + if (p_cursor.is_valid()) { HashMap<CursorShape, Vector<Variant>>::Iterator cursor_c = cursors_cache.find(p_shape); diff --git a/platform/web/display_server_web.cpp b/platform/web/display_server_web.cpp index e89a79834b..565d439a92 100644 --- a/platform/web/display_server_web.cpp +++ b/platform/web/display_server_web.cpp @@ -395,6 +395,7 @@ DisplayServer::CursorShape DisplayServerWeb::cursor_get_shape() const { } void DisplayServerWeb::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { + ERR_FAIL_INDEX(p_shape, CURSOR_MAX); if (p_cursor.is_valid()) { Ref<Texture2D> texture = p_cursor; Ref<AtlasTexture> atlas_texture = p_cursor; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 1cfc9c9f47..d2889a3442 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1719,6 +1719,8 @@ DisplayServer::CursorShape DisplayServerWindows::cursor_get_shape() const { void DisplayServerWindows::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { _THREAD_SAFE_METHOD_ + ERR_FAIL_INDEX(p_shape, CURSOR_MAX); + if (p_cursor.is_valid()) { RBMap<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 25a27d5e1a..d367a8d281 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -801,8 +801,9 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) { search_string = ""; //any mousepress cancels for (int i = 4; i > 0; i--) { - if (current - current_columns * i >= 0 && CAN_SELECT(current - current_columns * i)) { - set_current(current - current_columns * i); + int index = current - current_columns * i; + if (index >= 0 && index < items.size() && CAN_SELECT(index)) { + set_current(index); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { emit_signal(SNAME("item_selected"), current); @@ -815,8 +816,9 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) { search_string = ""; //any mousepress cancels for (int i = 4; i > 0; i--) { - if (current + current_columns * i < items.size() && CAN_SELECT(current + current_columns * i)) { - set_current(current + current_columns * i); + int index = current + current_columns * i; + if (index >= 0 && index < items.size() && CAN_SELECT(index)) { + set_current(index); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { emit_signal(SNAME("item_selected"), current); @@ -832,7 +834,7 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) { if (current % current_columns != 0) { int current_row = current / current_columns; int next = current - 1; - while (!CAN_SELECT(next)) { + while (next >= 0 && !CAN_SELECT(next)) { next = next - 1; } if (next < 0 || !IS_SAME_ROW(next, current_row)) { @@ -852,7 +854,7 @@ void ItemList::gui_input(const Ref<InputEvent> &p_event) { if (current % current_columns != (current_columns - 1) && current + 1 < items.size()) { int current_row = current / current_columns; int next = current + 1; - while (!CAN_SELECT(next)) { + while (next < items.size() && !CAN_SELECT(next)) { next = next + 1; } if (items.size() <= next || !IS_SAME_ROW(next, current_row)) { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index d785280701..2b3b577697 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4362,7 +4362,9 @@ int TextEdit::get_minimap_line_at_pos(const Point2i &p_pos) const { if (first_vis_line > 0 && minimap_line >= 0) { minimap_line -= get_next_visible_line_index_offset_from(first_vis_line, 0, -num_lines_before).x; minimap_line -= (minimap_line > 0 && smooth_scroll_enabled ? 1 : 0); - } else { + } + + if (minimap_line < 0) { minimap_line = 0; } |