- Ara es poden reordenar els templates i les categories
This commit is contained in:
@@ -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; i<old_categories.size(); ++i)
|
||||
{
|
||||
if (i==index) {
|
||||
relocated = old_categories[i];
|
||||
} else {
|
||||
categories.push_back(old_categories[i]);
|
||||
if (relocated != "") { categories.push_back(relocated); relocated = ""; }
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
namespace hero
|
||||
|
||||
@@ -123,6 +123,8 @@ namespace actor
|
||||
// Torna un nou actor
|
||||
actor_t *create(std::string name, vec3_t p, vec3_t s, std::string bmp, SDL_Rect r, SDL_Point o);
|
||||
|
||||
actor_t *createEmptyActor();
|
||||
|
||||
actor_t *duplicate(actor_t *act);
|
||||
|
||||
actor_t *createFromTemplate(const char *name);
|
||||
@@ -183,6 +185,7 @@ namespace actor
|
||||
actor_t *getByName(const char *name);
|
||||
void copy(actor_t *dest, actor_t *source);
|
||||
void add(actor_t *act);
|
||||
void swapCategories(const int a, const int b);
|
||||
}
|
||||
|
||||
namespace hero
|
||||
|
||||
@@ -105,6 +105,22 @@ namespace modules
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_X) && (hovered_actor < actors.size())) strcpy(actor_cut, actors[hovered_actor].name);
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_W) && (hovered_actor < actors.size()) && actor_cut[0]!=0)
|
||||
{
|
||||
actor::actor_t *act = actor::templates::getByName(actor_cut);
|
||||
actor::actor_t *other = actor::templates::getByName(actors[hovered_actor].name);
|
||||
actor::actor_t temp; // = actor::createEmptyActor();
|
||||
|
||||
if (act && other)
|
||||
{
|
||||
actor::templates::copy(&temp, other); temp.surface = other->surface;
|
||||
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<categories.size())
|
||||
{
|
||||
if (input::keyDown(SDL_SCANCODE_LCTRL))
|
||||
{
|
||||
actor::templates::swapCategories(current_category, clicked_category);
|
||||
actor::templates::save();
|
||||
}
|
||||
current_category = clicked_category;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user