Sfoglia il codice sorgente

Improve `TileMap` and `TileSet` editors UI

arkology 6 mesi fa
parent
commit
1be23eee2c

+ 6 - 1
editor/plugins/tiles/tile_map_layer_editor.cpp

@@ -2371,6 +2371,7 @@ TileMapLayerEditorTilesPlugin::TileMapLayerEditorTilesPlugin() {
 
 	missing_source_label = memnew(Label);
 	missing_source_label->set_text(TTR("This TileMap's TileSet has no Tile Source configured. Go to the TileSet bottom panel to add one."));
+	missing_source_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
 	missing_source_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
 	missing_source_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
 	missing_source_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
@@ -2489,8 +2490,9 @@ TileMapLayerEditorTilesPlugin::TileMapLayerEditorTilesPlugin() {
 
 	patterns_help_label = memnew(Label);
 	patterns_help_label->set_text(TTR("Drag and drop or paste a TileMap selection here to store a pattern."));
+	patterns_help_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
 	patterns_help_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
-	patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_CENTER);
+	patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_HCENTER_WIDE);
 	patterns_item_list->add_child(patterns_help_label);
 
 	// Update.
@@ -4113,6 +4115,7 @@ void TileMapLayerEditor::_tab_changed(int p_tab_id) {
 	// Graphical update.
 	tabs_data[tabs_bar->get_current_tab()].panel->queue_redraw();
 	CanvasItemEditor::get_singleton()->update_viewport();
+	_update_bottom_panel();
 }
 
 void TileMapLayerEditor::_layers_select_next_or_previous(bool p_next) {
@@ -4521,6 +4524,8 @@ TileMapLayerEditor::TileMapLayerEditor() {
 
 	// A label for editing errors.
 	cant_edit_label = memnew(Label);
+	cant_edit_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
+	cant_edit_label->set_anchors_and_offsets_preset(Control::PRESET_HCENTER_WIDE);
 	cant_edit_label->set_h_size_flags(SIZE_EXPAND_FILL);
 	cant_edit_label->set_v_size_flags(SIZE_EXPAND_FILL);
 	cant_edit_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);

+ 15 - 13
editor/plugins/tiles/tile_set_atlas_source_editor.cpp

@@ -968,7 +968,15 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
 	if (tile_set.is_null()) {
 		return;
 	} else {
-		tile_create_help->set_visible(tools_button_group->get_pressed_button() == tool_setup_atlas_source_button);
+		if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) {
+			help_label->set_visible(true);
+			help_label->set_text(TTR("Hold Ctrl to create multiple tiles.") + "\n" + TTR("Hold Shift to create big tiles."));
+		} else if (tools_button_group->get_pressed_button() == tool_select_button) {
+			help_label->set_visible(true);
+			help_label->set_text(TTRC("Hold Shift to select multiple regions."));
+		} else {
+			help_label->set_visible(false);
+		}
 	}
 
 	if (tools_button_group->get_pressed_button() != tool_paint_button) {
@@ -2685,18 +2693,12 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
 	tile_atlas_view->connect("transform_changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_atlas_view_transform_changed).unbind(2));
 	right_panel->add_child(tile_atlas_view);
 
-	tile_create_help = memnew(VBoxContainer);
-	tile_atlas_view->add_child(tile_create_help);
-	tile_create_help->set_mouse_filter(MOUSE_FILTER_IGNORE);
-
-	Label *help_label = memnew(Label(TTR("Hold Ctrl to create multiple tiles.")));
-	tile_create_help->add_child(help_label);
-
-	help_label = memnew(Label(TTR("Hold Shift to create big tiles.")));
-	tile_create_help->add_child(help_label);
-
-	tile_create_help->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_LEFT, Control::PRESET_MODE_MINSIZE, 8);
-	tile_create_help->set_grow_direction_preset(Control::PRESET_BOTTOM_LEFT);
+	help_label = memnew(Label);
+	help_label->set_mouse_filter(MOUSE_FILTER_IGNORE);
+	help_label->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
+	help_label->set_vertical_alignment(VERTICAL_ALIGNMENT_BOTTOM);
+	help_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
+	tile_atlas_view->add_child(help_label);
 
 	base_tile_popup_menu = memnew(PopupMenu);
 	base_tile_popup_menu->add_shortcut(ED_GET_SHORTCUT("tiles_editor/delete"), TILE_DELETE);

+ 1 - 1
editor/plugins/tiles/tile_set_atlas_source_editor.h

@@ -159,7 +159,7 @@ private:
 
 	// -- Atlas view --
 	TileAtlasView *tile_atlas_view = nullptr;
-	VBoxContainer *tile_create_help = nullptr;
+	Label *help_label = nullptr;
 
 	// Dragging
 	enum DragType {

+ 6 - 1
editor/plugins/tiles/tile_set_editor.cpp

@@ -914,6 +914,8 @@ TileSetEditor::TileSetEditor() {
 	// No source selected.
 	no_source_selected_label = memnew(Label);
 	no_source_selected_label->set_text(TTR("No TileSet source selected. Select or create a TileSet source.\nYou can create a new source by using the Add button on the left or by dropping a tileset texture onto the source list."));
+	no_source_selected_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
+	no_source_selected_label->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
 	no_source_selected_label->set_h_size_flags(SIZE_EXPAND_FILL);
 	no_source_selected_label->set_v_size_flags(SIZE_EXPAND_FILL);
 	no_source_selected_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
@@ -953,8 +955,9 @@ TileSetEditor::TileSetEditor() {
 
 	patterns_help_label = memnew(Label);
 	patterns_help_label->set_text(TTR("Add new patterns in the TileMap editing mode."));
+	patterns_help_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
 	patterns_help_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
-	patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_CENTER);
+	patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_HCENTER_WIDE);
 	patterns_item_list->add_child(patterns_help_label);
 
 	// Expanded editor
@@ -978,6 +981,8 @@ void TileSourceInspectorPlugin::_show_id_edit_dialog(Object *p_for_source) {
 
 		Label *label = memnew(Label(TTR("Warning: Modifying a source ID will result in all TileMaps using that source to reference an invalid source instead. This may result in unexpected data loss. Change this ID carefully.")));
 		label->set_autowrap_mode(TextServer::AUTOWRAP_WORD);
+		// Workaround too tall popup window due to text autowrapping. See GH-83546.
+		label->set_custom_minimum_size(Vector2i(400, 0));
 		vbox->add_child(label);
 
 		id_input = memnew(SpinBox);

+ 2 - 2
editor/plugins/tiles/tile_set_editor.h

@@ -44,8 +44,8 @@ class SplitContainer;
 class EditorFileDialog;
 class EditorInspectorPlugin;
 
-class TileSetEditor : public Control {
-	GDCLASS(TileSetEditor, Control);
+class TileSetEditor : public MarginContainer {
+	GDCLASS(TileSetEditor, MarginContainer);
 
 	static TileSetEditor *singleton;