File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -121,4 +121,17 @@ ButtonWidget::on_mouse_motion(const SDL_MouseMotionEvent& motion)
121
121
}
122
122
}
123
123
124
+ void
125
+ ButtonWidget::set_sprite (SpritePtr sprite)
126
+ {
127
+ m_sprite = std::move (sprite);
128
+ m_rect.set_size (sprite->get_width () * 1 .0f , sprite->get_height () * 1 .0f );
129
+ }
130
+
131
+ void
132
+ ButtonWidget::set_sprite (const std::string& path)
133
+ {
134
+ set_sprite (SpriteManager::current ()->create (path));
135
+ }
136
+
124
137
/* EOF */
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ class ButtonWidget : public Widget
45
45
virtual bool on_mouse_button_down (const SDL_MouseButtonEvent& button) override ;
46
46
virtual bool on_mouse_motion (const SDL_MouseMotionEvent& motion) override ;
47
47
48
+ void set_sprite (const std::string& path);
49
+ void set_sprite (SpritePtr sprite);
50
+
48
51
private:
49
52
SpritePtr m_sprite;
50
53
Rectf m_rect;
Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ static const float CAMERA_ZOOM_FOCUS_PROGRESSION = 8.f;
82
82
83
83
bool Editor::s_resaving_in_progress = false ;
84
84
85
+ using InputType = EditorTilebox::InputType;
86
+
85
87
bool
86
88
Editor::is_active ()
87
89
{
@@ -178,6 +180,18 @@ Editor::Editor() :
178
180
m_save_widget = save_button.get ();
179
181
180
182
m_widgets.insert (m_widgets.begin () + 4 , std::move (save_button));
183
+
184
+ auto mode_button = std::make_unique<ButtonWidget>(" images/engine/editor/tilemap.png" ,
185
+ Vector (160 , 0 ), [this ] {
186
+ auto & tilebox = m_toolbox_widget->get_tilebox ();
187
+ const auto & input_type = tilebox.get_input_type ();
188
+ if (input_type == InputType::OBJECT)
189
+ select_tilegroup (0 );
190
+ else
191
+ select_objectgroup (0 );
192
+ });
193
+
194
+ m_widgets.insert (m_widgets.begin () + 5 , std::move (mode_button));
181
195
}
182
196
183
197
Editor::~Editor ()
You can’t perform that action at this time.
0 commit comments