- Treballant en poder editar guay les propietats

This commit is contained in:
2024-06-10 14:14:13 +02:00
parent edc88eec89
commit 1af08ecf3c
3 changed files with 26 additions and 10 deletions

View File

@@ -110,7 +110,7 @@ int sx=1, sy=0;
if (sign) draw::draw(x,y,5,7,50,120);
}
void btn(const char* label, const int x, const int y, int &var, int min, int max)
const bool btn(const char* label, const int x, const int y, int &var, int min, int max)
{
char buffer[100];
int result=0;
@@ -119,11 +119,12 @@ void btn(const char* label, const int x, const int y, int &var, int min, int max
if (result)
{
var=SDL_max(min, SDL_min(max, var-(result-2)));
room::editor::setWidth(var);
return true;
}
return false;
}
void btn_small(const int x, const int y, int &var, int min, int max, bool restrt=false)
const bool btn_small(const int x, const int y, int &var, int min, int max)
{
char buffer[100];
int result=0;
@@ -131,8 +132,9 @@ void btn_small(const int x, const int y, int &var, int min, int max, bool restrt
if (result)
{
var=SDL_max(min, SDL_min(max, var+result));
if (restrt) restart();
return true;
}
return false;
}
void btn_check(const int x, const int y, const char* label, uint8_t &flags, const uint8_t value)
@@ -312,25 +314,28 @@ bool game::loop()
switch (section) {
case 0:
*/
bool change = false;
draw::setViewport(0,0,100,240);
draw::color(WHITE);
draw::fillrect(0, 0, 100, 240);
btn("ROOM WIDTH:", 10, 40, room_w, 0, 3);
btn("ROOM HEIGHT:", 10, 55, room_h, 0, 3);
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);
btn_small(32, 80, room_xn, -1, 5, true);
btn_small(49, 80, room_yp, -1, 5, true);
btn_small(66, 80, room_xp, -1, 5, true);
btn_small(83, 80, room_yn, -1, 5, true);
btn_small(32, 80, room::editor::refDoor(XN), -1, 5);
btn_small(49, 80, room_yp, -1, 5);
btn_small(66, 80, room_xp, -1, 5);
btn_small(83, 80, room_yn, -1, 5);
btn("COLOR:", 10, 140, room_color, 5, 11);
btn("FLOOR:", 10, 155, room_floor, 0, 5);
btn("WALLS:", 10, 170, room_walls, 0, 5);
btn("DOORS:", 10, 185, room_doors, 0, 4);
btn("WDOORS:", 10, 200, room_walldoors, 0, 5);
if (change) room::update();
/*
break;
case 1: