- Editor més guapet
- [NEW] Ja es poden duplicar els actors - [NEW] Ja es poden crear actors desde plantilla - [NEW] Ja es pot afegir un actor com a plantilla - [NEW] Ja es pot updatar una plantilla, usant un actor que tinga el mateix nom
This commit is contained in:
195
source/main.cpp
195
source/main.cpp
@@ -56,6 +56,7 @@ void game::init()
|
||||
draw::setSource(surf);
|
||||
draw::loadPalette("test.gif");
|
||||
game::setUpdateTicks(64);
|
||||
actor::templates::load();
|
||||
|
||||
FILE* f = fopen("data/gifs.txt", "r");
|
||||
int buffer_len=255;
|
||||
@@ -215,7 +216,7 @@ const bool btn_opt(const char* label, const int x, const int y, int &var, std::v
|
||||
bool btn_opt2(const char* label, const int x, const int y, char *var, std::vector<std::string> values)
|
||||
{
|
||||
//draw::print(label, x, y+3, PAPER, 0);
|
||||
ui::label(label, x, y, 32, 11);
|
||||
ui::label(label, x, y, 48, 11);
|
||||
int result = 0;
|
||||
std::size_t pos = 0;
|
||||
std::string v = var;
|
||||
@@ -225,7 +226,7 @@ bool btn_opt2(const char* label, const int x, const int y, char *var, std::vecto
|
||||
}
|
||||
if (pos==values.size()) pos = 0;
|
||||
|
||||
result = ui::combo(var, x+31, y, 65, 11);
|
||||
result = ui::combo(var, x+47, y, 48, 11);
|
||||
if (result)
|
||||
{
|
||||
pos++; if (pos==values.size()) pos=0;
|
||||
@@ -246,9 +247,9 @@ const uint8_t scancode_to_char(const uint8_t scancode)
|
||||
const bool btn_txt(const char* label, const int x, const int y, char *var)
|
||||
{
|
||||
//draw::print(label, x, y+3, PAPER, 0);
|
||||
ui::label(label, x, y, 32, 11);
|
||||
ui::label(label, x, y, 48, 11);
|
||||
int result = 0;
|
||||
result = ui::textbox(var, x+31, y, 65, 11);
|
||||
result = ui::textbox(var, x+47, y, 48, 11);
|
||||
if (result)
|
||||
{
|
||||
const int len = strlen(var);
|
||||
@@ -394,10 +395,32 @@ bool game::loop()
|
||||
draw::color(WHITE);
|
||||
draw::fillrect(0, 0, 100, 240);
|
||||
|
||||
//if (ui::button("+ACTOR", 2, 2, 28, 11))
|
||||
//{
|
||||
//room::load(room::editor::getCurrentRoom());
|
||||
//editor::setEditing(!editor::isEditing());
|
||||
//}
|
||||
int result = ui::combo(actor::templates::get(editor::getCurrentTemplate())->name, 2, 2, 76, 11);
|
||||
if (result)
|
||||
{
|
||||
int new_current_template = editor::getCurrentTemplate() + (result-2);
|
||||
if (new_current_template >= actor::templates::size()) new_current_template = 0;
|
||||
if (new_current_template < 0) new_current_template = actor::templates::size()-1;
|
||||
editor::setCurrentTemplate(new_current_template);
|
||||
}
|
||||
if (ui::button("NEW", 78, 2, 20, 11))
|
||||
{
|
||||
actor::actor_t *new_act = actor::duplicate(actor::templates::get(editor::getCurrentTemplate()));
|
||||
actor::setUniqueName(new_act);
|
||||
actor::setDirty(new_act, true);
|
||||
}
|
||||
|
||||
draw::color(LIGHT+WHITE);
|
||||
draw::fillrect(2, 2, 96, 236);
|
||||
draw::fillrect(2, 15, 96, 223);
|
||||
draw::color(PAPER);
|
||||
draw::rect(2, 2, 96, 236);
|
||||
draw::rect(2, 15, 96, 223);
|
||||
|
||||
draw::setViewport(0, 15, 100, 225);
|
||||
|
||||
const int mx = draw::getLocalX(input::mouseX());
|
||||
const int my = draw::getLocalY(input::mouseY());
|
||||
@@ -469,11 +492,9 @@ bool game::loop()
|
||||
editor::setEditing(!editor::isEditing());
|
||||
}
|
||||
|
||||
draw::color(LIGHT+WHITE);
|
||||
draw::fillrect(2, 22, 96, 216);
|
||||
draw::color(PAPER);
|
||||
draw::rect(2, 22, 96, 216);
|
||||
draw::setViewport(420, 22, 100, 218);
|
||||
//draw::color(PAPER); // el borde del propertyview es pinta al final de tot
|
||||
//draw::rect(2, 22, 96, 216);
|
||||
draw::setViewport(420, 15, 100, 225);
|
||||
|
||||
bool changed = false;
|
||||
|
||||
@@ -484,6 +505,9 @@ switch (section)
|
||||
break;
|
||||
|
||||
case SECTION_ROOM:
|
||||
draw::color(LIGHT+WHITE);
|
||||
draw::fillrect(2, 0, 96, 223);
|
||||
|
||||
line = 0;
|
||||
//changed |= btn("ROOM WIDTH:", 10, 40, room::editor::refWidth(), 0, 3);
|
||||
//changed |= btn("ROOM HEIGHT:", 10, 55, room::editor::refHeight(), 0, 3);
|
||||
@@ -562,87 +586,136 @@ switch (section)
|
||||
changed |= btn("WDOORS:", 10, 200, room::editor::refWallDoorTex(), 0, 5);*/
|
||||
|
||||
if (changed) { room::editor::modify(); room::update(); }
|
||||
|
||||
draw::color(PAPER);
|
||||
draw::rect(2, 0, 96, 223);
|
||||
|
||||
break;
|
||||
|
||||
case SECTION_ACTOR:
|
||||
draw::color(LIGHT+WHITE);
|
||||
draw::fillrect(2, 0, 96, 153);
|
||||
|
||||
changed = false;
|
||||
act = actor::getSelected();
|
||||
if (act)
|
||||
{
|
||||
line = 0;
|
||||
//draw::setViewport(420, 90, 100, 150);
|
||||
|
||||
changed |= btn_txt("NAME:", 2, 0, act->name);
|
||||
if (btn_opt2("BMP:", 2, 10, act->bmp, gifs)) {
|
||||
changed |= btn_txt("NAME", 2, line, act->name); line+=10;
|
||||
|
||||
ui::label("LOCATION", 2, line, 96, 11, GRAY); line+=10;
|
||||
|
||||
ui::label("POS", 2, line, 48, 11);
|
||||
changed |= btn_small(49, line, act->pos.x, 0, 512);
|
||||
changed |= btn_small(65, line, act->pos.y, 0, 512);
|
||||
changed |= btn_small(81, line, act->pos.z, 0, 512);
|
||||
line+=10;
|
||||
|
||||
ui::label("SIZE", 2, line, 48, 11);
|
||||
changed |= btn_small(49, line, act->size.x, 0, 512);
|
||||
changed |= btn_small(65, line, act->size.y, 0, 512);
|
||||
changed |= btn_small(81, line, act->size.z, 0, 512);
|
||||
line+=10;
|
||||
|
||||
ui::label("BITMAP", 2, line, 96, 11, GRAY); line+=10;
|
||||
|
||||
if (btn_opt2("FILE", 2, line, act->bmp, gifs)) {
|
||||
draw::freeSurface(act->surface);
|
||||
act->surface = draw::loadSurface(act->bmp);
|
||||
changed = true;
|
||||
}
|
||||
//draw::print("RECT:", 2, 64, PAPER, 0);
|
||||
ui::label("RECT", 2, 20, 32, 11);
|
||||
changed |= btn_small(33, 20, act->bmp_rect.x, 0, 512);
|
||||
changed |= btn_small(49, 20, act->bmp_rect.y, 0, 512);
|
||||
changed |= btn_small(65, 20, act->bmp_rect.w, 0, 512);
|
||||
changed |= btn_small(81, 20, act->bmp_rect.h, 0, 512);
|
||||
line+=10;
|
||||
ui::label("POS", 2, line, 48, 11);
|
||||
changed |= btn_small(49, line, act->bmp_rect.x, 0, 512, 25);
|
||||
changed |= btn_small(73, line, act->bmp_rect.y, 0, 512, 25);
|
||||
line+=10;
|
||||
ui::label("SIZE", 2, line, 48, 11);
|
||||
changed |= btn_small(49, line, act->bmp_rect.w, 0, 512, 25);
|
||||
changed |= btn_small(73, line, act->bmp_rect.h, 0, 512, 25);
|
||||
line+=10;
|
||||
ui::label("OFFSET", 2, line, 48, 11);
|
||||
changed |= btn_small(49, line, act->bmp_offset.x, -32, 64, 25);
|
||||
changed |= btn_small(73, line, act->bmp_offset.y, -32, 64, 25);
|
||||
line+=10;
|
||||
|
||||
ui::label("OFFSET", 2, 30, 32, 11);
|
||||
changed |= btn_small(65, 30, act->bmp_offset.x, -32, 64);
|
||||
changed |= btn_small(81, 30, act->bmp_offset.y, -32, 64);
|
||||
ui::label("FLAGS", 2, line, 96, 11, GRAY); line+=10;
|
||||
|
||||
ui::label("POS", 2, 42, 32, 11);
|
||||
changed |= btn_small(49, 42, act->pos.x, 0, 512);
|
||||
changed |= btn_small(65, 42, act->pos.y, 0, 512);
|
||||
changed |= btn_small(81, 42, act->pos.z, 0, 512);
|
||||
changed |= btn_check(2, line, "PICK", act->flags, FLAG_PICKABLE);
|
||||
changed |= btn_check(26, line, "PUSH", act->flags, FLAG_PUSHABLE);
|
||||
changed |= btn_check(50, line, "REAC", act->flags, FLAG_REACTIVE);
|
||||
changed |= btn_check(74, line, "MOVI", act->flags, FLAG_MOVING);
|
||||
line+=10;
|
||||
changed |= btn_check(2, line, "ANIM", act->flags, FLAG_ANIMATED);
|
||||
changed |= btn_check(26, line, "ORIE", act->flags, FLAG_ORIENTABLE);
|
||||
changed |= btn_check(50, line, "DEAD", act->flags, FLAG_DEADLY);
|
||||
changed |= btn_check(74, line, "GRAV", act->flags, FLAG_GRAVITY);
|
||||
line+=11;
|
||||
|
||||
ui::label("SIZE", 2, 52, 32, 11);
|
||||
changed |= btn_small(49, 52, act->size.x, 0, 512);
|
||||
changed |= btn_small(65, 52, act->size.y, 0, 512);
|
||||
changed |= btn_small(81, 52, act->size.z, 0, 512);
|
||||
ui::label("PROPERTIES", 2, line, 96, 11, GRAY); line+=10;
|
||||
|
||||
changed |= btn_check(2, 64, "HERO", act->flags, FLAG_HERO);
|
||||
changed |= btn_check(26, 64, "PUSH", act->flags, FLAG_PUSHABLE);
|
||||
changed |= btn_check(50, 64, "REAC", act->flags, FLAG_REACTIVE);
|
||||
changed |= btn_check(74, 64, "MOVI", act->flags, FLAG_MOVING);
|
||||
changed |= btn_check(2, 74, "ANIM", act->flags, FLAG_ANIMATED);
|
||||
changed |= btn_check(26, 74, "ORIE", act->flags, FLAG_ORIENTABLE);
|
||||
changed |= btn_check(50, 74, "DEAD", act->flags, FLAG_DEADLY);
|
||||
changed |= btn_check(74, 74, "GRAV", act->flags, FLAG_GRAVITY);
|
||||
|
||||
if (btn_opt("ORIENT", 2, 86, act->orient, {PUSH_NONE, PUSH_XP, PUSH_XN, PUSH_YP, PUSH_YN, PUSH_ZP, PUSH_ZN}, {"NONE", "XP", "XN", "YP", "YN", "ZP", "ZN"}))
|
||||
if (btn_opt("ORIENT", 2, line, act->orient, {PUSH_NONE, PUSH_XP, PUSH_XN, PUSH_YP, PUSH_YN, PUSH_ZP, PUSH_ZN}, {"NONE", "XP", "XN", "YP", "YN", "ZP", "ZN"}, 48))
|
||||
{
|
||||
act->mov_push = act->orient;
|
||||
changed = true;
|
||||
}
|
||||
changed |= btn_opt("MOVEMNT", 2, 96, act->movement, {MOV_NONE, MOV_X, MOV_Y, MOV_Z, MOV_CW, MOV_CCW, MOV_RAND, MOV_HUNT}, {"NONE", "X", "Y", "Z", "CW", "CCW", "RAND", "HUNT"});
|
||||
changed |= btn_opt("ANIMCYC", 2, 106, act->anim_cycle, {0, 1}, {"0 1 0 2", "0 1 2 3"});
|
||||
line+=10;
|
||||
|
||||
changed |= btn_opt("MOVEMNT", 2, line, act->movement, {MOV_NONE, MOV_X, MOV_Y, MOV_Z, MOV_CW, MOV_CCW, MOV_RAND, MOV_HUNT}, {"NONE", "X", "Y", "Z", "CW", "CCW", "RAND", "HUNT"}, 48);
|
||||
line+=10;
|
||||
changed |= btn_opt("ANIMCYC", 2, line, act->anim_cycle, {0, 1}, {"0 1 0 2", "0 1 2 3"}, 48);
|
||||
line+=10;
|
||||
|
||||
//draw::print("ANIM SPEED:", 2, 156, 15, 0);
|
||||
ui::label("ANMSPED", 2, 116, 32, 11);
|
||||
changed |= btn_small(81, 116, act->anim_wait, 0, 10);
|
||||
ui::label("ANMSPED", 2, line, 49, 11);
|
||||
changed |= btn_small(49, line, act->anim_wait, 0, 10, 49);
|
||||
line+=10;
|
||||
|
||||
ui::label("RMASK", 2, 128, 24, 11);
|
||||
changed |= btn_check(24+2, 128, "XP", act->react_mask, PUSH_XP, 12);
|
||||
changed |= btn_check(24+14, 128, "XN", act->react_mask, PUSH_XN, 12);
|
||||
changed |= btn_check(24+26, 128, "YP", act->react_mask, PUSH_YP, 12);
|
||||
changed |= btn_check(24+38, 128, "YN", act->react_mask, PUSH_YN, 12);
|
||||
changed |= btn_check(24+50, 128, "ZP", act->react_mask, PUSH_ZP, 12);
|
||||
changed |= btn_check(24+62, 128, "ZN", act->react_mask, PUSH_ZN, 12);
|
||||
ui::label("MASKS", 2, line, 96, 11, GRAY); line+=10;
|
||||
|
||||
ui::label("RPUSH", 2, 140, 24, 11);
|
||||
changed |= btn_check(24+2, 140, "XP", act->react_push, PUSH_XP, 12);
|
||||
changed |= btn_check(24+14, 140, "XN", act->react_push, PUSH_XN, 12);
|
||||
changed |= btn_check(24+26, 140, "YP", act->react_push, PUSH_YP, 12);
|
||||
changed |= btn_check(24+38, 140, "YN", act->react_push, PUSH_YN, 12);
|
||||
changed |= btn_check(24+50, 140, "ZP", act->react_push, PUSH_ZP, 12);
|
||||
changed |= btn_check(24+62, 140, "ZN", act->react_push, PUSH_ZN, 12);
|
||||
ui::label("RMASK", 2, line, 24, 11);
|
||||
changed |= btn_check(24+2, line, "XP", act->react_mask, PUSH_XP, 12);
|
||||
changed |= btn_check(24+14, line, "XN", act->react_mask, PUSH_XN, 12);
|
||||
changed |= btn_check(24+26, line, "YP", act->react_mask, PUSH_YP, 12);
|
||||
changed |= btn_check(24+38, line, "YN", act->react_mask, PUSH_YN, 12);
|
||||
changed |= btn_check(24+50, line, "ZP", act->react_mask, PUSH_ZP, 12);
|
||||
changed |= btn_check(24+62, line, "ZN", act->react_mask, PUSH_ZN, 12);
|
||||
line+=11;
|
||||
|
||||
ui::label("RPUSH", 2, line, 24, 11);
|
||||
changed |= btn_check(24+2, line, "XP", act->react_push, PUSH_XP, 12);
|
||||
changed |= btn_check(24+14, line, "XN", act->react_push, PUSH_XN, 12);
|
||||
changed |= btn_check(24+26, line, "YP", act->react_push, PUSH_YP, 12);
|
||||
changed |= btn_check(24+38, line, "YN", act->react_push, PUSH_YN, 12);
|
||||
changed |= btn_check(24+50, line, "ZP", act->react_push, PUSH_ZP, 12);
|
||||
changed |= btn_check(24+62, line, "ZN", act->react_push, PUSH_ZN, 12);
|
||||
line+=12;
|
||||
|
||||
if (changed) { room::editor::modify(); }
|
||||
|
||||
draw::color(PAPER);
|
||||
draw::rect(2, 0, 96, 204);
|
||||
|
||||
if (ui::button("DUPLICATE", 2, line, 96, 11))
|
||||
{
|
||||
actor::actor_t *new_act = actor::duplicate(act);
|
||||
actor::setUniqueName(new_act);
|
||||
new_act->pos.x++; new_act->pos.y++;
|
||||
actor::setDirty(new_act, true);
|
||||
}
|
||||
line+=10;
|
||||
|
||||
if (ui::button("ADD TO TEMPLATES", 2, line, 96, 11))
|
||||
{
|
||||
if (!actor::templates::getByName(act->name)) actor::templates::add(act);
|
||||
}
|
||||
//changed |= btn_opt("ANIMCYC", 2, 106, act->anim_cycle, {0, 1}, {"0 1 0 2", "0 1 2 3"});
|
||||
|
||||
}
|
||||
break;
|
||||
};
|
||||
|
||||
draw::color(PAPER);
|
||||
draw::rect(2, 0, 96, 236);
|
||||
|
||||
/*
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user