Delay imgui initialization

This commit is contained in:
Federico Cecchetto 2022-07-19 03:26:26 +02:00
parent 54c7d0f5e5
commit 1f2025d75e
2 changed files with 21 additions and 10 deletions

View File

@ -6,6 +6,7 @@
#include "scheduler.hpp"
#include "gui.hpp"
#include "console.hpp"
#include <utils/string.hpp>
#include <utils/hook.hpp>
@ -175,8 +176,14 @@ namespace gui
void gui_on_frame()
{
if (!game::Sys_IsDatabaseReady2())
{
return;
}
if (!initialized)
{
console::info("[ImGui] Initializing\n");
initialize_gui_context();
}
else
@ -212,7 +219,7 @@ namespace gui
a.mov(r8d, esi);
a.mov(edx, r15d);
a.mov(rcx, rdi);
a.call_aligned(rbx);
a.call(rbx);
a.mov(ecx, eax);
a.jmp(0x1407A14D1);
@ -308,7 +315,8 @@ namespace gui
void post_unpack() override
{
utils::hook::jump(0x1407A14C4, utils::hook::assemble(dxgi_swap_chain_present_stub), true);
utils::hook::nop(0x1407A14BB, 9);
utils::hook::call(0x1407A14BE, gui_on_frame);
wnd_proc_hook.create(0x140650F10, wnd_proc_stub);
on_frame([]()

View File

@ -215,6 +215,17 @@ namespace loadscreen
class component final : public component_interface
{
public:
void post_start() override
{
scheduler::loop([]()
{
if (in_loadscreen())
{
draw_loadscreen();
}
}, scheduler::pipeline::renderer);
}
void post_unpack() override
{
// not registered, used in CL_StartLoading
@ -231,14 +242,6 @@ namespace loadscreen
cl_loadscreen_obj = dvars::register_string("cl_loadscreenObj", "", 0, "Loadscreen mission objective");
cl_loadscreen_obj_icon = dvars::register_string("cl_loadscreenObjIcon", "", 0, "Loadscreen mission objective icon");
}, scheduler::pipeline::main);
scheduler::loop([]()
{
if (in_loadscreen())
{
draw_loadscreen();
}
}, scheduler::pipeline::renderer);
}
};
}