diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index 0b75a025..0faa17aa 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -63,6 +63,8 @@ namespace Components FastFiles::FastFiles() { + Dvar::Register("ui_zoneDebug", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display current loaded zone."); + // Redirect zone paths Utils::Hook(0x44DA90, FastFiles::GetZoneLocation, HOOK_JUMP).Install()->Quick(); @@ -94,6 +96,15 @@ namespace Components // Add custom zone paths FastFiles::AddZonePath("zone\\patch\\"); FastFiles::AddZonePath("zone\\dlc\\"); + + Renderer::OnFrame([] () + { + if (!FastFiles::Current().size() || !Dvar::Var("ui_zoneDebug").Get()) return; + + Game::Font_s* font = Game::R_RegisterFont("fonts/consoleFont"); // Inlining that seems to skip xpos, no idea why xD + float color[4] = { 1.0f, 1.0f, 1.0f, (Game::CL_IsCgameInitialized() ? 0.3f : 1.0f) }; + Game::R_AddCmdDrawText(Utils::VA("Loading FastFile: %s", FastFiles::Current().data()), 0x7FFFFFFF, font, 5.0f, (float)(Renderer::Height() - 5), 1.0f, 1.0f, 0.0f, color, 0); + }); } FastFiles::~FastFiles() diff --git a/src/Components/Modules/Renderer.cpp b/src/Components/Modules/Renderer.cpp index 0f621336..679b12d6 100644 --- a/src/Components/Modules/Renderer.cpp +++ b/src/Components/Modules/Renderer.cpp @@ -27,6 +27,16 @@ namespace Components Renderer::FrameCallbacks.push_back(callback); } + int Renderer::Width() + { + return Utils::Hook::Get(0x66E1C68); + } + + int Renderer::Height() + { + return Utils::Hook::Get(0x66E1C6C); + } + Renderer::Renderer() { // Frame hook diff --git a/src/Components/Modules/Renderer.hpp b/src/Components/Modules/Renderer.hpp index 7e07261d..6029f2a3 100644 --- a/src/Components/Modules/Renderer.hpp +++ b/src/Components/Modules/Renderer.hpp @@ -9,6 +9,9 @@ namespace Components ~Renderer(); const char* GetName() { return "Renderer"; }; + static int Width(); + static int Height(); + static void OnFrame(Callback callback); private: diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 7e162af3..1c45a949 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -104,6 +104,11 @@ namespace Game PartyHost_GetMemberAddressBySlot_t PartyHost_GetMemberAddressBySlot = (PartyHost_GetMemberAddressBySlot_t)0x44E100; PartyHost_GetMemberName_t PartyHost_GetMemberName = (PartyHost_GetMemberName_t)0x44BE90; + R_AddCmdDrawStretchPic_t R_AddCmdDrawStretchPic = (R_AddCmdDrawStretchPic_t)0x509770; + R_RegisterFont_t R_RegisterFont = (R_RegisterFont_t)0x505670; + R_AddCmdDrawText_t R_AddCmdDrawText = (R_AddCmdDrawText_t)0x509D80; + R_TextWidth_t R_TextWidth = (R_TextWidth_t)0x5056C0; + Script_Alloc_t Script_Alloc = (Script_Alloc_t)0x422E70; Script_SetupTokens_t Script_SetupTokens = (Script_SetupTokens_t)0x4E6950; Script_CleanString_t Script_CleanString = (Script_CleanString_t)0x498220; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 44b2c624..fc8e442a 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -247,6 +247,18 @@ namespace Game typedef const char *(__cdecl * PartyHost_GetMemberName_t)(PartyData_s* party, const int clientNum); extern PartyHost_GetMemberName_t PartyHost_GetMemberName; + typedef Font_s* (__cdecl * R_RegisterFont_t)(const char* asset); + extern R_RegisterFont_t R_RegisterFont; + + typedef void(__cdecl * R_AddCmdDrawText_t)(const char *text, int maxChars, Font_s *font, float x, float y, float xScale, float yScale, float rotation, const float *color, int style); + extern R_AddCmdDrawText_t R_AddCmdDrawText; + + typedef void(_cdecl * R_AddCmdDrawStretchPic_t)(float x, float y, float w, float h, float xScale, float yScale, float xay, float yay, const float *color, void* material); + extern R_AddCmdDrawStretchPic_t R_AddCmdDrawStretchPic; + + typedef int(__cdecl * R_TextWidth_t)(const char* text, int maxlength, void* font); + extern R_TextWidth_t R_TextWidth; + typedef script_t* (__cdecl * Script_Alloc_t)(int length); extern Script_Alloc_t Script_Alloc; diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 7a169ccd..cabeb168 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -924,6 +924,31 @@ namespace Game char * compressedData; }; + typedef struct fontEntry_s + { + unsigned short character; + unsigned char padLeft; + unsigned char padTop; + unsigned char padRight; + unsigned char width; + unsigned char height; + unsigned char const0; + float uvLeft; + float uvTop; + float uvRight; + float uvBottom; + } fontEntry_t; + + typedef struct Font_s + { + char* name; + int size; + int entries; + Material* image; + Material* glowImage; + fontEntry_t* characters; + } Font; + union XAssetHeader { void *data; @@ -935,6 +960,7 @@ namespace Game StringTable *stringTable; MapEnts* mapEnts; RawFile* rawfile; + Font* font; }; struct XAsset