Added options_modal component & showcase with Orbital drone feature (#1353)

This commit is contained in:
DayibBaba 2023-05-19 10:30:25 +02:00 committed by GitHub
parent 4147bc583a
commit c1fc45ea64
6 changed files with 52 additions and 36 deletions

View File

@ -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<void()> render_elements, bool sameline = true, std::string custom_button_name = "Options");
template<template_str cmd_str, ImVec2 size = ImVec2(0, 0), ImVec4 color = ImVec4(0.24f, 0.23f, 0.29f, 1.00f)>
static void command_button(const std::vector<std::uint64_t> args = {}, std::optional<const std::string_view> label_override = std::nullopt)
{

View File

@ -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<void()> 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();
}
}
}

View File

@ -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}},
},
},
},

View File

@ -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");

View File

@ -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();

View File

@ -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();
}
}
}