[TextRenderer]: Added 'Low Ammo' with keybind. (#4)
This commit is contained in:
parent
3a50517730
commit
76cf13689b
@ -198,6 +198,21 @@
|
||||
visible 1
|
||||
decoration
|
||||
}
|
||||
|
||||
itemDef
|
||||
{
|
||||
name "lowammowarning"
|
||||
rect -10 15 150 30 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER
|
||||
textfont UI_FONT_DEFAULT
|
||||
textscale TEXTSIZE_SMALL
|
||||
textalign (ITEM_ALIGN_CENTER | ITEM_ALIGN_MIDDLE)
|
||||
textstyle ITEM_TEXTSTYLE_SHADOWED
|
||||
forecolor 1 1 1 1
|
||||
//background "white"
|
||||
ownerdraw CG_PLAYER_WEAPON_LOW_AMMO_WARNING
|
||||
visible when ( dvarInt( g_gameskill ) == 0 || dvarInt( g_gameskill ) == 1 /*&& dvarBool ( gpad_in_use ) == 1*/ );
|
||||
decoration
|
||||
}
|
||||
}
|
||||
|
||||
#define COMPASS_OFFSET 0 -10
|
||||
|
@ -148,6 +148,32 @@ namespace Components
|
||||
Game::UI_FilterStringForButtonAnimation(text, 1024);
|
||||
}
|
||||
|
||||
const char* TextRenderer::CG_DrawPlayerWeaponLowAmmoKey(const char* pszInputBuffer, const char* pszMessageType, int errType)
|
||||
{
|
||||
char binding[256];
|
||||
Game::UI_GetKeyBindingLocalizedString(0, "+usereload", binding, 0);
|
||||
const char* displayString = Game::UI_SafeTranslateString(pszInputBuffer);
|
||||
const char* localizedString = Game::UI_ReplaceConversionString(displayString, binding);
|
||||
|
||||
return localizedString;
|
||||
}
|
||||
|
||||
__declspec(naked) void TextRenderer::CG_DrawPlayerWeaponLowAmmoWarningStub()
|
||||
{
|
||||
const static uint32_t jump_offset = 0x040A1F0;
|
||||
static const char* messageType = "low ammo warning";
|
||||
__asm
|
||||
{
|
||||
push 0;
|
||||
push messageType;
|
||||
push esi;
|
||||
call CG_DrawPlayerWeaponLowAmmoKey;
|
||||
add esp, 0xC;
|
||||
|
||||
jmp jump_offset;
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void TextRenderer::R_TextWidth_Stub01()
|
||||
{
|
||||
const static uint32_t jump_offset = 0x56E618;
|
||||
@ -238,5 +264,8 @@ namespace Components
|
||||
// GetHudelemDirective
|
||||
Utils::Hook::Nop(0x41AA8B, 7);
|
||||
Utils::Hook(0x41AA8B, UI_GetKeyBindingLocalizedStringStub, HOOK_JUMP).install()->quick();
|
||||
|
||||
// Converting a simple 'reload' text to a text with keybind localized
|
||||
Utils::Hook(0x40A1EB, CG_DrawPlayerWeaponLowAmmoWarningStub, HOOK_JUMP).install()->quick();
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ namespace Components
|
||||
static void DrawHudIconStub();
|
||||
static void UI_ReplaceConversionStringStub();
|
||||
static void ButtonAnimation(char* text);
|
||||
static void CG_DrawPlayerWeaponLowAmmoWarningStub();
|
||||
static const char* CG_DrawPlayerWeaponLowAmmoKey(const char* pszInputBuffer, const char* pszMessageType, int errType);
|
||||
static void UI_GetKeyBindingLocalizedStringStub();
|
||||
|
||||
static int R_TextWidth_Hk(const char* text, int maxChars, Game::Font_s* font);
|
||||
|
@ -1317,4 +1317,23 @@ namespace Game
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int UI_GetKeyBindingLocalizedString/*eax*/(int localClientNum/*eax*/, const char* command/*ecx*/, char* keys, int bindNum)
|
||||
{
|
||||
int result;
|
||||
const uint32_t UI_GetKeyBindingLocalizedString_func = 0x56F1E0;
|
||||
__asm
|
||||
{
|
||||
pushad;
|
||||
mov eax, [localClientNum];
|
||||
mov ecx, [command];
|
||||
push bindNum;
|
||||
push keys;
|
||||
call UI_GetKeyBindingLocalizedString_func;
|
||||
add esp, 8;
|
||||
mov result, eax;
|
||||
popad;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -259,4 +259,6 @@ namespace Game
|
||||
void SV_ShutdownGameVM(int clearScripts/*edi*/);
|
||||
void UI_DrawTextWithGlow(int vertAlign/*eax*/, int horzAlign/*ecx*/, const Game::ScreenPlacement* ScrPlace, const char* text, Game::Font_s* font, float x, float y, float scale, const float* color, int style, const float* glowColor, int subtitle, int cinematic);
|
||||
int String_Parse/*eax*/(const char** p/*eax*/, char* char_out, int len);
|
||||
|
||||
int UI_GetKeyBindingLocalizedString/*eax*/(int localClientNum/*eax*/, const char* command/*ecx*/, char* keys, int bindNum);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user