The menu namespace contains many functions related to User Interface functionality inside of your script!
Declaration:
namespace menu{ // remove an element by it's labelvoidremove_element(string label); // toggle with a name and specified valuetoggle_t@ add_toggle(string label,bool value =false); // slider with a float value (uses C-style formatting, google "printf" formatting for more information) slider_float_t@ add_slider_float(string label, float min, float max, float value = 0.f, string format_text = "%.1f")
// slider with an integer value (uses C-style formatting, google "printf" formatting for more information)slider_int_t@ add_slider_int(string label,int min,int max,int value =0.f, string format_text ="%d"); // combo (aka. multi-select) with your specified elementscombo_t@ add_combo(string label, array<string>@ combo_elements,int value =0); // multi-combo, you will need to call set_value to set default values (if you wish)multi_combo_t@ add_multi_combo(string label, array<string>@ combo_elements); // specified text positioned automatically in the menulabel_t@ add_label(string label); // separator between elementsdivider_t@ add_divider(string label); // seperator with a label in the middlelabel_divider_t@ add_label_divider(string label); // button that can be clicked to call your codebutton_t@ add_button(string label); // colorpicker to allow custom coloring of anythingcolorpicker_t@ add_colorpicker(string label); // add a keybind which allows you to easily create per-key functionskeybind_t@ add_keybind(string label,bind_t&in bind);}
Information:
All of these functions should be called in the beginning of your script, and not a callback! They will add/remove from the "elements" subtab in the "scripting" tab!
Examples:
Creating a button with a function that gets called on click which adds to a value
// create a button and increment a value when it's clickedauto my_button = menu::add_button("Click me!");auto my_value =1; // start with oneauto did_alert =false;// add 1 to "my_value"voidmy_button_callback() { my_value +=1; }// register the callback with the buttonmy_button.set_interaction_callback(my_button_callback);// check if "my_value" is 3 and if so, alert the uservoidrender(){if (m_value ==3&&!did_alert) { cheat::add_log("my_value is 3!"); did_alert =true; }}
Creating a combo and a multi-combo and checking their values
auto my_combo = menu::add_combo("My combo", { "One","Two","Three" });auto my_multi_combo = menu::add_combo("My multi-combo", { "Option 1","Option 2" });// check if "my_combo" has "three" selected// also check if "my_multi_combo" has all options selectedvoidrender(){ // counting starts from 0if (my_combo.get_value() ==2) { /* run your code */ } // multi-combos take an "idx" parameter in their "get_value" functionif (my_multi_combo.get_value(0) &&my_multi_combo.get_value(1)) { /* both options are selected, run code */ }}