feat(lua): Add tab:is_selected function to check if the tab is the currently selected one in the GUI. (#1763)

This commit is contained in:
Quentin 2023-07-19 09:28:22 +02:00 committed by GitHub
parent 1fa7f3448b
commit 497781b048
3 changed files with 28 additions and 6 deletions

View File

@ -2,7 +2,17 @@
Class for representing a tab within the GUI.
## Functions (11)
## Functions (12)
### `is_selected()`
- **Returns:**
- `boolean`: Returns true if this tab is the currently selected one in the GUI.
**Example Usage:**
```lua
boolean = tab:is_selected()
```
### `clear()`

View File

@ -115,6 +115,11 @@ namespace lua::gui
module->m_owned_tabs.push_back(id());
}
bool tab::is_selected(sol::this_state state)
{
return big::g_gui_service->get_selected()->hash == m_tab_hash;
}
void tab::clear(sol::this_state state)
{
auto module = sol::state_view(state)["!this"].get<big::lua_module*>();
@ -318,10 +323,10 @@ namespace lua::gui
text_ut["set_text"] = &lua::gui::text::set_text;
text_ut["set_font"] = &lua::gui::text::set_font;
auto checkbox_ut = ns.new_usertype<lua::gui::checkbox>("checkbox");
checkbox_ut["get_text"] = &lua::gui::checkbox::get_text;
checkbox_ut["set_text"] = &lua::gui::checkbox::set_text;
checkbox_ut["is_enabled"] = &lua::gui::checkbox::is_enabled;
auto checkbox_ut = ns.new_usertype<lua::gui::checkbox>("checkbox");
checkbox_ut["get_text"] = &lua::gui::checkbox::get_text;
checkbox_ut["set_text"] = &lua::gui::checkbox::set_text;
checkbox_ut["is_enabled"] = &lua::gui::checkbox::is_enabled;
checkbox_ut["set_enabled"] = &lua::gui::checkbox::set_enabled;
ns.new_usertype<lua::gui::sameline>("sameline");
@ -346,6 +351,7 @@ namespace lua::gui
input_string_ut["set_value"] = &lua::gui::input_string::set_value;
auto tab_ut = ns.new_usertype<tab>("tab");
tab_ut["is_selected"] = &tab::is_selected;
tab_ut["clear"] = &tab::clear;
tab_ut["add_tab"] = &tab::add_tab;
tab_ut["add_button"] = &tab::add_button;

View File

@ -35,6 +35,12 @@ namespace lua::gui
tab(const std::string& name, const rage::joaat_t parent_tab_hash, const sol::this_state& state);
// Lua API: Function
// Class: tab
// Name: is_selected
// Returns: boolean: Returns true if this tab is the one currently selected in the GUI.
bool is_selected(sol::this_state state);
// Lua API: Function
// Class: tab
// Name: clear
@ -123,7 +129,7 @@ namespace lua::gui
// -- call natives in there
// end)
// end
//
//
// ImGui.End()
// end
// end)