- Treballant en poder editar guay les propietats
This commit is contained in:
@@ -110,7 +110,7 @@ int sx=1, sy=0;
|
|||||||
if (sign) draw::draw(x,y,5,7,50,120);
|
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];
|
char buffer[100];
|
||||||
int result=0;
|
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)
|
if (result)
|
||||||
{
|
{
|
||||||
var=SDL_max(min, SDL_min(max, var-(result-2)));
|
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];
|
char buffer[100];
|
||||||
int result=0;
|
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)
|
if (result)
|
||||||
{
|
{
|
||||||
var=SDL_max(min, SDL_min(max, var+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)
|
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) {
|
switch (section) {
|
||||||
case 0:
|
case 0:
|
||||||
*/
|
*/
|
||||||
|
bool change = false;
|
||||||
draw::setViewport(0,0,100,240);
|
draw::setViewport(0,0,100,240);
|
||||||
|
|
||||||
draw::color(WHITE);
|
draw::color(WHITE);
|
||||||
draw::fillrect(0, 0, 100, 240);
|
draw::fillrect(0, 0, 100, 240);
|
||||||
|
|
||||||
btn("ROOM WIDTH:", 10, 40, room_w, 0, 3);
|
change |= btn("ROOM WIDTH:", 10, 40, room::editor::refWidth(), 0, 3);
|
||||||
btn("ROOM HEIGHT:", 10, 55, room_h, 0, 3);
|
change |= btn("ROOM HEIGHT:", 10, 55, room::editor::refHeight(), 0, 3);
|
||||||
|
|
||||||
draw::print("DOORS:", 10, 80, 15, 0);
|
draw::print("DOORS:", 10, 80, 15, 0);
|
||||||
btn_small(32, 80, room_xn, -1, 5, true);
|
btn_small(32, 80, room::editor::refDoor(XN), -1, 5);
|
||||||
btn_small(49, 80, room_yp, -1, 5, true);
|
btn_small(49, 80, room_yp, -1, 5);
|
||||||
btn_small(66, 80, room_xp, -1, 5, true);
|
btn_small(66, 80, room_xp, -1, 5);
|
||||||
btn_small(83, 80, room_yn, -1, 5, true);
|
btn_small(83, 80, room_yn, -1, 5);
|
||||||
|
|
||||||
btn("COLOR:", 10, 140, room_color, 5, 11);
|
btn("COLOR:", 10, 140, room_color, 5, 11);
|
||||||
btn("FLOOR:", 10, 155, room_floor, 0, 5);
|
btn("FLOOR:", 10, 155, room_floor, 0, 5);
|
||||||
btn("WALLS:", 10, 170, room_walls, 0, 5);
|
btn("WALLS:", 10, 170, room_walls, 0, 5);
|
||||||
btn("DOORS:", 10, 185, room_doors, 0, 4);
|
btn("DOORS:", 10, 185, room_doors, 0, 4);
|
||||||
btn("WDOORS:", 10, 200, room_walldoors, 0, 5);
|
btn("WDOORS:", 10, 200, room_walldoors, 0, 5);
|
||||||
|
|
||||||
|
if (change) room::update();
|
||||||
/*
|
/*
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -337,6 +337,11 @@ namespace room
|
|||||||
|
|
||||||
namespace editor
|
namespace editor
|
||||||
{
|
{
|
||||||
|
int &refWidth() { return inner_w; }
|
||||||
|
int &refHeight() { return inner_h; }
|
||||||
|
|
||||||
|
uint8_t &refDoor(const int which) { return door_height[which]; }
|
||||||
|
|
||||||
void setWidth(const int value) { inner_w = value; update(); }
|
void setWidth(const int value) { inner_w = value; update(); }
|
||||||
void setHeight(const int value) { inner_h = value; update(); }
|
void setHeight(const int value) { inner_h = value; update(); }
|
||||||
void setDoor(const int which, const int value) { door_height[which] = value; update(); }
|
void setDoor(const int which, const int value) { door_height[which] = value; update(); }
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace room
|
|||||||
void init();
|
void init();
|
||||||
void load(const int room);
|
void load(const int room);
|
||||||
//void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn, uint8_t col, uint8_t floor, uint8_t walls, uint8_t door, uint8_t doorwall);
|
//void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn, uint8_t col, uint8_t floor, uint8_t walls, uint8_t door, uint8_t doorwall);
|
||||||
|
void update();
|
||||||
void draw();
|
void draw();
|
||||||
void draw2();
|
void draw2();
|
||||||
|
|
||||||
@@ -31,6 +32,11 @@ namespace room
|
|||||||
|
|
||||||
namespace editor
|
namespace editor
|
||||||
{
|
{
|
||||||
|
int &refWidth();
|
||||||
|
int &refHeight();
|
||||||
|
|
||||||
|
uint8_t &refDoor(const int which);
|
||||||
|
|
||||||
void setWidth(const int value);
|
void setWidth(const int value);
|
||||||
void setHeight(const int value);
|
void setHeight(const int value);
|
||||||
void setDoor(const int which, const int value);
|
void setDoor(const int which, const int value);
|
||||||
|
|||||||
Reference in New Issue
Block a user