AlpacaLibrary/Include/Game/Interfaces/Menu.hpp

304 lines
15 KiB
C++
Raw Normal View History

2017-12-25 23:49:48 +00:00
#ifndef MENU_HPP_INCLUDED
#define MENU_HPP_INCLUDED
#include "../../Core/Types/Box.hpp"
#include <cstdint>
#include <string>
#include <vector>
/** @addtogroup Interfaces
* @{ */
2018-05-15 03:41:51 +00:00
/**
* @brief A class containing various functions for the right-click menu
*/
2017-12-25 23:49:48 +00:00
class Menu
{
public:
2018-05-11 03:38:30 +00:00
2018-05-10 01:08:38 +00:00
/**
* @brief Returns true if the right-click menu is open
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @return true if the right-click menu is open
*/
2017-12-25 23:49:48 +00:00
static bool IsOpen();
2018-05-10 01:08:38 +00:00
/**
* @brief Opens the menu by right-clicking wherever the mouse currently is
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @return true if the menu is currently open or opened by right clicking
* @return false if WaitFunc fails - WaitFunc(1000, 100, Menu::IsOpen, true);
* @note Implements an %Interactable delay if succesful
*/
2017-12-25 23:49:48 +00:00
static bool Open();
2018-05-10 01:08:38 +00:00
/**
* @brief Closes the menu by moving the mouse to either left or right of the menu, uses the current mouse position as a base point
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @return true if the menu isn't open, or closed by moving the mouse
* @return false if the generated point is off-screen, or WaitFunc fails - WaitFunc(1000, 100, Menu::IsOpen, false);
* @note Implements an %Interactable delay if succesful
*/
static bool Close();
/**
* @brief Get the number of menu options
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @return the number of menu options
2018-05-15 03:41:51 +00:00
* @note The menu does not need to be open for this to be accurate
2018-05-10 01:08:38 +00:00
*/
2017-12-25 23:49:48 +00:00
static std::int32_t GetCount();
2018-05-10 01:08:38 +00:00
/**
* @brief Get the raw, un-filtered menu actions
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @description By default the game includes html code in menu actions/targets
* This function returns those actions without the removal of the html code
2018-05-15 03:41:51 +00:00
* @return std::vector<std::string> of raw menu actions
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
2018-04-18 05:50:40 +00:00
static std::vector<std::string> GetActionsRaw();
2018-05-10 01:08:38 +00:00
/**
* @brief Get the raw, un-filtered menu targets
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @description By default the game includes html code in menu actions/targets
* This function returns those targets without the removal of the html code
2018-05-15 03:41:51 +00:00
* @return std::vector<std::string> of targets
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
2017-12-25 23:49:48 +00:00
static std::vector<std::string> GetTargetsRaw();
2018-05-10 01:08:38 +00:00
/**
* @brief Get the menu actions
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @description Actions are almost always the very first word in a menu option
* 'Use' - action 'gold bar' - target
* 'Attack' - action 'Guard (level-21)' - target
* @return std::vector<std::string> array of menu actions
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
static std::vector<std::string> GetActions();
/**
* @brief Get the menu targets
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @description Targets are almost always everything after the action
* 'Use' - action 'gold bar' - target
* 'Attack' - action 'Guard (level-21)' - target
* @return std::vector<std::string> array of menu targets
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
2017-12-25 23:49:48 +00:00
static std::vector<std::string> GetTargets();
2018-05-10 01:08:38 +00:00
/**
* @brief Get the menu options
2018-05-11 03:38:30 +00:00
*
* @description
2018-05-10 01:08:38 +00:00
* 'Use' - action 'gold bar' - target
* 'Attack' - action 'Guard (level-21)' - target
* 'Use gold bar' - option
* 'Attack Guard (level-21)' - option
* @return std::vector<std::string> array of menu options
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
2017-12-25 23:49:48 +00:00
static std::vector<std::string> GetOptions();
2018-05-10 01:08:38 +00:00
/**
* @brief Get the index of the found option
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @description This function will find the first menu option containing the string 'Option'
* This means passing 'Att' or 'Attack' will return the first found menu option containing 'Att' or 'Attack'
* If you want to find a very specific menu option, the more the 'Option' string contains, the more specific it'll be
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* Say for example, you want to attack a guard whose level is 40, and on this one tile, there's 5 different guards, all with different levels
* If you pass 'Attack' as the 'Option' to look for, it'll select the very first guard, regardless of level.
* If you pass 'Attack Guard (level-40)' as the 'Option' to look for, it'll attack the guard whose level is 40.
2018-05-15 03:41:51 +00:00
* @param Option %Menu option to look for, can be very specific, or very lenient
2018-05-16 19:35:55 +00:00
* @return std::int32_t The index of the first found option, -1 if the option wasn't found
2018-05-10 01:08:38 +00:00
* @note Notice that 'Attack Guard (level-40)' has a double space after 'Guard', menu options can vary, in this case the menu option i'm looking for
* has a double space after 'Guard'.
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
static std::int32_t IndexOf(const std::string& Option);
/**
* @brief Get the index of the first found option
2018-05-11 03:38:30 +00:00
*
* @description This function will return the first found index, of the first found option.
2018-05-15 03:41:51 +00:00
* This function is just Menu::IndexOf(const std::string& Option), but instead of looking for one single option, this function looks for multiple
2018-05-11 03:38:30 +00:00
*
2018-05-15 03:41:51 +00:00
* @param %Options %Menu options to look for, returns on first option found, the more specific the options, the more accurate the result will be
2018-05-16 19:35:55 +00:00
* @return std::int32_t The index of the first found option, -1 if the option wasn't found
2018-05-10 01:08:38 +00:00
* @see Menu::IndexOf(const std::string& Option)
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
2018-05-11 03:38:30 +00:00
static std::int32_t IndexOf(const std::vector<std::string>& Options);
2018-05-10 01:08:38 +00:00
/**
* @brief Looks for a menu option at the passed index, and returns information about the found option
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @param Index The index of the menu option to look at
* @return std::tuple<bool, std::string, std::string>
2018-05-16 19:35:55 +00:00
* std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found
2018-05-10 01:08:38 +00:00
* std::string [1] = Action that was found at index
* std::string [2] = Target that was found at index
2018-05-11 03:38:30 +00:00
* @see Menu::IndexOf(const std::string& Option)
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
2018-05-10 14:03:33 +00:00
static std::tuple<std::int32_t, std::string, std::string> FindOption(std::uint32_t Index);
2018-05-10 01:08:38 +00:00
/**
* @brief Looks for a menu option containing the passed Option, and returns information about the found option
2018-05-11 03:38:30 +00:00
*
2018-05-15 03:41:51 +00:00
* @param Option %Menu option to look for, the more specific, the more accurate the result will be
2018-05-10 01:08:38 +00:00
* @return std::tuple<bool, std::string, std::string>
2018-05-16 19:35:55 +00:00
* std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found
2018-05-10 01:08:38 +00:00
* std::string [1] = Action that was found
* std::string [2] = Target that was found
2018-05-11 03:38:30 +00:00
* @see Menu::IndexOf(const std::string& Option)
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
2018-05-10 14:03:33 +00:00
static std::tuple<std::int32_t, std::string, std::string> FindOption(const std::string& Option);
2018-05-10 01:08:38 +00:00
/**
* @brief Looks for a menu option containing the passed Option, and returns information about the found option
2018-05-11 03:38:30 +00:00
*
2018-05-15 03:41:51 +00:00
* @param %Options %Menu options to look for, returns on first option found, the more specific the options, the more accurate the result will be
2018-05-10 01:08:38 +00:00
* @return std::tuple<bool, std::string, std::string>
2018-05-16 19:35:55 +00:00
* std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found
2018-05-10 01:08:38 +00:00
* std::string [1] = Action that was found
* std::string [2] = Target that was found
2018-05-15 03:41:51 +00:00
* @see Menu::IndexOf(const std::string& Options)
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
2018-05-15 03:41:51 +00:00
static std::tuple<std::int32_t, std::string, std::string> FindOption(const std::vector<std::string>& Options);
2018-05-10 14:03:33 +00:00
/**
* @brief Looks for a menu option containing the passed Option, and returns information of all options that were found
2018-05-11 03:38:30 +00:00
*
2018-05-15 03:41:51 +00:00
* @param Option %Menu option to look for, the more specific the option, the more accurate the result will be
2018-05-10 14:03:33 +00:00
* @return std::vector<std::tuple<std::int32_t, std::string, std::string>>
2018-05-16 19:35:55 +00:00
* std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found
2018-05-10 14:03:33 +00:00
* std::string [1] = Action that was found
* std::string [2] = Target that was found
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-11 03:38:30 +00:00
* @see Menu::IndexOf(const std::string& Option)
2018-05-10 14:03:33 +00:00
*/
static std::vector<std::tuple<std::int32_t, std::string, std::string>> FindOptions(const std::string& Option);
/**
* @brief Looks for a menu option containing the passed Option, and returns information of all options that were found
2018-05-11 03:38:30 +00:00
*
2018-05-15 03:41:51 +00:00
* @param %Options %Menu options to look for, if the option is found within the menu options, it'll be added to the result array, the more specific the options, the more accurate the result will be
2018-05-10 14:03:33 +00:00
* @return std::vector<std::tuple<std::int32_t, std::string, std::string>>
2018-05-16 19:35:55 +00:00
* std::int32_t [0] = Index of the option that was found, -1 if the option wasn't found
2018-05-10 14:03:33 +00:00
* std::string [1] = Action that was found
* std::string [2] = Target that was found
2018-05-15 03:41:51 +00:00
* @see Menu::IndexOf(const std::string& Options)
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 14:03:33 +00:00
*/
2018-05-15 03:41:51 +00:00
static std::vector<std::tuple<std::int32_t, std::string, std::string>> FindOptions(const std::vector<std::string>& Options);
2018-05-10 01:08:38 +00:00
/**
* @brief Returns true if the menu contains the passed Option
2018-05-11 03:38:30 +00:00
*
2018-05-15 03:41:51 +00:00
* @param Option %Menu option to look for, the more specific the option, the more specific the option, the more accurate the result will be
* @return true if the found index is valid (Index >= 0)
2018-05-10 01:08:38 +00:00
* @see Menu::IndexOf(const std::string& Option)
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
static bool Contains(const std::string& Option);
/**
* @brief Returns true if the menu contains at least one of the passed Options
2018-05-11 03:38:30 +00:00
*
2018-05-15 03:41:51 +00:00
* @param %Options %Menu options to look for, returns on first option found, the more specific the options, the more accurate the result will be
* @return true if the found index is valid (Index >= 0)
* @see Menu::IndexOf(const std::string& Options)
2018-05-16 19:35:55 +00:00
* @warning The result can be inaccurate if the menu isn't open before calling this function
2018-05-10 01:08:38 +00:00
*/
2018-05-11 03:38:30 +00:00
static bool Contains(const std::vector<std::string>& Options);
2018-05-10 01:08:38 +00:00
/**
* @brief Waits until the menu contains the passed option
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @param Duration How long to wait until returning
* @param Step How long to wait until it checks the menu options
2018-05-15 03:41:51 +00:00
* @param Option %Menu option to look for, the more specific the option, the more accurate the result will be
* @return true if the found index is valid (Index >= 0)
* @see Menu::IndexOf(const std::string& Option)
* @see Menu::Contains(const std::string& Option)
2018-05-10 01:08:38 +00:00
*/
static bool WaitContains(std::uint32_t Duration, std::uint32_t Step, const std::string& Option);
/**
* @brief Waits until the menu contains at leaset one of the passed options
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @param Duration How long to wait until returning
* @param Step How long to wait until it checks the menu options
2018-05-15 03:41:51 +00:00
* @param %Options %Menu options to look for, returns on first option found, the more specific the options, the more accurate the result will be
* @return true if the found index is valid (Index >= 0)
* @see Menu::IndexOf(const std::string& Options)
* @see Menu::Contains(const std::string& Options)
2018-05-10 01:08:38 +00:00
*/
static bool WaitContains(std::uint32_t Duration, std::uint32_t Step, const std::vector<std::string>& Options);
/**
* @brief Selects the menu option by the passed index if the menu is open
2018-05-11 03:38:30 +00:00
*
2018-05-10 01:08:38 +00:00
* @param Index The index of the option
* @param CloseMenu Close the menu if the function fails by using Menu::Close(), true by default
* @return true if the function selected the option by index
2018-05-15 03:41:51 +00:00
* @return false if the menu isn't open, the passed index is invalid (-1), the option box is off-screen, or the WaitFunc failed - WaitFunc(1000, 100, Menu::IsOpen, false)
2018-05-10 01:08:38 +00:00
* @note Implements an %Interactable delay if succesful
*/
static bool Select(std::int32_t Index, bool CloseMenu = true);
/**
* @brief Selects the passed menu option if the menu is open
2018-05-11 03:38:30 +00:00
*
2018-05-15 03:41:51 +00:00
* @param Option %Menu option to look for, the more specific the option, the more accurate the result will be
2018-05-10 01:08:38 +00:00
* @param CloseMenu Close the menu if the function fails by using Menu::Close(), true by default
* @return true if the function selected the option by option
2018-05-15 03:41:51 +00:00
* @return false if the menu isn't open, the found option was invalid, the option box is off-screen, or the WaitFunc failed - WaitFunc(1000, 100, Menu::IsOpen, false)
2018-05-10 01:08:38 +00:00
* @note Implements an %Interactable delay if succesful
* @see Menu::IndexOf(const std::string& Option)
*/
static bool Select(const std::string& Option, bool CloseMenu = true);
/**
* @brief Selects the first found option in the menu
2018-05-11 03:38:30 +00:00
*
2018-05-15 03:41:51 +00:00
* @param %Options %Menu options to look for, uses the first option found, the more specific the options, the more accurate the result will be
2018-05-10 01:08:38 +00:00
* @param CloseMenu Close the menu if the function fails using Menu::Close(), true by default
2018-05-11 03:38:30 +00:00
* @return true if the function selected the option by the first found option
2018-05-15 03:41:51 +00:00
* @return false if the menu isn't open, the found option was invalid, the option box is off-screen, or the WaitFunc failed - WaitFunc(1000, 100, Menu::IsOpen, false)
2018-05-10 01:08:38 +00:00
* @note Implements an %Interactable delay if succesful
2018-05-15 03:41:51 +00:00
* @see Menu::IndexOf(const std::string& Options)
2018-05-10 01:08:38 +00:00
*/
static bool Select(const std::vector<std::string>& Options, bool CloseMenu = true);
2017-12-25 23:49:48 +00:00
2018-05-10 01:08:38 +00:00
/**
* @brief Get the array of menu option boxes, each box is a menu option
2018-05-15 03:41:51 +00:00
* @return std::vector<Box> array of the menu option boxes, returns an empty array if the menu isn't open
2018-05-10 01:08:38 +00:00
*/
static std::vector<Box> GetOptionBoxes();
2017-12-25 23:49:48 +00:00
2018-05-10 01:08:38 +00:00
/**
* @brief Get the full menu box
2018-05-15 03:41:51 +00:00
* @return Box representing the full menu, returns a null box if the menu isn't open
2018-05-10 01:08:38 +00:00
*/
2017-12-25 23:49:48 +00:00
static Box GetBox();
};
/** @} */
#endif // MENU_HPP_INCLUDED