File XMLUIGameLayer.h

File List > engine > include > XMLUIGameLayer.h

Go to the documentation of this file

#ifndef XMLUI_GAME_LAYER_H
#define XMLUI_GAME_LAYER_H

#include <libxml/tree.h>


#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>
#include "HandleDefs.h"
#include "DynArray.h"
#include "Widget.h"
#include "DrawContext.h"
#include "TimerPool.h"
#include "InputContext.h"

struct XMLUIData;
struct GameFrameworkLayer;
struct DataNode;

struct XMLUIGameLayerOptions
{
    DrawContext* pDc;

    const char* xmlPath;

    bool bLoadImmediately;
};

typedef HWidget(*AddChildFn)(HWidget hParent, struct DataNode* pDataNode, struct XMLUIData* pUILayerData);

#define XML_UI_MAX_PATH 256
#define MAX_FOCUSED_WIDGETS 16


struct WidgetChildrenChangeRequest
{
    int regIndex;

    const char* funcName;

    HWidget hWidget;
};


typedef struct XMLUIData
{
    HWidget rootWidget;
    char xmlFilePath[XML_UI_MAX_PATH];
    const char* xmlData;
    bool bLoaded;
    hAtlas atlas;
    VECTOR(WidgetVertex) pWidgetVertices;
    HUIVertexBuffer hVertexBuffer;
    int hViewModel; // reference to lua table
    HWidget focusedWidgets[MAX_FOCUSED_WIDGETS];
    int nFocusedWidgets;
    struct SDTimerPool timerPool;
    VECTOR(struct WidgetChildrenChangeRequest) pChildrenChangeRequests;
    struct AxisBinding gMouseX;
    struct AxisBinding gMouseY;
    struct ButtonBinding gMouseBtnLeft;
}XMLUIData;


void XMLUIGameLayer_Get(struct GameFrameworkLayer* pLayer, struct XMLUIGameLayerOptions* pOptions);

void XMLUI_PushGameFrameworkLayer(const char* xmlPath);

#ifdef __cplusplus
}
#endif

#endif