Apply resolution and fullscreen changes immediately.

This commit is contained in:
Steve 2018-12-17 18:04:23 +00:00
parent 975ece4796
commit 2981fde2ec
4 changed files with 14 additions and 2 deletions

View File

@ -25,8 +25,8 @@ extern void drawText(int x, int y, int size, int align, SDL_Color c, const char
extern void drawWidgets(char *groupName); extern void drawWidgets(char *groupName);
extern AtlasImage *getAtlasImage(char *filename); extern AtlasImage *getAtlasImage(char *filename);
extern char *getChallengeDescription(Challenge *c); extern char *getChallengeDescription(Challenge *c);
extern char *timeToString(long millis, int showHours);
extern void setAtlasColor(int r, int g, int b, int a); extern void setAtlasColor(int r, int g, int b, int a);
extern char *timeToString(long millis, int showHours);
extern App app; extern App app;
extern Battle battle; extern Battle battle;

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "starfield.h" #include "starfield.h"
Star stars[MAX_STARS]; static Star stars[MAX_STARS];
void initStars(void) void initStars(void)
{ {

View File

@ -162,6 +162,14 @@ static void changeWindowSize(char *value)
app.uiOffset.x = (app.winWidth / 2) - (UI_WIDTH / 2); app.uiOffset.x = (app.winWidth / 2) - (UI_WIDTH / 2);
app.uiOffset.y = (app.winHeight / 2) - (UI_HEIGHT / 2); app.uiOffset.y = (app.winHeight / 2) - (UI_HEIGHT / 2);
SDL_DestroyTexture(app.backBuffer);
app.backBuffer = SDL_CreateTexture(app.renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, app.winWidth, app.winHeight);
initGraphics();
initStars();
} }
static void changeSoundVolume(char *value) static void changeSoundVolume(char *value)
@ -181,6 +189,8 @@ static void changeMusicVolume(char *value)
static void changeFullscreen(char *value) static void changeFullscreen(char *value)
{ {
app.fullscreen = strcmp(value, "On") == 0; app.fullscreen = strcmp(value, "On") == 0;
SDL_SetWindowFullscreen(app.window, app.fullscreen? SDL_WINDOW_FULLSCREEN : 0);
} }
static void ok(void) static void ok(void)

View File

@ -30,6 +30,8 @@ extern void drawText(int x, int y, int size, int align, SDL_Color c, const char
extern void drawWidgets(char *groupName); extern void drawWidgets(char *groupName);
extern Widget *getWidget(const char *name, const char *group); extern Widget *getWidget(const char *name, const char *group);
extern void initControlsDisplay(void); extern void initControlsDisplay(void);
extern void initGraphics(void);
extern void initStars(void);
extern void saveConfig(void); extern void saveConfig(void);
extern void selectWidget(const char *name, const char *group); extern void selectWidget(const char *name, const char *group);
extern void setWidgetOption(const char *name, const char *group, const char *value); extern void setWidgetOption(const char *name, const char *group, const char *value);