- [ONGOING] Treballant en que els camps d'edició funcionen millor
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
width: 2
|
width: 3
|
||||||
height: 2
|
height: 3
|
||||||
color: CYAN
|
color: CYAN
|
||||||
floor-texture: 0
|
floor-texture: 0
|
||||||
wall-texture: 0
|
wall-texture: 0
|
||||||
@@ -11,7 +11,7 @@ actor{
|
|||||||
bmp: altres.gif
|
bmp: altres.gif
|
||||||
bmp-rect: 160 0 30 48
|
bmp-rect: 160 0 30 48
|
||||||
bmp-offset: 0 48
|
bmp-offset: 0 48
|
||||||
pos: 8 8 0
|
pos: 0 0 0
|
||||||
size: 8 8 8
|
size: 8 8 16
|
||||||
movement: CW
|
movement: CW
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ actor{
|
|||||||
bmp: test.gif
|
bmp: test.gif
|
||||||
bmp-rect: 32 0 32 32
|
bmp-rect: 32 0 32 32
|
||||||
bmp-offset: 0 32
|
bmp-offset: 0 32
|
||||||
pos: 32 32 8
|
pos: 32 32 0
|
||||||
size: 8 8 8
|
size: 8 8 8
|
||||||
movement: CW
|
movement: CW
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
|
static bool select = false;
|
||||||
|
|
||||||
void label(const char *label, const int x, const int y, const int w, const int h, const int color)
|
void label(const char *label, const int x, const int y, const int w, const int h, const int color)
|
||||||
{
|
{
|
||||||
draw::color(color);
|
draw::color(color);
|
||||||
@@ -117,7 +119,7 @@ namespace ui
|
|||||||
|
|
||||||
char temp[10];
|
char temp[10];
|
||||||
|
|
||||||
const char *spin(const char *label, const int x, const int y, const int w, const int h)
|
const char *spin(const char *lbl, const int x, const int y, const int w, const int h)
|
||||||
{
|
{
|
||||||
const int mx = draw::getLocalX(input::mouseX());
|
const int mx = draw::getLocalX(input::mouseX());
|
||||||
const int my = draw::getLocalY(input::mouseY());
|
const int my = draw::getLocalY(input::mouseY());
|
||||||
@@ -125,6 +127,12 @@ namespace ui
|
|||||||
const bool inside = (mx>=x) && (mx<x+w) && (my>=y) && (my<y+h);
|
const bool inside = (mx>=x) && (mx<x+w) && (my>=y) && (my<y+h);
|
||||||
//const int txt_size = strlen(label)*4;
|
//const int txt_size = strlen(label)*4;
|
||||||
//const int txt_x = x+(w-txt_size)/2;
|
//const int txt_x = x+(w-txt_size)/2;
|
||||||
|
char label[100];
|
||||||
|
if (!select) {
|
||||||
|
label[0]='0'; label[1]='\0';
|
||||||
|
} else {
|
||||||
|
strcpy(label, lbl);
|
||||||
|
}
|
||||||
|
|
||||||
draw::color(LIGHT+WHITE);
|
draw::color(LIGHT+WHITE);
|
||||||
draw::fillrect(x, y, w, h);
|
draw::fillrect(x, y, w, h);
|
||||||
@@ -152,7 +160,7 @@ namespace ui
|
|||||||
}
|
}
|
||||||
const int wheel = input::mouseWheel();
|
const int wheel = input::mouseWheel();
|
||||||
if (wheel != 0) {
|
if (wheel != 0) {
|
||||||
const int value = SDL_atoi(label)+wheel*(input::keyDown(SDL_SCANCODE_LCTRL)?32:1);
|
const int value = SDL_atoi(lbl)+wheel*(input::keyDown(SDL_SCANCODE_LCTRL)?32:1);
|
||||||
SDL_itoa(value, temp, 10);
|
SDL_itoa(value, temp, 10);
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
@@ -183,4 +191,10 @@ namespace ui
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void selected(const bool value)
|
||||||
|
{
|
||||||
|
select = value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace ui
|
|||||||
const bool button(const char *label, const int x, const int y, const int w, const int h, const bool pressed=false);
|
const bool button(const char *label, const int x, const int y, const int w, const int h, const bool pressed=false);
|
||||||
const int check(const char *label, const int x, const int y, const int w, const int h, const bool checked);
|
const int check(const char *label, const int x, const int y, const int w, const int h, const bool checked);
|
||||||
const int combo(const char *label, const int x, const int y, const int w, const int h);
|
const int combo(const char *label, const int x, const int y, const int w, const int h);
|
||||||
const char *spin(const char *label, const int x, const int y, const int w, const int h);
|
const char *spin(const char *lbl, const int x, const int y, const int w, const int h);
|
||||||
const int textbox(const char *label, const int x, const int y, const int w, const int h);
|
const int textbox(const char *label, const int x, const int y, const int w, const int h);
|
||||||
|
|
||||||
|
void selected(const bool value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace modules
|
|||||||
std::vector<std::string> gifs;
|
std::vector<std::string> gifs;
|
||||||
int treeview_scroll = 0;
|
int treeview_scroll = 0;
|
||||||
|
|
||||||
|
int *current_field = nullptr;
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
actor::clear(true);
|
actor::clear(true);
|
||||||
@@ -61,11 +63,18 @@ namespace modules
|
|||||||
const bool btn_small(const int x, const int y, int &var, int min, int max)
|
const bool btn_small(const int x, const int y, int &var, int min, int max)
|
||||||
{
|
{
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
|
if (current_field == &var) {
|
||||||
|
ui::selected(false);
|
||||||
|
} else {
|
||||||
|
ui::selected(true);
|
||||||
|
}
|
||||||
const char *result=ui::spin(SDL_itoa(var, buffer, 10), x, y, 17, 11);
|
const char *result=ui::spin(SDL_itoa(var, buffer, 10), x, y, 17, 11);
|
||||||
|
ui::selected(false);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
const int value = SDL_atoi(result);
|
const int value = SDL_atoi(result);
|
||||||
var=SDL_max(min, SDL_min(max, value));
|
var=SDL_max(min, SDL_min(max, value));
|
||||||
|
current_field = &var;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user