diff --git a/src/gui/components/components.hpp b/src/gui/components/components.hpp index 56f86368..309e4a69 100644 --- a/src/gui/components/components.hpp +++ b/src/gui/components/components.hpp @@ -33,6 +33,8 @@ namespace big static bool script_patch_checkbox(const std::string_view text, bool* option, const std::string_view tooltip = ""); + static void options_modal(std::string element_name, std::function render_elements, bool sameline = true, std::string custom_button_name = "Options"); + template static void command_button(const std::vector args = {}, std::optional label_override = std::nullopt) { diff --git a/src/gui/components/options_modal.cpp b/src/gui/components/options_modal.cpp new file mode 100644 index 00000000..4c3aa8b2 --- /dev/null +++ b/src/gui/components/options_modal.cpp @@ -0,0 +1,27 @@ +#include "gui/components/components.hpp" + +namespace big +{ + /* + Will provide an options button next to the previous element that opens up a popup to run the content of 'render_elements' + */ + void components::options_modal(std::string element_name, std::function render_elements, bool sameline, std::string custom_button_name) + { + if (sameline) + ImGui::SameLine(); + + if (ImGui::SmallButton(std::string(custom_button_name + "##" + element_name).data())) + ImGui::OpenPopup(element_name.data()); + + ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f, ImGui::GetIO().DisplaySize.y * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); + if (ImGui::BeginPopupModal(element_name.data(), nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_Modal | ImGuiWindowFlags_AlwaysAutoResize)) + { + render_elements(); + ImGui::Spacing(); + if (ImGui::Button(std::string("Close##" + element_name).data()) || ((!ImGui::IsWindowHovered() && !ImGui::IsAnyItemHovered()) && ImGui::IsMouseClicked(ImGuiMouseButton_Left))) + ImGui::CloseCurrentPopup(); + + ImGui::EndPopup(); + } + } +} \ No newline at end of file diff --git a/src/services/gui/gui_service.hpp b/src/services/gui/gui_service.hpp index ceb4c95b..428d1221 100644 --- a/src/services/gui/gui_service.hpp +++ b/src/services/gui/gui_service.hpp @@ -34,7 +34,6 @@ namespace big BLACKHOLE, MODEL_SWAPPER, NEARBY, - ORBITAL_DRONE, NETWORK, SESSION, @@ -123,7 +122,6 @@ namespace big {tabs::BLACKHOLE, {"GUI_TAB_BLACKHOLE", view::blackhole}}, {tabs::MODEL_SWAPPER, {"GUI_TAB_MODEL_SWAPPER", view::model_swapper}}, {tabs::NEARBY, {"GUI_TAB_NEARBY", view::nearby}}, - {tabs::ORBITAL_DRONE, {"GUI_TAB_ORBITAL_DRONE", view::orbital_drone}}, }, }, }, diff --git a/src/views/self/view_self.cpp b/src/views/self/view_self.cpp index c698ad89..261c8154 100644 --- a/src/views/self/view_self.cpp +++ b/src/views/self/view_self.cpp @@ -63,6 +63,29 @@ namespace big ImGui::Checkbox("DANCE_MODE"_T.data(), &g.self.dance_mode); + components::command_checkbox<"orbitaldrone">(); + components::options_modal("Orbital drone", []{ + ImGui::Separator(); + ImGui::BeginGroup(); + ImGui::Text("ORBITAL_DRONE_USAGE_DESCR"_T.data()); + ImGui::EndGroup(); + ImGui::Separator(); + + ImGui::BeginGroup(); + ImGui::Checkbox("ORBITAL_DRONE_AUTO_LOCK_ON_PLAYER"_T.data(), &g.world.orbital_drone.detect_player); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("ORBITAL_DRONE_AUTO_LOCK_ON_PLAYER_TOOLTIP"_T.data()); + ImGui::EndTooltip(); + } + ImGui::Text("ORBITAL_DRONE_HIGH_SPEED_MULTIPLIER"_T.data()); + ImGui::SliderFloat("##fastspeed", &g.world.orbital_drone.nav_ovverride_fast, 1.f, 10.f); + ImGui::Text("ORBITAL_DRONE_LOW_SPEED_MULTIPLIER"_T.data()); + ImGui::SliderFloat("##slowspeed", &g.world.orbital_drone.nav_ovverride_slow, 0.f, 1.f); + ImGui::EndGroup(); + }); + ImGui::EndGroup(); components::sub_title("PTFX Styles"); diff --git a/src/views/view.hpp b/src/views/view.hpp index 2f687f8b..6e21f876 100644 --- a/src/views/view.hpp +++ b/src/views/view.hpp @@ -30,7 +30,6 @@ namespace big static void mobile(); static void navigation(); static void notifications(); - static void orbital_drone(); static void overlay(); static void root(); static void self(); diff --git a/src/views/world/view_orbital_drone.cpp b/src/views/world/view_orbital_drone.cpp deleted file mode 100644 index 74ef529f..00000000 --- a/src/views/world/view_orbital_drone.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "views/view.hpp" - -namespace big -{ - void view::orbital_drone() - { - components::command_checkbox<"orbitaldrone">(); - - if (g.world.orbital_drone.enabled) - { - ImGui::Separator(); - ImGui::BeginGroup(); - ImGui::Text("ORBITAL_DRONE_USAGE_DESCR"_T.data()); - ImGui::EndGroup(); - ImGui::Separator(); - - ImGui::BeginGroup(); - ImGui::Checkbox("ORBITAL_DRONE_AUTO_LOCK_ON_PLAYER"_T.data(), &g.world.orbital_drone.detect_player); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("ORBITAL_DRONE_AUTO_LOCK_ON_PLAYER_TOOLTIP"_T.data()); - ImGui::EndTooltip(); - } - ImGui::Text("ORBITAL_DRONE_HIGH_SPEED_MULTIPLIER"_T.data()); - ImGui::SliderFloat("##fastspeed", &g.world.orbital_drone.nav_ovverride_fast, 1.f, 10.f); - ImGui::Text("ORBITAL_DRONE_LOW_SPEED_MULTIPLIER"_T.data()); - ImGui::SliderFloat("##slowspeed", &g.world.orbital_drone.nav_ovverride_slow, 0.f, 1.f); - ImGui::EndGroup(); - } - - } -} \ No newline at end of file