mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-05-28 05:34:34 +00:00
Remove Win64LaunchOptions
This commit is contained in:
@@ -46,23 +46,11 @@ extern "C"
|
||||
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "legacy_stdio_definitions.lib")
|
||||
#endif
|
||||
|
||||
HINSTANCE hMyInst;
|
||||
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
char chGlobalText[256];
|
||||
uint16_t ui16GlobalText[256];
|
||||
|
||||
#define THEME_NAME "584111F70AAAAAAA"
|
||||
#define THEME_FILESIZE 2797568
|
||||
|
||||
//#define THREE_MB 3145728 // minimum save size (checking for this on a selected device)
|
||||
//#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device)
|
||||
//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device)
|
||||
#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device)
|
||||
|
||||
//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU
|
||||
#define NUM_PROFILE_VALUES 5
|
||||
#define NUM_PROFILE_SETTINGS 4
|
||||
@@ -78,13 +66,6 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
||||
0,0,0,0,0
|
||||
#endif
|
||||
};
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Time Since fAppTime is a float, we need to keep the quadword app time
|
||||
// as a LARGE_INTEGER so that we don't lose precision after running
|
||||
// for a long time.
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
BOOL g_bWidescreen = TRUE;
|
||||
|
||||
// Screen resolution — auto-detected from the monitor at startup.
|
||||
// The 3D world renders at native resolution; Flash UI is 16:9-fitted and centered
|
||||
@@ -115,19 +96,6 @@ struct Win64LaunchOptions
|
||||
bool fullscreen;
|
||||
};
|
||||
|
||||
static void CopyWideArgToAnsi(LPCWSTR source, char* dest, size_t destSize)
|
||||
{
|
||||
if (destSize == 0)
|
||||
return;
|
||||
|
||||
dest[0] = 0;
|
||||
if (source == nullptr)
|
||||
return;
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, source, -1, dest, static_cast<int>(destSize), nullptr, nullptr);
|
||||
dest[destSize - 1] = 0;
|
||||
}
|
||||
|
||||
// ---------- Persistent options (options.txt next to exe) ----------
|
||||
static void GetOptionsFilePath(char *out, size_t outSize)
|
||||
{
|
||||
@@ -172,76 +140,6 @@ static bool LoadFullscreenOption()
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
static void ApplyScreenMode(int screenMode)
|
||||
{
|
||||
switch (screenMode)
|
||||
{
|
||||
case 1:
|
||||
g_iScreenWidth = 1280;
|
||||
g_iScreenHeight = 720;
|
||||
break;
|
||||
case 2:
|
||||
g_iScreenWidth = 640;
|
||||
g_iScreenHeight = 480;
|
||||
break;
|
||||
case 3:
|
||||
g_iScreenWidth = 720;
|
||||
g_iScreenHeight = 408;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static Win64LaunchOptions ParseLaunchOptions()
|
||||
{
|
||||
Win64LaunchOptions options = {};
|
||||
options.screenMode = 0;
|
||||
|
||||
g_Win64MultiplayerJoin = false;
|
||||
g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT;
|
||||
|
||||
int argc = 0;
|
||||
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
if (argv == nullptr)
|
||||
return options;
|
||||
|
||||
if (argc > 1 && lstrlenW(argv[1]) == 1)
|
||||
{
|
||||
if (argv[1][0] >= L'1' && argv[1][0] <= L'3')
|
||||
options.screenMode = argv[1][0] - L'0';
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
if (_wcsicmp(argv[i], L"-name") == 0 && (i + 1) < argc)
|
||||
{
|
||||
CopyWideArgToAnsi(argv[++i], g_Win64Username, sizeof(g_Win64Username));
|
||||
}
|
||||
else if (_wcsicmp(argv[i], L"-ip") == 0 && (i + 1) < argc)
|
||||
{
|
||||
char ipBuf[256];
|
||||
CopyWideArgToAnsi(argv[++i], ipBuf, sizeof(ipBuf));
|
||||
strncpy_s(g_Win64MultiplayerIP, sizeof(g_Win64MultiplayerIP), ipBuf, _TRUNCATE);
|
||||
g_Win64MultiplayerJoin = true;
|
||||
}
|
||||
else if (_wcsicmp(argv[i], L"-port") == 0 && (i + 1) < argc)
|
||||
{
|
||||
wchar_t* endPtr = nullptr;
|
||||
const long port = wcstol(argv[++i], &endPtr, 10);
|
||||
if (endPtr != argv[i] && *endPtr == 0 && port > 0 && port <= 65535)
|
||||
{
|
||||
g_Win64MultiplayerPort = static_cast<int>(port);
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(argv[i], L"-fullscreen") == 0)
|
||||
options.fullscreen = true;
|
||||
}
|
||||
|
||||
LocalFree(argv);
|
||||
return options;
|
||||
}
|
||||
|
||||
void DefineActions(void)
|
||||
{
|
||||
// The app needs to define the actions required, and the possible mappings for these
|
||||
@@ -845,7 +743,7 @@ HRESULT InitDevice()
|
||||
sd.Width = width;
|
||||
sd.Height = height;
|
||||
sd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT;
|
||||
sd.SampleDesc.Count = 1;
|
||||
sd.SampleDesc.Quality = 0;
|
||||
sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
@@ -1023,7 +921,7 @@ static bool ResizeD3D(int newW, int newH)
|
||||
sd.Width = bbW;
|
||||
sd.Height = bbH;
|
||||
sd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT;
|
||||
sd.SampleDesc.Count = 1;
|
||||
sd.SampleDesc.Quality = 0;
|
||||
sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
@@ -1205,28 +1103,24 @@ postReset:
|
||||
void ToggleFullscreen()
|
||||
{
|
||||
const DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE);
|
||||
|
||||
if (!g_isFullscreen)
|
||||
{
|
||||
MONITORINFO mi = {};
|
||||
mi.cbSize = sizeof(mi);
|
||||
if (GetWindowPlacement(g_hWnd, &g_wpPrev) &&
|
||||
GetMonitorInfo(MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTOPRIMARY), &mi))
|
||||
if (GetWindowPlacement(g_hWnd, &g_wpPrev) && GetMonitorInfo(MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTOPRIMARY), &mi))
|
||||
{
|
||||
SetWindowLong(g_hWnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPos(g_hWnd, HWND_TOP,
|
||||
mi.rcMonitor.left, mi.rcMonitor.top,
|
||||
mi.rcMonitor.right - mi.rcMonitor.left,
|
||||
mi.rcMonitor.bottom - mi.rcMonitor.top,
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
SetWindowPos(g_hWnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowLong(g_hWnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPlacement(g_hWnd, &g_wpPrev);
|
||||
SetWindowPos(g_hWnd, nullptr, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
SetWindowPos(g_hWnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
|
||||
g_isFullscreen = !g_isFullscreen;
|
||||
SaveFullscreenOption(g_isFullscreen);
|
||||
|
||||
@@ -1239,14 +1133,42 @@ void ToggleFullscreen()
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CleanupDevice()
|
||||
{
|
||||
if( g_pImmediateContext ) g_pImmediateContext->ClearState();
|
||||
if (g_pImmediateContext)
|
||||
{
|
||||
g_pImmediateContext->ClearState();
|
||||
g_pImmediateContext->Release();
|
||||
g_pImmediateContext = nullptr;
|
||||
}
|
||||
|
||||
if( g_pDepthStencilView ) g_pDepthStencilView->Release();
|
||||
if( g_pDepthStencilBuffer ) g_pDepthStencilBuffer->Release();
|
||||
if( g_pRenderTargetView ) g_pRenderTargetView->Release();
|
||||
if( g_pSwapChain ) g_pSwapChain->Release();
|
||||
if( g_pImmediateContext ) g_pImmediateContext->Release();
|
||||
if( g_pd3dDevice ) g_pd3dDevice->Release();
|
||||
if (g_pDepthStencilView)
|
||||
{
|
||||
g_pDepthStencilView->Release();
|
||||
g_pDepthStencilView = nullptr;
|
||||
}
|
||||
|
||||
if (g_pDepthStencilBuffer)
|
||||
{
|
||||
g_pDepthStencilBuffer->Release();
|
||||
g_pDepthStencilBuffer = nullptr;
|
||||
}
|
||||
|
||||
if (g_pRenderTargetView)
|
||||
{
|
||||
g_pRenderTargetView->Release();
|
||||
g_pRenderTargetView = nullptr;
|
||||
}
|
||||
|
||||
if (g_pSwapChain)
|
||||
{
|
||||
g_pSwapChain->Release();
|
||||
g_pSwapChain = nullptr;
|
||||
}
|
||||
|
||||
if (g_pd3dDevice)
|
||||
{
|
||||
g_pd3dDevice->Release();
|
||||
g_pd3dDevice = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static Minecraft* InitialiseMinecraftRuntime()
|
||||
@@ -1368,10 +1290,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
// Load stuff from launch options, including username
|
||||
const Win64LaunchOptions launchOptions = ParseLaunchOptions();
|
||||
ApplyScreenMode(launchOptions.screenMode);
|
||||
|
||||
// Ensure uid.dat exists from startup (before any multiplayer/login path).
|
||||
Win64Xuid::ResolvePersistentXuid();
|
||||
|
||||
@@ -1468,7 +1386,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
|
||||
// Restore fullscreen state from previous session
|
||||
if (LoadFullscreenOption() && !g_isFullscreen || launchOptions.fullscreen)
|
||||
if (LoadFullscreenOption() && !g_isFullscreen)
|
||||
{
|
||||
ToggleFullscreen();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user