Add RmlUi: SettingsUIMenu. And the other menus that already use RmlUi have been cleaned up.

This commit is contained in:
Zero
2026-06-20 21:04:32 +02:00
parent f7e0465dc3
commit 2a5633b256
19 changed files with 921 additions and 806 deletions

View File

@@ -17,11 +17,8 @@
#pragma pop_macro("GetNextSibling")
#pragma pop_macro("byte")
extern KeyboardMouseInput g_KBMInput;
UIScene_MessageBox::UIScene_MessageBox(int iPad, void *initData, UILayer *parentLayer)
: UIScene(iPad, parentLayer)
, m_document(nullptr)
: UIScene_RmlBase(iPad, parentLayer)
, m_buttonCount(0)
, m_Func(nullptr)
, m_lpParam(nullptr)
@@ -59,7 +56,6 @@ UIScene_MessageBox::UIScene_MessageBox(int iPad, void *initData, UILayer *parent
if (auto* descEl = m_document->GetElementById("description"))
descEl->SetInnerRML(descUtf8);
int buttonIndex = 0;
Rml::Element* buttons[4] = {
m_document->GetElementById("button0"),
m_document->GetElementById("button1"),
@@ -76,10 +72,7 @@ UIScene_MessageBox::UIScene_MessageBox(int iPad, void *initData, UILayer *parent
}
}
int startIndex = 4 - m_buttonCount;
if (startIndex < 0)
startIndex = 0;
int startIndex = max(0, 4 - m_buttonCount);
int labelIndex = 0;
for (int i = startIndex; i < 4; i++)
{
@@ -98,7 +91,6 @@ UIScene_MessageBox::UIScene_MessageBox(int iPad, void *initData, UILayer *parent
buttons[focusButton]->Focus();
m_document->Show();
parentLayer->addComponent(iPad, eUIComponent_MenuBackground);
}
@@ -106,79 +98,23 @@ UIScene_MessageBox::~UIScene_MessageBox()
{
if (m_document)
{
m_document->GetElementById("button0")->RemoveEventListener(Rml::EventId::Click, this);
m_document->GetElementById("button1")->RemoveEventListener(Rml::EventId::Click, this);
m_document->GetElementById("button2")->RemoveEventListener(Rml::EventId::Click, this);
m_document->GetElementById("button3")->RemoveEventListener(Rml::EventId::Click, this);
Rml::Element* buttons[4] = {
m_document->GetElementById("button0"),
m_document->GetElementById("button1"),
m_document->GetElementById("button2"),
m_document->GetElementById("button3")
};
for (int i = 0; i < 4; i++)
{
if (buttons[i])
buttons[i]->RemoveEventListener(Rml::EventId::Click, this);
}
m_document->Close();
m_document = nullptr;
}
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)
{
}
//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_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();
@@ -208,7 +144,7 @@ void UIScene_MessageBox::handleInput(int iPad, int key, bool repeat, bool presse
case ACTION_MENU_CANCEL:
{
C4JStorage::EMessageResult result = C4JStorage::EMessage_Cancelled;
int( *tmpFunc)(LPVOID,int,const C4JStorage::EMessageResult) = m_Func;
auto tmpFunc = m_Func;
LPVOID tmpParam = m_lpParam;
int tmpPad = m_iPad;
@@ -227,11 +163,11 @@ void UIScene_MessageBox::handleInput(int iPad, int key, bool repeat, bool presse
bool UIScene_MessageBox::hasFocus(int iPad)
{
if (m_iPad == 255) // Message box is for everyone
if (m_iPad == 255)
return bHasFocus;
else if (ProfileManager.IsSignedIn(m_iPad)) // Owner is still present
else if (ProfileManager.IsSignedIn(m_iPad))
return bHasFocus && (iPad == m_iPad);
else // Original owner has left so let everyone interact
else
return bHasFocus;
}
@@ -250,12 +186,7 @@ void UIScene_MessageBox::ProcessEvent(Rml::Event& event)
void UIScene_MessageBox::OnButtonClicked(int buttonIndex)
{
//GabsPuN: Something is wrong with the IDs. This fixed it but
//I don't know if this is the right way to do it
int startIndex = 4 - m_buttonCount;
if (startIndex < 0)
startIndex = 0;
int startIndex = max(0, 4 - m_buttonCount);
int RButtonIndex = buttonIndex - startIndex;
C4JStorage::EMessageResult result = C4JStorage::EMessage_Cancelled;
@@ -269,7 +200,7 @@ void UIScene_MessageBox::OnButtonClicked(int buttonIndex)
ui.PlayUISFX(eSFX_Press);
int( *tmpFunc)(LPVOID,int,const C4JStorage::EMessageResult) = m_Func;
auto tmpFunc = m_Func;
LPVOID tmpParam = m_lpParam;
int tmpPad = m_iPad;