Game Menu

GameMenu is set of game control buttons organized in tree by groups and subgroups.



You can access to GameMenu by fv.core.GameMenu. The most interesting thing is model field of this class (fv.core.GameMenu.model). Model represents button's hierarchy and can be modified at mod's loading time.

At low level model is just a tree of nodes. Where each node is a regular lua table that represents button and contains some fields such as: name, icon, tooltip, onClick, childs and some other. The main node is available by root field. So, you can inspect and modify tree manually:

local model = fv.core.GameMenu.model for i, node in ipairs (model.root.childs) do    if node.name == 'food' then table.remove (model.root.childs, i)       break end end

Model also provides some useful functions to adding new content.

local model = fv.core.GameMenu.model model:regGroup( "decorations", "GameLook1/iconDecor" , "@btnDecorate@" ) model:regBuilding(Pointer1, "decorations.pointer1", "GameLook1/iconpointer1" , "@pricePointer1@" )

regGroup
function MenuModel:regGroup(fullName, icon, tooltip, priority)

Function for adding group button (that contains other buttons).


 * fullName is name of group. If it is nested group it must include full path. For instance, "decorations.flowers".
 * icon is name of icon for button.
 * tooltip is tooltip message for button.
 * priority is optional number. It is used for order buttons inside group. Can be fractional.

regButton
function MenuModel:regButton(fullName, icon, tooltip, priority, onClick, isSelectedFunc)

Function for adding button (end node).


 * fullName is name of button. It must include full path. For instance, "decorations.flowers.rose".
 * icon is name of icon for button.
 * tooltip is tooltip message for button.
 * priority is optional number. It is used for order buttons inside group. Can be fractional.
 * onClick is function that will be called on button click.
 * isSelectedFunc is function that check is button highlighted (return true or false).

regBuilding
function MenuModel:regBuilding(building, fullName, icon, tooltip, priority)

Function for adding building button.


 * building is building Class. Alternatively you can pass list of classes for random selection in game. Possible syntax:
 * Scarecrow1
 * {Scarecrow1, Scarecrow2}
 * "Scarecrow1,Scarecrow2"
 * fullName is name of button. It must include full path. For instance, "houses.cottage".
 * icon is name of icon for button.
 * tooltip is tooltip message for button.
 * priority is optional number. It is used for order buttons inside group. Can be fractional.