From fd8d853c5a019f168a9f537b7e9400cd73b6f8c7 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Sun, 28 Jan 2024 20:10:03 +0800 Subject: [PATCH] Change COptionsSubAudioAdvancedDlg and COptionsSubVideoAdvancedDlg from modal dialog to property tab. --- .../captionmod/OptionsSubAudioAdvancedDlg.res | 232 +----- .../captionmod/OptionsSubVideoAdvancedDlg.res | 108 +-- Build/svencoop/captionmod/SubtitlePanel.res | 16 - Build/svencoop/captionmod/gameui_english.txt | Bin 3066 -> 2558 bytes Build/svencoop/captionmod/gameui_koreana.txt | Bin 2602 -> 2214 bytes Build/svencoop/captionmod/gameui_schinese.txt | Bin 2496 -> 2102 bytes .../captionmod/SubtitlePanel.res | 24 +- .../svencoop_hidpi/resource/OptionsDialog.res | 2 +- .../resource/OptionsSubAudio.res | 184 ----- .../resource/OptionsSubVideo.res | 333 --------- Plugins/CaptionMod/CaptionMod.vcxproj | 16 +- Plugins/CaptionMod/CaptionMod.vcxproj.filters | 42 +- Plugins/CaptionMod/CvarSlider.cpp | 225 ------ Plugins/CaptionMod/CvarSlider.h | 53 -- Plugins/CaptionMod/CvarToggleCheckButton.cpp | 127 ---- Plugins/CaptionMod/CvarToggleCheckButton.h | 35 - Plugins/CaptionMod/GameUI.cpp | 689 ++++++++++-------- Plugins/CaptionMod/SubtitlePanel.cpp | 69 +- Plugins/CaptionMod/SubtitlePanel.h | 30 +- Plugins/CaptionMod/Viewport.cpp | 20 +- Plugins/CaptionMod/Viewport.h | 4 +- Plugins/CaptionMod/chatdialog.cpp | 8 +- Plugins/CaptionMod/chatdialog.h | 4 +- Plugins/CaptionMod/cstrikechatdialog.cpp | 2 +- Plugins/CaptionMod/cstrikechatdialog.h | 2 +- Plugins/CaptionMod/exportfuncs.cpp | 23 + Plugins/CaptionMod/message.cpp | 14 +- Plugins/CaptionMod/plugins.cpp | 14 + Plugins/CaptionMod/plugins.h | 2 +- Plugins/CaptionMod/privatefuncs.cpp | 16 + Plugins/CaptionMod/privatefuncs.h | 12 +- include/vgui_controls/Controls.cpp | 11 - include/vgui_controls/Panel.cpp | 31 - include/vgui_controls/Panel.h | 6 - 34 files changed, 597 insertions(+), 1757 deletions(-) delete mode 100644 Build/svencoop_hidpi/resource/OptionsSubAudio.res delete mode 100644 Build/svencoop_hidpi/resource/OptionsSubVideo.res delete mode 100644 Plugins/CaptionMod/CvarSlider.cpp delete mode 100644 Plugins/CaptionMod/CvarSlider.h delete mode 100644 Plugins/CaptionMod/CvarToggleCheckButton.cpp delete mode 100644 Plugins/CaptionMod/CvarToggleCheckButton.h diff --git a/Build/svencoop/captionmod/OptionsSubAudioAdvancedDlg.res b/Build/svencoop/captionmod/OptionsSubAudioAdvancedDlg.res index 1211f0b9..112c022d 100644 --- a/Build/svencoop/captionmod/OptionsSubAudioAdvancedDlg.res +++ b/Build/svencoop/captionmod/OptionsSubAudioAdvancedDlg.res @@ -1,27 +1,10 @@ "resource/OptionsSubAudioAdvancedDlg.res" { - "OptionsSubAudioAdvancedDlg" - { - "ControlName" "OptionsSubAudioAdvancedDlg" - "fieldName" "OptionsSubAudioAdvancedDlg" - "xpos" "c-171" - "ypos" "c-85" - "wide" "600" - "tall" "400" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "0" - "settitlebarvisible" "1" - "title" "#GameUI_CaptionMod_Title" - } - "PrefixButton" { - "ControlName" "CheckButton" + "ControlName" "CCvarToggleCheckButton" "fieldName" "PrefixButton" - "xpos" "20" + "xpos" "250" "ypos" "38" "wide" "300" "tall" "28" @@ -41,9 +24,9 @@ "WaitPlayButton" { - "ControlName" "CheckButton" + "ControlName" "CCvarToggleCheckButton" "fieldName" "WaitPlayButton" - "xpos" "20" + "xpos" "250" "ypos" "66" "wide" "300" "tall" "28" @@ -63,9 +46,9 @@ "AntiSpamButton" { - "ControlName" "CheckButton" + "ControlName" "CCvarToggleCheckButton" "fieldName" "AntiSpamButton" - "xpos" "20" + "xpos" "250" "ypos" "94" "wide" "300" "tall" "28" @@ -87,7 +70,7 @@ "ControlName" "Label" "fieldName" "FadeInLabel" "xpos" "28" - "ypos" "122" + "ypos" "38" "wide" "140" "tall" "24" "autoResize" "0" @@ -101,10 +84,10 @@ } "FadeInEntry" { - "ControlName" "TextEntry" + "ControlName" "CCvarTextEntry" "fieldName" "FadeInEntry" "xpos" "180" - "ypos" "122" + "ypos" "38" "wide" "48" "tall" "24" "autoResize" "0" @@ -122,7 +105,7 @@ "ControlName" "Label" "fieldName" "FadeOutLabel" "xpos" "28" - "ypos" "150" + "ypos" "66" "wide" "140" "tall" "24" "autoResize" "0" @@ -136,10 +119,10 @@ } "FadeOutEntry" { - "ControlName" "TextEntry" + "ControlName" "CCvarTextEntry" "fieldName" "FadeOutEntry" "xpos" "180" - "ypos" "150" + "ypos" "66" "wide" "48" "tall" "24" "autoResize" "0" @@ -157,7 +140,7 @@ "ControlName" "Label" "fieldName" "HoldTimeLabel" "xpos" "28" - "ypos" "178" + "ypos" "94" "wide" "140" "tall" "24" "autoResize" "0" @@ -171,10 +154,10 @@ } "HoldTimeEntry" { - "ControlName" "TextEntry" + "ControlName" "CCvarTextEntry" "fieldName" "HoldTimeEntry" "xpos" "180" - "ypos" "178" + "ypos" "94" "wide" "48" "tall" "24" "autoResize" "0" @@ -193,7 +176,7 @@ "ControlName" "Label" "fieldName" "HoldTimeScaleLabel" "xpos" "28" - "ypos" "206" + "ypos" "122" "wide" "140" "tall" "24" "autoResize" "0" @@ -210,7 +193,7 @@ "ControlName" "TextEntry" "fieldName" "HoldTimeScaleEntry" "xpos" "180" - "ypos" "206" + "ypos" "122" "wide" "48" "tall" "24" "autoResize" "0" @@ -229,7 +212,7 @@ "ControlName" "Label" "fieldName" "StartTimeScaleLabel" "xpos" "28" - "ypos" "234" + "ypos" "150" "wide" "140" "tall" "24" "autoResize" "0" @@ -246,7 +229,7 @@ "ControlName" "TextEntry" "fieldName" "StartTimeScaleEntry" "xpos" "180" - "ypos" "234" + "ypos" "150" "wide" "48" "tall" "24" "autoResize" "0" @@ -259,179 +242,4 @@ "maxchars" "16" "NumericInputOnly" "1" } - - "WidthLabel" - { - "ControlName" "Label" - "fieldName" "WidthLabel" - "xpos" "300" - "ypos" "38" - "wide" "140" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "labelText" "#GameUI_CaptionMod_PanelWidth" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - } - "WidthEntry" - { - "ControlName" "TextEntry" - "fieldName" "WidthEntry" - "xpos" "452" - "ypos" "38" - "wide" "60" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "9" - "textHidden" "0" - "editable" "1" - "maxchars" "16" - "NumericInputOnly" "1" - } - - "HeightLabel" - { - "ControlName" "Label" - "fieldName" "HeightLabel" - "xpos" "300" - "ypos" "66" - "wide" "140" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "labelText" "#GameUI_CaptionMod_PanelHeight" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - } - "HeightEntry" - { - "ControlName" "TextEntry" - "fieldName" "HeightEntry" - "xpos" "452" - "ypos" "66" - "wide" "60" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "10" - "textHidden" "0" - "editable" "1" - "maxchars" "16" - "NumericInputOnly" "1" - } - - "YPosLabel" - { - "ControlName" "Label" - "fieldName" "YPosLabel" - "xpos" "300" - "ypos" "94" - "wide" "140" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "labelText" "#GameUI_CaptionMod_PanelYPos" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - } - "YPosEntry" - { - "ControlName" "TextEntry" - "fieldName" "YPosEntry" - "xpos" "452" - "ypos" "94" - "wide" "60" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "11" - "textHidden" "0" - "editable" "1" - "maxchars" "16" - "NumericInputOnly" "1" - } - - "ButtonOK" - { - "ControlName" "Button" - "fieldName" "ButtonOK" - "xpos" "300" - "ypos" "350" - "wide" "80" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "12" - "labelText" "#GameUI_OK" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - "wrap" "0" - "Command" "OK" - "Default" "1" - "selected" "0" - } - "ButtonCancel" - { - "ControlName" "Button" - "fieldName" "ButtonCancel" - "xpos" "400" - "ypos" "350" - "wide" "80" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "13" - "labelText" "#GameUI_Cancel" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - "wrap" "0" - "Command" "Close" - "Default" "0" - "selected" "0" - } - "ButtonApply" - { - "ControlName" "Button" - "fieldName" "ButtonApply" - "xpos" "500" - "ypos" "350" - "wide" "80" - "tall" "24" - "autoResize" "0" - "pinCorner" "3" - "visible" "1" - "enabled" "1" - "tabPosition" "14" - "paintbackground" "1" - "labelText" "#GameUI_Apply" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - "wrap" "0" - "Command" "Apply" - "Default" "0" - } -} +} \ No newline at end of file diff --git a/Build/svencoop/captionmod/OptionsSubVideoAdvancedDlg.res b/Build/svencoop/captionmod/OptionsSubVideoAdvancedDlg.res index eab8bac9..6223cdda 100644 --- a/Build/svencoop/captionmod/OptionsSubVideoAdvancedDlg.res +++ b/Build/svencoop/captionmod/OptionsSubVideoAdvancedDlg.res @@ -1,22 +1,5 @@ "resource/OptionsSubVideoAdvancedDlg.res" { - "OptionsSubVideoAdvancedDlg" - { - "ControlName" "COptionsSubVideoAdvancedDlg" - "fieldName" "OptionsSubVideoAdvancedDlg" - "xpos" "c-171" - "ypos" "c-85" - "wide" "600" - "tall" "400" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "0" - "settitlebarvisible" "1" - "title" "#GameUI_VideoAdvanced_Title" - } - "DetailTexture" { "ControlName" "CCvarToggleCheckButton" @@ -263,7 +246,7 @@ { "ControlName" "Label" "fieldName" "Label_HDRExposure" - "xpos" "220" + "xpos" "180" "ypos" "40" "wide" "160" "tall" "24" @@ -283,7 +266,7 @@ { "ControlName" "CCvarSlider" "fieldName" "HDRExposure" - "xpos" "220" + "xpos" "180" "ypos" "62" "wide" "160" "tall" "40" @@ -305,7 +288,7 @@ { "ControlName" "Label" "fieldName" "Label_HDRDarkness" - "xpos" "220" + "xpos" "180" "ypos" "100" "wide" "160" "tall" "24" @@ -325,7 +308,7 @@ { "ControlName" "CCvarSlider" "fieldName" "HDRDarkness" - "xpos" "220" + "xpos" "180" "ypos" "122" "wide" "160" "tall" "40" @@ -347,7 +330,7 @@ { "ControlName" "Label" "fieldName" "Label_BloomIntensity" - "xpos" "220" + "xpos" "180" "ypos" "160" "wide" "160" "tall" "24" @@ -367,7 +350,7 @@ { "ControlName" "CCvarSlider" "fieldName" "BloomIntensity" - "xpos" "220" + "xpos" "180" "ypos" "188" "wide" "160" "tall" "40" @@ -389,7 +372,7 @@ { "ControlName" "Label" "fieldName" "Label_ShadowIntensity" - "xpos" "220" + "xpos" "180" "ypos" "220" "wide" "160" "tall" "24" @@ -409,7 +392,7 @@ { "ControlName" "CCvarSlider" "fieldName" "ShadowIntensity" - "xpos" "220" + "xpos" "180" "ypos" "242" "wide" "160" "tall" "40" @@ -431,7 +414,7 @@ { "ControlName" "Label" "fieldName" "Label_TexGamma" - "xpos" "410" + "xpos" "350" "ypos" "40" "wide" "160" "tall" "24" @@ -451,7 +434,7 @@ { "ControlName" "CCvarSlider" "fieldName" "TexGamma" - "xpos" "410" + "xpos" "350" "ypos" "62" "wide" "160" "tall" "40" @@ -473,7 +456,7 @@ { "ControlName" "Label" "fieldName" "Label_LightGamma" - "xpos" "410" + "xpos" "350" "ypos" "100" "wide" "160" "tall" "24" @@ -493,7 +476,7 @@ { "ControlName" "CCvarSlider" "fieldName" "LightGamma" - "xpos" "410" + "xpos" "350" "ypos" "122" "wide" "160" "tall" "40" @@ -550,71 +533,4 @@ "NumericInputOnly" "0" "unicode" "0" } - - "ButtonOK" - { - "ControlName" "Button" - "fieldName" "ButtonOK" - "xpos" "300" - "ypos" "350" - "wide" "80" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "19" - "labelText" "#GameUI_OK" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - "wrap" "0" - "Command" "OK" - "Default" "1" - "selected" "0" - } - "ButtonCancel" - { - "ControlName" "Button" - "fieldName" "ButtonCancel" - "xpos" "400" - "ypos" "350" - "wide" "80" - "tall" "24" - "autoResize" "0" - "pinCorner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "20" - "labelText" "#GameUI_Cancel" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - "wrap" "0" - "Command" "Close" - "Default" "0" - "selected" "0" - } - "ButtonApply" - { - "ControlName" "Button" - "fieldName" "ButtonApply" - "xpos" "500" - "ypos" "350" - "wide" "80" - "tall" "24" - "autoResize" "0" - "pinCorner" "3" - "visible" "1" - "enabled" "1" - "tabPosition" "21" - "paintbackground" "1" - "labelText" "#GameUI_Apply" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - "wrap" "0" - "Command" "Apply" - "Default" "0" - } } diff --git a/Build/svencoop/captionmod/SubtitlePanel.res b/Build/svencoop/captionmod/SubtitlePanel.res index 37fe68ea..b623480e 100644 --- a/Build/svencoop/captionmod/SubtitlePanel.res +++ b/Build/svencoop/captionmod/SubtitlePanel.res @@ -27,21 +27,5 @@ "panelcolor" "ControlBG" //Subtitle panel's background color "textfont" "SubtitleFont" //Text font "textalign" "L" //Text Alignment, L/C/R - "fadein" "0.3" //Text fade in duration. - "fadeout" "0.3" //Text fade out duration. - "holdtime" "10.0" //Text lifetime as default. - - //Add speaker's name to the head of subtitle text? - "prefix" "0" - - //Wait for all former lines to be played before playing a new line, 1 for wait and 0 for don't wait. - "waitplay" "0" - - //The bigger this value is, the longer it will take before displaying a queued lines. - //The default value is 1, if set to 0, all lines will be displayed instantly. If set to 1, lines will gradually disappear line by line. - "stimescale" "1.0" - - //This value scales the holdtime. default value = 1.0, if set to 0 or negative, 1.0 will be used. - "htimescale" "1.0" } } diff --git a/Build/svencoop/captionmod/gameui_english.txt b/Build/svencoop/captionmod/gameui_english.txt index 367ef1587d31e4c7f270b149a73dc7aca442699b..634b98745acc8f4844e2d743901960e1f2750107 100644 GIT binary patch delta 307 zcmew*{!e&9o^B9BDnlMa3Xm)U<9LP;hD3%W1|H%%Y r0IJLZ`bPnXQFX89Ovcb9$(62!rVi}#WT34%KzA!K@G@{Q)Iv!BzU)Ha delta 677 zcma)3%SyvQ6g^^XQo)UaMcfSCbRn&{5OE<=v|tgT8d18C(l#+ErfD$M>cU@;!u)|h zAa2BOvml;D)&}qy6(IPh zy#gg>{vc!}o0s8y=I#AuVc)_X+C(P|5vpYJ8Hb2yqaV)czB2fcYjY#P#?ud|E!2#C zY7{u3W}Bx{V#!luPkv;Vw=H1 zzJOU(Z|iDbcd2flxJO-gHJhWSC@qfM%B;yzZdE=TVlI-e#+9Kq=QO!)HYfhrtQF&3 z4mEd+cjR*;p*8z@n*=vDI}==W6l za!i3i7sz|ChI8G-4`LfPy<#y8W+-Jy0;+_mE@p5A>dFD~3mA%lWHD6#gySc7>M;P} zWI-nJ$sgFnjL>ax2HIZ$HYp$I4h05Zpu19lG{{Df?k8I&8?ftae#g3jX|e-{noa=N zy{SOE!h!ar0Ci>{*`>gsaamwv#Bl`%i*+T(K|1vi8a#mB%4A3fYAC^~Wzt5778`_? eNQMBQdysvDuptuY!k!Z`SCkld8Mqi~p(FsNxLY0o diff --git a/Build/svencoop/captionmod/gameui_schinese.txt b/Build/svencoop/captionmod/gameui_schinese.txt index 8093cf009f1f9e3db04bb6de59971bfd870830c5..2a845d42b950004a2afb2eb0516475eca929dba6 100644 GIT binary patch delta 116 zcmX>gyiH(2fl?4dDnlMa3Xm)U<9LP;hD3%W1|PG)2g2Z~EfR$-H2+2zL@GC6@$XLAW#6XWDL>^769afnRz;HcoJW#DDtVyI;R E0Jx(aGynhq delta 391 zcmdlca6ouMfn69wCPNBCDnmYlBakj*NMy)kNCxs#7~&a1fN~`aIY6Egg8~pA>zp`4 zfk79@zAY&FcbsHVyF?}(V=ns zy7TJw7(fuDeR2b /MP %(AdditionalOptions) - .\;$(SolutionDir)include;$(SolutionDir)include\Interface;$(SolutionDir)include\HLSDK\cl_dll;$(SolutionDir)include\HLSDK\common;$(SolutionDir)include\HLSDK\engine;$(SolutionDir)include\HLSDK\pm_shared;$(SolutionDir)include\HLSDK\public;$(SolutionDir)include\SteamSDK;$(SolutionDir)include\VGUI;$(SolutionDir)include\vgui_controls;$(SolutionDir)include\vgui_controls_legacy;$(SolutionDir)include\SourceSDK;$(SolutionDir)include\SourceSDK\tier0;$(SolutionDir)include\SourceSDK\tier1;$(SolutionDir)include\SourceSDK\vstdlib;$(CapstoneIncludeDirectory);%(AdditionalIncludeDirectories) + .\;$(SolutionDir)include;$(SolutionDir)include\Interface;$(SolutionDir)include\HLSDK\cl_dll;$(SolutionDir)include\HLSDK\common;$(SolutionDir)include\HLSDK\engine;$(SolutionDir)include\HLSDK\pm_shared;$(SolutionDir)include\HLSDK\public;$(SolutionDir)include\SteamSDK;$(SolutionDir)include\VGUI;$(SolutionDir)include\vgui_controls;$(SolutionDir)include\SourceSDK;$(SolutionDir)include\SourceSDK\tier0;$(SolutionDir)include\SourceSDK\tier1;$(SolutionDir)include\SourceSDK\vstdlib;$(CapstoneIncludeDirectory);%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;STEAM_API_NODLL;VGUI_USE_SURFACE2;VGUI_USE_SCHEME2;NO_MALLOC_OVERRIDE;%(PreprocessorDefinitions) MultiThreadedDebug @@ -102,7 +102,7 @@ $(GLEWCheckRequirements) /MP %(AdditionalOptions) - .\;$(SolutionDir)include;$(SolutionDir)include\Interface;$(SolutionDir)include\HLSDK\cl_dll;$(SolutionDir)include\HLSDK\common;$(SolutionDir)include\HLSDK\engine;$(SolutionDir)include\HLSDK\pm_shared;$(SolutionDir)include\HLSDK\public;$(SolutionDir)include\SteamSDK;$(SolutionDir)include\VGUI;$(SolutionDir)include\vgui_controls;$(SolutionDir)include\vgui_controls_legacy;$(SolutionDir)include\SourceSDK;$(SolutionDir)include\SourceSDK\tier0;$(SolutionDir)include\SourceSDK\tier1;$(SolutionDir)include\SourceSDK\vstdlib;$(CapstoneIncludeDirectory);%(AdditionalIncludeDirectories) + .\;$(SolutionDir)include;$(SolutionDir)include\Interface;$(SolutionDir)include\HLSDK\cl_dll;$(SolutionDir)include\HLSDK\common;$(SolutionDir)include\HLSDK\engine;$(SolutionDir)include\HLSDK\pm_shared;$(SolutionDir)include\HLSDK\public;$(SolutionDir)include\SteamSDK;$(SolutionDir)include\VGUI;$(SolutionDir)include\vgui_controls;$(SolutionDir)include\SourceSDK;$(SolutionDir)include\SourceSDK\tier0;$(SolutionDir)include\SourceSDK\tier1;$(SolutionDir)include\SourceSDK\vstdlib;$(CapstoneIncludeDirectory);%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;STEAM_API_NODLL;VGUI_USE_SURFACE2;VGUI_USE_SCHEME2;NO_MALLOC_OVERRIDE;%(PreprocessorDefinitions) Async MultiThreaded @@ -157,13 +157,14 @@ $(GLEWCheckRequirements) + + + - - @@ -290,11 +291,13 @@ $(GLEWCheckRequirements) + + + + - - @@ -312,7 +315,6 @@ $(GLEWCheckRequirements) - diff --git a/Plugins/CaptionMod/CaptionMod.vcxproj.filters b/Plugins/CaptionMod/CaptionMod.vcxproj.filters index 6fb06c7b..b7219b08 100644 --- a/Plugins/CaptionMod/CaptionMod.vcxproj.filters +++ b/Plugins/CaptionMod/CaptionMod.vcxproj.filters @@ -194,12 +194,6 @@ VGUI2 - - VGUI2 - - - VGUI2 - VGUI2 @@ -455,6 +449,15 @@ vgui_controls + + vgui_controls + + + vgui_controls + + + vgui_controls + @@ -760,12 +763,6 @@ VGUI2 - - VGUI2 - - - VGUI2 - VGUI2 @@ -790,9 +787,6 @@ vgui_controls - - vgui_controls - vgui_controls @@ -1018,14 +1012,26 @@ EngineVGUI2 - - EngineVGUI2 - vgui_interface vgui_controls + + EngineVGUI2 + + + vgui_controls + + + vgui_controls + + + vgui_controls + + + VGUI2 + \ No newline at end of file diff --git a/Plugins/CaptionMod/CvarSlider.cpp b/Plugins/CaptionMod/CvarSlider.cpp deleted file mode 100644 index ddc3a21e..00000000 --- a/Plugins/CaptionMod/CvarSlider.cpp +++ /dev/null @@ -1,225 +0,0 @@ -#include -#include "CvarSlider.h" -#include -#include "tier1/KeyValues.h" -#include -#include - -#define CVARSLIDER_SCALE_FACTOR 100.0f - -using namespace vgui; - -DECLARE_BUILD_FACTORY(CCvarSlider); - -CCvarSlider::CCvarSlider(Panel *parent, const char *name) : Slider(parent, name) -{ - SetupSlider(0, 1, "", false); - m_bCreatedInCode = false; - - AddActionSignalTarget(this); -} - -CCvarSlider::CCvarSlider(Panel *parent, const char *panelName, char const *caption, float minValue, float maxValue, char const *cvarname, bool bAllowOutOfRange) : Slider(parent, panelName) -{ - AddActionSignalTarget(this); - SetupSlider(minValue, maxValue, cvarname, bAllowOutOfRange); - - m_bCreatedInCode = true; -} - -void CCvarSlider::SetupSlider(float minValue, float maxValue, const char *cvarname, bool bAllowOutOfRange) -{ - m_flMinValue = minValue; - m_flMaxValue = maxValue; - - SetRange((int)(CVARSLIDER_SCALE_FACTOR * minValue), (int)(CVARSLIDER_SCALE_FACTOR * maxValue)); - - char szMin[32]; - char szMax[32]; - - Q_snprintf(szMin, sizeof(szMin), "%.2f", minValue); - Q_snprintf(szMax, sizeof(szMax), "%.2f", maxValue); - - SetTickCaptions(szMin, szMax); - - Q_strncpy(m_szCvarName, cvarname, sizeof(m_szCvarName)); - - m_bModifiedOnce = false; - m_bAllowOutOfRange = bAllowOutOfRange; - - Reset(); -} - -CCvarSlider::~CCvarSlider(void) -{ -} - -void CCvarSlider::ApplySettings(KeyValues *inResourceData) -{ - BaseClass::ApplySettings(inResourceData); - - if (!m_bCreatedInCode) - { - float minValue = inResourceData->GetFloat("minvalue", 0); - float maxValue = inResourceData->GetFloat("maxvalue", 1); - const char *cvarname = inResourceData->GetString("cvar_name", ""); - bool bAllowOutOfRange = inResourceData->GetInt("allowoutofrange", 0) != 0; - SetupSlider(minValue, maxValue, cvarname, bAllowOutOfRange); - - if (GetParent()) - { - if (dynamic_cast(GetParent()) && GetParent()->GetParent()) - GetParent()->GetParent()->AddActionSignalTarget(this); - else - GetParent()->AddActionSignalTarget(this); - } - } -} - -void CCvarSlider::GetSettings(KeyValues *outResourceData) -{ - BaseClass::GetSettings(outResourceData); - - if (!m_bCreatedInCode) - { - outResourceData->SetFloat("minvalue", m_flMinValue); - outResourceData->SetFloat("maxvalue", m_flMaxValue); - outResourceData->SetString("cvar_name", m_szCvarName); - outResourceData->SetInt("allowoutofrange", m_bAllowOutOfRange); - } -} - -void CCvarSlider::SetCVarName(char const *cvarname) -{ - Q_strncpy(m_szCvarName, cvarname, sizeof(m_szCvarName)); - - m_bModifiedOnce = false; - - Reset(); -} - -void CCvarSlider::SetMinMaxValues(float minValue, float maxValue, bool bSetTickDisplay) -{ - SetRange((int)(CVARSLIDER_SCALE_FACTOR * minValue), (int)(CVARSLIDER_SCALE_FACTOR * maxValue)); - - if (bSetTickDisplay) - { - char szMin[32]; - char szMax[32]; - - Q_snprintf(szMin, sizeof(szMin), "%.2f", minValue); - Q_snprintf(szMax, sizeof(szMax), "%.2f", maxValue); - - SetTickCaptions(szMin, szMax); - } - - Reset(); -} - -void CCvarSlider::SetTickColor(Color color) -{ - m_TickColor = color; -} - -void CCvarSlider::Paint(void) -{ - float curvalue = gEngfuncs.pfnGetCvarFloat(m_szCvarName); - - if (curvalue != m_fStartValue) - { - int val = (int)(CVARSLIDER_SCALE_FACTOR * curvalue); - m_fStartValue = curvalue; - m_fCurrentValue = curvalue; - - SetValue(val); - m_iStartValue = GetValue(); - } - - BaseClass::Paint(); -} - -void CCvarSlider::ApplyChanges(void) -{ - if (m_bModifiedOnce) - { - m_iStartValue = GetValue(); - - if (m_bAllowOutOfRange) - m_fStartValue = m_fCurrentValue; - else - m_fStartValue = (float)m_iStartValue / CVARSLIDER_SCALE_FACTOR; - - char value[128]; - Q_snprintf(value, sizeof(value), "%.2f", m_fStartValue); - gEngfuncs.Cvar_Set(m_szCvarName, value); - } -} - -float CCvarSlider::GetSliderValue(void) -{ - if (m_bAllowOutOfRange) - return m_fCurrentValue; - else - return ((float)GetValue()) / CVARSLIDER_SCALE_FACTOR; -} - -void CCvarSlider::SetSliderValue(float fValue) -{ - int nVal = (int)(CVARSLIDER_SCALE_FACTOR * fValue); - SetValue(nVal, false); - - m_iLastSliderValue = GetValue(); - - if (m_fCurrentValue != fValue) - { - m_fCurrentValue = fValue; - m_bModifiedOnce = true; - } -} - -void CCvarSlider::Reset(void) -{ - auto cvar = gEngfuncs.pfnGetCvarPointer(m_szCvarName); - if (!cvar) - { - SetEnabled(false); - return; - } - - m_fStartValue = gEngfuncs.pfnGetCvarFloat(m_szCvarName); - m_fCurrentValue = m_fStartValue; - - int value = (int)(CVARSLIDER_SCALE_FACTOR * m_fStartValue); - SetValue(value); - - m_iStartValue = GetValue(); - m_iLastSliderValue = m_iStartValue; -} - -bool CCvarSlider::HasBeenModified(void) -{ - if (GetValue() != m_iStartValue) - m_bModifiedOnce = true; - - return m_bModifiedOnce; -} - -void CCvarSlider::OnSliderMoved(void) -{ - if (HasBeenModified()) - { - if (m_iLastSliderValue != GetValue()) - { - m_iLastSliderValue = GetValue(); - m_fCurrentValue = ((float) m_iLastSliderValue) / CVARSLIDER_SCALE_FACTOR; - } - - PostActionSignal(new KeyValues("ControlModified")); - } -} - -void CCvarSlider::OnApplyChanges(void) -{ - if (!m_bCreatedInCode) - ApplyChanges(); -} \ No newline at end of file diff --git a/Plugins/CaptionMod/CvarSlider.h b/Plugins/CaptionMod/CvarSlider.h deleted file mode 100644 index 8f227f1b..00000000 --- a/Plugins/CaptionMod/CvarSlider.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef CVARSLIDER_H -#define CVARSLIDER_H -#ifdef _WIN32 -#pragma once -#endif - -#include - -class CCvarSlider : public vgui::Slider -{ - DECLARE_CLASS_SIMPLE(CCvarSlider, vgui::Slider); - -public: - CCvarSlider(vgui::Panel *parent, const char *panelName); - CCvarSlider(vgui::Panel *parent, const char *panelName, char const *caption, float minValue, float maxValue, char const *cvarname, bool bAllowOutOfRange = false); - ~CCvarSlider(void); - -public: - void SetupSlider(float minValue, float maxValue, const char *cvarname, bool bAllowOutOfRange); - void SetCVarName(char const *cvarname); - void SetMinMaxValues(float minValue, float maxValue, bool bSetTickdisplay = true); - void SetTickColor(Color color); - -public: - virtual void Paint(void); - virtual void ApplySettings(KeyValues *inResourceData); - virtual void GetSettings(KeyValues *outResourceData); - -public: - void ApplyChanges(void); - float GetSliderValue(void); - void SetSliderValue(float fValue); - void Reset(void); - bool HasBeenModified(void); - -private: - MESSAGE_FUNC(OnSliderMoved, "SliderMoved"); - MESSAGE_FUNC(OnApplyChanges, "ApplyChanges"); - -private: - bool m_bAllowOutOfRange; - bool m_bModifiedOnce; - float m_fStartValue; - int m_iStartValue; - int m_iLastSliderValue; - float m_fCurrentValue; - char m_szCvarName[64]; - bool m_bCreatedInCode; - float m_flMinValue; - float m_flMaxValue; -}; - -#endif \ No newline at end of file diff --git a/Plugins/CaptionMod/CvarToggleCheckButton.cpp b/Plugins/CaptionMod/CvarToggleCheckButton.cpp deleted file mode 100644 index 16a046ce..00000000 --- a/Plugins/CaptionMod/CvarToggleCheckButton.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include "CvarToggleCheckButton.h" -#include -#include "tier1/KeyValues.h" -#include "IGameUIFuncs.h" - -using namespace vgui; - -vgui::Panel *CvarToggleCheckButton_Factory(void) -{ - return new CCvarToggleCheckButton(NULL, NULL, "CvarToggleCheckButton", NULL); -} - -DECLARE_BUILD_FACTORY_CUSTOM(CCvarToggleCheckButton, CvarToggleCheckButton_Factory); - -CCvarToggleCheckButton::CCvarToggleCheckButton(Panel *parent, const char *panelName, const char *text, char const *cvarname) : CheckButton(parent, panelName, text) -{ - m_bStartValue = false; - - if (cvarname) - { - Q_strncpy(m_szCvarName, cvarname, 63); - m_szCvarName[63] = 0; - } - else - { - m_szCvarName[0] = 0; - } - - Reset(); - - AddActionSignalTarget(this); -} - -CCvarToggleCheckButton::~CCvarToggleCheckButton(void) -{ - m_szCvarName[0] = 0; -} - -void CCvarToggleCheckButton::Paint(void) -{ - if (!m_szCvarName[0]) - { - BaseClass::Paint(); - return; - } - - bool value = gEngfuncs.pfnGetCvarFloat(m_szCvarName) > 0.0f ? true : false; - - if (value != m_bStartValue) - { - SetSelected(value); - m_bStartValue = value; - } - - BaseClass::Paint(); -} - -void CCvarToggleCheckButton::ApplyChanges(void) -{ - if (!m_szCvarName[0]) - return; - - m_bStartValue = IsSelected(); - gEngfuncs.Cvar_SetValue(m_szCvarName, m_bStartValue ? 1.0f : 0.0f); -} - -void CCvarToggleCheckButton::Reset(void) -{ - if (!m_szCvarName[0]) - return; - - auto cvar = gEngfuncs.pfnGetCvarPointer(m_szCvarName); - if (!cvar) - { - SetEnabled(false); - return; - } - - m_bStartValue = gEngfuncs.pfnGetCvarFloat(m_szCvarName) > 0.0f ? true : false; - SetSelected(m_bStartValue); -} - -bool CCvarToggleCheckButton::HasBeenModified(void) -{ - return IsSelected() != m_bStartValue; -} - -const char *CCvarToggleCheckButton::GetCvarName(void) -{ - return m_szCvarName; -} - -void CCvarToggleCheckButton::SetSelected(bool state) -{ - BaseClass::SetSelected(state); -} - -void CCvarToggleCheckButton::OnButtonChecked(void) -{ - if (HasBeenModified()) - PostActionSignal(new KeyValues("ControlModified")); -} - -void CCvarToggleCheckButton::ApplySettings(KeyValues *inResourceData) -{ - BaseClass::ApplySettings(inResourceData); - - const char *cvarName = inResourceData->GetString("cvar_name", ""); - const char *cvarValue = inResourceData->GetString("cvar_value", ""); - - if (Q_stricmp(cvarName, "") == 0) - return; - - Q_strncpy(m_szCvarName, cvarName, 63); - m_szCvarName[63] = 0; - - if (Q_stricmp(cvarValue, "1") == 0) - m_bStartValue = true; - else - m_bStartValue = false; - - if (gEngfuncs.pfnGetCvarFloat(m_szCvarName) != 0) - SetSelected(true); - else - SetSelected(false); -} \ No newline at end of file diff --git a/Plugins/CaptionMod/CvarToggleCheckButton.h b/Plugins/CaptionMod/CvarToggleCheckButton.h deleted file mode 100644 index d3310890..00000000 --- a/Plugins/CaptionMod/CvarToggleCheckButton.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef CVARTOGGLECHECKBUTTON_H -#define CVARTOGGLECHECKBUTTON_H -#ifdef _WIN32 -#pragma once -#endif - -#include - -class CCvarToggleCheckButton : public vgui::CheckButton -{ - DECLARE_CLASS_SIMPLE(CCvarToggleCheckButton, vgui::CheckButton); - -public: - CCvarToggleCheckButton(vgui::Panel *parent, const char *panelName, const char *text, char const *cvarname); - ~CCvarToggleCheckButton(void); - -public: - virtual void SetSelected(bool state); - virtual void Paint(void); - -public: - void Reset(void); - void ApplyChanges(void); - bool HasBeenModified(void); - void ApplySettings(KeyValues *inResourceData); - const char *GetCvarName(void); -private: - MESSAGE_FUNC(OnButtonChecked, "CheckButtonChecked"); - -private: - char m_szCvarName[64]; - bool m_bStartValue; -}; - -#endif \ No newline at end of file diff --git a/Plugins/CaptionMod/GameUI.cpp b/Plugins/CaptionMod/GameUI.cpp index d2d562ce..2227a22a 100644 --- a/Plugins/CaptionMod/GameUI.cpp +++ b/Plugins/CaptionMod/GameUI.cpp @@ -13,6 +13,7 @@ #include "vgui_controls/PropertyPage.h" #include "CvarSlider.h" #include "CvarToggleCheckButton.h" +#include "CvarTextEntry.h" #include "Viewport.h" @@ -28,15 +29,17 @@ static hook_t* g_phook_GameUI_Panel_Init = NULL; static hook_t* g_phook_CGameConsoleDialog_ctor = NULL; static hook_t* g_phook_CCreateMultiplayerGameDialog_ctor = NULL; static hook_t* g_phook_COptionsDialog_ctor = NULL; -static hook_t *g_phook_COptionsSubVideo_ctor = NULL; +//static hook_t *g_phook_COptionsSubVideo_ctor = NULL; +//static hook_t *g_phook_COptionsSubAudio_ctor = NULL; static hook_t *g_phook_COptionsSubVideo_ApplyVidSettings = NULL; -static hook_t *g_phook_COptionsSubAudio_ctor = NULL; static hook_t* g_phook_RichText_InsertChar = NULL; static hook_t* g_phook_RichText_InsertStringW = NULL; static hook_t* g_phook_RichText_OnThink = NULL; static hook_t* g_phook_TextEntry_OnKeyCodeTyped = NULL; static hook_t* g_phook_TextEntry_LayoutVerticalScrollBarSlider = NULL; static hook_t* g_phook_TextEntry_GetStartDrawIndex = NULL; +static hook_t* g_phook_PropertySheet_HasHotkey = NULL; +static hook_t* g_phook_FocusNavGroup_GetCurrentFocus = NULL; vgui::Panel** staticPanel = NULL; @@ -221,11 +224,24 @@ void CGameUI::Initialize(CreateInterfaceFn *factories, int count) void CGameUI::Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion, void *system) { - if (!vgui::localize()->AddFile(g_pFullFileSystem, "captionmod/gameui_%language%.txt")) + if (g_pFileSystem) { - if (!vgui::localize()->AddFile(g_pFullFileSystem, "captionmod/gameui_english.txt")) + if (!vgui::localize()->AddFile(g_pFileSystem, "captionmod/gameui_%language%.txt")) { - g_pMetaHookAPI->SysError("Failed to load captionmod/gameui_english.txt"); + if (!vgui::localize()->AddFile(g_pFileSystem, "captionmod/gameui_english.txt")) + { + g_pMetaHookAPI->SysError("Failed to load captionmod/gameui_english.txt"); + } + } + } + else if (g_pFileSystem_HL25) + { + if (!vgui::localize()->AddFile((IFileSystem *)g_pFileSystem_HL25, "captionmod/gameui_%language%.txt")) + { + if (!vgui::localize()->AddFile((IFileSystem*)g_pFileSystem_HL25, "captionmod/gameui_english.txt")) + { + g_pMetaHookAPI->SysError("Failed to load captionmod/gameui_english.txt"); + } } } @@ -327,18 +343,13 @@ void CGameUI::SetSecondaryProgressBarText(const char *statusText) return g_pfnCGameUI_SetSecondaryProgressBarText(this, 0, statusText); } -class COptionsSubVideoAdvancedDlg : public vgui::Frame +class COptionsSubVideoAdvancedDlg : public vgui::PropertyPage { - DECLARE_CLASS_SIMPLE(COptionsSubVideoAdvancedDlg, vgui::Frame); + DECLARE_CLASS_SIMPLE(COptionsSubVideoAdvancedDlg, vgui::PropertyPage); public: COptionsSubVideoAdvancedDlg(vgui::Panel *parent) : BaseClass(parent, "OptionsSubVideoAdvancedDlg") { - SetTitle("#GameUI_VideoAdvanced_Title", true); - SetSize(600, 400); - SetSizeable(false); - SetDeleteSelfOnClose(true); - m_pAnisotropicFiltering = new vgui::ComboBox(this, "AnisotropicFiltering", 5, false); m_pAnisotropicFiltering->AddItem("1X", NULL); m_pAnisotropicFiltering->AddItem("2X", NULL); @@ -366,29 +377,7 @@ class COptionsSubVideoAdvancedDlg : public vgui::Frame m_pTexGamma = new CCvarSlider(this, "TexGamma", "#GameUI_TexGamma", 1.8f, 3.0f, "texgamma", false); m_pLightGamma = new CCvarSlider(this, "LightGamma", "#GameUI_LightGamma", 1.8f, 3.0f, "lightgamma", false); - LoadControlSettings("captionmod\\OptionsSubVideoAdvancedDlg.res"); - } - - virtual void Activate(void) - { - OnResetData(); - BaseClass::Activate(); - - vgui::input()->SetAppModalSurface(GetVPanel()); - } - - MESSAGE_FUNC_PTR(OnTextChanged, "TextChanged", panel) - { - } - - MESSAGE_FUNC(OnGameUIHidden, "GameUIHidden") - { - Close(); - } - - MESSAGE_FUNC(OK_Confirmed, "OK_Confirmed") - { - Close(); + LoadControlSettings("captionmod/OptionsSubVideoAdvancedDlg.res"); } void ApplyChangesToConVar(const char *pConVarName, int value) @@ -398,7 +387,7 @@ class COptionsSubVideoAdvancedDlg : public vgui::Frame gEngfuncs.pfnClientCmd(szCmd); } - virtual void ApplyChanges(void) + void ApplyChanges(void) { int activateItem = m_pAnisotropicFiltering->GetActiveItem(); @@ -430,7 +419,7 @@ class COptionsSubVideoAdvancedDlg : public vgui::Frame m_pLightGamma->ApplyChanges(); } - virtual void OnResetData(void) + void OnResetData(void) override { m_pDetailTexture->Reset(); m_pWaterShader->Reset(); @@ -452,6 +441,7 @@ class COptionsSubVideoAdvancedDlg : public vgui::Frame m_pLightGamma->Reset(); auto gl_ansio = gEngfuncs.pfnGetCvarPointer("gl_ansio"); + if (gl_ansio) { int ansio = gl_ansio->value; @@ -473,12 +463,11 @@ class COptionsSubVideoAdvancedDlg : public vgui::Frame } } - virtual void OnCommand(const char *command) + void OnCommand(const char *command) override { if (!stricmp(command, "OK")) { ApplyChanges(); - Close(); } else if (!stricmp(command, "Apply")) { @@ -490,13 +479,9 @@ class COptionsSubVideoAdvancedDlg : public vgui::Frame } } - bool RequiresRestart(void) - { - return false; - } + MESSAGE_FUNC(OnDataChanged, "ControlModified"); private: - bool m_bUseChanges; vgui::ComboBox *m_pAnisotropicFiltering; CCvarToggleCheckButton *m_pDetailTexture; CCvarToggleCheckButton *m_pWaterShader; @@ -518,53 +503,24 @@ class COptionsSubVideoAdvancedDlg : public vgui::Frame CCvarSlider *m_pLightGamma; }; -class COptionsSubAudioAdvancedDlg : public vgui::Frame +class COptionsSubAudioAdvancedDlg : public vgui::PropertyPage { - DECLARE_CLASS_SIMPLE(COptionsSubAudioAdvancedDlg, vgui::Frame); + DECLARE_CLASS_SIMPLE(COptionsSubAudioAdvancedDlg, vgui::PropertyPage); public: COptionsSubAudioAdvancedDlg(vgui::Panel *parent) : BaseClass(parent, "OptionsSubAudioAdvancedDlg") { - SetTitle("#GameUI_CaptionMod_Title", true); - SetSize(600, 400); - SetSizeable(false); - SetDeleteSelfOnClose(true); - - m_pPrefixButton = new vgui::CheckButton(this, "PrefixButton", "#GameUI_CaptionMod_Prefix"); - m_pWaitPlayButton = new vgui::CheckButton(this, "WaitPlayButton", "#GameUI_CaptionMod_WaitPlay"); - m_pAntiSpamButton = new vgui::CheckButton(this, "AntiSpamButton", "#GameUI_CaptionMod_AntiSpam"); - m_pFadeInEntry = new vgui::TextEntry(this, "FadeInEntry"); - m_pFadeOutEntry = new vgui::TextEntry(this, "FadeOutEntry"); - m_pHoldTimeEntry = new vgui::TextEntry(this, "HoldTimeEntry"); - m_pHoldTimeScaleEntry = new vgui::TextEntry(this, "HoldTimeScaleEntry"); - m_pStartTimeScaleEntry = new vgui::TextEntry(this, "StartTimeScaleEntry"); - m_pWidthEntry = new vgui::TextEntry(this, "WidthEntry"); - m_pHeightEntry = new vgui::TextEntry(this, "HeightEntry"); - m_pYPosEntry = new vgui::TextEntry(this, "YPosEntry"); - - LoadControlSettings("captionmod\\OptionsSubAudioAdvancedDlg.res"); - } + m_pPrefixButton = new CCvarToggleCheckButton(this, "PrefixButton", "#GameUI_CaptionMod_Prefix", "cap_subtitle_prefix"); + m_pWaitPlayButton = new CCvarToggleCheckButton(this, "WaitPlayButton", "#GameUI_CaptionMod_WaitPlay", "cap_subtitle_waitplay"); + m_pAntiSpamButton = new CCvarToggleCheckButton(this, "AntiSpamButton", "#GameUI_CaptionMod_AntiSpam", "cap_subtitle_antispam"); - virtual void Activate(void) - { - OnResetData(); - BaseClass::Activate(); + m_pFadeInEntry = new CCvarTextEntry(this, "FadeInEntry", "cap_subtitle_fadein"); + m_pFadeOutEntry = new CCvarTextEntry(this, "FadeOutEntry", "cap_subtitle_fadeout"); + m_pHoldTimeEntry = new CCvarTextEntry(this, "HoldTimeEntry", "cap_subtitle_holdtime"); + m_pHoldTimeScaleEntry = new CCvarTextEntry(this, "HoldTimeScaleEntry", "cap_subtitle_htimescale"); + m_pStartTimeScaleEntry = new CCvarTextEntry(this, "StartTimeScaleEntry", "cap_subtitle_stimescale"); - vgui::input()->SetAppModalSurface(GetVPanel()); - } - - MESSAGE_FUNC_PTR(OnTextChanged, "TextChanged", panel) - { - } - - MESSAGE_FUNC(OnGameUIHidden, "GameUIHidden") - { - Close(); - } - - MESSAGE_FUNC(OK_Confirmed, "OK_Confirmed") - { - Close(); + LoadControlSettings("captionmod/OptionsSubAudioAdvancedDlg.res"); } void ApplyChangesToConVar(const char *pConVarName, int value) @@ -574,124 +530,42 @@ class COptionsSubAudioAdvancedDlg : public vgui::Frame gEngfuncs.pfnClientCmd(szCmd); } - virtual void ApplyChanges(void) + void ApplyChanges(void) { - SubtitlePanelVars_t vars = { 0 }; - - vars.m_iPrefix = m_pPrefixButton->IsSelected() ? 1 : 0; - vars.m_iWaitPlay = m_pWaitPlayButton->IsSelected() ? 1 : 0; - vars.m_iAntiSpam = m_pAntiSpamButton->IsSelected() ? 1 : 0; - - { - char szTextEntry[16] = { 0 }; - m_pFadeInEntry->GetText(szTextEntry, sizeof(szTextEntry)); - vars.m_flFadeIn = atof(szTextEntry); - } - - { - char szTextEntry[16] = { 0 }; - m_pFadeOutEntry->GetText(szTextEntry, sizeof(szTextEntry)); - vars.m_flFadeOut = atof(szTextEntry); - } - - { - char szTextEntry[16] = { 0 }; - m_pHoldTimeEntry->GetText(szTextEntry, sizeof(szTextEntry)); - vars.m_flHoldTime = atof(szTextEntry); - } - - { - char szTextEntry[16] = { 0 }; - m_pHoldTimeScaleEntry->GetText(szTextEntry, sizeof(szTextEntry)); - vars.m_flHoldTimeScale = atof(szTextEntry); - } - - { - char szTextEntry[16] = { 0 }; - m_pStartTimeScaleEntry->GetText(szTextEntry, sizeof(szTextEntry)); - vars.m_flStartTimeScale = atof(szTextEntry); - } - - { - char szTextEntry[16] = { 0 }; - m_pWidthEntry->GetText(szTextEntry, sizeof(szTextEntry)); - vars.m_iWidth = atoi(szTextEntry); - } - - { - char szTextEntry[16] = { 0 }; - m_pHeightEntry->GetText(szTextEntry, sizeof(szTextEntry)); - vars.m_iHeight = atoi(szTextEntry); - } - - { - char szTextEntry[16] = { 0 }; - m_pYPosEntry->GetText(szTextEntry, sizeof(szTextEntry)); - vars.m_iYPos = atoi(szTextEntry); - } - - if (g_pViewPort) - g_pViewPort->UpdateSubtitlePanelVars(&vars); + m_pPrefixButton->ApplyChanges(); + m_pWaitPlayButton->ApplyChanges(); + m_pAntiSpamButton->ApplyChanges(); + + m_pFadeInEntry->ApplyChanges(); + m_pFadeOutEntry->ApplyChanges(); + m_pHoldTimeEntry->ApplyChanges(); + m_pHoldTimeScaleEntry->ApplyChanges(); + m_pStartTimeScaleEntry->ApplyChanges(); } - virtual void OnResetData(void) + void OnApplyChanges() override { - SubtitlePanelVars_t vars = { 0 }; - if(g_pViewPort) - g_pViewPort->QuerySubtitlePanelVars(&vars); - - m_pPrefixButton->SetSelected(vars.m_iPrefix ? true : false); - m_pWaitPlayButton->SetSelected(vars.m_iWaitPlay ? true : false); - m_pAntiSpamButton->SetSelected(vars.m_iAntiSpam ? true : false); + ApplyChanges(); + } - { - char szTextEntry[16] = { 0 }; - V_snprintf(szTextEntry, sizeof(szTextEntry) - 1, "%.1f", vars.m_flFadeIn); - m_pFadeInEntry->SetText(szTextEntry); - } - { - char szTextEntry[16] = { 0 }; - V_snprintf(szTextEntry, sizeof(szTextEntry) - 1, "%.1f", vars.m_flFadeOut); - m_pFadeOutEntry->SetText(szTextEntry); - } - { - char szTextEntry[16] = { 0 }; - V_snprintf(szTextEntry, sizeof(szTextEntry) - 1, "%.1f", vars.m_flHoldTime); - m_pHoldTimeEntry->SetText(szTextEntry); - } - { - char szTextEntry[16] = { 0 }; - V_snprintf(szTextEntry, sizeof(szTextEntry) - 1, "%.1f", vars.m_flHoldTimeScale); - m_pHoldTimeScaleEntry->SetText(szTextEntry); - } - { - char szTextEntry[16] = { 0 }; - V_snprintf(szTextEntry, sizeof(szTextEntry) - 1, "%.1f", vars.m_flStartTimeScale); - m_pStartTimeScaleEntry->SetText(szTextEntry); - } - { - char szTextEntry[16] = { 0 }; - V_snprintf(szTextEntry, sizeof(szTextEntry) - 1, "%d", vars.m_iWidth); - m_pWidthEntry->SetText(szTextEntry); - } - { - char szTextEntry[16] = { 0 }; - V_snprintf(szTextEntry, sizeof(szTextEntry) - 1, "%d", vars.m_iHeight); - m_pHeightEntry->SetText(szTextEntry); - } - { - char szTextEntry[16] = { 0 }; - V_snprintf(szTextEntry, sizeof(szTextEntry) - 1, "%d", vars.m_iYPos); - m_pYPosEntry->SetText(szTextEntry); - } + void OnResetData(void) override + { + m_pPrefixButton->Reset(); + m_pWaitPlayButton->Reset(); + m_pAntiSpamButton->Reset(); + + m_pFadeInEntry->Reset(); + m_pFadeOutEntry->Reset(); + m_pHoldTimeEntry->Reset(); + m_pHoldTimeScaleEntry->Reset(); + m_pStartTimeScaleEntry->Reset(); } - virtual void OnCommand(const char *command) + void OnCommand(const char *command) override { if (!stricmp(command, "OK")) { ApplyChanges(); - Close(); } else if (!stricmp(command, "Apply")) { @@ -703,49 +577,29 @@ class COptionsSubAudioAdvancedDlg : public vgui::Frame } } -private: - bool m_bUseChanges; - - vgui::CheckButton *m_pPrefixButton; - vgui::CheckButton *m_pWaitPlayButton; - vgui::CheckButton *m_pAntiSpamButton; - vgui::TextEntry *m_pFadeInEntry; - vgui::TextEntry *m_pFadeOutEntry; - vgui::TextEntry *m_pHoldTimeEntry; - vgui::TextEntry *m_pHoldTimeScaleEntry; - vgui::TextEntry *m_pStartTimeScaleEntry; - vgui::TextEntry *m_pWidthEntry; - vgui::TextEntry *m_pHeightEntry; - vgui::TextEntry *m_pYPosEntry; -}; - -static vgui::DHANDLE m_hOptionsSubVideoAdvancedDlg; + MESSAGE_FUNC(OnDataChanged, "ControlModified"); -static vgui::DHANDLE m_hOptionsSubAudioAdvancedDlg; +private: -void __fastcall COptionsSubVideo_OnCommand(vgui::Panel *pthis, int dummy, const char *command); + CCvarToggleCheckButton*m_pPrefixButton; + CCvarToggleCheckButton*m_pWaitPlayButton; + CCvarToggleCheckButton*m_pAntiSpamButton; -static decltype(COptionsSubVideo_OnCommand) *g_pfnCOptionsSubVideo_OnCommand = NULL; + CCvarTextEntry *m_pFadeInEntry; + CCvarTextEntry *m_pFadeOutEntry; + CCvarTextEntry *m_pHoldTimeEntry; + CCvarTextEntry *m_pHoldTimeScaleEntry; + CCvarTextEntry *m_pStartTimeScaleEntry; +}; -void __fastcall COptionsSubVideo_OnCommand(vgui::Panel *pthis, int dummy, const char *command) +void COptionsSubVideoAdvancedDlg::OnDataChanged() { - if (0 == strcmp(command, "Advanced")) - { - if (!m_hOptionsSubVideoAdvancedDlg.Get()) - m_hOptionsSubVideoAdvancedDlg = new COptionsSubVideoAdvancedDlg(pthis); - - m_hOptionsSubVideoAdvancedDlg->Activate(); - } + GetParentWithModuleName("GameUI")->PostActionSignal(new KeyValues("ApplyButtonEnable")); } -void * __fastcall COptionsSubVideo_ctor(vgui::Panel *pthis, int dummy, vgui::Panel *parent) +void COptionsSubAudioAdvancedDlg::OnDataChanged() { - auto result = gPrivateFuncs.COptionsSubVideo_ctor(pthis, dummy, parent); - - if (!g_pfnCOptionsSubVideo_OnCommand) - g_pMetaHookAPI->VFTHook(pthis, 0, 0x15C / 4, COptionsSubVideo_OnCommand, (void **)&g_pfnCOptionsSubVideo_OnCommand); - - return result; + GetParentWithModuleName("GameUI")->PostActionSignal(new KeyValues("ApplyButtonEnable")); } void __fastcall COptionsSubVideo_ApplyVidSettings(vgui::Panel *pthis, int dummy, bool bForceRestart) @@ -761,39 +615,99 @@ void __fastcall COptionsSubVideo_ApplyVidSettings_HL25(vgui::Panel *pthis, int d gPrivateFuncs.COptionsSubVideo_ApplyVidSettings_HL25(pthis, dummy); } -void __fastcall COptionsSubAudio_OnCommand(vgui::Panel *pthis, int dummy, const char *command); - -static decltype(COptionsSubAudio_OnCommand) *g_pfnCOptionsSubAudio_OnCommand = NULL; - -void __fastcall COptionsSubAudio_OnCommand(vgui::Panel *pthis, int dummy, const char *command) +void* __fastcall FocusNavGroup_GetCurrentFocus(void* pthis, int dummy) { - g_pfnCOptionsSubAudio_OnCommand(pthis, dummy, command); + vgui::VPanelHandle* _currentFocus = (vgui::VPanelHandle*)((PUCHAR)pthis + 12); - if (0 == strcmp(command, "Advanced")) + auto vpanel = _currentFocus->Get(); + + if (vpanel) { - if (!m_hOptionsSubAudioAdvancedDlg.Get()) - m_hOptionsSubAudioAdvancedDlg = new COptionsSubAudioAdvancedDlg(pthis); + auto pPanel = vgui::ipanel()->GetPanel(vpanel, "GameUI"); + + if (!pPanel) + { + pPanel = vgui::ipanel()->GetPanel(vpanel, vgui::GetControlsModuleName()); + } - m_hOptionsSubAudioAdvancedDlg->Activate(); + return pPanel; } + + return NULL; } -void * __fastcall COptionsSubAudio_ctor(vgui::Panel *pthis, int dummy, vgui::Panel *parent) +void* __fastcall PropertySheet_HasHotkey(void *pthis, int dummy, wchar_t key) { - auto result = gPrivateFuncs.COptionsSubAudio_ctor(pthis, dummy, parent); + vgui::Panel* _activePage = *(vgui::Panel **)((PUCHAR)pthis + 144); - if (!g_pfnCOptionsSubAudio_OnCommand) - g_pMetaHookAPI->VFTHook(pthis, 0, 0x15C / 4, COptionsSubAudio_OnCommand, (void **)&g_pfnCOptionsSubAudio_OnCommand); + if (!_activePage) + return 0; - return result; + int childCount = _activePage->GetChildCount(); + + for (int i = 0; i < childCount; i++) + { + auto pChild = _activePage->GetChild(i); +#if 0 + if (!pChild) + { + pChild = _activePage->GetChildWithModuleName(i, "GameUI"); + } + if (!pChild) + { + pChild = _activePage->GetChildWithModuleName(i, "CaptionMod"); + } +#endif + if (pChild) + { + auto hot = pChild->HasHotkey(key); + + if (hot) + { + return (void *)hot; + } + } + } + + return NULL; } void* __fastcall COptionsDialog_ctor(vgui::Panel* pthis, int dummy, vgui::Panel* parent) { auto result = gPrivateFuncs.COptionsDialog_ctor(pthis, dummy, parent); + PVOID* COptionsDialog_vftable = *(PVOID**)pthis; + + vgui::Panel* _propertySheet = *(vgui::Panel**)((PUCHAR)pthis + 272); + PVOID* _propertySheet_vftable = *(PVOID**)_propertySheet; + + if (!gPrivateFuncs.FocusNavGroup_GetCurrentFocus) + { + void* (__fastcall * pfnGetFocusNavGroup)(vgui::Panel * pthis, int dummy) = (decltype(pfnGetFocusNavGroup))COptionsDialog_vftable[612 / 4]; + + auto FocusNavGroup = pfnGetFocusNavGroup(pthis, 0); + PVOID* FocusNavGroup_vftable = *(PVOID**)FocusNavGroup; + + gPrivateFuncs.FocusNavGroup_GetCurrentFocus = (decltype(gPrivateFuncs.FocusNavGroup_GetCurrentFocus))FocusNavGroup_vftable[7]; + Install_InlineHook(FocusNavGroup_GetCurrentFocus); + } + + if (!gPrivateFuncs.PropertySheet_HasHotkey) + { + gPrivateFuncs.PropertySheet_HasHotkey = (decltype(gPrivateFuncs.PropertySheet_HasHotkey))_propertySheet_vftable[73]; + Install_InlineHook(PropertySheet_HasHotkey); + } + + void(__fastcall * pfnAddPage)(vgui::Panel * pthis, int dummy, vgui::Panel * panel, const char* title) = + (decltype(pfnAddPage))_propertySheet_vftable[536 / 4]; + + //AddPage = (decltype(AddPage))((PUCHAR)GetModuleHandleA("GameUI.dll") + 0x3B180); + + pfnAddPage(_propertySheet, 0, new COptionsSubAudioAdvancedDlg(pthis), "#GameUI_CaptionMod_Tab"); + pfnAddPage(_propertySheet, 0, new COptionsSubVideoAdvancedDlg(pthis), "#GameUI_Renderer_Tab"); + //Load res to make it proportional - gPrivateFuncs.GameUI_LoadControlSettings(pthis, 0, "Resource\\OptionsDialog.res", NULL); + gPrivateFuncs.GameUI_LoadControlSettings(pthis, 0, "Resource/OptionsDialog.res", NULL); return result; } @@ -803,7 +717,7 @@ void* __fastcall CCreateMultiplayerGameDialog_ctor(vgui::Panel* pthis, int dummy auto result = gPrivateFuncs.CCreateMultiplayerGameDialog_ctor(pthis, dummy, parent); //Load res to make it proportional - gPrivateFuncs.GameUI_LoadControlSettings(pthis, 0, "Resource\\CreateMultiplayerGameDialog.res", NULL); + gPrivateFuncs.GameUI_LoadControlSettings(pthis, 0, "Resource/CreateMultiplayerGameDialog.res", NULL); return result; } @@ -813,7 +727,7 @@ void* __fastcall CGameConsoleDialog_ctor(vgui::Panel* pthis, int dummy) auto result = gPrivateFuncs.CGameConsoleDialog_ctor(pthis, dummy); //Load res to make it proportional - gPrivateFuncs.GameUI_LoadControlSettings(pthis, 0, "Resource\\GameConsoleDialog.res", NULL); + gPrivateFuncs.GameUI_LoadControlSettings(pthis, 0, "Resource/GameConsoleDialog.res", NULL); return result; } @@ -826,7 +740,7 @@ void* __fastcall QueryBox_ctor(vgui::Panel* pthis, int dummy, const char* title, //Load res to make it proportional if (!strcmp(queryText, "#GameUI_QuitConfirmationText")) { - //gPrivateFuncs.GameUI_LoadControlSettings(pthis, 0, "Resource\\QuitConfirmationBox.res", NULL); + //gPrivateFuncs.GameUI_LoadControlSettings(pthis, 0, "Resource/QuitConfirmationBox.res", NULL); return gPrivateFuncs.QueryBox_ctor(pthis, dummy, title, "#GameUI_QuitConfirmationText\n\n", parent); } @@ -838,28 +752,11 @@ void* __fastcall QueryBox_ctor(vgui::Panel* pthis, int dummy, const char* title, void CGameUI::HideGameUI(void) { - if (m_hOptionsSubVideoAdvancedDlg.Get()) - { - m_hOptionsSubVideoAdvancedDlg.Get()->PostMessage(m_hOptionsSubVideoAdvancedDlg.Get(), new KeyValues("GameUIHidden")); - } - if (m_hOptionsSubAudioAdvancedDlg.Get()) - { - m_hOptionsSubAudioAdvancedDlg.Get()->PostMessage(m_hOptionsSubAudioAdvancedDlg.Get(), new KeyValues("GameUIHidden")); - } - return g_pfnCGameUI_HideGameUI(this, 0); } -void GameUI_InstallHooks(void) +void GameUI_FillAddress(HMODULE hGameUI) { - auto hGameUI = GetModuleHandleA("GameUI.dll"); - - if (!hGameUI) - { - g_pMetaHookAPI->SysError("Failed to get GameUI module"); - return; - } - auto GameUIBase = g_pMetaHookAPI->GetModuleBase(hGameUI); if (!GameUIBase) @@ -868,22 +765,6 @@ void GameUI_InstallHooks(void) return; } - CreateInterfaceFn GameUICreateInterface = Sys_GetFactory((HINTERFACEMODULE)hGameUI); - - if (!GameUICreateInterface) - { - g_pMetaHookAPI->SysError("Failed to get interface factory from GameUI.dll"); - return; - } - - g_pGameUI = (IGameUI *)GameUICreateInterface(GAMEUI_INTERFACE_VERSION, 0); - - if (!g_pGameUI) - { - g_pMetaHookAPI->SysError("Failed to get interface \"" GAMEUI_INTERFACE_VERSION "\" from GameUI.dll"); - return; - } - ULONG GameUITextSize = 0; auto GameUITextBase = g_pMetaHookAPI->GetSectionByName(GameUIBase, ".text\0\0\0", &GameUITextSize); @@ -944,7 +825,7 @@ void GameUI_InstallHooks(void) return FALSE; - }, 0, NULL); + }, 0, NULL); Sig_FuncNotFound(QueryBox_ctor); } @@ -954,7 +835,7 @@ void GameUI_InstallHooks(void) { const char sigs1[] = "CreateMultiplayerGameDialog\0"; auto CreateMultiplayerGameDialog_String = g_pMetaHookAPI->SearchPattern(GameUIRdataBase, GameUIRdataSize, sigs1, sizeof(sigs1) - 1); - if(!CreateMultiplayerGameDialog_String) + if (!CreateMultiplayerGameDialog_String) CreateMultiplayerGameDialog_String = g_pMetaHookAPI->SearchPattern(GameUIDataBase, GameUIDataSize, sigs1, sizeof(sigs1) - 1); Sig_VarNotFound(CreateMultiplayerGameDialog_String); @@ -984,7 +865,7 @@ void GameUI_InstallHooks(void) } } return FALSE; - }); + }); Sig_FuncNotFound(CCreateMultiplayerGameDialog_ctor); } @@ -993,7 +874,7 @@ void GameUI_InstallHooks(void) { const char sigs1[] = "#GameUI_Options"; auto GameUI_Options_String = g_pMetaHookAPI->SearchPattern(GameUIRdataBase, GameUIRdataSize, sigs1, sizeof(sigs1) - 1); - if(!GameUI_Options_String) + if (!GameUI_Options_String) GameUI_Options_String = g_pMetaHookAPI->SearchPattern(GameUIDataBase, GameUIDataSize, sigs1, sizeof(sigs1) - 1); Sig_VarNotFound(GameUI_Options_String); @@ -1026,7 +907,7 @@ void GameUI_InstallHooks(void) } } return FALSE; - }); + }); Sig_FuncNotFound(COptionsDialog_ctor); } @@ -1035,12 +916,12 @@ void GameUI_InstallHooks(void) { const char sigs1[] = "#GameUI_Video"; auto GameUI_Video_String = g_pMetaHookAPI->SearchPattern(GameUIRdataBase, GameUIRdataSize, sigs1, sizeof(sigs1) - 1); - if(!GameUI_Video_String) + if (!GameUI_Video_String) GameUI_Video_String = g_pMetaHookAPI->SearchPattern(GameUIDataBase, GameUIDataSize, sigs1, sizeof(sigs1) - 1); Sig_VarNotFound(GameUI_Video_String); char pattern[] = "\xE8\x2A\x2A\x2A\x2A\x2A\x2A\x33\xC0\x68\x2A\x2A\x2A\x2A"; - *(DWORD *)(pattern + 10) = (DWORD)GameUI_Video_String; + *(DWORD*)(pattern + 10) = (DWORD)GameUI_Video_String; auto GameUI_Video_Call = g_pMetaHookAPI->SearchPattern(gPrivateFuncs.COptionsDialog_ctor, 0x300, pattern, sizeof(pattern) - 1); Sig_VarNotFound(GameUI_Video_Call); @@ -1052,7 +933,7 @@ void GameUI_InstallHooks(void) { const char sigs1[] = "Resource\\OptionsSubVideo.res"; auto OptionsSubVideo_res_String = g_pMetaHookAPI->SearchPattern(GameUIRdataBase, GameUIRdataSize, sigs1, sizeof(sigs1) - 1); - if(!OptionsSubVideo_res_String) + if (!OptionsSubVideo_res_String) OptionsSubVideo_res_String = g_pMetaHookAPI->SearchPattern(GameUIDataBase, GameUIDataSize, sigs1, sizeof(sigs1) - 1); Sig_VarNotFound(OptionsSubVideo_res_String); @@ -1062,25 +943,25 @@ void GameUI_InstallHooks(void) Sig_VarNotFound(OptionsSubVideo_res_PushString); g_pMetaHookAPI->DisasmRanges(OptionsSubVideo_res_PushString, 0x80, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) { - + auto pinst = (cs_insn*)inst; - if (address[0] == 0xE8 && instCount <= 8) - { - gPrivateFuncs.GameUI_LoadControlSettings = (decltype(gPrivateFuncs.GameUI_LoadControlSettings))GetCallAddress(address); + if (address[0] == 0xE8 && instCount <= 8) + { + gPrivateFuncs.GameUI_LoadControlSettings = (decltype(gPrivateFuncs.GameUI_LoadControlSettings))GetCallAddress(address); - return TRUE; - } + return TRUE; + } - if (address[0] == 0xCC) - return TRUE; + if (address[0] == 0xCC) + return TRUE; - if (pinst->id == X86_INS_RET) - return TRUE; + if (pinst->id == X86_INS_RET) + return TRUE; - return FALSE; + return FALSE; - }, 0, NULL); + }, 0, NULL); Sig_FuncNotFound(GameUI_LoadControlSettings); } @@ -1089,12 +970,12 @@ void GameUI_InstallHooks(void) { const char sigs1[] = "#GameUI_Audio"; auto GameUI_Audio_String = g_pMetaHookAPI->SearchPattern(GameUIRdataBase, GameUIRdataSize, sigs1, sizeof(sigs1) - 1); - if(!GameUI_Audio_String) + if (!GameUI_Audio_String) GameUI_Audio_String = g_pMetaHookAPI->SearchPattern(GameUIDataBase, GameUIDataSize, sigs1, sizeof(sigs1) - 1); Sig_VarNotFound(GameUI_Audio_String); char pattern[] = "\xE8\x2A\x2A\x2A\x2A\x2A\x2A\x33\xC0\x68\x2A\x2A\x2A\x2A"; - *(DWORD *)(pattern + 10) = (DWORD)GameUI_Audio_String; + *(DWORD*)(pattern + 10) = (DWORD)GameUI_Audio_String; auto GameUI_Audio_Call = g_pMetaHookAPI->SearchPattern(gPrivateFuncs.COptionsDialog_ctor, 0x300, pattern, sizeof(pattern) - 1); Sig_VarNotFound(GameUI_Audio_Call); @@ -1106,12 +987,12 @@ void GameUI_InstallHooks(void) { const char sigs1[] = "_setvideomode"; auto SetVideoMode_String = g_pMetaHookAPI->SearchPattern(GameUIRdataBase, GameUIRdataSize, sigs1, sizeof(sigs1) - 1); - if(!SetVideoMode_String) + if (!SetVideoMode_String) SetVideoMode_String = g_pMetaHookAPI->SearchPattern(GameUIDataBase, GameUIDataSize, sigs1, sizeof(sigs1) - 1); Sig_VarNotFound(SetVideoMode_String); char pattern[] = "\x68\x2A\x2A\x2A\x2A\x2A\xE8"; - *(DWORD *)(pattern + 1) = (DWORD)SetVideoMode_String; + *(DWORD*)(pattern + 1) = (DWORD)SetVideoMode_String; auto SetVideoMode_PushString = g_pMetaHookAPI->SearchPattern(GameUITextBase, GameUITextSize, pattern, sizeof(pattern) - 1); Sig_VarNotFound(SetVideoMode_PushString); @@ -1138,7 +1019,7 @@ void GameUI_InstallHooks(void) } return FALSE; - }); + }); Sig_FuncNotFound(COptionsSubVideo_ApplyVidSettings); } @@ -1165,7 +1046,7 @@ void GameUI_InstallHooks(void) } return FALSE; - }); + }); Sig_FuncNotFound(COptionsSubVideo_ApplyVidSettings_HL25); } } @@ -1215,7 +1096,7 @@ void GameUI_InstallHooks(void) ((PUCHAR)pinst->detail->x86.operands[1].imm > (PUCHAR)ctx->GameUIRdataBase && (PUCHAR)pinst->detail->x86.operands[1].imm < (PUCHAR)ctx->GameUIRdataBase + ctx->GameUIRdataSize)) { - auto candidate = (PVOID *)pinst->detail->x86.operands[1].imm; + auto candidate = (PVOID*)pinst->detail->x86.operands[1].imm; if (candidate[0] >= (PUCHAR)ctx->GameUITextBase && candidate[0] < (PUCHAR)ctx->GameUITextBase + ctx->GameUITextSize) { ctx->ConsoleHistory_vftable = candidate; @@ -1233,7 +1114,7 @@ void GameUI_InstallHooks(void) return FALSE; - }, 0, & ctx); + }, 0, &ctx); Sig_VarNotFound(ctx.ConsoleHistory_vftable); @@ -1300,7 +1181,7 @@ void GameUI_InstallHooks(void) return FALSE; - }, 0, & ctx); + }, 0, &ctx); Sig_VarNotFound(ctx.bFound_RichText_Print); } @@ -1351,7 +1232,7 @@ void GameUI_InstallHooks(void) ctx.walks.pop_back(); g_pMetaHookAPI->DisasmRanges(walk.address, walk.len, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) - { + { auto pinst = (cs_insn*)inst; auto ctx = (RichText_PrintWalkContext*)context; @@ -1448,7 +1329,7 @@ void GameUI_InstallHooks(void) return FALSE; - }, 0, & ctx2); + }, 0, &ctx2); if (ctx2.IsFetchWord) { @@ -1607,26 +1488,199 @@ void GameUI_InstallHooks(void) gPrivateFuncs.TextEntry_LayoutVerticalScrollBarSlider = (decltype(gPrivateFuncs.TextEntry_LayoutVerticalScrollBarSlider))ctx.ConsoleEntry_vftable[0x2C0 / 4]; gPrivateFuncs.TextEntry_GetStartDrawIndex = (decltype(gPrivateFuncs.TextEntry_GetStartDrawIndex))ctx.ConsoleEntry_vftable[0x2F8 / 4]; } +#if 0 + if (1) + { + PVOID Sheet_PushString = NULL; + const char sigs1[] = "Sheet\0"; + auto PropertySheet_String = g_pMetaHookAPI->SearchPattern(GameUIRdataBase, GameUIRdataSize, sigs1, sizeof(sigs1) - 1); + if (!PropertySheet_String) + { + PropertySheet_String = g_pMetaHookAPI->SearchPattern(GameUIDataBase, GameUIDataSize, sigs1, sizeof(sigs1) - 1); + + if (PropertySheet_String) + { + PUCHAR SearchBegin = (PUCHAR)GameUIDataBase; + PUCHAR SearchLimit = (PUCHAR)GameUIDataBase + GameUIDataSize; + while (SearchBegin < SearchLimit) + { + PUCHAR pFound = (PUCHAR)Search_Pattern_From_Size(SearchBegin, SearchLimit - SearchBegin, sigs1); + if (pFound) + { + char pattern[] = "\x74\x2A\x68\x2A\x2A\x2A\x2A"; + *(DWORD*)(pattern + 3) = (DWORD)pFound; + Sheet_PushString = g_pMetaHookAPI->SearchPattern(GameUITextBase, GameUITextSize, pattern, sizeof(pattern) - 1); + if (Sheet_PushString) + { + break; + } + + SearchBegin = pFound + Sig_Length(sigs1); + } + else + { + break; + } + } + } + } + else + { + PUCHAR SearchBegin = (PUCHAR)GameUIRdataBase; + PUCHAR SearchLimit = (PUCHAR)GameUIRdataBase + GameUIRdataSize; + while (SearchBegin < SearchLimit) + { + PUCHAR pFound = (PUCHAR)Search_Pattern_From_Size(SearchBegin, SearchLimit - SearchBegin, sigs1); + if (pFound) + { + char pattern[] = "\x74\x2A\x68\x2A\x2A\x2A\x2A"; + *(DWORD*)(pattern + 3) = (DWORD)pFound; + Sheet_PushString = g_pMetaHookAPI->SearchPattern(GameUITextBase, GameUITextSize, pattern, sizeof(pattern) - 1); + if (Sheet_PushString) + { + break; + } + + SearchBegin = pFound + Sig_Length(sigs1); + } + else + { + break; + } + } + } + Sig_VarNotFound(Sheet_PushString); + + g_pMetaHookAPI->DisasmRanges(Sheet_PushString, 0x80, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) { + + auto pinst = (cs_insn*)inst; + + if (address[0] == 0xE8 && instCount <= 5) + { + gPrivateFuncs.Sheet_ctor = (decltype(gPrivateFuncs.Sheet_ctor))GetCallAddress(address); + + return TRUE; + } + + if (address[0] == 0xCC) + return TRUE; + + if (pinst->id == X86_INS_RET) + return TRUE; + + return FALSE; + + }, 0, NULL); + + Sig_FuncNotFound(Sheet_ctor); + + typedef struct + { + PVOID GameUIRdataBase; + ULONG GameUIRdataSize; + + PVOID GameUITextBase; + ULONG GameUITextSize; + + PVOID* Sheet_vftable; + + }SheetSearchContext; + + SheetSearchContext ctx = { 0 }; + + ctx.GameUIRdataBase = GameUIRdataBase; + ctx.GameUIRdataSize = GameUIRdataSize; + + ctx.GameUITextBase = GameUITextBase; + ctx.GameUITextSize = GameUITextSize; + + g_pMetaHookAPI->DisasmRanges(gPrivateFuncs.Sheet_ctor, 0x300, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) { + + auto pinst = (cs_insn*)inst; + auto ctx = (SheetSearchContext*)context; + + if (pinst->id == X86_INS_MOV && + pinst->detail->x86.op_count == 2 && + pinst->detail->x86.operands[0].type == X86_OP_MEM && + pinst->detail->x86.operands[1].type == X86_OP_IMM && + ((PUCHAR)pinst->detail->x86.operands[1].imm > (PUCHAR)ctx->GameUIRdataBase && + (PUCHAR)pinst->detail->x86.operands[1].imm < (PUCHAR)ctx->GameUIRdataBase + ctx->GameUIRdataSize)) + { + auto candidate = (PVOID*)pinst->detail->x86.operands[1].imm; + if (candidate[0] >= (PUCHAR)ctx->GameUITextBase && candidate[0] < (PUCHAR)ctx->GameUITextBase + ctx->GameUITextSize) + { + ctx->Sheet_vftable = candidate; + } + } + + if (ctx->Sheet_vftable) + return TRUE; + + if (address[0] == 0xCC) + return TRUE; + + if (pinst->id == X86_INS_RET) + return TRUE; + + return FALSE; + + }, 0, &ctx); + + Sig_VarNotFound(ctx.Sheet_vftable); + + gPrivateFuncs.PropertySheet_HasHotkey = (decltype(gPrivateFuncs.PropertySheet_HasHotkey))ctx.Sheet_vftable[73]; + } +#endif gPrivateFuncs.GameUI_Panel_Init = (decltype(gPrivateFuncs.GameUI_Panel_Init))VGUI2_FindPanelInit(GameUITextBase, GameUITextSize); Sig_FuncNotFound(GameUI_Panel_Init); + //gPrivateFuncs.PropertySheet_HasHotkey = (decltype(gPrivateFuncs.PropertySheet_HasHotkey))((PUCHAR)GameUIBase + 0x53060); + //gPrivateFuncs.FocusNavGroup_GetCurrentFocus = (decltype(gPrivateFuncs.FocusNavGroup_GetCurrentFocus))((PUCHAR)GameUIBase + 0x4D640); +} + +HMODULE GetGameUIModule(); + +void GameUI_InstallHooks(void) +{ + auto hGameUI = GetGameUIModule(); + + if (!hGameUI) + { + g_pMetaHookAPI->SysError("Failed to get GameUI.dll "); + return; + } + + CreateInterfaceFn GameUICreateInterface = Sys_GetFactory((HINTERFACEMODULE)hGameUI); + + if (!GameUICreateInterface) + { + g_pMetaHookAPI->SysError("Failed to get interface factory from GameUI.dll"); + return; + } + + g_pGameUI = (IGameUI*)GameUICreateInterface(GAMEUI_INTERFACE_VERSION, 0); + + if (!g_pGameUI) + { + g_pMetaHookAPI->SysError("Failed to get interface \"" GAMEUI_INTERFACE_VERSION "\" from GameUI.dll"); + return; + } + DWORD *pVFTable = *(DWORD **)&s_GameUI; g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 1, (void *)pVFTable[1], (void **)&g_pfnCGameUI_Initialize); g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 2, (void *)pVFTable[2], (void **)&g_pfnCGameUI_Start); g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 4, (void *)pVFTable[4], (void **)&g_pfnCGameUI_ActivateGameUI); g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 8, (void*)pVFTable[8], (void**)&g_pfnCGameUI_ConnectToServer); - g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 10, (void *)pVFTable[10], (void **)&g_pfnCGameUI_HideGameUI); + //g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 10, (void *)pVFTable[10], (void **)&g_pfnCGameUI_HideGameUI); //Install_InlineHook(QueryBox_ctor); Install_InlineHook(GameUI_Panel_Init); Install_InlineHook(CGameConsoleDialog_ctor); Install_InlineHook(CCreateMultiplayerGameDialog_ctor); Install_InlineHook(COptionsDialog_ctor); - Install_InlineHook(COptionsSubVideo_ctor); Install_InlineHook(COptionsSubVideo_ApplyVidSettings); - Install_InlineHook(COptionsSubAudio_ctor); if(gPrivateFuncs.RichText_InsertChar) Install_InlineHook(RichText_InsertChar); @@ -1638,6 +1692,8 @@ void GameUI_InstallHooks(void) Install_InlineHook(TextEntry_OnKeyCodeTyped); Install_InlineHook(TextEntry_LayoutVerticalScrollBarSlider); Install_InlineHook(TextEntry_GetStartDrawIndex); + + //Install_InlineHook(PropertySheet_HasHotkey); } void GameUI_UninstallHooks(void) @@ -1647,13 +1703,16 @@ void GameUI_UninstallHooks(void) Uninstall_Hook(CGameConsoleDialog_ctor); Uninstall_Hook(CCreateMultiplayerGameDialog_ctor); Uninstall_Hook(COptionsDialog_ctor); - Uninstall_Hook(COptionsSubVideo_ctor); + //Uninstall_Hook(COptionsSubVideo_ctor); Uninstall_Hook(COptionsSubVideo_ApplyVidSettings); - Uninstall_Hook(COptionsSubAudio_ctor); + //Uninstall_Hook(COptionsSubAudio_ctor); Uninstall_Hook(RichText_InsertChar); Uninstall_Hook(RichText_InsertStringW); Uninstall_Hook(RichText_OnThink); Uninstall_Hook(TextEntry_OnKeyCodeTyped); Uninstall_Hook(TextEntry_LayoutVerticalScrollBarSlider); Uninstall_Hook(TextEntry_GetStartDrawIndex); + + Uninstall_Hook(PropertySheet_HasHotkey); + Uninstall_Hook(FocusNavGroup_GetCurrentFocus); } \ No newline at end of file diff --git a/Plugins/CaptionMod/SubtitlePanel.cpp b/Plugins/CaptionMod/SubtitlePanel.cpp index a66b1ee1..b7f925ef 100644 --- a/Plugins/CaptionMod/SubtitlePanel.cpp +++ b/Plugins/CaptionMod/SubtitlePanel.cpp @@ -11,20 +11,31 @@ #include "SubtitlePanel.h" #include "privatefuncs.h" -extern client_textmessage_t *g_pCurrentTextMessage; +client_textmessage_t* GetCurrentTextMessage(); + +extern cvar_t* cap_subtitle_prefix; +extern cvar_t* cap_subtitle_waitplay; +extern cvar_t* cap_subtitle_antispam; +extern cvar_t* cap_subtitle_fadein; +extern cvar_t* cap_subtitle_fadeout; +extern cvar_t* cap_subtitle_holdtime; +extern cvar_t* cap_subtitle_stimescale; +extern cvar_t* cap_subtitle_htimescale; using namespace vgui; SubtitlePanel::SubtitlePanel(Panel *parent) : EditablePanel(parent, "Subtitle") { m_bInLevel = false; - m_flFadeIn = 0; - m_flFadeOut = 0; - m_flHoldTime = 0; - m_flHoldTimeScale = 0; - m_flStartTimeScale = 0; + //m_flFadeIn = 0; + //m_flFadeOut = 0; + //m_flHoldTime = 0; + //m_flHoldTimeScale = 0; + //m_flStartTimeScale = 0; + //m_iAntiSpam = 0; + //m_iPrefix = 0; + //m_iWaitPlay = 0; m_hTextFont = NULL; - m_iAntiSpam = 0; m_iCornorSize = 0; m_flCurPanelY = 0; m_flCurPanelYEnd = 0; @@ -35,7 +46,6 @@ SubtitlePanel::SubtitlePanel(Panel *parent) : EditablePanel(parent, "Subtitle") m_iPanelTop = 0; m_iPanelY = 0; m_iPanelYEnd = 0; - m_iPrefix = 0; m_iRoundCornorMaterial[0] = 0; m_iRoundCornorMaterial[1] = 0; m_iRoundCornorMaterial[2] = 0; @@ -45,7 +55,6 @@ SubtitlePanel::SubtitlePanel(Panel *parent) : EditablePanel(parent, "Subtitle") m_iScaledXSpace = 0; m_iScaledYSpace = 0; m_iTextAlign = ALIGN_DEFAULT; - m_iWaitPlay = 0; m_iXSpace = 0; m_iYSpace = 0; m_szTextAlign[0] = 0; @@ -55,7 +64,7 @@ SubtitlePanel::SubtitlePanel(Panel *parent) : EditablePanel(parent, "Subtitle") SetPaintBorderEnabled(false); SetProportional(true); - SetScheme("CaptionScheme"); + SetScheme2("CaptionScheme"); LoadControlSettings("captionmod/SubtitlePanel.res"); @@ -353,7 +362,7 @@ void SubtitlePanel::StartLine(CSubLine *Line) CSubLine *Temp = m_Lines[i]; //Move all existing lines up Temp->m_LineIndex ++; - Temp->MoveTo(Temp->CalcYPos(), m_flFadeIn); + Temp->MoveTo(Temp->CalcYPos(), cap_subtitle_fadein->value); if(m_Lines[i]->m_EndTime > latestEndTime) latestEndTime = m_Lines[i]->m_EndTime; @@ -371,7 +380,7 @@ void SubtitlePanel::StartLine(CSubLine *Line) Line->m_EndTime = max(Line->m_StartTime + Line->m_Duration, latestEndTime); //Fade it now - Line->AlphaFade(255, m_flFadeIn); + Line->AlphaFade(255, cap_subtitle_fadein->value); StartNextSubtitle(Line->m_Dict); } @@ -389,15 +398,15 @@ void SubtitlePanel::AddLine(CDictionary *Dict, wchar_t *wszSentence, int nLength Line->m_Duration = flDuration; Line->m_Color = Dict->m_Color; - if (Dict->m_bDefaultColor && g_pCurrentTextMessage) + if (Dict->m_bDefaultColor && GetCurrentTextMessage()) { - Line->m_Color = Color(g_pCurrentTextMessage->r1, g_pCurrentTextMessage->g1, g_pCurrentTextMessage->b1, g_pCurrentTextMessage->a1); + Line->m_Color = Color(GetCurrentTextMessage()->r1, GetCurrentTextMessage()->g1, GetCurrentTextMessage()->b1, GetCurrentTextMessage()->a1); } Line->m_Alpha = 0; Line->m_LineIndex = 0; Line->m_YPos = Line->CalcYPos(); - Line->m_FadeOut = m_flFadeOut; + Line->m_FadeOut = cap_subtitle_fadeout->value; Line->m_TextAlign = Dict->m_iTextAlign ? Dict->m_iTextAlign : m_iTextAlign; } @@ -413,7 +422,7 @@ void SubtitlePanel::StartSubtitle(CDictionary * pDict, float flDurationTime, flo float flLatestStart = 0; for(int i = 0; i < m_BackLines.Count(); ++i) { - if (m_iWaitPlay) + if (cap_subtitle_waitplay->value >= 1.0f) { m_BackLines[i]->m_StartTime = 0; } @@ -428,7 +437,7 @@ void SubtitlePanel::StartSubtitle(CDictionary * pDict, float flDurationTime, flo return; } - if (m_iAntiSpam) + if (cap_subtitle_antispam->value >= 1.0f) { for (int i = 0; i < m_Lines.Count(); ++i) { @@ -440,7 +449,7 @@ void SubtitlePanel::StartSubtitle(CDictionary * pDict, float flDurationTime, flo std::wstring sentence; - pDict->FinalizeString(sentence, m_iPrefix); + pDict->FinalizeString(sentence, (cap_subtitle_prefix->value >= 1.0f) ? true : false); int iPanelWidth = GetWide(); int iMaxTextWidth = iPanelWidth - (m_iScaledXSpace << 1); @@ -475,25 +484,25 @@ void SubtitlePanel::StartSubtitle(CDictionary * pDict, float flDurationTime, flo //Fallback to m_flHoldTime if(flDuration <= 0) - flDuration = m_flHoldTime; + flDuration = cap_subtitle_holdtime->value; if(flDuration <= 0) flDuration = 4.0f; - if (!pDict->m_bOverrideDuration && g_pCurrentTextMessage) + if (!pDict->m_bOverrideDuration && GetCurrentTextMessage()) { - if (g_pCurrentTextMessage->effect == 2 && g_pCurrentTextMessage->pMessage) + if (GetCurrentTextMessage()->effect == 2 && GetCurrentTextMessage()->pMessage) { - flDuration = (g_pCurrentTextMessage->fadein * sentence.length() ) + g_pCurrentTextMessage->fadeout + g_pCurrentTextMessage->holdtime; + flDuration = (GetCurrentTextMessage()->fadein * sentence.length() ) + GetCurrentTextMessage()->fadeout + GetCurrentTextMessage()->holdtime; } else { - flDuration = g_pCurrentTextMessage->holdtime + g_pCurrentTextMessage->fadein + g_pCurrentTextMessage->fadeout; + flDuration = GetCurrentTextMessage()->holdtime + GetCurrentTextMessage()->fadein + GetCurrentTextMessage()->fadeout; } } - if(m_flHoldTimeScale > 0) - flDuration *= m_flHoldTimeScale; + if(cap_subtitle_htimescale->value > 0) + flDuration *= cap_subtitle_htimescale->value; p = pStart; @@ -565,13 +574,13 @@ void SubtitlePanel::StartSubtitle(CDictionary * pDict, float flDurationTime, flo float flCalcStartTime = flPercentStart * flDuration; float flRealStartTime; - if(m_flStartTimeScale <= 0) + if(cap_subtitle_stimescale->value <= 0) flRealStartTime = flStartTime; else - flRealStartTime = flStartTime + flCalcStartTime * m_flStartTimeScale; + flRealStartTime = flStartTime + flCalcStartTime * cap_subtitle_stimescale->value; //Shall we wait for the latest backlines played? - if(m_iWaitPlay) + if(cap_subtitle_waitplay->value >= 1.0f) flRealStartTime = max(flRealStartTime, flLatestStart); //Calculate the Duration @@ -579,7 +588,7 @@ void SubtitlePanel::StartSubtitle(CDictionary * pDict, float flDurationTime, flo float flRealDuration; //Longer start time won't change the duration - if(m_flStartTimeScale >= 1) + if(cap_subtitle_stimescale->value >= 1) flRealDuration = flCalcDuration; else//real duration = original starttime - real starttime + original duration flRealDuration = max(flStartTime + flCalcStartTime - flRealStartTime, 0) + flCalcDuration; @@ -604,6 +613,7 @@ void SubtitlePanel::ClearSubtitle(void) m_BackLines.RemoveAll(); } +#if 0 void SubtitlePanel::QuerySubtitlePanelVars(SubtitlePanelVars_t *vars) { GetSize(vars->m_iWidth, vars->m_iHeight); @@ -639,6 +649,7 @@ void SubtitlePanel::UpdateSubtitlePanelVars(SubtitlePanelVars_t *vars) m_iPrefix = vars->m_iPrefix; m_iWaitPlay = vars->m_iWaitPlay; } +#endif void SubtitlePanel::VidInit(void) { diff --git a/Plugins/CaptionMod/SubtitlePanel.h b/Plugins/CaptionMod/SubtitlePanel.h index 7f57fc0f..06fd364e 100644 --- a/Plugins/CaptionMod/SubtitlePanel.h +++ b/Plugins/CaptionMod/SubtitlePanel.h @@ -30,6 +30,10 @@ class CSubLineAnim m_AnimTime = AnimTime; m_Line = Line; m_Started = false; + } + virtual ~CSubLineAnim() + { + } virtual bool IsPlaying(void) { @@ -41,6 +45,7 @@ class CSubLineAnim } virtual LineAnim_t GetType(void) = 0; virtual bool Update(void) = 0; + protected: float m_StartTime; float m_AnimTime; @@ -84,6 +89,7 @@ class CSubLine m_Length = 0; m_Duration = 0; m_StartTime = 0; + m_EndTime = 0; m_Alpha = 0; m_YPos = 0; m_LineIndex = 0; @@ -94,6 +100,10 @@ class CSubLine m_TextWide = 0; m_TextAlign = ALIGN_DEFAULT; } + virtual ~CSubLine() + { + + } void Draw(int x, int w, int align); bool Update(void); @@ -115,7 +125,7 @@ class CSubLine int m_LineIndex;//Line number, 0 means the bottom bool m_Retired;//Should this line be retired? float m_FadeOut;//Fadeout duration - CUtlVector m_AnimList;//Animation list + CUtlVector m_AnimList;//Animation list SubtitlePanel *m_Panel;//Subtitle panel CDictionary *m_Dict;//Linked dictionary int m_TextWide; @@ -139,8 +149,10 @@ class SubtitlePanel : public vgui::EditablePanel void AddLine(CDictionary *Dict, wchar_t *wszSentence, int nLength, float flStartTime, float flDuration, int nTextLength); void StartLine(CSubLine *Line); void ClearSubtitle(void); +#if 0 void QuerySubtitlePanelVars(SubtitlePanelVars_t *vars); void UpdateSubtitlePanelVars(SubtitlePanelVars_t *vars); +#endif protected: virtual void ApplySchemeSettings(vgui::IScheme *pScheme); virtual void PaintBackground(void); @@ -154,14 +166,14 @@ class SubtitlePanel : public vgui::EditablePanel CPanelAnimationVar( int, m_iYSpace, "yspace", "8" ); CPanelAnimationVar( int, m_iLineSpace, "linespace", "8" ); CPanelAnimationVar( Color, m_PanelColor, "panelcolor", "SubtitleBG" ); - CPanelAnimationVar( float, m_flFadeIn, "fadein", "0.5" ); - CPanelAnimationVar( float, m_flFadeOut, "fadeout", "0.8" ); - CPanelAnimationVar( float, m_flHoldTime, "holdtime", "4.0" ); - CPanelAnimationVar( int, m_iPrefix, "prefix", "1" ); - CPanelAnimationVar( int, m_iWaitPlay, "waitplay", "1" ); - CPanelAnimationVar(int, m_iAntiSpam, "antispam", "1"); - CPanelAnimationVar( float, m_flStartTimeScale, "stimescale", "1" ); - CPanelAnimationVar( float, m_flHoldTimeScale, "htimescale", "1" ); + //CPanelAnimationVar( float, m_flFadeIn, "fadein", "0.5" ); + //CPanelAnimationVar( float, m_flFadeOut, "fadeout", "0.8" ); + //CPanelAnimationVar( float, m_flHoldTime, "holdtime", "4.0" ); + //CPanelAnimationVar( int, m_iPrefix, "prefix", "1" ); + //CPanelAnimationVar( int, m_iWaitPlay, "waitplay", "1" ); + //CPanelAnimationVar(int, m_iAntiSpam, "antispam", "1"); + //CPanelAnimationVar( float, m_flStartTimeScale, "stimescale", "1" ); + //CPanelAnimationVar( float, m_flHoldTimeScale, "htimescale", "1" ); public: //Some attributes diff --git a/Plugins/CaptionMod/Viewport.cpp b/Plugins/CaptionMod/Viewport.cpp index 5a3e5c03..ff2151c2 100644 --- a/Plugins/CaptionMod/Viewport.cpp +++ b/Plugins/CaptionMod/Viewport.cpp @@ -26,14 +26,14 @@ CMemoryPool m_HashItemMemPool(sizeof(hash_item_t), 64); extern CHudMessage m_HudMessage; extern CHudMenu m_HudMenu; -CViewport::CViewport(void) : Panel(NULL, "CaptionViewport") +CViewport::CViewport() : BaseClass(NULL, "CaptionViewport") { int swide, stall; surface()->GetScreenSize(swide, stall); MakePopup(false, true); - SetScheme("CaptionScheme"); + SetScheme2("CaptionScheme"); SetBounds(0, 0, swide, stall); SetPaintBorderEnabled(false); SetPaintBackgroundEnabled(false); @@ -757,7 +757,7 @@ void CViewport::LoadBaseDictionary(void) gEngfuncs.Con_Printf("LoadBaseDictionary: %d lines are loaded.\n", nRowCount - 1); } -extern char *m_pSenderName; +const char* GetSenderName(); //KeyBinding Name(jump) -> Key Name(SPACE) const char *PrimaryKey_ForBinding(const char *binding) @@ -765,9 +765,9 @@ const char *PrimaryKey_ForBinding(const char *binding) if(binding[0] == '+') binding ++; - if (!strcmp(binding, "sender") && m_pSenderName) + if (!strcmp(binding, "sender") && GetSenderName()) { - return m_pSenderName; + return GetSenderName(); } for (int i = 255; i >= 0; --i) @@ -791,7 +791,7 @@ const char *PrimaryKey_ForBinding(const char *binding) return ""; } -void CDictionary::FinalizeString(std::wstring &output, int iPrefix) +void CDictionary::FinalizeString(std::wstring &output, bool bPrefix) { auto finalize = m_szSentence; @@ -841,7 +841,7 @@ void CDictionary::FinalizeString(std::wstring &output, int iPrefix) searchStart = result.suffix().first; } - if(iPrefix) + if(bPrefix) output = m_szSpeaker + finalize; else output = finalize; @@ -850,7 +850,7 @@ void CDictionary::FinalizeString(std::wstring &output, int iPrefix) void CViewport::Start(void) { m_pSubtitlePanel = new SubtitlePanel(this); - m_pChatDialog = new CCSChatDialog(this); + m_pChatDialog = new CCSChatDialog(this, PANEL_CHAT); SetVisible(false); } @@ -1017,6 +1017,7 @@ void CViewport::ChatPrintf(int iPlayerIndex, const wchar_t *buffer) m_pChatDialog->ChatPrintf(iPlayerIndex, buffer); } +#if 0 void CViewport::QuerySubtitlePanelVars(SubtitlePanelVars_t *vars) { m_pSubtitlePanel->QuerySubtitlePanelVars(vars); @@ -1025,4 +1026,5 @@ void CViewport::QuerySubtitlePanelVars(SubtitlePanelVars_t *vars) void CViewport::UpdateSubtitlePanelVars(SubtitlePanelVars_t *vars) { m_pSubtitlePanel->UpdateSubtitlePanelVars(vars); -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Plugins/CaptionMod/Viewport.h b/Plugins/CaptionMod/Viewport.h index 90f8083e..f1da0345 100644 --- a/Plugins/CaptionMod/Viewport.h +++ b/Plugins/CaptionMod/Viewport.h @@ -64,7 +64,7 @@ class CDictionary virtual ~CDictionary(); void Load(CSV::CSVDocument::row_type &row, Color &defaultColor, vgui::IScheme *ischeme); - void FinalizeString(std::wstring &output, int iPrefix); + void FinalizeString(std::wstring &output, bool iPrefix); dict_t m_Type; std::string m_szTitle; @@ -102,7 +102,7 @@ class CViewport : public vgui::Panel DECLARE_CLASS_SIMPLE(CViewport, vgui::Panel); public: - CViewport(void); + CViewport(); virtual ~CViewport(void); public: diff --git a/Plugins/CaptionMod/chatdialog.cpp b/Plugins/CaptionMod/chatdialog.cpp index 472ace6a..47bb8fc8 100644 --- a/Plugins/CaptionMod/chatdialog.cpp +++ b/Plugins/CaptionMod/chatdialog.cpp @@ -253,7 +253,7 @@ void CChatDialogHistory::Paint(void) int CChatDialog::m_nLineCounter = 1; -CChatDialog::CChatDialog(Panel *parent) : BaseClass(parent, PANEL_CHAT) +CChatDialog::CChatDialog(Panel *parent, const char* panelName) : BaseClass(parent, panelName) { m_PreviousAppModal = NULL; MakePopup(false, false); @@ -553,12 +553,6 @@ void CChatDialog::StartMessageMode(int iMessageModeType) void CChatDialog::StopMessageMode(void) { - /*if (m_PreviousAppModal) - { - input()->SetAppModalSurface(m_PreviousAppModal); - m_PreviousAppModal = NULL; - }*/ - m_nMessageMode = MM_NONE; SetKeyBoardInputEnabled(false); diff --git a/Plugins/CaptionMod/chatdialog.h b/Plugins/CaptionMod/chatdialog.h index 9b000b40..6c03e147 100644 --- a/Plugins/CaptionMod/chatdialog.h +++ b/Plugins/CaptionMod/chatdialog.h @@ -38,7 +38,7 @@ class CChatDialogLine : public vgui::RichText typedef vgui::RichText BaseClass; public: - CChatDialogLine(vgui::Panel *parent, const char *panelNam); + CChatDialogLine(vgui::Panel *parent, const char *panelName); ~CChatDialogLine(void); public: @@ -117,7 +117,7 @@ class CChatDialog : public vgui::Frame }; public: - CChatDialog(Panel *parent); + CChatDialog(Panel *parent, const char* panelName); public: virtual void CreateChatInputLine(void); diff --git a/Plugins/CaptionMod/cstrikechatdialog.cpp b/Plugins/CaptionMod/cstrikechatdialog.cpp index 68a67f8c..c0a4bde3 100644 --- a/Plugins/CaptionMod/cstrikechatdialog.cpp +++ b/Plugins/CaptionMod/cstrikechatdialog.cpp @@ -8,7 +8,7 @@ extern IGameUI *g_pGameUI; using namespace vgui; -CCSChatDialog::CCSChatDialog(Panel *parent) : BaseClass(parent) +CCSChatDialog::CCSChatDialog(Panel *parent, const char* panelName) : BaseClass(parent, panelName) { SetProportional(true); SetSizeable(false); diff --git a/Plugins/CaptionMod/cstrikechatdialog.h b/Plugins/CaptionMod/cstrikechatdialog.h index d1f20b77..214dc04f 100644 --- a/Plugins/CaptionMod/cstrikechatdialog.h +++ b/Plugins/CaptionMod/cstrikechatdialog.h @@ -12,7 +12,7 @@ class CCSChatDialog : public CChatDialog DECLARE_CLASS_SIMPLE(CCSChatDialog, CChatDialog); public: - CCSChatDialog(Panel *parent); + CCSChatDialog(Panel *parent, const char* panelName); public: virtual void CreateChatInputLine(void); diff --git a/Plugins/CaptionMod/exportfuncs.cpp b/Plugins/CaptionMod/exportfuncs.cpp index de9cb148..4e1e08b3 100644 --- a/Plugins/CaptionMod/exportfuncs.cpp +++ b/Plugins/CaptionMod/exportfuncs.cpp @@ -41,6 +41,27 @@ void *gHud = NULL; HWND g_MainWnd = NULL; WNDPROC g_MainWndProc = NULL; +cvar_t* cap_subtitle_prefix = NULL; +cvar_t* cap_subtitle_waitplay = NULL; +cvar_t* cap_subtitle_antispam = NULL; +cvar_t* cap_subtitle_fadein = NULL; +cvar_t* cap_subtitle_fadeout = NULL; +cvar_t* cap_subtitle_holdtime = NULL; +cvar_t* cap_subtitle_stimescale = NULL; +cvar_t* cap_subtitle_htimescale = NULL; + +void Cap_RegisterSubtitleCvars() +{ + cap_subtitle_prefix = gEngfuncs.pfnRegisterVariable("cap_subtitle_prefix", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); + cap_subtitle_waitplay = gEngfuncs.pfnRegisterVariable("cap_subtitle_waitplay", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); + cap_subtitle_antispam = gEngfuncs.pfnRegisterVariable("cap_subtitle_antispam", "1", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); + cap_subtitle_fadein = gEngfuncs.pfnRegisterVariable("cap_subtitle_fadein", "0.3", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); + cap_subtitle_fadeout = gEngfuncs.pfnRegisterVariable("cap_subtitle_fadeout", "0.3", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); + cap_subtitle_holdtime = gEngfuncs.pfnRegisterVariable("cap_subtitle_holdtime", "10.0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); + cap_subtitle_stimescale = gEngfuncs.pfnRegisterVariable("cap_subtitle_stimescale", "1.0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); + cap_subtitle_htimescale = gEngfuncs.pfnRegisterVariable("cap_subtitle_htimescale", "1.0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE); +} + cl_entity_t* EngineGetViewEntity(void) { return gEngfuncs.GetEntityByIndex((*cl_viewentity)); @@ -249,6 +270,8 @@ void HUD_Init(void) { gExportfuncs.HUD_Init(); + Cap_RegisterSubtitleCvars(); + if(g_pViewPort) g_pViewPort->Init(); diff --git a/Plugins/CaptionMod/message.cpp b/Plugins/CaptionMod/message.cpp index 92855aa7..bd2f2a00 100644 --- a/Plugins/CaptionMod/message.cpp +++ b/Plugins/CaptionMod/message.cpp @@ -16,9 +16,19 @@ extern cvar_t *hud_saytext; extern cvar_t *hud_saytext_time; extern cvar_t *cap_newchat; -char *m_pSenderName = NULL; +static char *m_pSenderName = NULL; -client_textmessage_t *g_pCurrentTextMessage = NULL; +static client_textmessage_t *g_pCurrentTextMessage = NULL; + +const char *GetSenderName() +{ + return m_pSenderName; +} + +client_textmessage_t* GetCurrentTextMessage() +{ + return g_pCurrentTextMessage; +} CHudMessage m_HudMessage; CHudMenu m_HudMenu; diff --git a/Plugins/CaptionMod/plugins.cpp b/Plugins/CaptionMod/plugins.cpp index fc35af0f..7c0917f0 100644 --- a/Plugins/CaptionMod/plugins.cpp +++ b/Plugins/CaptionMod/plugins.cpp @@ -35,6 +35,16 @@ bool g_bIsCounterStrike = false; extern IFileSystem* g_pFullFileSystem; extern IFileSystem_HL25* g_pFullFileSystem_HL25; +#if 0 +PVOID g_dwCurrentModuleBase = NULL; +DWORD g_dwCurrentModuleSize = 0; + +bool IsFromCurrentModule(void *addr) +{ + return addr >= g_dwCurrentModuleBase && addr < (PUCHAR)g_dwCurrentModuleBase + g_dwCurrentModuleSize; +} +#endif + ICommandLine *CommandLine(void) { return g_pInterface->CommandLine; @@ -45,6 +55,10 @@ void IPluginsV4::Init(metahook_api_t *pAPI, mh_interface_t *pInterface, mh_engin g_pInterface = pInterface; g_pMetaHookAPI = pAPI; g_pMetaSave = pSave; +#if 0 + g_dwCurrentModuleBase = g_pMetaHookAPI->GetModuleBase(IsFromCurrentModule); + g_dwCurrentModuleSize = g_pMetaHookAPI->GetModuleSize(g_dwCurrentModuleBase); +#endif } void IPluginsV4::Shutdown(void) diff --git a/Plugins/CaptionMod/plugins.h b/Plugins/CaptionMod/plugins.h index d95e5945..667984db 100644 --- a/Plugins/CaptionMod/plugins.h +++ b/Plugins/CaptionMod/plugins.h @@ -26,7 +26,7 @@ extern bool g_bIsSvenCoop; extern bool g_bIsCounterStrike; #define GetCallAddress(addr) g_pMetaHookAPI->GetNextCallAddr((PUCHAR)addr, 1) -#define Sig_NotFound(name) g_pMetaHookAPI->SysError("Could not found: %s\nEngine buildnum: %d", #name, g_dwEngineBuildnum); +#define Sig_NotFound(name) g_pMetaHookAPI->SysError("[CaptionMod] Could not found: %s\nEngine buildnum: %d", #name, g_dwEngineBuildnum); #define Sig_VarNotFound(name) if(!name) Sig_NotFound(name) #define Sig_AddrNotFound(name) if(!addr) Sig_NotFound(name) #define Sig_FuncNotFound(name) if(!gPrivateFuncs.name) Sig_NotFound(name) diff --git a/Plugins/CaptionMod/privatefuncs.cpp b/Plugins/CaptionMod/privatefuncs.cpp index 91ae6e3f..bf36b8ca 100644 --- a/Plugins/CaptionMod/privatefuncs.cpp +++ b/Plugins/CaptionMod/privatefuncs.cpp @@ -76,6 +76,12 @@ static hook_t *g_phook_FMOD_System_playSound = NULL; //static hook_t *g_phook_FileSystem_SetGameDirectory = NULL; static HMODULE g_hFMODEx = NULL; +static HMODULE g_hGameUI = NULL; + +HMODULE GetGameUIModule() +{ + return g_hGameUI; +} void FMOD_InstallHooks(HMODULE fmodex) { @@ -1747,6 +1753,11 @@ void DllLoadNotification(mh_load_dll_notification_context_t* ctx) g_hFMODEx = ctx->hModule; FMOD_InstallHooks(ctx->hModule); } + else if (ctx->BaseDllName && ctx->hModule && !_wcsicmp(ctx->BaseDllName, L"GameUI.dll")) + { + g_hGameUI = ctx->hModule; + GameUI_FillAddress(ctx->hModule); + } } else if (ctx->flags & LOAD_DLL_NOTIFICATION_IS_UNLOAD) { @@ -1755,5 +1766,10 @@ void DllLoadNotification(mh_load_dll_notification_context_t* ctx) FMOD_UninstallHooks(ctx->hModule); g_hFMODEx = NULL; } + else if (ctx->hModule == g_hFMODEx) + { + GameUI_UninstallHooks(); + g_hGameUI = NULL; + } } } diff --git a/Plugins/CaptionMod/privatefuncs.h b/Plugins/CaptionMod/privatefuncs.h index 07ea00b5..cd9696e0 100644 --- a/Plugins/CaptionMod/privatefuncs.h +++ b/Plugins/CaptionMod/privatefuncs.h @@ -89,15 +89,18 @@ typedef struct //GameUI void(__fastcall* GameUI_Panel_Init)(void* pthis, int dummy, int x, int y, int w, int h); void(__fastcall* GameUI_LoadControlSettings)(void* pthis, int dummy, const char* controlResourceName, const char* pathID); - void * (__fastcall* QueryBox_ctor)(void* pthis, int dummy, const char* title, const char* queryText, void* parent); - void* (__fastcall* CCreateMultiplayerGameDialog_ctor)(void* pthis, int dummy, void* parent); - void* (__fastcall* CGameConsoleDialog_ctor)(void* pthis, int dummy); + void *(__fastcall* Sheet_ctor)(void* pthis, int dummy, void* parent, const char *panelName); + //void *(__fastcall* QueryBox_ctor)(void* pthis, int dummy, const char* title, const char* queryText, void* parent); + void *(__fastcall* CCreateMultiplayerGameDialog_ctor)(void* pthis, int dummy, void* parent); + void *(__fastcall* CGameConsoleDialog_ctor)(void* pthis, int dummy); void *(__fastcall*COptionsDialog_ctor)(void *pthis, int dummy, void *parent); void *(__fastcall*COptionsSubVideo_ctor)(void *pthis, int dummy, void *parent); + void *(__fastcall*COptionsSubAudio_ctor)(void *pthis, int dummy, void *parent); void(__fastcall *COptionsSubVideo_ApplyVidSettings)(void *pthis, int dummy, bool bForceRestart); void(__fastcall *COptionsSubVideo_ApplyVidSettings_HL25)(void *pthis, int dummy); - void *(__fastcall*COptionsSubAudio_ctor)(void *pthis, int dummy, void *parent); //void *(__fastcall *COptionsDialog_AddPage)(void *pthis, int dummy, void *panel, const char *name); + void* (__fastcall *PropertySheet_HasHotkey)(void* pthis, int dummy, wchar_t key); + void* (__fastcall *FocusNavGroup_GetCurrentFocus)(void* pthis, int dummy); void(__fastcall* RichText_Print)(void* pthis, int dummy, const char* msg); void (__fastcall* RichText_InsertStringA)(void* pthis, int dummy, const char* msg); @@ -155,6 +158,7 @@ void Engine_InstallHooks(void); void Engine_UninstallHooks(void); void BaseUI_InstallHook(void); void BaseUI_UninstallHook(void); +void GameUI_FillAddress(HMODULE hModule); void GameUI_InstallHooks(void); void GameUI_UninstallHooks(void); void ClientVGUI_InstallHook(cl_exportfuncs_t* pExportFunc); diff --git a/include/vgui_controls/Controls.cpp b/include/vgui_controls/Controls.cpp index 2aee9a81..2f57e1fe 100644 --- a/include/vgui_controls/Controls.cpp +++ b/include/vgui_controls/Controls.cpp @@ -29,20 +29,9 @@ IEngineSurface_HL25 *staticSurface_HL25 = NULL; namespace vgui { static char g_szControlsModuleName[256] = {0}; -const char *g_pszOverrideControlsModuleName = NULL; bool (__fastcall *g_pfnCWin32Input_PostKeyMessage)(void *pthis, int, KeyValues *message); -void SetOverrideControlsModuleName(const char *pszNewName) -{ - g_pszOverrideControlsModuleName = pszNewName; -} - -const char* GetOverrideControlsModuleName() -{ - return g_pszOverrideControlsModuleName; -} - const char* GetControlsModuleName(void) { return g_szControlsModuleName; diff --git a/include/vgui_controls/Panel.cpp b/include/vgui_controls/Panel.cpp index f1617238..4423c077 100644 --- a/include/vgui_controls/Panel.cpp +++ b/include/vgui_controls/Panel.cpp @@ -649,7 +649,6 @@ void Panel::Init( int x, int y, int wide, int tall ) _tabPosition = 0; m_iScheme = 0; m_bIsSilent = false; - m_pszOverrideModuleName = vgui::GetOverrideControlsModuleName(); _buildModeFlags = 0; // not editable or deletable in buildmode dialog by default @@ -776,11 +775,6 @@ const char *Panel::GetName() //----------------------------------------------------------------------------- const char *Panel::GetModuleName() { - if (GetOverrideModuleName()) - { - return GetOverrideModuleName(); - } - return vgui::GetControlsModuleName(); } @@ -6125,31 +6119,6 @@ void Panel::GetDragData( CUtlVector< KeyValues * >& list ) #endif } -const char* Panel::GetOverrideModuleName() const -{ - return m_pszOverrideModuleName; -} - -void Panel::SetOverrideModuleName(const char* pszModuleName) -{ - m_pszOverrideModuleName = pszModuleName; -} - -void Panel::RecursiveSetOverrideModuleName(const char* pszModuleName, const char* pszPreviousModuleName) -{ - SetOverrideModuleName(pszModuleName); - - for (int i = 0; i < GetChildCount(); ++i) - { - auto pChild = GetChildWithModuleName(i, pszPreviousModuleName); - - if (pChild) - { - pChild->RecursiveSetOverrideModuleName(pszModuleName, pszPreviousModuleName); - } - } -} - #if defined( VGUI_USEDRAGDROP ) CDragDropHelperPanel::CDragDropHelperPanel() : BaseClass( NULL, "DragDropHelper" ) { diff --git a/include/vgui_controls/Panel.h b/include/vgui_controls/Panel.h index ba7a12b4..59a92c66 100644 --- a/include/vgui_controls/Panel.h +++ b/include/vgui_controls/Panel.h @@ -549,10 +549,6 @@ class Panel : public IClientPanel virtual void GetDragData( CUtlVector< KeyValues * >& list ); virtual void CreateDragData(); - virtual const char *GetOverrideModuleName() const; - virtual void SetOverrideModuleName(const char *pszModuleName); - virtual void RecursiveSetOverrideModuleName(const char* pszModuleName, const char* pszPreviousModuleName); - protected: MESSAGE_FUNC_ENUM_ENUM( OnRequestFocus, "OnRequestFocus", VPANEL, subFocus, VPANEL, defaultPanel); MESSAGE_FUNC_INT_INT( OnScreenSizeChanged, "OnScreenSizeChanged", oldwide, oldtall ); @@ -690,8 +686,6 @@ class Panel : public IClientPanel bool m_bIsSilent; // should this panel PostActionSignals? - const char* m_pszOverrideModuleName; - CPanelAnimationVar( float, m_flAlpha, "alpha", "255" ); // 1 == Textured (TextureId1 only)