mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-07-10 22:28:52 +00:00
Add RmlUi: SettingsUIMenu. And the other menus that already use RmlUi have been cleaned up.
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
// Non-RmlUi includes that depend on Windows macros
|
||||
#include "UI.h"
|
||||
#include "../../MinecraftServer.h"
|
||||
#include "../../MultiPlayerLocalPlayer.h"
|
||||
|
||||
// RmlUi includes (Windows macros temporarily suppressed)
|
||||
#pragma push_macro("byte")
|
||||
#pragma push_macro("GetNextSibling")
|
||||
#pragma push_macro("GetFirstChild")
|
||||
@@ -22,9 +20,7 @@
|
||||
#pragma pop_macro("byte")
|
||||
|
||||
UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLayer)
|
||||
: UIScene(iPad, parentLayer)
|
||||
, m_document(nullptr)
|
||||
, m_bIgnoreInput(false)
|
||||
: UIScene_RmlBase(iPad, parentLayer)
|
||||
{
|
||||
Rml::Context* ctx = RmlManager::Get().GetContext();
|
||||
if (!ctx)
|
||||
@@ -40,11 +36,8 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLa
|
||||
m_document->Show();
|
||||
app.DebugPrintf("[RmlPauseMenu] Document shown, visible=%d, context docs=%d\n",
|
||||
m_document->IsVisible(), ctx->GetNumDocuments());
|
||||
m_document->GetElementById("resume")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("help_options")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("achievements")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("save_game")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_game")->AddEventListener(Rml::EventId::Click, this);
|
||||
|
||||
RegisterEvents({ "resume", "help_options", "achievements", "save_game", "exit_game" });
|
||||
m_document->GetElementById("resume")->Focus();
|
||||
}
|
||||
else
|
||||
@@ -67,13 +60,8 @@ UIScene_PauseMenu::~UIScene_PauseMenu()
|
||||
{
|
||||
if (m_document)
|
||||
{
|
||||
m_document->GetElementById("resume")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("help_options")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("achievements")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("save_game")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_game")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
UnregisterEvents({ "resume", "help_options", "achievements", "save_game", "exit_game" });
|
||||
m_document->Close();
|
||||
m_document = nullptr;
|
||||
}
|
||||
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, false);
|
||||
@@ -81,74 +69,6 @@ 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)
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// 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)
|
||||
@@ -164,9 +84,6 @@ void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, bool pressed
|
||||
if (!ctx)
|
||||
return;
|
||||
|
||||
// Translate game actions to RmlUi key events.
|
||||
// Mouse clicks are forwarded in tick() via ProcessMouseButtonDown/Up,
|
||||
// so here we only handle keyboard-originated actions.
|
||||
if (!pressed)
|
||||
return;
|
||||
|
||||
@@ -179,8 +96,6 @@ void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, bool pressed
|
||||
ctx->ProcessKeyDown(Rml::Input::KI_DOWN, 0);
|
||||
break;
|
||||
case ACTION_MENU_OK:
|
||||
// Only forward as keyboard Enter if actually coming from keyboard,
|
||||
// not from mouse click (mouse is handled in tick()).
|
||||
if (g_KBMInput.IsKeyPressed(VK_RETURN))
|
||||
ctx->ProcessKeyDown(Rml::Input::KI_RETURN, 0);
|
||||
break;
|
||||
@@ -253,11 +168,9 @@ void UIScene_PauseMenu::OnSaveGame()
|
||||
if (m_iPad != ProfileManager.GetPrimaryPad())
|
||||
return;
|
||||
|
||||
// Does the save exist?
|
||||
bool bSaveExists;
|
||||
StorageManager.DoesSaveExist(&bSaveExists);
|
||||
|
||||
// We need to ask if they are sure they want to overwrite the existing game
|
||||
if (bSaveExists)
|
||||
{
|
||||
UINT uiIDA[2];
|
||||
@@ -267,7 +180,6 @@ void UIScene_PauseMenu::OnSaveGame()
|
||||
}
|
||||
else
|
||||
{
|
||||
// Flag a app action of save game
|
||||
app.SetAction(m_iPad, eAppAction_SaveGame);
|
||||
}
|
||||
}
|
||||
@@ -278,7 +190,6 @@ void UIScene_PauseMenu::OnExitGame()
|
||||
|
||||
UINT uiIDA[3];
|
||||
|
||||
// Is it the primary player exiting?
|
||||
if (m_iPad == ProfileManager.GetPrimaryPad())
|
||||
{
|
||||
int playTime = -1;
|
||||
@@ -313,7 +224,7 @@ void UIScene_PauseMenu::OnExitGame()
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Non-primary pad: exit directly without dialog
|
||||
else
|
||||
{
|
||||
int playTime = -1;
|
||||
if (pMinecraft->localplayers[m_iPad] != NULL)
|
||||
@@ -325,4 +236,4 @@ void UIScene_PauseMenu::OnExitGame()
|
||||
app.SetAction(m_iPad, eAppAction_ExitPlayer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user