Menu creation
To create menu in your plugin, you have to initialize root tab.
You have to do it only once, best option is to do it in load function after global deleraction.
Menu global variable is called menu.
Class deleraction
class tree_menu
{
public:
// Delete tab and associated elements and sub tabs
//
virtual bool delete_tab( TreeTab* tab ) = 0;
virtual bool delete_tab( std::string _key ) = 0;
// Create or get (if existing) root tab of menu
//
virtual TreeTab* create_tab( std::string key, std::string name ) = 0;
// Get root tab
//
// nullptr - if dosen't exists
//
virtual TreeTab* get_tab( std::string key ) = 0;
};
Example:
Also remember to remove root tab (if created) while unloadingMenu elements
TreeEntry
Every menu element is inheriting TreeEntry
class TreeEntry
{
public:
virtual ~TreeEntry( );
// Returns bool value of element
//
// TreeTab*
// Returns false if assigned_active is not specify otherwise it returns assigned_active current value
//
// TreeHotkey*
// Returns current hotkey_state
//
// TreeCheckbox*
// Returns true if checkbox is checked
//
// Other types of menu element returns false
//
virtual bool get_bool( );
// Returns integer value of element
//
// TreeSlider*
// Returns current slider value
//
// TreeDisplayInt*
// Returns current display value
//
// TreeCombobox*
// Returns selected index
//
// TreeHotkey*
// Returns associated virtual key to hotkey
//
// TreeColorPicker*
// Returns current color value from picker
//
// Other types of menu element returns 0
//
virtual std::int32_t get_int( );
// Returns color value of element
//
// TreeColorPicker*
// Returns current color value from picker
//
// Other types of menu element returns 0
//
virtual std::uint32_t get_color( );
// Returns pair <prority, active> value of element
//
// TreeProrityList*
// Returns pair <prority, active> of element associated with given key.
// If given key wasn't found return value is {-1, false}
// If given key was found return value is {i, active}
// Where i = index (from 0) on list, top is 0, bottom is elements size - 1
// active = element checked, always true if always_active option is true while creating
//
// Other types of menu element returns {-1, false}
//
virtual std::pair<std::int32_t, bool> get_prority( std::uint32_t key );
// Gets string value of element
//
// TreeTextInput*
// Returns current value of input
//
virtual const std::string& get_string( );
// Gets hotkey type
//
// TreeHotkey*
// Returns current hotkey type toggle/hold
//
virtual std::int32_t get_hotkey_type( );
// Sets bool value of element
//
// See get_bool function for supported elements
//
virtual void set_bool( bool value );
// Sets int value of element
//
// See get_int function for supported elements
//
virtual void set_int( std::int32_t value );
// Sets new list for combo element
//
// See creation of TreeCombobox for more details
//
// Use reset_index if you want to sets current element and scrollbar to 0
//
virtual void set_combo( const std::vector<std::pair<std::string, void*>>& list, bool reset_index = true );
// Sets texture to current menu element
//
// Supported types
// TreeImage*
// TreeCheckbox*
// TreeTab*
//
virtual void set_texture( void* texture );
// Sets string to current menu element
//
// Supported types
// TreeTextInput*
//
virtual void set_string( const std::string& );
// Sets color to current menu element
//
// Supported types
// TreeColorPicker*
//
virtual void set_color( float* color );
// Determines if element is hidden
//
// This function returns reference so you can change the value itself
// element->is_hidden() = true;
//
virtual bool& is_hidden( );
// Determines if element should be saved after new session
//
// This function returns reference so you can change the value itself
// You can also specify this value while creating element
//
virtual bool& should_save( );
// Gets display name of element
//
virtual const std::string& display_name( );
// Gets key of element
//
virtual const std::string& key( );
// Gets config path of element
//
virtual const std::string& config_key( );
// Gets element type
//
virtual std::int32_t element_type( );
// Add property change callback
//
// See PropertyChangeCallback section to more information
//
virtual void add_property_change_callback( PropertyChangeCallback callback );
// Remove property change callback
//
// See PropertyChangeCallback section to get more information
//
virtual void remove_property_change_callback( PropertyChangeCallback callback );
// Gets tooltip of element
//
virtual const std::string& tooltip( );
// Sets display name of element
//
virtual void set_display_name( const std::string& display_name );
// Sets tooltip of element
//
// See Tooltip section to get more information
//
virtual void set_tooltip( const std::string& tooltip );
// Apply filter for TreeCombobox
//
// Use only when you want to re apply filter
//
virtual void apply_filter( );
// Apply filter for TreeCombobox
//
// You can combine it with TreeTextInput
//
virtual void apply_filter( const std::string& filter, bool ignore_case, bool save_filter = true );
// Reserved for core
//
virtual void reserved_0( );
virtual void reserved_1( );
};
TreeTab
class TreeTab: public TreeEntry
{
public:
// Gets menu element by key, only for this tab
//
// If not found returns nullptr
//
virtual TreeEntry* get_entry( const std::string& key );
// Creates or gets (if already exists and type is TreeTab) menu element
//
// See TreeTab element to get more information
//
virtual TreeTab* add_tab( const std::string& key, const std::string& name );
// Creates or gets (if already exists and type is TreeSeperator) menu element
//
// See TreeSeperator element to get more information
//
virtual TreeEntry* add_separator( const std::string& key, const std::string& name );
// Creates or gets (if already exists and type is TreeHotkey) menu element
//
// See TreeHotkey element to get more information
//
virtual TreeEntry* add_hotkey( const std::string& key, const std::string& name, const std::int32_t& type, const std::int32_t& vkey, const bool& default_value, const bool& should_save = true );
// Creates or gets (if already exists and type is TreeCheckbox) menu element
//
// See TreeCheckbox element to get more information
//
virtual TreeEntry* add_checkbox( const std::string& key, const std::string& name, const bool& default_value, const bool& should_save = true );
// Creates or gets (if already exists and type is TreeSlider) menu element
//
// See TreeSlider element to get more information
//
virtual TreeEntry* add_slider( const std::string& key, const std::string& name, const int32_t& default_value, const std::int32_t& min, const std::int32_t& max, const bool& should_save = true );
// Creates or gets (if already exists and type is TreeDisplayInt) menu element
//
// See TreeDisplayInt element to get more information
//
virtual TreeEntry* add_display_value( const std::string& key, const std::string& name, std::int32_t* value );
// Creates or gets (if already exists and type is TreeCombobox) menu element
//
// See TreeCombobox element to get more information
//
virtual TreeEntry* add_combobox( const std::string& key, const std::string& name, const std::vector<std::pair<std::string, void*>>& combo_elements, const std::int32_t& default_value, const bool& should_save = true );
// Creates or gets (if already exists and type is TreeColorPicker) menu element
//
// See TreeColorPicker element to get more information
//
virtual TreeEntry* add_colorpick( const std::string& key, const std::string& name, std::array<float, 4> const& default_color, const bool& should_save = true );
// Creates or gets (if already exists and type is TreeColorPicker) menu element
//
// See TreeColorPicker element to get more information
//
virtual TreeEntry* add_colorpick( const std::string& key, const std::string& name, float default_color[ 4 ], const bool& should_save = true );
// Creates or gets (if already exists and type is TreeProrityList) menu element
//
// See TreeProrityList element to get more information
//
virtual TreeEntry* add_prority_list( const std::string& key, const std::string& name, const std::vector<ProrityCheckItem>& prority_elements, const bool& always_active = true, const bool& should_save = true );
// Creates or gets (if already exists and type is TreeImage) menu element
//
// See TreeImage element to get more information
//
virtual TreeEntry* add_image_item( const std::string& key, void* texture, const std::int32_t& height );
// Creates or gets (if already exists and type is TreeTextInput) menu element
//
// See TreeTextInput element to get more information
//
virtual TreeEntry* add_text_input( const std::string& key, const std::string& name, const std::string& default_value, const bool& should_save = true );
// Creates or gets (if already exists and type is TreeButton) menu element
//
// See TreeButton element to get more information
//
virtual TreeEntry* add_button( const std::string& key, const std::string& name );
// Remove all sub elements of this tab
//
// After clear menu elements created with this tab will be invalid and you can't use them
//
virtual void clear( );
// Sets if user is able to use revert function (right click) on this tab
//
// Default: false
//
virtual void set_revert_enabled( bool enabled );
// Sets assigned texture for this tab
//
// Function is same as set_texture from TreeEntry
//
virtual void set_assigned_texture( void* texture );
// Sets assigned active for this tab
//
// You can use bool pointer or TreeEntry pointer
//
// TreeEntry must be type of TreeCheckbox
//
virtual void set_assigned_active( TreeEntry* active );
virtual void set_assigned_active( bool* active );
// Reserved for core
//
virtual void reserved_3( );
};
Key has to be unique for this tab. Key is used to create config path and as unique identifier.
Name is just display name, it can be duplicated.
When create, tab will be attached at the end of elements list.
Unique functions for TreeTab:
TreeSeperator
// Element must be type of TreeTab
//
seperator = element->add_separator("settingsQ", "Q Settings");
See TreeTab for key, name explanation
You can use PropertyChangeCallback on this type, see PropertyChangeCallback to get more information.
TreeButton
See TreeTab for key, name explanation
You can use PropertyChangeCallback on this type, see PropertyChangeCallback to get more information.
TreeHotkey
virtual TreeEntry* add_hotkey( const std::string& key, const std::string& name, const std::int32_t& type, const std::int32_t& vkey, const bool& default_value, const bool& should_save = true );
//Element must be type of TreeTab
hotkey = element->add_hotkey( "someMode", "Enable mode", TreeHotkeyMode::Toggle, 0x41 /*A key*/, false );
See TreeTab for key, name explanation
Supported types: * TreeHotkeyMode::Hold - active when user keep holding a key * TreeHotkeyMode::Toggle - active toggles when user click key
Vkey it's virtual key code, to get proper vkey value see VKey Codes
Default value determines what is default state for hotkey * TreeHotkeyMode::Hold - it's always false, this option dosen't matter for that type * TreeHotkeyMode::Toggle - enabled if default value is true
Should save determines if option should be saved between games for this type we recommend you to do not change it to false
You can use PropertyChangeCallback on this type, see PropertyChangeCallback to get more information.
TreeCheckbox
virtual TreeEntry* add_checkbox( const std::string& key, const std::string& name, const bool& default_value, const bool& should_save = true );
See TreeTab for key, name explanation
Default value determines if checkbox is checked
Should save determines if option should be saved between games for this type we recommend you to do not change it to false
For TreeCheckbox you can call set_texture:
TreeSlider
virtual TreeEntry* add_slider( const std::string& key, const std::string& name, const int32_t& default_value, const std::int32_t& min, const std::int32_t& max, const bool& should_save = true );
//Element must be type of TreeTab
slider = element->add_slider( "manaUseW", "Min mana to use W", 40, 0, 100 );
Default value for slider must be between min and max
Min value has to be integer and be smaller than max
Max value has to be integer and be higher than min
Should save determines if option should be saved between games for this type we recommend you to do not change it to false
You can use PropertyChangeCallback on this type, see PropertyChangeCallback to get more information.
TreeDisplayInt
virtual TreeEntry* add_display_value( const std::string& key, const std::string& name, std::int32_t* value );
//Element must be type of TreeTab
display_int = element->add_display_value( "someValue", "Some value", &someValue );
See TreeTab for key, name explanation
Value must be a valid pointer to integer value
TreeCombobox
virtual TreeEntry* add_combobox( const std::string& key, const std::string& name, const std::vector<std::pair<std::string, void*>>& combo_elements, const std::int32_t& default_value, const bool& should_save = true );
//Element must be type of TreeTab
combobox = element->add_combobox( "mode", "Current mode", { { "Fast" , nullptr }, {"Normal", myhero->get_square_icon_portrait( )}, {"Slow", nullptr} }, 0 );
Combo elements is a vector of std::pair where
- First is combo element display name
- Second is texture pointer for element, could be nullptr (optional parametr)
Default value is default index of combo elements
Should save determines if option should be saved between games for this type we recommend you to do not change it to false
You can use PropertyChangeCallback on this type, see PropertyChangeCallback to get more information.
TreeColorPicker
virtual TreeEntry* add_colorpick( const std::string& key, const std::string& name, std::array<float, 4> const& default_color, const bool& should_save = true );
virtual TreeEntry* add_colorpick( const std::string& key, const std::string& name, float default_color[ 4 ], const bool& should_save = true );
//Element must be type of TreeTab
colorpicker = element->add_colorpick( "color", "Draw color", { 1.f, 0.f, 0.f, 1.f } );
float color[] = { 0.f, 1.f, 0.f, 1.f };
colorpicker2 = element->add_colorpick( "color2", "Draw color2", color );
See TreeTab for key, name explanation
Default color is array of 4 floats which are
- R (Red from 0.f - 1.f)
- 0.f = 0
- 1.f = 255
- G (Green from 0.f - 1.f)
- 0.f = 0
- 1.f = 255
- B (Blue from 0.f - 1.f)
- 0.f = 0
- 1.f = 255
- A (Alpha from 0.f - 1.f)
- 0.f = 0
- 1.f = 255
Should save determines if option should be saved between games for this type we recommend you to do not change it to false
colorpicker color here
You can use PropertyChangeCallback on this type, see PropertyChangeCallback to get more information.
TreeProrityList
virtual TreeEntry* add_prority_list( const std::string& key, const std::string& name, const std::vector<ProrityCheckItem>& prority_elements, const bool& always_active = true, const bool& should_save = true );
struct ProrityCheckItem
{
std::uint32_t key;
std::string display_name;
bool is_active = false;
void* assigned_texture = nullptr;
};
//Element must be type of TreeTab
prority_list = element->add_prority_list( "attackPrority", "Prority list", { { 0, "Champions" }, { 1, "Minions" }, { 2, "Jungle mob" } } );
See TreeTab for key, name explanation
Prority elements is a vector of ProrityCheckItem
- ProrityCheckItem
- Key must be unique identifier for current prority list
- Display name is item display name
- Is active option is used only when always_active parametr is false, you can specify if item is enabled by default (optional parametr)
- Assigned texture is texture for item, see Per champion menu for usage (optional parametr)
Default order is by order of elements in vector.
Always active determines if prority element can be disabled/enabled by user
always_active = true
always_active = false
Should save determines if option should be saved between games for this type we recommend you to do not change it to false
You can use PropertyChangeCallback on this type, see PropertyChangeCallback to get more information.
TreeImage
virtual TreeEntry* add_image_item( const std::string& key, void* texture, const std::int32_t& height );
//Element must be type of TreeTab
image = element->add_image_item( "championImage", myhero->get_square_icon_portrait( ), 150 );
See TreeTab for key explanation
Texture is pointer to texture
Height is height of texture where width is adjusted to width of current tab
tree image sample
TreeTextInput
virtual TreeEntry* add_text_input( const std::string& key, const std::string& name, const std::string& default_value, const bool& should_save = true );
You can use PropertyChangeCallback on this type, see PropertyChangeCallback to get more information.
Menu utils
PropertyChangeCallback
For most menu elements you can add/remove property change callback.
It gets called whenever value or setting of element changes. Callback typdef
Example:
You don't have to remove callback while unloading, when you delete root tab it also delete all callbacks from elements.List of supported elements:
- TreeSeperator*
- TreeButton*
- Called when user click on seperator/button
- TreeCombobox*
- Called when user change selected index
- TreeSlider*
- Called when user change slider value
- TreeCheckbox*
- Called when user change value of checkbox
- TreeHotkey*
- Called when user change associated virtual key
- Called when user change hotkey type
- Called when hotkey state changes
- TreeColorPicker*
- Called when user change color
- TreeProrityList*
- Called when user change active state any of element
- Called when user swap any of element
- TreeTab*
- Called when user click revert on tab
Tooltip
For every menu element you can specify tooltip.
To disable tooltip just pass empty string to set_tooltip function.
By default tooltip is empty.
tooltip sample image
Per champion menu
To create menu elements which depends on champions in game you have to keep some guidelines.
When you use network id as key in menu element should_save parameter must be false.
TreeCheckbox
To create checkbox list which depends on champions you can simple create
Where key is champion network id and TreeEntry* is corresponding menu element
Example:
std::map<std::uint32_t, TreeEntry*> use_r_on;
bool can_use_r_on( game_object_script target )
{
auto it = use_r_on.find( target->get_network_id( ) );
if ( it == use_r_on.end( ) )
return false;
return it->second->get_bool( );
}
... in load function
auto use_r_on_tab = orbwalker_menu->add_tab( "use_r", "Use R On" );
{
for ( auto&& enemy : entitylist->get_enemy_heroes( ) )
{
// In this case you HAVE to set should save to false since key contains network id which is unique per game
//
use_r_on[ enemy->get_network_id( ) ] = use_r_on_tab->add_checkbox( std::to_string( enemy->get_network_id( ) ), enemy->get_model( ), true, false );
// Set texture to enemy square icon
//
use_r_on[ enemy->get_network_id( ) ]->set_texture( enemy->get_square_icon_portrait( ) );
}
}
... in logic code
if ( can_use_r_on( target ) )
{
// Do something
//
}
example of netid tree
TreeCombobox
It's very similar to TreeCheckbox.
In for loop
// In this case you HAVE to set should save to false since key contains network id which is unique per game
//
use_r_on[ enemy->get_network_id( ) ] = use_r_on_tab->add_combobox( std::to_string( enemy->get_network_id( ) ), enemy->get_model( ), { {"Always", nullptr }, {"Killsteal" , nullptr}, {"Never", nullptr} }, 0, false );
std::int32_t use_r_on_mode( game_object_script target )
{
auto it = use_r_on.find( target->get_network_id( ) );
if ( it == use_r_on.end( ) )
return false;
return it->second->get_int( );
}
... in logic code
auto mode = use_r_on_mode( target );
if ( mode == 0) //Always
{
// Do something
//
} else if ( mode == 1) //Killsteal
{
// Do something
//
} else if ( mode == 2) //Never
{
// Do something
//
}
tree combobox sample
TreeProrityList
TreeEntry* use_r_prority = nullptr;
game_object_script get_best_target_prority( const std::vector<game_object_script>& possible_targets )
{
std::vector<std::pair<game_object_script, std::int32_t>> valid_targets;
for ( auto&& target : possible_targets )
{
auto target_prority = use_r_prority->get_prority( target->get_network_id( ) );
if ( target_prority.first == -1 || !target_prority.second )
continue;
valid_targets.push_back( { target, target_prority.first } );
}
std::sort( valid_targets.begin( ), valid_targets.end( ), [](const std::pair<game_object_script, std::int32_t>& a, const std::pair<game_object_script, std::int32_t>& b )
{
// Sort by prority value
//
// First in vector = top
//
return a.second < b.second;
} );
// Return best target
//
// If list is empty return nullptr
//
return valid_targets.empty( ) ? nullptr : valid_targets.front( ).first;
}
... in load function
{
std::vector<ProrityCheckItem> prority_items;
for ( auto&& enemy : entitylist->get_enemy_heroes( ) )
{
prority_items.push_back( { enemy->get_network_id( ), enemy->get_model( ), true, enemy->get_square_icon_portrait( ) } );
}
// In this case you HAVE to set should save to false since prority key contains network id which is unique per game
//
use_r_prority = orbwalker_menu->add_prority_list( "use_r_on", "Use R On", prority_items, false, false );
}
... code logic
auto best_target = get_best_target_prority( targets );
if ( best_target )
{
// Do something
//
}