- Ja guarda l'habitació

This commit is contained in:
2024-06-12 12:44:43 +02:00
parent a854b1da86
commit 8750483839
4 changed files with 32 additions and 29 deletions

View File

@@ -44,6 +44,7 @@ namespace actor
act->anim_wait = act->anim_wait_count = 0; act->anim_wait = act->anim_wait_count = 0;
act->anim_frame=0; act->anim_frame=0;
act->react_mask = act->react_push = 0; act->react_mask = act->react_push = 0;
act->flags = FLAG_NONE;
return act; return act;
} }
@@ -61,6 +62,7 @@ namespace actor
act->anim_wait = act->anim_wait_count = 0; act->anim_wait = act->anim_wait_count = 0;
act->anim_frame=0; act->anim_frame=0;
act->react_mask = act->react_push = 0; act->react_mask = act->react_push = 0;
act->flags = FLAG_NONE;
return act; return act;
} }
@@ -195,21 +197,21 @@ namespace actor
void saveToFile(FILE *f, actor_t *act) void saveToFile(FILE *f, actor_t *act)
{ {
fprintf(f, "actor{\n"); fprintf(f, "\nactor{\n");
fprintf(f, " name: %s\n", act->name); fprintf(f, " name: %s\n", act->name);
fprintf(f, " bmp: %s\n", act->bmp); fprintf(f, " bmp: %s\n", act->bmp);
fprintf(f, " bmp-rect: %i %i %i %i\n", act->bmp_rect.x, act->bmp_rect.y, act->bmp_rect.w, act->bmp_rect.h); fprintf(f, " bmp-rect: %i %i %i %i\n", act->bmp_rect.x, act->bmp_rect.y, act->bmp_rect.w, act->bmp_rect.h);
fprintf(f, " bmp-offset: %i %i\n", act->bmp_offset.x, act->bmp_offset.y); fprintf(f, " bmp-offset: %i %i\n", act->bmp_offset.x, act->bmp_offset.y);
fprintf(f, " pos: %i %i %i\n", act->pos.x, act->pos.y, act->pos.z); fprintf(f, " pos: %i %i %i\n", act->pos.x, act->pos.y, act->pos.z);
fprintf(f, " size: %i %i %i\n", act->size.x, act->size.y, act->size.z); fprintf(f, " size: %i %i %i\n", act->size.x, act->size.y, act->size.z);
fprintf(f, " orient: %s\n", numToOrient(act->orient)); if (act->orient!=0) fprintf(f, " orient: %s\n", numToOrient(act->orient));
fprintf(f, " anim-cycle: %s\n", act->anim_cycle==0 ? "WALK" : "SEQ"); if (act->anim_cycle!=0) fprintf(f, " anim-cycle: %s\n", act->anim_cycle==0 ? "WALK" : "SEQ");
fprintf(f, " anim-wait: %i\n", act->anim_wait); if (act->anim_wait!=0) fprintf(f, " anim-wait: %i\n", act->anim_wait);
fprintf(f, " flags: %s\n", numToFlags(act->flags)); if (act->flags!=0) fprintf(f, " flags: %s\n", numToFlags(act->flags));
fprintf(f, " react-mask: %s\n", numToOrient(act->react_mask)); if (act->react_mask!=0) fprintf(f, " react-mask: %s\n", numToOrient(act->react_mask));
fprintf(f, " react-push: %s\n", numToOrient(act->react_push)); if (act->react_push!=0) fprintf(f, " react-push: %s\n", numToOrient(act->react_push));
fprintf(f, " movement: %s\n\n", numToMov(act->movement)); if (act->movement!=0) fprintf(f, " movement: %s\n", numToMov(act->movement));
fprintf(f, "}\n\n"); fprintf(f, "}\n");
} }
const bool check_2d_collision(actor_t *obj1, actor_t *obj2) const bool check_2d_collision(actor_t *obj1, actor_t *obj2)

View File

@@ -77,7 +77,7 @@ namespace ui
draw::color(LIGHT+WHITE); draw::color(LIGHT+WHITE);
draw::fillrect(x, y, w, h); draw::fillrect(x, y, w, h);
draw::color(PAPER); draw::color(WHITE);
draw::rect(x, y, w, h); draw::rect(x, y, w, h);
draw::vline(x+w-11,y+1,h-2); draw::vline(x+w-11,y+1,h-2);

View File

@@ -191,10 +191,10 @@ const bool btn_check(const int x, const int y, const char* label, uint16_t &flag
return false; return false;
} }
const bool btn_opt(const char* label, const int x, const int y, uint8_t &var, std::vector<uint8_t> values, std::vector<std::string> labels) const bool btn_opt(const char* label, const int x, const int y, uint8_t &var, std::vector<uint8_t> values, std::vector<std::string> labels, const int w=32)
{ {
//draw::print(label, x, y+3, 15, 0); //draw::print(label, x, y+3, 15, 0);
ui::label(label, x, y, 32, 11); ui::label(label, x, y, w, 11);
int result = 0; int result = 0;
std::size_t pos = 0; std::size_t pos = 0;
while (pos<values.size()) while (pos<values.size())
@@ -203,7 +203,7 @@ const bool btn_opt(const char* label, const int x, const int y, uint8_t &var, st
pos++; pos++;
} }
result = ui::combo(labels[pos].c_str(), x+31, y, 65, 11); result = ui::combo(labels[pos].c_str(), x+31, y, 96-w, 11);
if (result) if (result)
{ {
pos++; if (pos==values.size()) pos=0; pos++; if (pos==values.size()) pos=0;
@@ -449,8 +449,9 @@ switch (section)
ui::label("TEXTURES", 2, line, 96, 11, GRAY); line+=10; ui::label("TEXTURES", 2, line, 96, 11, GRAY); line+=10;
ui::label("COLOR", 2, line, 64, 11); changed |= btn_opt("COLOR", 2, line, room::editor::refColor(), {5, 6, 7, 8, 9, 10, 11}, {"BLUE", "RED", "PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE"});
changed |= btn_small(64, line, room::editor::refColor(), 5, 11); //ui::label("COLOR", 2, line, 64, 11);
//changed |= btn_small(64, line, room::editor::refColor(), 5, 11);
line += 10; line += 10;
ui::label("FLOOR", 2, line, 64, 11); ui::label("FLOOR", 2, line, 64, 11);
changed |= btn_small(64, line, room::editor::refFloorTex(), 0, 5); changed |= btn_small(64, line, room::editor::refFloorTex(), 0, 5);

View File

@@ -377,7 +377,7 @@ namespace room
const char *numToColor(uint8_t value) const char *numToColor(uint8_t value)
{ {
const char* colors[7] = {"blue", "red", "purple", "green", "cyan", "yellow", "white"}; const char* colors[7] = {"BLUE", "RED", "PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE"};
return colors[value-5]; return colors[value-5];
} }
@@ -386,16 +386,16 @@ namespace room
void save() void save()
{ {
char filename[] = "data/rooms/00.txt"; char filename[] = "data/rooms/00.txt";
filename[6] = int(current_room/10)+48; filename[11] = int(current_room/10)+48;
filename[7] = (current_room%10)+48; filename[12] = (current_room%10)+48;
FILE *f = fopen(filename, "w"); FILE *f = fopen(filename, "w");
fprintf(f, "width: %i\n", inner_w); fprintf(f, "width: %i\n", inner_w);
fprintf(f, "height: %i\n", inner_h); fprintf(f, "height: %i\n", inner_h);
fprintf(f, "door-height-xp: %i\n", door_height[XP]); if (door_height[XP]!=-1) fprintf(f, "door-height-xp: %i\n", door_height[XP]);
fprintf(f, "door-height-xn: %i\n", door_height[XN]); if (door_height[XN]!=-1) fprintf(f, "door-height-xn: %i\n", door_height[XN]);
fprintf(f, "door-height-yp: %i\n", door_height[YP]); if (door_height[YP]!=-1) fprintf(f, "door-height-yp: %i\n", door_height[YP]);
fprintf(f, "door-height-yn: %i\n", door_height[YN]); if (door_height[YN]!=-1) fprintf(f, "door-height-yn: %i\n", door_height[YN]);
fprintf(f, "color: %s\n", numToColor(color)); fprintf(f, "color: %s\n", numToColor(color));
fprintf(f, "floor-texture: %i\n", floor_type); fprintf(f, "floor-texture: %i\n", floor_type);
@@ -403,17 +403,17 @@ namespace room
fprintf(f, "door-texture: %i\n", doors_type); fprintf(f, "door-texture: %i\n", doors_type);
fprintf(f, "under-door-texture: %i\n", walldoors_type); fprintf(f, "under-door-texture: %i\n", walldoors_type);
fprintf(f, "exit-xp: %i\n", exits[XP]); if (exits[XP]!=-1) fprintf(f, "exit-xp: %i\n", exits[XP]);
fprintf(f, "exit-xn: %i\n", exits[XN]); if (exits[XN]!=-1) fprintf(f, "exit-xn: %i\n", exits[XN]);
fprintf(f, "exit-yp: %i\n", exits[YP]); if (exits[YP]!=-1) fprintf(f, "exit-yp: %i\n", exits[YP]);
fprintf(f, "exit-yn: %i\n", exits[YN]); if (exits[YN]!=-1) fprintf(f, "exit-yn: %i\n", exits[YN]);
fprintf(f, "exit-zp: %i\n", exits[ZP]); if (exits[ZP]!=-1) fprintf(f, "exit-zp: %i\n", exits[ZP]);
fprintf(f, "exit-zn: %i\n", exits[ZN]); if (exits[ZN]!=-1) fprintf(f, "exit-zn: %i\n", exits[ZN]);
actor::actor_t *act = actor::getFirst(); actor::actor_t *act = actor::getFirst();
while (act) while (act)
{ {
actor::saveToFile(f, act); if ( (act->flags&(FLAG_HERO|FLAG_NOEDITOR))==0 ) actor::saveToFile(f, act);
act = act->next; act = act->next;
} }