diff --git a/Plugins/CaptionMod/GameUI.cpp b/Plugins/CaptionMod/GameUI.cpp index 196c3837..082a534d 100644 --- a/Plugins/CaptionMod/GameUI.cpp +++ b/Plugins/CaptionMod/GameUI.cpp @@ -103,17 +103,6 @@ void __fastcall RichText_InsertStringW(void* pthis, int dummy, wchar_t *ch) } } -//TextEntry doesn't have such issue -#if 0 -void __fastcall TextEntry_InsertChar(void* pthis, int dummy, wchar_t ch) -{ - if (ch == L'\r') - return; - - gPrivateFuncs.TextEntry_InsertChar(pthis, 0, ch); -} -#endif - void __fastcall RichText_OnThink(void* pthis, int dummy) { vgui::Panel* pPanel = (vgui::Panel*)pthis; diff --git a/Plugins/CaptionMod/SubtitlePanel.cpp b/Plugins/CaptionMod/SubtitlePanel.cpp index 7b519312..36052f4c 100644 --- a/Plugins/CaptionMod/SubtitlePanel.cpp +++ b/Plugins/CaptionMod/SubtitlePanel.cpp @@ -267,6 +267,7 @@ void CSubLine::Draw(int x, int w, int align) int nTextAlign = ALIGN_DEFAULT; float flFraction = GetYPosOutRate(); + if(flFraction != 0) { nAlpha = (float)nAlpha * (1 - flFraction); @@ -623,6 +624,8 @@ void SubtitlePanel::VidInit(void) ClearSubtitle(); } +//#include + void SubtitlePanel::Paint(void) { //if (SCR_IsLoadingVisible()) @@ -644,13 +647,13 @@ void SubtitlePanel::Paint(void) iPanelWidth -= x << 1; - //Draw lines and get how large the panel suppose to be. + //Draw lines and calculate the size of panel. surface()->DrawSetTextFont(m_hTextFont); for(int i = 0; i < m_Lines.Count(); ++i) { - CSubLine *Line = m_Lines[i]; + auto Line = m_Lines[i]; Line->Draw(x, iPanelWidth, m_iTextAlign); @@ -664,18 +667,18 @@ void SubtitlePanel::Paint(void) m_iPanelAlpha = Line->m_Alpha; } - //If the panel try to fade in when it's fully hidden + //Check if the panel is trying to fade in when it's fully hidden if(m_iCurPanelY > m_iCurPanelYEnd && m_iPanelY < m_iPanelYEnd) { m_iCurPanelY = m_iPanelY; m_iCurPanelYEnd = m_iPanelYEnd; } - //the panel's top won't be higher than m_iPanelTop + //The panel's top won't be higher than m_iPanelTop if(m_iPanelY < m_iPanelTop) m_iPanelY = m_iPanelTop; - //do not go away too far + //Do not go away too far if(m_iPanelY > iPanelHeight) m_iPanelY = iPanelHeight; @@ -692,6 +695,7 @@ void SubtitlePanel::Paint(void) else if(sign == -1 && m_iCurPanelY < m_iPanelY) m_iCurPanelY = m_iPanelY; } + if(m_iCurPanelYEnd != m_iPanelYEnd) { int sign = (m_iPanelYEnd - m_iCurPanelYEnd) ? 1 : -1; @@ -735,7 +739,7 @@ void SubtitlePanel::PaintBackground(void) surface()->DrawSetColor(clr); - //Draw 4 side rectangle + //Draw 4 side rectangles surface()->DrawFilledRect(x+r, y, x+w-r, y+r); surface()->DrawFilledRect(x+w-r, y+r, x+w, y+h-r); surface()->DrawFilledRect(x+r, y+h-r, x+w-r, y+h); @@ -744,7 +748,7 @@ void SubtitlePanel::PaintBackground(void) //Draw the central rectangle surface()->DrawFilledRect(x+r, y+r, x+w-r, y+h-r); - //draw 4 round cornor + //Draw 4 round cornors surface()->DrawSetTexture(m_iRoundCornorMaterial[0]); surface()->DrawTexturedRect(x, y, x+r, y+r); diff --git a/Plugins/CaptionMod/SurfaceHook.cpp b/Plugins/CaptionMod/SurfaceHook.cpp index 79745a4d..9118e124 100644 --- a/Plugins/CaptionMod/SurfaceHook.cpp +++ b/Plugins/CaptionMod/SurfaceHook.cpp @@ -312,7 +312,7 @@ void CSurfaceProxy::DrawUnicodeChar(wchar_t wch) return; int x, y; - g_pSurface->DrawGetTextPos(x, y); + DrawGetTextPos(x, y); int a, b, c; FontManager().GetCharABCwide(g_hCurrentFont, wch, a, b, c); @@ -330,7 +330,7 @@ void CSurfaceProxy::DrawUnicodeChar(wchar_t wch) rgbaWide = b; } - int textureID; + int textureID = 0; float *texCoords = NULL; if (!g_FontTextureCache.GetTextureForChar(g_hCurrentFont, wch, &textureID, &texCoords)) @@ -338,10 +338,18 @@ void CSurfaceProxy::DrawUnicodeChar(wchar_t wch) g_pSurface->DrawSetTexture(textureID); + int iSavedColor[4]; + + iSavedColor[0] = g_iCurrentTextR; + iSavedColor[1] = g_iCurrentTextG; + iSavedColor[2] = g_iCurrentTextB; + iSavedColor[3] = g_iCurrentTextA; + if (FontManager().GetFontOutlined(g_hCurrentFont)) { int OutlineColor = (g_iCurrentTextR <= 10 && g_iCurrentTextG <= 10 && g_iCurrentTextB <= 10) ? 255 : 0; - m_pfnDrawSetTextColor(this, 0, OutlineColor, OutlineColor, OutlineColor, g_iCurrentTextA); + + DrawSetTextColor(OutlineColor, OutlineColor, OutlineColor, g_iCurrentTextA); if (staticSurface) { @@ -367,15 +375,14 @@ void CSurfaceProxy::DrawUnicodeChar(wchar_t wch) } } - m_pfnDrawSetTextColor(this, 0, g_iCurrentTextR, g_iCurrentTextG, g_iCurrentTextB, g_iCurrentTextA); + DrawSetTextColor(iSavedColor[0], iSavedColor[1], iSavedColor[2], iSavedColor[3]); if (staticSurface) staticSurface->drawPrintChar(x, y, rgbaWide, rgbaTall, texCoords[0], texCoords[1], texCoords[2], texCoords[3]); else staticSurface_HL25->drawPrintChar(x, y, rgbaWide, rgbaTall, texCoords[0], texCoords[1], texCoords[2], texCoords[3]); - m_pfnDrawSetTextColor(this, 0, g_iCurrentTextR, g_iCurrentTextG, g_iCurrentTextB, g_iCurrentTextA); - g_pSurface->DrawSetTextPos(x + b + c, y); + DrawSetTextPos(x + b + c, y); } void CSurfaceProxy::DrawUnicodeCharAdd(wchar_t wch) @@ -410,10 +417,18 @@ void CSurfaceProxy::DrawUnicodeCharAdd(wchar_t wch) g_pSurface->DrawSetTexture(textureID); + int iSavedColor[4]; + + iSavedColor[0] = g_iCurrentTextR; + iSavedColor[1] = g_iCurrentTextG; + iSavedColor[2] = g_iCurrentTextB; + iSavedColor[3] = g_iCurrentTextA; + if (FontManager().GetFontOutlined(g_hCurrentFont)) { int OutlineColor = (g_iCurrentTextR <= 10 && g_iCurrentTextG <= 10 && g_iCurrentTextB <= 10) ? 255 : 0; - m_pfnDrawSetTextColor(this, 0, OutlineColor, OutlineColor, OutlineColor, g_iCurrentTextA); + + DrawSetTextColor(OutlineColor, OutlineColor, OutlineColor, g_iCurrentTextA); if (staticSurface) { @@ -439,15 +454,14 @@ void CSurfaceProxy::DrawUnicodeCharAdd(wchar_t wch) } } - m_pfnDrawSetTextColor(this, 0, g_iCurrentTextR, g_iCurrentTextG, g_iCurrentTextB, g_iCurrentTextA); + DrawSetTextColor(iSavedColor[0], iSavedColor[1], iSavedColor[2], iSavedColor[3]); if (staticSurface) staticSurface->drawPrintCharAdd(x, y, rgbaWide, rgbaTall, texCoords[0], texCoords[1], texCoords[2], texCoords[3]); else staticSurface_HL25->drawPrintCharAdd(x, y, rgbaWide, rgbaTall, texCoords[0], texCoords[1], texCoords[2], texCoords[3]); - m_pfnDrawSetTextColor(this, 0, g_iCurrentTextR, g_iCurrentTextG, g_iCurrentTextB, g_iCurrentTextA); - g_pSurface->DrawSetTextPos(x + b + c, y); + DrawSetTextPos(x + b + c, y); } void CSurfaceProxy::DrawFlushText(void) @@ -1177,6 +1191,13 @@ void CSurfaceProxy_HL25::DrawUnicodeChar(wchar_t wch) DrawSetTexture(textureID); + int iSavedColor[4]; + + iSavedColor[0] = g_iCurrentTextR; + iSavedColor[1] = g_iCurrentTextG; + iSavedColor[2] = g_iCurrentTextB; + iSavedColor[3] = g_iCurrentTextA; + if (FontManager().GetFontOutlined(g_hCurrentFont)) { int OutlineColor = (g_iCurrentTextR <= 10 && g_iCurrentTextG <= 10 && g_iCurrentTextB <= 10) ? 255 : 0; @@ -1207,15 +1228,13 @@ void CSurfaceProxy_HL25::DrawUnicodeChar(wchar_t wch) } } - DrawSetTextColor(g_iCurrentTextR, g_iCurrentTextG, g_iCurrentTextB, g_iCurrentTextA); + DrawSetTextColor(iSavedColor[0], iSavedColor[1], iSavedColor[2], iSavedColor[3]); if (staticSurface_HL25) staticSurface_HL25->drawPrintChar(x, y, rgbaWide, rgbaTall, texCoords[0], texCoords[1], texCoords[2], texCoords[3]); else staticSurface->drawPrintChar(x, y, rgbaWide, rgbaTall, texCoords[0], texCoords[1], texCoords[2], texCoords[3]); - DrawSetTextColor(g_iCurrentTextR, g_iCurrentTextG, g_iCurrentTextB, g_iCurrentTextA); - DrawSetTextPos(x + b + c, y); } @@ -1251,6 +1270,13 @@ void CSurfaceProxy_HL25::DrawUnicodeCharAdd(wchar_t wch) DrawSetTexture(textureID); + int iSavedColor[4]; + + iSavedColor[0] = g_iCurrentTextR; + iSavedColor[1] = g_iCurrentTextG; + iSavedColor[2] = g_iCurrentTextB; + iSavedColor[3] = g_iCurrentTextA; + if (FontManager().GetFontOutlined(g_hCurrentFont)) { int OutlineColor = (g_iCurrentTextR <= 10 && g_iCurrentTextG <= 10 && g_iCurrentTextB <= 10) ? 255 : 0; @@ -1281,15 +1307,13 @@ void CSurfaceProxy_HL25::DrawUnicodeCharAdd(wchar_t wch) } } - DrawSetTextColor(g_iCurrentTextR, g_iCurrentTextG, g_iCurrentTextB, g_iCurrentTextA); + DrawSetTextColor(iSavedColor[0], iSavedColor[1], iSavedColor[2], iSavedColor[3]); if (staticSurface_HL25) staticSurface_HL25->drawPrintCharAdd(x, y, rgbaWide, rgbaTall, texCoords[0], texCoords[1], texCoords[2], texCoords[3]); else staticSurface->drawPrintCharAdd(x, y, rgbaWide, rgbaTall, texCoords[0], texCoords[1], texCoords[2], texCoords[3]); - DrawSetTextColor(g_iCurrentTextR, g_iCurrentTextG, g_iCurrentTextB, g_iCurrentTextA); - DrawSetTextPos(x + b + c, y); } diff --git a/Plugins/CaptionMod/Win32Font.cpp b/Plugins/CaptionMod/Win32Font.cpp index 78631b72..fa237f77 100644 --- a/Plugins/CaptionMod/Win32Font.cpp +++ b/Plugins/CaptionMod/Win32Font.cpp @@ -37,6 +37,11 @@ CWin32Font::CWin32Font(void): m_ExtendedABCWidthsCache(256, 0, &ExtendedABCWidth m_hDIB = NULL; m_bAntiAliased = false; m_bUnderlined = false; + m_bOutlined = false; + m_iDropShadowOffset = 0; + m_iFxpHeight = 0; + m_iOutlineSize = 0; + m_pBuf = NULL; m_iBlur = 0; m_iScanLines = 0; m_bRotary = false; @@ -71,6 +76,11 @@ CWin32Font::~CWin32Font(void) if (m_hDIB) ::DeleteObject(m_hDIB); + + if (m_pGaussianDistribution) + { + delete[]m_pGaussianDistribution; + } } bool g_bFontFound = false; @@ -196,7 +206,7 @@ bool CWin32Font::Create(const char *windowsFontName, int tall, int weight, int b m_ABCWidthsCache[i].b = (char)tm.tmAveCharWidth; } - if (m_iBlur > 1) + if (m_iBlur > 1 && !m_pGaussianDistribution) { m_pGaussianDistribution = new float[m_iBlur * 2 + 1]; double sigma = 0.683 * m_iBlur; @@ -659,10 +669,4 @@ bool CWin32Font::GetAdditive(void) int CWin32Font::GetAscent(void) { return m_iAscent; -} - -void __fastcall CWin32Font_GetCharRGBA(void *pthis, int, int ch, int rgbaX, int rgbaY, int rgbaWide, int rgbaTall, unsigned char *rgba) -{ - CWin32Font *pFont = (CWin32Font *)pthis; - pFont->GetCharRGBA(ch, rgbaX, rgbaY, rgbaWide, rgbaTall, rgba); } \ No newline at end of file diff --git a/Plugins/CaptionMod/Win32Font.h b/Plugins/CaptionMod/Win32Font.h index 99f15080..7ca214b5 100644 --- a/Plugins/CaptionMod/Win32Font.h +++ b/Plugins/CaptionMod/Win32Font.h @@ -91,6 +91,4 @@ class CWin32Font public: static bool ms_bSetFriendlyNameCacheLessFunc; }; - -void __fastcall CWin32Font_GetCharRGBA(void *pthis, int, int ch, int rgbaX, int rgbaY, int rgbaWide, int rgbaTall, unsigned char *rgba); #endif \ No newline at end of file diff --git a/Plugins/CaptionMod/exportfuncs.h b/Plugins/CaptionMod/exportfuncs.h index 92ce49d2..1ef73b1c 100644 --- a/Plugins/CaptionMod/exportfuncs.h +++ b/Plugins/CaptionMod/exportfuncs.h @@ -42,8 +42,6 @@ void S_StartDynamicSound(int entnum, int entchannel, sfx_t *sfx, float *origin, void S_StartStaticSound(int entnum, int entchannel, sfx_t *sfx, float *origin, float fvol, float attenuation, int flags, int pitch); sfx_t *S_FindName(char *name, int *pfInCache); -void __fastcall CWin32Font_GetCharRGBA(void *pthis, int, int ch, int rgbaX, int rgbaY, int rgbaWide, int rgbaTall, unsigned char *rgba); - void MessageMode_f(void); void MessageMode2_f(void); void Cap_Version_f(void); diff --git a/Plugins/CaptionMod/privatefuncs.cpp b/Plugins/CaptionMod/privatefuncs.cpp index 19b01cd5..ab58af76 100644 --- a/Plugins/CaptionMod/privatefuncs.cpp +++ b/Plugins/CaptionMod/privatefuncs.cpp @@ -71,7 +71,6 @@ static hook_t *g_phook_S_StartDynamicSound = NULL; static hook_t *g_phook_S_StartStaticSound = NULL; static hook_t *g_phook_ScClient_FindSoundEx = NULL; static hook_t *g_phook_pfnTextMessageGet = NULL; -static hook_t *g_phook_CWin32Font_GetCharRGBA = NULL; static hook_t *g_phook_WeaponsResource_SelectSlot = NULL; //hook_t *g_phook_FileSystem_SetGameDirectory = NULL; @@ -1188,26 +1187,6 @@ void Engine_FillAddress(void) } } } - - //TODO: Remove this? Looks like not used anymore? -#if 0 - if (g_iEngineType == ENGINE_SVENGINE) - { -#define CWIN32FONT_GETCHARABCWIDTHS_SIG_SVENGINE "\x55\x8B\xEC\x83\xEC\x2A\xA1\x2A\x2A\x2A\x2A\x33\xC5\x89\x45\xFC\x2A\x45\x0C\x2A\x2A\x5D\x14" - - gPrivateFuncs.CWin32Font_GetCharRGBA = (decltype(gPrivateFuncs.CWin32Font_GetCharRGBA))Search_Pattern(CWIN32FONT_GETCHARABCWIDTHS_SIG_SVENGINE); - Sig_FuncNotFound(CWin32Font_GetCharRGBA); - } - else - { -#define CWIN32FONT_GETCHARABCWIDTHS_SIG "\x55\x8B\xEC\x83\xEC\x70\x53\x56\x8B\xF1\x8D\x45\xD0\x57\x8D\x4D\xE4\x50\x8B\x45\x08\x8D\x55\xD4\x51\x52\x50\x8B\xCE" - - gPrivateFuncs.CWin32Font_GetCharRGBA = (decltype(gPrivateFuncs.CWin32Font_GetCharRGBA))Search_Pattern(CWIN32FONT_GETCHARABCWIDTHS_SIG); - Sig_FuncNotFound(CWin32Font_GetCharRGBA); - } -#endif - - } void Client_FillAddress(void) diff --git a/Plugins/CaptionMod/privatefuncs.h b/Plugins/CaptionMod/privatefuncs.h index fa5d1e30..c5866efa 100644 --- a/Plugins/CaptionMod/privatefuncs.h +++ b/Plugins/CaptionMod/privatefuncs.h @@ -43,9 +43,6 @@ typedef struct sfxcache_t *(*S_LoadSound)(sfx_t *s, channel_t *ch); sentenceEntry_s*(*SequenceGetSentenceByIndex)(unsigned int); - //Engine Surface - void(__fastcall *CWin32Font_GetCharRGBA)(void *pthis, int, int ch, int rgbaX, int rgbaY, int rgbaWide, int rgbaTall, unsigned char *rgba); - //SC ClientDLL int(__fastcall *ScClient_FindSoundEx)(void *pthis, int, const char *soundName);