Save window position
This commit is contained in:
1 parent
1cf4d1ea85
commit
167f1a5ddd
4 files changed
+10
No files matched your search
@@ -324,6 +324,7 @@ Stores general game settings and configuration; beyond individual characters.
|
||||
| `color` | Red, green and blue (0-1) of the menu color. |
|
||||
| `character_color` | `1` to use the character's color while playing. |
|
||||
| `width`, `height` | Window size. |
|
||||
| `x`, `y` | Window position. |
|
||||
| `last_character` | The character being played at exit, which the game continues on start. |
|
||||
| `console` | `1` enables the developer console (the grave key). |
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ static void init()
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
game.window = SDL_CreateWindow(GAME_NAME, game.settings.width, game.settings.height,
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
|
||||
SDL_SetWindowPosition(game.window, game.settings.x, game.settings.y);
|
||||
game.context = game.window ? SDL_GL_CreateContext(game.window) : nullptr;
|
||||
if (game.context)
|
||||
game.renderer.init();
|
||||
@@ -201,7 +202,10 @@ static void update()
|
||||
SDL_SetWindowFullscreen(game.window, !(SDL_GetWindowFlags(game.window) & SDL_WINDOW_FULLSCREEN));
|
||||
ui.isFullscreen = SDL_GetWindowFlags(game.window) & SDL_WINDOW_FULLSCREEN;
|
||||
if (!ui.isFullscreen)
|
||||
{
|
||||
SDL_GetWindowSize(game.window, &game.settings.width, &game.settings.height);
|
||||
SDL_GetWindowPosition(game.window, &game.settings.x, &game.settings.y);
|
||||
}
|
||||
bool isCursorHidden = game.screen == SCREEN_PLAY && play.character->cursor && !console.isOpen;
|
||||
isCursorHidden ? SDL_HideCursor() : SDL_ShowCursor();
|
||||
}
|
||||
|
||||
@@ -135,6 +135,8 @@ template <class Visitor> void Settings::visit(Visitor&& visitor)
|
||||
visitor("mute", isMuted);
|
||||
visitor("volume", volume);
|
||||
visitor("width", width);
|
||||
visitor("x", x);
|
||||
visitor("y", y);
|
||||
}
|
||||
|
||||
void Settings::load()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include <SDL3/SDL_video.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -18,6 +19,8 @@ struct Settings
|
||||
int height = 900;
|
||||
int volume = 50;
|
||||
int width = 1600;
|
||||
int x = SDL_WINDOWPOS_CENTERED;
|
||||
int y = SDL_WINDOWPOS_CENTERED;
|
||||
Measurement measurement = MEASUREMENT_METRIC;
|
||||
bool isCharacterColor = true;
|
||||
bool isConsole = false;
|
||||
|
||||
Reference in new issue
Block a user