Disable input when typing into a text field. (#2140)

Closes #2139
This commit is contained in:
gir489 2023-09-17 16:23:26 -04:00 committed by GitHub
parent a4209c1b23
commit 347f33fb2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 41 additions and 19 deletions

View File

@ -117,6 +117,7 @@ namespace big
while (g_running) while (g_running)
{ {
looped::hud_transition_state(); looped::hud_transition_state();
looped::hud_disable_input();
looped::session_pop_multiplier_areas(); looped::session_pop_multiplier_areas();
looped::session_force_thunder(); looped::session_force_thunder();
looped::session_randomize_ceo_colors(); looped::session_randomize_ceo_colors();

View File

@ -0,0 +1,14 @@
#include "backend/looped/looped.hpp"
#include "natives.hpp"
namespace big
{
void looped::hud_disable_input()
{
if (g.self.hud.typing)
{
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
g.self.hud.typing--;
}
}
}

View File

@ -18,6 +18,7 @@ namespace big
{ {
public: public:
static void hud_transition_state(); static void hud_transition_state();
static void hud_disable_input();
static void player_good_options(); static void player_good_options();
static void player_toxic_options(); static void player_toxic_options();

View File

@ -15,6 +15,7 @@
#define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h> #include <imgui.h>
#define TYPING_TICKS 3
class CNetGamePlayer; class CNetGamePlayer;
enum class eNetObjType; enum class eNetObjType;
@ -363,6 +364,7 @@ namespace big
std::array<bool, 22> hud_components_states = {false}; std::array<bool, 22> hud_components_states = {false};
bool force_show_hud_element = false; bool force_show_hud_element = false;
bool force_show_hud = false; bool force_show_hud = false;
std::atomic_uint_fast8_t typing = 0;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(hud, color_override, color_override_initialized, hud_color_overrides, hide_radar, hide_ammo, selected_hud_component, hud_components_states, force_show_hud_element, force_show_hud) NLOHMANN_DEFINE_TYPE_INTRUSIVE(hud, color_override, color_override_initialized, hud_color_overrides, hide_radar, hide_ammo, selected_hud_component, hud_components_states, force_show_hud_element, force_show_hud)
} hud{}; } hud{};

View File

@ -11,8 +11,6 @@ namespace big
g_fiber_pool->queue_job(std::move(cb)); g_fiber_pool->queue_job(std::move(cb));
if (ImGui::IsItemActive()) if (ImGui::IsItemActive())
g_fiber_pool->queue_job([] { g.self.hud.typing = TYPING_TICKS;
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
} }
} }

View File

@ -12,11 +12,7 @@ namespace big
g_fiber_pool->queue_job(std::move(cb)); g_fiber_pool->queue_job(std::move(cb));
if (ImGui::IsItemActive()) if (ImGui::IsItemActive())
{ g.self.hud.typing = TYPING_TICKS;
g_fiber_pool->queue_job([] {
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
}
return returned; return returned;
} }
@ -27,11 +23,7 @@ namespace big
g_fiber_pool->queue_job(std::move(cb)); g_fiber_pool->queue_job(std::move(cb));
if (ImGui::IsItemActive()) if (ImGui::IsItemActive())
{ g.self.hud.typing = TYPING_TICKS;
g_fiber_pool->queue_job([] {
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
}
return returned; return returned;
} }
} }

View File

@ -88,7 +88,7 @@ namespace big
if (g.cmd_executor.enabled) if (g.cmd_executor.enabled)
return; return;
if (g_gui->is_open()) if (g_gui->is_open() || HUD::IS_PAUSE_MENU_ACTIVE() || SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("cellphone_flashhand")) > 0 || HUD::IS_MP_TEXT_CHAT_TYPING())
return; return;
if (state == eKeyState::RELEASE || state == eKeyState::DOWN) if (state == eKeyState::RELEASE || state == eKeyState::DOWN)

View File

@ -219,6 +219,8 @@ namespace big
static char global_name[50]{}; static char global_name[50]{};
ImGui::SetNextItemWidth(200.f); ImGui::SetNextItemWidth(200.f);
ImGui::InputText("##GlobalName", global_name, IM_ARRAYSIZE(global_name)); ImGui::InputText("##GlobalName", global_name, IM_ARRAYSIZE(global_name));
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
if (ImGui::Button("Save Global")) if (ImGui::Button("Save Global"))
{ {
save_global(global_name, global_test); save_global(global_name, global_test);

View File

@ -120,6 +120,8 @@ namespace big
{ {
current_player->name = name_buf; current_player->name = name_buf;
} }
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
if (ImGui::InputScalar("RID"_T.data(), ImGuiDataType_S64, &current_player->rockstar_id) if (ImGui::InputScalar("RID"_T.data(), ImGuiDataType_S64, &current_player->rockstar_id)
|| ImGui::Checkbox("IS_MODDER"_T.data(), &current_player->is_modder) || ImGui::Checkbox("IS_MODDER"_T.data(), &current_player->is_modder)
@ -189,6 +191,8 @@ namespace big
current_player->notes = note_buffer; current_player->notes = note_buffer;
notes_dirty = true; notes_dirty = true;
} }
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
ImGui::Checkbox("Join Redirect", &current_player->join_redirect); ImGui::Checkbox("Join Redirect", &current_player->join_redirect);
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())

View File

@ -182,6 +182,8 @@ namespace big
ImGui::SetNextItemWidth(300); ImGui::SetNextItemWidth(300);
ImGui::InputText("##outfit_name", outfit_name, sizeof(outfit_name)); ImGui::InputText("##outfit_name", outfit_name, sizeof(outfit_name));
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
ImGui::SameLine(); ImGui::SameLine();
components::button("OUTFIT_SAVE_CURRENT"_T, [] { components::button("OUTFIT_SAVE_CURRENT"_T, [] {

View File

@ -21,6 +21,8 @@ namespace big
ImGui::SetNextItemWidth(300); ImGui::SetNextItemWidth(300);
ImGui::InputText("OUTFIT_NAME"_T.data(), outfit::get_slot_name_address(slot), 16); ImGui::InputText("OUTFIT_NAME"_T.data(), outfit::get_slot_name_address(slot), 16);
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
static outfit::components_t components; static outfit::components_t components;
static outfit::props_t props; static outfit::props_t props;

View File

@ -141,11 +141,7 @@ namespace big
g.weapons.vehicle_gun_model = vehicle_gun; g.weapons.vehicle_gun_model = vehicle_gun;
} }
if (ImGui::IsItemActive()) if (ImGui::IsItemActive())
{ g.self.hud.typing = TYPING_TICKS;
g_fiber_pool->queue_job([] {
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
});
}
break; break;
case CustomWeapon::PAINT_GUN: case CustomWeapon::PAINT_GUN:

View File

@ -132,6 +132,8 @@ namespace big
components::small_text("VEHICLE_FILE_NAME"_T); components::small_text("VEHICLE_FILE_NAME"_T);
ImGui::SetNextItemWidth(250); ImGui::SetNextItemWidth(250);
ImGui::InputText("##vehiclefilename", vehicle_file_name_input, IM_ARRAYSIZE(vehicle_file_name_input)); ImGui::InputText("##vehiclefilename", vehicle_file_name_input, IM_ARRAYSIZE(vehicle_file_name_input));
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
ImGui::SetTooltip("VEHICLE_FILE_NAME_EXAMPLE"_T.data()); ImGui::SetTooltip("VEHICLE_FILE_NAME_EXAMPLE"_T.data());
@ -139,6 +141,8 @@ namespace big
components::small_text("VEHICLE_FOLDER_NAME"_T); components::small_text("VEHICLE_FOLDER_NAME"_T);
ImGui::SetNextItemWidth(250); ImGui::SetNextItemWidth(250);
ImGui::InputText("##foldername", save_folder, IM_ARRAYSIZE(save_folder)); ImGui::InputText("##foldername", save_folder, IM_ARRAYSIZE(save_folder));
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
ImGui::SetTooltip("VEHICLE_FOLDER_NAME_EXAMPLE"_T.data()); ImGui::SetTooltip("VEHICLE_FOLDER_NAME_EXAMPLE"_T.data());

View File

@ -16,9 +16,13 @@ namespace big
ImGui::SetNextItemWidth(width); ImGui::SetNextItemWidth(width);
ImGui::InputText("Dst", dst_text, IM_ARRAYSIZE(dst_text)); ImGui::InputText("Dst", dst_text, IM_ARRAYSIZE(dst_text));
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(width); ImGui::SetNextItemWidth(width);
ImGui::InputText("Src", src_text, IM_ARRAYSIZE(src_text)); ImGui::InputText("Src", src_text, IM_ARRAYSIZE(src_text));
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Add/Change")) if (ImGui::Button("Add/Change"))