- Els camps numèrics de l'editor ara també es poden modificar escribint
This commit is contained in:
@@ -115,7 +115,9 @@ namespace ui
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int spin(const char *label, const int x, const int y, const int w, const int h)
|
char temp[10];
|
||||||
|
|
||||||
|
const char *spin(const char *label, 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());
|
||||||
@@ -134,14 +136,30 @@ namespace ui
|
|||||||
{
|
{
|
||||||
draw::color(PAPER);
|
draw::color(PAPER);
|
||||||
draw::rect(x+1, y+1, w-2, h-2);
|
draw::rect(x+1, y+1, w-2, h-2);
|
||||||
if (input::keyDown(SDL_SCANCODE_LCTRL))
|
const uint8_t key = input::getKeyPressed();
|
||||||
return input::mouseWheel()*32;
|
if (key==SDL_SCANCODE_BACKSPACE) {
|
||||||
else
|
strcpy(temp, label); const int size = strlen(label);
|
||||||
return input::mouseWheel();
|
temp[size-1] = '\0';
|
||||||
|
return temp;
|
||||||
|
} else if (key==SDL_SCANCODE_0) {
|
||||||
|
strcpy(temp, label); const int size = strlen(label);
|
||||||
|
temp[size] = '0'; temp[size+1] = '\0';
|
||||||
|
return temp;
|
||||||
|
} else if (key>=SDL_SCANCODE_1 && key<=SDL_SCANCODE_9) {
|
||||||
|
strcpy(temp, label); const int size = strlen(label);
|
||||||
|
temp[size] = key+19; temp[size+1] = '\0';
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
const int wheel = input::mouseWheel();
|
||||||
|
if (wheel != 0) {
|
||||||
|
const int value = SDL_atoi(label)+wheel*(input::keyDown(SDL_SCANCODE_LCTRL)?32:1);
|
||||||
|
SDL_itoa(value, temp, 10);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
//if (input::mouseClk(1)) return 1;
|
//if (input::mouseClk(1)) return 1;
|
||||||
//if (input::mouseClk(3)) return 3;
|
//if (input::mouseClk(3)) return 3;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ 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 int spin(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 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,11 +60,11 @@ 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];
|
||||||
int result=0;
|
const char *result=ui::spin(SDL_itoa(var, buffer, 10), x, y, 17, 11);
|
||||||
result=ui::spin(SDL_itoa(var, buffer, 10), x, y, 17, 11);
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
var=SDL_max(min, SDL_min(max, var+result));
|
const int value = SDL_atoi(result);
|
||||||
|
var=SDL_max(min, SDL_min(max, value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -73,12 +73,11 @@ namespace modules
|
|||||||
const bool btn_small(const int x, const int y, int &var, int min, int max, int width)
|
const bool btn_small(const int x, const int y, int &var, int min, int max, int width)
|
||||||
{
|
{
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
int result=0;
|
const char *result=ui::spin(SDL_itoa(var, buffer, 10), x, y, width, 11);
|
||||||
result=ui::spin(SDL_itoa(var, buffer, 10), x, y, width, 11);
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
var=SDL_max(min, SDL_min(max, var+result));
|
const int value = SDL_atoi(result);
|
||||||
return true;
|
var=SDL_max(min, SDL_min(max, value));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user