From c5f02179c55a2af7dda5abde08ab4bdb83cb517e Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Tue, 27 Sep 2022 01:56:06 +0200 Subject: [PATCH] Add "bankshadow" hudelem font --- src/client/component/fonts.cpp | 37 ++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/client/component/fonts.cpp b/src/client/component/fonts.cpp index 1e799e47..209f42c4 100644 --- a/src/client/component/fonts.cpp +++ b/src/client/component/fonts.cpp @@ -34,7 +34,8 @@ namespace fonts "subtitle", "timer", "nameplate", - "bank" + "bank", + "bankshadow", }; struct font_data_t @@ -120,7 +121,7 @@ namespace fonts game::Font_s* ui_get_font_handle_stub(void* a1, int font_index) { - if (font_index == 12 && bank_font != nullptr) + if ((font_index == 12 || font_index == 13) && bank_font != nullptr) { return bank_font; } @@ -149,6 +150,11 @@ namespace fonts return 12; } + if (hudelem_font_index == 13) + { + return 13; + } + return current; } @@ -168,6 +174,27 @@ namespace fonts a.jmp(0x14037B39E); } + + void get_hud_elem_text_style_stub(utils::hook::assembler& a) + { + const auto set_style = a.newLabel(); + const auto loc_14037AF98 = a.newLabel(); + a.mov(eax, dword_ptr(rdi, 4)); + a.cmp(eax, 13); // 13 => bankshadow index + a.jz(set_style); + + a.cmp(eax, 9); + a.jnz(loc_14037AF98); + a.mov(edx, 0x400); + a.jmp(0x14037AFA5); + + a.bind(set_style); + a.mov(edx, 4); // 4 => shadowed style + a.jmp(0x14037AFA5); + + a.bind(loc_14037AF98); + a.jmp(0x14037AF98); + } } void add(const std::string& name, const std::string& data) @@ -200,12 +227,14 @@ namespace fonts utils::hook::call(0x140747096, db_find_xasset_header_stub); // add fonts/bank.ttf to hud elem fonts - // make font index 12 => bank.ttf + // make font index 12, 13 => bank.ttf ui_asset_cache_hook.create(0x140606090, ui_asset_cache_stub); ui_get_font_handle_hook.create(0x1406058F0, ui_get_font_handle_stub); utils::hook::jump(0x14037B390, utils::hook::assemble(get_hud_elem_info_stub), true); utils::hook::inject(0x1404C17A6, hudelem_fonts); - utils::hook::set(0x1404C17B7, 13); // 13 hud elem fonts + utils::hook::set(0x1404C17B7, 14); // 14 hud elem fonts + // make bankshadow have text style 4 (dropshadow) + utils::hook::jump(0x14037AF89, utils::hook::assemble(get_hud_elem_text_style_stub), true); command::add("dumpFont", [](const command::params& params) {