mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
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:
parent
544befe162
commit
bb37600c87
|
|
@ -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(¤t, 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);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue