mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-07-10 07:58:26 +00:00
Implement UnhandledExceptionFilter and revert "set intro scene background to white"
Also use g_iScreenWidth and g_iScreenHeight in RMLManager
This commit is contained in:
@@ -249,8 +249,6 @@ IDXGISwapChain* g_pSwapChain = nullptr;
|
||||
ID3D11RenderTargetView* g_pRenderTargetView = nullptr;
|
||||
ID3D11DepthStencilView* g_pDepthStencilView = nullptr;
|
||||
ID3D11Texture2D* g_pDepthStencilBuffer = nullptr;
|
||||
static const float kClearColorWhite[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static const float kClearColorBlack[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
//
|
||||
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
|
||||
@@ -363,9 +361,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
vk = (lParam & (1 << 24)) ? VK_RCONTROL : VK_LCONTROL;
|
||||
else if (vk == VK_MENU)
|
||||
vk = (lParam & (1 << 24)) ? VK_RMENU : VK_LMENU;
|
||||
|
||||
g_KBMInput.OnKeyDown(vk);
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
if (message == WM_SYSKEYDOWN)
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
{
|
||||
@@ -376,7 +380,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
vk = (lParam & (1 << 24)) ? VK_RCONTROL : VK_LCONTROL;
|
||||
else if (vk == VK_MENU)
|
||||
vk = (lParam & (1 << 24)) ? VK_RMENU : VK_LMENU;
|
||||
|
||||
g_KBMInput.OnKeyUp(vk);
|
||||
|
||||
if (message == WM_SYSKEYUP)
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -400,7 +409,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
g_KBMInput.OnMouseMove(LOWORD(lParam), HIWORD(lParam));
|
||||
g_KBMInput.OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
break;
|
||||
|
||||
case WM_MOUSEWHEEL:
|
||||
@@ -413,18 +422,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, nullptr, &dwSize, sizeof(RAWINPUTHEADER));
|
||||
if (dwSize > 0 && dwSize <= 256)
|
||||
{
|
||||
BYTE rawBuffer[256];
|
||||
alignas(RAWINPUT) BYTE rawBuffer[256];
|
||||
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) == dwSize)
|
||||
{
|
||||
const RAWINPUT* raw = (RAWINPUT*)rawBuffer;
|
||||
if (raw->header.dwType == RIM_TYPEMOUSE)
|
||||
{
|
||||
g_KBMInput.OnRawMouseDelta(raw->data.mouse.lLastX, raw->data.mouse.lLastY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_ENTERSIZEMOVE:
|
||||
g_bInSizeMove = true;
|
||||
break;
|
||||
@@ -442,6 +450,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
if (wParam == SIZE_MINIMIZED)
|
||||
{
|
||||
TrimMem();
|
||||
break;
|
||||
}
|
||||
|
||||
int newW = LOWORD(lParam);
|
||||
int newH = HIWORD(lParam);
|
||||
if (newW > 0 && newH > 0)
|
||||
@@ -459,8 +473,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
ResizeD3D(newW, newH);
|
||||
}
|
||||
}
|
||||
if (wParam == SIZE_MINIMIZED)
|
||||
TrimMem();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -621,6 +633,8 @@ HRESULT InitDevice()
|
||||
hr = dxgiFactory->CreateSwapChainForHwnd(g_pd3dDevice, g_hWnd, &sd, nullptr, nullptr, &pNewSwapChain);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
dxgiFactory->MakeWindowAssociation(g_hWnd, DXGI_MWA_NO_ALT_ENTER);
|
||||
|
||||
g_pSwapChain = pNewSwapChain;
|
||||
|
||||
// Create a render target view
|
||||
@@ -810,6 +824,8 @@ static bool ResizeD3D(int newW, int newH)
|
||||
goto postReset;
|
||||
}
|
||||
|
||||
dxgiFactory->MakeWindowAssociation(g_hWnd, DXGI_MWA_NO_ALT_ENTER);
|
||||
|
||||
// New swap chain created successfully — NOW destroy the old one.
|
||||
// The Renderer's internal RTV/SRV still reference the old backbuffer —
|
||||
// those COM objects become orphaned (tiny leak, harmless). We DON'T
|
||||
@@ -1114,33 +1130,30 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
// Init our exception handler
|
||||
//SetUnhandledExceptionFilter(CConsoleMinecraftApp::UnhandledExceptionFilter);
|
||||
SetUnhandledExceptionFilter(CConsoleMinecraftApp::UnhandledExceptionFilter);
|
||||
|
||||
// 4J-Win64: set CWD to exe dir so asset paths resolve correctly
|
||||
{
|
||||
char szExeDir[MAX_PATH] = {};
|
||||
GetModuleFileNameA(nullptr, szExeDir, MAX_PATH);
|
||||
char *pSlash = strrchr(szExeDir, '\\');
|
||||
if (pSlash) { *(pSlash + 1) = '\0'; SetCurrentDirectoryA(szExeDir); }
|
||||
}
|
||||
{
|
||||
char szExeDir[MAX_PATH] = {};
|
||||
GetModuleFileNameA(nullptr, szExeDir, MAX_PATH);
|
||||
char *pSlash = strrchr(szExeDir, '\\');
|
||||
if (pSlash)
|
||||
{
|
||||
*(pSlash + 1) = '\0';
|
||||
SetCurrentDirectoryA(szExeDir);
|
||||
}
|
||||
}
|
||||
|
||||
// Declare DPI awareness so GetSystemMetrics returns physical pixels
|
||||
SetProcessDPIAware();
|
||||
|
||||
// Use the native monitor resolution for the window and swap chain
|
||||
g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
// Load username from username.txt
|
||||
char exePath[MAX_PATH] = {};
|
||||
GetModuleFileNameA(nullptr, exePath, MAX_PATH);
|
||||
char *lastSlash = strrchr(exePath, '\\');
|
||||
if (lastSlash)
|
||||
{
|
||||
*(lastSlash + 1) = '\0';
|
||||
}
|
||||
|
||||
char filePath[MAX_PATH] = {};
|
||||
_snprintf_s(filePath, sizeof(filePath), _TRUNCATE, "%susername.txt", exePath);
|
||||
_snprintf_s(filePath, sizeof(filePath), _TRUNCATE, "%susername.txt", utils.GetExeDir().c_str());
|
||||
|
||||
FILE *f = nullptr;
|
||||
if (fopen_s(&f, filePath, "r") == 0 && f)
|
||||
@@ -1150,14 +1163,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
{
|
||||
int len = static_cast<int>(strlen(buf));
|
||||
while (len > 0 && (buf[len - 1] == '\n' || buf[len - 1] == '\r' || buf[len - 1] == ' '))
|
||||
{
|
||||
buf[--len] = '\0';
|
||||
}
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
strncpy_s(g_Win64Username, sizeof(g_Win64Username), buf, _TRUNCATE);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
@@ -1245,9 +1254,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
|
||||
// Perform application initialization:
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hMyInst=hInstance;
|
||||
|
||||
@@ -1362,18 +1369,11 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
// to avoid pegging the GPU at 100% presenting to a non-visible swap chain.
|
||||
if (IsIconic(g_hWnd))
|
||||
{
|
||||
Sleep(100);
|
||||
Sleep(16);
|
||||
continue;
|
||||
}
|
||||
|
||||
const float* clearColor = app.GetGameStarted() ? kClearColorBlack : kClearColorWhite;
|
||||
RenderManager.SetClearColour(clearColor);
|
||||
RenderManager.StartFrame();
|
||||
if (!app.GetGameStarted())
|
||||
{
|
||||
RenderManager.SetClearColour(kClearColorWhite); // set intro scene background to white
|
||||
RenderManager.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
#if 0
|
||||
if(pMinecraft->soundEngine->isStreamingWavebankReady() &&
|
||||
!pMinecraft->soundEngine->isPlayingStreamingGameMusic() &&
|
||||
@@ -1410,9 +1410,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
g_KBMInput.SetKBMActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_KBMInput.SetKBMActive(true);
|
||||
}
|
||||
|
||||
if (!g_KBMInput.IsMouseGrabbed())
|
||||
{
|
||||
@@ -1646,9 +1644,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
DisableFullscreen();
|
||||
|
||||
if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_FULLSCREEN))
|
||||
{
|
||||
app.SetGameSettings(primaryPad, eGameSetting_Fullscreen, fullscreen ? 0 : 1);
|
||||
}
|
||||
|
||||
// Open chat
|
||||
if (g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CHAT) && app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == nullptr)
|
||||
|
||||
Reference in New Issue
Block a user