46 class DVDTextureTarget;
57 struct MemoryBarrierCommand;
68class SceneGUIElements;
71struct TextElementBatch;
72struct SizeChangeParams;
108 template <
typename T>
requires std::is_base_of_v<GUIElement, T>
111 template <
typename T>
requires std::is_base_of_v<GUIElement, T>
139 [[nodiscard]]
bool onKeyDown( const Input::KeyEvent& key ) override;
141 [[nodiscard]]
bool onKeyUp( const Input::KeyEvent& key ) override;
143 [[nodiscard]]
bool joystickAxisMoved( const Input::JoystickEvent& arg ) override;
145 [[nodiscard]]
bool joystickPovMoved( const Input::JoystickEvent& arg ) override;
150 [[nodiscard]]
bool joystickBallMoved( const Input::JoystickEvent& arg ) override;
151 [[nodiscard]]
bool joystickAddRemove( const Input::JoystickEvent& arg ) override;
152 [[nodiscard]]
bool joystickRemap( const Input::JoystickEvent& arg ) override;
154 [[nodiscard]]
bool mouseMoved( const Input::MouseMoveEvent& arg ) override;
160 [[nodiscard]]
bool onTextEvent( const Input::TextEvent& arg ) noexcept override;
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
GUIConsole implementation, CEGUI based, as in the practical tutorial series.
Graphical User Interface.
CEGUI::GUIContext * getCEGUIContext() noexcept
Provides direct access to the CEGUI context. Used by plugins (e.g. GUIConsole, GUIInput,...
CEGUI::Window * _rootSheet
The root window into which CEGUI anchors all of its elements.
CEGUI::Window * rootSheet() const noexcept
Get a pointer to the root sheet that CEGUI renders into.
bool joystickPovMoved(const Input::JoystickEvent &arg) override
Joystick direction change: return true if input was consumed.
bool onKeyUp(const Input::KeyEvent &key) override
Key released: return true if input was consumed.
std::unique_ptr< GUIConsole > _console
Our custom in-game console (for logs and commands. A la Quake's ~-console)
ErrorCode init(PlatformContext &context)
Create the GUI.
GUIConsole & getConsole() noexcept
Get a reference to our console window.
bool onTextEvent(const Input::TextEvent &arg) noexcept override
Called when text input was detected.
bool joystickButtonReleased(const Input::JoystickEvent &arg) override
Joystick button released: return true if input was consumed.
std::unique_ptr< GUIMessageBox > _defaultMsgBox
Pointer to a default message box used for general purpose messages.
CEGUIInput _ceguiInput
Used to implement key repeat.
void recreateDefaultMessageBox()
Used to recreate and re-register the default message box if needed (usually on scene change)
CEGUI::GUIContext * _ceguiContext
The CEGUI context as returned by the library upon creation.
void setCursorPosition(I32 x, I32 y)
Mouse cursor forced to a certain position.
DVDFONSContext_uptr _fonsContext
We use Font Stash (https://github.com/memononen/fontstash) for rendering basic text on the screen....
Handle< ShaderProgram > _textRenderShader
The text rendering shaderProgram we used to draw Font Stash text.
void preDraw(GFXDevice &context, const Rect< I32 > &viewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Render all elements that need their own internal render targets (e.g. CEGUI)
bool mouseButtonPressed(const Input::MouseButtonEvent &arg) override
Mouse button pressed: return true if input was consumed.
bool joystickAddRemove(const Input::JoystickEvent &arg) override
bool joystickBallMoved(const Input::JoystickEvent &arg) override
void draw(GFXDevice &context, const Rect< I32 > &viewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Go through all of the registered scene gui elements and gather all of the render commands.
Pipeline * _textRenderPipeline
The text rendering pipeline we used to draw Font Stash text.
void showDebugCursor(bool state)
Toggle debug cursor rendering on or off.
void onUnloadScene(Scene *scene)
When we unload a scene, we unload all of its GUI elements. ToDo: Scene should own these and scene sho...
void onChangeScene(Scene *newScene)
When we change a scene, we want to toggle our current scene GUI elements off and toggle the new scene...
bool joystickRemap(const Input::JoystickEvent &arg) override
hashMap< I64, SceneGUIElements * > GUIMapPerScene
void onResolutionChange(const SizeChangeParams ¶ms)
Mostly used by CEGUI to keep track of screen dimensions.
bool joystickAxisMoved(const Input::JoystickEvent &arg) override
Joystick axis change: return true if input was consumed.
I32 getFont(const Str< 64 > &fontName)
Try to find the requested font in the font cache. Load on cache miss.
bool mouseMoved(const Input::MouseMoveEvent &arg) override
Mouse moved: return true if input was consumed.
T * getSceneGUIElementImpl(const I64 sceneID, const I64 elementID)
Find a return a gui element by ID.
bool joystickButtonPressed(const Input::JoystickEvent &arg) override
Joystick button pressed: return true if input was consumed.
GUIMapPerScene _guiStack
All the GUI elements created per scene.
bool onKeyDown(const Input::KeyEvent &key) override
Key pressed: return true if input was consumed.
const GUIConsole & getConsole() const noexcept
Get a const reference to our console window.
bool frameStarted(const FrameEvent &evt) override
GUIMessageBox * getDefaultMessageBox() const noexcept
Return a pointer to the default, general purpose message box.
T * getSceneGUIElementImpl(const I64 sceneID, const U64 elementName)
Find a return a gui element by name.
bool mouseButtonReleased(const Input::MouseButtonEvent &arg) override
Mouse button released: return true if input was consumed.
void update(U64 deltaTimeUS)
Main update call. Used to tick gui elements (cursors, animations, etc)
bool _init
Set to true when the GUI has finished loading.
SharedMutex _guiStackLock
A lock to protect access to _guiStack.
CEGUI::CEGUIRenderer * _ceguiRenderer
Used to render CEGUI to a texture; We want to port this to the Divide::GFX interface.
hashMap< U64, I32 > _fonts
A cache of all font IDs used by Font Stash stored by name ID.
Scene * _activeScene
Each scene has its own gui elements! (0 = global). We keep a pointer to the scene but we really shoul...
CEGUI::DVDTextureTarget * _renderTextureTarget
Used to render CEGUI elements into. We blit this on top of our scene target.
Handle< ShaderProgram > _ceguiRenderShader
hashAlg::pair< Str< 64 >, I32 > _fontCache
A cache of the last requested font by name to avoid a lookup in the fonts map.
void drawText(const TextElementBatch &batch, const Rect< I32 > &targetViewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut, bool pushCamera=true)
Text rendering is handled exclusively by Mikko Mononen's FontStash library (https://github....
Kernel & parent() noexcept
The kernel is the main system that connects all of our various systems: windows, gfx,...
struct FONScontext FONScontext
constexpr Optick::Category::Type Scene
Handle console commands that start with a forward slash.
std::shared_mutex SharedMutex
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap