add cg_draw2d

This commit is contained in:
quaK 2023-02-10 12:48:10 +02:00
parent 3c6e4de5c8
commit e8be93a37e
3 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,47 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
#include "scheduler.hpp"
#include <utils/hook.hpp>
namespace ui
{
namespace
{
utils::hook::detour cg_draw2d_hook;
void cg_draw2d_stub(__int64 a1)
{
if (dvars::cg_draw2D && !dvars::cg_draw2D->current.enabled)
{
return;
}
cg_draw2d_hook.invoke<void>(a1);
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
if (game::environment::is_dedi())
{
return;
}
scheduler::once([]()
{
dvars::cg_draw2D = game::Dvar_RegisterBool("cg_draw2D", true, game::DVAR_FLAG_NONE, "Draw 2D screen elements");
}, scheduler::main);
cg_draw2d_hook.create(0x781D90_b, cg_draw2d_stub);
}
};
}
REGISTER_COMPONENT(ui::component)

View File

@ -23,6 +23,8 @@ namespace dvars
game::dvar_t* lui_debug = nullptr;
game::dvar_t* cg_draw2D = nullptr;
game::dvar_t* r_fullbright = nullptr;
game::dvar_t* bg_bounces = nullptr;

View File

@ -19,6 +19,8 @@ namespace dvars
extern game::dvar_t* lui_debug;
extern game::dvar_t* cg_draw2D;
extern game::dvar_t* r_fullbright;
extern game::dvar_t* bg_bounces;