- [NEW] F12 recarrega gràfics sense eixir

This commit is contained in:
2024-07-24 11:58:32 +02:00
parent 12674cc1a6
commit cd44dceb6b
3 changed files with 20 additions and 0 deletions

View File

@@ -255,6 +255,20 @@ namespace draw
managed[num_managed++] = surf;
}
void reloadSurface(surface *surf)
{
free(surf->pixels);
int size;
uint8_t *buffer = (uint8_t *)file::getFileBuffer(surf->filename, size);
surf->pixels = LoadGif(buffer, &surf->w, &surf->h);
free(buffer);
}
void reloadAll()
{
for (int i=0; i<num_managed; ++i) reloadSurface(managed[i]);
}
surface *getSurface(const std::string &filename)
{
for(int i=0; i<num_managed; ++i)

View File

@@ -55,6 +55,8 @@ namespace draw
/// @return un punter a una nova superficie
/// ATENCIÓ: EN THEPOOL AÇÒ VAL PER A LA CÀRREGA INCIAL DE TOTS ELS GIFs
void loadSurface(const std::string &filename);
void reloadSurface(surface *surf);
void reloadAll();
surface *getSurface(const std::string &filename);

View File

@@ -93,6 +93,10 @@ bool game::loop()
file::setConfigValue("fullscreen", fullscreen?"yes":"no");
}
if (input::keyPressed(SDL_SCANCODE_F12)) {
draw::reloadAll();
}
int option;
switch(current_module)
{