Menu

GUI

Benedict Jäggi

Back to [APK_DOTNET_MAUI].

GUI.cs

Classes and functions for creating the GUI (Graphical User Interface)

class GUI

General functions for accessing and using the GUI. All functions are static.

void showMessageBox(CGUIMessageBox box)

Shows the given message box box.

void hideMessageBox()

Hides/removes the actually shown message box.

void showMenu(CGUIMenu menu)

Shows the menu menu at its position given by its eMainMenuAlignement and posidx values.

void hideMenu()

Hides the actually shown menu.

void addMainMenuItem(eMainMenuAlignement align, int posidx, string txt, int funcNum, int funcVal)

Sets a CGUIMainMenuButton to the given corner align and button position index posidx, showing txt and returning funcNum and funcVal to IGame.onGUI()when clicked. If that position is already taken, it will be overwritten.

void clearMainMenu()

Removes all CGUIMainMenuButtons from the GUI.

class CGUIText

A text drawn at the center of the screen.
Used with CGUIMessageBox.addText().
You need to handle it yourself (call Draw() in IGame.onDraw()) if not used with CGUIMessageBox.

void CGUIText(string txt, Color colr, float setx, float sety)

Creates the text using txt in color colr, positioned at setx, sety seen from the center of the screen.

void Draw()

Draws the text. Used automagically in CGUIMessageBox, else you need to call it yourself.

class CGUIButton

A button drawn at the center of the screen.
Used with CGUIMessageBox.addButton().
You need to handle it yourself (call Draw() and isMouseOver() in IGame.onDraw() and IGame.onClick()) if not used with CGUIMessageBox.

void CGUIButton(int funcnum, int funcval, string txt, float vx, float vy, float w, float h)

Creates the button with the function number funcnum, the function value funcval (received in IGame.onGUI()), the display text txt at position vx, vy seen from center of the screen with width w and height h (defaulting to 200, 50).

You need to handle the button by yourself if not used with a CGUIMessageBox. It will NOT call IGame.onGUI() outside of a CGUIMessageBox, you need to do that also by yourself.

void setColors(Color front, Color back)

Sets the colors of the button and it's text to front and back. Used by CGUIMessageBox.setColors() for already registered buttons and texts.

bool isMouseOver(float mousex, float mousey)

Returns true if mousex, mousey is placed in the buttons rectangle, seen from center of the screen.

void Draw()

Draws the button, seen from center of the screen.

class CGUIMessageBox

Message Boxes are drawn over all other GUI elements and need to be responded to get hidden.
There can only be ONE message box shown at a time.

static CGUIMessageBox? actualBox

The actually visible message box. Only one message box can be shown at a time, and this is the handle to it.
Null if no message box is shown.

void CGUIMessageBox(int funcnum, int funcval, Color? col, Color? backcol)

Creates a the messagebox.
The messagebox will be hidden after a click somewhere on the screen, if there are NO buttons in the message box.
Else it will be hidden after a click on one of the buttons.
funcnum and funcval are used in IGame.onGUI() after a click on the box, if there are NO buttons in the messagebox.
Use addText and addButton to create text and buttons of the messagebox.

void setColors(Color front, Color back)

Sets the colors of this message box, and all of its texts and buttons.

List getButtonList()

Returns a list with all registered buttons for this message box. The list consists of CGUIButtons.

void addText(string text, float setx, float sety, Color? col)

Adds a text to the messagebox at setx, sety seen from the center of the screen. If col is null, it will take the message box front color.

void addButton(int funcnum, int funcval, string text, float x, float y, float w, float h, Color? front, Color? back)

Creates and adds a CGUIButton to the message box, with the function number funcnum, function value funcval (received in IGame.onGUI()) atx, y (seen from center of the screen) with the width w and height h and colors front and back (set to the message box colors if null).

void addButton(CGUIButton btn)

Adds the button btn to the message box.

void Draw()

Draws the message box. You don't need to use this, just set the actualBox with GUI.showMessagebox().

enum eMainMenuAlignement

Defines in which corner of the screen a main menu button or a menu is positioned.
The first position is taken if the screen height is bigger than the screen width (mobile phone), the second position is taken when the screen width is bigger than the screen height (tablet).
Members are: TOPLEFT_OR_LEFTTOP, TOPRIGHT_OR_LEFTBOTTOM, BOTTOMLEFT_OR_RIGHTTOP, BOTTOMRIGHT_OR_RIGHTBOTTOM

class CGUIMainMenuButton

A button which is positioned in one of the corners (+ positionidx) of the screen.
Create and add them to the GUI with GUI.addMainMenuItem().
The buttons will be handled by the engine then. Use IGame.onGUI() to handle them in your App.

More about them at GUI.addMainMenuItem().

class CGUIMenu

A menu aligned to a specific CGUIMainMenuButton (respective its alignement and posidx), consisting of CGUIMenuItems.
There can be only one menu visible at a time.

static CGUIMenu? actualMenu

The actually shown menu. Set it with GUI.showMenu().

List itemList

The list with all menu entries of that menu.

CGUIMenu(eMainMenuAlignement align, int posidx, float width, float itmheight)

Creates the menu aligned to the screen corner align at button position posidx with the width width and height itmheight of one item.

CGUIMenuItem addItem(string text, int funcnum, int funcval)

Adds an item with the text text, which returns funcnum and funcval to IGame.onGUI() when clicked - and returns it.

void clear()

Removes all the items of this menu.

...you don't need to know about the rest of it.

class CGUIMenuItem

A menu item which is created with CGUIMenu.addItem()


Related

Wiki: APK_DOTNET_MAUI