Skip to content

Commit f9996a2

Browse files
committed
Make mode buttons actually work
1 parent 442ba42 commit f9996a2

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/editor/editor.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,24 @@ Editor::Editor() :
198198
m_widgets.insert(m_widgets.begin() + 5, std::move(mode_button));
199199

200200
auto select_mode_mouse_button = std::make_unique<ButtonWidget>(
201-
"images/engine/editor/select-mode0.png", Vector(192, 0), [] {});
201+
"images/engine/editor/select-mode0.png", Vector(192, 0), [this] {
202+
m_toolbox_widget->set_tileselect_select_mode(0);
203+
});
202204
select_mode_mouse_button->set_help_text(_("Draw mode (The current tool applies to the tile under the mouse)"));
203205
auto select_mode_area_button = std::make_unique<ButtonWidget>(
204-
"images/engine/editor/select-mode1.png", Vector(224, 0), [] {});
206+
"images/engine/editor/select-mode1.png", Vector(224, 0), [this] {
207+
m_toolbox_widget->set_tileselect_select_mode(1);
208+
});
205209
select_mode_area_button->set_help_text(_("Box draw mode (The current tool applies to an area / box drawn with the mouse)"));
206210
auto select_mode_fill_button = std::make_unique<ButtonWidget>(
207-
"images/engine/editor/select-mode2.png", Vector(256, 0), [] {});
211+
"images/engine/editor/select-mode2.png", Vector(256, 0), [this] {
212+
m_toolbox_widget->set_tileselect_select_mode(2);
213+
});
208214
select_mode_fill_button->set_help_text(_("Fill mode (The current tool applies to the empty area in the enclosed space that was clicked)"));
209215
auto select_mode_same_button = std::make_unique<ButtonWidget>(
210-
"images/engine/editor/select-mode3.png", Vector(288, 0), [] {});
216+
"images/engine/editor/select-mode3.png", Vector(288, 0), [this] {
217+
m_toolbox_widget->set_tileselect_select_mode(3);
218+
});
211219
select_mode_same_button->set_help_text(_("Replace mode (The current tool applies to all tiles that are the same tile as the one under the mouse)"));
212220

213221
m_widgets.insert(m_widgets.begin() + 6, std::move(select_mode_mouse_button));

src/editor/toolbox_widget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,13 @@ EditorToolboxWidget::get_tileselect_select_mode() const
300300
return m_select_mode->get_mode();
301301
}
302302

303+
void
304+
EditorToolboxWidget::set_tileselect_select_mode(int mode)
305+
{
306+
m_select_mode->set_mode(mode);
307+
update_mouse_icon();
308+
}
309+
303310
int
304311
EditorToolboxWidget::get_tileselect_move_mode() const
305312
{

src/editor/toolbox_widget.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class EditorToolboxWidget final : public Widget
6161

6262
void update_mouse_icon();
6363

64+
void set_tileselect_select_mode(int mode);
65+
6466
inline EditorTilebox& get_tilebox() const { return *m_tilebox; }
6567

6668
inline bool has_mouse_focus() const { return m_has_mouse_focus; }

0 commit comments

Comments
 (0)