Skip to content

Commit

Permalink
edit button for tile map control panel
Browse files Browse the repository at this point in the history
- makes editing a bit more intuitive
  • Loading branch information
mrDIMAS committed Jul 23, 2024
1 parent 3e472ad commit d6eb56f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions editor/src/plugins/tilemap/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use crate::{
asset::item::AssetItem,
command::{Command, CommandGroup, SetPropertyCommand},
fyrox::{
core::{algebra::Vector2, pool::Handle, Uuid},
core::{algebra::Vector2, pool::Handle, TypeUuidProvider, Uuid},
fxhash::FxHashSet,
graph::{BaseSceneGraph, SceneGraph, SceneGraphNode},
gui::{
border::BorderBuilder,
button::{Button, ButtonMessage},
button::{Button, ButtonBuilder, ButtonMessage},
decorator::DecoratorMessage,
dropdown_list::{DropdownListBuilder, DropdownListMessage},
grid::{Column, GridBuilder, Row},
Expand Down Expand Up @@ -42,12 +42,14 @@ use crate::{
DrawingMode, TileMapInteractionMode,
},
scene::{commands::GameSceneContext, container::EditorSceneEntry},
Message,
};

pub struct TileMapPanel {
pub window: Handle<UiNode>,
pub palette: Handle<UiNode>,
active_brush_selector: Handle<UiNode>,
edit: Handle<UiNode>,
draw_button: Handle<UiNode>,
erase_button: Handle<UiNode>,
flood_fill_button: Handle<UiNode>,
Expand Down Expand Up @@ -112,6 +114,10 @@ impl TileMapPanel {
.with_items(make_brush_entries(tile_map, ctx))
.build(ctx);

let edit = ButtonBuilder::new(WidgetBuilder::new().with_width(45.0).with_height(26.0))
.with_text("Edit")
.build(ctx);

let width = 20.0;
let height = 20.0;
let draw_button = make_image_button_with_tooltip(
Expand Down Expand Up @@ -158,6 +164,7 @@ impl TileMapPanel {
let toolbar = WrapPanelBuilder::new(
WidgetBuilder::new()
.on_row(0)
.with_child(edit)
.with_child(draw_button)
.with_child(erase_button)
.with_child(flood_fill_button)
Expand Down Expand Up @@ -199,6 +206,7 @@ impl TileMapPanel {
window,
palette,
active_brush_selector,
edit,
draw_button,
erase_button,
flood_fill_button,
Expand Down Expand Up @@ -367,6 +375,10 @@ impl TileMapPanel {
interaction_mode.drawing_mode = DrawingMode::Pick {
click_grid_position: Default::default(),
};
} else if message.destination() == self.edit {
sender.send(Message::SetInteractionMode(
TileMapInteractionMode::type_uuid(),
));
}
}
}
Expand Down

0 comments on commit d6eb56f

Please sign in to comment.