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:
parent
81bd1f9dc7
commit
69959df3ed
@ -2,7 +2,17 @@
|
|||||||
|
|
||||||
Class for representing a tab within the GUI.
|
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()`
|
### `clear()`
|
||||||
|
|
||||||
|
@ -115,6 +115,11 @@ namespace lua::gui
|
|||||||
module->m_owned_tabs.push_back(id());
|
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)
|
void tab::clear(sol::this_state state)
|
||||||
{
|
{
|
||||||
auto module = sol::state_view(state)["!this"].get<big::lua_module*>();
|
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_text"] = &lua::gui::text::set_text;
|
||||||
text_ut["set_font"] = &lua::gui::text::set_font;
|
text_ut["set_font"] = &lua::gui::text::set_font;
|
||||||
|
|
||||||
auto checkbox_ut = ns.new_usertype<lua::gui::checkbox>("checkbox");
|
auto checkbox_ut = ns.new_usertype<lua::gui::checkbox>("checkbox");
|
||||||
checkbox_ut["get_text"] = &lua::gui::checkbox::get_text;
|
checkbox_ut["get_text"] = &lua::gui::checkbox::get_text;
|
||||||
checkbox_ut["set_text"] = &lua::gui::checkbox::set_text;
|
checkbox_ut["set_text"] = &lua::gui::checkbox::set_text;
|
||||||
checkbox_ut["is_enabled"] = &lua::gui::checkbox::is_enabled;
|
checkbox_ut["is_enabled"] = &lua::gui::checkbox::is_enabled;
|
||||||
checkbox_ut["set_enabled"] = &lua::gui::checkbox::set_enabled;
|
checkbox_ut["set_enabled"] = &lua::gui::checkbox::set_enabled;
|
||||||
|
|
||||||
ns.new_usertype<lua::gui::sameline>("sameline");
|
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;
|
input_string_ut["set_value"] = &lua::gui::input_string::set_value;
|
||||||
|
|
||||||
auto tab_ut = ns.new_usertype<tab>("tab");
|
auto tab_ut = ns.new_usertype<tab>("tab");
|
||||||
|
tab_ut["is_selected"] = &tab::is_selected;
|
||||||
tab_ut["clear"] = &tab::clear;
|
tab_ut["clear"] = &tab::clear;
|
||||||
tab_ut["add_tab"] = &tab::add_tab;
|
tab_ut["add_tab"] = &tab::add_tab;
|
||||||
tab_ut["add_button"] = &tab::add_button;
|
tab_ut["add_button"] = &tab::add_button;
|
||||||
|
@ -35,6 +35,12 @@ namespace lua::gui
|
|||||||
|
|
||||||
tab(const std::string& name, const rage::joaat_t parent_tab_hash, const sol::this_state& state);
|
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
|
// Lua API: Function
|
||||||
// Class: tab
|
// Class: tab
|
||||||
// Name: clear
|
// Name: clear
|
||||||
@ -123,7 +129,7 @@ namespace lua::gui
|
|||||||
// -- call natives in there
|
// -- call natives in there
|
||||||
// end)
|
// end)
|
||||||
// end
|
// end
|
||||||
//
|
//
|
||||||
// ImGui.End()
|
// ImGui.End()
|
||||||
// end
|
// end
|
||||||
// end)
|
// end)
|
||||||
|
Reference in New Issue
Block a user