Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GameObject change undo/redo refactor to track different options #3085

Merged
merged 8 commits into from
Oct 24, 2024
30 changes: 19 additions & 11 deletions src/editor/layers_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,7 @@ EditorLayersWidget::draw(DrawingContext& context)
void
EditorLayersWidget::update(float dt_sec)
{
auto it = m_layer_icons.begin();
while (it != m_layer_icons.end())
{
auto layer_icon = (*it).get();
if (!layer_icon->is_valid())
{
it = m_layer_icons.erase(it);
continue;
}
++it;
}
remove_invalid_layers();

TileMap* selected_tilemap = get_selected_tilemap();
if (selected_tilemap)
Expand Down Expand Up @@ -460,6 +450,8 @@ EditorLayersWidget::add_layer(GameObject* layer, bool initial)
void
EditorLayersWidget::update_tip()
{
remove_invalid_layers();

if (m_hovered_layer == m_layer_icons.size())
m_object_tip->set_info(_("Add Layer"));
else if (m_hovered_layer > m_layer_icons.size())
Expand All @@ -477,6 +469,22 @@ EditorLayersWidget::update_current_tip()
update_tip();
}

void
EditorLayersWidget::remove_invalid_layers()
{
auto it = m_layer_icons.begin();
while (it != m_layer_icons.end())
{
auto layer_icon = (*it).get();
if (!layer_icon->is_valid())
{
it = m_layer_icons.erase(it);
continue;
}
++it;
}
}

TileMap*
EditorLayersWidget::get_selected_tilemap() const
{
Expand Down
2 changes: 2 additions & 0 deletions src/editor/layers_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ class EditorLayersWidget final : public Widget
private:
Vector get_layer_coords(const int pos) const;
int get_layer_pos(const Vector& coords) const;

void update_tip();
void remove_invalid_layers();

private:
Editor& m_editor;
Expand Down
Loading
Loading