- [FIX] l'animació no funcionava be

- Versió del Update dels actors per al Editor
- [NEW] gui::TextBox
- [NEW] input::getKeyPressed()
- Acabant el editor...
This commit is contained in:
2023-10-05 18:55:51 +02:00
parent a141d11760
commit 543c6a81e3
7 changed files with 80 additions and 10 deletions

View File

@@ -155,7 +155,7 @@ void btn_opt(const char* label, const int x, const int y, uint8_t &var, std::vec
{
draw::print(label, x, y+3, 15, 0);
int result = 0;
int pos = 0;
std::size_t pos = 0;
while (pos<values.size())
{
if (values[pos]==var) break;
@@ -174,7 +174,7 @@ bool btn_opt2(const char* label, const int x, const int y, char *var, std::vecto
{
draw::print(label, x, y+3, 15, 0);
int result = 0;
int pos = 0;
std::size_t pos = 0;
std::string v = var;
while (pos < values.size() && v != values[pos])
{
@@ -192,13 +192,30 @@ bool btn_opt2(const char* label, const int x, const int y, char *var, std::vecto
return false;
}
void btn_txt(const char* label, const int x, const int y, const char *var)
const uint8_t scancode_to_char(const uint8_t scancode)
{
if (scancode == SDL_SCANCODE_0) return '0';
if (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_9) return scancode+19;
if (scancode >= SDL_SCANCODE_A && scancode <= SDL_SCANCODE_Z) return scancode+61;
return 32;
}
void btn_txt(const char* label, const int x, const int y, char *var)
{
draw::print(label, x, y+3, 15, 0);
int result = 0;
result = ui::button(var, x+22, y, 66, 11, TEAL, LIGHT+TEAL, LIGHT+PURPLE);
result = ui::textbox(var, x+22, y, 66, 11, WHITE, LIGHT+WHITE);
if (result)
{
const int len = strlen(var);
if (result == SDL_SCANCODE_BACKSPACE) {
if (len>0) var[len-1] = 0;
} else {
if (len<15) {
var[len] = scancode_to_char(result);
var[len+1] = 0;
}
}
}
}
@@ -226,6 +243,8 @@ bool game::loop()
// WHILE EDITING...
editor_move_selected();
actor::updateEditor(actor::getFirst());
//actor::update(actor::getFirst());
actor::reorder();
@@ -244,7 +263,7 @@ bool game::loop()
if (section==0) {
draw::print("ROOM", 334, 13, YELLOW, LIGHT+BLACK);
if (ui::button("ACTORS", 365, 10, 30, 11, TEAL, LIGHT+TEAL, LIGHT+PURPLE)) section=1;
if (ui::button("ACTORS", 365, 10, 30, 11, TEAL, LIGHT+TEAL, LIGHT+PURPLE)) section=2;
} else {
if (ui::button("ROOM", 330, 10, 30, 11, TEAL, LIGHT+TEAL, LIGHT+PURPLE)) section=0;
draw::print("ACTORS", 369, 13, YELLOW, BLACK);
@@ -285,8 +304,8 @@ bool game::loop()
btn_small(403, 70, act->bmp_rect.h, 0, 512);
draw::print("OFFSET:", 330, 88, 15, 0);
btn_small(386, 85, act->bmp_offset.x, 0, 512);
btn_small(403, 85, act->bmp_offset.y, 0, 512);
btn_small(386, 85, act->bmp_offset.x, -32, 64);
btn_small(403, 85, act->bmp_offset.y, -32, 64);
draw::print("POS:", 330, 108, 15, 0);
btn_small(369, 105, act->pos.x, 0, 512);
@@ -309,6 +328,12 @@ bool game::loop()
btn_check(374, 165, "DEAD", act->flags, FLAG_DEADLY);
btn_check(396, 165, "GRAV", act->flags, FLAG_GRAVITY);
btn_opt("MOVEMNT:", 330, 180, 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:", 330, 195, act->anim_cycle, {0, 1}, {"0 1 0 2", "0 1 2 3"});
draw::print("ANIM SPEED:", 330, 213, 15, 0);
btn_small(403, 210, act->anim_wait, 0, 10);
break;
}
case 2:
@@ -325,8 +350,10 @@ bool game::loop()
if (act==actor::getSelected()) {
draw::color(TEAL);
draw::fillrect(330, 40+line*9, 63, 9);
} else if ((mx>=330) && (mx<394) && (my>=40+line*9) && (my<40+9+line*9) && btnDown) {
}
if ((mx>=330) && (mx<394) && (my>=40+line*9) && (my<40+9+line*9) && btnDown) {
actor::select(act);
section=1;
}
draw::print(act->name, 332, 42+line*9, WHITE, BLACK);
line++;