Skip to content

Commit

Permalink
1.make HudMenu white at default
Browse files Browse the repository at this point in the history
2.HudMenu starts from GetBorderSize+5 instead of hardcoded 20 now.
  • Loading branch information
hzqst committed Sep 6, 2022
1 parent f6abfc8 commit 4a03c56
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions Plugins/CaptionMod/exportfuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ int m_iIntermission = 0;

void *GameViewport = NULL;
int *g_iVisibleMouse = NULL;
void *gHud = NULL;

HWND g_MainWnd = NULL;
WNDPROC g_MainWndProc = NULL;
Expand Down
16 changes: 10 additions & 6 deletions Plugins/CaptionMod/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ void CHudMenu::Init(void)
{
m_pfnShowMenu = HOOK_MESSAGE(ShowMenu);

m_bMenuDisplayed = 0;
m_bMenuDisplayed = false;
m_bitsValidSlots = 0;

Reset();
Expand Down Expand Up @@ -2025,14 +2025,17 @@ int CHudMenu::Draw(void)
{
if (m_flShutoffTime <= (*cl_time))
{
m_bMenuDisplayed = 0;
m_bMenuDisplayed = false;
return 1;
}
}

if (g_pViewPort && g_pViewPort->IsScoreBoardVisible())
return 1;

if(!m_bMenuDisplayed)
return 1;

int nlc = 0;

for (int i = 0; i < MAX_MENU_STRING && m_szMenuString[i] != '\0'; i++)
Expand All @@ -2041,10 +2044,11 @@ int CHudMenu::Draw(void)
nlc++;
}

menu_x = 20;
int border = (gPrivateFuncs.CHud_GetBorderSize && gHud) ? gPrivateFuncs.CHud_GetBorderSize(gHud, 0) : 15;
menu_x = border + 5;
menu_r = 255;
menu_g = 255;
menu_b = 20;
menu_b = 255;
menu_ralign = 0;

int ScreenWidth, ScreenHeight;
Expand Down Expand Up @@ -2117,7 +2121,7 @@ int CHudMenu::Draw(void)
case 'R':
{
menu_ralign = 1;
menu_x = ScreenWidth / 2;
menu_x = ScreenWidth / 2 - border;

sptr += 2;
break;
Expand Down Expand Up @@ -2246,7 +2250,7 @@ bool CHudMenu::SelectMenuItem(int menu_item)
gEngfuncs.pfnClientCmd(szbuf);
}

m_bMenuDisplayed = 0;
m_bMenuDisplayed = false;
return true;
}

Expand Down
10 changes: 10 additions & 0 deletions Plugins/CaptionMod/privatefuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,16 @@ void Client_FillAddress(void)

g_iVisibleMouse = *(decltype(g_iVisibleMouse) *)(addr + 11);
}

#define SC_GETBORDERSIZE_SIG "\xF6\x05\x2A\x2A\x2A\x2A\x20\x2A\x2A\xB9\x2A\x2A\x2A\x2A\xE8"
{
auto addr = (PUCHAR)g_pMetaHookAPI->SearchPattern(g_dwClientBase, g_dwClientSize, SC_GETBORDERSIZE_SIG, Sig_Length(SC_GETBORDERSIZE_SIG));
Sig_AddrNotFound(CHud_GetBorderSize);

gHud = *(decltype(gHud) *)(addr + 10);
gPrivateFuncs.CHud_GetBorderSize = (decltype(gPrivateFuncs.CHud_GetBorderSize))
g_pMetaHookAPI->GetNextCallAddr(addr + Sig_Length(SC_GETBORDERSIZE_SIG) - 1, 1);
}
}

if (!strcmp(gEngfuncs.pfnGetGameDirectory(), "cstrike") || !strcmp(gEngfuncs.pfnGetGameDirectory(), "czero") || !strcmp(gEngfuncs.pfnGetGameDirectory(), "czeror"))
Expand Down
2 changes: 2 additions & 0 deletions Plugins/CaptionMod/privatefuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef struct
bool (__fastcall *GameViewport_AllowedToPrintText)(void *pthis, int);
bool (__fastcall *GameViewport_IsScoreBoardVisible)(void *pthis, int);
void (__fastcall *WeaponsResource_SelectSlot)(void *pthis, int, int iSlot, int fAdvance, int iDirection);
int (__fastcall *CHud_GetBorderSize)(void *pthis, int);
//int(__fastcall *CHud_DrawHudString)(void *pthis, int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b);
//int(__fastcall *DrawHudStringReverse)(void *pthis, int xpos, int ypos, int iMinX, char *szString, int r, int g, int b);

Expand Down Expand Up @@ -76,6 +77,7 @@ typedef struct

extern void *GameViewport;
extern int *g_iVisibleMouse;
extern void *gHud;

extern double *cl_time;
extern double *cl_oldtime;
Expand Down

0 comments on commit 4a03c56

Please sign in to comment.