9#include <unordered_map>
47 GameOverlay(std::shared_ptr<Context> context =
nullptr, std::shared_ptr<ResourceManager> resourceManager =
nullptr,
48 std::shared_ptr<ConsoleVariable> consoleVariables =
nullptr, std::shared_ptr<Window> window =
nullptr);
52 void OnInit(
const nlohmann::json& initArgs = {})
override;
68 void LoadFont(
const std::string& name,
float fontSize,
const std::string& path);
96 ImVec2
CalculateTextSize(
const char* text,
const char* textEnd = NULL,
bool shortenText =
false,
97 float wrapWidth = -1.0f);
107 void TextDraw(
float x,
float y,
bool shadow, ImVec4 color,
const char* text, ...);
134 std::unordered_map<std::string, ImFont*> mFonts;
135 std::unordered_map<std::string, Overlay> mRegisteredOverlays;
136 std::string mCurrentFont =
"Default";
137 bool mNeedsCleanup =
false;
139 std::shared_ptr<ResourceManager> mResourceManager;
140 std::shared_ptr<ConsoleVariable> mConsoleVariables;
141 std::shared_ptr<Window> mWindow;
144 void CleanupNotifications();
A named Part with a parent/child hierarchy and optional thread safety.
Definition Component.h:34
Renders on-screen timed notification messages.
Definition GameOverlay.h:45
void OnInit(const nlohmann::json &initArgs={}) override
Initialises the overlay and loads the default font.
float GetScreenHeight()
Returns the current game viewport height in pixels.
float GetStringWidth(const char *text)
Returns the pixel width of text using the currently selected font.
void SetCurrentFont(const std::string &name)
Selects the font used for subsequent TextDraw() and notification calls.
void DrawSettings()
Renders the overlay settings panel (font selector, position, etc.) in ImGui.
ImGuiID GetID()
Returns the ImGui ID of the overlay's invisible host window.
void Draw()
Renders all active overlays for the current frame. Called by Gui::DrawGame().
void TextDraw(float x, float y, bool shadow, ImVec4 color, const char *text,...)
Draws text at the given screen position, optionally with a drop shadow.
void LoadFont(const std::string &name, float fontSize, const ResourceIdentifier &identifier)
Loads a font from an archive resource and registers it under name.
ImVec2 CalculateTextSize(const char *text, const char *textEnd=NULL, bool shortenText=false, float wrapWidth=-1.0f)
Calculates the bounding box of the given text.
float GetScreenWidth()
Returns the current game viewport width in pixels.
void TextDrawNotification(float duration, bool shadow, const char *fmt,...)
Posts a timed notification message that fades out automatically.
void ClearNotifications()
Immediately removes all active notification overlays.
void LoadFont(const std::string &name, float fontSize, const std::string &path)
Loads a font from a virtual archive path and registers it under name.
GameOverlay(std::shared_ptr< Context > context=nullptr, std::shared_ptr< ResourceManager > resourceManager=nullptr, std::shared_ptr< ConsoleVariable > consoleVariables=nullptr, std::shared_ptr< Window > window=nullptr)
Uniquely identifies a cached resource by path/hash, owner, and source archive.
Definition ResourceIdentifier.h:15
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14
OverlayType
Identifies the type of an overlay item rendered by GameOverlay.
Definition GameOverlay.h:18
@ IMAGE
An image drawn at a screen position.
@ NOTIFICATION
A transient notification that fades out after a duration.
An active overlay item managed by GameOverlay.
Definition GameOverlay.h:27
float fadeTime
Remaining fade-out time in seconds (notifications only).
Definition GameOverlay.h:30
float duration
Total display duration in seconds (notifications only).
Definition GameOverlay.h:31
std::string Value
Text content or resource path, depending on Type.
Definition GameOverlay.h:29
OverlayType Type
Discriminator for the overlay kind.
Definition GameOverlay.h:28