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