From c71ee1bbb50a972b54f18dc3c593399947d4de52 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Mon, 10 Jun 2024 21:56:32 +0200 Subject: [PATCH] =?UTF-8?q?-=20Ja=20mostra=20el=20panel=20de=20propietats?= =?UTF-8?q?=20que=20toca=20segons=20el=20que=20est=C3=A0=20seleccionat.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/main.cpp | 191 +++++++++++++++++++++--------------------------- 1 file changed, 85 insertions(+), 106 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 89690e9..6a1a3c9 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -320,27 +320,6 @@ bool game::loop() draw::color(WHITE); draw::fillrect(0, 0, 100, 240); -/* - bool change = false; - - change |= btn("ROOM WIDTH:", 10, 40, room::editor::refWidth(), 0, 3); - change |= btn("ROOM HEIGHT:", 10, 55, room::editor::refHeight(), 0, 3); - - draw::print("DOORS:", 10, 80, 15, 0); - change |= btn_small(32, 80, room::editor::refDoor(XN), -1, 5); - change |= btn_small(49, 80, room::editor::refDoor(YP), -1, 5); - change |= btn_small(66, 80, room::editor::refDoor(XP), -1, 5); - change |= btn_small(83, 80, room::editor::refDoor(YN), -1, 5); - - btn("COLOR:", 10, 140, room::editor::refColor(), 5, 11); - btn("FLOOR:", 10, 155, room::editor::refFloorTex(), 0, 5); - btn("WALLS:", 10, 170, room::editor::refWallTex(), 0, 5); - btn("DOORS:", 10, 185, room::editor::refDoorTex(), 0, 4); - btn("WDOORS:", 10, 200, room::editor::refWallDoorTex(), 0, 5); - - if (change) room::update(); -*/ - draw::color(LIGHT+WHITE); draw::fillrect(2, 2, 96, 236); draw::color(PAPER); @@ -406,103 +385,104 @@ bool game::loop() break; case 1: */ - draw::setViewport(420, 0, 100, 240); - draw::color(WHITE); - draw::fillrect(0, 0, 100, 240); + draw::setViewport(420, 0, 100, 240); + draw::color(WHITE); + draw::fillrect(0, 0, 100, 240); - draw::setViewport(420, 2, 100, 238); + bool room_changed = false; - draw::color(LIGHT+WHITE); - draw::fillrect(2, 0, 96, 100); - draw::color(PAPER); - draw::rect(2, 0, 96, 100); +switch (section) +{ + case SECTION_GENERAL: + break; -/* - const int mx = draw::getLocalX(input::mouseX()); - const int my = draw::getLocalY(input::mouseY()); - const bool btnDown = input::mouseBtn(1) || input::mouseBtn(3); + case SECTION_ROOM: - int line = 0; - act = actor::getFirst(); - while (act) { - if ((act->flags&FLAG_NOEDITOR)!=FLAG_NOEDITOR) { - if (act==actor::getSelected()) { - draw::color(LIGHT+BLUE); - draw::fillrect(4, 2+line*9, 92, 9); - } - if ((mx>=2) && (mx<98) && (my>=2+line*9) && (my<2+9+line*9) && btnDown) { - actor::select(act); - //section=1; - } - draw::print(act->name, 6, 4+line*9, LIGHT+WHITE, BLACK); - line++; - } - act = act->next; + room_changed |= btn("ROOM WIDTH:", 10, 40, room::editor::refWidth(), 0, 3); + room_changed |= btn("ROOM HEIGHT:", 10, 55, room::editor::refHeight(), 0, 3); + + draw::print("DOORS:", 10, 80, 15, 0); + room_changed |= btn_small(32, 80, room::editor::refDoor(XN), -1, 5); + room_changed |= btn_small(49, 80, room::editor::refDoor(YP), -1, 5); + room_changed |= btn_small(66, 80, room::editor::refDoor(XP), -1, 5); + room_changed |= btn_small(83, 80, room::editor::refDoor(YN), -1, 5); + + room_changed |= btn("COLOR:", 10, 140, room::editor::refColor(), 5, 11); + room_changed |= btn("FLOOR:", 10, 155, room::editor::refFloorTex(), 0, 5); + room_changed |= btn("WALLS:", 10, 170, room::editor::refWallTex(), 0, 5); + room_changed |= btn("DOORS:", 10, 185, room::editor::refDoorTex(), 0, 4); + room_changed |= btn("WDOORS:", 10, 200, room::editor::refWallDoorTex(), 0, 5); + + if (room_changed) room::update(); + break; + + case SECTION_ACTOR: + act = actor::getSelected(); + if (act) + { + //draw::setViewport(420, 90, 100, 150); + + 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); } -*/ - act = actor::getSelected(); - if (act) - { - draw::setViewport(420, 90, 100, 150); + //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); - 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); - } - //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); + 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); - 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); + 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); - 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); + 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); - 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); + 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); + 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); - 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); - 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); + 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"}); + 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"}); - 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"}); - 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"}); + //draw::print("ANIM SPEED:", 2, 156, 15, 0); + ui::label("ANMSPED", 2, 116, 32, 11); + btn_small(81, 116, act->anim_wait, 0, 10); - //draw::print("ANIM SPEED:", 2, 156, 15, 0); - ui::label("ANMSPED", 2, 116, 32, 11); - 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); - 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); - - 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); + 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); + } + break; +}; /* break; @@ -538,7 +518,6 @@ bool game::loop() } break; */ - } draw::render();