From 3e37be8a3a621844fda63edf911d774aa75bc995 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Wed, 12 Jun 2024 13:56:22 +0200 Subject: [PATCH] - Millores del editor --- data/rooms/00.txt | 34 ++++++++--------- source/actor.h | 20 +++++----- source/main.cpp | 96 +++++++++++++++++++++++++---------------------- 3 files changed, 78 insertions(+), 72 deletions(-) diff --git a/data/rooms/00.txt b/data/rooms/00.txt index bb00025..cbb3fd0 100644 --- a/data/rooms/00.txt +++ b/data/rooms/00.txt @@ -1,30 +1,28 @@ width: 2 -height: 3 +height: 0 door-height-xn: 0 -color: cyan -floor-texture: 1 -wall-texture: 1 +color: CYAN +floor-texture: 0 +wall-texture: 3 door-texture: 1 under-door-texture: 1 -actor{ - name: BOX - bmp: test.gif - bmp-rect: 32 0 32 32 - bmp-offset: 0 32 - pos: 32 32 8 - size: 8 8 8 - orient: NONE - flags: PUSHABLE GRAVITY -} - actor{ name: BOX2 bmp: test.gif bmp-rect: 32 0 32 32 bmp-offset: 0 32 - pos: 32 32 0 + pos: 38 24 0 size: 8 8 8 - orient: NONE - flags: pushable gravity + flags: PUSHABLE GRAVITY +} + +actor{ + name: BOX + bmp: test.gif + bmp-rect: 32 0 32 32 + bmp-offset: 0 32 + pos: 28 32 0 + size: 8 8 8 + flags: PUSHABLE GRAVITY } diff --git a/source/actor.h b/source/actor.h index 24a208e..24bd1b0 100644 --- a/source/actor.h +++ b/source/actor.h @@ -55,20 +55,20 @@ namespace actor vec3_t pos; vec3_t size; - uint8_t orient; - uint8_t anim_cycle; - uint8_t anim_frame; + int orient; + int anim_cycle; + int anim_frame; int anim_wait; - uint8_t anim_wait_count; + int anim_wait_count; - uint16_t flags; - uint8_t push; + int flags; + int push; - uint8_t react_mask; - uint8_t react_push; + int react_mask; + int react_push; - uint8_t movement; - uint8_t mov_push; + int movement; + int mov_push; actor_t *below; actor_t *above; diff --git a/source/main.cpp b/source/main.cpp index f1646ce..bb4f13f 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -26,7 +26,7 @@ int room_walldoors = 0; std::vector gifs; -bool editing = false; +bool editing = true; void restart() { @@ -153,6 +153,7 @@ const bool btn_small(const int x, const int y, int &var, int min, int max, int w } +/* void btn_check(const int x, const int y, const char* label, uint8_t &flags, const uint8_t value) { int result=0; @@ -170,14 +171,14 @@ void btn_check(const int x, const int y, const char* label, uint8_t &flags, cons } } } - -const bool btn_check(const int x, const int y, const char* label, uint16_t &flags, const uint16_t value) +*/ +const bool btn_check(const int x, const int y, const char* label, int &flags, const uint16_t value, const int width=24) { int result=0; if (flags & value) { - result=ui::check(label, x, y, 24, 11, true); + result=ui::check(label, x, y, width, 11, true); } else { - result=ui::check(label, x, y, 24, 11, false); + result=ui::check(label, x, y, width, 11, false); } if (result) { @@ -191,7 +192,7 @@ const bool btn_check(const int x, const int y, const char* label, uint16_t &flag return false; } -const bool btn_opt(const char* label, const int x, const int y, uint8_t &var, std::vector values, std::vector labels, const int w=32) +const bool btn_opt(const char* label, const int x, const int y, int &var, std::vector values, std::vector labels, const int w=32) { //draw::print(label, x, y+3, 15, 0); ui::label(label, x, y, w, 11); @@ -244,7 +245,7 @@ const uint8_t scancode_to_char(const uint8_t scancode) return 32; } -void btn_txt(const char* label, const int x, const int y, char *var) +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); @@ -261,7 +262,9 @@ void btn_txt(const char* label, const int x, const int y, char *var) var[len+1] = 0; } } + return true; } + return false; } int section = SECTION_ROOM; @@ -481,66 +484,71 @@ switch (section) { //draw::setViewport(420, 90, 100, 150); - btn_txt("NAME:", 2, 0, act->name); + changed |= btn_txt("NAME:", 2, 0, act->name); if (btn_opt2("BMP:", 2, 10, 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); - btn_small(33, 20, act->bmp_rect.x, 0, 512); - btn_small(49, 20, act->bmp_rect.y, 0, 512); - btn_small(65, 20, act->bmp_rect.w, 0, 512); - btn_small(81, 20, act->bmp_rect.h, 0, 512); + 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); ui::label("OFFSET", 2, 30, 32, 11); - btn_small(65, 30, act->bmp_offset.x, -32, 64); - btn_small(81, 30, act->bmp_offset.y, -32, 64); + changed |= btn_small(65, 30, act->bmp_offset.x, -32, 64); + changed |= btn_small(81, 30, act->bmp_offset.y, -32, 64); ui::label("POS", 2, 42, 32, 11); - btn_small(49, 42, act->pos.x, 0, 512); - btn_small(65, 42, act->pos.y, 0, 512); - btn_small(81, 42, act->pos.z, 0, 512); + 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); ui::label("SIZE", 2, 52, 32, 11); - btn_small(49, 52, act->size.x, 0, 512); - btn_small(65, 52, act->size.y, 0, 512); - btn_small(81, 52, act->size.z, 0, 512); + 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); - btn_check(2, 64, "HERO", act->flags, FLAG_HERO); - btn_check(26, 64, "PUSH", act->flags, FLAG_PUSHABLE); - btn_check(50, 64, "REAC", act->flags, FLAG_REACTIVE); + 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); - btn_check(2, 74, "ANIM", act->flags, FLAG_ANIMATED); - btn_check(26, 74, "ORIE", act->flags, FLAG_ORIENTABLE); - btn_check(50, 74, "DEAD", act->flags, FLAG_DEADLY); - btn_check(74, 74, "GRAV", act->flags, FLAG_GRAVITY); + 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); - changed |= 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, 86, act->orient, {PUSH_NONE, PUSH_XP, PUSH_XN, PUSH_YP, PUSH_YN, PUSH_ZP, PUSH_ZN}, {"NONE", "XP", "XN", "YP", "YN", "ZP", "ZN"})) + { + 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"}); - btn_opt("ANIMCYC", 2, 106, act->anim_cycle, {0, 1}, {"0 1 0 2", "0 1 2 3"}); - - if (changed) act->mov_push = act->orient; + changed |= btn_opt("ANIMCYC", 2, 106, act->anim_cycle, {0, 1}, {"0 1 0 2", "0 1 2 3"}); //draw::print("ANIM SPEED:", 2, 156, 15, 0); ui::label("ANMSPED", 2, 116, 32, 11); - btn_small(81, 116, act->anim_wait, 0, 10); + changed |= btn_small(81, 116, act->anim_wait, 0, 10); ui::label("RMASK", 2, 128, 24, 11); - btn_check(24+2, 128, "XP", act->react_mask, PUSH_XP); - btn_check(24+14, 128, "XN", act->react_mask, PUSH_XN); - btn_check(24+26, 128, "YP", act->react_mask, PUSH_YP); - btn_check(24+38, 128, "YN", act->react_mask, PUSH_YN); - btn_check(24+50, 128, "ZP", act->react_mask, PUSH_ZP); - btn_check(24+62, 128, "ZN", act->react_mask, PUSH_ZN); + 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("RPUSH", 2, 140, 24, 11); - btn_check(24+2, 140, "XP", act->react_push, PUSH_XP); - btn_check(24+14, 140, "XN", act->react_push, PUSH_XN); - btn_check(24+26, 140, "YP", act->react_push, PUSH_YP); - btn_check(24+38, 140, "YN", act->react_push, PUSH_YN); - btn_check(24+50, 140, "ZP", act->react_push, PUSH_ZP); - btn_check(24+62, 140, "ZN", act->react_push, PUSH_ZN); + 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); + + if (changed) { room::editor::modify(); } } break; };