mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-01-07 09:53:50 +08:00
fix(Globals): Globals created at runtime need their cache built
This commit is contained in:
parent
d76ca9c23c
commit
adb95d3f46
@ -30,28 +30,28 @@ namespace big
|
||||
ImGui::Separator();
|
||||
|
||||
char label[64];
|
||||
sprintf(label, "Freeze###freeze_%d", global.m_base_address);
|
||||
sprintf(label, "Freeze###freeze_%d", global.get_id());
|
||||
ImGui::Checkbox(label, &global.m_freeze);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::Text(global.m_name.c_str());
|
||||
ImGui::SameLine();
|
||||
|
||||
sprintf(label, "###input_%d", global.m_base_address);
|
||||
sprintf(label, "###input_%d", global.get_id());
|
||||
ImGui::PushItemWidth(200.f);
|
||||
ImGui::InputInt(label, global.get());
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
sprintf(label, "Write###btn_%d", global.m_base_address);
|
||||
sprintf(label, "Write###btn_%d", global.get_id());
|
||||
if (ImGui::Button(label))
|
||||
global.write();
|
||||
|
||||
ImGui::SameLine();
|
||||
sprintf(label, "Delete##delet_%d", global.m_base_address);
|
||||
sprintf(label, "Delete##delete_%d", global.get_id());
|
||||
if (ImGui::Button(label))
|
||||
{
|
||||
for (int i = 0; i < g_globals_service->m_globals.size(); i++)
|
||||
if (const auto& it = g_globals_service->m_globals.at(i); it.m_base_address == global.m_base_address && it.m_name == global.m_name)
|
||||
if (auto& it = g_globals_service->m_globals.at(i); it.get_id() == global.get_id())
|
||||
g_globals_service->m_globals.erase(g_globals_service->m_globals.begin() + i);
|
||||
|
||||
break;
|
||||
|
@ -80,7 +80,10 @@ namespace big
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Save"))
|
||||
{
|
||||
g_globals_service->m_globals.push_back(global(name, base_address, freeze, offsets, offset_count));
|
||||
auto new_global = global(name, base_address, freeze, offsets, offset_count);
|
||||
new_global.build_cache();
|
||||
|
||||
g_globals_service->m_globals.push_back(new_global);
|
||||
|
||||
strcpy(name, "");
|
||||
freeze = false;
|
||||
|
@ -52,6 +52,8 @@ namespace big
|
||||
|
||||
global(nlohmann::json data)
|
||||
{
|
||||
m_internal_id = ++m_instance_count;
|
||||
|
||||
m_base_address = data["base_address"];
|
||||
m_freeze = data["freeze"];
|
||||
m_name = data["name"];
|
||||
@ -63,6 +65,8 @@ namespace big
|
||||
|
||||
global(const char* name, const int base_address, const bool freeze, const int(*offsets)[2], int offset_count)
|
||||
{
|
||||
m_internal_id = ++m_instance_count;
|
||||
|
||||
m_base_address = base_address;
|
||||
m_freeze = freeze;
|
||||
m_name = std::string(name);
|
||||
@ -89,6 +93,11 @@ namespace big
|
||||
return m_internal_addr;
|
||||
}
|
||||
|
||||
int get_id()
|
||||
{
|
||||
return m_internal_id;
|
||||
}
|
||||
|
||||
void set(int value)
|
||||
{
|
||||
m_value = value;
|
||||
@ -118,6 +127,9 @@ namespace big
|
||||
}
|
||||
|
||||
private:
|
||||
inline static int m_instance_count;
|
||||
|
||||
int m_internal_id;
|
||||
int* m_internal_addr;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user