Fastfile stuff.

This commit is contained in:
momo5502 2016-01-12 23:42:05 +01:00
parent 9f01412ca8
commit 8a629bc391
6 changed files with 67 additions and 0 deletions

View File

@ -63,6 +63,8 @@ namespace Components
FastFiles::FastFiles() FastFiles::FastFiles()
{ {
Dvar::Register<bool>("ui_zoneDebug", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display current loaded zone.");
// Redirect zone paths // Redirect zone paths
Utils::Hook(0x44DA90, FastFiles::GetZoneLocation, HOOK_JUMP).Install()->Quick(); Utils::Hook(0x44DA90, FastFiles::GetZoneLocation, HOOK_JUMP).Install()->Quick();
@ -94,6 +96,15 @@ namespace Components
// Add custom zone paths // Add custom zone paths
FastFiles::AddZonePath("zone\\patch\\"); FastFiles::AddZonePath("zone\\patch\\");
FastFiles::AddZonePath("zone\\dlc\\"); FastFiles::AddZonePath("zone\\dlc\\");
Renderer::OnFrame([] ()
{
if (!FastFiles::Current().size() || !Dvar::Var("ui_zoneDebug").Get<bool>()) 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() FastFiles::~FastFiles()

View File

@ -27,6 +27,16 @@ namespace Components
Renderer::FrameCallbacks.push_back(callback); Renderer::FrameCallbacks.push_back(callback);
} }
int Renderer::Width()
{
return Utils::Hook::Get<int>(0x66E1C68);
}
int Renderer::Height()
{
return Utils::Hook::Get<int>(0x66E1C6C);
}
Renderer::Renderer() Renderer::Renderer()
{ {
// Frame hook // Frame hook

View File

@ -9,6 +9,9 @@ namespace Components
~Renderer(); ~Renderer();
const char* GetName() { return "Renderer"; }; const char* GetName() { return "Renderer"; };
static int Width();
static int Height();
static void OnFrame(Callback callback); static void OnFrame(Callback callback);
private: private:

View File

@ -104,6 +104,11 @@ namespace Game
PartyHost_GetMemberAddressBySlot_t PartyHost_GetMemberAddressBySlot = (PartyHost_GetMemberAddressBySlot_t)0x44E100; PartyHost_GetMemberAddressBySlot_t PartyHost_GetMemberAddressBySlot = (PartyHost_GetMemberAddressBySlot_t)0x44E100;
PartyHost_GetMemberName_t PartyHost_GetMemberName = (PartyHost_GetMemberName_t)0x44BE90; 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_Alloc_t Script_Alloc = (Script_Alloc_t)0x422E70;
Script_SetupTokens_t Script_SetupTokens = (Script_SetupTokens_t)0x4E6950; Script_SetupTokens_t Script_SetupTokens = (Script_SetupTokens_t)0x4E6950;
Script_CleanString_t Script_CleanString = (Script_CleanString_t)0x498220; Script_CleanString_t Script_CleanString = (Script_CleanString_t)0x498220;

View File

@ -247,6 +247,18 @@ namespace Game
typedef const char *(__cdecl * PartyHost_GetMemberName_t)(PartyData_s* party, const int clientNum); typedef const char *(__cdecl * PartyHost_GetMemberName_t)(PartyData_s* party, const int clientNum);
extern PartyHost_GetMemberName_t PartyHost_GetMemberName; 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); typedef script_t* (__cdecl * Script_Alloc_t)(int length);
extern Script_Alloc_t Script_Alloc; extern Script_Alloc_t Script_Alloc;

View File

@ -924,6 +924,31 @@ namespace Game
char * compressedData; 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 union XAssetHeader
{ {
void *data; void *data;
@ -935,6 +960,7 @@ namespace Game
StringTable *stringTable; StringTable *stringTable;
MapEnts* mapEnts; MapEnts* mapEnts;
RawFile* rawfile; RawFile* rawfile;
Font* font;
}; };
struct XAsset struct XAsset