mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-07-10 19:08:32 +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_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(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,43 +29,30 @@ UIScene_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(int iPad, void *initData,
|
||||
}
|
||||
|
||||
m_document = ctx->LoadDocument("HelpOptions.rml");
|
||||
if (m_document)
|
||||
{
|
||||
m_document->Show();
|
||||
|
||||
bool bNotInGame = (Minecraft::GetInstance()->level == nullptr);
|
||||
|
||||
// Change Skin: hide if not full version
|
||||
if (!ProfileManager.IsFullVersion())
|
||||
{
|
||||
auto* el = m_document->GetElementById("change_skin");
|
||||
if (el) el->SetProperty("display", "none");
|
||||
}
|
||||
|
||||
// Credits: hide in splitscreen
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
{
|
||||
auto* el = m_document->GetElementById("credits");
|
||||
if (el) el->SetProperty("display", "none");
|
||||
}
|
||||
|
||||
// Register button click listeners
|
||||
m_document->GetElementById("change_skin")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("how_to_play")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("controls")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("settings")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("credits")->AddEventListener(Rml::EventId::Click, this);
|
||||
|
||||
// Focus first visible button
|
||||
m_document->GetElementById("change_skin")->Focus();
|
||||
}
|
||||
else
|
||||
if (!m_document)
|
||||
{
|
||||
app.DebugPrintf("[RmlHelpAndOptions] Failed to load HelpOptions.rml\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ui.HidePressStart();
|
||||
m_document->Show();
|
||||
|
||||
if (!ProfileManager.IsFullVersion())
|
||||
{
|
||||
auto* el = m_document->GetElementById("change_skin");
|
||||
if (el) el->SetProperty("display", "none");
|
||||
}
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
{
|
||||
auto* el = m_document->GetElementById("credits");
|
||||
if (el) el->SetProperty("display", "none");
|
||||
}
|
||||
|
||||
RegisterEvents({ "change_skin", "how_to_play", "controls", "settings", "credits" });
|
||||
m_document->GetElementById("change_skin")->Focus();
|
||||
|
||||
ui.HidePressStart();
|
||||
TelemetryManager->RecordMenuShown(m_iPad, eUIScene_HelpAndOptionsMenu, 0);
|
||||
}
|
||||
|
||||
@@ -76,76 +60,11 @@ UIScene_HelpAndOptionsMenu::~UIScene_HelpAndOptionsMenu()
|
||||
{
|
||||
if (m_document)
|
||||
{
|
||||
m_document->GetElementById("change_skin")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("how_to_play")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("controls")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("settings")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("credits")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
UnregisterEvents({ "change_skin", "how_to_play", "controls", "settings", "credits" });
|
||||
m_document->Close();
|
||||
m_document = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_HelpAndOptionsMenu::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_HelpAndOptionsMenu::handleLoseFocus()
|
||||
{
|
||||
if (m_document)
|
||||
m_document->Hide();
|
||||
}
|
||||
|
||||
void UIScene_HelpAndOptionsMenu::reloadMovie(bool force)
|
||||
{
|
||||
}
|
||||
|
||||
void UIScene_HelpAndOptionsMenu::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_HelpAndOptionsMenu::render(S32 width, S32 height, C4JRender::eViewportType viewport)
|
||||
{
|
||||
}
|
||||
|
||||
void UIScene_HelpAndOptionsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
||||
{
|
||||
Rml::Context* ctx = RmlManager::Get().GetContext();
|
||||
@@ -196,10 +115,6 @@ void UIScene_HelpAndOptionsMenu::ProcessEvent(Rml::Event& event)
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_HelpAndOptionsMenu::updateTooltips()
|
||||
{
|
||||
}
|
||||
|
||||
void UIScene_HelpAndOptionsMenu::updateComponents()
|
||||
{
|
||||
bool bNotInGame = (Minecraft::GetInstance()->level == nullptr);
|
||||
@@ -211,11 +126,7 @@ void UIScene_HelpAndOptionsMenu::updateComponents()
|
||||
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);
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, app.GetLocalPlayerCount() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,5 +165,3 @@ void UIScene_HelpAndOptionsMenu::OnCredits()
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
ui.NavigateToScene(m_iPad, eUIScene_Credits);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user