chore: Replace ImGui::InputText with components::input_text (#869)

Fixes #862
This commit is contained in:
TheGreenBandit 2023-01-16 15:58:57 -05:00 committed by GitHub
parent 7433b0a69f
commit 61f125901e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 13 deletions

View File

@ -23,6 +23,7 @@ namespace big
static void nav_item(std::pair<tabs, navigation_struct>&, int);
static void input_text_with_hint(const std::string_view label, const std::string_view hint, char* buf, size_t buf_size, ImGuiInputTextFlags_ flag = ImGuiInputTextFlags_None, std::function<void()> cb = nullptr);
static void input_text(const std::string_view label, char* buf, size_t buf_size, ImGuiInputTextFlags_ flag = ImGuiInputTextFlags_None, std::function<void()> cb = nullptr);
static bool selectable(const std::string_view, bool);
static bool selectable(const std::string_view, bool, ImGuiSelectableFlags);

View File

@ -0,0 +1,17 @@
#include "gui/components/components.hpp"
#include "fiber_pool.hpp"
#include "natives.hpp"
namespace big
{
void components::input_text(const std::string_view label, char* buf, size_t buf_size, ImGuiInputTextFlags_ flag, std::function<void()> cb) {
if (ImGui::InputText(label.data(), buf, buf_size, flag))
if (cb)
g_fiber_pool->queue_job(std::move(cb));
if (ImGui::IsItemActive())
g_fiber_pool->queue_job([] {
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
}
}

View File

@ -134,7 +134,7 @@ namespace big
});
static char message[256];
ImGui::InputText("Input Message", message, sizeof(message));
components::input_text("Input Message", message, sizeof(message));
if (components::button("Send Message"))
{
g_thread_pool->push([selected]
@ -180,7 +180,7 @@ namespace big
static char new_name[64];
static int64_t new_rockstar_id;
ImGui::InputText("Name", new_name, sizeof(new_name));
components::input_text("Name", new_name, sizeof(new_name));
ImGui::InputScalar("Rockstar ID", ImGuiDataType_S64, &new_rockstar_id);
if (ImGui::Button("Add"))

View File

@ -31,7 +31,7 @@ namespace big
});
static char username[20];
ImGui::InputText("Input Username", username, sizeof(username));
components::input_text("Input Username", username, sizeof(username));
if (components::button("Join by Username"))
{
session::join_by_username(username);
@ -43,7 +43,7 @@ namespace big
};
static char base64[500]{};
ImGui::InputText("Session Info", base64, sizeof(base64));
components::input_text("Session Info", base64, sizeof(base64));
components::button("Join Session Info", []
{
rage::rlSessionInfo info;
@ -101,7 +101,7 @@ namespace big
ImGui::Checkbox("Log Chat Messages", &g.session.log_chat_messages);
ImGui::Checkbox("Log Text Messages", &g.session.log_text_messages);
static char msg[256];
ImGui::InputText("##message", msg, sizeof(msg));
components::input_text("##message", msg, sizeof(msg));
ImGui::SameLine();
ImGui::Checkbox("Is Team", &g.session.is_team);
ImGui::SameLine();
@ -179,7 +179,7 @@ namespace big
strcpy_s(name, sizeof(name), g.session.spoofed_name.c_str());
ImGui::Text("Name: ");
ImGui::InputText("##username_input", name, sizeof(name));
components::input_text("##username_input", name, sizeof(name));
if (name != g.session.spoofed_name)
g.session.spoofed_name = std::string(name);

View File

@ -9,10 +9,6 @@ namespace big
{
void view::spoofing()
{
g_fiber_pool->queue_job([] {
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
components::small_text("To spoof any of the below credentials you need to reconnect with the lobby.\nAll spoofed details will be only visible by other players, your game will still show your actual name, ip, rid...");
components::sub_title("Username");
@ -29,7 +25,7 @@ namespace big
strcpy_s(name, sizeof(name), g.spoofing.username.c_str());
ImGui::Text("Username:");
ImGui::InputText("##username_input", name, sizeof(name));
components::input_text("##username_input", name, sizeof(name));
if (name != g.spoofing.username)
g.spoofing.username = std::string(name);
@ -67,7 +63,7 @@ namespace big
strcpy_s(crew_tag, sizeof(crew_tag), g.spoofing.crew_tag.c_str());
ImGui::Text("Crew Tag:");
ImGui::InputText("##crew_tag_input", crew_tag, sizeof(crew_tag));
components::input_text("##crew_tag_input", crew_tag, sizeof(crew_tag));
if (crew_tag != g.spoofing.crew_tag)
g.spoofing.crew_tag = std::string(crew_tag);

View File

@ -77,7 +77,7 @@ namespace big
ImGui::Separator();
static char job_link[69]{};
ImGui::InputText("SocialClub Job Link", job_link, sizeof(job_link));
components::input_text("SocialClub Job Link", job_link, sizeof(job_link));
components::button("Import", []
{