Add TileMap grid editor settings.
This commit is contained in:
parent
af03e9c830
commit
78ad206d74
|
@ -704,6 +704,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||||
_initial_set("editors/2d/scroll_to_pan", false);
|
_initial_set("editors/2d/scroll_to_pan", false);
|
||||||
_initial_set("editors/2d/pan_speed", 20);
|
_initial_set("editors/2d/pan_speed", 20);
|
||||||
|
|
||||||
|
// Tiles editor
|
||||||
|
_initial_set("editors/tiles_editor/display_grid", true);
|
||||||
|
_initial_set("editors/tiles_editor/grid_color", Color(1.0, 0.5, 0.2, 0.5));
|
||||||
|
|
||||||
// Polygon editor
|
// Polygon editor
|
||||||
_initial_set("editors/poly_editor/point_grab_radius", 8);
|
_initial_set("editors/poly_editor/point_grab_radius", 8);
|
||||||
_initial_set("editors/poly_editor/show_previous_outline", true);
|
_initial_set("editors/poly_editor/show_previous_outline", true);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v2 10 2h2 12v-2-12h-12zm2 2h2v2h-2zm4 0h2v2h-2zm4 0h2v2h-2zm-8 4h2v2h-2zm4 0h2v2h-2zm4 0h2v2h-2zm-8 4h2v2h-2zm4 0h2v2h-2zm4 0h2v2h-2z" fill="#8da5f3" fill-opacity=".98824"/></svg>
|
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v14h14v-14zm1.9999999 2h2v2h-2zm4 0h2v2h-2zm4.0000001 0h2v2h-2zm-8.0000001 4.0000004h2v2h-2zm4 0h2v2h-2zm4.0000001 0h2v2h-2zm-8.0000001 3.9999996h2v2h-2zm4 0h2v2h-2zm4.0000001 0h2v2h-2z" fill="#e0e0e0"/></svg>
|
||||||
|
|
Before Width: | Height: | Size: 276 B After Width: | Height: | Size: 306 B |
|
@ -39,6 +39,7 @@
|
||||||
#include "scene/gui/texture_rect.h"
|
#include "scene/gui/texture_rect.h"
|
||||||
|
|
||||||
#include "editor/editor_scale.h"
|
#include "editor/editor_scale.h"
|
||||||
|
#include "editor/editor_settings.h"
|
||||||
|
|
||||||
void TileAtlasView::_gui_input(const Ref<InputEvent> &p_event) {
|
void TileAtlasView::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
bool ctrl = Input::get_singleton()->is_key_pressed(KEY_CTRL);
|
bool ctrl = Input::get_singleton()->is_key_pressed(KEY_CTRL);
|
||||||
|
@ -316,6 +317,7 @@ void TileAtlasView::_draw_base_tiles_dark() {
|
||||||
|
|
||||||
void TileAtlasView::_draw_base_tiles_shape_grid() {
|
void TileAtlasView::_draw_base_tiles_shape_grid() {
|
||||||
// Draw the shapes.
|
// Draw the shapes.
|
||||||
|
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||||
Vector2i tile_shape_size = tile_set->get_tile_size();
|
Vector2i tile_shape_size = tile_set->get_tile_size();
|
||||||
for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) {
|
for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) {
|
||||||
Vector2i tile_id = tile_set_atlas_source->get_tile_id(i);
|
Vector2i tile_id = tile_set_atlas_source->get_tile_id(i);
|
||||||
|
@ -324,7 +326,7 @@ void TileAtlasView::_draw_base_tiles_shape_grid() {
|
||||||
Vector2 origin = texture_region.position + (texture_region.size - tile_shape_size) / 2 + in_tile_base_offset;
|
Vector2 origin = texture_region.position + (texture_region.size - tile_shape_size) / 2 + in_tile_base_offset;
|
||||||
|
|
||||||
// Draw only if the tile shape fits in the texture region
|
// Draw only if the tile shape fits in the texture region
|
||||||
tile_set->draw_tile_shape(base_tiles_shape_grid, Rect2(origin, tile_shape_size), Color(1.0, 0.5, 0.2, 0.8));
|
tile_set->draw_tile_shape(base_tiles_shape_grid, Rect2(origin, tile_shape_size), grid_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,18 @@ void TileMapEditorTilesPlugin::_notification(int p_what) {
|
||||||
picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons"));
|
picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons"));
|
||||||
erase_button->set_icon(get_theme_icon("Eraser", "EditorIcons"));
|
erase_button->set_icon(get_theme_icon("Eraser", "EditorIcons"));
|
||||||
|
|
||||||
|
toggle_grid_button->set_icon(get_theme_icon("Grid", "EditorIcons"));
|
||||||
|
|
||||||
missing_atlas_texture_icon = get_theme_icon("TileSet", "EditorIcons");
|
missing_atlas_texture_icon = get_theme_icon("TileSet", "EditorIcons");
|
||||||
|
|
||||||
|
toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid"));
|
||||||
break;
|
break;
|
||||||
case NOTIFICATION_VISIBILITY_CHANGED:
|
case NOTIFICATION_VISIBILITY_CHANGED:
|
||||||
_stop_dragging();
|
_stop_dragging();
|
||||||
|
break;
|
||||||
|
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED:
|
||||||
|
toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +85,10 @@ void TileMapEditorTilesPlugin::_on_scattering_spinbox_changed(double p_value) {
|
||||||
scattering = p_value;
|
scattering = p_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileMapEditorTilesPlugin::_on_grid_toggled(bool p_pressed) {
|
||||||
|
EditorSettings::get_singleton()->set("editors/tiles_editor/display_grid", p_pressed);
|
||||||
|
}
|
||||||
|
|
||||||
void TileMapEditorTilesPlugin::_update_toolbar() {
|
void TileMapEditorTilesPlugin::_update_toolbar() {
|
||||||
// Stop draggig if needed.
|
// Stop draggig if needed.
|
||||||
_stop_dragging();
|
_stop_dragging();
|
||||||
|
@ -604,7 +616,9 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over
|
||||||
if (drag_type == DRAG_TYPE_MOVE || (drag_type == DRAG_TYPE_SELECT && !Input::get_singleton()->is_key_pressed(KEY_CTRL) && !Input::get_singleton()->is_key_pressed(KEY_SHIFT))) {
|
if (drag_type == DRAG_TYPE_MOVE || (drag_type == DRAG_TYPE_SELECT && !Input::get_singleton()->is_key_pressed(KEY_CTRL) && !Input::get_singleton()->is_key_pressed(KEY_SHIFT))) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
} else {
|
} else {
|
||||||
tile_map->draw_cells_outline(p_overlay, tile_map_selection, Color(0.0, 0.0, 1.0), xform);
|
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||||
|
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
|
||||||
|
tile_map->draw_cells_outline(p_overlay, tile_map_selection, selection_color, xform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,21 +717,27 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over
|
||||||
const int fading = 5;
|
const int fading = 5;
|
||||||
|
|
||||||
// Draw the lines of the grid behind the preview.
|
// Draw the lines of the grid behind the preview.
|
||||||
if (drawn_grid_rect.size.x > 0 && drawn_grid_rect.size.y > 0) {
|
bool display_grid = EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid");
|
||||||
drawn_grid_rect = drawn_grid_rect.grow(fading);
|
if (display_grid) {
|
||||||
for (int x = drawn_grid_rect.position.x; x < (drawn_grid_rect.position.x + drawn_grid_rect.size.x); x++) {
|
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||||
for (int y = drawn_grid_rect.position.y; y < (drawn_grid_rect.position.y + drawn_grid_rect.size.y); y++) {
|
if (drawn_grid_rect.size.x > 0 && drawn_grid_rect.size.y > 0) {
|
||||||
Vector2i pos_in_rect = Vector2i(x, y) - drawn_grid_rect.position;
|
drawn_grid_rect = drawn_grid_rect.grow(fading);
|
||||||
|
for (int x = drawn_grid_rect.position.x; x < (drawn_grid_rect.position.x + drawn_grid_rect.size.x); x++) {
|
||||||
|
for (int y = drawn_grid_rect.position.y; y < (drawn_grid_rect.position.y + drawn_grid_rect.size.y); y++) {
|
||||||
|
Vector2i pos_in_rect = Vector2i(x, y) - drawn_grid_rect.position;
|
||||||
|
|
||||||
// Fade out the border of the grid.
|
// Fade out the border of the grid.
|
||||||
float left_opacity = CLAMP(Math::inverse_lerp(0.0f, (float)fading, (float)pos_in_rect.x), 0.0f, 1.0f);
|
float left_opacity = CLAMP(Math::inverse_lerp(0.0f, (float)fading, (float)pos_in_rect.x), 0.0f, 1.0f);
|
||||||
float right_opacity = CLAMP(Math::inverse_lerp((float)drawn_grid_rect.size.x, (float)(drawn_grid_rect.size.x - fading), (float)pos_in_rect.x), 0.0f, 1.0f);
|
float right_opacity = CLAMP(Math::inverse_lerp((float)drawn_grid_rect.size.x, (float)(drawn_grid_rect.size.x - fading), (float)pos_in_rect.x), 0.0f, 1.0f);
|
||||||
float top_opacity = CLAMP(Math::inverse_lerp(0.0f, (float)fading, (float)pos_in_rect.y), 0.0f, 1.0f);
|
float top_opacity = CLAMP(Math::inverse_lerp(0.0f, (float)fading, (float)pos_in_rect.y), 0.0f, 1.0f);
|
||||||
float bottom_opacity = CLAMP(Math::inverse_lerp((float)drawn_grid_rect.size.y, (float)(drawn_grid_rect.size.y - fading), (float)pos_in_rect.y), 0.0f, 1.0f);
|
float bottom_opacity = CLAMP(Math::inverse_lerp((float)drawn_grid_rect.size.y, (float)(drawn_grid_rect.size.y - fading), (float)pos_in_rect.y), 0.0f, 1.0f);
|
||||||
float opacity = CLAMP(MIN(left_opacity, MIN(right_opacity, MIN(top_opacity, bottom_opacity))) + 0.1, 0.0f, 1.0f);
|
float opacity = CLAMP(MIN(left_opacity, MIN(right_opacity, MIN(top_opacity, bottom_opacity))) + 0.1, 0.0f, 1.0f);
|
||||||
|
|
||||||
Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(Vector2(x, y)) - tile_shape_size / 2, tile_shape_size));
|
Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(Vector2(x, y)) - tile_shape_size / 2, tile_shape_size));
|
||||||
tile_set->draw_tile_shape(p_overlay, cell_region, Color(1.0, 0.5, 0.2, 0.5 * opacity), false);
|
Color color = grid_color;
|
||||||
|
color.a = color.a * opacity;
|
||||||
|
tile_set->draw_tile_shape(p_overlay, cell_region, color, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1417,9 +1437,11 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the selection.
|
// Draw the selection.
|
||||||
|
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||||
|
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
|
||||||
for (Set<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) {
|
for (Set<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) {
|
||||||
if (E->get().source_id == source_id && E->get().alternative_tile == 0) {
|
if (E->get().source_id == source_id && E->get().alternative_tile == 0) {
|
||||||
tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E->get().get_atlas_coords()), Color(0.0, 0.0, 1.0), false);
|
tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E->get().get_atlas_coords()), selection_color, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1445,9 +1467,9 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Color selection_rect_color = selection_color.lightened(0.2);
|
||||||
for (Set<Vector2i>::Element *E = to_draw.front(); E; E = E->next()) {
|
for (Set<Vector2i>::Element *E = to_draw.front(); E; E = E->next()) {
|
||||||
tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E->get()), Color(0.8, 0.8, 1.0), false);
|
tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E->get()), selection_rect_color, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1730,6 +1752,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||||
|
|
||||||
// --- Toolbar ---
|
// --- Toolbar ---
|
||||||
toolbar = memnew(HBoxContainer);
|
toolbar = memnew(HBoxContainer);
|
||||||
|
toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
|
||||||
HBoxContainer *tilemap_tiles_tools_buttons = memnew(HBoxContainer);
|
HBoxContainer *tilemap_tiles_tools_buttons = memnew(HBoxContainer);
|
||||||
|
|
||||||
|
@ -1774,7 +1797,6 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||||
bucket_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/bucket_tool", "Bucket", KEY_B));
|
bucket_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/bucket_tool", "Bucket", KEY_B));
|
||||||
bucket_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTilesPlugin::_update_toolbar));
|
bucket_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTilesPlugin::_update_toolbar));
|
||||||
tilemap_tiles_tools_buttons->add_child(bucket_tool_button);
|
tilemap_tiles_tools_buttons->add_child(bucket_tool_button);
|
||||||
|
|
||||||
toolbar->add_child(tilemap_tiles_tools_buttons);
|
toolbar->add_child(tilemap_tiles_tools_buttons);
|
||||||
|
|
||||||
// -- TileMap tool settings --
|
// -- TileMap tool settings --
|
||||||
|
@ -1834,6 +1856,18 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
|
||||||
|
|
||||||
_on_random_tile_checkbox_toggled(false);
|
_on_random_tile_checkbox_toggled(false);
|
||||||
|
|
||||||
|
// Wide empty separation control.
|
||||||
|
Control *h_empty_space = memnew(Control);
|
||||||
|
h_empty_space->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
toolbar->add_child(h_empty_space);
|
||||||
|
|
||||||
|
// Grid toggle.
|
||||||
|
toggle_grid_button = memnew(Button);
|
||||||
|
toggle_grid_button->set_flat(true);
|
||||||
|
toggle_grid_button->set_toggle_mode(true);
|
||||||
|
toggle_grid_button->connect("toggled", callable_mp(this, &TileMapEditorTilesPlugin::_on_grid_toggled));
|
||||||
|
toolbar->add_child(toggle_grid_button);
|
||||||
|
|
||||||
// Default tool.
|
// Default tool.
|
||||||
paint_tool_button->set_pressed(true);
|
paint_tool_button->set_pressed(true);
|
||||||
_update_toolbar();
|
_update_toolbar();
|
||||||
|
@ -3426,19 +3460,25 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the grid.
|
// Draw the grid.
|
||||||
for (int x = displayed_rect.position.x; x < (displayed_rect.position.x + displayed_rect.size.x); x++) {
|
bool display_grid = EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid");
|
||||||
for (int y = displayed_rect.position.y; y < (displayed_rect.position.y + displayed_rect.size.y); y++) {
|
if (display_grid) {
|
||||||
Vector2i pos_in_rect = Vector2i(x, y) - displayed_rect.position;
|
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||||
|
for (int x = displayed_rect.position.x; x < (displayed_rect.position.x + displayed_rect.size.x); x++) {
|
||||||
|
for (int y = displayed_rect.position.y; y < (displayed_rect.position.y + displayed_rect.size.y); y++) {
|
||||||
|
Vector2i pos_in_rect = Vector2i(x, y) - displayed_rect.position;
|
||||||
|
|
||||||
// Fade out the border of the grid.
|
// Fade out the border of the grid.
|
||||||
float left_opacity = CLAMP(Math::inverse_lerp(0.0f, (float)fading, (float)pos_in_rect.x), 0.0f, 1.0f);
|
float left_opacity = CLAMP(Math::inverse_lerp(0.0f, (float)fading, (float)pos_in_rect.x), 0.0f, 1.0f);
|
||||||
float right_opacity = CLAMP(Math::inverse_lerp((float)displayed_rect.size.x, (float)(displayed_rect.size.x - fading), (float)pos_in_rect.x), 0.0f, 1.0f);
|
float right_opacity = CLAMP(Math::inverse_lerp((float)displayed_rect.size.x, (float)(displayed_rect.size.x - fading), (float)pos_in_rect.x), 0.0f, 1.0f);
|
||||||
float top_opacity = CLAMP(Math::inverse_lerp(0.0f, (float)fading, (float)pos_in_rect.y), 0.0f, 1.0f);
|
float top_opacity = CLAMP(Math::inverse_lerp(0.0f, (float)fading, (float)pos_in_rect.y), 0.0f, 1.0f);
|
||||||
float bottom_opacity = CLAMP(Math::inverse_lerp((float)displayed_rect.size.y, (float)(displayed_rect.size.y - fading), (float)pos_in_rect.y), 0.0f, 1.0f);
|
float bottom_opacity = CLAMP(Math::inverse_lerp((float)displayed_rect.size.y, (float)(displayed_rect.size.y - fading), (float)pos_in_rect.y), 0.0f, 1.0f);
|
||||||
float opacity = CLAMP(MIN(left_opacity, MIN(right_opacity, MIN(top_opacity, bottom_opacity))) + 0.1, 0.0f, 1.0f);
|
float opacity = CLAMP(MIN(left_opacity, MIN(right_opacity, MIN(top_opacity, bottom_opacity))) + 0.1, 0.0f, 1.0f);
|
||||||
|
|
||||||
Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(Vector2(x, y)) - tile_shape_size / 2, tile_shape_size));
|
Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(Vector2(x, y)) - tile_shape_size / 2, tile_shape_size));
|
||||||
tile_set->draw_tile_shape(p_overlay, cell_region, Color(1.0, 0.5, 0.2, 0.5 * opacity), false);
|
Color color = grid_color;
|
||||||
|
color.a = color.a * opacity;
|
||||||
|
tile_set->draw_tile_shape(p_overlay, cell_region, color, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3500,9 +3540,8 @@ TileMapEditor::TileMapEditor() {
|
||||||
|
|
||||||
// --- TileMap toolbar ---
|
// --- TileMap toolbar ---
|
||||||
tilemap_toolbar = memnew(HBoxContainer);
|
tilemap_toolbar = memnew(HBoxContainer);
|
||||||
//tilemap_toolbar->add_child(memnew(VSeparator));
|
tilemap_toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
tilemap_toolbar->add_child(tabs);
|
tilemap_toolbar->add_child(tabs);
|
||||||
//tilemap_toolbar->add_child(memnew(VSeparator));
|
|
||||||
for (int i = 0; i < tile_map_editor_plugins.size(); i++) {
|
for (int i = 0; i < tile_map_editor_plugins.size(); i++) {
|
||||||
tile_map_editor_plugins[i]->get_toolbar()->hide();
|
tile_map_editor_plugins[i]->get_toolbar()->hide();
|
||||||
tilemap_toolbar->add_child(tile_map_editor_plugins[i]->get_toolbar());
|
tilemap_toolbar->add_child(tile_map_editor_plugins[i]->get_toolbar());
|
||||||
|
|
|
@ -82,6 +82,9 @@ private:
|
||||||
void _on_random_tile_checkbox_toggled(bool p_pressed);
|
void _on_random_tile_checkbox_toggled(bool p_pressed);
|
||||||
void _on_scattering_spinbox_changed(double p_value);
|
void _on_scattering_spinbox_changed(double p_value);
|
||||||
|
|
||||||
|
Button *toggle_grid_button;
|
||||||
|
void _on_grid_toggled(bool p_pressed);
|
||||||
|
|
||||||
void _update_toolbar();
|
void _update_toolbar();
|
||||||
|
|
||||||
///// Tilemap editing. /////
|
///// Tilemap editing. /////
|
||||||
|
|
|
@ -1178,6 +1178,10 @@ Array TileSetAtlasSourceEditor::_get_selection_as_array() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
|
void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
|
||||||
|
// Colors.
|
||||||
|
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||||
|
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
|
||||||
|
|
||||||
// Draw the selected tile.
|
// Draw the selected tile.
|
||||||
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
||||||
for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
|
for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
|
||||||
|
@ -1185,7 +1189,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
|
||||||
if (selected.alternative == 0) {
|
if (selected.alternative == 0) {
|
||||||
// Draw the rect.
|
// Draw the rect.
|
||||||
Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile);
|
Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile);
|
||||||
tile_atlas_control->draw_rect(region, Color(0.2, 0.2, 1.0), false);
|
tile_atlas_control->draw_rect(region, selection_color, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1234,7 +1238,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
|
||||||
|
|
||||||
Color color = Color(0.0, 0.0, 0.0);
|
Color color = Color(0.0, 0.0, 0.0);
|
||||||
if (drag_type == DRAG_TYPE_RECT_SELECT) {
|
if (drag_type == DRAG_TYPE_RECT_SELECT) {
|
||||||
color = Color(0.5, 0.5, 1.0);
|
color = selection_color.lightened(0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Vector2i> to_paint;
|
Set<Vector2i> to_paint;
|
||||||
|
@ -1393,6 +1397,9 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
|
void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
|
||||||
|
Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color");
|
||||||
|
Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0);
|
||||||
|
|
||||||
// Update the hovered alternative tile.
|
// Update the hovered alternative tile.
|
||||||
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
||||||
// Draw hovered tile.
|
// Draw hovered tile.
|
||||||
|
@ -1410,7 +1417,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
|
||||||
if (selected.alternative >= 1) {
|
if (selected.alternative >= 1) {
|
||||||
Rect2i rect = tile_atlas_view->get_alternative_tile_rect(selected.tile, selected.alternative);
|
Rect2i rect = tile_atlas_view->get_alternative_tile_rect(selected.tile, selected.alternative);
|
||||||
if (rect != Rect2i()) {
|
if (rect != Rect2i()) {
|
||||||
alternative_tiles_control->draw_rect(rect, Color(0.2, 0.2, 1.0), false);
|
alternative_tiles_control->draw_rect(rect, selection_color, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,6 +202,7 @@ TilesEditor::TilesEditor(EditorNode *p_editor) {
|
||||||
|
|
||||||
// Toolbar.
|
// Toolbar.
|
||||||
HBoxContainer *toolbar = memnew(HBoxContainer);
|
HBoxContainer *toolbar = memnew(HBoxContainer);
|
||||||
|
toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
add_child(toolbar);
|
add_child(toolbar);
|
||||||
|
|
||||||
// Switch button.
|
// Switch button.
|
||||||
|
|
Loading…
Reference in New Issue