diff --git a/src/gui/components/components.hpp b/src/gui/components/components.hpp index 14ad3457..d2c9559c 100644 --- a/src/gui/components/components.hpp +++ b/src/gui/components/components.hpp @@ -23,6 +23,7 @@ namespace big static void nav_item(std::pair&, 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 cb = nullptr); + static void input_text(const std::string_view label, char* buf, size_t buf_size, ImGuiInputTextFlags_ flag = ImGuiInputTextFlags_None, std::function cb = nullptr); static bool selectable(const std::string_view, bool); static bool selectable(const std::string_view, bool, ImGuiSelectableFlags); diff --git a/src/gui/components/input_text.cpp b/src/gui/components/input_text.cpp new file mode 100644 index 00000000..73487acd --- /dev/null +++ b/src/gui/components/input_text.cpp @@ -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 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); + }); + } +} \ No newline at end of file diff --git a/src/views/network/view_player_database.cpp b/src/views/network/view_player_database.cpp index 27f82637..1e6f52e3 100644 --- a/src/views/network/view_player_database.cpp +++ b/src/views/network/view_player_database.cpp @@ -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")) diff --git a/src/views/network/view_session.cpp b/src/views/network/view_session.cpp index 399fc030..a1015441 100644 --- a/src/views/network/view_session.cpp +++ b/src/views/network/view_session.cpp @@ -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); diff --git a/src/views/network/view_spoofing.cpp b/src/views/network/view_spoofing.cpp index 428c457d..9a66f1a3 100644 --- a/src/views/network/view_spoofing.cpp +++ b/src/views/network/view_spoofing.cpp @@ -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); diff --git a/src/views/world/view_creator.cpp b/src/views/world/view_creator.cpp index 596ee5e0..1fd43a7e 100644 --- a/src/views/world/view_creator.cpp +++ b/src/views/world/view_creator.cpp @@ -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", [] {