mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-23 04:27:25 +08:00
Lua: can make new tabs from lua scripts, doc generation for available tabs to use (#1593)
* lua api: add globals.get_uint and globals.set_uint * lua doc: remove duplicate function check as we can overload so it doesn't make sense * lua doc gen: add support for parsing the tabs enum * gui: custom lua tabs don't have a `func` rendering function but can still have elements to draw * lua doc: update generated doc * chore: code style * chore: minor spelling mistake * chore: code style * gui_service: add runtime removal of tabs * refactor: make it so that it's less likely defining tabs and their translation key in a wrong way. * lua api: ability to add custom tabs to the gui from lua
This commit is contained in:
parent
19f6487171
commit
76afd97185
@ -9,7 +9,7 @@ Class representing a gui text element.
|
||||
- **Parameters:**
|
||||
- `new_text` (string): The new text for that gui text element.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
base_text_element:set_text(new_text)
|
||||
```
|
||||
@ -19,7 +19,7 @@ base_text_element:set_text(new_text)
|
||||
- **Returns:**
|
||||
- `string`: Returns the current text for that gui text element.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
string = base_text_element:get_text()
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class representing a gui checkbox.
|
||||
- **Returns:**
|
||||
- `boolean`: Is the checkbox checked?
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = checkbox:is_enabled()
|
||||
```
|
||||
@ -21,7 +21,7 @@ boolean = checkbox:is_enabled()
|
||||
- **Parameters:**
|
||||
- `enabled` (boolean): The desired enabled state of the checkbox.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
checkbox:set_enabled(enabled)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class for representing an input field for editing a float value within the GUI.
|
||||
- **Returns:**
|
||||
- `float`: Get the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = input_float:get_value()
|
||||
```
|
||||
@ -21,7 +21,7 @@ float = input_float:get_value()
|
||||
- **Parameters:**
|
||||
- `val` (float): Set the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_float:set_value(val)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class for representing an input field for editing an integer value within the GU
|
||||
- **Returns:**
|
||||
- `integer`: Get the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = input_int:get_value()
|
||||
```
|
||||
@ -21,7 +21,7 @@ integer = input_int:get_value()
|
||||
- **Parameters:**
|
||||
- `val` (integer): Set the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_int:set_value(val)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class for representing an input field for editing a string value within the GUI.
|
||||
- **Returns:**
|
||||
- `string`: Get the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
string = input_string:get_value()
|
||||
```
|
||||
@ -21,7 +21,7 @@ string = input_string:get_value()
|
||||
- **Parameters:**
|
||||
- `val` (string): Set the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_string:set_value(val)
|
||||
```
|
||||
|
@ -8,7 +8,7 @@ Class representing a in-memory patch.
|
||||
|
||||
Apply the modified value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch:apply()
|
||||
```
|
||||
@ -17,7 +17,7 @@ lua_patch:apply()
|
||||
|
||||
Restore the original value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch:restore()
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Returns a memory instance, with the given address.
|
||||
- **Parameters:**
|
||||
- `address` (integer): Address
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
myInstance = pointer:new(address)
|
||||
```
|
||||
@ -28,7 +28,7 @@ Adds an offset to the current memory address and returns a new pointer object.
|
||||
- **Returns:**
|
||||
- `pointer`: new pointer object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = pointer:add(offset)
|
||||
```
|
||||
@ -43,7 +43,7 @@ Subs an offset to the current memory address and returns a new pointer object.
|
||||
- **Returns:**
|
||||
- `pointer`: new pointer object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = pointer:sub(offset)
|
||||
```
|
||||
@ -58,7 +58,7 @@ Rips the current memory address and returns a new pointer object.
|
||||
- **Returns:**
|
||||
- `pointer`: new pointer object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = pointer:rip(offset)
|
||||
```
|
||||
@ -70,7 +70,7 @@ Retrieves the value stored at the memory address as the specified type.
|
||||
- **Returns:**
|
||||
- `number`: the value stored at the memory address as the specified type.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_byte()
|
||||
```
|
||||
@ -82,7 +82,7 @@ Retrieves the value stored at the memory address as the specified type.
|
||||
- **Returns:**
|
||||
- `number`: the value stored at the memory address as the specified type.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_word()
|
||||
```
|
||||
@ -94,7 +94,7 @@ Retrieves the value stored at the memory address as the specified type.
|
||||
- **Returns:**
|
||||
- `number`: the value stored at the memory address as the specified type.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_dword()
|
||||
```
|
||||
@ -106,7 +106,7 @@ Retrieves the value stored at the memory address as the specified type.
|
||||
- **Returns:**
|
||||
- `float`: the value stored at the memory address as the specified type.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = pointer:get_float()
|
||||
```
|
||||
@ -118,7 +118,7 @@ Retrieves the value stored at the memory address as the specified type.
|
||||
- **Returns:**
|
||||
- `number`: the value stored at the memory address as the specified type.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_qword()
|
||||
```
|
||||
@ -130,7 +130,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (number): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_byte(value)
|
||||
```
|
||||
@ -142,7 +142,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (number): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_word(value)
|
||||
```
|
||||
@ -154,7 +154,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (number): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_dword(value)
|
||||
```
|
||||
@ -166,7 +166,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (float): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_float(value)
|
||||
```
|
||||
@ -178,7 +178,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (number): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_qword(value)
|
||||
```
|
||||
@ -190,7 +190,7 @@ Retrieves the value stored at the memory address as the specified type.
|
||||
- **Returns:**
|
||||
- `string`: the value stored at the memory address as the specified type.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
string = pointer:get_string()
|
||||
```
|
||||
@ -202,7 +202,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (string): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_string(value)
|
||||
```
|
||||
@ -219,7 +219,7 @@ The original value is restored when you call the restore function on the lua_pat
|
||||
- **Returns:**
|
||||
- `lua_patch`: memory patch instance for modifying the value at the memory address with the specified value. Can call apply / restore on the object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch = pointer:patch_byte(value)
|
||||
```
|
||||
@ -236,7 +236,7 @@ The original value is restored when you call the restore function on the lua_pat
|
||||
- **Returns:**
|
||||
- `lua_patch`: memory patch instance for modifying the value at the memory address with the specified value. Can call apply / restore on the object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch = pointer:patch_word(value)
|
||||
```
|
||||
@ -253,7 +253,7 @@ The original value is restored when you call the restore function on the lua_pat
|
||||
- **Returns:**
|
||||
- `lua_patch`: memory patch instance for modifying the value at the memory address with the specified value. Can call apply / restore on the object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch = pointer:patch_dword(value)
|
||||
```
|
||||
@ -270,7 +270,7 @@ The original value is restored when you call the restore function on the lua_pat
|
||||
- **Returns:**
|
||||
- `lua_patch`: memory patch instance for modifying the value at the memory address with the specified value. Can call apply / restore on the object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch = pointer:patch_qword(value)
|
||||
```
|
||||
@ -280,7 +280,7 @@ lua_patch = pointer:patch_qword(value)
|
||||
- **Returns:**
|
||||
- `boolean`: Returns true if the address is null.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = pointer:is_null()
|
||||
```
|
||||
@ -290,7 +290,7 @@ boolean = pointer:is_null()
|
||||
- **Returns:**
|
||||
- `boolean`: Returns true if the address is not null.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = pointer:is_valid()
|
||||
```
|
||||
@ -302,7 +302,7 @@ Dereferences the memory address and returns a new pointer object pointing to the
|
||||
- **Returns:**
|
||||
- `pointer`: A new pointer object pointing to the value at that address.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = pointer:deref()
|
||||
```
|
||||
@ -314,7 +314,7 @@ Retrieves the memory address stored in the pointer object.
|
||||
- **Returns:**
|
||||
- `number`: The memory address stored in the pointer object as a number.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_address()
|
||||
```
|
||||
|
@ -2,7 +2,25 @@
|
||||
|
||||
Class for representing a tab within the GUI.
|
||||
|
||||
## Functions (8)
|
||||
## Functions (10)
|
||||
|
||||
### `clear()`
|
||||
|
||||
Clear the tab of all its custom lua content that you own.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab:clear()
|
||||
```
|
||||
|
||||
### `add_tab()`
|
||||
|
||||
Add a sub tab to this tab.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab:add_tab()
|
||||
```
|
||||
|
||||
### `add_button(name, callback)`
|
||||
|
||||
@ -12,7 +30,7 @@ Add a button to the gui tab.
|
||||
- `name` (string): Text written inside the button.
|
||||
- `callback` (function): function that will be called when the button is clicked.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab:add_button(name, callback)
|
||||
```
|
||||
@ -27,7 +45,7 @@ Add text to the gui tab.
|
||||
- **Returns:**
|
||||
- `text`: The text object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
text = tab:add_text(name)
|
||||
```
|
||||
@ -42,7 +60,7 @@ Add a checkbox widget to the gui tab.
|
||||
- **Returns:**
|
||||
- `checkbox`: The checkbox object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
checkbox = tab:add_checkbox(name)
|
||||
```
|
||||
@ -54,7 +72,7 @@ Add a ImGui::SameLine.
|
||||
- **Returns:**
|
||||
- `sameline`: The sameline object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
sameline = tab:add_sameline()
|
||||
```
|
||||
@ -66,7 +84,7 @@ Add a ImGui::Separator.
|
||||
- **Returns:**
|
||||
- `separator`: The separator object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
separator = tab:add_separator()
|
||||
```
|
||||
@ -81,7 +99,7 @@ Add a ImGui::InputInt.
|
||||
- **Returns:**
|
||||
- `input_int`: The input_int object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_int = tab:add_input_int(name)
|
||||
```
|
||||
@ -96,7 +114,7 @@ Add a ImGui::InputFloat.
|
||||
- **Returns:**
|
||||
- `input_float`: The input_float object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_float = tab:add_input_float(name)
|
||||
```
|
||||
@ -111,7 +129,7 @@ Add a ImGui::InputText.
|
||||
- **Returns:**
|
||||
- `input_string`: The input_string object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_string = tab:add_input_string(name)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class representing an imgui text element.
|
||||
- **Parameters:**
|
||||
- `font` (string): The new font name for that imgui text element.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
text:set_font(font)
|
||||
```
|
||||
|
@ -33,7 +33,7 @@ Returns a vector that contains the x, y, and z values.
|
||||
- `y` (float): y component of the vector.
|
||||
- `z` (float): z component of the vector.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
myInstance = vec3:new(x, y, z)
|
||||
```
|
||||
|
@ -17,6 +17,7 @@ class DocKind(Enum):
|
||||
Field = "field"
|
||||
Constructor = "constructor"
|
||||
Function = "function"
|
||||
Tabs = "tabs"
|
||||
|
||||
|
||||
class Table:
|
||||
@ -47,8 +48,6 @@ class Table:
|
||||
s += f"## Functions ({len(self.functions)})\n"
|
||||
s += "\n"
|
||||
|
||||
self.check_for_duplicate_function_names()
|
||||
|
||||
for func in self.functions:
|
||||
s += func.print_markdown(f"{self.name}.")
|
||||
|
||||
@ -65,15 +64,6 @@ class Table:
|
||||
print(dup)
|
||||
exit(1)
|
||||
|
||||
def check_for_duplicate_function_names(self):
|
||||
seen = set()
|
||||
duplicates = [x for x in self.functions if x.name in seen or seen.add(x.name)]
|
||||
if len(duplicates) > 0:
|
||||
print("Error while building lua doc. Duplicate function names:")
|
||||
for dup in duplicates:
|
||||
print(dup)
|
||||
exit(1)
|
||||
|
||||
|
||||
class Class:
|
||||
def __init__(self, name, inheritance, fields, constructors, functions, description):
|
||||
@ -117,8 +107,6 @@ class Class:
|
||||
s += f"## Functions ({len(self.functions)})\n"
|
||||
s += "\n"
|
||||
|
||||
self.check_for_duplicate_function_names()
|
||||
|
||||
for func in self.functions:
|
||||
s += func.print_markdown(f"{self.name}:")
|
||||
|
||||
@ -135,15 +123,6 @@ class Class:
|
||||
print(dup)
|
||||
exit(1)
|
||||
|
||||
def check_for_duplicate_function_names(self):
|
||||
seen = set()
|
||||
duplicates = [x for x in self.functions if x.name in seen or seen.add(x.name)]
|
||||
if len(duplicates) > 0:
|
||||
print("Error while building lua doc. Duplicate function names:")
|
||||
for dup in duplicates:
|
||||
print(dup)
|
||||
exit(1)
|
||||
|
||||
|
||||
class Field:
|
||||
def __init__(self, name, type_, description):
|
||||
@ -203,7 +182,7 @@ class Constructor:
|
||||
s += f"\n"
|
||||
s += "\n"
|
||||
|
||||
s += f"**Exemple Usage:**\n"
|
||||
s += f"**Example Usage:**\n"
|
||||
s += "```lua\n"
|
||||
|
||||
s += f"myInstance = {self.parent.name}:new({parameters_str})\n"
|
||||
@ -285,7 +264,7 @@ class Function:
|
||||
|
||||
s += "\n"
|
||||
|
||||
s += f"**Exemple Usage:**\n"
|
||||
s += f"**Example Usage:**\n"
|
||||
s += "```lua\n"
|
||||
if self.return_type is not None and len(self.return_type) > 0:
|
||||
s += self.return_type + " = "
|
||||
@ -345,6 +324,7 @@ def parse_lua_api_doc(folder_path):
|
||||
.lower()
|
||||
)
|
||||
|
||||
if doc_kind is not DocKind.Tabs:
|
||||
continue
|
||||
|
||||
if doc_kind is not None and "//" in line:
|
||||
@ -387,6 +367,7 @@ def parse_lua_api_doc(folder_path):
|
||||
line,
|
||||
line_lower,
|
||||
)
|
||||
case DocKind.Tabs: parse_tabs_doc(file)
|
||||
case _:
|
||||
# print("unsupported doc kind: " + str(doc_kind))
|
||||
pass
|
||||
@ -503,6 +484,28 @@ def parse_constructor_doc(cur_constructor, cur_class, line, line_lower):
|
||||
return cur_constructor, cur_class
|
||||
|
||||
|
||||
tabs_enum = []
|
||||
def parse_tabs_doc(file):
|
||||
start_parsing = False
|
||||
for line in file:
|
||||
if "enum class" in line.lower():
|
||||
start_parsing = True
|
||||
continue
|
||||
|
||||
if start_parsing:
|
||||
if "};" in line.lower():
|
||||
return
|
||||
if "{" == line.lower().strip():
|
||||
continue
|
||||
if "//" in line.lower():
|
||||
continue
|
||||
if "" == line.lower().strip():
|
||||
continue
|
||||
else:
|
||||
tabs_enum.append(line.replace(",", "").strip())
|
||||
|
||||
|
||||
|
||||
def make_parameter_from_doc_line(line):
|
||||
param_info = line.split(lua_api_comment_separator, 3)[1:]
|
||||
param_name = param_type = param_desc = ""
|
||||
@ -542,6 +545,36 @@ for table_name, table in tables.items():
|
||||
f.write(str(table))
|
||||
f.close()
|
||||
|
||||
tabs_file_name = f"./tabs.md"
|
||||
if os.path.exists(tabs_file_name):
|
||||
os.remove(tabs_file_name)
|
||||
f = open(tabs_file_name, "a")
|
||||
|
||||
f.write("""# Tabs
|
||||
|
||||
All the tabs from the menu are listed below, used as parameter for adding gui elements to them.
|
||||
|
||||
**Example Usage:**
|
||||
|
||||
```lua
|
||||
missionsTab = gui.get_tab("GUI_TAB_MISSIONS")
|
||||
missionsTab:add_button("Click me", function ()
|
||||
log.info("You clicked!")
|
||||
end)
|
||||
```
|
||||
|
||||
For a complete list of available gui functions, please refer to the tab class documentation and the gui table documentation.
|
||||
|
||||
""")
|
||||
|
||||
f.write(f"## Tab Count: {len(tabs_enum)}\n\n")
|
||||
|
||||
# Minus the first, because it's the `NONE` tab, minus the last one because it's for runtime defined tabs.
|
||||
for i in range(1, len(tabs_enum) - 1 ):
|
||||
f.write("### `GUI_TAB_" + tabs_enum[i] + "`\n")
|
||||
|
||||
f.close()
|
||||
|
||||
try:
|
||||
os.makedirs("./classes/")
|
||||
except:
|
||||
|
@ -12,7 +12,7 @@ Custom fields, functions, etc added to The Lua [Global Table](https://www.lua.or
|
||||
- **Returns:**
|
||||
- `integer`: The joaat hashed input string.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = joaat(str)
|
||||
```
|
||||
|
@ -12,7 +12,7 @@ Call a menu command.
|
||||
- `command_name` (string): The name of the command that will be called.
|
||||
- `_args` (table): Optional. List of arguments for the command.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
command.call(command_name, _args)
|
||||
```
|
||||
@ -26,7 +26,7 @@ Call a menu command on a given player.
|
||||
- `command_name` (string): The name of the command that will be called.
|
||||
- `_args` (table): Optional. List of arguments for the command.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
command.call_player(player_idx, command_name, _args)
|
||||
```
|
||||
|
@ -12,7 +12,7 @@ Register a function that will be called each time the corresponding menu_event i
|
||||
- `menu_event` (menu_event): The menu_event that we want to respond to.
|
||||
- `func` (function): The function that will be called.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event, func)
|
||||
```
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Table containing functions for manipulating gta script globals.
|
||||
|
||||
## Functions (7)
|
||||
## Functions (9)
|
||||
|
||||
### `get_int(global)`
|
||||
|
||||
@ -14,11 +14,26 @@ Retrieves an int global value.
|
||||
- **Returns:**
|
||||
- `integer`: value of the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = globals.get_int(global)
|
||||
```
|
||||
|
||||
### `get_uint(global)`
|
||||
|
||||
Retrieves an uint global value.
|
||||
|
||||
- **Parameters:**
|
||||
- `global` (integer): index of the global
|
||||
|
||||
- **Returns:**
|
||||
- `integer`: value of the global
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = globals.get_uint(global)
|
||||
```
|
||||
|
||||
### `get_float(global)`
|
||||
|
||||
Retrieves a float global value.
|
||||
@ -29,7 +44,7 @@ Retrieves a float global value.
|
||||
- **Returns:**
|
||||
- `float`: value of the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = globals.get_float(global)
|
||||
```
|
||||
@ -44,7 +59,7 @@ Retrieves a string global value.
|
||||
- **Returns:**
|
||||
- `string`: value of the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
string = globals.get_string(global)
|
||||
```
|
||||
@ -57,11 +72,24 @@ Sets an int global value.
|
||||
- `global` (integer): index of the global
|
||||
- `val` (integer): new value for the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
globals.set_int(global, val)
|
||||
```
|
||||
|
||||
### `set_uint(global, val)`
|
||||
|
||||
Sets an uint global value.
|
||||
|
||||
- **Parameters:**
|
||||
- `global` (integer): index of the global
|
||||
- `val` (integer): new value for the global
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
globals.set_uint(global, val)
|
||||
```
|
||||
|
||||
### `set_float(global, val)`
|
||||
|
||||
Sets a float global value.
|
||||
@ -70,7 +98,7 @@ Sets a float global value.
|
||||
- `global` (integer): index of the global
|
||||
- `val` (float): new value for the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
globals.set_float(global, val)
|
||||
```
|
||||
@ -83,7 +111,7 @@ Sets a string global value.
|
||||
- `global` (integer): index of the global
|
||||
- `str` (string): new value for the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
globals.set_string(global, str)
|
||||
```
|
||||
@ -98,7 +126,7 @@ Retrieves a pointer global.
|
||||
- **Returns:**
|
||||
- `pointer`: value of the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = globals.get_pointer(global)
|
||||
```
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Table containing functions for modifying the menu GUI.
|
||||
|
||||
## Functions (5)
|
||||
## Functions (6)
|
||||
|
||||
### `get_tab(tab_name)`
|
||||
|
||||
@ -12,11 +12,24 @@ Table containing functions for modifying the menu GUI.
|
||||
- **Returns:**
|
||||
- `tab`: A tab instance which corresponds to the tab in the GUI.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab = gui.get_tab(tab_name)
|
||||
```
|
||||
|
||||
### `add_tab(tab_name)`
|
||||
|
||||
- **Parameters:**
|
||||
- `tab_name` (string): Name of the tab to add.
|
||||
|
||||
- **Returns:**
|
||||
- `tab`: A tab instance which corresponds to the new tab in the GUI.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab = gui.add_tab(tab_name)
|
||||
```
|
||||
|
||||
### `show_message(title, message)`
|
||||
|
||||
Shows a message to the user with the given title and message.
|
||||
@ -25,7 +38,7 @@ Shows a message to the user with the given title and message.
|
||||
- `title` (string)
|
||||
- `message` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
gui.show_message(title, message)
|
||||
```
|
||||
@ -38,7 +51,7 @@ Shows a warning to the user with the given title and message.
|
||||
- `title` (string)
|
||||
- `message` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
gui.show_warning(title, message)
|
||||
```
|
||||
@ -51,7 +64,7 @@ Shows an error to the user with the given title and message.
|
||||
- `title` (string)
|
||||
- `message` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
gui.show_error(title, message)
|
||||
```
|
||||
@ -61,7 +74,7 @@ gui.show_error(title, message)
|
||||
- **Returns:**
|
||||
- `bool`: Returns true if the GUI is open.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
bool = gui.is_open()
|
||||
```
|
||||
|
@ -13,7 +13,7 @@ Table for manipulating GTA scripts locals.
|
||||
- **Returns:**
|
||||
- `integer`: The value of the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = locals.get_int(script, index)
|
||||
```
|
||||
@ -27,7 +27,7 @@ integer = locals.get_int(script, index)
|
||||
- **Returns:**
|
||||
- `float`: The value of the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = locals.get_float(script, index)
|
||||
```
|
||||
@ -39,7 +39,7 @@ float = locals.get_float(script, index)
|
||||
- `index` (index): Index of the script local.
|
||||
- `val` (integer): The new value of the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
locals.set_int(script, index, val)
|
||||
```
|
||||
@ -51,7 +51,7 @@ locals.set_int(script, index, val)
|
||||
- `index` (index): Index of the script local.
|
||||
- `val` (float): The new value of the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
locals.set_float(script, index, val)
|
||||
```
|
||||
@ -65,7 +65,7 @@ locals.set_float(script, index, val)
|
||||
- **Returns:**
|
||||
- `pointer`: The pointer to the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = locals.get_pointer(script, index)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Logs an informational message.
|
||||
- **Parameters:**
|
||||
- `data` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
log.info(data)
|
||||
```
|
||||
@ -23,7 +23,7 @@ Logs a warning message.
|
||||
- **Parameters:**
|
||||
- `data` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
log.warning(data)
|
||||
```
|
||||
@ -35,7 +35,7 @@ Logs a debug message.
|
||||
- **Parameters:**
|
||||
- `data` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
log.debug(data)
|
||||
```
|
||||
|
@ -14,7 +14,7 @@ Scans the specified memory pattern within the "GTA5.exe" module and returns a po
|
||||
- **Returns:**
|
||||
- `pointer`: A pointer to the found address.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = memory.scan_pattern(pattern)
|
||||
```
|
||||
@ -27,7 +27,7 @@ pointer = memory.scan_pattern(pattern)
|
||||
- **Returns:**
|
||||
- `pointer`: A rage::CDynamicEntity pointer to the script game entity handle
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = memory.handle_to_ptr(entity)
|
||||
```
|
||||
@ -40,7 +40,7 @@ pointer = memory.handle_to_ptr(entity)
|
||||
- **Returns:**
|
||||
- `number`: The script game entity handle linked to the given rage::CDynamicEntity pointer.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = memory.ptr_to_handle(mem_addr)
|
||||
```
|
||||
@ -53,7 +53,7 @@ number = memory.ptr_to_handle(mem_addr)
|
||||
- **Returns:**
|
||||
- `pointer`: A pointer to the newly allocated memory.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = memory.allocate(size)
|
||||
```
|
||||
@ -63,7 +63,7 @@ pointer = memory.allocate(size)
|
||||
- **Parameters:**
|
||||
- `ptr` (pointer): The pointer that must be freed.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
memory.free(ptr)
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ Table containing all possible events to which you can respond.
|
||||
### `PlayerLeave`
|
||||
|
||||
Event that is triggered when a player leave the game session.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.PlayerLeave, function (player_name)
|
||||
log.info(player_name)
|
||||
@ -19,7 +19,7 @@ end)
|
||||
### `PlayerJoin`
|
||||
|
||||
Event that is triggered when a player join the game session.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.PlayerJoin, function (player_name, player_id)
|
||||
log.info(player_name)
|
||||
@ -32,7 +32,7 @@ end)
|
||||
### `PlayerMgrInit`
|
||||
|
||||
Event that is triggered when the player manager initialize. Usually called when we are joining a session.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.PlayerMgrInit, function ()
|
||||
log.info("Player manager inited, we just joined a session.")
|
||||
@ -44,10 +44,10 @@ end)
|
||||
### `PlayerMgrShutdown`
|
||||
|
||||
Event that is triggered when the player manager shutdown. Usually called when we are leaving a session.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.PlayerMgrShutdown, function ()
|
||||
log.info("Player manager inited, we just joined a session.")
|
||||
log.info("Player manager inited, we just left a session.")
|
||||
end)
|
||||
```
|
||||
|
||||
@ -56,7 +56,7 @@ end)
|
||||
### `ChatMessageReceived`
|
||||
|
||||
Event that is triggered when we receive a in-game chat message.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.ChatMessageReceived, function (player_id, chat_message)
|
||||
log.info(player_id)
|
||||
@ -69,7 +69,7 @@ end)
|
||||
### `ScriptedGameEventReceived`
|
||||
|
||||
Event that is triggered when we receive a scripted game event.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.ScriptedGameEventReceived, function (player_id, script_event_args)
|
||||
log.info(player_id)
|
||||
|
@ -12,7 +12,7 @@ Call trigger_script_event (TSE)
|
||||
- `bitset` (integer)
|
||||
- `_args` (table)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.trigger_script_event(bitset, _args)
|
||||
```
|
||||
@ -25,7 +25,7 @@ Give the given pickup reward to the given player.
|
||||
- `player` (integer): Index of the player.
|
||||
- `reward` (integer): Index of the reward pickup.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.give_pickup_rewards(player, reward)
|
||||
```
|
||||
@ -40,7 +40,7 @@ Teleport the given player to the given position.
|
||||
- `y` (float): New y position.
|
||||
- `z` (float): New z position.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.set_player_coords(player_idx, x, y, z)
|
||||
```
|
||||
@ -54,7 +54,7 @@ Teleport all players to the given position.
|
||||
- `y` (float): New y position.
|
||||
- `z` (float): New z position.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.set_all_player_coords(x, y, z)
|
||||
```
|
||||
@ -64,7 +64,7 @@ network.set_all_player_coords(x, y, z)
|
||||
- **Returns:**
|
||||
- `integer`: Returns the index of the currently selected player in the GUI.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = network.get_selected_player()
|
||||
```
|
||||
@ -74,7 +74,7 @@ integer = network.get_selected_player()
|
||||
- **Returns:**
|
||||
- `integer`: Returns the rockstar id of the currently selected player in the GUI.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = network.get_selected_database_player_rockstar_id()
|
||||
```
|
||||
@ -86,7 +86,7 @@ Flags the given player as a modder in our local database.
|
||||
- **Parameters:**
|
||||
- `player_idx` (integer): Index of the player.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.flag_player_as_modder(player_idx)
|
||||
```
|
||||
@ -99,7 +99,7 @@ network.flag_player_as_modder(player_idx)
|
||||
- **Returns:**
|
||||
- `boolean`: Returns true if the given player is flagged as a modder.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = network.is_player_flagged_as_modder(player_idx)
|
||||
```
|
||||
@ -111,7 +111,7 @@ Try to force ourself to be host for the given GTA Script.
|
||||
- **Parameters:**
|
||||
- `script_name` (string): Name of the script
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.force_script_host(script_name)
|
||||
```
|
||||
@ -124,7 +124,7 @@ Sends a message to the in game chat.
|
||||
- `msg` (string): Message to be sent.
|
||||
- `team_only` (boolean): Should be true if the msg should only be sent to our team.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.send_chat_message(msg, team_only)
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ Table containing helper functions related to gta scripts.
|
||||
### `register_looped(name, func)`
|
||||
|
||||
Registers a function that will be looped as a gta script.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.register_looped("nameOfMyLoopedScript", function (script)
|
||||
-- sleep until next game frame
|
||||
@ -35,7 +35,7 @@ end)
|
||||
- `name` (string): name of your new looped script
|
||||
- `func` (function): function that will be executed in a forever loop.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.register_looped(name, func)
|
||||
```
|
||||
@ -43,7 +43,7 @@ script.register_looped(name, func)
|
||||
### `run_in_fiber(func)`
|
||||
|
||||
Executes a function once inside the fiber pool, you can call natives inside it and yield or sleep.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.run_in_fiber(function (script)
|
||||
-- sleep until next game frame
|
||||
@ -70,9 +70,8 @@ end)
|
||||
- **Parameters:**
|
||||
- `func` (function): function that will be executed once in the fiber pool.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.run_in_fiber(func)
|
||||
```
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ Table for manipulating gta tunables.
|
||||
- **Returns:**
|
||||
- `integer`: The value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = tunables.get_int(tunable_name)
|
||||
```
|
||||
@ -25,7 +25,7 @@ integer = tunables.get_int(tunable_name)
|
||||
- **Returns:**
|
||||
- `float`: The value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = tunables.get_float(tunable_name)
|
||||
```
|
||||
@ -38,7 +38,7 @@ float = tunables.get_float(tunable_name)
|
||||
- **Returns:**
|
||||
- `boolean`: The value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = tunables.get_bool(tunable_name)
|
||||
```
|
||||
@ -49,7 +49,7 @@ boolean = tunables.get_bool(tunable_name)
|
||||
- `tunable_name` (string): The name of the tunable.
|
||||
- `val` (integer): The new value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tunables.set_int(tunable_name, val)
|
||||
```
|
||||
@ -60,7 +60,7 @@ tunables.set_int(tunable_name, val)
|
||||
- `tunable_name` (string): The name of the tunable.
|
||||
- `val` (float): The new value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tunables.set_float(tunable_name, val)
|
||||
```
|
||||
@ -71,7 +71,7 @@ tunables.set_float(tunable_name, val)
|
||||
- `tunable_name` (string): The name of the tunable.
|
||||
- `val` (boolean): The new value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tunables.set_bool(tunable_name, val)
|
||||
```
|
||||
|
57
docs/lua/tabs.md
Normal file
57
docs/lua/tabs.md
Normal file
@ -0,0 +1,57 @@
|
||||
# Tabs
|
||||
|
||||
All the tabs from the menu are listed below, used as parameter for adding gui elements to them.
|
||||
|
||||
**Example Usage:**
|
||||
|
||||
```lua
|
||||
missionsTab = gui.get_tab("GUI_TAB_MISSIONS")
|
||||
missionsTab:add_button("Click me", function ()
|
||||
log.info("You clicked!")
|
||||
end)
|
||||
```
|
||||
|
||||
For a complete list of available gui functions, please refer to the tab class documentation and the gui table documentation.
|
||||
|
||||
## Tab Count: 42
|
||||
|
||||
### `GUI_TAB_SELF`
|
||||
### `GUI_TAB_WEAPONS`
|
||||
### `GUI_TAB_TELEPORT`
|
||||
### `GUI_TAB_MOBILE`
|
||||
### `GUI_TAB_OUTFIT_EDITOR`
|
||||
### `GUI_TAB_OUTFIT_SLOTS`
|
||||
### `GUI_TAB_VEHICLE`
|
||||
### `GUI_TAB_HANDLING`
|
||||
### `GUI_TAB_HANDLING_SEARCH`
|
||||
### `GUI_TAB_HANDLING_SAVED_PROFILE`
|
||||
### `GUI_TAB_HANDLING_MY_PROFILES`
|
||||
### `GUI_TAB_HANDLING_CURRENT_PROFILE`
|
||||
### `GUI_TAB_LSC`
|
||||
### `GUI_TAB_SPAWN_VEHICLE`
|
||||
### `GUI_TAB_FUN_VEHICLE`
|
||||
### `GUI_TAB_WORLD`
|
||||
### `GUI_TAB_SPAWN_PED`
|
||||
### `GUI_TAB_SQUAD_SPAWNER`
|
||||
### `GUI_TAB_CREATOR`
|
||||
### `GUI_TAB_TRAIN`
|
||||
### `GUI_TAB_BLACKHOLE`
|
||||
### `GUI_TAB_MODEL_SWAPPER`
|
||||
### `GUI_TAB_NETWORK`
|
||||
### `GUI_TAB_MISSIONS`
|
||||
### `GUI_TAB_SPOOFING`
|
||||
### `GUI_TAB_PLAYER_DATABASE`
|
||||
### `GUI_TAB_SESSION_BROWSER`
|
||||
### `GUI_TAB_STAT_EDITOR`
|
||||
### `GUI_TAB_SETTINGS`
|
||||
### `GUI_TAB_LUA_SCRIPTS`
|
||||
### `GUI_TAB_CONTEXT_MENU_SETTINGS`
|
||||
### `GUI_TAB_ESP_SETTINGS`
|
||||
### `GUI_TAB_GTA_CACHE_SETTINGS`
|
||||
### `GUI_TAB_GUI_SETTINGS`
|
||||
### `GUI_TAB_HOTKEY_SETTINGS`
|
||||
### `GUI_TAB_REACTION_SETTINGS`
|
||||
### `GUI_TAB_PROTECTION_SETTINGS`
|
||||
### `GUI_TAB_TRANSLATION_SETTINGS`
|
||||
### `GUI_TAB_DEBUG`
|
||||
### `GUI_TAB_PLAYER`
|
@ -6,9 +6,13 @@ namespace big
|
||||
{
|
||||
void components::nav_item(std::pair<tabs, navigation_struct>& navItem, int nested)
|
||||
{
|
||||
const bool curTab = !g_gui_service->get_selected_tab().empty() && g_gui_service->get_selected_tab().size() > nested
|
||||
&& navItem.first == g_gui_service->get_selected_tab().at(nested);
|
||||
if (curTab)
|
||||
const bool current_tab =
|
||||
!g_gui_service->get_selected_tab().empty() &&
|
||||
g_gui_service->get_selected_tab().size() > nested &&
|
||||
navItem.first == g_gui_service->get_selected_tab().at(nested);
|
||||
|
||||
|
||||
if (current_tab)
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.29f, 0.45f, 0.69f, 1.f));
|
||||
|
||||
const char* key = nullptr;
|
||||
@ -17,16 +21,16 @@ namespace big
|
||||
if (components::nav_button(key))
|
||||
g_gui_service->set_selected(navItem.first);
|
||||
|
||||
if (curTab)
|
||||
if (current_tab)
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
if (curTab && !navItem.second.sub_nav.empty())
|
||||
if (current_tab && !navItem.second.sub_nav.empty())
|
||||
{
|
||||
ImDrawList* dl = ImGui::GetForegroundDrawList();
|
||||
ImDrawList* draw_list = ImGui::GetForegroundDrawList();
|
||||
|
||||
for (std::pair<tabs, navigation_struct> item : navItem.second.sub_nav)
|
||||
{
|
||||
dl->AddRectFilled({10.f, ImGui::GetCursorPosY() + (100.f * g.window.gui_scale)},
|
||||
draw_list->AddRectFilled({10.f, ImGui::GetCursorPosY() + (100.f * g.window.gui_scale)},
|
||||
{(10.f + (300.f * g.window.gui_scale)),
|
||||
(ImGui::GetCursorPosY() + (100.f * (g.window.gui_scale)) + ImGui::CalcTextSize("A").y
|
||||
+ (ImGui::GetStyle().ItemInnerSpacing.y / g.window.gui_scale) * 2)},
|
||||
|
@ -13,7 +13,7 @@ namespace lua::event
|
||||
// Table: menu_event
|
||||
// Field: PlayerLeave: integer
|
||||
// Event that is triggered when a player leave the game session.
|
||||
// **Exemple Usage:**
|
||||
// **Example Usage:**
|
||||
// ```lua
|
||||
// event.register_handler(menu_event.PlayerLeave, function (player_name)
|
||||
// log.info(player_name)
|
||||
@ -24,7 +24,7 @@ namespace lua::event
|
||||
// Table: menu_event
|
||||
// Field: PlayerJoin: integer
|
||||
// Event that is triggered when a player join the game session.
|
||||
// **Exemple Usage:**
|
||||
// **Example Usage:**
|
||||
// ```lua
|
||||
// event.register_handler(menu_event.PlayerJoin, function (player_name, player_id)
|
||||
// log.info(player_name)
|
||||
@ -36,7 +36,7 @@ namespace lua::event
|
||||
// Table: menu_event
|
||||
// Field: PlayerMgrInit: integer
|
||||
// Event that is triggered when the player manager initialize. Usually called when we are joining a session.
|
||||
// **Exemple Usage:**
|
||||
// **Example Usage:**
|
||||
// ```lua
|
||||
// event.register_handler(menu_event.PlayerMgrInit, function ()
|
||||
// log.info("Player manager inited, we just joined a session.")
|
||||
@ -47,10 +47,10 @@ namespace lua::event
|
||||
// Table: menu_event
|
||||
// Field: PlayerMgrShutdown: integer
|
||||
// Event that is triggered when the player manager shutdown. Usually called when we are leaving a session.
|
||||
// **Exemple Usage:**
|
||||
// **Example Usage:**
|
||||
// ```lua
|
||||
// event.register_handler(menu_event.PlayerMgrShutdown, function ()
|
||||
// log.info("Player manager inited, we just joined a session.")
|
||||
// log.info("Player manager inited, we just left a session.")
|
||||
// end)
|
||||
// ```
|
||||
|
||||
@ -58,7 +58,7 @@ namespace lua::event
|
||||
// Table: menu_event
|
||||
// Field: ChatMessageReceived: integer
|
||||
// Event that is triggered when we receive a in-game chat message.
|
||||
// **Exemple Usage:**
|
||||
// **Example Usage:**
|
||||
// ```lua
|
||||
// event.register_handler(menu_event.ChatMessageReceived, function (player_id, chat_message)
|
||||
// log.info(player_id)
|
||||
@ -70,7 +70,7 @@ namespace lua::event
|
||||
// Table: menu_event
|
||||
// Field: ScriptedGameEventReceived: integer
|
||||
// Event that is triggered when we receive a scripted game event.
|
||||
// **Exemple Usage:**
|
||||
// **Example Usage:**
|
||||
// ```lua
|
||||
// event.register_handler(menu_event.ScriptedGameEventReceived, function (player_id, script_event_args)
|
||||
// log.info(player_id)
|
||||
|
@ -19,6 +19,17 @@ namespace lua::globals
|
||||
return *big::script_global(global).as<int*>();
|
||||
}
|
||||
|
||||
// Lua API: Function
|
||||
// Table: globals
|
||||
// Name: get_uint
|
||||
// Param: global: integer: index of the global
|
||||
// Returns: integer: value of the global
|
||||
// Retrieves an uint global value.
|
||||
static int get_uint(int global)
|
||||
{
|
||||
return *big::script_global(global).as<unsigned int*>();
|
||||
}
|
||||
|
||||
// Lua API: Function
|
||||
// Table: globals
|
||||
// Name: get_float
|
||||
@ -52,6 +63,17 @@ namespace lua::globals
|
||||
*big::script_global(global).as<int*>() = val;
|
||||
}
|
||||
|
||||
// Lua API: Function
|
||||
// Table: globals
|
||||
// Name: set_uint
|
||||
// Param: global: integer: index of the global
|
||||
// Param: val: integer: new value for the global
|
||||
// Sets an uint global value.
|
||||
static void set_uint(int global, unsigned int val)
|
||||
{
|
||||
*big::script_global(global).as<unsigned int*>() = val;
|
||||
}
|
||||
|
||||
// Lua API: Function
|
||||
// Table: globals
|
||||
// Name: set_float
|
||||
@ -89,9 +111,11 @@ namespace lua::globals
|
||||
{
|
||||
auto ns = state["globals"].get_or_create<sol::table>();
|
||||
ns["get_int"] = get_int;
|
||||
ns["get_uint"] = get_uint;
|
||||
ns["get_float"] = get_float;
|
||||
ns["get_string"] = get_string;
|
||||
ns["set_int"] = set_int;
|
||||
ns["set_uint"] = set_uint;
|
||||
ns["set_float"] = set_float;
|
||||
ns["set_string"] = set_string;
|
||||
ns["get_pointer"] = get_pointer;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "gui/separator.hpp"
|
||||
#include "gui/text.hpp"
|
||||
#include "lua/lua_module.hpp"
|
||||
#include "services/gui/gui_service.hpp"
|
||||
|
||||
namespace lua::gui
|
||||
{
|
||||
@ -27,12 +28,136 @@ namespace lua::gui
|
||||
// Class for representing a tab within the GUI.
|
||||
class tab
|
||||
{
|
||||
big::tabs m_id;
|
||||
rage::joaat_t m_tab_hash;
|
||||
|
||||
public:
|
||||
tab(rage::joaat_t hash) :
|
||||
m_tab_hash(hash)
|
||||
inline big::tabs id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
inline rage::joaat_t hash() const
|
||||
{
|
||||
return m_tab_hash;
|
||||
}
|
||||
|
||||
bool check_if_existing_tab_and_fill_id(const std::map<big::tabs, big::navigation_struct>& nav)
|
||||
{
|
||||
for (const auto& nav_item : nav)
|
||||
{
|
||||
if (nav_item.second.hash == m_tab_hash)
|
||||
{
|
||||
m_id = nav_item.first;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (check_if_existing_tab_and_fill_id(nav_item.second.sub_nav))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void add_to_existing_tab(std::map<big::tabs, big::navigation_struct>& nav, const rage::joaat_t existing_tab_hash, const std::pair<big::tabs, big::navigation_struct>& new_tab, const sol::this_state& state)
|
||||
{
|
||||
for (auto& nav_item : nav)
|
||||
{
|
||||
if (nav_item.second.hash == existing_tab_hash)
|
||||
{
|
||||
auto module = sol::state_view(state)["!this"].get<big::lua_module*>();
|
||||
module->m_tab_to_sub_tabs[nav_item.first].push_back(new_tab.first);
|
||||
|
||||
nav_item.second.sub_nav.emplace(new_tab);
|
||||
return;
|
||||
}
|
||||
|
||||
add_to_existing_tab(nav_item.second.sub_nav, existing_tab_hash, new_tab, state);
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<big::tabs, big::navigation_struct> make_tab_nav(const std::string& name, const rage::joaat_t tab_hash, const sol::this_state& state)
|
||||
{
|
||||
static size_t custom_tab_count = size_t(big::tabs::RUNTIME_CUSTOM);
|
||||
m_id = big::tabs(custom_tab_count);
|
||||
|
||||
custom_tab_count++;
|
||||
|
||||
big::navigation_struct new_navigation_struct{};
|
||||
strcpy(new_navigation_struct.name, name.c_str());
|
||||
new_navigation_struct.hash = tab_hash;
|
||||
|
||||
return std::make_pair(m_id, new_navigation_struct);
|
||||
}
|
||||
|
||||
tab(const std::string& name, const sol::this_state& state) :
|
||||
m_tab_hash(rage::joaat(name))
|
||||
{
|
||||
auto& nav = big::g_gui_service->get_navigation();
|
||||
|
||||
if (check_if_existing_tab_and_fill_id(nav))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// add top tab
|
||||
nav.emplace(make_tab_nav(name, m_tab_hash, state));
|
||||
|
||||
auto module = sol::state_view(state)["!this"].get<big::lua_module*>();
|
||||
module->m_owned_tabs.push_back(id());
|
||||
}
|
||||
|
||||
tab(const std::string& name, const rage::joaat_t parent_tab_hash, const sol::this_state& state) :
|
||||
m_tab_hash(rage::joaat(name))
|
||||
{
|
||||
auto& nav = big::g_gui_service->get_navigation();
|
||||
|
||||
if (check_if_existing_tab_and_fill_id(nav))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto sub_tab = make_tab_nav(name, m_tab_hash, state);
|
||||
add_to_existing_tab(nav, parent_tab_hash, sub_tab, state);
|
||||
|
||||
auto module = sol::state_view(state)["!this"].get<big::lua_module*>();
|
||||
module->m_owned_tabs.push_back(id());
|
||||
}
|
||||
|
||||
// Lua API: Function
|
||||
// Class: tab
|
||||
// Name: clear
|
||||
// Clear the tab of all its custom lua content that you own.
|
||||
void clear(sol::this_state state)
|
||||
{
|
||||
auto module = sol::state_view(state)["!this"].get<big::lua_module*>();
|
||||
|
||||
if (module->m_gui.contains(m_tab_hash))
|
||||
module->m_gui[m_tab_hash] = {};
|
||||
|
||||
for (auto sub_tab : module->m_tab_to_sub_tabs[id()])
|
||||
{
|
||||
for (const auto owned_tab : module->m_owned_tabs)
|
||||
{
|
||||
if (sub_tab == owned_tab)
|
||||
{
|
||||
big::g_gui_service->remove_from_nav(sub_tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Lua API: Function
|
||||
// Class: tab
|
||||
// Name: add_tab
|
||||
// Add a sub tab to this tab.
|
||||
tab add_tab(const std::string& name, sol::this_state state)
|
||||
{
|
||||
const auto sub_tab = tab(name, m_tab_hash, state);
|
||||
|
||||
return sub_tab;
|
||||
}
|
||||
|
||||
// Lua API: Function
|
||||
@ -147,9 +272,21 @@ namespace lua::gui
|
||||
// Name: get_tab
|
||||
// Param: tab_name: string: Name of the tab to get.
|
||||
// Returns: tab: A tab instance which corresponds to the tab in the GUI.
|
||||
static tab get_tab(const std::string& tab_name)
|
||||
static tab get_tab(const std::string& tab_name, sol::this_state state)
|
||||
{
|
||||
return tab(rage::joaat(tab_name));
|
||||
return tab(tab_name, state);
|
||||
}
|
||||
|
||||
// Lua API: Function
|
||||
// Table: gui
|
||||
// Name: add_tab
|
||||
// Param: tab_name: string: Name of the tab to add.
|
||||
// Returns: tab: A tab instance which corresponds to the new tab in the GUI.
|
||||
static tab add_tab(const std::string& tab_name, sol::this_state state)
|
||||
{
|
||||
const auto new_tab = tab(tab_name, state);
|
||||
|
||||
return new_tab;
|
||||
}
|
||||
|
||||
// Lua API: Function
|
||||
@ -195,6 +332,7 @@ namespace lua::gui
|
||||
{
|
||||
auto ns = state["gui"].get_or_create<sol::table>();
|
||||
ns["get_tab"] = get_tab;
|
||||
ns["add_tab"] = add_tab;
|
||||
ns["show_message"] = show_message;
|
||||
ns["show_warning"] = show_warning;
|
||||
ns["show_error"] = show_error;
|
||||
@ -244,6 +382,8 @@ namespace lua::gui
|
||||
);
|
||||
|
||||
ns.new_usertype<tab>("tab",
|
||||
"clear", &tab::clear,
|
||||
"add_tab", &tab::add_tab,
|
||||
"add_button", &tab::add_button,
|
||||
"add_text", &tab::add_text,
|
||||
"add_checkbox", &tab::add_checkbox,
|
||||
|
@ -24,6 +24,24 @@ namespace big
|
||||
g_lua_manager = nullptr;
|
||||
}
|
||||
|
||||
bool lua_manager::has_gui_to_draw(rage::joaat_t tab_hash)
|
||||
{
|
||||
std::lock_guard guard(m_module_lock);
|
||||
|
||||
for (const auto& module : m_modules)
|
||||
{
|
||||
if (const auto it = module->m_gui.find(tab_hash); it != module->m_gui.end())
|
||||
{
|
||||
if (it->second.size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void lua_manager::draw_gui(rage::joaat_t tab_hash)
|
||||
{
|
||||
std::lock_guard guard(m_module_lock);
|
||||
|
@ -37,11 +37,15 @@ namespace big
|
||||
return m_modules.size();
|
||||
}
|
||||
|
||||
|
||||
bool has_gui_to_draw(rage::joaat_t tab_hash);
|
||||
|
||||
inline const folder& get_scripts_folder() const
|
||||
{
|
||||
return m_scripts_folder;
|
||||
}
|
||||
|
||||
|
||||
void draw_gui(rage::joaat_t tab_hash);
|
||||
|
||||
void unload_module(rage::joaat_t module_id);
|
||||
|
@ -79,17 +79,16 @@ namespace big
|
||||
|
||||
lua_module::~lua_module()
|
||||
{
|
||||
for (const auto owned_tab : m_owned_tabs)
|
||||
{
|
||||
big::g_gui_service->remove_from_nav(owned_tab);
|
||||
}
|
||||
|
||||
for (auto script : m_registered_scripts)
|
||||
g_script_mgr.remove_script(script);
|
||||
|
||||
for (auto& patch : m_registered_patches)
|
||||
patch.reset();
|
||||
|
||||
for (auto memory : m_allocated_memory)
|
||||
delete[] memory;
|
||||
|
||||
m_registered_scripts.clear();
|
||||
m_registered_patches.clear();
|
||||
}
|
||||
|
||||
rage::joaat_t lua_module::module_id() const
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "lua_patch.hpp"
|
||||
#include "sol.hpp"
|
||||
#include "core/data/menu_event.hpp"
|
||||
#include <services/gui/gui_service.hpp>
|
||||
|
||||
namespace big
|
||||
{
|
||||
@ -20,6 +21,11 @@ namespace big
|
||||
public:
|
||||
std::vector<script*> m_registered_scripts;
|
||||
std::vector<std::shared_ptr<lua_patch>> m_registered_patches;
|
||||
|
||||
std::vector<big::tabs> m_owned_tabs;
|
||||
|
||||
std::unordered_map<big::tabs, std::vector<big::tabs>> m_tab_to_sub_tabs;
|
||||
|
||||
std::unordered_map<rage::joaat_t, std::vector<std::shared_ptr<lua::gui::gui_element>>> m_gui;
|
||||
std::unordered_map<menu_event, std::vector<sol::function>> m_event_callbacks;
|
||||
std::vector<void*> m_allocated_memory;
|
||||
|
@ -75,4 +75,26 @@ namespace big
|
||||
{
|
||||
return nav;
|
||||
}
|
||||
|
||||
void gui_service::remove_from_nav_internal(std::map<big::tabs, big::navigation_struct>& nav, big::tabs existing_tab_id)
|
||||
{
|
||||
std::erase_if(nav, [&](auto& nav_item) {
|
||||
if (nav_item.first == existing_tab_id)
|
||||
{
|
||||
set_selected(tabs::NONE);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
remove_from_nav_internal(nav_item.second.sub_nav, existing_tab_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
void gui_service::remove_from_nav(tabs existing_tab_id)
|
||||
{
|
||||
remove_from_nav_internal(get_navigation(), existing_tab_id);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
namespace big
|
||||
{
|
||||
// Lua API: Tabs
|
||||
enum class tabs
|
||||
{
|
||||
NONE,
|
||||
@ -51,7 +52,10 @@ namespace big
|
||||
TRANSLATION_SETTINGS,
|
||||
DEBUG,
|
||||
|
||||
PLAYER
|
||||
PLAYER,
|
||||
|
||||
// Added at runtime by things like lua scripts.
|
||||
RUNTIME_CUSTOM
|
||||
};
|
||||
|
||||
struct navigation_struct
|
||||
@ -62,92 +66,88 @@ namespace big
|
||||
rage::joaat_t hash = rage::joaat(name);
|
||||
};
|
||||
|
||||
// Used for constructing translation key for tabs
|
||||
#define TAB_DECL_INTERNAL(prefix, tab) \
|
||||
tabs::tab, \
|
||||
{ \
|
||||
#prefix #tab
|
||||
#define TAB_DECL(tab) TAB_DECL_INTERNAL(GUI_TAB_, tab)
|
||||
|
||||
class gui_service final
|
||||
{
|
||||
std::vector<tabs> current_tab{};
|
||||
bool switched_view = true;
|
||||
|
||||
// clang-format off
|
||||
std::map<tabs, navigation_struct> nav = {
|
||||
{
|
||||
tabs::SELF,
|
||||
{
|
||||
"GUI_TAB_SELF",
|
||||
TAB_DECL(SELF),
|
||||
view::self,
|
||||
{
|
||||
{tabs::WEAPONS, {"GUI_TAB_WEAPONS", view::weapons}},
|
||||
{tabs::MOBILE, {"GUI_TAB_MOBILE", view::mobile}},
|
||||
{tabs::TELEPORT, {"GUI_TAB_TELEPORT", view::teleport}},
|
||||
{tabs::OUTFIT_EDITOR, {"GUI_TAB_OUTFIT_EDITOR", view::outfit_editor}},
|
||||
{tabs::OUTFIT_SLOTS, {"GUI_TAB_OUTFIT_SLOTS", view::outfit_slots}},
|
||||
{TAB_DECL(WEAPONS), view::weapons}},
|
||||
{TAB_DECL(MOBILE), view::mobile}},
|
||||
{TAB_DECL(TELEPORT), view::teleport}},
|
||||
{TAB_DECL(OUTFIT_EDITOR), view::outfit_editor}},
|
||||
{TAB_DECL(OUTFIT_SLOTS), view::outfit_slots}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
tabs::VEHICLE,
|
||||
{
|
||||
"GUI_TAB_VEHICLE",
|
||||
TAB_DECL(VEHICLE),
|
||||
view::vehicle,
|
||||
{
|
||||
{
|
||||
tabs::HANDLING,
|
||||
{
|
||||
"GUI_TAB_HANDLING",
|
||||
TAB_DECL(HANDLING),
|
||||
view::handling_current_profile,
|
||||
{
|
||||
{tabs::HANDLING_CURRENT_PROFILE, {"GUI_TAB_HANDLING_CURRENT_PROFILE", view::handling_current_profile}},
|
||||
{tabs::HANDLING_SAVED_PROFILE, {"GUI_TAB_HANDLING_SAVED_PROFILES", view::handling_saved_profiles}},
|
||||
{TAB_DECL(HANDLING_CURRENT_PROFILE), view::handling_current_profile}},
|
||||
{TAB_DECL(HANDLING_SAVED_PROFILE), view::handling_saved_profiles}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{tabs::LSC, {"GUI_TAB_LSC", view::lsc}},
|
||||
{tabs::SPAWN_VEHICLE, {"GUI_TAB_SPAWN_VEHICLE", view::spawn_vehicle}},
|
||||
{tabs::FUN_VEHICLE, {"GUI_TAB_VEHICLE_FUN_FEATURES", view::fun_vehicle}},
|
||||
{TAB_DECL(LSC), view::lsc}},
|
||||
{TAB_DECL(SPAWN_VEHICLE), view::spawn_vehicle}},
|
||||
{TAB_DECL(FUN_VEHICLE), view::fun_vehicle}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
tabs::WORLD,
|
||||
{
|
||||
"GUI_TAB_WORLD",
|
||||
TAB_DECL(WORLD),
|
||||
view::world,
|
||||
{
|
||||
{tabs::SPAWN_PED, {"GUI_TAB_SPAWN_PED", view::spawn_ped}},
|
||||
{tabs::SQUAD_SPAWNER, {"Squad spawner", view::squad_spawner}},
|
||||
{tabs::CREATOR, {"GUI_TAB_CREATOR", view::creator}},
|
||||
{tabs::TRAIN, {"GUI_TAB_TRAIN", view::train}},
|
||||
{tabs::BLACKHOLE, {"GUI_TAB_BLACKHOLE", view::blackhole}},
|
||||
{tabs::MODEL_SWAPPER, {"GUI_TAB_MODEL_SWAPPER", view::model_swapper}},
|
||||
{TAB_DECL(SPAWN_PED), view::spawn_ped}},
|
||||
{TAB_DECL(SQUAD_SPAWNER), view::squad_spawner}},
|
||||
{TAB_DECL(CREATOR), view::creator}},
|
||||
{TAB_DECL(TRAIN), view::train}},
|
||||
{TAB_DECL(BLACKHOLE), view::blackhole}},
|
||||
{TAB_DECL(MODEL_SWAPPER), view::model_swapper}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
tabs::NETWORK,
|
||||
{
|
||||
"GUI_TAB_NETWORK",
|
||||
TAB_DECL(NETWORK),
|
||||
view::network,
|
||||
{
|
||||
{tabs::SPOOFING, {"GUI_TAB_SPOOFING", view::spoofing}},
|
||||
{tabs::MISSIONS, {"GUI_TAB_MISSIONS", view::missions}},
|
||||
{tabs::PLAYER_DATABASE, {"GUI_TAB_PLAYER_DB", view::player_database}},
|
||||
{tabs::SESSION_BROWSER, {"GUI_TAB_SESSION_BROWSER", view::session_browser}},
|
||||
{tabs::STAT_EDITOR, {"GUI_TAB_STAT_EDITOR", view::stat_editor}},
|
||||
{TAB_DECL(SPOOFING), view::spoofing}},
|
||||
{TAB_DECL(MISSIONS), view::missions}},
|
||||
{TAB_DECL(PLAYER_DATABASE), view::player_database}},
|
||||
{TAB_DECL(SESSION_BROWSER), view::session_browser}},
|
||||
{TAB_DECL(STAT_EDITOR), view::stat_editor}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
tabs::SETTINGS,
|
||||
{
|
||||
"GUI_TAB_SETTINGS",
|
||||
TAB_DECL(SETTINGS),
|
||||
view::settings,
|
||||
{
|
||||
{tabs::LUA_SCRIPTS, {"GUI_TAB_LUA_SCRIPTS", view::lua_scripts}},
|
||||
{tabs::ESP_SETTINGS, {"GUI_TAB_ESP", view::esp_settings}},
|
||||
{tabs::GTA_CACHE_SETTINGS, {"GTA Cache", view::gta_cache}},
|
||||
{tabs::GUI_SETTINGS, {"GUI_TAB_GUI", view::gui_settings}},
|
||||
{tabs::HOTKEY_SETTINGS, {"GUI_TAB_HOTKEYS", view::hotkey_settings}},
|
||||
{tabs::REACTION_SETTINGS, {"GUI_TAB_REACTIONS", view::reaction_settings}},
|
||||
{tabs::PROTECTION_SETTINGS, {"GUI_TAB_PROTECTION", view::protection_settings}},
|
||||
{tabs::DEBUG, {"GUI_TAB_DEBUG", nullptr}},
|
||||
{TAB_DECL(LUA_SCRIPTS), view::lua_scripts}},
|
||||
{TAB_DECL(ESP_SETTINGS), view::esp_settings}},
|
||||
{TAB_DECL(GTA_CACHE_SETTINGS), view::gta_cache}},
|
||||
{TAB_DECL(GUI_SETTINGS), view::gui_settings}},
|
||||
{TAB_DECL(HOTKEY_SETTINGS), view::hotkey_settings}},
|
||||
{TAB_DECL(REACTION_SETTINGS), view::reaction_settings}},
|
||||
{TAB_DECL(PROTECTION_SETTINGS), view::protection_settings}},
|
||||
{TAB_DECL(DEBUG), nullptr}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -156,6 +156,9 @@ namespace big
|
||||
{"", view::view_player},
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
void remove_from_nav_internal(std::map<big::tabs, big::navigation_struct>& nav, big::tabs existing_tab_id);
|
||||
|
||||
public:
|
||||
gui_service();
|
||||
@ -171,6 +174,7 @@ namespace big
|
||||
void increment_nav_size();
|
||||
void reset_nav_size();
|
||||
std::map<tabs, navigation_struct>& get_navigation();
|
||||
void remove_from_nav(tabs existing_tab_id);
|
||||
};
|
||||
|
||||
inline gui_service* g_gui_service{};
|
||||
|
@ -9,12 +9,15 @@ namespace big
|
||||
{
|
||||
void view::active_view()
|
||||
{
|
||||
auto selected = g_gui_service->get_selected();
|
||||
const auto selected = g_gui_service->get_selected();
|
||||
|
||||
if (selected->func == nullptr)
|
||||
if (selected->func == nullptr &&
|
||||
(g_lua_manager && !g_lua_manager->has_gui_to_draw(selected->hash)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static float alpha = 1.f;
|
||||
constexpr float alpha = 1.f;
|
||||
|
||||
ImGui::SetNextWindowPos({(300.f + 20.f) * g.window.gui_scale, 100.f * g.window.gui_scale}, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize({0.f, 0.f});
|
||||
@ -31,6 +34,8 @@ namespace big
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
||||
components::title(key);
|
||||
ImGui::Separator();
|
||||
|
||||
if (selected->func)
|
||||
selected->func();
|
||||
|
||||
if (g_lua_manager)
|
||||
|
@ -11,13 +11,13 @@ namespace big
|
||||
if (ImGui::Begin("navigation", 0, window_flags))
|
||||
{
|
||||
g_gui_service->reset_nav_size();
|
||||
for (std::pair<tabs, navigation_struct> navItem : g_gui_service->get_navigation())
|
||||
for (std::pair<tabs, navigation_struct> nav_item : g_gui_service->get_navigation())
|
||||
{
|
||||
switch (navItem.first)
|
||||
switch (nav_item.first)
|
||||
{
|
||||
case tabs::PLAYER:
|
||||
case tabs::DEBUG: continue;
|
||||
default: components::nav_item(navItem, 0);
|
||||
default: components::nav_item(nav_item, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user