git repos / saland

commit fbc7ed16

Poul Sander · 2018-12-28 16:25
fbc7ed16a3f28eaed96d36f4cfac226b47e0f3bb patch · browse files
parent e2fac1ee209feb6b6130db51ed34df9e24008f8b

Add switch fullscreen button. Going fullscreen -> Windows still has some issues

Changed files

M src/MenuSystem.cpp before
M src/saland.cpp before
diff --git a/src/MenuSystem.cpp b/src/MenuSystem.cpp index 6504bd1..5bec2d5 100644 --- a/src/MenuSystem.cpp +++ b/src/MenuSystem.cpp
@@ -86,7 +86,7 @@ void Button::doAction() {
action();
return;
}
- std::cerr << "Warning: button \"" << label << "\" has no action assigned!";
+ std::cerr << "Warning: button \"" << label << "\" has no action assigned!\n";
}
void Button::setPopOnRun(bool popOnRun) {
diff --git a/src/saland.cpp b/src/saland.cpp index e182c41..b1575aa 100644 --- a/src/saland.cpp +++ b/src/saland.cpp
@@ -156,6 +156,11 @@ void RunGameState(sago::GameStateInterface& state ) {
done = true;
}
+ if (event.type == SDL_WINDOWEVENT_RESIZED) {
+ std::cout << event.window.data1 << ", " << event.window.data2 << "\n";
+ SDL_GetRendererOutputSize(globalData.screen, &globalData.xsize, &globalData.ysize);
+ }
+
if (event.type == SDL_KEYDOWN) {
if (!globalData.resetVideo && event.key.keysym.sym == SDLK_RETURN && event.key.keysym.mod & KMOD_LALT) {
globalData.fullscreen = !globalData.fullscreen;
@@ -201,6 +206,20 @@ void ResetFullscreen() {
SDL_GetRendererOutputSize(globalData.screen, &globalData.xsize, &globalData.ysize);
}
+void toggleFullscreen() {
+ globalData.fullscreen = !globalData.fullscreen;
+ ResetFullscreen();
+}
+
+void runMenuOptions() {
+ Menu m(globalData.screen, true);
+ Button bFullscreen;
+ bFullscreen.setLabel("Fullscreen");
+ bFullscreen.setAction(toggleFullscreen);
+ m.addButton(&bFullscreen);
+ RunGameState(m);
+}
+
void runGame() {
int posX = 100, posY = 100, width = 1024, height = 768;
SDL_Init(SDL_INIT_VIDEO);
@@ -227,6 +246,10 @@ void runGame() {
bStart.setLabel("Start");
bStart.setAction(startWorld);
m.addButton(&bStart);
+ Button bOptions;
+ bOptions.setLabel("Options");
+ bOptions.setAction(runMenuOptions);
+ m.addButton(&bOptions);
RunGameState(m);
SDL_DestroyRenderer(globalData.screen);