Engine UI module
GG-UI in the engine: the UI host and its documents, HUDs (TnxUI), widget classes (TnxWidget), view models, entity bindings, string tables, themes, and the inspector. The UI library itself is the GG-UI group.
Files
- file EntityFields.h
- EntityFields: an entity's reflected components as a GG-UI FieldSource.
- file StatsOverlay.h
- The stats overlay (
--stats): engine health in a corner of the window. - file TnxBind.h
- TnxBind: a UI binding to a field of an entity or a view model, read from the frame on screen.
- file TnxStringTable.h
- TnxStringTable: the text the UI shows, a file per language, reloaded when a file is saved.
- file TnxUI.h
- TnxUI: each local player's HUD (docs/ui/Widgets.md, HUDs and Regions).
- file TnxViewModel.h
- View models: values a game shows that live in no component (docs/ui/Widgets.md, Contexts).
- file TnxWidget.h
- Widget classes: the code behind widget assets (docs/ui/Widgets.md, Widget Classes).
- file TnxWidgets.h
- TnxWidgets: what the engine gives widget assets (docs/ui/Widgets.md).
- file UIConsole.h
- UIConsole: the engine console.
- file UIDemo.h
- The UI check document (
--ui-test) and the widget workbench (--ui-workbench). - file UIHost.h
- UIHost: the engine's side of GG-UI.
- file UIInspector.h
- UIInspector: a document that shows another document.
- file UISheetFiles.h
- UISheetFiles: style sheets loaded from files, with hot reload.
- file UITheme.h
- UITheme: the engine's theme.
- file UIWidgetFiles.h
- UIWidgetFiles: widget assets, tables, and sheets loaded from files, with hot reload.
Namespaces
- namespace StatsOverlay
- namespace GGUI
- namespace TnxUI
- namespace TnxViewModels
- The registry of view model types, and how bindings read their values.
- namespace TnxWidgets
- namespace UIConsole
- namespace UIDemo
- namespace UIInspector
- namespace UITheme
Classes
- struct EntityFields
- An entity's reflected components as a field source, for property grids and bindings.
- class TnxBinding
- A binding TnxBind made: a target and an expression over its fields, passed wherever a GGUI::
GGBinding goes, combined with others of the same target by arithmetic and comparison. - class TnxStringTable
- The string files of every folder added, as the table of one language.
- struct TnxWidgetRef
- A widget added to a HUD (TnxHud::
Add), to remove it by. - class TnxItems
- The items a named source adds, in the order a list shows them unless it sorts them.
- struct TnxGivenContext
- A context a HUD's class gives its asset, as it is now.
- class TnxHud
- One player's HUD.
- class TnxViewModelBase
- The non-template part of a view model: its target, and how readers reach its values.
-
template<typename T>class TnxViewModel
- One set of a view model's values, readable by bindings while it lives. Set from any thread.
-
template<typename T>class TnxContextOf
- Game state a widget reads: an entity of type
T(TnxContextOf<EPlayer<>>), or a view model (TnxContextOf<ShopInfo>). Empty until given one. -
template<typename T>class TnxInput
- A value a widget class gives its asset: a number (
float,int32_t,bool), shown as it changes with nothing built again; or text (a string ID) or a colour, which builds the widget again when set to something else. - class TnxWidgetBase
- The non-template part of every widget class.
-
template<typename T>class TnxWidget
- The base of a widget class:
class PlayerHud : public TnxWidget<PlayerHud>.Tlists what its assets see with TNX_WIDGET, and is registered with TNX_REGISTER_WIDGET. - class UIHost
- The documents the engine shows, one per window, and the libraries, styles, strings, and services they share. See the file description for which thread does what.
- class UISheetFiles
- Style sheets read from files into style tables, and read again when saved.
- class UIWidgetFiles
- Widget assets (.tnxwidget), data tables (.tnxtable), and the style sheets assets name (.ggss), loaded from files into a widget library and reloaded when saved.
Functions
-
template<typename TComponent, typename TMember>auto TnxBind(WorldBase& world, EntityHandle entity, TMember TComponent::* member, std::source_location where = std::source_location::current()) -> TnxBinding
- A field of
entityinworld. -
template<typename TView, typename TComponent, typename TMember>auto TnxBind(const TView& view, TMember TComponent::* member, std::source_location where = std::source_location::current()) -> TnxBinding
- A field of the entity a ConstructView (or anything with GetRegistry and GetEntityHandle) shows.
-
template<typename T, typename TMember>auto TnxBind(const TnxViewModel<T>& model, TMember T::* member, std::source_location where = std::source_location::current()) -> TnxBinding
- A value of a view model.
-
auto TnxContextResolver() -> GGUI::
GGContextResolver - Resolves
Component.Fieldfor a context of an entity type (EPlayer) or a component (CMatchState), andFieldfor a view model. The UI host gives it to its widget library. -
auto TnxReferenceResolver() -> GGUI::
GGReferenceResolver - Finds an asset's current name from its ID in the asset registry, for references by ID in widget files. The UI host gives it to its widget library.
-
auto TnxCommandChecker() -> GGUI::
GGCommandChecker - Checks command actions against the commands registered with TNX_REGISTER_COMMAND, and lists them for tools. The UI host gives it to its widget library.
-
auto TnxSendCommand(WorldBase& world,
const GGUI::
GGWidgetAction& action, const GGUI:: BindingReader& reader, std::string& why) -> bool - Send a command action from
world'slocal player. -
auto TnxContext(WorldBase& world,
EntityHandle entity) -> GGUI::
GGContextValue - The entity
entityofworldas a context. Its type isn't known here, so only the component and field are checked. -
auto TnxContext(const TnxViewModelBase& model) -> GGUI::
GGContextValue - A view model as a context of its type: its fields are
Context.Field. -
template<typename TView>auto TnxContext(const TView& view) -> GGUI::
GGContextValue - The entity a ConstructView shows, as a context of its entity type.
Defines
- #define TNX_VIEW_MODEL(ModelType, Name, ...)
- Declare a view model's name and fields, inside its struct:
TNX_.VIEW_ MODEL(ConnectionInfo, "Net.Connection", PingMs, Players) - #define TNX_REGISTER_VIEW_MODEL(ModelType)
- Make a view model's type known by name, for widget assets. At namespace scope, after its struct.
- #define TNX_WIDGET(WidgetType, ...)
- List what a widget class's assets see, inside the class:
TNX_.WIDGET(PlayerHud, Player, Gold, Health, Buy) - #define TNX_REGISTER_WIDGET(WidgetType)
- Make a widget class known by name, for widget assets. At namespace scope, after its class.
Function documentation
#include <Runtime/UI/Public/TnxBind.h>
template<typename TComponent, typename TMember>
TnxBinding TnxBind(WorldBase& world,
EntityHandle entity,
TMember TComponent::* member,
std::source_location where = std::source_location::current())
A field of entity in world.
#include <Runtime/UI/Public/TnxBind.h>
template<typename TView, typename TComponent, typename TMember>
TnxBinding TnxBind(const TView& view,
TMember TComponent::* member,
std::source_location where = std::source_location::current())
A field of the entity a ConstructView (or anything with GetRegistry and GetEntityHandle) shows.
#include <Runtime/UI/Public/TnxBind.h>
template<typename T, typename TMember>
TnxBinding TnxBind(const TnxViewModel<T>& model,
TMember T::* member,
std::source_location where = std::source_location::current())
A value of a view model.
GGUI:: GGContextResolver TnxContextResolver()
#include <Runtime/UI/Public/TnxWidgets.h>
Resolves Component.Field for a context of an entity type (EPlayer) or a component (CMatchState), and Field for a view model. The UI host gives it to its widget library.
GGUI:: GGReferenceResolver TnxReferenceResolver()
#include <Runtime/UI/Public/TnxWidgets.h>
Finds an asset's current name from its ID in the asset registry, for references by ID in widget files. The UI host gives it to its widget library.
GGUI:: GGCommandChecker TnxCommandChecker()
#include <Runtime/UI/Public/TnxWidgets.h>
Checks command actions against the commands registered with TNX_REGISTER_COMMAND, and lists them for tools. The UI host gives it to its widget library.
bool TnxSendCommand(WorldBase& world,
const GGUI:: GGWidgetAction& action,
const GGUI:: BindingReader& reader,
std::string& why)
#include <Runtime/UI/Public/TnxWidgets.h>
Send a command action from world's local player.
The action is { "command": "Game.BuyUpgrade", "Tier": "=Item.CUpgrade.Tier" }: its fields are filled by name, and those that read game state are read through reader. False, with why, if the command or a field is unknown or a value can't be read.
GGUI:: GGContextValue TnxContext(WorldBase& world,
EntityHandle entity)
#include <Runtime/UI/Public/TnxWidgets.h>
The entity entity of world as a context. Its type isn't known here, so only the component and field are checked.
GGUI:: GGContextValue TnxContext(const TnxViewModelBase& model)
#include <Runtime/UI/Public/TnxWidgets.h>
A view model as a context of its type: its fields are Context.Field.
#include <Runtime/UI/Public/TnxWidgets.h>
template<typename TView>
GGUI:: GGContextValue TnxContext(const TView& view)
The entity a ConstructView shows, as a context of its entity type.
Define documentation
#define TNX_VIEW_MODEL(ModelType,
Name,
...)
#include <Runtime/UI/Public/TnxViewModel.h>
Declare a view model's name and fields, inside its struct: TNX_.
Name is what assets call its type ("contexts": { "Item": "Net.Connection" }). Fields not listed aren't read; listed fields of a type a view model can't hold are left out.
#define TNX_REGISTER_VIEW_MODEL(ModelType)
#include <Runtime/UI/Public/TnxViewModel.h>
Make a view model's type known by name, for widget assets. At namespace scope, after its struct.
#define TNX_WIDGET(WidgetType,
...)
#include <Runtime/UI/Public/TnxWidget.h>
List what a widget class's assets see, inside the class: TNX_.
Each is a context (TnxContextOf), an input (TnxInput), a widget member (another widget class), or a method its actions call (taking nothing, or the item of a list's row). Its kind comes from its type; anything else doesn't compile.
#define TNX_REGISTER_WIDGET(WidgetType)
#include <Runtime/UI/Public/TnxWidget.h>
Make a widget class known by name, for widget assets. At namespace scope, after its class.