Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CGUIImporter Class Reference

This object class helps initialize GUI components for the CCanvas from files and data.The CGUIImporter class helps load, import, and initialize GUI components for a CCanvas, from .gui files or serializable data, typically exported by CGUIExporter or designed in the Skylicht-Editor. More...

#include <Graphics2D/CGUIImporter.h>

Static Public Member Functions

static bool loadGUI (const char *file, CCanvas *canvas)
static bool beginImport (const char *file, CCanvas *canvas)
 Begin importing a GUI layout from file. Initializes structures for step-based loading.
static bool updateLoadGUI ()
 Perform one step in the GUI loading process. Used for asynchronous or progressive loading.
static float getLoadingPercent ()
 Get percent progress of the GUI loading process.
static CObjectSerializableloadGUIToSerializable (const char *file, CCanvas *canvas)
 Load a GUI layout from file into a serializable object structure.
static void loadGUIFromSerializable (CObjectSerializable *gui, CCanvas *canvas)
 Initialize a canvas from a serializable GUI object.
static CGUIElementimportGUI (CCanvas *canvas, CGUIElement *target, CObjectSerializable *obj, bool generateNewId=false)
 Import a GUI element tree from a serializable object into the canvas.
static CObjectSerializablegetSerializableByPath (CObjectSerializable *obj, const char *path)
 Find a serializable GUI object by its path in the hierarchy.
static void reset (CCanvas *canvas)
 Reset the canvas to default state after import (position, size, background color).

Static Protected Member Functions

static bool loadStep (CCanvas *canvas, io::IXMLReader *reader)
 Internal loading step for canvas from XML reader.
static void buildCanvas (CCanvas *canvas, io::IXMLReader *reader)
 Build the initial canvas structure from XML reader.
static bool loadObjStep (CObjectSerializable *obj, CCanvas *canvas, io::IXMLReader *reader)
 Internal loading step for a serializable object from XML reader.
static bool loadObjChilds (CObjectSerializable *obj, CCanvas *canvas, io::IXMLReader *reader)
 Load all children for a serializable object from XML reader.
static CGUIElementcreateElementByType (const wchar_t *type, CCanvas *canvas, CGUIElement *parent)

Detailed Description

This object class helps initialize GUI components for the CCanvas from files and data.

The CGUIImporter class helps load, import, and initialize GUI components for a CCanvas, from .gui files or serializable data, typically exported by CGUIExporter or designed in the Skylicht-Editor.

See also
CCanvas
CZone* zone = scene->getZone(0);
CGameObject* guiObj = zone->createEmptyObject();
CCanvas* canvas = guiObj->addComponent<CCanvas>();
float applyScale = 0.0f;
CGUIImporter::loadGUI("menu.gui", canvas);
canvas->applyGUIScale(applyScale);
canvas->updateEntities();
This class manages GUI components, including creating and deleting images and sprites.
Definition CCanvas.h:79
void updateEntities()
Update internal entity lists and sorting for rendering.
void applyGUIScale(float widthOrHeight=1.0f)
Apply GUI scaling based on width or height ratio.
This object class stores information for a GameObject.
Definition CGameObject.h:52
It's the primary container object for the CScene; all CGameObject have a CZone as their root parent.
Definition CZone.h:37
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CIndexBuffer.h:13

Member Function Documentation

◆ beginImport()

bool Skylicht::CGUIImporter::beginImport ( const char * file,
CCanvas * canvas )
static

Begin importing a GUI layout from file. Initializes structures for step-based loading.

Parameters
filePath to the .gui file.
canvasPointer to the CCanvas to initialize.
Returns
True if initialization was successful.

◆ buildCanvas()

void Skylicht::CGUIImporter::buildCanvas ( CCanvas * canvas,
io::IXMLReader * reader )
staticprotected

Build the initial canvas structure from XML reader.

Parameters
canvasPointer to CCanvas.
readerXML reader.

◆ getLoadingPercent()

float Skylicht::CGUIImporter::getLoadingPercent ( )
static

Get percent progress of the GUI loading process.

Returns
Loading progress as a value between 0.0 and 1.0.

◆ getSerializableByPath()

CObjectSerializable * Skylicht::CGUIImporter::getSerializableByPath ( CObjectSerializable * obj,
const char * path )
static

Find a serializable GUI object by its path in the hierarchy.

Parameters
objRoot serializable object.
pathPath string (separated by / or ).
Returns
Pointer to found CObjectSerializable, or NULL.

◆ importGUI()

CGUIElement * Skylicht::CGUIImporter::importGUI ( CCanvas * canvas,
CGUIElement * target,
CObjectSerializable * obj,
bool generateNewId = false )
static

Import a GUI element tree from a serializable object into the canvas.

Parameters
canvasPointer to CCanvas.
targetParent GUI element.
objSerializable object for element.
generateNewIdIf true, assigns new IDs to elements.
Returns
Pointer to imported CGUIElement.

◆ loadGUIFromSerializable()

void Skylicht::CGUIImporter::loadGUIFromSerializable ( CObjectSerializable * gui,
CCanvas * canvas )
static

Initialize a canvas from a serializable GUI object.

Parameters
guiPointer to root serializable object.
canvasPointer to CCanvas to initialize.

◆ loadGUIToSerializable()

CObjectSerializable * Skylicht::CGUIImporter::loadGUIToSerializable ( const char * file,
CCanvas * canvas )
static

Load a GUI layout from file into a serializable object structure.

Parameters
filePath to the .gui file.
canvasPointer to CCanvas (for context).
Returns
Pointer to the loaded CObjectSerializable (must be deleted by caller).

◆ loadObjChilds()

bool Skylicht::CGUIImporter::loadObjChilds ( CObjectSerializable * obj,
CCanvas * canvas,
io::IXMLReader * reader )
staticprotected

Load all children for a serializable object from XML reader.

Parameters
objSerializable object.
canvasPointer to CCanvas.
readerXML reader.
Returns
True if loading is finished.

◆ loadObjStep()

bool Skylicht::CGUIImporter::loadObjStep ( CObjectSerializable * obj,
CCanvas * canvas,
io::IXMLReader * reader )
staticprotected

Internal loading step for a serializable object from XML reader.

Parameters
objSerializable object.
canvasPointer to CCanvas.
readerXML reader.
Returns
True if loading is finished.

◆ loadStep()

bool Skylicht::CGUIImporter::loadStep ( CCanvas * canvas,
io::IXMLReader * reader )
staticprotected

Internal loading step for canvas from XML reader.

Parameters
canvasPointer to CCanvas.
readerXML reader.
Returns
True if loading is finished.

◆ reset()

void Skylicht::CGUIImporter::reset ( CCanvas * canvas)
static

Reset the canvas to default state after import (position, size, background color).

Parameters
canvasPointer to canvas to reset.

◆ updateLoadGUI()

bool Skylicht::CGUIImporter::updateLoadGUI ( )
static

Perform one step in the GUI loading process. Used for asynchronous or progressive loading.

Returns
True if loading is finished.

The documentation for this class was generated from the following file: