Fixing localization bugs, working with graphics settings

This commit is contained in:
Vladislav Khorev committed 2026-07-12 16:02:09 +03:00
1 parent d4365728fe
commit 9d03b52c2a
14 files changed
+354 -44

No files matched your search

+33 -1
View File
@@ -235,6 +235,8 @@ int main(int argc, char *argv[]) {
try
{
SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "permonitorv2");
//SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, "1");
constexpr int CONST_WIDTH = ZL::Environment::CONST_DEFAULT_WIDTH;
constexpr int CONST_HEIGHT = ZL::Environment::CONST_DEFAULT_HEIGHT;
@@ -261,6 +263,9 @@ int main(int argc, char *argv[]) {
if (settingsRoot.contains("fullscreen")) {
ZL::Environment::isFullscreen = settingsRoot["fullscreen"].get<bool>();
}
if (settingsRoot.contains("isHighDPIEnabled")) {
ZL::Environment::isHighDPIEnabled = settingsRoot["isHighDPIEnabled"].get<bool>();
}
} catch (const std::exception& e) {
std::cerr << "[settings] Failed to parse settings.json: " << e.what() << std::endl;
}
@@ -272,10 +277,27 @@ int main(int argc, char *argv[]) {
windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
SDL_DisplayMode dm;
if (SDL_GetCurrentDisplayMode(0, &dm) == 0) {
std::cout << "Desktop resolution: " << dm.w << "x" << dm.h << " @ " << dm.refresh_rate << "Hz\n";
}
else {
SDL_Log("SDL_GetCurrentDisplayMode failed: %s", SDL_GetError());
}
int windowWidth = ZL::Environment::width;
int windowHeight = ZL::Environment::height;
//In case if the game is launched on a small screen
if (dm.w <= 1280 && dm.h <= 720) {
windowWidth = round(dm.w / 1.5);
windowHeight = round(dm.h / 1.5);
}
ZL::Environment::window = SDL_CreateWindow(
"Shadow Over Bishkek",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
ZL::Environment::width, ZL::Environment::height,
windowWidth, windowHeight,
windowFlags
);
@@ -285,11 +307,21 @@ int main(int argc, char *argv[]) {
// On HiDPI displays the drawable (physical) size is larger than the
// logical window size. Use the drawable size so the GL framebuffer
// covers every physical pixel and the image stays sharp.
if (ZL::Environment::isHighDPIEnabled)
{
int drawW, drawH;
SDL_GL_GetDrawableSize(ZL::Environment::window, &drawW, &drawH);
ZL::Environment::width = drawW;
ZL::Environment::height = drawH;
std::cout << "HiDPI enabled, drawable size: " << drawW << "x" << drawH << std::endl;
}
else
{
int winW, winH;
SDL_GetWindowSize(ZL::Environment::window, &winW, &winH);
ZL::Environment::width = winW;
ZL::Environment::height = winH;
std::cout << "HiDPI disabled, window size: " << winW << "x" << winH << std::endl;
}
game.setup();