Add menudef overriding
This commit is contained in:
parent
145f2d81d8
commit
d10a101fec
@ -23,7 +23,7 @@ namespace fonts
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const char* hudelem_fonts[] =
|
std::array<const char*, game::HE_FONT_COUNT> hudelem_fonts
|
||||||
{
|
{
|
||||||
"",
|
"",
|
||||||
"bigfixed",
|
"bigfixed",
|
||||||
@ -45,26 +45,45 @@ namespace fonts
|
|||||||
game::Font_s* bank_font = nullptr;
|
game::Font_s* bank_font = nullptr;
|
||||||
|
|
||||||
utils::hook::detour ui_get_font_handle_hook;
|
utils::hook::detour ui_get_font_handle_hook;
|
||||||
|
utils::hook::detour ui_get_font_handle2_hook;
|
||||||
utils::hook::detour ui_asset_cache_hook;
|
utils::hook::detour ui_asset_cache_hook;
|
||||||
|
|
||||||
game::Font_s* ui_get_font_handle_stub(void* a1, int font_index)
|
game::Font_s* get_font_handle_at_index(int font_index)
|
||||||
{
|
{
|
||||||
if (font_index < 12 || bank_font == nullptr)
|
|
||||||
{
|
|
||||||
return ui_get_font_handle_hook.invoke<game::Font_s*>(a1, font_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (font_index)
|
switch (font_index)
|
||||||
{
|
{
|
||||||
case 12:
|
case game::HE_FONT_BANK:
|
||||||
case 13:
|
case game::HE_FONT_BANKSHADOW:
|
||||||
case 14:
|
case game::HE_FONT_BANKSHADOWMORE:
|
||||||
return bank_font;
|
return bank_font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
game::Font_s* ui_get_font_handle_stub(void* a1, int font_index)
|
||||||
|
{
|
||||||
|
const auto res = get_font_handle_at_index(font_index);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
return ui_get_font_handle_hook.invoke<game::Font_s*>(a1, font_index);
|
return ui_get_font_handle_hook.invoke<game::Font_s*>(a1, font_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
game::Font_s* ui_get_font_handle2_stub(void* a1, size_t a2)
|
||||||
|
{
|
||||||
|
const auto font_index = *reinterpret_cast<int*>(a2 + 208);
|
||||||
|
const auto res = get_font_handle_at_index(font_index);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ui_get_font_handle2_hook.invoke<game::Font_s*>(a1, a2);
|
||||||
|
}
|
||||||
|
|
||||||
game::Font_s* get_bank_font()
|
game::Font_s* get_bank_font()
|
||||||
{
|
{
|
||||||
if (language::is_asian())
|
if (language::is_asian())
|
||||||
@ -87,9 +106,9 @@ namespace fonts
|
|||||||
{
|
{
|
||||||
switch (hudelem_font_index)
|
switch (hudelem_font_index)
|
||||||
{
|
{
|
||||||
case 12:
|
case game::HE_FONT_BANK:
|
||||||
case 13:
|
case game::HE_FONT_BANKSHADOW:
|
||||||
case 14:
|
case game::HE_FONT_BANKSHADOWMORE:
|
||||||
return hudelem_font_index;
|
return hudelem_font_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,11 +136,11 @@ namespace fonts
|
|||||||
{
|
{
|
||||||
switch (font_index)
|
switch (font_index)
|
||||||
{
|
{
|
||||||
case 12:
|
case game::HE_FONT_BANK:
|
||||||
return 0; // none
|
return 0; // none
|
||||||
case 13:
|
case game::HE_FONT_BANKSHADOW:
|
||||||
return 2; // shadowed
|
return 2; // shadowed
|
||||||
case 14:
|
case game::HE_FONT_BANKSHADOWMORE:
|
||||||
return 4; // shadowed more
|
return 4; // shadowed more
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,10 +231,11 @@ namespace fonts
|
|||||||
// add custom fonts to hud elem fonts
|
// add custom fonts to hud elem fonts
|
||||||
ui_asset_cache_hook.create(0x140606090, ui_asset_cache_stub);
|
ui_asset_cache_hook.create(0x140606090, ui_asset_cache_stub);
|
||||||
ui_get_font_handle_hook.create(0x1406058F0, ui_get_font_handle_stub);
|
ui_get_font_handle_hook.create(0x1406058F0, ui_get_font_handle_stub);
|
||||||
|
ui_get_font_handle2_hook.create(0x1405F9820, ui_get_font_handle2_stub);
|
||||||
|
|
||||||
// change hudelem font array
|
// change hudelem font array
|
||||||
utils::hook::inject(0x1404C17A6, hudelem_fonts);
|
utils::hook::inject(0x1404C17A6, hudelem_fonts.data());
|
||||||
utils::hook::set(0x1404C17B7, static_cast<int>(ARRAYSIZE(hudelem_fonts)));
|
utils::hook::set(0x1404C17B7, static_cast<int>(hudelem_fonts.size()));
|
||||||
|
|
||||||
// handle custom fonts
|
// handle custom fonts
|
||||||
utils::hook::jump(0x14037B390, utils::hook::assemble(get_hud_elem_info_stub), true);
|
utils::hook::jump(0x14037B390, utils::hook::assemble(get_hud_elem_info_stub), true);
|
||||||
|
61
src/client/component/menus.cpp
Normal file
61
src/client/component/menus.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include <std_include.hpp>
|
||||||
|
#include "loader/component_loader.hpp"
|
||||||
|
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
|
#include "console.hpp"
|
||||||
|
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
|
||||||
|
namespace menus
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
constexpr auto patch_menu_list_name = "ui/patch_code.txt";
|
||||||
|
|
||||||
|
void ui_add_menu_list_stub(void* context, void* menu_list, int a3)
|
||||||
|
{
|
||||||
|
game::UI_AddMenuList(context, menu_list, a3);
|
||||||
|
|
||||||
|
if (game::DB_XAssetExists(game::ASSET_TYPE_MENUFILE, patch_menu_list_name) &&
|
||||||
|
!game::DB_IsXAssetDefault(game::ASSET_TYPE_MENUFILE, patch_menu_list_name))
|
||||||
|
{
|
||||||
|
const auto patch_code_list = game::UI_LoadMenus(patch_menu_list_name);
|
||||||
|
game::UI_AddMenuList(context, patch_code_list, a3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int menus_open_by_name_stub(void* context, const char* name)
|
||||||
|
{
|
||||||
|
const std::string override_name = "override/"s + name;
|
||||||
|
const auto override_menu = game::Menus_FindByName(context, override_name.data());
|
||||||
|
|
||||||
|
if (override_menu)
|
||||||
|
{
|
||||||
|
game::Menus_Open(context, override_menu, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto menu = game::Menus_FindByName(context, name);
|
||||||
|
if (menu)
|
||||||
|
{
|
||||||
|
game::Menus_Open(context, menu, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class component final : public component_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void post_unpack() override
|
||||||
|
{
|
||||||
|
utils::hook::call(0x1405F0A45, ui_add_menu_list_stub);
|
||||||
|
utils::hook::jump(game::Menus_OpenByName, menus_open_by_name_stub);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(menus::component)
|
@ -2949,6 +2949,26 @@ namespace game
|
|||||||
GamerProfileDataUnion u;
|
GamerProfileDataUnion u;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum HeFont
|
||||||
|
{
|
||||||
|
HE_FONT_DEFAULT = 0x0,
|
||||||
|
HE_FONT_BIGFIXED = 0x1,
|
||||||
|
HE_FONT_SMALLFIXED = 0x2,
|
||||||
|
HE_FONT_OBJECTIVE = 0x3,
|
||||||
|
HE_FONT_BIG = 0x4,
|
||||||
|
HE_FONT_SMALL = 0x5,
|
||||||
|
HE_FONT_HUDBIG = 0x6,
|
||||||
|
HE_FONT_HUDSMALL = 0x7,
|
||||||
|
HE_FONT_BUTTONPROMPT = 0x8,
|
||||||
|
HE_FONT_SUBTITLE = 0x9,
|
||||||
|
HE_FONT_TIMER = 0xA,
|
||||||
|
HE_FONT_NAMEPLATE = 0xB,
|
||||||
|
HE_FONT_BANK = 0xC,
|
||||||
|
HE_FONT_BANKSHADOW = 0xD,
|
||||||
|
HE_FONT_BANKSHADOWMORE = 0xE,
|
||||||
|
HE_FONT_COUNT,
|
||||||
|
};
|
||||||
|
|
||||||
namespace hks
|
namespace hks
|
||||||
{
|
{
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
|
@ -120,7 +120,11 @@ namespace game
|
|||||||
WEAK symbol<void(hks::lua_State* s)> LUI_EndEvent{0x140316890};
|
WEAK symbol<void(hks::lua_State* s)> LUI_EndEvent{0x140316890};
|
||||||
WEAK symbol<void()> LUI_EnterCriticalSection{0x140316980};
|
WEAK symbol<void()> LUI_EnterCriticalSection{0x140316980};
|
||||||
WEAK symbol<void()> LUI_LeaveCriticalSection{0x14031BC20};
|
WEAK symbol<void()> LUI_LeaveCriticalSection{0x14031BC20};
|
||||||
|
|
||||||
WEAK symbol<bool(int localClientNum, const char* menuName)> Menu_IsMenuOpenAndVisible{0x1405EE1A0};
|
WEAK symbol<bool(int localClientNum, const char* menuName)> Menu_IsMenuOpenAndVisible{0x1405EE1A0};
|
||||||
|
WEAK symbol<void*(void* context, const char* name)> Menus_FindByName{0x140603080};
|
||||||
|
WEAK symbol<void(void* context, const char* name)> Menus_OpenByName{0x140603770};
|
||||||
|
WEAK symbol<void(void* context, void* menu, int a3)> Menus_Open{0x1406034E0};
|
||||||
|
|
||||||
WEAK symbol<Material*(const char* material)> Material_RegisterHandle{0x140759BA0};
|
WEAK symbol<Material*(const char* material)> Material_RegisterHandle{0x140759BA0};
|
||||||
|
|
||||||
@ -211,6 +215,9 @@ namespace game
|
|||||||
WEAK symbol<void(ScreenPlacement* scrPlace, const char* text, rectDef_s* rect, Font_s* font, float x, float y,
|
WEAK symbol<void(ScreenPlacement* scrPlace, const char* text, rectDef_s* rect, Font_s* font, float x, float y,
|
||||||
float scale, const float* color, int style, int textAlignMode, rectDef_s* textRect, char a12)> UI_DrawWrappedText{0x1406055E0};
|
float scale, const float* color, int style, int textAlignMode, rectDef_s* textRect, char a12)> UI_DrawWrappedText{0x1406055E0};
|
||||||
|
|
||||||
|
WEAK symbol<void*(const char* name)> UI_LoadMenus{0x1406072B0};
|
||||||
|
WEAK symbol<void(void* context, void* menu_list, int a3)> UI_AddMenuList{0x140604FE0};
|
||||||
|
|
||||||
WEAK symbol<void(pmove_t* move, trace_t*, const float*, const float*,
|
WEAK symbol<void(pmove_t* move, trace_t*, const float*, const float*,
|
||||||
const Bounds*, int, int)> PM_playerTrace{0x14068F0A0};
|
const Bounds*, int, int)> PM_playerTrace{0x14068F0A0};
|
||||||
WEAK symbol<void(pmove_t*, trace_t*, const float*, const float*,
|
WEAK symbol<void(pmove_t*, trace_t*, const float*, const float*,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user