Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Clientside] Simple menu framework
#1
Simple Menu Framework

It is easy to use menu framework with labels/textbox and mouse support!

Function list:
Code:
Menu::Menu(x, y, font, lineHeight) //Create menu
int Menu::addOption(name, onclick_function) //Add option to existing menu, returns optionID
int Menu::addTextBox(value, onclick_function) //Add textbox to existing menu, returns optionID
void Menu::show() //Shows menu
void Menu::hide() //Hide menu
void Menu::clear() //Experimental, destroying all draws and options, can be used for dynamic menu
array Menu::m_Options[] //Options list in current menu
int Menu::m_Option //Current option
bool Menu::m_Visible //Is menu visible?
New event:
Code:
onMenuChangeSelection(menu)
Example script (menu.nut):

Code:
local myMenu = 0;
local option1 = 0;
local textbox = 0;

addEvent("onInit", function()
{
    myMenu = Menu(6000, 2000, "Font_Old_10_White_Hi.TGA", 130);
    
    option1 = myMenu.addOption("Option1", function(menu)
    {
        print("You clicked first option");
    });
    
    textbox = myMenu.addTextBox("Your text here", function(menu)
    {
        //Get value of current option
        local text = menu.m_Options[menu.m_Option].name;
        print("Your text: " + text);
    });
});

addEvent("onKey", function(key, letter)
{
    if(key == KEY_F1)
        if(myMenu.m_Visible == false)
            myMenu.show();
        else myMenu.hide();
});

addEvent("onMenuChangeSelection", function(menu)
{
    if(menu == myMenu)
    {
        if(menu.m_Option == option1)
            print("Set to: Option1");
        if(menu.m_Option == textbox)
            print("Set to: textbox");
    }
});
How to use it?
Just put in your config.xml
Code:
<script src="simple-menu-framework.nuc" type="client" />
before your script. And put simple-menu-framework.nuc in client-scripts folder.

Download:

Donate me via PayPal: [email protected]
Reply
#2
Link updated.
[Image: CPCFNwD.png]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [New G2O][Client] GUI.Framework Patrix 0 3,151 07.02.2019, 01:39
Last Post: Patrix
  GUI Framework 2.0 Osmith 7 9,623 27.01.2018, 15:01
Last Post: Osmith
  [clientside][dev 8] Simple menu framework Nubzior 1 4,197 07.04.2017, 16:20
Last Post: Son Goku

Forum Jump:


Users browsing this thread: 1 Guest(s)