fix: game startup not checking fullscren values correct (#122)

* fix outdated fullscreenload & added a bool to check at startupfullscreen

* fix outdated methods & add back accidental deletes + debug things

* used old vars & added deleted showwindow & updatewindow

* added deleted few things
This commit is contained in:
Necmi 2026-05-26 19:00:08 +03:00 committed by GitHub
parent 544befe162
commit bb37600c87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -149,47 +149,57 @@ static void CopyWideArgToAnsi(LPCWSTR source, char* dest, size_t destSize)
dest[destSize - 1] = 0; dest[destSize - 1] = 0;
} }
// ---------- Persistent options (options.txt next to exe) ---------- // ---------- Persistent options (options.dat next to exe) ----------
static void GetOptionsFilePath(char *out, size_t outSize) static void GetOptionsFilePath(char *out, DWORD outSize)
{ {
GetModuleFileNameA(nullptr, out, static_cast<DWORD>(outSize)); GetModuleFileNameA(nullptr, out, outSize);
char *p = strrchr(out, '\\'); char *p = strrchr(out, '\\');
if (p) *(p + 1) = '\0'; if (p) *(p + 1) = '\0';
strncat_s(out, outSize, "options.txt", _TRUNCATE); strncat_s(out, outSize, "settings.dat", _TRUNCATE);
} }
static void SaveFullscreenOption(bool fullscreen) static void SaveFullscreenOption(bool fullscreen)
{ {
char path[MAX_PATH]; GAME_SETTINGS settings = {};
GetOptionsFilePath(path, sizeof(path));
FILE *f = nullptr; char path[MAX_PATH] = {};
if (fopen_s(&f, path, "w") == 0 && f) GetOptionsFilePath(path, MAX_PATH);
{ FILE *f = nullptr;
fprintf(f, "fullscreen=%d\n", fullscreen ? 1 : 0); if (fopen_s(&f, path, "rb") == 0 && f)
fclose(f); {
} fread(&settings, sizeof(GAME_SETTINGS), 1, f);
fclose(f);
}
if (fullscreen)
settings.uiBitmaskValues |= (1UL << 25);
else
settings.uiBitmaskValues &= ~(1UL << 25);
if (fopen_s(&f, path, "wb") == 0 && f)
{
fwrite(&settings, sizeof(GAME_SETTINGS), 1, f);
fclose(f);
}
} }
static bool LoadFullscreenOption() static bool LoadFullscreenOption()
{ {
char path[MAX_PATH]; char path[MAX_PATH] = {};
GetOptionsFilePath(path, sizeof(path)); GetOptionsFilePath(path, sizeof(path));
FILE *f = nullptr;
if (fopen_s(&f, path, "r") == 0 && f) FILE *f = nullptr;
{ if (fopen_s(&f, path, "rb") != 0 || !f)
char line[256]; return false;
while (fgets(line, sizeof(line), f))
{ GAME_SETTINGS current = {};
int val = 0; bool ok = (fread(&current, sizeof(GAME_SETTINGS), 1, f) == 1);
if (sscanf_s(line, "fullscreen=%d", &val) == 1) fclose(f);
{
fclose(f); if (!ok)
return val != 0; return false;
}
} return (current.uiBitmaskValues & (1UL << 25)) != 0;
fclose(f);
}
return false;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -824,7 +834,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
@ -1695,11 +1705,12 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
CleanupDevice(); CleanupDevice();
return 0; return 0;
} }
// Restore fullscreen state from previous session. Route through the // Restore fullscreen state from previous session. Route through the
// deferred exclusive fullscreen path so the main loop applies it on the // deferred exclusive fullscreen path so the main loop applies it on the
// first tick (safer than transitioning during init). // first tick (safer than transitioning during init).
if ((LoadFullscreenOption() && !g_isFullscreen) || launchOptions.fullscreen)
bool FullScreenEnabled = LoadFullscreenOption();
if (FullScreenEnabled && !g_isFullscreen)
{ {
g_bPendingExclusiveFullscreen = true; g_bPendingExclusiveFullscreen = true;
g_bPendingExclusiveFullscreenValue = true; g_bPendingExclusiveFullscreenValue = true;
@ -1764,7 +1775,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
return 1; return 1;
} }
g_bResizeReady = true; g_bResizeReady = true;
//app.TemporaryCreateGameStart(); //app.TemporaryCreateGameStart();
//Sleep(10000); //Sleep(10000);