From 81b9791144bf14d5359b863d2af1a23db633f9af Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Fri, 20 Sep 2024 09:21:26 +0200 Subject: [PATCH] - Ara es poden reordenar els templates i les categories --- source/actor.cpp | 30 ++++++++++++++++++++++++++++++ source/actor.h | 3 +++ source/m_editor_templates.cpp | 27 ++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/source/actor.cpp b/source/actor.cpp index 4d86eea..4160a8b 100644 --- a/source/actor.cpp +++ b/source/actor.cpp @@ -1446,6 +1446,7 @@ namespace actor dest->react_mask = source->react_mask; dest->react_push = source->react_push; dest->movement = source->movement; + dest->template_category = source->template_category; } void add(actor_t *act) @@ -1470,6 +1471,35 @@ namespace actor } save(); } + + void swapCategories(const int a, const int b) + { + if (a >= categories.size() || a < 0) return; + if (b >= categories.size() || b < 0) return; + auto str = categories[a]; + categories[a] = categories[b]; + categories[b] = str; + + for (auto &actor : templates) + { + if (actor.template_category == a) actor.template_category = b; + else if (actor.template_category == b) actor.template_category = a; + } +/* + auto old_categories = categories; + categories.clear(); + std::string relocated = ""; + for (int i=0; isurface; + actor::templates::copy(other, act); other->surface = act->surface; + actor::templates::copy(act, &temp); act->surface = temp.surface; + actor::templates::save(); + } + actor_cut[0] = 0; + } + for (auto actor : actors) { draw::swapcol(1, strcmp(actor.name, actor_cut)==0 ? BLUE : TEAL); @@ -137,7 +153,16 @@ namespace modules edit_mode = EDITING_CATEGORY_NAME; init_text_edit(); } else { - current_category = (input::mouseX()-11)/40; + int clicked_category = (input::mouseX()-11)/40; + if (clicked_category