Implement MessageBox UI: Add styles and structure for message box, including buttons and event handling

This commit is contained in:
Zero
2026-06-14 15:57:59 +02:00
parent ec221ab410
commit 4f5eca9194
6 changed files with 406 additions and 181 deletions

View File

@@ -1,60 +1,52 @@
#pragma once
#pragma push_macro("byte")
#pragma push_macro("GetNextSibling")
#pragma push_macro("GetFirstChild")
#undef byte
#undef GetNextSibling
#undef GetFirstChild
#include "UIScene.h"
#include <RmlUi/Core/EventListener.h>
#include <RmlUi/Core/ElementDocument.h>
class UIScene_MessageBox : public UIScene
class UIScene_MessageBox : public UIScene, public Rml::EventListener
{
private:
enum EControls
{
eControl_Button0,
eControl_Button1,
eControl_Button2,
eControl_Button3,
eControl_COUNT
};
int( *m_Func)(LPVOID,int,const C4JStorage::EMessageResult);
LPVOID m_lpParam;
int m_buttonCount;
UIControl_Button m_buttonButtons[eControl_COUNT];
UIControl_Label m_labelTitle, m_labelContent;
IggyName m_funcInit, m_funcAutoResize;
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_ELEMENT( m_buttonButtons[eControl_Button0], "Button0")
UI_MAP_ELEMENT( m_buttonButtons[eControl_Button1], "Button1")
UI_MAP_ELEMENT( m_buttonButtons[eControl_Button2], "Button2")
UI_MAP_ELEMENT( m_buttonButtons[eControl_Button3], "Button3")
UI_MAP_ELEMENT( m_labelTitle, "Title")
UI_MAP_ELEMENT( m_labelContent, "Content")
UI_MAP_NAME( m_funcInit, L"Init")
UI_MAP_NAME( m_funcAutoResize, L"AutoResize")
UI_END_MAP_ELEMENTS_AND_NAMES()
public:
UIScene_MessageBox(int iPad, void *initData, UILayer *parentLayer);
~UIScene_MessageBox();
virtual ~UIScene_MessageBox();
virtual EUIScene getSceneType() { return eUIScene_MessageBox;}
virtual EUIScene getSceneType() { return eUIScene_MessageBox; }
// Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden
virtual bool hidesLowerScenes() { return false; }
virtual bool hidesLowerScenes() { return false; }
virtual bool blocksInput() { return true; }
protected:
// TODO: This should be pure virtual in this class
virtual wstring getMoviePath();
virtual void updateTooltips();
virtual void tick();
virtual void render(S32 width, S32 height, C4JRender::eViewportType viewport);
public:
virtual void handleReload();
virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled);
virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled);
virtual bool hasFocus(int iPad);
virtual void gainFocus() override;
virtual void reloadMovie(bool force) override;
void ProcessEvent(Rml::Event& event) override;
protected:
void handlePress(F64 controlId, F64 childId);
};
virtual wstring getMoviePath() { return L""; }
virtual void handleLoseFocus() override;
void OnButtonClicked(int buttonIndex);
void navigateBack();
private:
Rml::ElementDocument* m_document;
int m_buttonCount;
int(*m_Func)(LPVOID, int, const C4JStorage::EMessageResult);
LPVOID m_lpParam;
};
#pragma pop_macro("GetFirstChild")
#pragma pop_macro("GetNextSibling")
#pragma pop_macro("byte")