File interfaceView.hpp¶
-
class InterfaceView : public ISaveable
- #include <interfaceView.hpp>
An InterfaceView represents a collection of UI elements drawn on the screen to make up a user interface.
Subclassed by DialogueInterfaceView
Public Functions
-
InterfaceView()
Default constructor.
-
InterfaceView(const std::string &filePath)
Construct from a UI View file.
-
InterfaceView(InterfaceViewBin &bin)
Construct from binary data.
-
virtual nlohmann::json dumpJson()
Dump json data.
-
const std::string &getEntityName(int index)
Get name of an element by index.
-
ElementIndex findByName(const std::string &title)
Get the index of an element identified by its name.
-
bool elementExists(const std::string &title)
Whether an element with such a name exists.
-
ElementIndex addElement(const std::string &title, const std::string &type)
Add an element with a title and a registered type.
-
void removeElement(const std::string &title)
Remove an element by its title.
-
UIElement *getElement(const std::string &title)
Get an element pointer by its title.
-
UIElement *getElement(ElementIndex i)
Get an element pointer by its index.
-
void renameElement(const std::string &title, const std::string &newTitle)
Rename an element.
-
void changeFocusedElement(const std::string &title)
Change the focus to an element identified by its index.
-
void changeFocusedElement(ElementIndex index)
Change the focus to an element identified by an index.
-
UIElement *cloneElement(const std::string &title, const std::string &newTitle)
Clone an element by giving it a title. It will appear right above the element that was cloned.
-
const std::array<std::unique_ptr<UIElement>, MAX_ELEMENTS> &getElements()
Get an array of the elements.
-
void swapElements(ElementIndex a, ElementIndex b)
Swap two elements.
-
void moveToPosition(ElementIndex source, ElementIndex dest)
Move an element to another position within the array.
-
void resetElements()
Reset the elements’ positions and sizes.
-
ElementIndex getSize()
Get the amount of elements within this View.
-
virtual void onNotify(Event event)
Notify routine, the View shall react to this event.
-
virtual void update()
Update routine.
-
virtual void draw()
Draw routine. Draws all the elements.
-
virtual void drawEntity(ElementIndex i)
Draw a specific element.
-
void setScriptFile(const std::string &fileName)
Set the script file for this UI View.
-
std::string getScriptFile()
Get the path to the script file for this UI View.
-
bool hasScript()
Check whether this View has an attached script or not.
-
sol::environment &getLuaEnvironment()
Get a reference to the Lua environment of this View.
-
std::list<TweenContainer> &getTweens()
Get a reference to the list of running tweens.
-
void addTweenContainer(TweenContainer tweenContainer)
Add a tween container to be animated.
-
void addTween(Tween tween)
Add a singular tween to be animated.
-
void abandonLua()
Abandon the Lua environment. Should always be done before the end of the program.
Public Members
-
bool runScript = true
Flag whether the script should be ran.
Protected Attributes
-
InterfaceViewBin bin¶
The structure which was used to construct this InterfaceView.
-
std::string focusedElementName = ""¶
The title of the currently focused element.
-
std::string scriptSource = ""¶
The source of the Lua script.
-
bool scriptFlag = false¶
Whether this view has a script or not.
-
sol::environment env¶
A Lua environment for this view.
-
std::array<std::string, MAX_ELEMENTS> elementNames = {}¶
The array of the elements’ names.
-
ElementIndex currentElement = MAX_ELEMENTS¶
Index of the currently focused element.
-
std::queue<ElementIndex> availableIds = {}¶
Queue of available element indexes.
-
int size = 0¶
Amount of elements in this View.
-
std::list<TweenContainer> tweens = {}¶
List of the tweens currently being ran.
Private Members
-
Rectangle rect¶
-
InterfaceView()