From 8f8a93e88f40935e7efa2fd339e59f366d01d95c Mon Sep 17 00:00:00 2001 From: Nick K Date: Mon, 20 Jun 2016 00:48:30 -0400 Subject: [PATCH 01/10] Changelog added to versionwarning panel Converted clientevents to AutoGameSystem Refactored some things to be better Made some fonts look better (needs work) Fixed ghost errors (there were multiple) Fixed player tweening --- changelog.txt | 31 +++ mp/game/momentum/resource/SourceScheme.res | 9 +- mp/game/momentum/resource/gameui_english.txt | Bin 718 -> 900 bytes .../momentum/resource/ui/versionwarnpanel.res | 201 +++++++++++------- mp/game/momentum/scripts/HudLayout.res | 4 +- mp/src/game/client/cdll_client_int.cpp | 6 - mp/src/game/client/client_momentum.vpc | 2 +- mp/src/game/client/momentum/client_events.cpp | 95 +++++---- mp/src/game/client/momentum/client_events.h | 16 +- .../client/momentum/ui/IVersionWarnPanel.h | 3 + .../client/momentum/ui/VersionWarnPanel.cpp | 131 +++--------- .../client/momentum/ui/VersionWarnPanel.h | 105 +++++++++ ...ud_versionwarn.cpp => hud_versioninfo.cpp} | 16 +- mp/src/game/server/gameinterface.cpp | 3 - mp/src/game/server/momentum/mom_player.cpp | 19 +- mp/src/game/server/momentum/mom_player.h | 2 +- .../server/momentum/mom_replay_entity.cpp | 26 ++- .../server/momentum/mom_replay_manager.cpp | 6 +- .../game/server/momentum/mom_replay_manager.h | 2 +- .../server/momentum/mom_replay_system.cpp | 11 - .../game/server/momentum/mom_replay_system.h | 10 +- mp/src/game/server/momentum/server_events.cpp | 22 +- mp/src/game/server/momentum/server_events.h | 4 +- mp/src/game/shared/momentum/util/mom_util.cpp | 66 ++++-- mp/src/game/shared/momentum/util/mom_util.h | 10 +- version.txt | 2 +- 26 files changed, 493 insertions(+), 309 deletions(-) create mode 100644 changelog.txt create mode 100644 mp/src/game/client/momentum/ui/VersionWarnPanel.h rename mp/src/game/client/momentum/ui/{hud_versionwarn.cpp => hud_versioninfo.cpp} (81%) diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000000..f9628b612e --- /dev/null +++ b/changelog.txt @@ -0,0 +1,31 @@ +0.4.0 +Replay System + Automatically records replays for every run + Small, lightweight file (28 bytes / tick) + Truncates the recording to the first two seconds before the run started to show prestrafe only + Supports all stats that were displayed during the real run + Allows playback of ghosts with options for 15 different display models and customizable colors (see mom_replay_* commands for more details) +Comparisons Panel + Compare your current run against your PB + Compare against any run stats; all, some or none +Precise Timer + Times accurate to 6 decimal places (however, we currently only display 3 decimal places) + The only timer for surf or bhop that is more accurate than the interval per tick + Read about how it works on our devblog +Map Finished Screen + Mouse controls for watching the replay of the run you just finished + Pages for stats in every zone, not just overall + Shows both XY and XYZ velocity (controlled by mom_speedometer_hvel currently) +Other changes + Added Source Shader Editor + Added both XY and XYZ velocities to run stats + Player's velocity is now slowed down when they finish a map to allow them to see the map finished screen + Crosshair is off by default + +left and +right are now bindable from Options->Keyboard + JUMP indicator in key press display no longer flashes when the player uses the scroll wheel to jump + Credits can now go faster if +attack is pressed + DIsabled demo interpolation, which fixes demo stuttering bug, but makes demos lag. Demos will work properly if you turn off client interpolation (cl_interp 0) but this breaks other things + point_servercommand entities are disabled by default + sv_gravity is development-only (sorry) + Player FOV setting now works properly through fov_desired + Changed mom_generate_zon_file to mom_zone_generate \ No newline at end of file diff --git a/mp/game/momentum/resource/SourceScheme.res b/mp/game/momentum/resource/SourceScheme.res index 8a7796febd..7877e6de37 100644 --- a/mp/game/momentum/resource/SourceScheme.res +++ b/mp/game/momentum/resource/SourceScheme.res @@ -89,7 +89,7 @@ Scheme FrameSystemButton.BgColor "Blank" FrameSystemButton.Icon "" FrameSystemButton.DisabledIcon "" - FrameTitleBar.Font "Verdana" + FrameTitleBar.Font "DefaultSmall" FrameTitleBar.TextColor "255 255 255 204" FrameTitleBar.BgColor "Blank" FrameTitleBar.DisabledTextColor "255 255 255 91" @@ -255,6 +255,7 @@ Scheme "name" "Verdana" [$LINUX] "tall" "16" "weight" "500" + "antialias" "1" } } "DefaultBold" @@ -287,6 +288,7 @@ Scheme "tall" "12" [!$LINUX] "tall" "16" [$LINUX] "weight" "0" + "antialias" "1" } } "DefaultSmallDropShadow" @@ -298,6 +300,7 @@ Scheme "tall" "13" "weight" "0" "dropshadow" "1" + "antialias" "1" } } "DefaultVerySmall" @@ -306,8 +309,10 @@ Scheme { "name" "Tahoma" [!$LINUX] "name" "Verdana" [$LINUX] - "tall" "12" + "tall" "12" [$LINUX] + "tall" "10" [!$LINUX] "weight" "0" + "antialias" "1" } } diff --git a/mp/game/momentum/resource/gameui_english.txt b/mp/game/momentum/resource/gameui_english.txt index ff333582f8f788f77fa85b39edb8cce72ab7e2ad..f07a8ecd8b75643413282461aada40102bbbfcfb 100644 GIT binary patch delta 121 zcmX@d+QPn}i%HX&A%h{2A&()QA(g?0As4FNEa~_17-7pW+^Z@GL!*L%>=4UWJm(5R|M*ppWMad0s!##7{&kq delta 11 ScmZo+KgYVEi)pe0vkL$i&jYmp diff --git a/mp/game/momentum/resource/ui/versionwarnpanel.res b/mp/game/momentum/resource/ui/versionwarnpanel.res index af09405341..bb16c534f8 100644 --- a/mp/game/momentum/resource/ui/versionwarnpanel.res +++ b/mp/game/momentum/resource/ui/versionwarnpanel.res @@ -4,11 +4,10 @@ { "ControlName" "CVersionWarnPanel" "fieldName" "VersionWarnPanel" - "xpos" "c-225" - "ypos" "c-50" - "wide" "450" - "tall" "100" - "alpha" "255" + "xpos" "c-250" + "ypos" "c-125" + "wide" "650" + "tall" "320" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -16,18 +15,18 @@ "pin_to_sibling_corner" "0" "visible" "1" "enabled" "1" - "tabPosition" "32" + "tabPosition" "0" "settitlebarvisible" "1" - "title" "New version available" + "title" "#MOM_NewVersionTitle" } "frame_topGrip" { "ControlName" "Panel" "fieldName" "frame_topGrip" - "xpos" "8" + "xpos" "4" "ypos" "0" - "wide" "496" - "tall" "5" + "wide" "255" + "tall" "2" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -41,10 +40,10 @@ { "ControlName" "Panel" "fieldName" "frame_bottomGrip" - "xpos" "8" - "ypos" "507" - "wide" "486" - "tall" "5" + "xpos" "4" + "ypos" "157" + "wide" "250" + "tall" "2" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -59,9 +58,9 @@ "ControlName" "Panel" "fieldName" "frame_leftGrip" "xpos" "0" - "ypos" "8" - "wide" "5" - "tall" "496" + "ypos" "4" + "wide" "2" + "tall" "151" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -75,10 +74,10 @@ { "ControlName" "Panel" "fieldName" "frame_rightGrip" - "xpos" "507" - "ypos" "8" - "wide" "5" - "tall" "486" + "xpos" "261" + "ypos" "4" + "wide" "2" + "tall" "146" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -94,8 +93,8 @@ "fieldName" "frame_tlGrip" "xpos" "0" "ypos" "0" - "wide" "8" - "tall" "8" + "wide" "4" + "tall" "4" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -109,10 +108,10 @@ { "ControlName" "Panel" "fieldName" "frame_trGrip" - "xpos" "504" + "xpos" "259" "ypos" "0" - "wide" "8" - "tall" "8" + "wide" "4" + "tall" "4" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -127,9 +126,9 @@ "ControlName" "Panel" "fieldName" "frame_blGrip" "xpos" "0" - "ypos" "504" - "wide" "8" - "tall" "8" + "ypos" "155" + "wide" "4" + "tall" "4" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -143,10 +142,10 @@ { "ControlName" "Panel" "fieldName" "frame_brGrip" - "xpos" "494" - "ypos" "494" - "wide" "18" - "tall" "18" + "xpos" "254" + "ypos" "150" + "wide" "9" + "tall" "9" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -160,10 +159,10 @@ { "ControlName" "Panel" "fieldName" "frame_caption" - "xpos" "3" - "ypos" "-16" - "wide" "502" - "tall" "23" + "xpos" "0" + "ypos" "0" + "wide" "258" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -179,8 +178,8 @@ "fieldName" "frame_minimize" "xpos" "0" "ypos" "0" - "wide" "18" - "tall" "18" + "wide" "0" + "tall" "0" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -207,8 +206,8 @@ "fieldName" "frame_maximize" "xpos" "0" "ypos" "0" - "wide" "18" - "tall" "18" + "wide" "0" + "tall" "0" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -235,8 +234,8 @@ "fieldName" "frame_mintosystray" "xpos" "0" "ypos" "0" - "wide" "18" - "tall" "18" + "wide" "0" + "tall" "0" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -262,10 +261,10 @@ { "ControlName" "Button" "fieldName" "frame_close" - "xpos" "487" + "xpos" "239" "ypos" "8" - "wide" "13" - "tall" "13" + "wide" "17" + "tall" "17" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -280,21 +279,21 @@ "brighttext" "0" "wrap" "0" "centerwrap" "0" - "textinsetx" "2" - "textinsety" "1" + "textinsetx" "4" + "textinsety" "2" "auto_wide_tocontents" "0" "use_proportional_insets" "0" + "command" "turnoff" "Default" "0" - "command" "turnoff" } "frame_menu" { "ControlName" "FrameSystemButton" "fieldName" "frame_menu" - "xpos" "7" - "ypos" "8" - "wide" "18" - "tall" "18" + "xpos" "3" + "ypos" "4" + "wide" "9" + "tall" "9" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -320,8 +319,8 @@ "fieldName" "CloseButton" "xpos" "0" "ypos" "0" - "wide" "18" - "tall" "18" + "wide" "0" + "tall" "0" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -333,8 +332,8 @@ "labelText" "#GameUI_Close" "textAlignment" "north-west" "dulltext" "0" - "Font" "Default" "brighttext" "0" + "Font" "Default" "wrap" "0" "centerwrap" "0" "textinsetx" "2" @@ -345,34 +344,88 @@ } "ReleaseText" { - "ControlName" "URLLabel" + "ControlName" "URLLabel" "fieldName" "ReleaseText" - "xpos" "25" - "ypos" "50" - "wide" "640" - "tall" "20" - "autoResize" "0" + "xpos" "380" + "ypos" "94" + "wide" "260" + "tall" "120" + "autoResize" "0" "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" "visible" "1" "enabled" "1" - "textAlignment" "west" + "tabPosition" "0" "labelText" "#MOM_NewVersion" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "1" + "Font" "DefaultSmall" + "wrap" "1" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "URLText" "https://github.com/momentum-mod/game/releases" + } + "ChangeLog" + { + "ControlName" "RichText" + "fieldName" "ChangeLog" + "xpos" "12" + "ypos" "55" + "wide" "350" + "tall" "250" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "maxchars" "-1" + "scrollbar" "1" + } + "Changelog_Label" + { + "ControlName" "Label" + "fieldName" "Changelog_Label" + "xpos" "9" + "ypos" "36" + "wide" "150" + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "#MOM_ChangeLog" + "textAlignment" "west" "dulltext" "0" - "brighttext" "1" - "Font" "Default" - "wrap" "0" - "centerwrap" "0" - "textinsetx" "0" - "textinsety" "0" + "brighttext" "0" + "font" "DefaultVerySmall" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" } "BuildModeDialog" { "ControlName" "BuildModeDialog" "fieldName" "BuildModeDialog" - "xpos" "327" - "ypos" "301" - "wide" "300" - "tall" "420" + "xpos" "0" + "ypos" "0" + "wide" "160" + "tall" "224" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -384,4 +437,4 @@ "settitlebarvisible" "1" "title" "#Frame_Untitled" } -} \ No newline at end of file +} diff --git a/mp/game/momentum/scripts/HudLayout.res b/mp/game/momentum/scripts/HudLayout.res index 51b16fa086..f6b22935b4 100644 --- a/mp/game/momentum/scripts/HudLayout.res +++ b/mp/game/momentum/scripts/HudLayout.res @@ -79,9 +79,9 @@ //You can override "MenuItemColor" etc here (I think) } // Version warning - CHudVersionWarn + CHudVersionInfo { - "fieldName" "CHudVersionWarn" + "fieldName" "CHudVersionInfo" "xpos" "640" "ypos" "460" "visible" "1" diff --git a/mp/src/game/client/cdll_client_int.cpp b/mp/src/game/client/cdll_client_int.cpp index 77a7e9e762..5b8f10d962 100644 --- a/mp/src/game/client/cdll_client_int.cpp +++ b/mp/src/game/client/cdll_client_int.cpp @@ -170,10 +170,6 @@ extern vgui::IInputInternal *g_InputInternal; #include "sixense/in_sixense.h" #endif - -//Momentum -#include "mom_event_listener.h" - // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -1093,8 +1089,6 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi HookHapticMessages(); // Always hook the messages #endif - g_MOMEventListener->Init();//Hook into game events - return true; } diff --git a/mp/src/game/client/client_momentum.vpc b/mp/src/game/client/client_momentum.vpc index f79d1bd03c..6782758655 100644 --- a/mp/src/game/client/client_momentum.vpc +++ b/mp/src/game/client/client_momentum.vpc @@ -75,7 +75,7 @@ $Project "Client (Momentum)" $File "momentum\ui\ClientTimesDisplay.cpp" $File "momentum\ui\IVersionWarnPanel.h" $File "momentum\ui\VersionWarnPanel.cpp" - $File "momentum\ui\hud_versionwarn.cpp" + $File "momentum\ui\hud_versioninfo.cpp" $File "momentum\ui\hud_mapfinished.cpp" $File "momentum\ui\hud_mapfinished.h" $File "momentum\ui\hud_keypress.cpp" diff --git a/mp/src/game/client/momentum/client_events.cpp b/mp/src/game/client/momentum/client_events.cpp index 924b7af8ea..a9fffb59e0 100644 --- a/mp/src/game/client/momentum/client_events.cpp +++ b/mp/src/game/client/momentum/client_events.cpp @@ -3,57 +3,66 @@ #endif #include "client_events.h" + #include "filesystem.h" #include "movevars_shared.h" +#include "util/mom_util.h" +#include "mom_event_listener.h" #include "tier0/memdbgon.h" extern IFileSystem *filesystem; -namespace Momentum { +void CMOMClientEvents::PostInit() +{ + g_MOMEventListener->Init();//Hook into game events + + // enable console by default + ConVarRef con_enable("con_enable"); + con_enable.SetValue(true); - void OnClientDLLInit() - { - // enable console by default - ConVarRef con_enable("con_enable"); - con_enable.SetValue(true); - // mount CSS content even if it's on a different drive than SDK + if (SteamAPI_IsSteamRunning()) + { + mom_UTIL->GetRemoteRepoModVersion(); + } + + // mount CSS content even if it's on a different drive than SDK #ifdef _WIN32 - HKEY hKey; - if (VCRHook_RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 240", - 0, - KEY_READ, - &hKey) == ERROR_SUCCESS) - { - char installPath[MAX_PATH]; - DWORD len = sizeof(installPath); - if (VCRHook_RegQueryValueEx(hKey, - "InstallLocation", - NULL, - NULL, - (LPBYTE)installPath, - &len) == ERROR_SUCCESS) - { - char path[MAX_PATH]; - Q_strncpy(path, installPath, sizeof(path)); - - Q_strncat(path, "\\cstrike", sizeof(path)); - filesystem->AddSearchPath(path, "GAME"); - - Q_strncat(path, "\\download", sizeof(path)); - filesystem->AddSearchPath(path, "GAME"); - - Q_strncpy(path, installPath, sizeof(path)); - Q_strncat(path, "\\cstrike\\cstrike_pak.vpk", sizeof(path)); - filesystem->AddSearchPath(path, "GAME"); - - filesystem->PrintSearchPaths(); - } - - VCRHook_RegCloseKey(hKey); - } + HKEY hKey; + if (VCRHook_RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 240", + 0, + KEY_READ, + &hKey) == ERROR_SUCCESS) + { + char installPath[MAX_PATH]; + DWORD len = sizeof(installPath); + if (VCRHook_RegQueryValueEx(hKey, + "InstallLocation", + NULL, + NULL, + (LPBYTE) installPath, + &len) == ERROR_SUCCESS) + { + char path[MAX_PATH]; + Q_strncpy(path, installPath, sizeof(path)); + + Q_strncat(path, "\\cstrike", sizeof(path)); + filesystem->AddSearchPath(path, "GAME"); + + Q_strncat(path, "\\download", sizeof(path)); + filesystem->AddSearchPath(path, "GAME"); + + Q_strncpy(path, installPath, sizeof(path)); + Q_strncat(path, "\\cstrike\\cstrike_pak.vpk", sizeof(path)); + filesystem->AddSearchPath(path, "GAME"); + + filesystem->PrintSearchPaths(); + } + + VCRHook_RegCloseKey(hKey); + } #endif - } +} -} // namespace Momentum +CMOMClientEvents g_MOMClientEvents("CMOMClientEvents"); \ No newline at end of file diff --git a/mp/src/game/client/momentum/client_events.h b/mp/src/game/client/momentum/client_events.h index 302cbc8bda..791d46c3ce 100644 --- a/mp/src/game/client/momentum/client_events.h +++ b/mp/src/game/client/momentum/client_events.h @@ -4,10 +4,18 @@ #pragma once #endif -namespace Momentum { +#include "cbase.h" - void OnClientDLLInit(); +class CMOMClientEvents : public CAutoGameSystem +{ +public: + CMOMClientEvents(const char *pName) : CAutoGameSystem(pName) + { + } -} // namespace Momentum + //After DLL inits successfully + void PostInit() override; -#endif // CLIENT_EVENTS_H +}; + +#endif // CLIENT_EVENTS_H \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/IVersionWarnPanel.h b/mp/src/game/client/momentum/ui/IVersionWarnPanel.h index 1d8a0157af..3de4a470c9 100644 --- a/mp/src/game/client/momentum/ui/IVersionWarnPanel.h +++ b/mp/src/game/client/momentum/ui/IVersionWarnPanel.h @@ -5,10 +5,13 @@ class VersionWarnPanel { public: + virtual ~VersionWarnPanel() {} virtual void Create(vgui::VPANEL parent) = 0; virtual void Destroy(void) = 0; virtual void Activate(void) = 0; virtual void Close() = 0; + virtual void SetVersion(const char *pVersion) const = 0; + virtual void SetChangelog(char *pChangelog) const = 0; }; extern VersionWarnPanel *versionwarnpanel; \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/VersionWarnPanel.cpp b/mp/src/game/client/momentum/ui/VersionWarnPanel.cpp index e9a06ecc42..9886a8310c 100644 --- a/mp/src/game/client/momentum/ui/VersionWarnPanel.cpp +++ b/mp/src/game/client/momentum/ui/VersionWarnPanel.cpp @@ -1,132 +1,54 @@ -//The following include files are necessary to allow The Panel .cpp to compile. +// The following include files are necessary to allow The Panel .cpp to compile. #include "cbase.h" -#include "IVersionWarnPanel.h" -using namespace vgui; -#include -#include -#include -#include -#include "momentum/mom_shareddefs.h" +#include "VersionWarnPanel.h" #include "tier0/memdbgon.h" -//CVersionWarnPanel class -class CVersionWarnPanel : public vgui::Frame -{ - DECLARE_CLASS_SIMPLE(CVersionWarnPanel, vgui::Frame); - //CVersionWarnPanel : This Class / vgui::Frame : BaseClass - - CVersionWarnPanel(vgui::VPANEL parent); // Constructor - ~CVersionWarnPanel(){}; // Destructor - -protected: - //VGUI overrides: - virtual void OnTick(); - virtual void OnCommand(const char* pcCommand); - -private: - //Other used VGUI control Elements: - URLLabel *m_pReleaseText; - const char *m_pVersion; -}; - // Constuctor: Initializes the Panel -CVersionWarnPanel::CVersionWarnPanel(vgui::VPANEL parent) - : BaseClass(nullptr, "VersionWarnPanel") +CVersionWarnPanel::CVersionWarnPanel(VPANEL parent) : BaseClass(nullptr, "VersionWarnPanel") { + V_memset(m_cOnlineVersion, 0, sizeof(m_cOnlineVersion)); SetParent(parent); + LoadControlSettings("resource/ui/versionwarnpanel.res"); + m_pReleaseText = FindControl("ReleaseText", true); + m_pChangeLog = FindControl("ChangeLog", true); SetKeyBoardInputEnabled(true); SetMouseInputEnabled(true); - - SetProportional(true); SetTitleBarVisible(true); SetMinimizeButtonVisible(false); SetMaximizeButtonVisible(false); SetCloseButtonVisible(true); SetSizeable(false); + SetMinimumSize(400, 250); SetMoveable(true); SetVisible(false); + SetProportional(true); - - SetScheme(vgui::scheme()->LoadSchemeFromFile("resource/SourceScheme.res", "SourceScheme")); - - LoadControlSettings("resource/ui/versionwarnpanel.res"); - - vgui::ivgui()->AddTickSignal(GetVPanel(), 100); - - m_pReleaseText = FindControl("ReleaseText", true); - if (!m_pReleaseText) + //SetScheme(scheme()->LoadSchemeFromFile("resource/SourceScheme.res", "SourceScheme")); + if (!m_pReleaseText || !m_pChangeLog) { Assert("Missing one more gameui controls from ui/versionwarnpanel.res"); } - } -//Class: CMyPanelInterface Class. Used for construction. -class CVersionWarnPanelInterface : public VersionWarnPanel +// Called when the versions don't match (there's an update) +void CVersionWarnPanel::Activate() { -private: - CVersionWarnPanel *MyPanel; -public: - CVersionWarnPanelInterface() - { - MyPanel = nullptr; - } - void Create(vgui::VPANEL parent) - { - MyPanel = new CVersionWarnPanel(parent); - } - void Destroy() - { - if (MyPanel) - { - MyPanel->SetParent(nullptr); - delete MyPanel; - } - } - void Activate(void) - { - if (MyPanel) - { - MyPanel->Activate(); - } - } - void Close() - { - if (MyPanel) - { - MyPanel->Close(); - } - } -}; -static CVersionWarnPanelInterface g_VersionWarn; -VersionWarnPanel* versionwarnpanel = (VersionWarnPanel*)&g_VersionWarn; - -ConVar cl_showversionwarnpanel("cl_showversionwarnpanel", "0", FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_SERVER_CAN_EXECUTE | FCVAR_HIDDEN, "Sets the state of versionwarnpanel"); + //HFont m_hfReleaseFont = m_pReleaseText->GetFont(); + char m_cReleaseText[225]; + m_pReleaseText->GetText(m_cReleaseText, sizeof(m_cReleaseText)); + char m_cReleaseF[225]; -void CVersionWarnPanel::OnTick() -{ - BaseClass::OnTick(); - if (Q_strcmp(cl_showversionwarnpanel.GetString(), cl_showversionwarnpanel.GetDefault()) != 0) - { - SetVisible(true); - HFont m_hfReleaseFont = m_pReleaseText->GetFont(); - char m_cReleaseText[225]; - m_pReleaseText->GetText(m_cReleaseText, sizeof(m_cReleaseText)); - char m_cReleaseF[225]; + Q_snprintf(m_cReleaseF, 225, m_cReleaseText, MOM_CURRENT_VERSION, m_cOnlineVersion); + m_pReleaseText->SetText(m_cReleaseF); + m_pReleaseText->SetURL("https://github.com/momentum-mod/game/releases"); - Q_snprintf(m_cReleaseF, 225, m_cReleaseText, MOM_CURRENT_VERSION, cl_showversionwarnpanel.GetString()); - cl_showversionwarnpanel.Revert(); - m_pReleaseText->SetText(m_cReleaseF); - m_pReleaseText->SetURL("https://github.com/momentum-mod/game/releases"); - SetSize(UTIL_ComputeStringWidth(m_hfReleaseFont, m_cReleaseF) + m_pReleaseText->GetXPos() * 2, GetTall()); - m_pReleaseText->SetPos(m_pReleaseText->GetXPos(), GetTall() / 2); - } + BaseClass::Activate(); } -void CVersionWarnPanel::OnCommand(const char* pcCommand) +void CVersionWarnPanel::OnCommand(const char *pcCommand) { BaseClass::OnCommand(pcCommand); @@ -139,5 +61,10 @@ void CVersionWarnPanel::OnCommand(const char* pcCommand) CON_COMMAND(mom_version, "Prints mod current installed version") { - Log("Mod currently installed version: %s\n",MOM_CURRENT_VERSION); -} \ No newline at end of file + Log("Mod currently installed version: %s\n", MOM_CURRENT_VERSION); + // MOM_TODO: Do we want to check for new versions in the future? +} + +// Interface this class to the rest of the DLL +static CVersionWarnPanelInterface g_VersionWarn; +VersionWarnPanel *versionwarnpanel = static_cast(&g_VersionWarn); \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/VersionWarnPanel.h b/mp/src/game/client/momentum/ui/VersionWarnPanel.h new file mode 100644 index 0000000000..e38962bbf7 --- /dev/null +++ b/mp/src/game/client/momentum/ui/VersionWarnPanel.h @@ -0,0 +1,105 @@ +#pragma once + +#include "cbase.h" + +#include "IVersionWarnPanel.h" +#include +#include +#include +#include +#include + +#include "momentum/mom_shareddefs.h" + +using namespace vgui; + +// CVersionWarnPanel class +class CVersionWarnPanel : public Frame +{ + DECLARE_CLASS_SIMPLE(CVersionWarnPanel, Frame); + // CVersionWarnPanel : This Class / vgui::Frame : BaseClass + + CVersionWarnPanel(VPANEL parent); // Constructor + ~CVersionWarnPanel(){}; // Destructor + + void SetVersion(const char *version) { Q_strncpy(m_cOnlineVersion, version, 12); } + + void SetChangelog(char *pChangelog) + { + Q_strncpy(m_cOnlineChangelog, pChangelog, sizeof(m_cOnlineChangelog)); + if (m_pChangeLog) + { + m_pChangeLog->InsertString(m_cOnlineChangelog); + m_pChangeLog->GotoTextStart(); + } + } + + void ApplySchemeSettings(IScheme *pScheme) override + { + BaseClass::ApplySchemeSettings(pScheme); + m_pChangeLog->SetFont(pScheme->GetFont("DefaultSmall")); + } + + void Activate() override; + + protected: + // VGUI overrides: + void OnCommand(const char *pcCommand) override; + + private: + // Other used VGUI control Elements: + URLLabel *m_pReleaseText; + RichText *m_pChangeLog; + char m_cOnlineVersion[12]; + char m_cOnlineChangelog[4056]; // MOM_TODO: Determine a better size +}; + +class CVersionWarnPanelInterface : public VersionWarnPanel +{ + private: + CVersionWarnPanel *pPanel; + + public: + CVersionWarnPanelInterface() { pPanel = nullptr; } + ~CVersionWarnPanelInterface() { } + void Create(vgui::VPANEL parent) override { pPanel = new CVersionWarnPanel(parent); } + void Destroy() override + { + if (pPanel) + { + pPanel->SetParent(nullptr); + delete pPanel; + } + pPanel = nullptr; + } + void Activate(void) override + { + if (pPanel) + { + pPanel->Activate(); + } + } + void Close() override + { + if (pPanel) + { + pPanel->Close(); + } + } + + void SetVersion(const char *pVersion) const override + { + if (pPanel) + { + pPanel->SetVersion(pVersion); + } + } + + void SetChangelog(char *pChangelog) const override + { + if (pPanel) + { + pPanel->SetChangelog(pChangelog); + } + } +}; \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/hud_versionwarn.cpp b/mp/src/game/client/momentum/ui/hud_versioninfo.cpp similarity index 81% rename from mp/src/game/client/momentum/ui/hud_versionwarn.cpp rename to mp/src/game/client/momentum/ui/hud_versioninfo.cpp index 52b6bafcdf..4d387faac5 100644 --- a/mp/src/game/client/momentum/ui/hud_versionwarn.cpp +++ b/mp/src/game/client/momentum/ui/hud_versioninfo.cpp @@ -13,12 +13,12 @@ using namespace vgui; -class CHudVersionWarn : public CHudElement, public Panel +class CHudVersionInfo : public CHudElement, public Panel { - DECLARE_CLASS_SIMPLE(CHudVersionWarn, Panel); + DECLARE_CLASS_SIMPLE(CHudVersionInfo, Panel); public: - CHudVersionWarn(const char *pElementName); + CHudVersionInfo(const char *pElementName); bool ShouldDraw() override { return CHudElement::ShouldDraw(); } @@ -33,10 +33,10 @@ class CHudVersionWarn : public CHudElement, public Panel wchar_t uVersionText[BUFSIZELOCL]; }; -DECLARE_HUDELEMENT(CHudVersionWarn); +DECLARE_HUDELEMENT(CHudVersionInfo); -CHudVersionWarn::CHudVersionWarn(const char *pElementName) - : CHudElement(pElementName), Panel(g_pClientMode->GetViewport(), "CHudVersionWarn") +CHudVersionInfo::CHudVersionInfo(const char *pElementName) + : CHudElement(pElementName), Panel(g_pClientMode->GetViewport(), "CHudVersionInfo") { SetPaintBackgroundEnabled(false); SetProportional(true); @@ -45,7 +45,7 @@ CHudVersionWarn::CHudVersionWarn(const char *pElementName) SetHiddenBits(HIDEHUD_WEAPONSELECTION); } -void CHudVersionWarn::Init() +void CHudVersionInfo::Init() { char m_pszStringVersion[BUFSIZELOCL]; char strVersion[BUFSIZELOCL]; @@ -57,7 +57,7 @@ void CHudVersionWarn::Init() g_pVGuiLocalize->ConvertANSIToUnicode(m_pszStringVersion, uVersionText, sizeof(m_pszStringVersion)); } -void CHudVersionWarn::Paint() +void CHudVersionInfo::Paint() { surface()->DrawSetTextPos(0, 0); surface()->DrawSetTextFont(m_hTextFont); diff --git a/mp/src/game/server/gameinterface.cpp b/mp/src/game/server/gameinterface.cpp index f61f006273..364a84a632 100644 --- a/mp/src/game/server/gameinterface.cpp +++ b/mp/src/game/server/gameinterface.cpp @@ -747,9 +747,6 @@ bool CServerGameDLL::DLLInit( CreateInterfaceFn appSystemFactory, gamestatsuploader->InitConnection(); #endif - //Momentum - Momentum::OnServerDLLInit(); - return true; } diff --git a/mp/src/game/server/momentum/mom_player.cpp b/mp/src/game/server/momentum/mom_player.cpp index 7f48117d7a..bdf3cef1b4 100644 --- a/mp/src/game/server/momentum/mom_player.cpp +++ b/mp/src/game/server/momentum/mom_player.cpp @@ -34,7 +34,7 @@ PRECACHE_REGISTER(player); CMomentumPlayer::CMomentumPlayer() : m_duckUntilOnGround(false), m_flStamina(0), m_flTicksOnGround(0), m_flLastVelocity(0), m_flLastSyncVelocity(0), m_nPerfectSyncTicks(0), m_nStrafeTicks(0), m_nAccelTicks(0), m_bPrevTimerRunning(false), m_nPrevButtons(0), - m_nTicksInAir(0) + m_nTicksInAir(0), m_flTweenVelValue(1.0f) { m_flPunishTime = -1; m_iLastBlock = -1; @@ -69,6 +69,13 @@ void CMomentumPlayer::FireGameEvent(IGameEvent* pEvent) //Hide the mapfinished panel and reset our speed to normal m_RunData.m_bMapFinished = false; SetLaggedMovementValue(1.0f); + + //Fix for the replay system not being able to listen to events + if (g_ReplaySystem->GetReplayManager()->GetPlaybackReplay() && + !g_ReplaySystem->GetReplayManager()->PlayingBack()) + { + g_ReplaySystem->GetReplayManager()->UnloadPlayback(); + } } } @@ -524,18 +531,16 @@ CBaseEntity *CMomentumPlayer::FindNextObserverTarget(bool bReverse) void CMomentumPlayer::TweenSlowdownPlayer() { - if (m_RunData.m_bMapFinished) //slowdown when map is finished - { + //slowdown when map is finished + if (m_RunData.m_bMapFinished) //decrease our lagged movement value by 10% every tick - if (!mom_UTIL->FloatEquals(m_flTweenVelValue, 0.0f)) - m_flTweenVelValue += (0.01f - m_flTweenVelValue) * 0.1f; - } + m_flTweenVelValue *= 0.9f; else m_flTweenVelValue = 1.0f;//Reset the tweened value back to normal SetLaggedMovementValue(m_flTweenVelValue); - SetNextThink(gpGlobals->curtime + 0.01f, "TWEEN"); + SetNextThink(gpGlobals->curtime + gpGlobals->interval_per_tick, "TWEEN"); } CMomentumReplayGhostEntity* CMomentumPlayer::GetReplayEnt() const diff --git a/mp/src/game/server/momentum/mom_player.h b/mp/src/game/server/momentum/mom_player.h index cc6d292523..a000658196 100644 --- a/mp/src/game/server/momentum/mom_player.h +++ b/mp/src/game/server/momentum/mom_player.h @@ -163,6 +163,6 @@ class CMomentumPlayer : public CBasePlayer, public CGameEventListener // Start zone thinkfunc int m_nTicksInAir; - float m_flTweenVelValue = 1.0f; + float m_flTweenVelValue; }; #endif // MOMPLAYER_H \ No newline at end of file diff --git a/mp/src/game/server/momentum/mom_replay_entity.cpp b/mp/src/game/server/momentum/mom_replay_entity.cpp index 70a52d9a93..2acd925108 100644 --- a/mp/src/game/server/momentum/mom_replay_entity.cpp +++ b/mp/src/game/server/momentum/mom_replay_entity.cpp @@ -57,7 +57,6 @@ CMomentumReplayGhostEntity::CMomentumReplayGhostEntity() : CMomentumReplayGhostEntity::~CMomentumReplayGhostEntity() { - g_ReplaySystem->GetReplayManager()->StopPlayback(); } void CMomentumReplayGhostEntity::Precache(void) @@ -143,19 +142,24 @@ void CMomentumReplayGhostEntity::UpdateStep() { --m_iCurrentStep; - if (m_iCurrentStep < 0) + if (m_bReplayShouldLoop && m_iCurrentStep < 0) + { m_iCurrentStep = m_pPlaybackReplay->GetFrameCount() - 1; + } return; } ++m_iCurrentStep; - if (m_iCurrentStep >= m_pPlaybackReplay->GetFrameCount()) + if (m_iCurrentStep >= m_pPlaybackReplay->GetFrameCount() && m_bReplayShouldLoop) m_iCurrentStep = 0; } void CMomentumReplayGhostEntity::Think(void) { + if (!m_bIsActive) + return; + if (!m_pPlaybackReplay) { BaseClass::Think(); @@ -181,12 +185,16 @@ void CMomentumReplayGhostEntity::Think(void) SetRenderColorA(mom_replay_ghost_alpha.GetInt()); } + bool reverse = mom_replay_reverse.GetBool(); + //move the ghost - if (((mom_replay_reverse.GetBool() && m_iCurrentStep - 1 < 0) || - (!mom_replay_reverse.GetBool() && m_iCurrentStep + 1 >= m_pPlaybackReplay->GetFrameCount()))) + if (!m_bReplayShouldLoop && + (reverse && (m_iCurrentStep - 1 < 0) || + !reverse && (m_iCurrentStep + 1 >= m_pPlaybackReplay->GetFrameCount()))) { // If we're not looping and we've reached the end of the video then stop and wait for the player // to make a choice about if it should repeat, or end. + SetAbsVelocity(vec3_origin); } else { @@ -249,7 +257,12 @@ void CMomentumReplayGhostEntity::HandleGhostFirstPerson() float distY = fabs(currentStep->PlayerOrigin().y - nextStep->PlayerOrigin().y); float distZ = fabs(currentStep->PlayerOrigin().z - nextStep->PlayerOrigin().z); Vector interpolatedVel = Vector(distX, distY, distZ) / gpGlobals->interval_per_tick; - SetAbsVelocity(interpolatedVel); + float maxvel = sv_maxvelocity.GetFloat(); + + //Fixes an issue with teleporting + if (interpolatedVel.x <= maxvel && interpolatedVel.y <= maxvel && interpolatedVel.z <= maxvel) + SetAbsVelocity(interpolatedVel); + m_nReplayButtons = currentStep->PlayerButtons(); // networked var that allows the replay to control keypress display on the client if (m_RunData.m_bTimerRunning) @@ -393,7 +406,6 @@ void CMomentumReplayGhostEntity::StopTimer() void CMomentumReplayGhostEntity::EndRun() { StopTimer();// Stop the timer for all spectating us - SetNextThink(-1);// Stop thinking m_bIsActive = false; // Make everybody stop spectating me. Goes backwards since players remove themselves. diff --git a/mp/src/game/server/momentum/mom_replay_manager.cpp b/mp/src/game/server/momentum/mom_replay_manager.cpp index 5310b3e985..17d1fa9988 100644 --- a/mp/src/game/server/momentum/mom_replay_manager.cpp +++ b/mp/src/game/server/momentum/mom_replay_manager.cpp @@ -160,17 +160,19 @@ void CMomReplayManager::StopPlayback() UnloadPlayback(); } -void CMomReplayManager::UnloadPlayback() +void CMomReplayManager::UnloadPlayback(bool shutdown) { SetPlayingBack(false); if (m_pPlaybackReplay) { - if (m_pPlaybackReplay->GetRunEntity()) + if (m_pPlaybackReplay->GetRunEntity() && !shutdown) m_pPlaybackReplay->GetRunEntity()->EndRun(); delete m_pPlaybackReplay; } m_pPlaybackReplay = nullptr; + + DevLog("Successfully unloaded playback, shutdown: %i\n", shutdown); } \ No newline at end of file diff --git a/mp/src/game/server/momentum/mom_replay_manager.h b/mp/src/game/server/momentum/mom_replay_manager.h index fbe256f45e..b6bc125dbc 100644 --- a/mp/src/game/server/momentum/mom_replay_manager.h +++ b/mp/src/game/server/momentum/mom_replay_manager.h @@ -35,7 +35,7 @@ class CMomReplayManager bool StoreReplay(const char* path, const char* pathID = "MOD"); CMomReplayBase* LoadReplay(const char* path, const char* pathID = "MOD"); void StopPlayback(); - void UnloadPlayback(); + void UnloadPlayback(bool shutdown = false); void SetPlayingBack(bool playing) { m_bPlayingBack = playing; } public: diff --git a/mp/src/game/server/momentum/mom_replay_system.cpp b/mp/src/game/server/momentum/mom_replay_system.cpp index a72ab8e3ee..049f9cddea 100644 --- a/mp/src/game/server/momentum/mom_replay_system.cpp +++ b/mp/src/game/server/momentum/mom_replay_system.cpp @@ -92,17 +92,6 @@ void CMomentumReplaySystem::TrimReplay() } } - -void CMomentumReplaySystem::FireGameEvent(IGameEvent* pEvent) -{ - if (!Q_strcmp(pEvent->GetName(), "mapfinished_panel_closed")) - { - //If we loaded a replay, and it's not already playing, we want to unload it here - if (m_pReplayManager->GetPlaybackReplay() && !m_pReplayManager->PlayingBack()) - m_pReplayManager->UnloadPlayback(); - } -} - void CMomentumReplaySystem::UpdateRecordingParams() { ++m_iTickCount; // increment recording tick diff --git a/mp/src/game/server/momentum/mom_replay_system.h b/mp/src/game/server/momentum/mom_replay_system.h index 98a6c2f51b..145e6eec45 100644 --- a/mp/src/game/server/momentum/mom_replay_system.h +++ b/mp/src/game/server/momentum/mom_replay_system.h @@ -14,7 +14,7 @@ class CMomentumReplayGhostEntity; -class CMomentumReplaySystem : public CAutoGameSystemPerFrame, public CGameEventListener +class CMomentumReplaySystem : public CAutoGameSystemPerFrame { public: CMomentumReplaySystem(const char *pName) : @@ -27,7 +27,6 @@ class CMomentumReplaySystem : public CAutoGameSystemPerFrame, public CGameEventL m_player(nullptr) { m_pReplayManager = new CMomReplayManager(); - ListenForGameEvent("mapfinished_panel_closed"); } virtual ~CMomentumReplaySystem() override @@ -48,6 +47,9 @@ class CMomentumReplaySystem : public CAutoGameSystemPerFrame, public CGameEventL //Stop a recording if there is one while the level shuts down if (m_pReplayManager->Recording()) StopRecording(nullptr, true, false); + + if (m_pReplayManager->GetPlaybackReplay()) + m_pReplayManager->UnloadPlayback(true); } void SetTimerStartTick(int tick) @@ -57,14 +59,10 @@ class CMomentumReplaySystem : public CAutoGameSystemPerFrame, public CGameEventL void BeginRecording(CBasePlayer *pPlayer); void StopRecording(CBasePlayer *pPlayer, bool throwaway, bool delay); - void TrimReplay(); //Trims a replay's start down to only include a defined amount of time in the start trigger - void OnGhostEntityRemoved(CMomentumReplayGhostEntity*);// Called when a ghost entity is done being played. inline CMomReplayManager* GetReplayManager() const { return m_pReplayManager; } - void FireGameEvent(IGameEvent *pEvent) override; - private: void UpdateRecordingParams(); // called every game frame after entities think and update void SetReplayInfo(); diff --git a/mp/src/game/server/momentum/server_events.cpp b/mp/src/game/server/momentum/server_events.cpp index 201489d99c..f613d66953 100644 --- a/mp/src/game/server/momentum/server_events.cpp +++ b/mp/src/game/server/momentum/server_events.cpp @@ -3,16 +3,6 @@ #include "tier0/memdbgon.h" -void Momentum::OnServerDLLInit() -{ - TickSet::TickInit(); - // MOM_TODO: connect to site - if (SteamAPI_IsSteamRunning()) - { - mom_UTIL->GetRemoteRepoModVersion(); - } -} - //This is only called when "map ____" is called, if the user uses changelevel then... // \/(o_o)\/ void Momentum::GameInit() @@ -51,6 +41,16 @@ void Momentum::GameInit() } } +void CMOMServerEvents::PostInit() +{ + TickSet::TickInit(); + // MOM_TODO: connect to site + /*if (SteamAPI_IsSteamRunning()) + { + + }*/ +} + void CMOMServerEvents::LevelInitPostEntity() { const char *pMapName = gpGlobals->mapname.ToCStr(); @@ -106,4 +106,4 @@ void CMOMServerEvents::FrameUpdatePreEntityThink() } //Create the -CMOMServerEvents g_MOMServerEvents("MOMServerEvents"); \ No newline at end of file +CMOMServerEvents g_MOMServerEvents("CMOMServerEvents"); \ No newline at end of file diff --git a/mp/src/game/server/momentum/server_events.h b/mp/src/game/server/momentum/server_events.h index f56c5b18bd..84f85d51e1 100644 --- a/mp/src/game/server/momentum/server_events.h +++ b/mp/src/game/server/momentum/server_events.h @@ -11,8 +11,6 @@ #include "mapzones_edit.h" namespace Momentum { - -void OnServerDLLInit(); void GameInit(); } // namespace Momentum @@ -22,7 +20,7 @@ class CMOMServerEvents : CAutoGameSystemPerFrame CMOMServerEvents(const char *pName) : CAutoGameSystemPerFrame(pName), zones(nullptr) { } - + void PostInit() override; void LevelInitPostEntity() override; void LevelShutdownPreEntity() override; void FrameUpdatePreEntityThink() override; diff --git a/mp/src/game/shared/momentum/util/mom_util.cpp b/mp/src/game/shared/momentum/util/mom_util.cpp index 91418c12e1..9d5c2e40d4 100644 --- a/mp/src/game/shared/momentum/util/mom_util.cpp +++ b/mp/src/game/shared/momentum/util/mom_util.cpp @@ -7,6 +7,17 @@ extern IFileSystem *filesystem; +inline void CleanupRequest(HTTPRequestCompleted_t* pCallback, uint8* pData) +{ + if (pData) + { + delete[] pData; + } + pData = nullptr; + steamapicontext->SteamHTTP()->ReleaseHTTPRequest(pCallback->m_hRequest); +} + + void MomentumUtil::DownloadCallback(HTTPRequestCompleted_t *pCallback, bool bIOFailure) { if (bIOFailure) @@ -32,7 +43,7 @@ void MomentumUtil::DownloadCallback(HTTPRequestCompleted_t *pCallback, bool bIOF DevLog("Successfully written file\n"); // Free resources - steamapicontext->SteamHTTP()->ReleaseHTTPRequest(pCallback->m_hRequest); + CleanupRequest(pCallback, pData); } void MomentumUtil::PostTimeCallback(HTTPRequestCompleted_t *pCallback, bool bIOFailure) @@ -91,7 +102,7 @@ void MomentumUtil::PostTimeCallback(HTTPRequestCompleted_t *pCallback, bool bIOF } // Last but not least, free resources alloc.deallocate(); - steamapicontext->SteamHTTP()->ReleaseHTTPRequest(pCallback->m_hRequest); + CleanupRequest(pCallback, pData); } void MomentumUtil::PostTime(const char *szURL) @@ -138,12 +149,41 @@ void MomentumUtil::CreateAndSendHTTPReq(const char *szURL, CCallResultSteamHTTP()->GetHTTPResponseBodySize(pCallback->m_hRequest, &size); + if (size == 0) + { + Warning("MomentumUtil::ChangelogCallback: 0 body size!\n"); + return; + } + + uint8 *pData = new uint8[size]; + steamapicontext->SteamHTTP()->GetHTTPResponseBodyData(pCallback->m_hRequest, pData, size); + char *pDataPtr = reinterpret_cast(pData); + + versionwarnpanel->SetChangelog(pDataPtr); + + CleanupRequest(pCallback, pData); +} + void MomentumUtil::VersionCallback(HTTPRequestCompleted_t *pCallback, bool bIOFailure) { if (bIOFailure) @@ -164,20 +204,20 @@ void MomentumUtil::VersionCallback(HTTPRequestCompleted_t *pCallback, bool bIOFa char versionValue[15]; Q_snprintf(versionValue, 15, "%s.%s.%s", repoVersion.Element(0), repoVersion.Element(1), repoVersion.Element(2)); - if (Q_atoi(repoVersion.Element(0)) > Q_atoi(storedVersion.Element(0))) - { - ConVarRef("cl_showversionwarnpanel").SetValue(versionValue); - } - else if (Q_atoi(repoVersion.Element(1)) > Q_atoi(storedVersion.Element(1))) - { - ConVarRef("cl_showversionwarnpanel").SetValue(versionValue); - } - else if (Q_atoi(repoVersion.Element(2)) > Q_atoi(storedVersion.Element(2))) + for (int i = 0; i < 3; i++) { - ConVarRef("cl_showversionwarnpanel").SetValue(versionValue); + if (Q_atoi(repoVersion.Element(i)) > Q_atoi(storedVersion.Element(i))) + { + versionwarnpanel->SetVersion(versionValue); + GetRemoteChangelog(); + versionwarnpanel->Activate(); + break; + } } - steamapicontext->SteamHTTP()->ReleaseHTTPRequest(pCallback->m_hRequest); + + CleanupRequest(pCallback, pData); } +#endif void MomentumUtil::FormatTime(float m_flSecondsTime, char *pOut, int precision, bool fileName) const { diff --git a/mp/src/game/shared/momentum/util/mom_util.h b/mp/src/game/shared/momentum/util/mom_util.h index da94cc90ef..4100871c48 100644 --- a/mp/src/game/shared/momentum/util/mom_util.h +++ b/mp/src/game/shared/momentum/util/mom_util.h @@ -11,6 +11,9 @@ #include "UtlSortVector.h" #include "filesystem.h" #include "gason.h" +#ifdef CLIENT_DLL +#include "VersionWarnPanel.h" +#endif class MomentumUtil { @@ -26,10 +29,15 @@ class MomentumUtil CCallResult cbDownloadCallback; CCallResult cbPostTimeCallback; - void GetRemoteRepoModVersion(); +#ifdef CLIENT_DLL + void GetRemoteChangelog(); + CCallResult cbChangeLog; + void ChangelogCallback(HTTPRequestCompleted_t*, bool); + void GetRemoteRepoModVersion(); CCallResult cbVersionCallback; void VersionCallback(HTTPRequestCompleted_t*, bool); +#endif //Color GetColorFromVariation(float variation, float deadZone, Color normalcolor, Color increasecolor, Color decreasecolor); Color* GetColorFromHex(const char* hexColor); //in hex color format RRGGBB diff --git a/version.txt b/version.txt index 1d0ba9ea18..60a2d3e96c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.4.0 +0.4.0 \ No newline at end of file From 1d8576569bce1a42d4db82a70c22f96e173d4ae5 Mon Sep 17 00:00:00 2001 From: Nick K Date: Mon, 20 Jun 2016 01:42:39 -0400 Subject: [PATCH 02/10] Begin work on settings dialog LOTS of work to do --- .../resource/ui/MomentumSettingsPanel.res | 208 +++++++++--------- mp/src/game/client/client_momentum.vpc | 13 +- .../momentum/ui/MomentumSettingsDialog.cpp | 30 +-- 3 files changed, 127 insertions(+), 124 deletions(-) diff --git a/mp/game/momentum/resource/ui/MomentumSettingsPanel.res b/mp/game/momentum/resource/ui/MomentumSettingsPanel.res index e34057f1d9..54fbf9a7c9 100644 --- a/mp/game/momentum/resource/ui/MomentumSettingsPanel.res +++ b/mp/game/momentum/resource/ui/MomentumSettingsPanel.res @@ -4,10 +4,10 @@ { "ControlName" "CMomentumSettingsPanel" "fieldName" "CMomentumSettingsPanel" - "xpos" "337" - "ypos" "74" - "wide" "360" - "tall" "360" + "xpos" "324" + "ypos" "96" + "wide" "266" + "tall" "266" "autoResize" "1" "pinCorner" "0" "RoundedCorners" "15" @@ -25,7 +25,7 @@ "fieldName" "frame_topGrip" "xpos" "4" "ypos" "0" - "wide" "351" + "wide" "258" "tall" "2" "autoResize" "0" "pinCorner" "0" @@ -41,8 +41,8 @@ "ControlName" "Panel" "fieldName" "frame_bottomGrip" "xpos" "4" - "ypos" "357" - "wide" "346" + "ypos" "264" + "wide" "252" "tall" "2" "autoResize" "0" "pinCorner" "0" @@ -60,7 +60,7 @@ "xpos" "0" "ypos" "4" "wide" "2" - "tall" "351" + "tall" "258" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -74,10 +74,10 @@ { "ControlName" "Panel" "fieldName" "frame_rightGrip" - "xpos" "357" + "xpos" "264" "ypos" "4" "wide" "2" - "tall" "346" + "tall" "252" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -108,7 +108,7 @@ { "ControlName" "Panel" "fieldName" "frame_trGrip" - "xpos" "355" + "xpos" "262" "ypos" "0" "wide" "4" "tall" "4" @@ -126,7 +126,7 @@ "ControlName" "Panel" "fieldName" "frame_blGrip" "xpos" "0" - "ypos" "355" + "ypos" "262" "wide" "4" "tall" "4" "autoResize" "0" @@ -142,8 +142,8 @@ { "ControlName" "Panel" "fieldName" "frame_brGrip" - "xpos" "350" - "ypos" "350" + "xpos" "257" + "ypos" "257" "wide" "9" "tall" "9" "autoResize" "0" @@ -161,7 +161,7 @@ "fieldName" "frame_caption" "xpos" "0" "ypos" "0" - "wide" "354" + "wide" "261" "tall" "12" "autoResize" "0" "pinCorner" "0" @@ -178,8 +178,8 @@ "fieldName" "frame_minimize" "xpos" "0" "ypos" "0" - "wide" "8" - "tall" "8" + "wide" "4" + "tall" "4" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -206,8 +206,8 @@ "fieldName" "frame_maximize" "xpos" "0" "ypos" "0" - "wide" "8" - "tall" "8" + "wide" "4" + "tall" "4" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -234,8 +234,8 @@ "fieldName" "frame_mintosystray" "xpos" "0" "ypos" "0" - "wide" "8" - "tall" "8" + "wide" "4" + "tall" "4" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -261,7 +261,7 @@ { "ControlName" "Button" "fieldName" "frame_close" - "xpos" "335" + "xpos" "242" "ypos" "8" "wide" "17" "tall" "17" @@ -316,11 +316,11 @@ { "ControlName" "ComboBox" "fieldName" "SpeedoUnits" - "xpos" "88" - "ypos" "108" - "wide" "120" - "tall" "17" - "autoResize" "1" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" + "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" "pin_corner_to_sibling" "0" @@ -338,10 +338,10 @@ { "ControlName" "ComboBox" "fieldName" "SyncType" - "xpos" "52" - "ypos" "256" - "wide" "170" - "tall" "16" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -360,10 +360,10 @@ { "ControlName" "ComboBox" "fieldName" "SyncColorize" - "xpos" "72" - "ypos" "273" - "wide" "70" - "tall" "16" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -382,10 +382,10 @@ { "ControlName" "CvarToggleCheckButton" "fieldName" "SpeedoShow" - "xpos" "8" - "ypos" "40" - "wide" "218" - "tall" "11" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -410,10 +410,10 @@ { "ControlName" "CvarToggleCheckButton" "fieldName" "SpeedoShowJump" - "xpos" "8" - "ypos" "69" - "wide" "312" - "tall" "16" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -438,10 +438,10 @@ { "ControlName" "CvarToggleCheckButton" "fieldName" "ShowSpeedoHvel" - "xpos" "8" - "ypos" "56" - "wide" "217" - "tall" "11" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -466,10 +466,10 @@ { "ControlName" "CvarToggleCheckButton" "fieldName" "SpeedoShowColor" - "xpos" "8" - "ypos" "85" - "wide" "320" - "tall" "16" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -494,10 +494,10 @@ { "ControlName" "CvarToggleCheckButton" "fieldName" "SyncShow" - "xpos" "8" - "ypos" "224" - "wide" "161" - "tall" "16" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -514,18 +514,18 @@ "centerwrap" "0" "textinsetx" "6" "textinsety" "0" - "auto_wide_tocontents" "0" - "use_proportional_insets" "0" + "auto_wide_tocontents" "1" + "use_proportional_insets" "1" "Default" "0" } "SyncShowBar" { "ControlName" "CvarToggleCheckButton" "fieldName" "SyncShowBar" - "xpos" "8" - "ypos" "240" - "wide" "144" - "tall" "16" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -542,18 +542,18 @@ "centerwrap" "0" "textinsetx" "6" "textinsety" "0" - "auto_wide_tocontents" "0" - "use_proportional_insets" "0" + "auto_wide_tocontents" "1" + "use_proportional_insets" "1" "Default" "0" } "ButtonsShow" { "ControlName" "CvarToggleCheckButton" "fieldName" "ButtonsShow" - "xpos" "8" - "ypos" "168" - "wide" "336" - "tall" "16" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -578,17 +578,17 @@ { "ControlName" "Button" "fieldName" "ApplyButton" - "xpos" "234" - "ypos" "273" - "wide" "40" - "tall" "16" + "xpos" "0" + "ypos" "0" + "wide" "34" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" "pin_corner_to_sibling" "0" "pin_to_sibling_corner" "0" "visible" "1" - "enabled" "0" + "enabled" "1" "tabPosition" "0" "labelText" "#GameUI_Apply" "textAlignment" "west" @@ -607,10 +607,10 @@ { "ControlName" "Label" "fieldName" "SyncLabel" - "xpos" "4" - "ypos" "212" - "wide" "144" - "tall" "8" + "xpos" "2" + "ypos" "113" + "wide" "76" + "tall" "4" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -634,10 +634,10 @@ { "ControlName" "Label" "fieldName" "SpeedoLabel" - "xpos" "6" - "ypos" "25" - "wide" "80" - "tall" "16" + "xpos" "3" + "ypos" "13" + "wide" "117" + "tall" "8" "autoResize" "1" "pinCorner" "0" "RoundedCorners" "15" @@ -661,10 +661,10 @@ { "ControlName" "Label" "fieldName" "KeysLabel" - "xpos" "4" - "ypos" "155" - "wide" "40" - "tall" "8" + "xpos" "2" + "ypos" "82" + "wide" "21" + "tall" "4" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -688,10 +688,10 @@ { "ControlName" "Label" "fieldName" "SpeedoUnitsLabel" - "xpos" "12" - "ypos" "107" - "wide" "75" - "tall" "16" + "xpos" "10" + "ypos" "54" + "wide" "40" + "tall" "8" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -708,17 +708,17 @@ "centerwrap" "0" "textinsetx" "0" "textinsety" "0" - "auto_wide_tocontents" "0" + "auto_wide_tocontents" "1" "use_proportional_insets" "0" } "SyncTypeLabel" { "ControlName" "Label" "fieldName" "SyncTypeLabel" - "xpos" "11" - "ypos" "256" - "wide" "65" - "tall" "11" + "xpos" "5" + "ypos" "136" + "wide" "34" + "tall" "5" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -735,18 +735,18 @@ "centerwrap" "0" "textinsetx" "0" "textinsety" "0" - "auto_wide_tocontents" "0" + "auto_wide_tocontents" "1" "use_proportional_insets" "0" } "SyncColorTypeLabel" { "ControlName" "Label" "fieldName" "SyncColorTypeLabel" - "xpos" "10" - "ypos" "273" - "wide" "59" - "tall" "12" - "autoResize" "0" + "xpos" "1" + "ypos" "186" + "wide" "57" + "tall" "15" + "autoResize" "1" "pinCorner" "0" "RoundedCorners" "15" "pin_corner_to_sibling" "0" @@ -762,17 +762,17 @@ "centerwrap" "0" "textinsetx" "0" "textinsety" "0" - "auto_wide_tocontents" "0" + "auto_wide_tocontents" "1" "use_proportional_insets" "0" } "BuildModeDialog" { "ControlName" "BuildModeDialog" "fieldName" "BuildModeDialog" - "xpos" "61" - "ypos" "100" - "wide" "210" - "tall" "289" + "xpos" "33" + "ypos" "19" + "wide" "160" + "tall" "224" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" diff --git a/mp/src/game/client/client_momentum.vpc b/mp/src/game/client/client_momentum.vpc index 6782758655..1ee5eaf982 100644 --- a/mp/src/game/client/client_momentum.vpc +++ b/mp/src/game/client/client_momentum.vpc @@ -60,7 +60,7 @@ $Project "Client (Momentum)" } } } - } + } $File "momentum\ui\MomentumSettingsDialog.cpp" $File "momentum\ui\IMomentumSettingsPanel.h" @@ -75,13 +75,14 @@ $Project "Client (Momentum)" $File "momentum\ui\ClientTimesDisplay.cpp" $File "momentum\ui\IVersionWarnPanel.h" $File "momentum\ui\VersionWarnPanel.cpp" + $File "momentum\ui\VersionWarnPanel.h" $File "momentum\ui\hud_versioninfo.cpp" - $File "momentum\ui\hud_mapfinished.cpp" + $File "momentum\ui\hud_mapfinished.cpp" $File "momentum\ui\hud_mapfinished.h" - $File "momentum\ui\hud_keypress.cpp" - $File "hl2\hud_credits.cpp" - $File "hl2\hud_weaponselection.cpp" - $File "hud_chat.cpp" + $File "momentum\ui\hud_keypress.cpp" + $File "hl2\hud_credits.cpp" + $File "hl2\hud_weaponselection.cpp" + $File "hud_chat.cpp" $File "momentum\ui\hud_comparisons.cpp" $File "momentum\ui\hud_comparisons.h" $File "momentum\ui\hud_mapinfo.cpp" diff --git a/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp b/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp index 67ee6d898d..9217c31205 100644 --- a/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp +++ b/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp @@ -17,7 +17,7 @@ class CMomentumSettingsPanel : public vgui::Frame DECLARE_CLASS_SIMPLE(CMomentumSettingsPanel, vgui::Frame); //CMomentumSettingsPanel : This Class / vgui::Frame : BaseClass - CMomentumSettingsPanel(vgui::VPANEL parent); // Constructor + CMomentumSettingsPanel(VPANEL parent); // Constructor ~CMomentumSettingsPanel() {}; // Destructor void Activate() override; @@ -49,11 +49,16 @@ CMomentumSettingsPanel::CMomentumSettingsPanel(vgui::VPANEL parent) : BaseClass(nullptr, "CMomentumSettingsPanel") { SetParent(parent); + + LoadControlSettings("resource/ui/MomentumSettingsPanel.res"); + SetPaintBackgroundType(1); SetRoundedCorners(PANEL_ROUND_CORNER_ALL); SetKeyBoardInputEnabled(true); SetMouseInputEnabled(true); + SetMinimumSize(500, 500); + SetProportional(true); SetTitleBarVisible(true); SetMinimizeButtonVisible(false); @@ -112,10 +117,9 @@ CMomentumSettingsPanel::CMomentumSettingsPanel(vgui::VPANEL parent) m_pApplyButton->AddActionSignalTarget(m_pSyncShowBar); m_pApplyButton->AddActionSignalTarget(m_pButtonsShow); - SetScheme("ClientScheme"); + //SetScheme("ClientScheme"); //SetScheme(vgui::scheme()->LoadSchemeFromFile("resource/ClientScheme.res", "ClientScheme")); - - LoadControlSettings("resource/ui/MomentumSettingsPanel.res"); + LoadSettings(); ivgui()->AddTickSignal(GetVPanel()); @@ -135,11 +139,11 @@ class CMomentumSettingsPanelInterface : public MomentumSettingsPanel { settings_panel = nullptr; } - void Create(vgui::VPANEL parent) + void Create(vgui::VPANEL parent) override { settings_panel = new CMomentumSettingsPanel(parent); } - void Destroy() + void Destroy() override { if (settings_panel) { @@ -147,14 +151,14 @@ class CMomentumSettingsPanelInterface : public MomentumSettingsPanel delete settings_panel; } } - void Activate(void) + void Activate(void) override { if (settings_panel) { settings_panel->Activate(); } } - void Close() + void Close() override { if (settings_panel) { @@ -163,12 +167,10 @@ class CMomentumSettingsPanelInterface : public MomentumSettingsPanel } }; static CMomentumSettingsPanelInterface g_SettingsPanel; -MomentumSettingsPanel* momentum_settings = (MomentumSettingsPanel*) &g_SettingsPanel; - -ConVar cl_showsettingspanel("cl_showsettingspanel", "0", FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE - | FCVAR_SERVER_CAN_EXECUTE | FCVAR_HIDDEN, "Sets the state of settings panel"); +MomentumSettingsPanel* momentum_settings = static_cast(&g_SettingsPanel); -CON_COMMAND(mom_settings_show, "Shows the settings") +CON_COMMAND_F(mom_settings_show, "Shows the settings panel.\n", FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE + | FCVAR_SERVER_CAN_EXECUTE | FCVAR_HIDDEN) { momentum_settings->Activate(); } @@ -194,7 +196,7 @@ void CMomentumSettingsPanel::LoadSettings() void CMomentumSettingsPanel::OnTick() { BaseClass::OnTick(); - vgui::GetAnimationController()->UpdateAnimations(system()->GetFrameTime()); + GetAnimationController()->UpdateAnimations(system()->GetFrameTime()); } void CMomentumSettingsPanel::Activate() From 1be39cb4e397005290503048153ec8de3c5081c1 Mon Sep 17 00:00:00 2001 From: Nick K Date: Mon, 20 Jun 2016 03:48:30 -0400 Subject: [PATCH 03/10] Fix scroll sensitivity bug Light scrolls are now detected again --- mp/src/game/client/momentum/ui/hud_keypress.cpp | 4 ++-- mp/src/game/server/momentum/mom_player.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mp/src/game/client/momentum/ui/hud_keypress.cpp b/mp/src/game/client/momentum/ui/hud_keypress.cpp index 55c03b0e72..2f5c3abbc9 100644 --- a/mp/src/game/client/momentum/ui/hud_keypress.cpp +++ b/mp/src/game/client/momentum/ui/hud_keypress.cpp @@ -195,10 +195,10 @@ void CHudKeyPressDisplay::OnThink() m_nButtons = pReplayEnt->m_nReplayButtons; m_nStrafes = pReplayEnt->m_iTotalStrafes; m_nJumps = pReplayEnt->m_iTotalJumps; - } + } else { - m_nButtons = ::input->GetButtonBits(1); + m_nButtons = ::input->GetButtonBits(engine->IsPlayingDemo()); if (g_MOMEventListener) { //we should only draw the strafe/jump counters when the timer is running diff --git a/mp/src/game/server/momentum/mom_player.cpp b/mp/src/game/server/momentum/mom_player.cpp index bdf3cef1b4..68dad3745a 100644 --- a/mp/src/game/server/momentum/mom_player.cpp +++ b/mp/src/game/server/momentum/mom_player.cpp @@ -269,7 +269,7 @@ void CMomentumPlayer::CheckForBhop() m_iSuccessiveBhops++; if (g_Timer->IsRunning()) { - int currentZone = m_RunData.m_iCurrentZone;//g_Timer->GetCurrentZoneNumber(); + int currentZone = m_RunData.m_iCurrentZone; m_RunStats.SetZoneJumps(0, m_RunStats.GetZoneJumps(0) + 1); m_RunStats.SetZoneJumps(currentZone, m_RunStats.GetZoneJumps(currentZone) + 1); } From 91771ff0954e580bb2812707c44dc2cc532c8634 Mon Sep 17 00:00:00 2001 From: Nick K Date: Mon, 20 Jun 2016 19:01:23 -0400 Subject: [PATCH 04/10] Fix settings panel layout Back to SourceScheme, for now --- .../resource/ui/MomentumSettingsPanel.res | 242 ++++++++++-------- .../momentum/ui/MomentumSettingsDialog.cpp | 128 +++++---- .../vgui_controls/cvartogglecheckbutton.h | 12 +- 3 files changed, 208 insertions(+), 174 deletions(-) diff --git a/mp/game/momentum/resource/ui/MomentumSettingsPanel.res b/mp/game/momentum/resource/ui/MomentumSettingsPanel.res index 54fbf9a7c9..c689913ba6 100644 --- a/mp/game/momentum/resource/ui/MomentumSettingsPanel.res +++ b/mp/game/momentum/resource/ui/MomentumSettingsPanel.res @@ -4,8 +4,8 @@ { "ControlName" "CMomentumSettingsPanel" "fieldName" "CMomentumSettingsPanel" - "xpos" "324" - "ypos" "96" + "xpos" "304" + "ypos" "144" "wide" "266" "tall" "266" "autoResize" "1" @@ -178,8 +178,8 @@ "fieldName" "frame_minimize" "xpos" "0" "ypos" "0" - "wide" "4" - "tall" "4" + "wide" "0" + "tall" "0" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -206,8 +206,8 @@ "fieldName" "frame_maximize" "xpos" "0" "ypos" "0" - "wide" "4" - "tall" "4" + "wide" "0" + "tall" "0" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -234,8 +234,8 @@ "fieldName" "frame_mintosystray" "xpos" "0" "ypos" "0" - "wide" "4" - "tall" "4" + "wide" "0" + "tall" "0" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -283,7 +283,7 @@ "textinsety" "2" "auto_wide_tocontents" "0" "use_proportional_insets" "0" - "Default" "1" + "Default" "0" } "frame_menu" { @@ -316,10 +316,10 @@ { "ControlName" "ComboBox" "fieldName" "SpeedoUnits" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "11" + "ypos" "100" + "wide" "96" + "tall" "17" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -338,10 +338,10 @@ { "ControlName" "ComboBox" "fieldName" "SyncType" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "16" + "ypos" "208" + "wide" "185" + "tall" "16" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -360,10 +360,10 @@ { "ControlName" "ComboBox" "fieldName" "SyncColorize" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "16" + "ypos" "241" + "wide" "56" + "tall" "16" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -382,10 +382,10 @@ { "ControlName" "CvarToggleCheckButton" "fieldName" "SpeedoShow" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "8" + "ypos" "26" + "wide" "96" + "tall" "16" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -398,6 +398,7 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "6" @@ -405,15 +406,17 @@ "auto_wide_tocontents" "0" "use_proportional_insets" "0" "Default" "0" + "cvar_name" "mom_speedometer" + "cvar_value" "1" } "SpeedoShowJump" { "ControlName" "CvarToggleCheckButton" "fieldName" "SpeedoShowJump" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "8" + "ypos" "56" + "wide" "189" + "tall" "16" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -426,6 +429,7 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "6" @@ -433,15 +437,17 @@ "auto_wide_tocontents" "0" "use_proportional_insets" "0" "Default" "0" + "cvar_name" "mom_speedometer_showlastjumpvel" + "cvar_value" "1" } "ShowSpeedoHvel" { "ControlName" "CvarToggleCheckButton" "fieldName" "ShowSpeedoHvel" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "8" + "ypos" "72" + "wide" "194" + "tall" "16" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -454,6 +460,7 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "6" @@ -461,15 +468,17 @@ "auto_wide_tocontents" "0" "use_proportional_insets" "0" "Default" "0" + "cvar_name" "mom_speedometer_hvel" + "cvar_value" "0" } "SpeedoShowColor" { "ControlName" "CvarToggleCheckButton" "fieldName" "SpeedoShowColor" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "8" + "ypos" "40" + "wide" "185" + "tall" "16" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -482,6 +491,7 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "6" @@ -489,15 +499,17 @@ "auto_wide_tocontents" "0" "use_proportional_insets" "0" "Default" "0" + "cvar_name" "mom_speedometer_colorize" + "cvar_value" "1" } "SyncShow" { "ControlName" "CvarToggleCheckButton" "fieldName" "SyncShow" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "9" + "ypos" "161" + "wide" "107" + "tall" "16" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -510,22 +522,25 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "6" "textinsety" "0" - "auto_wide_tocontents" "1" - "use_proportional_insets" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" "Default" "0" + "cvar_name" "mom_strafesync_draw" + "cvar_value" "1" } "SyncShowBar" { "ControlName" "CvarToggleCheckButton" "fieldName" "SyncShowBar" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "9" + "ypos" "176" + "wide" "96" + "tall" "16" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -538,22 +553,25 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "6" "textinsety" "0" - "auto_wide_tocontents" "1" - "use_proportional_insets" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" "Default" "0" + "cvar_name" "mom_strafesync_drawbar" + "cvar_value" "1" } "ButtonsShow" { "ControlName" "CvarToggleCheckButton" "fieldName" "ButtonsShow" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" + "xpos" "9" + "ypos" "130" + "wide" "200" + "tall" "16" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -566,6 +584,7 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "6" @@ -573,44 +592,17 @@ "auto_wide_tocontents" "0" "use_proportional_insets" "0" "Default" "0" - } - "ApplyButton" - { - "ControlName" "Button" - "fieldName" "ApplyButton" - "xpos" "0" - "ypos" "0" - "wide" "34" - "tall" "12" - "autoResize" "0" - "pinCorner" "0" - "RoundedCorners" "15" - "pin_corner_to_sibling" "0" - "pin_to_sibling_corner" "0" - "visible" "1" - "enabled" "1" - "tabPosition" "0" - "labelText" "#GameUI_Apply" - "textAlignment" "west" - "dulltext" "0" - "brighttext" "0" - "wrap" "0" - "centerwrap" "0" - "textinsetx" "6" - "textinsety" "0" - "auto_wide_tocontents" "0" - "use_proportional_insets" "0" - "command" "ApplyChanges" - "Default" "0" + "cvar_name" "mom_showkeypresses" + "cvar_value" "1" } "SyncLabel" { "ControlName" "Label" "fieldName" "SyncLabel" "xpos" "2" - "ypos" "113" - "wide" "76" - "tall" "4" + "ypos" "152" + "wide" "51" + "tall" "10" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -623,6 +615,7 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultSmall" "wrap" "0" "centerwrap" "0" "textinsetx" "0" @@ -634,10 +627,10 @@ { "ControlName" "Label" "fieldName" "SpeedoLabel" - "xpos" "3" - "ypos" "13" - "wide" "117" - "tall" "8" + "xpos" "2" + "ypos" "17" + "wide" "57" + "tall" "9" "autoResize" "1" "pinCorner" "0" "RoundedCorners" "15" @@ -650,6 +643,7 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultSmall" "wrap" "0" "centerwrap" "0" "textinsetx" "0" @@ -662,9 +656,9 @@ "ControlName" "Label" "fieldName" "KeysLabel" "xpos" "2" - "ypos" "82" - "wide" "21" - "tall" "4" + "ypos" "120" + "wide" "53" + "tall" "13" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -677,6 +671,7 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultSmall" "wrap" "0" "centerwrap" "0" "textinsetx" "0" @@ -688,10 +683,10 @@ { "ControlName" "Label" "fieldName" "SpeedoUnitsLabel" - "xpos" "10" - "ypos" "54" - "wide" "40" - "tall" "8" + "xpos" "4" + "ypos" "88" + "wide" "72" + "tall" "11" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -704,21 +699,22 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "0" "textinsety" "0" - "auto_wide_tocontents" "1" + "auto_wide_tocontents" "0" "use_proportional_insets" "0" } "SyncTypeLabel" { "ControlName" "Label" "fieldName" "SyncTypeLabel" - "xpos" "5" - "ypos" "136" - "wide" "34" - "tall" "5" + "xpos" "4" + "ypos" "194" + "wide" "48" + "tall" "12" "autoResize" "0" "pinCorner" "0" "RoundedCorners" "15" @@ -731,21 +727,22 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "0" "textinsety" "0" - "auto_wide_tocontents" "1" + "auto_wide_tocontents" "0" "use_proportional_insets" "0" } "SyncColorTypeLabel" { "ControlName" "Label" "fieldName" "SyncColorTypeLabel" - "xpos" "1" - "ypos" "186" - "wide" "57" - "tall" "15" + "xpos" "4" + "ypos" "226" + "wide" "65" + "tall" "9" "autoResize" "1" "pinCorner" "0" "RoundedCorners" "15" @@ -758,13 +755,44 @@ "textAlignment" "west" "dulltext" "0" "brighttext" "0" + "Font" "DefaultVerySmall" "wrap" "0" "centerwrap" "0" "textinsetx" "0" "textinsety" "0" - "auto_wide_tocontents" "1" + "auto_wide_tocontents" "0" "use_proportional_insets" "0" } + "ApplyButton" + { + "ControlName" "Button" + "fieldName" "ApplyButton" + "xpos" "224" + "ypos" "232" + "wide" "25" + "tall" "16" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "#GameUI_Apply" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "Font" "DefaultVerySmall" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "6" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "command" "ApplyChanges" + "Default" "0" + } "BuildModeDialog" { "ControlName" "BuildModeDialog" diff --git a/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp b/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp index 9217c31205..cf14a36a05 100644 --- a/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp +++ b/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp @@ -1,55 +1,51 @@ -//The following include files are necessary to allow your the panel .cpp to compile. #include "cbase.h" + #include "IMomentumSettingsPanel.h" -using namespace vgui; #include -#include #include +#include +#include #include #include -#include #include "momentum/mom_shareddefs.h" #include "tier0/memdbgon.h" +using namespace vgui; + class CMomentumSettingsPanel : public vgui::Frame { DECLARE_CLASS_SIMPLE(CMomentumSettingsPanel, vgui::Frame); - //CMomentumSettingsPanel : This Class / vgui::Frame : BaseClass + // CMomentumSettingsPanel : This Class / vgui::Frame : BaseClass - CMomentumSettingsPanel(VPANEL parent); // Constructor - ~CMomentumSettingsPanel() {}; // Destructor + CMomentumSettingsPanel(VPANEL parent); // Constructor + ~CMomentumSettingsPanel(){}; // Destructor void Activate() override; -protected: - //VGUI overrides: + protected: + // VGUI overrides: void OnTick() override; MESSAGE_FUNC_PTR(OnTextChanged, "TextChanged", panel); MESSAGE_FUNC_PTR(OnCheckboxChecked, "CheckButtonChecked", panel); - MESSAGE_FUNC(OnApplyChanges, "ApplyChanges") - { - m_pApplyButton->SetEnabled(false); - } + MESSAGE_FUNC(OnApplyChanges, "ApplyChanges") { m_pApplyButton->SetEnabled(false); } -private: + private: void LoadSettings(); - //Other used VGUI control Elements: + // Other used VGUI control Elements: ComboBox *m_pSpeedometerUnits, *m_pSyncType, *m_pSyncColorize; - CvarToggleCheckButton *m_pSpeedometerShow, *m_pSpeedometerShowLastJump, *m_pSpeedometerShowVerticalVel, *m_pSpeedometerColorize, - *m_pSyncShow, *m_pSyncShowBar, *m_pButtonsShow, - *m_pShowVersion; + CvarToggleCheckButton *m_pSpeedometerShow, *m_pSpeedometerShowLastJump, *m_pSpeedometerShowVerticalVel, + *m_pSpeedometerColorize, *m_pSyncShow, *m_pSyncShowBar, *m_pButtonsShow, *m_pShowVersion; Button *m_pApplyButton; - }; // Constuctor: Initializes the Panel -CMomentumSettingsPanel::CMomentumSettingsPanel(vgui::VPANEL parent) - : BaseClass(nullptr, "CMomentumSettingsPanel") +CMomentumSettingsPanel::CMomentumSettingsPanel(vgui::VPANEL parent) : BaseClass(nullptr, "CMomentumSettingsPanel") { SetParent(parent); + SetProportional(true); LoadControlSettings("resource/ui/MomentumSettingsPanel.res"); SetPaintBackgroundType(1); @@ -59,7 +55,6 @@ CMomentumSettingsPanel::CMomentumSettingsPanel(vgui::VPANEL parent) SetMinimumSize(500, 500); - SetProportional(true); SetTitleBarVisible(true); SetMinimizeButtonVisible(false); SetMaximizeButtonVisible(false); @@ -67,47 +62,51 @@ CMomentumSettingsPanel::CMomentumSettingsPanel(vgui::VPANEL parent) SetSizeable(false); SetMoveable(true); SetVisible(false); - - m_pSpeedometerUnits = new ComboBox(this, "SpeedoUnits", 3, false); + + m_pSpeedometerUnits = FindControl("SpeedoUnits"); + m_pSpeedometerUnits->SetNumberOfEditLines(3); m_pSpeedometerUnits->AddItem("#MOM_Settings_Speedometer_Units_UPS", nullptr); m_pSpeedometerUnits->AddItem("#MOM_Settings_Speedometer_Units_KPH", nullptr); m_pSpeedometerUnits->AddItem("#MOM_Settings_Speedometer_Units_MPH", nullptr); m_pSpeedometerUnits->AddActionSignalTarget(this); - m_pSyncType = new ComboBox(this, "SyncType", 2, false); + m_pSyncType = FindControl("SyncType"); + m_pSyncType->SetNumberOfEditLines(2); m_pSyncType->AddItem("#MOM_Settings_Sync_Type_Sync1", nullptr); m_pSyncType->AddItem("#MOM_Settings_Sync_Type_Sync2", nullptr); m_pSyncType->AddActionSignalTarget(this); - m_pSyncColorize = new ComboBox(this, "SyncColorize", 3, false); + m_pSyncColorize = FindControl("SyncColorize"); + m_pSyncColorize->SetNumberOfEditLines(3); m_pSyncColorize->AddItem("#MOM_Settings_Sync_Color_Type_None", nullptr); m_pSyncColorize->AddItem("#MOM_Settings_Sync_Color_Type_1", nullptr); m_pSyncColorize->AddItem("#MOM_Settings_Sync_Color_Type_2", nullptr); m_pSyncColorize->AddActionSignalTarget(this); - m_pSpeedometerShow = new CvarToggleCheckButton(this, "SpeedoShow", "#MOM_Settings_Speedometer_Show", "mom_speedometer", false); + m_pSpeedometerShow = FindControl>("SpeedoShow"); m_pSpeedometerShow->AddActionSignalTarget(this); - m_pSpeedometerShowLastJump = new CvarToggleCheckButton(this, "SpeedoShowJump", "#MOM_Settings_Speedometer_Show_Jump", - "mom_speedometer_showlastjumpvel", false); + + m_pSpeedometerShowLastJump = FindControl>("SpeedoShowJump"); m_pSpeedometerShowLastJump->AddActionSignalTarget(this); - m_pSpeedometerShowVerticalVel = new CvarToggleCheckButton(this, "ShowSpeedoHvel", "#MOM_Settings_Speedometer_Show_Hvel", - "mom_speedometer_hvel", false); + + m_pSpeedometerShowVerticalVel = FindControl>("ShowSpeedoHvel"); m_pSpeedometerShowVerticalVel->AddActionSignalTarget(this); - m_pSpeedometerColorize = new CvarToggleCheckButton(this, "SpeedoShowColor", "#MOM_Settings_Speedometer_Show_Color", - "mom_speedometer_colorize", false); + + m_pSpeedometerColorize = FindControl>("SpeedoShowColor"); m_pSpeedometerColorize->AddActionSignalTarget(this); - m_pSyncShow = new CvarToggleCheckButton(this, "SyncShow", "#MOM_Settings_Sync_Show", "mom_strafesync_draw", false); + m_pSyncShow = FindControl>("SyncShow"); m_pSyncShow->AddActionSignalTarget(this); - m_pSyncShowBar = new CvarToggleCheckButton(this, "SyncShowBar", "#MOM_Settings_Sync_Show_Bar", "mom_strafesync_drawbar", false); + + m_pSyncShowBar = FindControl>("SyncShowBar"); m_pSyncShowBar->AddActionSignalTarget(this); - m_pButtonsShow = new CvarToggleCheckButton(this, "ButtonsShow", "#MOM_Settings_Buttons_Show", "mom_showkeypresses", false); + m_pButtonsShow = FindControl>("ButtonsShow"); m_pButtonsShow->AddActionSignalTarget(this); - //MOM_TODO: have one for hud_versionwarn? + // MOM_TODO: have one for hud_versionwarn? - m_pApplyButton = new Button(this, "ApplyButton", "#GameUI_Apply", this); - m_pApplyButton->SetCommand("ApplyChanges"); + m_pApplyButton = FindControl