- Acabat el editor de templates
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
category{
|
category{
|
||||||
name: default
|
name: DEFAULT
|
||||||
|
|
||||||
actor{
|
actor{
|
||||||
name: BOX
|
name: BOX
|
||||||
@@ -85,18 +85,168 @@ category{
|
|||||||
}
|
}
|
||||||
|
|
||||||
actor{
|
actor{
|
||||||
name: P-TIMER
|
name: FINESTRA
|
||||||
bmp: objectes.gif
|
bmp: altres.gif
|
||||||
bmp-rect: 96 0 24 32
|
bmp-rect: 0 75 20 33
|
||||||
bmp-offset: -4 34
|
bmp-offset: 0 39
|
||||||
pos: 8 40 8
|
pos: 15 23 4
|
||||||
size: 4 4 4
|
size: 1 1 9
|
||||||
anim-cycle: SEQ
|
|
||||||
anim-wait: 2
|
|
||||||
flags: SPECIAL
|
|
||||||
movement: CW
|
movement: CW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: EXPLOSION
|
||||||
|
bmp: caixes.gif
|
||||||
|
bmp-rect: 0 160 18 22
|
||||||
|
bmp-offset: -7 24
|
||||||
|
pos: 32 32 0
|
||||||
|
size: 8 8 4
|
||||||
|
anim-cycle: SEQ
|
||||||
|
flags: ANIMATED
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: GAT-NEGRE
|
||||||
|
bmp: gat.gif
|
||||||
|
bmp-rect: 0 0 24 28
|
||||||
|
bmp-offset: -4 32
|
||||||
|
pos: 8 8 0
|
||||||
|
size: 8 8 8
|
||||||
|
orient: XP
|
||||||
|
anim-wait: 2
|
||||||
|
flags: MOVING ANIMATED ORIENTABLE
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: CUADRO
|
||||||
|
bmp: altres.gif
|
||||||
|
bmp-rect: 66 75 18 32
|
||||||
|
bmp-offset: 0 39
|
||||||
|
pos: 14 23 6
|
||||||
|
size: 1 1 9
|
||||||
|
orient: YP
|
||||||
|
flags: ORIENTABLE
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: ROOMBA
|
||||||
|
bmp: caixes.gif
|
||||||
|
bmp-rect: 160 0 32 32
|
||||||
|
bmp-offset: 0 34
|
||||||
|
pos: 32 32 0
|
||||||
|
size: 8 8 2
|
||||||
|
orient: XN
|
||||||
|
flags: REACTIVE MOVING DEADLY
|
||||||
|
react-mask: XP XN YP YN ZP ZN
|
||||||
|
movement: CCW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: WC
|
||||||
|
bmp: altres.gif
|
||||||
|
bmp-rect: 105 0 21 33
|
||||||
|
bmp-offset: -4 36
|
||||||
|
pos: 8 8 0
|
||||||
|
size: 8 8 8
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: MANCUERNA
|
||||||
|
bmp: altres.gif
|
||||||
|
bmp-rect: 106 33 17 14
|
||||||
|
bmp-offset: -6 20
|
||||||
|
pos: 24 25 0
|
||||||
|
size: 6 4 2
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
category{
|
||||||
|
name: MOBLES
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: SOFA
|
||||||
|
bmp: altres.gif
|
||||||
|
bmp-rect: 0 0 48 40
|
||||||
|
bmp-offset: 0 32
|
||||||
|
pos: 0 0 0
|
||||||
|
size: 16 8 6
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: LLIT
|
||||||
|
bmp: altres.gif
|
||||||
|
bmp-rect: 48 0 57 47
|
||||||
|
bmp-offset: 11 32
|
||||||
|
pos: 8 8 0
|
||||||
|
size: 16 16 8
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: KALLAX
|
||||||
|
bmp: altres.gif
|
||||||
|
bmp-rect: 0 48 24 27
|
||||||
|
bmp-offset: 0 31
|
||||||
|
pos: 0 0 0
|
||||||
|
size: 8 4 8
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: MESITA
|
||||||
|
bmp: caixes.gif
|
||||||
|
bmp-rect: 0 64 32 32
|
||||||
|
bmp-offset: 0 32
|
||||||
|
pos: 0 16 0
|
||||||
|
size: 8 8 4
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: LAMPARA
|
||||||
|
bmp: altres.gif
|
||||||
|
bmp-rect: 128 0 20 41
|
||||||
|
bmp-offset: -6 45
|
||||||
|
pos: 1 41 0
|
||||||
|
size: 6 6 16
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: CADIRA
|
||||||
|
bmp: caixes.gif
|
||||||
|
bmp-rect: 64 96 20 32
|
||||||
|
bmp-offset: -8 40
|
||||||
|
pos: 8 51 0
|
||||||
|
size: 5 4 8
|
||||||
|
orient: YP
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: PILA
|
||||||
|
bmp: caixes.gif
|
||||||
|
bmp-rect: 160 96 32 32
|
||||||
|
bmp-offset: 0 32
|
||||||
|
pos: 24 8 0
|
||||||
|
size: 8 8 8
|
||||||
|
orient: YP
|
||||||
|
flags: ORIENTABLE
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
category{
|
||||||
|
name: PARTS
|
||||||
|
|
||||||
actor{
|
actor{
|
||||||
name: P-FILTER
|
name: P-FILTER
|
||||||
bmp: objectes.gif
|
bmp: objectes.gif
|
||||||
@@ -163,160 +313,15 @@ category{
|
|||||||
}
|
}
|
||||||
|
|
||||||
actor{
|
actor{
|
||||||
name: SOFA
|
name: P-TIMER
|
||||||
bmp: altres.gif
|
bmp: objectes.gif
|
||||||
bmp-rect: 0 0 48 40
|
bmp-rect: 96 0 24 32
|
||||||
bmp-offset: 0 32
|
bmp-offset: -4 34
|
||||||
pos: 0 0 0
|
pos: 8 40 8
|
||||||
size: 16 8 6
|
size: 4 4 4
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: LLIT
|
|
||||||
bmp: altres.gif
|
|
||||||
bmp-rect: 48 0 57 47
|
|
||||||
bmp-offset: 11 32
|
|
||||||
pos: 8 8 0
|
|
||||||
size: 16 16 8
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: KALLAX-A
|
|
||||||
bmp: altres.gif
|
|
||||||
bmp-rect: 0 48 24 27
|
|
||||||
bmp-offset: 0 31
|
|
||||||
pos: 0 0 0
|
|
||||||
size: 8 4 8
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: FINESTRA
|
|
||||||
bmp: altres.gif
|
|
||||||
bmp-rect: 0 75 20 33
|
|
||||||
bmp-offset: 0 39
|
|
||||||
pos: 15 23 4
|
|
||||||
size: 1 1 9
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: EXPLOSION
|
|
||||||
bmp: caixes.gif
|
|
||||||
bmp-rect: 0 160 18 22
|
|
||||||
bmp-offset: -7 24
|
|
||||||
pos: 32 32 0
|
|
||||||
size: 8 8 4
|
|
||||||
anim-cycle: SEQ
|
anim-cycle: SEQ
|
||||||
flags: ANIMATED
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: GAT-NEGRE
|
|
||||||
bmp: gat.gif
|
|
||||||
bmp-rect: 0 0 24 28
|
|
||||||
bmp-offset: -4 32
|
|
||||||
pos: 8 8 0
|
|
||||||
size: 8 8 8
|
|
||||||
orient: XP
|
|
||||||
anim-wait: 2
|
anim-wait: 2
|
||||||
flags: MOVING ANIMATED ORIENTABLE
|
flags: SPECIAL
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: CUADRO
|
|
||||||
bmp: altres.gif
|
|
||||||
bmp-rect: 66 75 18 32
|
|
||||||
bmp-offset: 0 39
|
|
||||||
pos: 14 23 6
|
|
||||||
size: 1 1 9
|
|
||||||
orient: YP
|
|
||||||
flags: ORIENTABLE
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: MESITA
|
|
||||||
bmp: caixes.gif
|
|
||||||
bmp-rect: 0 64 32 32
|
|
||||||
bmp-offset: 0 32
|
|
||||||
pos: 0 16 0
|
|
||||||
size: 8 8 4
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: LAMPARA
|
|
||||||
bmp: altres.gif
|
|
||||||
bmp-rect: 128 0 20 41
|
|
||||||
bmp-offset: -6 45
|
|
||||||
pos: 1 41 0
|
|
||||||
size: 6 6 16
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: ROOMBA
|
|
||||||
bmp: caixes.gif
|
|
||||||
bmp-rect: 160 0 32 32
|
|
||||||
bmp-offset: 0 34
|
|
||||||
pos: 32 32 0
|
|
||||||
size: 8 8 2
|
|
||||||
orient: XN
|
|
||||||
flags: REACTIVE MOVING DEADLY
|
|
||||||
react-mask: XP XN YP YN ZP ZN
|
|
||||||
movement: CCW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: WC
|
|
||||||
bmp: altres.gif
|
|
||||||
bmp-rect: 105 0 21 33
|
|
||||||
bmp-offset: -4 36
|
|
||||||
pos: 8 8 0
|
|
||||||
size: 8 8 8
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: MANCUERNA
|
|
||||||
bmp: altres.gif
|
|
||||||
bmp-rect: 106 33 17 14
|
|
||||||
bmp-offset: -6 20
|
|
||||||
pos: 24 25 0
|
|
||||||
size: 6 4 2
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: CADIRA
|
|
||||||
bmp: caixes.gif
|
|
||||||
bmp-rect: 64 96 20 32
|
|
||||||
bmp-offset: -8 40
|
|
||||||
pos: 8 51 0
|
|
||||||
size: 5 4 8
|
|
||||||
orient: YP
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
category{
|
|
||||||
name: coses
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: PILA
|
|
||||||
bmp: caixes.gif
|
|
||||||
bmp-rect: 160 96 32 32
|
|
||||||
bmp-offset: 0 32
|
|
||||||
pos: 24 8 0
|
|
||||||
size: 8 8 8
|
|
||||||
orient: YP
|
|
||||||
flags: ORIENTABLE
|
|
||||||
movement: CW
|
movement: CW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,11 @@ namespace modules
|
|||||||
char name[13];
|
char name[13];
|
||||||
uint32_t time = 0;
|
uint32_t time = 0;
|
||||||
|
|
||||||
|
char actor_cut[13];
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
|
actor_cut[0] = 0;
|
||||||
current_category = 0;
|
current_category = 0;
|
||||||
edit_mode = EDITING_NORMAL;
|
edit_mode = EDITING_NORMAL;
|
||||||
//for (int i=0; i<templates.size(); ++i) if (templates[i] != nullptr) actor::remove(templates[i]);
|
//for (int i=0; i<templates.size(); ++i) if (templates[i] != nullptr) actor::remove(templates[i]);
|
||||||
@@ -62,6 +65,17 @@ namespace modules
|
|||||||
|
|
||||||
if (edit_mode == EDITING_NORMAL)
|
if (edit_mode == EDITING_NORMAL)
|
||||||
{
|
{
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_V) && actor_cut[0]!=0)
|
||||||
|
{
|
||||||
|
actor::actor_t *act = actor::templates::getByName(actor_cut);
|
||||||
|
if (act)
|
||||||
|
{
|
||||||
|
act->template_category = current_category;
|
||||||
|
actor::templates::save();
|
||||||
|
}
|
||||||
|
actor_cut[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
draw::cls(2);
|
draw::cls(2);
|
||||||
|
|
||||||
int x=0, y=0;
|
int x=0, y=0;
|
||||||
@@ -82,15 +96,22 @@ namespace modules
|
|||||||
draw::print(category.c_str(), 11+((40-category.size()*4)/2)+x*40, 3, LIGHT+WHITE, BLACK);
|
draw::print(category.c_str(), 11+((40-category.size()*4)/2)+x*40, 3, LIGHT+WHITE, BLACK);
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int hovered_actor = ((input::mouseX()-10)/65) + ((input::mouseY()-14)/40) * 8;
|
||||||
|
|
||||||
x = 0;
|
x = 0;
|
||||||
|
int i = 0;
|
||||||
auto actors = actor::templates::getByCategory(categories[current_category].c_str());
|
auto actors = actor::templates::getByCategory(categories[current_category].c_str());
|
||||||
|
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_X) && (hovered_actor < actors.size())) strcpy(actor_cut, actors[hovered_actor].name);
|
||||||
|
|
||||||
for (auto actor : actors)
|
for (auto actor : actors)
|
||||||
{
|
{
|
||||||
draw::swapcol(1, TEAL);
|
draw::swapcol(1, strcmp(actor.name, actor_cut)==0 ? BLUE : TEAL);
|
||||||
actor::drawAt(&actor, 10+x*65, 14+y*40);
|
actor::drawAt(&actor, 10+x*65, 14+y*40);
|
||||||
draw::print(actor.name, 10+(x*65), (y*40)+44, LIGHT+WHITE, BLACK);
|
draw::print(actor.name, 10+(x*65), (y*40)+44, i==hovered_actor ? YELLOW : LIGHT+WHITE, BLACK);
|
||||||
x++; if (x==8) { x=0;y++; }
|
x++; if (x==8) { x=0;y++; }
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw::render();
|
draw::render();
|
||||||
@@ -101,10 +122,9 @@ namespace modules
|
|||||||
|
|
||||||
if (input::mouseClk(1))
|
if (input::mouseClk(1))
|
||||||
{
|
{
|
||||||
if (input::mouseX()>12) {
|
if (input::mouseY()>12) {
|
||||||
const int clicked = ((input::mouseX()-10)/65) + ((input::mouseY()-14)/40) * 8;
|
if (hovered_actor<=actors.size()) {
|
||||||
if (clicked<=actors.size()) {
|
actor::actor_t *new_act = actor::duplicate(&actors[hovered_actor]);
|
||||||
actor::actor_t *new_act = actor::duplicate(&actors[clicked]);
|
|
||||||
actor::setUniqueName(new_act);
|
actor::setUniqueName(new_act);
|
||||||
actor::setDirty(new_act, true);
|
actor::setDirty(new_act, true);
|
||||||
actor::select(new_act);
|
actor::select(new_act);
|
||||||
@@ -113,17 +133,21 @@ namespace modules
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
edit_mode = EDITING_CATEGORY_NAME;
|
if (input::mouseX()<12) {
|
||||||
init_text_edit();
|
edit_mode = EDITING_CATEGORY_NAME;
|
||||||
|
init_text_edit();
|
||||||
|
} else {
|
||||||
|
current_category = (input::mouseX()-11)/40;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (input::mouseClk(3))
|
else if (input::mouseClk(3))
|
||||||
{
|
{
|
||||||
if (input::mouseX()>12) {
|
if (input::mouseX()>12) {
|
||||||
const int clicked = ((input::mouseX()-10)/65) + ((input::mouseY()-14)/40) * 8;
|
if (hovered_actor<=actors.size()) {
|
||||||
if (clicked<=actors.size()) {
|
actor_edited = actor::templates::getByName(actors[hovered_actor].name);
|
||||||
actor_edited = actor::templates::getByName(actors[clicked].name);
|
edit_mode = EDITING_ACTOR_NAME;
|
||||||
edit_mode = EDITING_CATEGORY_NAME;
|
init_text_edit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,7 +160,7 @@ namespace modules
|
|||||||
draw::rect(217+10,106+15,66,11);
|
draw::rect(217+10,106+15,66,11);
|
||||||
draw::print(name, 217+12, 106+17, BLACK, 0);
|
draw::print(name, 217+12, 106+17, BLACK, 0);
|
||||||
if (SDL_GetTicks()-time < 500) draw::print("_", 217+12+strlen(name)*4, 106+17, BLACK, 0);
|
if (SDL_GetTicks()-time < 500) draw::print("_", 217+12+strlen(name)*4, 106+17, BLACK, 0);
|
||||||
if (SDL_GetTicks()-time >= 500) time = SDL_GetTicks();
|
if (SDL_GetTicks()-time >= 1000) time = SDL_GetTicks();
|
||||||
draw::render();
|
draw::render();
|
||||||
|
|
||||||
int result = input::getKeyPressed();
|
int result = input::getKeyPressed();
|
||||||
@@ -144,7 +168,16 @@ namespace modules
|
|||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
const int len = strlen(name);
|
const int len = strlen(name);
|
||||||
if (result == SDL_SCANCODE_BACKSPACE) {
|
if (result == SDL_SCANCODE_RETURN) {
|
||||||
|
if (edit_mode==EDITING_CATEGORY_NAME) {
|
||||||
|
actor::templates::newCategory(name);
|
||||||
|
edit_mode = EDITING_NORMAL;
|
||||||
|
} else {
|
||||||
|
strcpy(actor_edited->name, name);
|
||||||
|
edit_mode = EDITING_NORMAL;
|
||||||
|
}
|
||||||
|
actor::templates::save();
|
||||||
|
} else if (result == SDL_SCANCODE_BACKSPACE) {
|
||||||
if (len>0) name[len-1] = 0;
|
if (len>0) name[len-1] = 0;
|
||||||
} else {
|
} else {
|
||||||
if (len<15) {
|
if (len<15) {
|
||||||
@@ -152,7 +185,6 @@ namespace modules
|
|||||||
name[len+1] = 0;
|
name[len+1] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ namespace modules
|
|||||||
if (console::isEnabled()) {
|
if (console::isEnabled()) {
|
||||||
console::toggle();
|
console::toggle();
|
||||||
} else {
|
} else {
|
||||||
if (editor::isEditing()) room::editor::save();
|
if (room::editor::isModified()) room::editor::save();
|
||||||
return GAME_MENU;
|
return GAME_MENU;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -545,6 +545,11 @@ namespace room
|
|||||||
|
|
||||||
void modify() { modified = true; }
|
void modify() { modified = true; }
|
||||||
|
|
||||||
|
const bool isModified()
|
||||||
|
{
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
void save()
|
void save()
|
||||||
{
|
{
|
||||||
char filename[] = "data/rooms/00.txt";
|
char filename[] = "data/rooms/00.txt";
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ namespace room
|
|||||||
int getCurrentRoom();
|
int getCurrentRoom();
|
||||||
|
|
||||||
void modify();
|
void modify();
|
||||||
|
const bool isModified();
|
||||||
void save();
|
void save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user