feat(GUI): Added debug window

This commit is contained in:
Yimura 2021-12-22 21:41:00 +01:00
parent 28773c63b1
commit 0856f3eab5
8 changed files with 136 additions and 0 deletions

View File

@ -9,6 +9,8 @@ namespace big
window::log();
window::debug();
window::main();
window::handling();

View File

@ -4,6 +4,7 @@ namespace big
{
class window {
public:
static void debug();
static void top_bar();
static void handling();
static void log();

View File

@ -0,0 +1,18 @@
#include "debug_tabs.hpp"
#include "util/system.hpp"
namespace big
{
void tab_debug::_tab_debug()
{
if (ImGui::BeginTabItem("Debug"))
{
if (ImGui::Button("Dump entrypoints"))
{
system::dump_entry_points();
}
ImGui::EndTabItem();
}
}
}

View File

@ -0,0 +1,14 @@
#include "debug_tabs.hpp"
namespace big
{
void tab_debug::tab_globals()
{
if (ImGui::BeginTabItem("Globals"))
{
ImGui::Text("Coming soon...");
ImGui::EndTabItem();
}
}
}

View File

@ -0,0 +1,68 @@
#include "debug_tabs.hpp"
#include "fiber_pool.hpp"
#include "pointers.hpp"
#include "script.hpp"
namespace big
{
void tab_debug::tab_script_events()
{
if (ImGui::BeginTabItem("Script Events"))
{
static int* args;
static int event_arg_count = 1;
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 < 1)
event_arg_count = 1;
if (event_arg_count != previous_arg_count)
{
int* temp_args = new int[event_arg_count] {0};
memcpy(temp_args, args, sizeof(int) * 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::Text("Arg[%d]", i);
ImGui::SameLine();
char input_arg_name[20];
sprintf(input_arg_name, "###input_dynamic_arg_%d", i);
ImGui::InputInt(input_arg_name, &args[i]);
}
ImGui::Separator();
ImGui::Checkbox("Send to everyone", &event_everyone);
if (!event_everyone)
{
ImGui::Text("Player ID:");
ImGui::InputInt("###player_bits", &event_player_bits);
}
if (ImGui::Button("Send Event"))
{
QUEUE_JOB_BEGIN_CLAUSE()
{
g_pointers->m_trigger_script_event(1, args, event_arg_count, event_everyone ? -1 : 1 << event_player_bits);
}QUEUE_JOB_END_CLAUSE
}
ImGui::EndTabItem();
}
}
}

View File

@ -0,0 +1,13 @@
#pragma once
#include "common.hpp"
#include "imgui.h"
namespace big
{
class tab_debug {
public:
static void tab_globals();
static void tab_script_events();
static void _tab_debug();
};
}

View File

@ -0,0 +1,19 @@
#include "gui/window.hpp"
#include "dbg/debug_tabs.hpp"
namespace big
{
void window::debug()
{
if (g.window.debug && ImGui::Begin("Dev"))
{
ImGui::BeginTabBar("dev_tabbar");
tab_debug::_tab_debug();
tab_debug::tab_globals();
tab_debug::tab_script_events();
ImGui::EndTabBar();
ImGui::End();
}
}
}

View File

@ -54,6 +54,7 @@ namespace big
ImGui::MenuItem("Main", nullptr, &g.window.main);
ImGui::MenuItem("Players", nullptr, &g.window.users);
ImGui::MenuItem("Logs", nullptr, &g.window.log);
ImGui::MenuItem("Debug", nullptr, &g.window.debug);
ImGui::EndMenu();
}