mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-07-01 12:02:55 +08:00
refactor!: Replace premake5 with CMake. (#551)
Co-authored-by: tupoy-ya <tupoy-ya@users.noreply.github.com>
This commit is contained in:
23
src/views/debug/view_debug.cpp
Normal file
23
src/views/debug/view_debug.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "services/gui/gui_service.hpp"
|
||||
#include "view_debug.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void debug::main()
|
||||
{
|
||||
if (strcmp(g_gui_service->get_selected()->name, "Debug"))
|
||||
return;
|
||||
|
||||
if (ImGui::Begin("Debug"))
|
||||
{
|
||||
ImGui::BeginTabBar("debug_tabbar");
|
||||
misc();
|
||||
logs();
|
||||
globals();
|
||||
locals();
|
||||
script_events();
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
12
src/views/debug/view_debug.hpp
Normal file
12
src/views/debug/view_debug.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
namespace big::debug
|
||||
{
|
||||
extern void globals();
|
||||
extern void locals();
|
||||
extern void logs();
|
||||
extern void misc();
|
||||
extern void script_events();
|
||||
|
||||
extern void main();
|
||||
}
|
161
src/views/debug/view_debug_globals.cpp
Normal file
161
src/views/debug/view_debug_globals.cpp
Normal file
@ -0,0 +1,161 @@
|
||||
#include "gui/components/components.hpp"
|
||||
#include "services/globals/globals_service.hpp"
|
||||
#include "thread_pool.hpp"
|
||||
#include "view_debug.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void debug::globals()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Globals"))
|
||||
{
|
||||
if (ImGui::Checkbox("Enable Freezing", &g_globals_service->m_running) && g_globals_service->m_running)
|
||||
g_thread_pool->push([&]() { g_globals_service->loop(); });
|
||||
|
||||
if (components::button("Load"))
|
||||
g_globals_service->load();
|
||||
ImGui::SameLine();
|
||||
if (components::button("Save"))
|
||||
g_globals_service->save();
|
||||
|
||||
|
||||
ImGui::SameLine();
|
||||
if (components::button("Add Global"))
|
||||
{
|
||||
ImGui::OpenPopup("New Global");
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupModal("New Global"))
|
||||
{
|
||||
static int base_address = 0;
|
||||
static bool freeze = false;
|
||||
static char name[32] = "";
|
||||
static int(*offsets)[2] = nullptr;
|
||||
static int offset_count = 0;
|
||||
static int previous_offset_count = 0;
|
||||
|
||||
ImGui::Text("Name:");
|
||||
components::input_text_with_hint("##global_name", "Name", name, sizeof(name));
|
||||
ImGui::Text("Base Address:");
|
||||
ImGui::InputInt("##modal_global_base_addr", &base_address);
|
||||
ImGui::Text("Freeze:");
|
||||
ImGui::Checkbox("##modal_global_freeze", &freeze);
|
||||
ImGui::Text("Number of Offsets:");
|
||||
ImGui::InputInt("##modal_offset_count", &offset_count);
|
||||
|
||||
if (offset_count < 0) offset_count = 0;
|
||||
else if (offset_count > 10) offset_count = 10;
|
||||
|
||||
if (offset_count != previous_offset_count)
|
||||
{
|
||||
int(*new_offsets)[2] = new int[offset_count][2]{ 0 };
|
||||
memcpy(new_offsets, offsets, sizeof(int) * std::min(offset_count, previous_offset_count) * 2);
|
||||
|
||||
delete[] offsets;
|
||||
offsets = new_offsets;
|
||||
|
||||
previous_offset_count = offset_count;
|
||||
}
|
||||
|
||||
ImGui::PushItemWidth(320.f);
|
||||
for (int i = 0; i < offset_count; i++)
|
||||
{
|
||||
ImGui::PushID(i);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Offset: %d", i + 1);
|
||||
ImGui::InputInt("##offset", &offsets[i][0]);
|
||||
|
||||
ImGui::Text("Size:");
|
||||
ImGui::SameLine();
|
||||
ImGui::InputInt("##size", &offsets[i][1]);
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
if (components::button("Cancel"))
|
||||
{
|
||||
strcpy(name, "");
|
||||
freeze = false;
|
||||
delete[] offsets;
|
||||
offsets = nullptr;
|
||||
offset_count = 0;
|
||||
previous_offset_count = 0;
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (components::button("Save"))
|
||||
{
|
||||
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;
|
||||
delete[] offsets;
|
||||
offsets = nullptr;
|
||||
offset_count = 0;
|
||||
previous_offset_count = 0;
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
for (auto& global : g_globals_service->m_globals)
|
||||
{
|
||||
char label[64];
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::PushID(global.get_id());
|
||||
ImGui::Checkbox("Freeze", &global.m_freeze);
|
||||
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text("Name:");
|
||||
ImGui::Text("Value:");
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Text(global.m_name.c_str());
|
||||
|
||||
sprintf(label, "###input_%d", global.get_id());
|
||||
ImGui::SetNextItemWidth(200.f);
|
||||
ImGui::InputInt(label, global.get());
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::BeginGroup();
|
||||
|
||||
if (components::button("Delete"))
|
||||
{
|
||||
for (int i = 0; i < g_globals_service->m_globals.size(); i++)
|
||||
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;
|
||||
}
|
||||
|
||||
if (components::button("Write"))
|
||||
global.write();
|
||||
|
||||
ImGui::PopID();
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
13
src/views/debug/view_debug_locals.cpp
Normal file
13
src/views/debug/view_debug_locals.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "view_debug.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void debug::locals()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Locals"))
|
||||
{
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
25
src/views/debug/view_debug_misc.cpp
Normal file
25
src/views/debug/view_debug_misc.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "gui/components/components.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/system.hpp"
|
||||
#include "view_debug.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void debug::misc()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Misc"))
|
||||
{
|
||||
if (components::button("Dump entrypoints"))
|
||||
{
|
||||
system::dump_entry_points();
|
||||
}
|
||||
|
||||
components::button("Network Bail", []
|
||||
{
|
||||
NETWORK::NETWORK_BAIL(16, 0, 0);
|
||||
});
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
66
src/views/debug/view_debug_script_events.cpp
Normal file
66
src/views/debug/view_debug_script_events.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include "gui/components/components.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include "view_debug.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void debug::script_events()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Script Events"))
|
||||
{
|
||||
static int64_t* args;
|
||||
static int event_arg_count = 3;
|
||||
static int previous_arg_count;
|
||||
static int event_player_bits;
|
||||
static bool event_everyone = false;
|
||||
|
||||
ImGui::Text("Script Argument Count:");
|
||||
ImGui::InputInt("###script_event_arg_count", &event_arg_count);
|
||||
if (event_arg_count > 32)
|
||||
event_arg_count = 32;
|
||||
else if (event_arg_count < 3)
|
||||
event_arg_count = 3;
|
||||
|
||||
if (event_arg_count != previous_arg_count)
|
||||
{
|
||||
int64_t* temp_args = new int64_t[event_arg_count]{ 0 };
|
||||
memcpy(temp_args, args, sizeof(int64_t) * std::min(event_arg_count, previous_arg_count));
|
||||
|
||||
delete[] args;
|
||||
args = temp_args;
|
||||
|
||||
previous_arg_count = event_arg_count;
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
for (int i = 0; i < event_arg_count; i++)
|
||||
{
|
||||
ImGui::PushID(i);
|
||||
ImGui::Text("Arg[%d]", i);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::InputScalar("###input_dynamic_arg", ImGuiDataType_S64, &args[i]);
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Checkbox("Send to everyone", &event_everyone);
|
||||
if (!event_everyone)
|
||||
{
|
||||
ImGui::Text("Player ID:");
|
||||
ImGui::InputInt("###player_bits", &event_player_bits);
|
||||
}
|
||||
|
||||
components::button("Send Event", []
|
||||
{
|
||||
args[1] = self::id; // prevent detection from AC
|
||||
g_pointers->m_trigger_script_event(1, args, event_arg_count, event_everyone ? -1 : 1 << event_player_bits);
|
||||
});
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
41
src/views/debug/views_debug_logs.cpp
Normal file
41
src/views/debug/views_debug_logs.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "gui/components/components.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
#include "view_debug.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void debug::logs()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Logs"))
|
||||
{
|
||||
ImGui::Checkbox("Log Metrics", &g->debug.logs.metric_logs);
|
||||
|
||||
ImGui::Checkbox("Native Script Hooks", &g->debug.logs.script_hook_logs);
|
||||
|
||||
if (ImGui::TreeNode("Script Event Logging"))
|
||||
{
|
||||
ImGui::Checkbox("Enable Script Event Logging", &g->debug.logs.script_event.logs);
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Checkbox("Filter by Player", &g->debug.logs.script_event.filter_player);
|
||||
|
||||
if (g->debug.logs.script_event.filter_player)
|
||||
{
|
||||
ImGui::ListBoxHeader("##filter_player");
|
||||
for (const auto& [_, player] : g_player_service->players())
|
||||
{
|
||||
if (components::selectable(player->get_name(), g->debug.logs.script_event.player_id == player->id()))
|
||||
{
|
||||
g->debug.logs.script_event.player_id = player->id();
|
||||
}
|
||||
}
|
||||
ImGui::EndListBox();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user