LordAshes-GUIMenuPlugin icon

GUIMenuPlugin

Add text/icon menus that appear in centre of screen or slide out the right side. Support for multi-layer hierarchy.

Last updated 8 months ago
Total downloads 9145
Total rating 0 
Categories Tweaks Tools Integration
Dependency string LordAshes-GUIMenuPlugin-1.2.0
Dependants 8 other packages depend on this package

This mod requires the following mods to function

bbepisTaleSpire-BepInExPack-5.4.10 icon
bbepisTaleSpire-BepInExPack

Unified BepInEx all-in-one modding pack - plugin framework, detour library

Preferred version: 5.4.10
brcoding-SetInjectionFlagPlugin-2.3.0 icon
brcoding-SetInjectionFlagPlugin

Allows players to flag mods are installed

Preferred version: 2.3.0

README

GUI Menu Plugin

This unofficial TaleSpire plugin allows the user to text and icon menus similar to the radial menu but in the centre of the screen or as a side out from the right side of the screen. The GUI Menu plugin allows any number of menu with links between any menus so you can construct anything from simple hierarchies to complex hierarchies.

Change Log

1.2.0: Added support for different sized icons and offsets
1.0.0: Initial release

Install

Use R2ModMan or similar installer to install this plugin.

Usage (User)

This plugin does not offer any direct functionality. Typically this will be installed as a dependency for some other plugin.
As such there is no user usage beyond that of what the parent plugin may provide.

Usage (Developer)

The GUI Menu Plugin uses a three tier hierarchy to create the menus: GuiMenu, MenuNode, two implementations of IMenuItem which are MenuLink and MenuSelection.

A GuiMenu holds the entire hierarchy for the menu. For example, if the main menu had two selections for two sub-menus then the GuiMenu object would hold all 3 Nodes (menus) - the main one and the two sub-menus.

A MenuNode holds all of the options for one particular menu. In the case of the example with two sub menus, there would be three MenuNodes - one for the main menu and one for each of the two sub-menus. MenuNodes hold IMenuItems are which there are two types: MenuLink and MenuSelection. They also hold additional internal information about the Node like the state.

IMenuItem is an interface for creating items that a menu (MenuNode) can contain. Currently there are two implementations of the IMenuIntem interface: MenuLink and MenuSelection. Most of the properties for these items are the same such as title, text color, texture, and gmOnly. However, each gave an addition property and perform a different task.

MenuLink has a link property. This property contains the name of a MenuNode and causes the current menu to be closed and the specified menu to be opened. Normally used to navigate from one menu to another such as from a parent menu to a child menu or from a child to a parent menu. However, the link feature is geenric so links can be made to any other MenuNode meaning that complex menus can jump from any menu to any other menu.

MenuSelection has a selection property. This property is contains the value that is sent to the callback when the item is selected.

While the GUI Menu Plugin does support a number of different ways to create the hierarchy of the GUI Menu, one of the simplest methods is show below:

GUIMenuPlugin.GuiMenu menu = new GUIMenuPlugin.GuiMenu(new GUIMenuPlugin.MenuNode[]
{
	new GUIMenuPlugin.MenuNode("Root", new GUIMenuPlugin.IMenuItem[]
    {
        new GUIMenuPlugin.MenuLink("Menu1","Menu1",UnityEngine.Color.red,FileAccessPlugin.Image.LoadTexture("Menu1.png"),false),
        new GUIMenuPlugin.MenuLink("Menu2","Menu2",UnityEngine.Color.red,FileAccessPlugin.Image.LoadTexture("Menu2.png"),false)
    }, GUIMenuPlugin.MenuStyle.centre),

    new GUIMenuPlugin.MenuNode("Menu1", new GUIMenuPlugin.IMenuItem[]
    {
        new GUIMenuPlugin.MenuLink("Root","Back",UnityEngine.Color.red,FileAccessPlugin.Image.LoadTexture("Back.png"),false),
        new GUIMenuPlugin.MenuSelection("Item1","Item1",UnityEngine.Color.red,FileAccessPlugin.Image.LoadTexture("Item1.png"),false),
        new GUIMenuPlugin.MenuSelection("Item2","Item2",UnityEngine.Color.red,FileAccessPlugin.Image.LoadTexture("Item2.png"),false)
    }, GUIMenuPlugin.MenuStyle.centre),

    new GUIMenuPlugin.MenuNode("Menu2", new GUIMenuPlugin.IMenuItem[]
    {
        new GUIMenuPlugin.MenuLink("Root","Back",UnityEngine.Color.red,FileAccessPlugin.Image.LoadTexture("Back.png"),false),
        new GUIMenuPlugin.MenuSelection("Item3","Item3",UnityEngine.Color.red,FileAccessPlugin.Image.LoadTexture("Item3.png"),false),
        new GUIMenuPlugin.MenuSelection("Item4","Item4",UnityEngine.Color.red,FileAccessPlugin.Image.LoadTexture("Item4.png"),false)
    }, GUIMenuPlugin.MenuStyle.centre)
});

You can change the icon size and offset with:

GUIMenuPlugin.GuiMenu menu = new GUIMenuPlugin.GuiMenu(nodes, iconSize, offsetSize);

for example:

GUIMenuPlugin.GuiMenu menu = new GUIMenuPlugin.GuiMenu(nodes, 32, 36);

To draw the menu, do:

void OnGUI()
{
  if(menu!=null){ menu.Draw(); }
}

To open the menu, do:

menu.Open("Root", selectionCallback);

where Root is the name of the menu to open and selectionCallback is the function that is triggered when a selection is made.