- Arreglat el problema
This commit is contained in:
@@ -27,8 +27,8 @@ namespace actor
|
||||
actor_t *create(std::string name, vec3_t p, vec3_t s, std::string bmp, SDL_Rect r, SDL_Point o)
|
||||
{
|
||||
actor_t *act = (actor_t*)malloc(sizeof(actor_t));
|
||||
act->name = std::string(name);
|
||||
act->bmp = std::string(bmp);
|
||||
strcpy(act->name, name.c_str());
|
||||
strcpy(act->bmp, bmp.c_str());
|
||||
act->pos = p;
|
||||
act->size = s;
|
||||
act->surface = draw::loadSurface(bmp.c_str());
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace actor
|
||||
{
|
||||
struct actor_t
|
||||
{
|
||||
std::string name;
|
||||
char name[16];
|
||||
draw::surface *surface;
|
||||
std::string bmp;
|
||||
char bmp[16];
|
||||
SDL_Rect bmp_rect;
|
||||
SDL_Point bmp_offset;
|
||||
|
||||
|
||||
@@ -64,6 +64,8 @@ void game::init()
|
||||
int buffer_len=255;
|
||||
char buffer[buffer_len];
|
||||
while(fgets(buffer, buffer_len, f)) {
|
||||
auto len = strlen(buffer);
|
||||
buffer[len-1]=0;
|
||||
gifs.push_back(std::string(buffer));
|
||||
}
|
||||
//actor::actor_t *hero = actor::create("HERO", {16,32,8}, {8,8,12}, "test.gif", {0,32,20,32}, {-6,38});
|
||||
@@ -168,22 +170,26 @@ void btn_opt(const char* label, const int x, const int y, uint8_t &var, std::vec
|
||||
}
|
||||
}
|
||||
|
||||
void btn_opt2(const char* label, const int x, const int y, std::string &var, std::vector<std::string> values)
|
||||
bool btn_opt2(const char* label, const int x, const int y, char *var, std::vector<std::string> values)
|
||||
{
|
||||
draw::print(label, x, y+3, 15, 0);
|
||||
int result = 0;
|
||||
int pos = 0;
|
||||
while (var != values[pos])
|
||||
std::string v = var;
|
||||
while (pos < values.size() && v != values[pos])
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
if (pos==values.size()) pos = 0;
|
||||
|
||||
result = ui::button(var.c_str(), x+32, y, 56, 11, TEAL, LIGHT+TEAL, LIGHT+PURPLE);
|
||||
result = ui::button(var, x+32, y, 56, 11, TEAL, LIGHT+TEAL, LIGHT+PURPLE);
|
||||
if (result)
|
||||
{
|
||||
pos++; if (pos==values.size()) pos=0;
|
||||
var = values[pos];
|
||||
strcpy(var,values[pos].c_str());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void btn_txt(const char* label, const int x, const int y, const char *var)
|
||||
@@ -267,8 +273,11 @@ bool game::loop()
|
||||
act = actor::getSelected();
|
||||
if (act)
|
||||
{
|
||||
btn_txt("NAME:", 330, 40, act->name.c_str());
|
||||
btn_opt2("BMP:", 330, 55, act->bmp, gifs);
|
||||
btn_txt("NAME:", 330, 40, act->name);
|
||||
if (btn_opt2("BMP:", 330, 55, act->bmp, gifs)) {
|
||||
draw::freeSurface(act->surface);
|
||||
act->surface = draw::loadSurface(act->bmp);
|
||||
}
|
||||
draw::print("RECT:", 330, 73, 15, 0);
|
||||
btn_small(352, 70, act->bmp_rect.x, 0, 512);
|
||||
btn_small(369, 70, act->bmp_rect.y, 0, 512);
|
||||
@@ -319,7 +328,7 @@ bool game::loop()
|
||||
} else if ((mx>=330) && (mx<394) && (my>=40+line*9) && (my<40+9+line*9) && btnDown) {
|
||||
actor::select(act);
|
||||
}
|
||||
draw::print(act->name.c_str(), 332, 42+line*9, WHITE, BLACK);
|
||||
draw::print(act->name, 332, 42+line*9, WHITE, BLACK);
|
||||
line++;
|
||||
}
|
||||
act = act->next;
|
||||
|
||||
Reference in New Issue
Block a user