This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/gui/components/input_text.cpp
gir489 48e83d9d5d
Clone Debug Globals into Debug Locals (#2419)
* Copied code from Debug Globals to Debug Locals.
Redesigned components::input_text to return the InputText result, and add an overloaded method to take a std::string.
Fixed Debug Globals having static text and not using components::input_text to prevent sending the input to the game.
Fixed view_debug_threads::thread_states not properly ending its string causing ImGui to read more than it should from memory.
Made Debug Globals cap the input index to UINT32, as the user could potentially overflow the get_ptr function and cause the game to crash.

* Removed extraneous does_thread_exist deceleration.
2023-11-16 14:17:46 +01:00

39 lines
913 B
C++

#include "fiber_pool.hpp"
#include "gui/components/components.hpp"
#include "misc/cpp/imgui_stdlib.h"
#include "natives.hpp"
namespace big
{
bool components::input_text(const std::string_view label, char* buf, size_t buf_size, ImGuiInputTextFlags_ flag, std::function<void()> cb)
{
bool retval = false;
if (ImGui::InputText(label.data(), buf, buf_size, flag))
{
if (cb)
g_fiber_pool->queue_job(std::move(cb));
retval = true;
}
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
return retval;
}
bool components::input_text(const std::string_view label, std::string& buf, ImGuiInputTextFlags_ flag, std::function<void()> cb)
{
bool retval = false;
if (ImGui::InputText(label.data(), &buf, flag))
{
if (cb)
g_fiber_pool->queue_job(std::move(cb));
retval = true;
}
if (ImGui::IsItemActive())
g.self.hud.typing = TYPING_TICKS;
return retval;
}
}