mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-07-11 00:19:57 +00:00
Add RmlUi: SettingsUIMenu. And the other menus that already use RmlUi have been cleaned up.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
// Non-RmlUi includes that depend on Windows macros
|
||||
#include "UI.h"
|
||||
#include "../../Minecraft.h"
|
||||
|
||||
// RmlUi includes (Windows macros temporarily suppressed)
|
||||
#pragma push_macro("byte")
|
||||
#pragma push_macro("GetNextSibling")
|
||||
#pragma push_macro("GetFirstChild")
|
||||
@@ -21,8 +19,7 @@
|
||||
#pragma pop_macro("byte")
|
||||
|
||||
UIScene_SettingsMenu::UIScene_SettingsMenu(int iPad, void *initData, UILayer *parentLayer)
|
||||
: UIScene(iPad, parentLayer)
|
||||
, m_document(nullptr)
|
||||
: UIScene_RmlBase(iPad, parentLayer)
|
||||
{
|
||||
Rml::Context* ctx = RmlManager::Get().GetContext();
|
||||
if (!ctx)
|
||||
@@ -32,40 +29,26 @@ UIScene_SettingsMenu::UIScene_SettingsMenu(int iPad, void *initData, UILayer *pa
|
||||
}
|
||||
|
||||
m_document = ctx->LoadDocument("SettingsMenu.rml");
|
||||
if (m_document)
|
||||
{
|
||||
m_document->Show();
|
||||
|
||||
// Apply conditional visibility matching original Iggy scene behavior
|
||||
bool bNotInGame = (Minecraft::GetInstance()->level == nullptr);
|
||||
|
||||
// Audio and Graphics: hidden if not primary pad
|
||||
if (ProfileManager.GetPrimaryPad() != m_iPad)
|
||||
{
|
||||
auto* elAudio = m_document->GetElementById("audio");
|
||||
if (elAudio) elAudio->SetProperty("display", "none");
|
||||
auto* elGraphics = m_document->GetElementById("graphics");
|
||||
if (elGraphics) elGraphics->SetProperty("display", "none");
|
||||
}
|
||||
|
||||
// Register button click listeners
|
||||
m_document->GetElementById("options")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("audio")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("controls")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("graphics")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("ui")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("reset_defaults")->AddEventListener(Rml::EventId::Click, this);
|
||||
|
||||
// Focus first visible button
|
||||
m_document->GetElementById("options")->Focus();
|
||||
}
|
||||
else
|
||||
if (!m_document)
|
||||
{
|
||||
app.DebugPrintf("[RmlSettingsMenu] Failed to load SettingsMenu.rml\n");
|
||||
return;
|
||||
}
|
||||
|
||||
updateComponents();
|
||||
m_document->Show();
|
||||
|
||||
if (ProfileManager.GetPrimaryPad() != m_iPad)
|
||||
{
|
||||
auto* elAudio = m_document->GetElementById("audio");
|
||||
if (elAudio) elAudio->SetProperty("display", "none");
|
||||
auto* elGraphics = m_document->GetElementById("graphics");
|
||||
if (elGraphics) elGraphics->SetProperty("display", "none");
|
||||
}
|
||||
|
||||
RegisterEvents({ "options", "audio", "controls", "graphics", "ui", "reset_defaults" });
|
||||
m_document->GetElementById("options")->Focus();
|
||||
|
||||
updateComponents();
|
||||
ui.HidePressStart();
|
||||
TelemetryManager->RecordMenuShown(m_iPad, eUIScene_SettingsMenu, 0);
|
||||
}
|
||||
@@ -74,101 +57,11 @@ UIScene_SettingsMenu::~UIScene_SettingsMenu()
|
||||
{
|
||||
if (m_document)
|
||||
{
|
||||
m_document->GetElementById("options")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("audio")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("controls")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("graphics")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("ui")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("reset_defaults")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
UnregisterEvents({ "options", "audio", "controls", "graphics", "ui", "reset_defaults" });
|
||||
m_document->Close();
|
||||
m_document = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_SettingsMenu::gainFocus()
|
||||
{
|
||||
if (!bHasFocus && stealsFocus())
|
||||
{
|
||||
bHasFocus = true;
|
||||
updateTooltips();
|
||||
updateComponents();
|
||||
if (!m_bFocussedOnce)
|
||||
{
|
||||
}
|
||||
handleGainFocus(m_bFocussedOnce);
|
||||
if (bHasFocus)
|
||||
m_bFocussedOnce = true;
|
||||
if (m_document)
|
||||
m_document->Show();
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_SettingsMenu::handleLoseFocus()
|
||||
{
|
||||
if (m_document)
|
||||
m_document->Hide();
|
||||
}
|
||||
|
||||
void UIScene_SettingsMenu::updateTooltips()
|
||||
{
|
||||
}
|
||||
|
||||
void UIScene_SettingsMenu::updateComponents()
|
||||
{
|
||||
bool bNotInGame = (Minecraft::GetInstance()->level == nullptr);
|
||||
|
||||
if (bNotInGame)
|
||||
{
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true);
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, false);
|
||||
|
||||
if (app.GetLocalPlayerCount() == 1)
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true);
|
||||
else
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, false);
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_SettingsMenu::reloadMovie(bool force)
|
||||
{
|
||||
}
|
||||
|
||||
void UIScene_SettingsMenu::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_SettingsMenu::render(S32 width, S32 height, C4JRender::eViewportType viewport)
|
||||
{
|
||||
}
|
||||
|
||||
void UIScene_SettingsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
||||
{
|
||||
Rml::Context* ctx = RmlManager::Get().GetContext();
|
||||
@@ -192,8 +85,8 @@ void UIScene_SettingsMenu::handleInput(int iPad, int key, bool repeat, bool pres
|
||||
break;
|
||||
case ACTION_MENU_CANCEL:
|
||||
case ACTION_MENU_PAUSEMENU:
|
||||
app.CheckGameSettingsChanged(true, iPad);
|
||||
navigateBack();
|
||||
app.CheckGameSettingsChanged(true, iPad);
|
||||
navigateBack();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -217,6 +110,21 @@ void UIScene_SettingsMenu::ProcessEvent(Rml::Event& event)
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_SettingsMenu::updateComponents()
|
||||
{
|
||||
bool bNotInGame = (Minecraft::GetInstance()->level == nullptr);
|
||||
if (bNotInGame)
|
||||
{
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, true);
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Panorama, false);
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, app.GetLocalPlayerCount() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_SettingsMenu::navigateBack()
|
||||
{
|
||||
ui.PlayUISFX(eSFX_Back);
|
||||
@@ -256,24 +164,20 @@ void UIScene_SettingsMenu::OnUI()
|
||||
void UIScene_SettingsMenu::OnResetToDefaults()
|
||||
{
|
||||
UINT uiIDA[2];
|
||||
uiIDA[0]=IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1]=IDS_CONFIRM_OK;
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_CONFIRM_OK;
|
||||
|
||||
ui.RequestAlertMessage(IDS_DEFAULTS_TITLE, IDS_DEFAULTS_TEXT, uiIDA, 2, m_iPad,&UIScene_SettingsMenu::ResetDefaultsDialogReturned,this);
|
||||
ui.RequestAlertMessage(IDS_DEFAULTS_TITLE, IDS_DEFAULTS_TEXT, uiIDA, 2, m_iPad, &UIScene_SettingsMenu::ResetDefaultsDialogReturned, this);
|
||||
}
|
||||
|
||||
int UIScene_SettingsMenu::ResetDefaultsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
int UIScene_SettingsMenu::ResetDefaultsDialogReturned(void *pParam, int iPad, C4JStorage::EMessageResult result)
|
||||
{
|
||||
UIScene_SettingsMenu* pClass = (UIScene_SettingsMenu*)pParam;
|
||||
auto pClass = static_cast<UIScene_SettingsMenu*>(pParam);
|
||||
|
||||
// results switched for this dialog
|
||||
if(result==C4JStorage::EMessage_ResultDecline)
|
||||
if (result == C4JStorage::EMessage_ResultDecline)
|
||||
{
|
||||
app.SetDefaultOptions(ProfileManager.GetDashboardProfileSettings(pClass->m_iPad),pClass->m_iPad);
|
||||
|
||||
// if the profile data has been changed, then force a profile write
|
||||
// It seems we're allowed to break the 5 minute rule if it's the result of a user action
|
||||
app.CheckGameSettingsChanged(true,iPad);
|
||||
app.SetDefaultOptions(ProfileManager.GetDashboardProfileSettings(pClass->m_iPad), pClass->m_iPad);
|
||||
app.CheckGameSettingsChanged(true, iPad);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user