diff --git a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp index d01a344d..92630746 100644 --- a/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LoadCreateJoinMenu.cpp @@ -878,7 +878,31 @@ void UIScene_LoadCreateJoinMenu::UpdateGamesListCallback(LPVOID pParam) void UIScene_LoadCreateJoinMenu::tick() { - UIScene_RmlBase::tick(); + UIScene::tick(); + + m_hasTickedOnce = true; + + // Forward mouse/input to RmlUi context + Rml::Context* rmlCtx = RmlManager::Get().GetContext(); + if (rmlCtx && bHasFocus) + { + rmlCtx->ProcessMouseMove(g_KBMInput.GetMouseX(), g_KBMInput.GetMouseY(), 0); + + if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)) + rmlCtx->ProcessMouseButtonDown(0, 0); + if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) + rmlCtx->ProcessMouseButtonUp(0, 0); + if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT)) + rmlCtx->ProcessMouseButtonDown(1, 0); + if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_RIGHT)) + rmlCtx->ProcessMouseButtonUp(1, 0); + + int wheelDelta = g_KBMInput.GetMouseWheel(); + if (wheelDelta != 0) + rmlCtx->ProcessMouseWheel(wheelDelta / -120, 0); + + rmlCtx->Update(); + } if (m_bExitScene) if (!m_bRetrievingSaveThumbnails) diff --git a/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp b/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp index 4fb727e5..5b11b0df 100644 --- a/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp +++ b/Minecraft.Client/Common/UI/UIScene_MessageBox.cpp @@ -115,6 +115,64 @@ UIScene_MessageBox::~UIScene_MessageBox() m_parentLayer->removeComponent(eUIComponent_MenuBackground); } +void UIScene_MessageBox::gainFocus() +{ + if (!bHasFocus && stealsFocus()) + { + bHasFocus = true; + updateTooltips(); + updateComponents(); + handleGainFocus(m_bFocussedOnce); + if (bHasFocus) + m_bFocussedOnce = true; + + if (m_document) + m_document->Show(); + } +} + +void UIScene_MessageBox::handleLoseFocus() +{ + if (m_document) + m_document->Hide(); +} + +void UIScene_MessageBox::reloadMovie(bool force) +{ +} + +void UIScene_MessageBox::tick() +{ + m_hasTickedOnce = true; + + UIScene::tick(); + + Rml::Context* ctx = RmlManager::Get().GetContext(); + if (!ctx || !bHasFocus) + return; + + ctx->ProcessMouseMove(g_KBMInput.GetMouseX(), g_KBMInput.GetMouseY(), 0); + + if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)) + ctx->ProcessMouseButtonDown(0, 0); + if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) + ctx->ProcessMouseButtonUp(0, 0); + if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT)) + ctx->ProcessMouseButtonDown(1, 0); + if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_RIGHT)) + ctx->ProcessMouseButtonUp(1, 0); + + int wheelDelta = g_KBMInput.GetMouseWheel(); + if (wheelDelta != 0) + ctx->ProcessMouseWheel(wheelDelta / -120, 0); + + ctx->Update(); +} + +void UIScene_MessageBox::render(S32 width, S32 height, C4JRender::eViewportType viewport) +{ +} + void UIScene_MessageBox::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) { Rml::Context* ctx = RmlManager::Get().GetContext(); diff --git a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp index 386131af..9f9ff6f0 100644 --- a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp @@ -69,6 +69,91 @@ UIScene_PauseMenu::~UIScene_PauseMenu() m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false); } +void UIScene_PauseMenu::gainFocus() +{ + if (!bHasFocus && stealsFocus()) + { + bHasFocus = true; + updateTooltips(); + updateComponents(); + + if (!m_bFocussedOnce) + // No Iggy set-focus call needed for RmlUi scene + + handleGainFocus(m_bFocussedOnce); + + if (bHasFocus) + m_bFocussedOnce = true; + + if (m_document) + m_document->Show(); + } +} + +void UIScene_PauseMenu::handleLoseFocus() +{ + if (m_document) + m_document->Hide(); +} + +void UIScene_PauseMenu::reloadMovie(bool force) +{ +} + +//GabsPuN: When Iggy is completely replaced, some functions should be moved to UIScene.cpp. +//This way, the tick() function won't be repeated in every UIScene_ cpp file. +//Also, since iggy no longer exists, we can take liberties with optimization or code +//that is easier to work with. +void UIScene_PauseMenu::tick() +{ + // Signal the base class that we've ticked once, so it sets m_bCanHandleInput + // (the Iggy while-loop that normally sets this never runs without a loaded SWF) + m_hasTickedOnce = true; + + UIScene::tick(); + + Rml::Context* ctx = RmlManager::Get().GetContext(); + if (!ctx || !bHasFocus) + return; + +//GabsPuN: Once the above comment is made, we can do something like this to increase performance. +/* + int currentX = g_KBMInput.GetMouseX(); + int currentY = g_KBMInput.GetMouseY(); + + if (currentX != m_lastMouseX || currentY != m_lastMouseY) + { + ctx->ProcessMouseMove(currentX, currentY, 0); + m_lastMouseX = currentX; + m_lastMouseY = currentY; + } +*/ + + // Forward mouse position (for hover effects and correct click targeting) + ctx->ProcessMouseMove(g_KBMInput.GetMouseX(), g_KBMInput.GetMouseY(), 0); + + // Forward mouse button presses/releases + if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT)) + ctx->ProcessMouseButtonDown(0, 0); + if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) + ctx->ProcessMouseButtonUp(0, 0); + if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT)) + ctx->ProcessMouseButtonDown(1, 0); + if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_RIGHT)) + ctx->ProcessMouseButtonUp(1, 0); + + // Forward scroll wheel + int wheelDelta = g_KBMInput.GetMouseWheel(); + if (wheelDelta != 0) + ctx->ProcessMouseWheel(wheelDelta / -120, 0); + + ctx->Update(); +} + +void UIScene_PauseMenu::render(S32 width, S32 height, C4JRender::eViewportType viewport) +{ +} + void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) { if (m_bIgnoreInput) @@ -91,23 +176,27 @@ void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, bool pressed { case ACTION_MENU_UP: ctx->ProcessKeyDown(Rml::Input::KI_UP, 0); + handled = true; break; case ACTION_MENU_DOWN: ctx->ProcessKeyDown(Rml::Input::KI_DOWN, 0); + handled = true; break; case ACTION_MENU_OK: if (g_KBMInput.IsKeyPressed(VK_RETURN)) + { ctx->ProcessKeyDown(Rml::Input::KI_RETURN, 0); + handled = true; + } break; case ACTION_MENU_CANCEL: case ACTION_MENU_PAUSEMENU: navigateBack(); + handled = true; break; default: break; } - - handled = true; } void UIScene_PauseMenu::ProcessEvent(Rml::Event& event) diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp index e2997753..126a8507 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp @@ -75,24 +75,28 @@ void UIScene_SettingsMenu::handleInput(int iPad, int key, bool repeat, bool pres { case ACTION_MENU_UP: ctx->ProcessKeyDown(Rml::Input::KI_UP, 0); + handled = true; break; case ACTION_MENU_DOWN: ctx->ProcessKeyDown(Rml::Input::KI_DOWN, 0); + handled = true; break; case ACTION_MENU_OK: if (g_KBMInput.IsKeyPressed(VK_RETURN)) + { ctx->ProcessKeyDown(Rml::Input::KI_RETURN, 0); + handled = true; + } break; case ACTION_MENU_CANCEL: case ACTION_MENU_PAUSEMENU: - app.CheckGameSettingsChanged(true, iPad); - navigateBack(); + app.CheckGameSettingsChanged(true, iPad); + navigateBack(); + handled = true; break; default: break; } - - handled = true; } void UIScene_SettingsMenu::ProcessEvent(Rml::Event& event) diff --git a/Minecraft.Client/RmlManager.cpp b/Minecraft.Client/RmlManager.cpp index d0386b6e..f1cd4e99 100644 --- a/Minecraft.Client/RmlManager.cpp +++ b/Minecraft.Client/RmlManager.cpp @@ -17,6 +17,9 @@ extern ID3D11Device* g_pd3dDevice; extern ID3D11DeviceContext* g_pImmediateContext; extern ID3D11RenderTargetView* g_pRenderTargetView; +extern int g_iScreenWidth; +extern int g_iScreenHeight; + RmlManager& RmlManager::Get() { static RmlManager instance; @@ -26,8 +29,6 @@ RmlManager& RmlManager::Get() RmlManager::RmlManager() : m_initialised(false) , m_context(nullptr) - , m_viewport_width(0) - , m_viewport_height(0) { } @@ -36,7 +37,7 @@ RmlManager::~RmlManager() Shutdown(); } -bool RmlManager::Init(int viewport_width, int viewport_height) +bool RmlManager::Init() { if (m_initialised) return true; @@ -65,22 +66,13 @@ bool RmlManager::Init(int viewport_width, int viewport_height) return false; } -// GabsPuN: Hardcoded. Is this really needed? -/* - // Load default fonts - Rml::LoadFontFace("C:/Windows/Fonts/segoeui.ttf", false); - Rml::LoadFontFace("C:/Windows/Fonts/segoeuib.ttf", false); - Rml::LoadFontFace("C:/Windows/Fonts/segoeuii.ttf", false); - Rml::LoadFontFace("C:/Windows/Fonts/segoeuiz.ttf", false); -*/ - // Minecraft's UI fonts (from tryashtar/minecraft-ttf) if (!Rml::LoadFontFace(assetPath + "/fonts/Mojangles.ttf", "Minecraft Default", Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Normal, false)) app.DebugPrintf("[RmlManager] FAILED loading Mojangles.ttf\n"); if (!Rml::LoadFontFace(assetPath + "/fonts/MinecraftTen.ttf", "Minecraft Default", Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Bold, true)) app.DebugPrintf("[RmlManager] FAILED loading MinecraftTen.ttf\n"); - m_context = Rml::CreateContext("main", Rml::Vector2i(viewport_width, viewport_height)); + m_context = Rml::CreateContext("main", Rml::Vector2i(g_iScreenWidth, g_iScreenHeight)); if (!m_context) { app.DebugPrintf("[RmlManager] Failed to create RmlUi context\n"); @@ -88,17 +80,14 @@ bool RmlManager::Init(int viewport_width, int viewport_height) return false; } - app.DebugPrintf("[RmlManager] Context created (%dx%d)\n", viewport_width, viewport_height); + app.DebugPrintf("[RmlManager] Context created (%dx%d)\n", g_iScreenWidth, g_iScreenHeight); - m_viewport_width = viewport_width; - m_viewport_height = viewport_height; - - m_renderer->SetViewport(viewport_width, viewport_height); + m_renderer->SetViewport(g_iScreenWidth, g_iScreenHeight); m_initialised = true; - app.DebugPrintf("[RmlManager] Initialised (%dx%d)\n", viewport_width, viewport_height); + app.DebugPrintf("[RmlManager] Initialised (%dx%d)\n", g_iScreenWidth, g_iScreenHeight); - UpdateDpRatio(m_viewport_width, m_viewport_height); + UpdateDpRatio(); return true; } @@ -175,24 +164,22 @@ void RmlManager::OnResize(int width, int height) { if (!m_initialised || !m_context) return; - m_viewport_width = width; - m_viewport_height = height; + m_context->SetDimensions(Rml::Vector2i(width, height)); m_renderer->SetViewport(width, height); - UpdateDpRatio(width, height); } -void RmlManager::UpdateDpRatio(int viewport_width, int viewport_height) +void RmlManager::UpdateDpRatio() { if (!m_context) return; - float scale_x = static_cast(viewport_width) / 1920; - float scale_y = static_cast(viewport_height) / 1080; + float scale_x = static_cast(g_iScreenWidth) / 1920; + float scale_y = static_cast(g_iScreenHeight) / 1080; float base_ratio = (scale_x < scale_y) ? scale_x : scale_y; float auto_dp = base_ratio; - float viewport_cap = 0.88f * static_cast(viewport_height) / 850.0f; + float viewport_cap = 0.88f * static_cast(g_iScreenHeight) / 850.0f; if (auto_dp > viewport_cap) auto_dp = viewport_cap; diff --git a/Minecraft.Client/RmlManager.h b/Minecraft.Client/RmlManager.h index 15f590ab..e5898582 100644 --- a/Minecraft.Client/RmlManager.h +++ b/Minecraft.Client/RmlManager.h @@ -21,7 +21,7 @@ class RmlManager public: static RmlManager& Get(); - bool Init(int viewport_width, int viewport_height); + bool Init(); void Shutdown(); void Update(); @@ -31,7 +31,7 @@ public: RenderInterface_D3D11* GetRenderInterface() const { return m_renderer.get(); } void OnResize(int width, int height); - void UpdateDpRatio(int viewport_width, int viewport_height); + void UpdateDpRatio(); void OnLanguageChanged(); @@ -48,9 +48,6 @@ private: std::unique_ptr m_file_interface; Rml::Context* m_context; - - int m_viewport_width; - int m_viewport_height; }; #pragma pop_macro("GetFirstChild") diff --git a/Minecraft.Client/Windows64/Windows64_App.cpp b/Minecraft.Client/Windows64/Windows64_App.cpp index a03d1e86..fe1bc206 100644 --- a/Minecraft.Client/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Windows64/Windows64_App.cpp @@ -5,6 +5,11 @@ #include "..\..\Minecraft.Client\MinecraftServer.h" #include "..\..\Minecraft.World\LevelSettings.h" +#include +#pragma comment(lib, "DbgHelp.lib") +#include +#pragma comment(lib, "Shlwapi.lib") + CConsoleMinecraftApp app; CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() @@ -29,7 +34,6 @@ void CConsoleMinecraftApp::FatalLoadError() ExitGame(); } -/* LONG WINAPI CConsoleMinecraftApp::UnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionInfo) { SYSTEMTIME st; @@ -113,9 +117,7 @@ LONG WINAPI CConsoleMinecraftApp::UnhandledExceptionFilter(EXCEPTION_POINTERS* p sprintf_s(msg, "%s has run into a fatal error and must be closed.\n\nException: 0x%08X (%s)\nAddress: 0x%p\n\nA crash dump and log file have been written.", exeName, code, ExceptionName(code), addr); } else - { sprintf_s(msg, "%s has run into a fatal error and must be closed.\n\nNo exception information was available.\n", exeName); - } char title[1024]; sprintf_s(title, "%s - Fatal Error", exeName); @@ -123,7 +125,7 @@ LONG WINAPI CConsoleMinecraftApp::UnhandledExceptionFilter(EXCEPTION_POINTERS* p return EXCEPTION_EXECUTE_HANDLER; } -*/ + void CConsoleMinecraftApp::CaptureSaveThumbnail() { RenderManager.CaptureThumbnail(&m_ThumbnailBuffer); diff --git a/Minecraft.Client/Windows64/Windows64_App.h b/Minecraft.Client/Windows64/Windows64_App.h index 4e16a537..30da3c0f 100644 --- a/Minecraft.Client/Windows64/Windows64_App.h +++ b/Minecraft.Client/Windows64/Windows64_App.h @@ -12,7 +12,7 @@ public: virtual void StoreLaunchData(); virtual void ExitGame(); virtual void FatalLoadError(); -// static LONG WINAPI UnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionInfo); + static LONG WINAPI UnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionInfo); virtual void CaptureSaveThumbnail(); virtual void GetSaveThumbnail(PBYTE*,DWORD*); diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 0205b679..9c3d8c86 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -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(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) diff --git a/Minecraft.Client/Windows64/Windows64_UIController.cpp b/Minecraft.Client/Windows64/Windows64_UIController.cpp index 69441754..492a78e2 100644 --- a/Minecraft.Client/Windows64/Windows64_UIController.cpp +++ b/Minecraft.Client/Windows64/Windows64_UIController.cpp @@ -63,7 +63,7 @@ void ConsoleUIController::init(ID3D11Device *dev, ID3D11DeviceContext *ctx, ID3D postInit(); // Initialise RmlUi (menus) - if (!RmlManager::Get().Init(w, h)) + if (!RmlManager::Get().Init()) app.DebugPrintf("ConsoleUIController::init - RmlManager::Init failed\n"); #endif } diff --git a/Minecraft.Server/RmlManagerStub.cpp b/Minecraft.Server/RmlManagerStub.cpp index ce057d64..6f490baf 100644 --- a/Minecraft.Server/RmlManagerStub.cpp +++ b/Minecraft.Server/RmlManagerStub.cpp @@ -17,6 +17,6 @@ bool RmlManager::Init(int viewport_width, int viewport_height) void RmlManager::Shutdown() {} void RmlManager::Update() {} void RmlManager::Render() {} -void RmlManager::OnResize(int width, int height) {} -void RmlManager::UpdateDpRatio(int, int) {} +void RmlManager::OnResize() {} +void RmlManager::UpdateDpRatio() {} void RmlManager::OnLanguageChanged() {} \ No newline at end of file