diff --git a/.gitattributes b/.gitattributes index 8309c7d75c..22614daea7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -43,9 +43,11 @@ README text CONTRIBUTING text LICENSE text +momentum_*.txt text +gameui_*.txt text + *.exe binary protoc binary ccache binary gtest_output_test_golden_lin.txt binary -mod_*_english.txt binary diff --git a/mp/game/momentum/momentum.fgd b/mp/game/momentum/momentum.fgd index a67df6265f..0e000f3af6 100644 --- a/mp/game/momentum/momentum.fgd +++ b/mp/game/momentum/momentum.fgd @@ -33,15 +33,12 @@ @SolidClass base(Trigger) = trigger_momentum_timer_start : "Trigger that starts the timer." [ - leavespeed(float) : "Max leave speed" : 290 : "Max speed (Units Per Second) the player will be able to leave the trigger if 'Limit Leave Speed' flag is set." bhopleavespeed(float) : "Max leave speed if player bhopped" : 250 : "Max speed (Units Per Second) the player will be able to leave the trigger if they bhopped inside the start zone, and 'Limit leave speed if player bhopped' flag is set." lookangles(angle) : "Look angles" : "0 0 0" : "Where player will look when teleported to start." spawnflags(flags) = [ 1 : "Limit leave speed" : 1 2 : "Use look angles" : 0 - 4 : "Check only XY for leave speed check" : 1 - 8 : "Limit leave speed if player bhopped" : 1 ] ] diff --git a/mp/game/momentum/resource/ClientScheme.res b/mp/game/momentum/resource/ClientScheme.res index f0219ae3c4..86bc7f6bb2 100644 --- a/mp/game/momentum/resource/ClientScheme.res +++ b/mp/game/momentum/resource/ClientScheme.res @@ -15,19 +15,23 @@ Scheme Colors { // base colors - "Orange" "255 176 0 255" - "OrangeDim" "255 176 0 120" - "LightOrange" "188 112 0 128" + "White" "255 255 255 255" + "Light Gray" "211 211 211 100" + "Gray" "128 128 128 150" + "Dark Gray" "64 64 64 200" - "Red" "192 28 0 140" - "Black" "0 0 0 196" - "TransparentBlack" "0 0 0 196" - "TransparentLightBlack" "0 0 0 90" - - "Blank" "0 0 0 0" - "ForTesting" "255 0 0 32" - "ForTesting_Magenta" "255 0 255 255" - "ForTesting_MagentaDim" "255 0 255 120" + "Red" "192 28 0 140" + "Black" "0 0 0 196" + "TransparentBlack" "0 0 0 196" + "TransparentLightBlack" "0 0 0 90" + + "Blank" "0 0 0 1" + + "MOM.Panel.Fg" "255 255 255 125" + "MOM.Panel.Bg" "0 0 0 76" + "MOM.Speedometer.Normal" "255 255 255 125" + "MOM.Speedometer.Increase" "30 150 210 255" + "MOM.Speedometer.Decrease" "255 75 75 255" } ///////////////////// BASE SETTINGS //////////////////////// @@ -36,10 +40,10 @@ Scheme // controls use these to determine their settings BaseSettings { - "FgColor" "0 128 255 255" + "FgColor" "255 255 255 255" "BgColor" "0 0 0 76" - "Panel.FgColor" "0 128 255 100" + "Panel.FgColor" "255 255 255 255" "Panel.BgColor" "0 0 0 76" "BrightFg" "128 255 255 255" @@ -81,26 +85,26 @@ Scheme ///HERE // vgui_controls color specifications - Border.Bright "LightOrange" // the lit side of a control - Border.Dark "LightOrange" // the dark/unlit side of a control + Border.Bright "Gray" // the lit side of a control + Border.Dark "Gray" // the dark/unlit side of a control Border.Selection "Blank" // the additional border color for displaying the default/selected button - Button.TextColor "Orange" + Button.TextColor "White" Button.BgColor "Blank" - Button.ArmedTextColor "Orange" + Button.ArmedTextColor "White" Button.ArmedBgColor "Red" - Button.DepressedTextColor "Orange" + Button.DepressedTextColor "White" Button.DepressedBgColor "Red" - CheckButton.TextColor "Orange" - CheckButton.SelectedTextColor "Orange" + CheckButton.TextColor "White" + CheckButton.SelectedTextColor "White" CheckButton.BgColor "TransparentBlack" CheckButton.Border1 "Border.Dark" // the left checkbutton border CheckButton.Border2 "Border.Bright" // the right checkbutton border - CheckButton.Check "Orange" // color of the check itself + CheckButton.Check "White" // color of the check itself - ComboBoxButton.ArrowColor "Orange" - ComboBoxButton.ArmedArrowColor "Orange" + ComboBoxButton.ArrowColor "White" + ComboBoxButton.ArmedArrowColor "White" ComboBoxButton.BgColor "TransparentBlack" ComboBoxButton.DisabledBgColor "Blank" @@ -119,70 +123,70 @@ Scheme FrameSystemButton.BgColor "Blank" FrameSystemButton.Icon "" FrameSystemButton.DisabledIcon "" - FrameTitleBar.TextColor "Orange" + FrameTitleBar.TextColor "White" FrameTitleBar.BgColor "Blank" - FrameTitleBar.DisabledTextColor "Orange" + FrameTitleBar.DisabledTextColor "White" FrameTitleBar.DisabledBgColor "Blank" - GraphPanel.FgColor "Orange" + GraphPanel.FgColor "White" GraphPanel.BgColor "TransparentBlack" - Label.TextDullColor "Orange" - Label.TextColor "Orange" - Label.TextBrightColor "Orange" - Label.SelectedTextColor "Orange" + Label.TextDullColor "White" + Label.TextColor "White" + Label.TextBrightColor "White" + Label.SelectedTextColor "White" Label.BgColor "Blank" Label.DisabledFgColor1 "Blank" - Label.DisabledFgColor2 "LightOrange" + Label.DisabledFgColor2 "Gray" - ListPanel.TextColor "Orange" + ListPanel.TextColor "White" ListPanel.BgColor "TransparentBlack" ListPanel.SelectedTextColor "Black" ListPanel.SelectedBgColor "Red" ListPanel.SelectedOutOfFocusBgColor "Red" - ListPanel.EmptyListInfoTextColor "Orange" + ListPanel.EmptyListInfoTextColor "White" - Menu.TextColor "Orange" + Menu.TextColor "White" Menu.BgColor "TransparentBlack" - Menu.ArmedTextColor "Orange" + Menu.ArmedTextColor "White" Menu.ArmedBgColor "Red" Menu.TextInset "6" - Chat.TypingText "Orange" + Chat.TypingText "White" - Panel.FgColor "OrangeDim" + Panel.FgColor "WhiteDim" Panel.BgColor "blank" - ProgressBar.FgColor "Orange" + ProgressBar.FgColor "White" ProgressBar.BgColor "TransparentBlack" - PropertySheet.TextColor "Orange" - PropertySheet.SelectedTextColor "Orange" + PropertySheet.TextColor "White" + PropertySheet.SelectedTextColor "White" PropertySheet.TransitionEffectTime "0.25" // time to change from one tab to another - RadioButton.TextColor "Orange" - RadioButton.SelectedTextColor "Orange" + RadioButton.TextColor "White" + RadioButton.SelectedTextColor "White" - RichText.TextColor "Orange" + RichText.TextColor "White" RichText.BgColor "Blank" - RichText.SelectedTextColor "Orange" + RichText.SelectedTextColor "White" RichText.SelectedBgColor "Blank" - ScrollBarButton.FgColor "Orange" + ScrollBarButton.FgColor "White" ScrollBarButton.BgColor "Blank" - ScrollBarButton.ArmedFgColor "Orange" + ScrollBarButton.ArmedFgColor "White" ScrollBarButton.ArmedBgColor "Blank" - ScrollBarButton.DepressedFgColor "Orange" + ScrollBarButton.DepressedFgColor "White" ScrollBarButton.DepressedBgColor "Blank" ScrollBarSlider.FgColor "Blank" // nob color ScrollBarSlider.BgColor "Blank" // slider background color - SectionedListPanel.HeaderTextColor "Orange" + SectionedListPanel.HeaderTextColor "White" SectionedListPanel.HeaderBgColor "Blank" SectionedListPanel.DividerColor "Black" - SectionedListPanel.TextColor "Orange" - SectionedListPanel.BrightTextColor "Orange" + SectionedListPanel.TextColor "White" + SectionedListPanel.BrightTextColor "White" SectionedListPanel.BgColor "TransparentLightBlack" SectionedListPanel.SelectedTextColor "Black" SectionedListPanel.SelectedBgColor "Red" @@ -195,17 +199,17 @@ Scheme Slider.DisabledTextColor1 "117 117 117 255" Slider.DisabledTextColor2 "30 30 30 255" - TextEntry.TextColor "Orange" + TextEntry.TextColor "White" TextEntry.BgColor "TransparentBlack" - TextEntry.CursorColor "Orange" - TextEntry.DisabledTextColor "Orange" + TextEntry.CursorColor "White" + TextEntry.DisabledTextColor "White" TextEntry.DisabledBgColor "Blank" TextEntry.SelectedTextColor "Black" TextEntry.SelectedBgColor "Red" TextEntry.OutOfFocusSelectedBgColor "Red" TextEntry.FocusEdgeColor "TransparentBlack" - ToggleButton.SelectedTextColor "Orange" + ToggleButton.SelectedTextColor "White" Tooltip.TextColor "TransparentBlack" Tooltip.BgColor "Red" @@ -215,7 +219,7 @@ Scheme WizardSubPanel.BgColor "Blank" // scheme-specific colors - "FgColor" "Orange" + "FgColor" "White" "BgColor" "TransparentBlack" "ViewportBG" "Blank" @@ -223,7 +227,7 @@ Scheme "team1" "255 64 64 255" // CT's "team2" "153 204 255 255" // T's - "MapDescriptionText" "Orange" // the text used in the map description window + "MapDescriptionText" "White" // the text used in the map description window "CT_Blue" "153 204 255 255" "T_Red" "255 64 64 255" "Hostage_Yellow" "Panel.FgColor" @@ -276,6 +280,18 @@ Scheme // describes all the fonts Fonts { + MomentumIcons + { + "1" + { + "name" "MomIcons" + "tall" "12" + "weight" "0" + "antialias" "1" + "additive" "1" + "custom" "1" + } + } Icons { "1" @@ -649,6 +665,43 @@ Scheme "custom" "1" } } + HudNumbersSmallBold + { + "1" + { + "name" "obsidian" + "tall" "16" + "weight" "1000" + "additive" "1" + "antialias" "1" + "custom" "1" + "bold" "1" + } + } + HudNumbersVerySmall + { + "1" + { + "name" "obsidian" + "tall" "11" + "weight" "1000" + "additive" "1" + "antialias" "1" + "custom" "1" + } + } + HudNumbersExtremelySmall + { + "1" + { + "name" "obsidian" + "tall" "9" + "weight" "600" + "additive" "1" + "antialias" "1" + "custom" "1" + } + } HudNumbersSmallGlow { "1" @@ -1688,14 +1741,12 @@ Scheme // // specifies all the custom (non-system) font files that need to be loaded to service the above described fonts CustomFontFiles - { + { "1" "resource/HALFLIFE2.ttf" - "1" "resource/HL2MP.ttf" - "1" "resource/obsidian.ttf" - "1" "resource/obsidianweaps.ttf" - "1" "resource/custom.ttf" - "2" "resource/HL2crosshairs.ttf" - "2" "resource/cs.ttf" + "1" "resource/MomIcons.ttf" + "2" "resource/HL2MP.ttf" + "3" "resource/HL2crosshairs.ttf" + "4" "resource/cs.ttf" } } diff --git a/mp/game/momentum/resource/GameMenu.res b/mp/game/momentum/resource/GameMenu.res index c134ecf243..4fbe2c7304 100644 --- a/mp/game/momentum/resource/GameMenu.res +++ b/mp/game/momentum/resource/GameMenu.res @@ -38,6 +38,12 @@ "InGameOrder" "90" } "6" + { + "label" "#MOM_Settings" + "command" "engine mom_settings_show" + "InGameOrder" "100" + } + "6" { "label" "#MOM_Credits" "command" "engine progress_enable \n map credits" @@ -49,20 +55,20 @@ { "label" "#MOM_QuitToMenu" "command" "engine disconnect" - "InGameOrder" "90" + "InGameOrder" "100" "OnlyInGame" "1" } "8" { "label" "" "command" "" - "InGameOrder" "100" + "InGameOrder" "110" } "9" { "label" "#GameUI_GameMenu_Quit" "command" "QuitNoConfirm" - "InGameOrder" "110" + "InGameOrder" "200" } } diff --git a/mp/game/momentum/resource/MomIcons.ttf b/mp/game/momentum/resource/MomIcons.ttf new file mode 100644 index 0000000000..808e262541 Binary files /dev/null and b/mp/game/momentum/resource/MomIcons.ttf differ diff --git a/mp/game/momentum/resource/SourceScheme.res b/mp/game/momentum/resource/SourceScheme.res new file mode 100644 index 0000000000..62385297f6 --- /dev/null +++ b/mp/game/momentum/resource/SourceScheme.res @@ -0,0 +1,1278 @@ +/////////////////////////////////////////////////////////// +// Tracker scheme resource file +// +// sections: +// Colors - all the colors used by the scheme +// BaseSettings - contains settings for app to use to draw controls +// Fonts - list of all the fonts used by app +// Borders - description of all the borders +// +/////////////////////////////////////////////////////////// +Scheme +{ + //////////////////////// COLORS /////////////////////////// + // color details + // this is a list of all the colors used by the scheme + Colors + { + // base colors + "White" "255 255 255 255" + "Light Gray" "211 211 211 100" + "Gray" "128 128 128 150" + "Dark Gray" "64 64 64 200" + + "Red" "192 28 0 140" + "Black" "0 0 0 196" + "TransparentBlack" "0 0 0 196" + "TransparentLightBlack" "0 0 0 90" + + "Blank" "0 0 0 1" + + "MOM.Panel.Fg" "255 255 255 125" + "MOM.Panel.Bg" "0 0 0 76" + "MomentumBlue" "30 150 210 255" + "MomentumRed" "255 75 75 255" + } + + ///////////////////// BASE SETTINGS //////////////////////// + // + // default settings for all panels + // controls use these to determine their settings + BaseSettings + { + // vgui_controls color specifications + Border.Bright "200 200 200 255" // the lit side of a control + Border.Dark "40 40 40 198" // the dark/unlit side of a control + Border.Selection "0 0 0 255" // the additional border color for displaying the default/selected button + Border.DarkSolid "40 40 40 255" + Border.Subtle "80 80 80 255" + + Button.TextColor "82 82 82 255" + Button.BgColor "227 227 227 255" + Button.ArmedTextColor "46 114 178 255" + Button.ArmedBgColor "240 240 240 255" + Button.DepressedTextColor "White" + Button.DepressedBgColor "84 178 245 255" + Button.FocusBorderColor "82 82 82 255" + + CheckButton.TextColor "White" + CheckButton.SelectedTextColor "White" + CheckButton.BgColor "MOM.Panel.Bg" + CheckButton.Border1 "Border.Subtle" // the left checkbutton border + CheckButton.Border2 "Border.Subtle" // the right checkbutton border + CheckButton.Check "118 189 118 255" // color of the check itself + CheckButton.HighlightFgColor "OffWhite" + CheckButton.ArmedBgColor "Blank" + CheckButton.DepressedBgColor "Blank" + CheckButton.DisabledBgColor "153 153 153 255" + + ComboBoxButton.ArrowColor "81 81 81 255" + ComboBoxButton.ArmedArrowColor "110 110 110 255" + ComboBoxButton.BgColor "Blank" + ComboBoxButton.DisabledBgColor "Blank" + + Frame.TitleTextInsetX 16 + Frame.ClientInsetX 8 + Frame.ClientInsetY 6 + Frame.BgColor "MOM.Panel.Bg" + Frame.OutOfFocusBgColor "97 100 102 240" + Frame.FocusTransitionEffectTime "0.3" // time it takes for a window to fade in/out on focus/out of focus + Frame.TransitionEffectTime "0.3" // time it takes for a window to fade in/out on open/close + Frame.AutoSnapRange "0" + FrameGrip.Color1 "200 200 200 196" + FrameGrip.Color2 "0 0 0 196" + FrameTitleButton.FgColor "200 200 200 196" + FrameTitleButton.BgColor "Blank" + FrameTitleButton.DisabledFgColor "255 255 255 192" + FrameTitleButton.DisabledBgColor "Blank" + FrameSystemButton.FgColor "Blank" + FrameSystemButton.BgColor "Blank" + FrameSystemButton.Icon "" + FrameSystemButton.DisabledIcon "" + FrameTitleBar.Font "Verdana" + FrameTitleBar.TextColor "255 255 255 204" + FrameTitleBar.BgColor "Blank" + FrameTitleBar.DisabledTextColor "255 255 255 91" + FrameTitleBar.DisabledBgColor "Blank" + + GraphPanel.FgColor "White" + GraphPanel.BgColor "TransparentBlack" + + Label.TextDullColor "DullWhite" + Label.TextColor "White" + Label.TextBrightColor "White" + Label.SelectedTextColor "White" + Label.BgColor "Blank" + Label.DisabledFgColor1 "110 110 110 255" + Label.DisabledFgColor2 "50 50 50 255" + + ListPanel.TextColor "White" + ListPanel.TextBgColor "Blank" + ListPanel.BgColor "MOM.Panel.Bg" + ListPanel.SelectedTextColor "White" + ListPanel.SelectedBgColor "MomentumBlue" + ListPanel.OutOfFocusSelectedTextColor "Gray" + ListPanel.SelectedOutOfFocusBgColor "132 183 241 100" + ListPanel.EmptyListInfoTextColor "Gray" + + Menu.TextColor "White" + Menu.BgColor "MOM.Panel.Bg" + Menu.ArmedTextColor "White" + Menu.ArmedBgColor "MomentumBlue" + Menu.TextInset "6" + + Panel.FgColor "DullWhite" + Panel.BgColor "Blank" + + ProgressBar.FgColor "White" + ProgressBar.BgColor "TransparentBlack" + + PropertySheet.TextColor "10 10 10 200" + PropertySheet.SelectedTextColor "10 10 10 255" + PropertySheet.SelectedBgColor "10 10 10 255" + PropertySheet.TransitionEffectTime "0.25" // time to change from one tab to another + PropertySheet.BgColor "0 0 0 255" + + RadioButton.TextColor "White" + RadioButton.SelectedTextColor "White" + + RichText.TextColor "White" + RichText.BgColor "TransparentBlack" + RichText.SelectedTextColor "White" + RichText.SelectedBgColor "MOM.Panel.Bg" + + ScrollBar.Wide 15 + + ScrollBarButton.FgColor "60 60 60 255" + ScrollBarButton.BgColor "207 207 207 255" + ScrollBarButton.ArmedFgColor "20 65 72 255" + ScrollBarButton.ArmedBgColor "210 237 255 255" + ScrollBarButton.DepressedFgColor "9 119 226 255" + ScrollBarButton.DepressedBgColor "31 207 248 255" + + ScrollBarSlider.FgColor "220 220 220 255" // nob color + ScrollBarSlider.BgColor "184 184 184 229" // slider background color + + SectionedListPanel.HeaderTextColor "White" + SectionedListPanel.HeaderBgColor "Blank" + SectionedListPanel.DividerColor "Dark Gray" + SectionedListPanel.TextColor "Light Gray" + SectionedListPanel.BrightTextColor "White" + SectionedListPanel.BgColor "MOM.Panel.Bg" + SectionedListPanel.SelectedTextColor "White" + SectionedListPanel.SelectedBgColor "MomentumBlue" + SectionedListPanel.OutOfFocusSelectedTextColor "White" + SectionedListPanel.OutOfFocusSelectedBgColor "132 183 241 100" + + Slider.NobColor "220 220 220 255" + Slider.TextColor "180 180 180 255" + Slider.TrackColor "184 184 184 229" + Slider.DisabledTextColor1 "110 110 110 255" + Slider.DisabledTextColor2 "50 50 50 255" + + TextEntry.TextColor "White" + TextEntry.BgColor "MOM.Panel.Bg" + TextEntry.CursorColor "Gray" + TextEntry.DisabledTextColor "Light Gray" + TextEntry.DisabledBgColor "TransparentBlack" + TextEntry.SelectedTextColor "White" + TextEntry.SelectedBgColor "MomentumBlue" + TextEntry.OutOfFocusSelectedBgColor "132 183 241 100" + TextEntry.FocusEdgeColor "0 0 0 196" + + ToggleButton.SelectedTextColor "White" + + Tooltip.TextColor "Light Gray" + Tooltip.BgColor "MOM.Panel.Bg" + + TreeView.BgColor "Light Gray" + + WizardSubPanel.BgColor "Blank" + + // scheme-specific colors + MainMenu.TextColor "White" + MainMenu.ArmedTextColor "Light Gray" + MainMenu.DepressedTextColor "Light Gray" + MainMenu.MenuItemHeight "32" + MainMenu.Inset "32" + MainMenu.Backdrop "0 0 0 175" + + Console.TextColor "White" + Console.DevTextColor "White" + } + + //////////////////////// FONTS ///////////////////////////// + // + // describes all the fonts + Fonts + { + // fonts are used in order that they are listed + // fonts listed later in the order will only be used if they fulfill a range not already filled + // if a font fails to load then the subsequent fonts will replace + // fonts are used in order that they are listed + "DebugFixed" + { + "1" + { + "name" "Courier New" + "tall" "10" + "weight" "500" + "antialias" "1" + } + } + // fonts are used in order that they are listed + "DebugFixedSmall" + { + "1" + { + "name" "Courier New" + "tall" "7" + "weight" "500" + "antialias" "1" + } + } + "DefaultFixedOutline" + { + "1" + { + "name" "Lucida Console" [$WINDOWS] + "name" "Lucida Console" [$X360] + "name" "Lucida Console" [$OSX] + "name" "Verdana" [$LINUX] + "tall" "14" [$LINUX] + "tall" "10" + "tall_lodef" "15" + "tall_hidef" "20" + "weight" "0" + "outline" "1" + } + } + "Default" + { + "1" + { + "name" "Tahoma" [!$LINUX] + "name" "Verdana" [$LINUX] + "tall" "16" + "weight" "500" + } + } + "DefaultBold" + { + "1" + { + "name" "Tahoma" [!$LINUX] + "name" "Verdana Bold" [$LINUX] + "tall" "16" + "weight" "1000" + } + } + "DefaultUnderline" + { + "1" + { + "name" "Tahoma" [!$LINUX] + "name" "Verdana" [$LINUX] + "tall" "16" + "weight" "500" + "underline" "1" + } + } + "DefaultSmall" + { + "1" + { + "name" "Tahoma" [!$LINUX] + "name" "Verdana" [$LINUX] + "tall" "12" [!$LINUX] + "tall" "16" [$LINUX] + "weight" "0" + } + } + "DefaultSmallDropShadow" + { + "1" + { + "name" "Tahoma" [!$LINUX] + "name" "Verdana" [$LINUX] + "tall" "13" + "weight" "0" + "dropshadow" "1" + } + } + "DefaultVerySmall" + { + "1" + { + "name" "Tahoma" [!$LINUX] + "name" "Verdana" [$LINUX] + "tall" "12" + "weight" "0" + } + } + + "DefaultLarge" + { + "1" + { + "name" "Tahoma" [!$LINUX] + "name" "Verdana" [$LINUX] + "tall" "18" + "weight" "0" + } + } + "UiBold" + { + "1" [$WIN32] + { + "name" "Tahoma" [!$LINUX] + "name" "Verdana" [$LINUX] + "tall" "12" + "weight" "1000" + } + "1" [$X360] + { + "name" "Tahoma" + "tall" "24" + "weight" "2000" + "outline" "1" + } + } + "ChapterTitle" [$X360] + { + "1" + { + "name" "Tahoma" + "tall" "20" + "tall_hidef" "28" + "weight" "2000" + "outline" "1" + } + } + "ChapterTitleBlur" [$X360] + { + "1" + { + "name" "Tahoma" + "tall" "20" + "tall_hidef" "28" + "weight" "2000" + "blur" "3" + "blur_hidef" "5" + } + } + "MenuLarge" + { + "1" + { + "name" "Verdana" + "tall" "16" + "weight" "1000" + "antialias" "1" + } + } + "AchievementTitleFont" + { + "1" + { + "name" "Verdana" + "tall" "20" + "weight" "1200" + "antialias" "1" + "outline" "1" + } + } + + "AchievementTitleFontSmaller" + { + "1" + { + "name" "Verdana" + "tall" "18" + "weight" "1200" + "antialias" "1" + //"outline" "1" + } + } + + + "AchievementDescriptionFont" + { + "1" + { + "name" "Verdana" + "tall" "15" + "weight" "1200" + "antialias" "1" + "outline" "1" + "yres" "0 480" + } + "2" + { + "name" "Verdana" + "tall" "20" + "weight" "1200" + "antialias" "1" + "outline" "1" + "yres" "481 10000" + } + } + + GameUIButtons + { + "1" [$X360] + { + "bitmap" "1" + "name" "Buttons" + "scalex" "0.63" + "scaley" "0.63" + "scalex_hidef" "1.0" + "scaley_hidef" "1.0" + "scalex_lodef" "0.75" + "scaley_lodef" "0.75" + } + } + "ConsoleText" + { + "1" + { + "name" "Lucida Console" [$WINDOWS] + "name" "Lucida Console" [$X360] + "name" "Lucida Console" [$OSX] + "name" "Verdana" [$LINUX] + "tall" "14" [$LINUX] + "tall" "10" + "weight" "500" + } + } + + // this is the symbol font + "Marlett" + { + "1" + { + "name" "Marlett" + "tall" "14" + "weight" "0" + "symbol" "1" + } + } + + "Trebuchet24" + { + "1" + { + "name" "Trebuchet MS" + "tall" "24" + "weight" "900" + } + } + + "Trebuchet20" + { + "1" + { + "name" "Trebuchet MS" + "tall" "20" + "weight" "900" + } + } + + "Trebuchet18" + { + "1" + { + "name" "Trebuchet MS" + "tall" "18" + "weight" "900" + } + } + + // HUD numbers + // We use multiple fonts to 'pulse' them in the HUD, hence the need for many of near size + "HUDNumber" + { + "1" + { + "name" "Trebuchet MS" + "tall" "40" + "weight" "900" + } + } + "HUDNumber1" + { + "1" + { + "name" "Trebuchet MS" + "tall" "41" + "weight" "900" + } + } + "HUDNumber2" + { + "1" + { + "name" "Trebuchet MS" + "tall" "42" + "weight" "900" + } + } + "HUDNumber3" + { + "1" + { + "name" "Trebuchet MS" + "tall" "43" + "weight" "900" + } + } + "HUDNumber4" + { + "1" + { + "name" "Trebuchet MS" + "tall" "44" + "weight" "900" + } + } + "HUDNumber5" + { + "1" + { + "name" "Trebuchet MS" + "tall" "45" + "weight" "900" + } + } + "DefaultFixed" + { + "1" + { + "name" "Lucida Console" [$WINDOWS] + "name" "Lucida Console" [$X360] + "name" "Verdana" [$LINUX] + "tall" "11" [$LINUX] + "tall" "10" + "weight" "0" + } +// "1" +// { +// "name" "FixedSys" +// "tall" "20" +// "weight" "0" +// } + } + + "DefaultFixedDropShadow" + { + "1" + { + "name" "Lucida Console" [$WINDOWS] + "name" "Lucida Console" [$X360] + "name" "Lucida Console" [$OSX] + "name" "Courier" [$LINUX] + "tall" "14" [$LINUX] + "tall" "10" + "weight" "0" + "dropshadow" "1" + } +// "1" +// { +// "name" "FixedSys" +// "tall" "20" +// "weight" "0" +// } + } + + "CloseCaption_Normal" + { + "1" + { + "name" "Tahoma" [!$POSIX] + "name" "Verdana" [$POSIX] + "tall" "16" + "weight" "500" + } + } + "CloseCaption_Italic" + { + "1" + { + "name" "Tahoma" + "tall" "16" + "weight" "500" + "italic" "1" + } + } + "CloseCaption_Bold" + { + "1" + { + "name" "Tahoma" [!$POSIX] + "name" "Verdana Bold" [$POSIX] + "tall" "16" + "weight" "900" + } + } + "CloseCaption_BoldItalic" + { + "1" + { + "name" "Tahoma" [!$POSIX] + "name" "Verdana Bold Italic" [$POSIX] + "tall" "16" + "weight" "900" + "italic" "1" + } + } + + TitleFont + { + "1" + { + "name" "HalfLife2" + "tall" "72" + "weight" "400" + "antialias" "1" + "custom" "1" + } + } + + TitleFont2 + { + "1" + { + "name" "HalfLife2" + "tall" "120" + "weight" "400" + "antialias" "1" + "custom" "1" + } + } + + AppchooserGameTitleFont [$X360] + { + "1" + { + "name" "Trebuchet MS" + "tall" "16" + "tall_hidef" "24" + "weight" "900" + "antialias" "1" + } + } + + AppchooserGameTitleFontBlur [$X360] + { + "1" + { + "name" "Trebuchet MS" + "tall" "16" + "tall_hidef" "24" + "weight" "900" + "blur" "3" + "blur_hidef" "5" + "antialias" "1" + } + } + + StatsTitle [$WIN32] + { + "1" + { + "name" "Arial" [!$POSIX] + "name" "Verdana Bold" [$POSIX] + "weight" "2000" + "tall" "20" + "antialias" "1" + } + } + + StatsText [$WIN32] + { + "1" + { + "name" "Arial" [!$POSIX] + "name" "Verdana Bold" [$POSIX] + "weight" "2000" + "tall" "18" + "antialias" "1" + } + } + + AchievementItemTitle [$WIN32] + { + "1" + { + "name" "Arial" [!$POSIX] + "name" "Verdana Bold" [$POSIX] + "weight" "1500" + "tall" "16" [!$POSIX] + "tall" "18" [$POSIX] + "antialias" "1" + } + } + + AchievementItemDate [$WIN32] + { + "1" + { + "name" "Arial" [!$POSIX] + "name" "Verdana Bold" [$POSIX] + "weight" "1500" + "tall" "16" + "antialias" "1" + } + } + + + StatsPageText + { + "1" + { + "name" "Arial" [!$POSIX] + "name" "Verdana Bold" [$POSIX] + "weight" "1500" + "tall" "14" [!$POSIX] + "tall" "16" [$POSIX] + "antialias" "1" + } + } + + AchievementItemTitleLarge [$WIN32] + { + "1" + { + "name" "Arial" [!$POSIX] + "name" "Verdana Bold" [$POSIX] + "weight" "1500" + "tall" "18" [!$POSIX] + "tall" "19" [$POSIX] + "antialias" "1" + } + } + + AchievementItemDescription [$WIN32] + { + "1" + { + "name" "Arial" [!$POSIX] + "name" "Verdana" [$POSIX] + "weight" "1000" + "tall" "14" [!$POSIX] + "tall" "15" [$POSIX] + "antialias" "1" + } + } + + + "ServerBrowserTitle" + { + "1" + { + "name" "Tahoma" [!$POSIX] + "name" "Verdana" [$POSIX] + "tall" "35" + "tall_lodef" "40" + "weight" "500" + "additive" "0" + "antialias" "1" + } + } + + "ServerBrowserSmall" + { + "1" + { + "name" "Tahoma" + "tall" "16" + "weight" "0" + "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A + "yres" "480 599" + } + "2" + { + "name" "Tahoma" + "tall" "16" + "weight" "0" + "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A + "yres" "600 767" + } + "3" + { + "name" "Tahoma" + "tall" "16" + "weight" "0" + "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A + "yres" "768 1023" + "antialias" "1" + } + "4" + { + "name" "Tahoma" + "tall" "19" + "weight" "0" + "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A + "yres" "1024 1199" + "antialias" "1" + } + "5" + { + "name" "Tahoma" + "tall" "19" + "weight" "0" + "range" "0x0000 0x017F" // Basic Latin, Latin-1 Supplement, Latin Extended-A + "yres" "1200 6000" + "antialias" "1" + } + } + + } + + // + //////////////////// BORDERS ////////////////////////////// + // + // describes all the border types + Borders + { + BaseBorder SubtleBorder + ButtonBorder RaisedBorder + ComboBoxBorder DepressedBorder + MenuBorder SubtleBorder + BrowserBorder DepressedBorder + PropertySheetBorder RaisedBorder + + FrameBorder + { + // rounded corners for frames + //"backgroundtype" "2" + + Left + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Right + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Top + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Bottom + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + } + + SubtleBorder + { + "inset" "0 0 0 0" + Left + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + + Right + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + + Top + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + + Bottom + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + } + + DepressedBorder + { + "inset" "0 0 0 0" + Left + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Right + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Top + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Bottom + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + } + RaisedBorder + { + "inset" "0 0 0 0" + Left + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + + Right + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + + Top + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + + Bottom + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + } + + TitleButtonBorder + { + "backgroundtype" "0" + } + + TitleButtonDisabledBorder + { + "backgroundtype" "0" + } + + TitleButtonDepressedBorder + { + "backgroundtype" "0" + } + + ScrollBarButtonBorder + { + "inset" "0 0 0 0" + Left + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Right + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Top + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Bottom + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + } + + ScrollBarButtonDepressedBorder + { + "inset" "0 0 0 0" + Left + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Right + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Top + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Bottom + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + } + + TabBorder + { + "inset" "1 1 1 1" + + render + { + "0" "fill( x0, y0, x1, y1, Black )" + } + + render_bg + { + "0" "fill( x0, y0, x1, y1, Orange )" + } + + } + + TabActiveBorder + { + "inset" "1 1 1 1" + Left + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + + Top + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + + Right + { + "1" + { + "color" "Border.Subtle" + "offset" "0 0" + } + } + + } + + + ToolTipBorder + { + "inset" "0 0 1 0" + Left + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Right + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Top + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Bottom + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + } + + // this is the border used for default buttons (the button that gets pressed when you hit enter) + ButtonKeyFocusBorder + { + "inset" "0 0 0 0" + Left + { + "1" + { + "color" "Border.Selection" + "offset" "0 0" + } + } + Top + { + "1" + { + "color" "Border.Selection" + "offset" "0 0" + } + } + Right + { + "1" + { + "color" "Border.Selection" + "offset" "0 0" + } + } + Bottom + { + "1" + { + "color" "Border.Selection" + "offset" "0 0" + } + } + } + + ButtonDepressedBorder + { + "inset" "0 0 0 0" + Left + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 1" + } + } + + Right + { + "1" + { + "color" "Border.DarkSolid" + "offset" "1 0" + } + } + + Top + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + + Bottom + { + "1" + { + "color" "Border.DarkSolid" + "offset" "0 0" + } + } + } + } + + //////////////////////// CUSTOM FONT FILES ///////////////////////////// + // + // specifies all the custom (non-system) font files that need to be loaded to service the above described fonts + CustomFontFiles + { + "1" "resource/HALFLIFE2.ttf" + "1" "resource/TypoGraphica.ttf" + "2" "resource/HL2EP2.ttf" + } +} diff --git a/mp/game/momentum/resource/gameui_english.txt b/mp/game/momentum/resource/gameui_english.txt index 77abcee8a6..ff333582f8 100644 Binary files a/mp/game/momentum/resource/gameui_english.txt and b/mp/game/momentum/resource/gameui_english.txt differ diff --git a/mp/game/momentum/resource/gameui_norwegian.txt b/mp/game/momentum/resource/gameui_norwegian.txt new file mode 100644 index 0000000000..4a6c0932cd Binary files /dev/null and b/mp/game/momentum/resource/gameui_norwegian.txt differ diff --git a/mp/game/momentum/resource/gameui_spanish.txt b/mp/game/momentum/resource/gameui_spanish.txt index be5d12af6a..d5d92e8c9b 100644 Binary files a/mp/game/momentum/resource/gameui_spanish.txt and b/mp/game/momentum/resource/gameui_spanish.txt differ diff --git a/mp/game/momentum/resource/modevents.res b/mp/game/momentum/resource/modevents.res index 762ea44f89..cdfd53ba66 100644 --- a/mp/game/momentum/resource/modevents.res +++ b/mp/game/momentum/resource/modevents.res @@ -27,25 +27,51 @@ "modevents" { - "player_death" // a game event, name may be 32 charaters long + "timer_stopped" { - "userid" "short" // user ID who died - "attacker" "short" // user ID who killed - "weapon" "string" // weapon name killed used + "avg_sync" "float" + "avg_sync2" "float" + "avg_vel" "float" + "max_vel" "float" + "start_vel" "float" + "end_vel" "float" + "num_strafes" "short" + "num_jumps" "short" } - - "teamplay_round_start" // round restart + "new_stage" { - "full_reset" "bool" // is this a full reset of the map + "stage_num" "byte" + "stage_ticks" "long" //time is in ticks + "avg_sync" "float" + "avg_sync2" "float" + "avg_vel" "float" + "max_vel" "float" + "stage_enter_vel" "float" + "num_strafes" "short" + "num_jumps" "short" } - - "spec_target_updated" + "run_save" { + "run_saved" "bool" + "run_posted" "bool" } - - "achievement_earned" + "timer_started" { - "player" "byte" // entindex of the player - "achievement" "short" // achievement ID + "timer_isrunning" "bool" + } + "player_inside_mapzone" + { + "inside_startzone" "bool" + "inside_endzone" "bool" + "map_finished" "bool" + } + "keypress" + { + "num_jumps" "short" + "num_strafes" "short" + } + "practice_mode" + { + "has_practicemode" "bool" } } diff --git a/mp/game/momentum/resource/momentum_english.txt b/mp/game/momentum/resource/momentum_english.txt index c40dc7d564..93acacc466 100644 Binary files a/mp/game/momentum/resource/momentum_english.txt and b/mp/game/momentum/resource/momentum_english.txt differ diff --git a/mp/game/momentum/resource/momentum_norwegian.txt b/mp/game/momentum/resource/momentum_norwegian.txt new file mode 100644 index 0000000000..d5ea8b5004 Binary files /dev/null and b/mp/game/momentum/resource/momentum_norwegian.txt differ diff --git a/mp/game/momentum/resource/ui/MomentumSettingsPanel.res b/mp/game/momentum/resource/ui/MomentumSettingsPanel.res new file mode 100644 index 0000000000..e34057f1d9 --- /dev/null +++ b/mp/game/momentum/resource/ui/MomentumSettingsPanel.res @@ -0,0 +1,787 @@ +"resource/ui/MomentumSettingsPanel.res" +{ + "CMomentumSettingsPanel" + { + "ControlName" "CMomentumSettingsPanel" + "fieldName" "CMomentumSettingsPanel" + "xpos" "337" + "ypos" "74" + "wide" "360" + "tall" "360" + "autoResize" "1" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "settitlebarvisible" "1" + "title" "#MOM_Settings" + } + "frame_topGrip" + { + "ControlName" "Panel" + "fieldName" "frame_topGrip" + "xpos" "4" + "ypos" "0" + "wide" "351" + "tall" "2" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_bottomGrip" + { + "ControlName" "Panel" + "fieldName" "frame_bottomGrip" + "xpos" "4" + "ypos" "357" + "wide" "346" + "tall" "2" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_leftGrip" + { + "ControlName" "Panel" + "fieldName" "frame_leftGrip" + "xpos" "0" + "ypos" "4" + "wide" "2" + "tall" "351" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_rightGrip" + { + "ControlName" "Panel" + "fieldName" "frame_rightGrip" + "xpos" "357" + "ypos" "4" + "wide" "2" + "tall" "346" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_tlGrip" + { + "ControlName" "Panel" + "fieldName" "frame_tlGrip" + "xpos" "0" + "ypos" "0" + "wide" "4" + "tall" "4" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_trGrip" + { + "ControlName" "Panel" + "fieldName" "frame_trGrip" + "xpos" "355" + "ypos" "0" + "wide" "4" + "tall" "4" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_blGrip" + { + "ControlName" "Panel" + "fieldName" "frame_blGrip" + "xpos" "0" + "ypos" "355" + "wide" "4" + "tall" "4" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_brGrip" + { + "ControlName" "Panel" + "fieldName" "frame_brGrip" + "xpos" "350" + "ypos" "350" + "wide" "9" + "tall" "9" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_caption" + { + "ControlName" "Panel" + "fieldName" "frame_caption" + "xpos" "0" + "ypos" "0" + "wide" "354" + "tall" "12" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_minimize" + { + "ControlName" "Button" + "fieldName" "frame_minimize" + "xpos" "0" + "ypos" "0" + "wide" "8" + "tall" "8" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "labelText" "0" + "textAlignment" "north-west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "2" + "textinsety" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "frame_maximize" + { + "ControlName" "Button" + "fieldName" "frame_maximize" + "xpos" "0" + "ypos" "0" + "wide" "8" + "tall" "8" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "labelText" "1" + "textAlignment" "north-west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "2" + "textinsety" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "frame_mintosystray" + { + "ControlName" "Button" + "fieldName" "frame_mintosystray" + "xpos" "0" + "ypos" "0" + "wide" "8" + "tall" "8" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "labelText" "o" + "textAlignment" "north-west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "2" + "textinsety" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "command" "MinimizeToSysTray" + "Default" "0" + } + "frame_close" + { + "ControlName" "Button" + "fieldName" "frame_close" + "xpos" "335" + "ypos" "8" + "wide" "17" + "tall" "17" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "r" + "textAlignment" "north-west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "4" + "textinsety" "2" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "1" + } + "frame_menu" + { + "ControlName" "FrameSystemButton" + "fieldName" "frame_menu" + "xpos" "3" + "ypos" "4" + "wide" "9" + "tall" "9" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "SpeedoUnits" + { + "ControlName" "ComboBox" + "fieldName" "SpeedoUnits" + "xpos" "88" + "ypos" "108" + "wide" "120" + "tall" "17" + "autoResize" "1" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "textHidden" "0" + "editable" "0" + "maxchars" "-1" + "NumericInputOnly" "0" + "unicode" "0" + } + "SyncType" + { + "ControlName" "ComboBox" + "fieldName" "SyncType" + "xpos" "52" + "ypos" "256" + "wide" "170" + "tall" "16" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "textHidden" "0" + "editable" "0" + "maxchars" "-1" + "NumericInputOnly" "0" + "unicode" "0" + } + "SyncColorize" + { + "ControlName" "ComboBox" + "fieldName" "SyncColorize" + "xpos" "72" + "ypos" "273" + "wide" "70" + "tall" "16" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "textHidden" "0" + "editable" "0" + "maxchars" "-1" + "NumericInputOnly" "0" + "unicode" "0" + } + "SpeedoShow" + { + "ControlName" "CvarToggleCheckButton" + "fieldName" "SpeedoShow" + "xpos" "8" + "ypos" "40" + "wide" "218" + "tall" "11" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "#MOM_Settings_Speedometer_Show" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "6" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "SpeedoShowJump" + { + "ControlName" "CvarToggleCheckButton" + "fieldName" "SpeedoShowJump" + "xpos" "8" + "ypos" "69" + "wide" "312" + "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" "#MOM_Settings_Speedometer_Show_Jump" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "6" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "ShowSpeedoHvel" + { + "ControlName" "CvarToggleCheckButton" + "fieldName" "ShowSpeedoHvel" + "xpos" "8" + "ypos" "56" + "wide" "217" + "tall" "11" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "#MOM_Settings_Speedometer_Show_Hvel" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "6" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "SpeedoShowColor" + { + "ControlName" "CvarToggleCheckButton" + "fieldName" "SpeedoShowColor" + "xpos" "8" + "ypos" "85" + "wide" "320" + "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" "#MOM_Settings_Speedometer_Show_Color" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "6" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "SyncShow" + { + "ControlName" "CvarToggleCheckButton" + "fieldName" "SyncShow" + "xpos" "8" + "ypos" "224" + "wide" "161" + "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" "#MOM_Settings_Sync_Show" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "6" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "SyncShowBar" + { + "ControlName" "CvarToggleCheckButton" + "fieldName" "SyncShowBar" + "xpos" "8" + "ypos" "240" + "wide" "144" + "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" "#MOM_Settings_Sync_Show_Bar" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "6" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "ButtonsShow" + { + "ControlName" "CvarToggleCheckButton" + "fieldName" "ButtonsShow" + "xpos" "8" + "ypos" "168" + "wide" "336" + "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" "#MOM_Settings_Buttons_Show" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "6" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "ApplyButton" + { + "ControlName" "Button" + "fieldName" "ApplyButton" + "xpos" "234" + "ypos" "273" + "wide" "40" + "tall" "16" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "0" + "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" + } + "SyncLabel" + { + "ControlName" "Label" + "fieldName" "SyncLabel" + "xpos" "4" + "ypos" "212" + "wide" "144" + "tall" "8" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "#MOM_Settings_Sync_Label" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "SpeedoLabel" + { + "ControlName" "Label" + "fieldName" "SpeedoLabel" + "xpos" "6" + "ypos" "25" + "wide" "80" + "tall" "16" + "autoResize" "1" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "#MOM_Settings_Speedometer_Label" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "KeysLabel" + { + "ControlName" "Label" + "fieldName" "KeysLabel" + "xpos" "4" + "ypos" "155" + "wide" "40" + "tall" "8" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "#MOM_Settings_Buttons_Label" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "SpeedoUnitsLabel" + { + "ControlName" "Label" + "fieldName" "SpeedoUnitsLabel" + "xpos" "12" + "ypos" "107" + "wide" "75" + "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" "#MOM_Settings_Speedometer_Units_Label" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "SyncTypeLabel" + { + "ControlName" "Label" + "fieldName" "SyncTypeLabel" + "xpos" "11" + "ypos" "256" + "wide" "65" + "tall" "11" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "#MOM_Settings_Sync_Type_Label" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "SyncColorTypeLabel" + { + "ControlName" "Label" + "fieldName" "SyncColorTypeLabel" + "xpos" "10" + "ypos" "273" + "wide" "59" + "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" "#MOM_Settings_Sync_Color_Type_Label" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "BuildModeDialog" + { + "ControlName" "BuildModeDialog" + "fieldName" "BuildModeDialog" + "xpos" "61" + "ypos" "100" + "wide" "210" + "tall" "289" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "settitlebarvisible" "1" + "title" "#Frame_Untitled" + } +} diff --git a/mp/game/momentum/resource/ui/versionwarnpanel.res b/mp/game/momentum/resource/ui/versionwarnpanel.res new file mode 100644 index 0000000000..af09405341 --- /dev/null +++ b/mp/game/momentum/resource/ui/versionwarnpanel.res @@ -0,0 +1,387 @@ +"resource/ui/versionwarnpanel.res" +{ + "VersionWarnPanel" + { + "ControlName" "CVersionWarnPanel" + "fieldName" "VersionWarnPanel" + "xpos" "c-225" + "ypos" "c-50" + "wide" "450" + "tall" "100" + "alpha" "255" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "32" + "settitlebarvisible" "1" + "title" "New version available" + } + "frame_topGrip" + { + "ControlName" "Panel" + "fieldName" "frame_topGrip" + "xpos" "8" + "ypos" "0" + "wide" "496" + "tall" "5" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_bottomGrip" + { + "ControlName" "Panel" + "fieldName" "frame_bottomGrip" + "xpos" "8" + "ypos" "507" + "wide" "486" + "tall" "5" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_leftGrip" + { + "ControlName" "Panel" + "fieldName" "frame_leftGrip" + "xpos" "0" + "ypos" "8" + "wide" "5" + "tall" "496" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_rightGrip" + { + "ControlName" "Panel" + "fieldName" "frame_rightGrip" + "xpos" "507" + "ypos" "8" + "wide" "5" + "tall" "486" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_tlGrip" + { + "ControlName" "Panel" + "fieldName" "frame_tlGrip" + "xpos" "0" + "ypos" "0" + "wide" "8" + "tall" "8" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_trGrip" + { + "ControlName" "Panel" + "fieldName" "frame_trGrip" + "xpos" "504" + "ypos" "0" + "wide" "8" + "tall" "8" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_blGrip" + { + "ControlName" "Panel" + "fieldName" "frame_blGrip" + "xpos" "0" + "ypos" "504" + "wide" "8" + "tall" "8" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_brGrip" + { + "ControlName" "Panel" + "fieldName" "frame_brGrip" + "xpos" "494" + "ypos" "494" + "wide" "18" + "tall" "18" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_caption" + { + "ControlName" "Panel" + "fieldName" "frame_caption" + "xpos" "3" + "ypos" "-16" + "wide" "502" + "tall" "23" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + } + "frame_minimize" + { + "ControlName" "Button" + "fieldName" "frame_minimize" + "xpos" "0" + "ypos" "0" + "wide" "18" + "tall" "18" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "labelText" "0" + "textAlignment" "north-west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "2" + "textinsety" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "frame_maximize" + { + "ControlName" "Button" + "fieldName" "frame_maximize" + "xpos" "0" + "ypos" "0" + "wide" "18" + "tall" "18" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "labelText" "1" + "textAlignment" "north-west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "2" + "textinsety" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "frame_mintosystray" + { + "ControlName" "Button" + "fieldName" "frame_mintosystray" + "xpos" "0" + "ypos" "0" + "wide" "18" + "tall" "18" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "labelText" "o" + "textAlignment" "north-west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "2" + "textinsety" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "command" "MinimizeToSysTray" + "Default" "0" + } + "frame_close" + { + "ControlName" "Button" + "fieldName" "frame_close" + "xpos" "487" + "ypos" "8" + "wide" "13" + "tall" "13" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "r" + "textAlignment" "north-west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "2" + "textinsety" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + "command" "turnoff" + } + "frame_menu" + { + "ControlName" "FrameSystemButton" + "fieldName" "frame_menu" + "xpos" "7" + "ypos" "8" + "wide" "18" + "tall" "18" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "CloseButton" + { + "ControlName" "Button" + "fieldName" "CloseButton" + "xpos" "0" + "ypos" "0" + "wide" "18" + "tall" "18" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "labelText" "#GameUI_Close" + "textAlignment" "north-west" + "dulltext" "0" + "Font" "Default" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "2" + "textinsety" "1" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + "Default" "0" + } + "ReleaseText" + { + "ControlName" "URLLabel" + "fieldName" "ReleaseText" + "xpos" "25" + "ypos" "50" + "wide" "640" + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "visible" "1" + "enabled" "1" + "textAlignment" "west" + "labelText" "#MOM_NewVersion" + "dulltext" "0" + "brighttext" "1" + "Font" "Default" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + } + "BuildModeDialog" + { + "ControlName" "BuildModeDialog" + "fieldName" "BuildModeDialog" + "xpos" "327" + "ypos" "301" + "wide" "300" + "tall" "420" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "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 aea3755a1d..8d5e77da05 100644 --- a/mp/game/momentum/scripts/HudLayout.res +++ b/mp/game/momentum/scripts/HudLayout.res @@ -4,32 +4,39 @@ HudSpeedMeter { "fieldName" "HudSpeedMeter" - "xpos" "c-57" - "ypos" "432" - "wide" "114" - "tall" "36" + "xpos" "c-60" + "ypos" "310" + "wide" "120" + "tall" "40" "visible" "1" "enabled" "1" - "PaintBackgroundType" "2" - "text_xpos" "8" - "text_ypos" "20" - "digit_xpos" "50" - "digit_ypos" "2" - } + "NumberFont" "HudNumbersSmallBold" + "SmallNumberFont" "HudNumbersExtremelySmall" + "text_ypos" "5" + "digit_ypos" "15" + "digit2_ypos" "30" + "PrimaryValueColor" "MOM.Panel.Fg" + "SecondaryValueColor" "Light Gray" + "LabelColor" "MOM.Panel.Fg" + "BgColor" "Blank" + } //Timer HudTimer { "fieldName" "HudTimer" - "xpos" "c-68" - "ypos" "c+75" - "wide" "136" + "xpos" "c-50" + "ypos" "c+150" + "wide" "100" "tall" "50" "visible" "1" "enabled" "1" "PaintBackgroundType" "2" + "TimerFont" "HudNumbersSmallBold" "TextFont" "HudHintTextLarge" + "SmallTextFont" "HudHintTextSmall" + "TextColor" "MOM.Panel.Fg" "centerTime" "1" //If true, won't use time_xpos, centering the text instead - "time_xpos" "58" + "time_xpos" "50" "time_ypos" "3" "centerCps" "1" //If true, won't use cps_xpos, centering the text instead "cps_xpos" "50" @@ -37,7 +44,32 @@ "centerStage" "1" //If true, won't use stage_xpos, centering the text instead "stage_xpos" "50" "stage_ypos" "34" - } + } + //Strafe Sync Meter + CHudSyncMeter + { + "fieldName" "CHudSyncMeter" + "xpos" "c-25" + "ypos" "c+198" + "wide" "50" + "tall" "30" + "visible" "1" + "enabled" "1" + "TextFont" "HudNumbersVerySmall" + "NumberFont" "HudNumbersSmall" + "SmallNumberFont" "HudNumbersVerySmall" + "PaintBackgroundType" "2" + "text_xpos" "15" + "text_ypos" "2" + "digit_xpos" "12" + "digit_ypos" "12" + "digit2_xpos" "30" + "digit2_ypos" "16" + "PrimaryValueColor" "MOM.Panel.Fg" + "SecondaryValueColor" "MOM.Panel.Fg" + "LabelColor" "White" + "BgColor" "Blank" + } //The design for in-game menus CHudMenuStatic { @@ -54,8 +86,74 @@ "enabled" "1" "wide" "200" "tall" "20" + "TextFont" "HudHintTextSmall" + } + CHudSyncBar + { + "fieldName" "CHudSyncBar" + "xpos" "c-60" + "ypos" "c+227" + "wide" "120" + "tall" "10" + "InitialValue" "0" + "BackgroundColor" "MOM.Panel.Bg" + "FillColor" "255 255 255 225" + "visible" "1" + "enabled" "1" + } + CHudMapFinishedDialog + { + "fieldName" "CHudMapFinishedDialog" + "xpos" "c-125" + "ypos" "c-100" + "wide" "250" + "tall" "120" + "visible" "1" + "enabled" "1" "TextFont" "Default" - } + "time_xpos" "20" + "time_ypos" "5" + "strafes_xpos" "20" + "strafes_xpos" "25" + "jumps_xpos" "20" + "jumps_xpos" "45" + "sync_xpos" "20" + "sync_xpos" "65" + "sync2_xpos" "20" + "sync2_ypos" "85" + "startvel_xpos" "120" + "startvel_ypos" "5" + "endvel_xpos" "120" + "endvel_ypos" "25" + "avgvel_xpos" "120" + "avgvel_ypos" "45" + "maxvel_xpos" "120" + "maxvel_ypos" "65" + "runsave_ypos" "95" + "runupload_ypos""105" + } + CHudKeyPressDisplay + { + "fieldName" "CHudKeyPressDisplay" + "xpos" "c+265" + "ypos" "c+150" + "wide" "150" + "tall" "100" + "visible" "1" + "enabled" "1" + "top_row_ypos" "5" + "mid_row_ypos" "20" + "lower_row_ypos" "35" + "jump_row_ypos" "45" + "duck_row_ypos" "55" + "strafe_count_xpos" "100" + "jump_count_xpos" "100" + "TextFont" "MomentumIcons" + "CounterTextFont" "HudNumbersVerySmall" + "WordTextFont" "HudNumbersVerySmall" + "KeyPressedColor" "MOM.Panel.Fg" + "KeyOutlineColor" "Dark Gray" + } HudHealth [$WIN32] { "fieldName" "HudHealth" diff --git a/mp/src/creategameprojects.ps1 b/mp/src/creategameprojects.ps1 index 0c11522961..9b73bcc202 100644 --- a/mp/src/creategameprojects.ps1 +++ b/mp/src/creategameprojects.ps1 @@ -22,7 +22,7 @@ if (!$path) } $hl2exe = Join-Path $path hl2.exe -$hl2args = "-game momentum -novid +developer 2 +sv_cheats 1 -console" +$hl2args = "-game momentum -window -w 1600 -h 900 -novid +developer 2 -console" $momentum_sym = Join-Path $path momentum $momentum = [System.IO.Path]::GetFullPath("..\game\momentum") diff --git a/mp/src/game/client/cdll_client_int.cpp b/mp/src/game/client/cdll_client_int.cpp index 5b8f10d962..77a7e9e762 100644 --- a/mp/src/game/client/cdll_client_int.cpp +++ b/mp/src/game/client/cdll_client_int.cpp @@ -170,6 +170,10 @@ 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" @@ -1089,6 +1093,8 @@ 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 2a80eb3334..01939fbaf9 100644 --- a/mp/src/game/client/client_momentum.vpc +++ b/mp/src/game/client/client_momentum.vpc @@ -60,19 +60,28 @@ $Project "Client (Momentum)" } } } - } - - $File "momentum\ui\speedometer.cpp" - $File "momentum\ui\versionwarn.cpp" + } + + $File "momentum\ui\MomentumSettingsDialog.cpp" + $File "momentum\ui\IMomentumSettingsPanel.h" + $File "momentum\ui\hud_speedometer.cpp" + $File "momentum\ui\hud_strafesync.cpp" + $File "momentum\ui\hud_timer.cpp" $File "momentum\ui\hud_cp_menu.cpp" $File "momentum\ui\hud_menu_static.h" $File "momentum\ui\hud_menu_static.cpp" - $File "momentum\ui\timer.cpp" + $File "momentum\ui\hud_fillablebar.h" $File "momentum\ui\ClientTimesDisplay.h" $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_mapfinished.cpp" + $File "momentum\ui\hud_keypress.cpp" $File "hl2\hud_credits.cpp" $File "hl2\hud_weaponselection.cpp" $File "hud_chat.cpp" + } $File "momentum\client_events.h" @@ -149,6 +158,8 @@ $Project "Client (Momentum)" $File "momentum\c_corpse.cpp" $File "momentum\clientmode_mom_normal.h" $File "momentum\clientmode_mom_normal.cpp" + $File "momentum\mom_event_listener.h" + $File "momentum\mom_event_listener.cpp" } $Folder "JSON Parser" diff --git a/mp/src/game/client/hud_numericdisplay.cpp b/mp/src/game/client/hud_numericdisplay.cpp index de9c84f1b1..ca1023a75b 100644 --- a/mp/src/game/client/hud_numericdisplay.cpp +++ b/mp/src/game/client/hud_numericdisplay.cpp @@ -101,48 +101,60 @@ void CHudNumericDisplay::SetIsTime(bool state) m_bIsTime = state; } -//----------------------------------------------------------------------------- -// Purpose: paints a number at the specified position -//----------------------------------------------------------------------------- -void CHudNumericDisplay::PaintNumbers(HFont font, int xpos, int ypos, int value) +void CHudNumericDisplay::PaintNumbers(HFont font, int xpos, int ypos, int value, bool atLeast2Digits) { - surface()->DrawSetTextFont(font); - wchar_t unicode[6]; - if ( !m_bIsTime ) - { - V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d", value); - } - else - { - int iMinutes = value / 60; - int iSeconds = value - iMinutes * 60; + surface()->DrawSetTextFont(font); + wchar_t unicode[6]; + if (!m_bIsTime) + { + if (atLeast2Digits && value < 10) + { + V_snwprintf(unicode, ARRAYSIZE(unicode), L"0%d", value); + } + else + { + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d", value); + } + } + else + { + int iMinutes = value / 60; + int iSeconds = value - iMinutes * 60; #ifdef PORTAL - // portal uses a normal font for numbers so we need the seperate to be a renderable ':' char - if ( iSeconds < 10 ) - V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d:0%d", iMinutes, iSeconds ); - else - V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d:%d", iMinutes, iSeconds ); + // portal uses a normal font for numbers so we need the seperate to be a renderable ':' char + if (iSeconds < 10) + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d:0%d", iMinutes, iSeconds); + else + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d:%d", iMinutes, iSeconds); #else - if ( iSeconds < 10 ) - V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d`0%d", iMinutes, iSeconds ); - else - V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d`%d", iMinutes, iSeconds ); + if (iSeconds < 10) + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d`0%d", iMinutes, iSeconds); + else + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d`%d", iMinutes, iSeconds); #endif - } - - // adjust the position to take into account 3 characters - int charWidth = surface()->GetCharacterWidth(font, '0'); - if (value < 100 && m_bIndent) - { - xpos += charWidth; - } - if (value < 10 && m_bIndent) - { - xpos += charWidth; - } + } + + // adjust the position to take into account 3 characters + int charWidth = surface()->GetCharacterWidth(font, '0'); + if (value < 100 && m_bIndent) + { + xpos += charWidth; + } + if (value < 10 && m_bIndent) + { + xpos += charWidth; + } + + surface()->DrawSetTextPos(xpos, ypos); + surface()->DrawUnicodeString(unicode); +} - surface()->DrawSetTextPos(xpos, ypos); - surface()->DrawUnicodeString( unicode ); +//----------------------------------------------------------------------------- +// Purpose: paints a number at the specified position +//----------------------------------------------------------------------------- +void CHudNumericDisplay::PaintNumbers(HFont font, int xpos, int ypos, int value) +{ + PaintNumbers(font, xpos, ypos, value, false); } //----------------------------------------------------------------------------- @@ -151,7 +163,7 @@ void CHudNumericDisplay::PaintNumbers(HFont font, int xpos, int ypos, int value) void CHudNumericDisplay::PaintLabel( void ) { surface()->DrawSetTextFont(m_hTextFont); - surface()->DrawSetTextColor(GetFgColor()); + surface()->DrawSetTextColor(m_LabelColor); surface()->DrawSetTextPos(text_xpos, text_ypos); surface()->DrawUnicodeString( m_LabelText ); } @@ -164,7 +176,7 @@ void CHudNumericDisplay::Paint() if (m_bDisplayValue) { // draw our numbers - surface()->DrawSetTextColor(GetFgColor()); + surface()->DrawSetTextColor(m_PrimaryValueColor); PaintNumbers(m_hNumberFont, digit_xpos, digit_ypos, m_iValue); // draw the overbright blur @@ -177,7 +189,7 @@ void CHudNumericDisplay::Paint() else { // draw a percentage of the last one - Color col = GetFgColor(); + Color col = m_PrimaryValueColor; col[3] *= fl; surface()->DrawSetTextColor(col); PaintNumbers(m_hNumberGlowFont, digit_xpos, digit_ypos, m_iValue); @@ -188,8 +200,8 @@ void CHudNumericDisplay::Paint() // total ammo if (m_bDisplaySecondaryValue) { - surface()->DrawSetTextColor(GetFgColor()); - PaintNumbers(m_hSmallNumberFont, digit2_xpos, digit2_ypos, m_iSecondaryValue); + surface()->DrawSetTextColor(m_SecondaryValueColor); + PaintNumbers(m_hSmallNumberFont, digit2_xpos, digit2_ypos, m_iSecondaryValue, true); } PaintLabel(); diff --git a/mp/src/game/client/hud_numericdisplay.h b/mp/src/game/client/hud_numericdisplay.h index b004f91826..2ec1417b32 100644 --- a/mp/src/game/client/hud_numericdisplay.h +++ b/mp/src/game/client/hud_numericdisplay.h @@ -42,6 +42,7 @@ class CHudNumericDisplay : public vgui::Panel virtual void PaintLabel(); virtual void PaintNumbers(vgui::HFont font, int xpos, int ypos, int value); + virtual void PaintNumbers(vgui::HFont font, int xpos, int ypos, int value, bool atLeast2Digits); protected: @@ -55,6 +56,10 @@ class CHudNumericDisplay : public vgui::Panel CPanelAnimationVar( float, m_flBlur, "Blur", "0" ); CPanelAnimationVar( Color, m_TextColor, "TextColor", "FgColor" ); CPanelAnimationVar( Color, m_Ammo2Color, "Ammo2Color", "FgColor" ); + CPanelAnimationVar( Color, m_PrimaryValueColor, "PrimaryValueColor", "FgColor" ); + CPanelAnimationVar( Color, m_SecondaryValueColor, "SecondaryValueColor", "FgColor" ); + CPanelAnimationVar( Color, m_LabelColor, "LabelColor", "FgColor" ); + CPanelAnimationVar( vgui::HFont, m_hNumberFont, "NumberFont", "HudNumbers" ); CPanelAnimationVar( vgui::HFont, m_hNumberGlowFont, "NumberGlowFont", "HudNumbersGlow" ); diff --git a/mp/src/game/client/momentum/c_mom_player.cpp b/mp/src/game/client/momentum/c_mom_player.cpp index 30d6f00c06..6a8c76b8dc 100644 --- a/mp/src/game/client/momentum/c_mom_player.cpp +++ b/mp/src/game/client/momentum/c_mom_player.cpp @@ -12,6 +12,10 @@ RecvPropBool(RECVINFO(m_bResumeZoom)), RecvPropInt(RECVINFO(m_iLastZoom)), RecvPropBool(RECVINFO(m_bAutoBhop)), RecvPropBool(RECVINFO(m_bDidPlayerBhop)), +RecvPropInt(RECVINFO(m_iSuccessiveBhops)), +RecvPropFloat(RECVINFO(m_flStrafeSync)), +RecvPropFloat(RECVINFO(m_flStrafeSync2)), +RecvPropFloat(RECVINFO(m_flLastJumpVel)), //RecvPropDataTable(RECVINFO_DT(m_HL2Local), 0, &REFERENCE_RECV_TABLE(DT_HL2Local)), //RecvPropBool(RECVINFO(m_fIsSprinting)), END_RECV_TABLE() @@ -54,8 +58,4 @@ bool C_MomentumPlayer::CanGrabLadder(const Vector& pos, const Vector& normal) } return false; -} -bool C_MomentumPlayer::HasAutoBhop() -{ - return m_bAutoBhop; } \ No newline at end of file diff --git a/mp/src/game/client/momentum/c_mom_player.h b/mp/src/game/client/momentum/c_mom_player.h index 10871e5f13..3cbb740fd5 100644 --- a/mp/src/game/client/momentum/c_mom_player.h +++ b/mp/src/game/client/momentum/c_mom_player.h @@ -21,8 +21,9 @@ class C_MomentumPlayer : public C_BasePlayer void SurpressLadderChecks(const Vector& pos, const Vector& normal); bool CanGrabLadder(const Vector& pos, const Vector& normal); - bool HasAutoBhop(); bool DidPlayerBhop() { return m_bDidPlayerBhop; } + bool HasAutoBhop() { return m_bAutoBhop; } + void ResetStrafeSync(); int m_iShotsFired; int m_iDirection; @@ -31,6 +32,11 @@ class C_MomentumPlayer : public C_BasePlayer bool m_bAutoBhop; bool m_bDidPlayerBhop; + float m_flStrafeSync, m_flStrafeSync2; + float m_flLastJumpVel; + + int m_nLastRunTime; + void GetBulletTypeParameters( int iBulletType, float &fPenetrationPower, @@ -59,6 +65,10 @@ class C_MomentumPlayer : public C_BasePlayer float lateral_max, int direction_change); + float m_flStartSpeed; + float m_flEndSpeed; + int m_iSuccessiveBhops; + private: CountdownTimer m_ladderSurpressionTimer; Vector m_lastLadderNormal; @@ -67,6 +77,8 @@ class C_MomentumPlayer : public C_BasePlayer bool m_duckUntilOnGround; float m_flStamina; + + friend class CMomentumGameMovement; }; diff --git a/mp/src/game/client/momentum/clientmode_mom_normal.cpp b/mp/src/game/client/momentum/clientmode_mom_normal.cpp index da80f37aa6..90ee69269d 100644 --- a/mp/src/game/client/momentum/clientmode_mom_normal.cpp +++ b/mp/src/game/client/momentum/clientmode_mom_normal.cpp @@ -72,7 +72,6 @@ class CHudViewport : public CBaseViewport AddNewPanel(CreatePanelByName(PANEL_TIMES), "PANEL_TIMES"); BaseClass::CreateDefaultPanels();// MOM_TODO: do we want the other panels? - /* don't create any panels yet*/ }; }; diff --git a/mp/src/game/client/momentum/mom_event_listener.cpp b/mp/src/game/client/momentum/mom_event_listener.cpp new file mode 100644 index 0000000000..2d035647ab --- /dev/null +++ b/mp/src/game/client/momentum/mom_event_listener.cpp @@ -0,0 +1,70 @@ +#include "cbase.h" + +#include "mom_event_listener.h" +#include "tier0/memdbgon.h" + +void C_Momentum_EventListener::Init() +{ + //add listeners for all of our custom events + if (gameeventmanager) + { + gameeventmanager->AddListener(this, "timer_stopped", false); + gameeventmanager->AddListener(this, "new_stage", false); + gameeventmanager->AddListener(this, "run_save", false); + gameeventmanager->AddListener(this, "timer_started", false); + gameeventmanager->AddListener(this, "player_inside_mapzone", false); + gameeventmanager->AddListener(this, "practice_mode", false); + gameeventmanager->AddListener(this, "keypress", false); + } +} + +void C_Momentum_EventListener::FireGameEvent(IGameEvent *pEvent) +{ + if (!Q_strcmp("timer_stopped", pEvent->GetName())) + { + m_flStartSpeed = pEvent->GetFloat("start_vel"); + m_flEndSpeed = pEvent->GetFloat("end_vel"); + m_flStrafeSyncAvg = pEvent->GetFloat("avg_sync"); + m_flStrafeSync2Avg = pEvent->GetFloat("avg_sync2"); + m_flVelocityAvg = pEvent->GetFloat("avg_vel"); + m_flVelocityMax = pEvent->GetFloat("max_vel"); + } + if (!Q_strcmp("new_stage", pEvent->GetName())) + { + m_iCurrentStage = pEvent->GetInt("stage_num"); + m_iStageTicks[m_iCurrentStage] = pEvent->GetInt("stage_ticks"); + m_flStageStrafeSyncAvg[m_iCurrentStage] = pEvent->GetFloat("avg_sync"); + m_flStageStrafeSync2Avg[m_iCurrentStage] = pEvent->GetFloat("avg_sync2"); + m_flStageStartSpeed[m_iCurrentStage] = pEvent->GetFloat("start_vel"); + m_flStageVelocityAvg[m_iCurrentStage] = pEvent->GetFloat("avg_vel"); + m_flStageVelocityMax[m_iCurrentStage] = pEvent->GetFloat("max_vel"); + } + if (!Q_strcmp("run_save", pEvent->GetName())) + { + m_bTimeDidSave = pEvent->GetBool("run_saved"); + m_bTimeDidUpload = pEvent->GetBool("run_posted"); + } + if (!Q_strcmp("timer_started", pEvent->GetName())) + { + m_bTimerIsRunning = pEvent->GetBool("timer_isrunning"); + } + if (!Q_strcmp("player_inside_mapzone", pEvent->GetName())) + { + m_bPlayerInsideStartZone = pEvent->GetBool("inside_startzone"); + m_bPlayerInsideEndZone = pEvent->GetBool("inside_endzone"); + m_bMapFinished = pEvent->GetBool("map_finished"); //different from "inside endzone", this is only fired if the player finished when their timer was running + } + if (!Q_strcmp("practice_mode", pEvent->GetName())) + { + m_bPlayerHasPracticeMode = pEvent->GetBool("has_practicemode"); + } + if (!Q_strcmp("keypress", pEvent->GetName())) + { + m_iTotalJumps = pEvent->GetInt("num_jumps"); + m_iTotalStrafes = pEvent->GetInt("num_strafes"); + } +} + +//Interface this event listener to the DLL +static C_Momentum_EventListener s_momListener; +C_Momentum_EventListener *g_MOMEventListener = &s_momListener; \ No newline at end of file diff --git a/mp/src/game/client/momentum/mom_event_listener.h b/mp/src/game/client/momentum/mom_event_listener.h new file mode 100644 index 0000000000..bdaae1e16e --- /dev/null +++ b/mp/src/game/client/momentum/mom_event_listener.h @@ -0,0 +1,35 @@ +#pragma once + +#include "mom_shareddefs.h" + + +class C_Momentum_EventListener : public IGameEventListener2 +{ +public: + C_Momentum_EventListener() {}; + ~C_Momentum_EventListener(){ + if (gameeventmanager) + gameeventmanager->RemoveListener(this); + } + + void Init(); + + void FireGameEvent(IGameEvent* pEvent); + + bool m_bTimerIsRunning, m_bMapFinished; + bool m_bTimeDidSave, m_bTimeDidUpload; + + bool m_bPlayerInsideStartZone, m_bPlayerInsideEndZone; + bool m_bPlayerHasPracticeMode; + + int m_iTotalStrafes, m_iTotalJumps; + float m_flStartSpeed, m_flEndSpeed, m_flVelocityMax, m_flVelocityAvg, m_flStrafeSyncAvg, m_flStrafeSync2Avg; + + int m_iCurrentStage, m_iStageTicks[MAX_STAGES], m_iStageJumps[MAX_STAGES], m_iStageStrafes[MAX_STAGES]; + float m_flStageStartSpeed[MAX_STAGES], m_flStageVelocityMax[MAX_STAGES], + m_flStageVelocityAvg[MAX_STAGES], m_flStageStrafeSyncAvg[MAX_STAGES], + m_flStageStrafeSync2Avg[MAX_STAGES]; + +}; + +extern C_Momentum_EventListener *g_MOMEventListener; \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/ClientTimesDisplay.cpp b/mp/src/game/client/momentum/ui/ClientTimesDisplay.cpp index 62a4a718f2..39e2e328a6 100644 --- a/mp/src/game/client/momentum/ui/ClientTimesDisplay.cpp +++ b/mp/src/game/client/momentum/ui/ClientTimesDisplay.cpp @@ -33,6 +33,7 @@ #include "vgui_avatarimage.h" #include "filesystem.h" +#include "util\mom_util.h" #include extern IFileSystem *filesystem; @@ -110,9 +111,9 @@ CClientTimesDisplay::CClientTimesDisplay(IViewPort *pViewPort) : EditablePanel(N m_iDesiredHeight = GetTall(); m_pPlayerList->SetVisible(false); // hide this until we load the images in applyschemesettings - // update scoreboard instantly if on of these events occure - ListenForGameEvent("runtime_saved"); - ListenForGameEvent("runtime_posted"); + // update scoreboard instantly if on of these events occur + gameeventmanager->LoadEventsFromFile("resource/modevents.res"); + ListenForGameEvent("run_save"); ListenForGameEvent("game_newmap"); m_pImageList = NULL; @@ -302,8 +303,6 @@ void CClientTimesDisplay::PostApplySchemeSettings(vgui::IScheme *pScheme) if (m_lMapSummary) m_lMapSummary->SetVisible(true); - - // light up scoreboard a bit SetBgColor(Color(0, 0, 0, 0)); } @@ -458,21 +457,19 @@ void CClientTimesDisplay::AddHeader(Label *pMapSummary) // We have to get rid of it, or at least discover why it was working for some (Goc) and not to me if (pMapSummary) { - char gameMode[4]; - - if (!Q_strnicmp(g_pGameRules->MapName(), "surf_", Q_strlen("surf_"))) + char gameMode[5]; + ConVarRef gm("mom_gamemode"); + if (gm.GetInt() == MOMGM_SURF) Q_strcpy(gameMode, "SURF"); - else if (!Q_strnicmp(g_pGameRules->MapName(), "bhop_", Q_strlen("bhop_"))) + else if (gm.GetInt() == MOMGM_BHOP) Q_strcpy(gameMode, "BHOP"); + else if (gm.GetInt() == MOMGM_SCROLL) + Q_strcpy(gameMode, "SCROLL"); else Q_strcpy(gameMode, "????"); - //MOM_TODO: There'll probably be official gametypes later on in mod development - //We'll have some sort of shared class or global setting that we will use to determine - //what game mode we're on (mom_UTIL.GameMode() or something) - char mapSummary[64]; - Q_snprintf(mapSummary, 64, "%s || %s", gameMode, g_pGameRules->MapName()); + Q_snprintf(mapSummary, 64, "%s | %s", gameMode, g_pGameRules->MapName()); pMapSummary->SetText(mapSummary); } } @@ -560,20 +557,9 @@ void CClientTimesDisplay::ConvertLocalTimes(KeyValues *kvInto) KeyValues *kvLocalTimeFormatted = new KeyValues("localtime"); kvLocalTimeFormatted->SetFloat("time_f", secondsF);//Used for static compare kvLocalTimeFormatted->SetInt("date_t", t.date);//Used for finding - char timeString[15]; - - int hours = secondsF / (60.0f * 60.0f); - int minutes = fmod(secondsF / 60.0f, 60.0f); - int seconds = fmod(secondsF, 60.0f); - int millis = fmod(secondsF, 1.0f) * 1000.0f; - - if (hours > 0) - Q_snprintf(timeString, sizeof(timeString), "%02d:%02d:%02d.%03d", hours, minutes, seconds, millis); - else if (minutes > 0) - Q_snprintf(timeString, sizeof(timeString), "%02d:%02d.%03d", minutes, seconds, millis); - else - Q_snprintf(timeString, sizeof(timeString), "%02d.%03d", seconds, millis); + char timeString[BUFSIZETIME]; + mom_UTIL.FormatTime(t.ticks, t.rate, timeString); kvLocalTimeFormatted->SetString("time", timeString); char dateString[64]; diff --git a/mp/src/game/client/momentum/ui/ClientTimesDisplay.h b/mp/src/game/client/momentum/ui/ClientTimesDisplay.h index b4c70bc1cc..3836830bc2 100644 --- a/mp/src/game/client/momentum/ui/ClientTimesDisplay.h +++ b/mp/src/game/client/momentum/ui/ClientTimesDisplay.h @@ -141,7 +141,7 @@ class CClientTimesDisplay : public vgui::EditablePanel, public IViewPortPanel, p Time(KeyValues* kv) { ticks = Q_atoi(kv->GetName()); - rate = kv->GetFloat("rate", 0.015); + rate = kv->GetFloat("rate", gpGlobals->interval_per_tick); date = (time_t) kv->GetInt("date", 0); }; }; diff --git a/mp/src/game/client/momentum/ui/IMomentumSettingsPanel.h b/mp/src/game/client/momentum/ui/IMomentumSettingsPanel.h new file mode 100644 index 0000000000..e11d6400b8 --- /dev/null +++ b/mp/src/game/client/momentum/ui/IMomentumSettingsPanel.h @@ -0,0 +1,14 @@ +#pragma once + +#include "vgui/IVGui.h" + +class MomentumSettingsPanel +{ +public: + virtual void Create(vgui::VPANEL parent) = 0; + virtual void Destroy(void) = 0; + virtual void Activate(void) = 0; + virtual void Close() = 0; +}; + +extern MomentumSettingsPanel *momentum_settings; \ 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 new file mode 100644 index 0000000000..1d8a0157af --- /dev/null +++ b/mp/src/game/client/momentum/ui/IVersionWarnPanel.h @@ -0,0 +1,14 @@ +#pragma once + +#include "vgui/IVGui.h" + +class VersionWarnPanel +{ + public: + virtual void Create(vgui::VPANEL parent) = 0; + virtual void Destroy(void) = 0; + virtual void Activate(void) = 0; + virtual void Close() = 0; +}; + +extern VersionWarnPanel *versionwarnpanel; \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/MapSelection/MapSelectorDialog.h b/mp/src/game/client/momentum/ui/MapSelection/MapSelectorDialog.h index c1a1bc4ba4..08ae7b363d 100644 --- a/mp/src/game/client/momentum/ui/MapSelection/MapSelectorDialog.h +++ b/mp/src/game/client/momentum/ui/MapSelection/MapSelectorDialog.h @@ -25,8 +25,8 @@ class CMapSelectorDialog : public vgui::Frame void Open(void); void Close(void) { - ConVar *pCvar = g_pCVar->FindVar("cl_showmapselection"); - if (pCvar) pCvar->SetValue(0); + ConVarRef pCvar = ConVarRef("cl_showmapselection"); + pCvar.SetValue(0); BaseClass::Close(); } diff --git a/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp b/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp new file mode 100644 index 0000000000..349d191315 --- /dev/null +++ b/mp/src/game/client/momentum/ui/MomentumSettingsDialog.cpp @@ -0,0 +1,227 @@ +//The following include files are necessary to allow your MyPanel.cpp to compile. +#include "cbase.h" +#include "IMomentumSettingsPanel.h" +using namespace vgui; +#include +#include +#include +#include +#include +#include + +#include "momentum/mom_shareddefs.h" +#include "tier0/memdbgon.h" + +class CMomentumSettingsPanel : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE(CMomentumSettingsPanel, vgui::Frame); + //CMomentumSettingsPanel : This Class / vgui::Frame : BaseClass + + CMomentumSettingsPanel(vgui::VPANEL parent); // Constructor + ~CMomentumSettingsPanel() {}; // Destructor + void Activate() override; + +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); + } + +private: + void LoadSettings(); + //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; + + Button *m_pApplyButton; + +}; + +// Constuctor: Initializes the Panel +CMomentumSettingsPanel::CMomentumSettingsPanel(vgui::VPANEL parent) + : BaseClass(nullptr, "CMomentumSettingsPanel") +{ + SetParent(parent); + SetPaintBackgroundType(1); + SetRoundedCorners(PANEL_ROUND_CORNER_ALL); + SetKeyBoardInputEnabled(true); + SetMouseInputEnabled(true); + + SetProportional(true); + SetTitleBarVisible(true); + SetMinimizeButtonVisible(false); + SetMaximizeButtonVisible(false); + SetCloseButtonVisible(true); + SetSizeable(false); + SetMoveable(true); + SetVisible(false); + + m_pSpeedometerUnits = new ComboBox(this, "SpeedoUnits", 3, false); + 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->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->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_drawspeedometer", false); + m_pSpeedometerShow->AddActionSignalTarget(this); + m_pSpeedometerShowLastJump = new CvarToggleCheckButton(this, "SpeedoShowJump", "#MOM_Settings_Speedometer_Show_Jump", + "mom_speedometer_showlastjumpvel", false); + m_pSpeedometerShowLastJump->AddActionSignalTarget(this); + m_pSpeedometerShowVerticalVel = new CvarToggleCheckButton(this, "ShowSpeedoHvel", "#MOM_Settings_Speedometer_Show_Hvel", + "mom_speedometer_hvel", false); + m_pSpeedometerShowVerticalVel->AddActionSignalTarget(this); + m_pSpeedometerColorize = new CvarToggleCheckButton(this, "SpeedoShowColor", "#MOM_Settings_Speedometer_Show_Color", + "mom_speedometer_colorize", false); + m_pSpeedometerColorize->AddActionSignalTarget(this); + + m_pSyncShow = new CvarToggleCheckButton(this, "SyncShow", "#MOM_Settings_Sync_Show", "mom_strafesync_draw", false); + m_pSyncShow->AddActionSignalTarget(this); + m_pSyncShowBar = new CvarToggleCheckButton(this, "SyncShowBar", "#MOM_Settings_Sync_Show_Bar", "mom_strafesync_drawbar", false); + m_pSyncShowBar->AddActionSignalTarget(this); + + m_pButtonsShow = new CvarToggleCheckButton(this, "ButtonsShow", "#MOM_Settings_Buttons_Show", "mom_showkeypresses", false); + m_pButtonsShow->AddActionSignalTarget(this); + //MOM_TODO: have one for hud_versionwarn? + + m_pApplyButton = new Button(this, "ApplyButton", "#GameUI_Apply", this); + m_pApplyButton->SetCommand("ApplyChanges"); + + m_pApplyButton->AddActionSignalTarget(m_pSpeedometerShow); + m_pApplyButton->AddActionSignalTarget(m_pSpeedometerShowLastJump); + m_pApplyButton->AddActionSignalTarget(m_pSpeedometerShowVerticalVel); + m_pApplyButton->AddActionSignalTarget(m_pSpeedometerColorize); + m_pApplyButton->AddActionSignalTarget(m_pSyncShow); + m_pApplyButton->AddActionSignalTarget(m_pSyncShowBar); + m_pApplyButton->AddActionSignalTarget(m_pButtonsShow); + + SetScheme("ClientScheme"); + //SetScheme(vgui::scheme()->LoadSchemeFromFile("resource/ClientScheme.res", "ClientScheme")); + + LoadControlSettings("resource/ui/MomentumSettingsPanel.res"); + LoadSettings(); + + ivgui()->AddTickSignal(GetVPanel()); +} + +//Class: CMyPanelInterface Class. Used for construction. +class CMomentumSettingsPanelInterface : public MomentumSettingsPanel +{ +private: + CMomentumSettingsPanel *settings_panel; +public: + CMomentumSettingsPanelInterface() + { + settings_panel = nullptr; + } + ~CMomentumSettingsPanelInterface() + { + settings_panel = nullptr; + } + void Create(vgui::VPANEL parent) + { + settings_panel = new CMomentumSettingsPanel(parent); + } + void Destroy() + { + if (settings_panel) + { + settings_panel->SetParent(nullptr); + delete settings_panel; + } + } + void Activate(void) + { + if (settings_panel) + { + settings_panel->Activate(); + } + } + void Close() + { + if (settings_panel) + { + settings_panel->Close(); + } + } +}; +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"); + +CON_COMMAND(mom_settings_show, "Shows the settings") +{ + momentum_settings->Activate(); +} + +//Combobox changed a value +void CMomentumSettingsPanel::OnTextChanged(vgui::Panel* panel) +{ + ConVarRef units("mom_speedometer_units"), sync_type("mom_strafesync_type"), sync_color("mom_strafesync_colorize"); + + units.SetValue(m_pSpeedometerUnits->GetActiveItem() + 1); + sync_type.SetValue(m_pSyncType->GetActiveItem() + 1);//Sync type needs +1 added to it before setting convar! + sync_color.SetValue(m_pSyncColorize->GetActiveItem()); +} + +void CMomentumSettingsPanel::LoadSettings() +{ + ConVarRef units("mom_speedometer_units"), sync_type("mom_strafesync_type"), sync_color("mom_strafesync_colorize"); + m_pSpeedometerUnits->ActivateItemByRow(units.GetInt() - 1); + m_pSyncType->ActivateItemByRow(sync_type.GetInt() - 1); + m_pSyncColorize->ActivateItemByRow(sync_color.GetInt()); +} + +void CMomentumSettingsPanel::OnTick() +{ + BaseClass::OnTick(); + vgui::GetAnimationController()->UpdateAnimations(system()->GetFrameTime()); +} + +void CMomentumSettingsPanel::Activate() +{ + LoadSettings(); + BaseClass::Activate(); +} + +void CMomentumSettingsPanel::OnCheckboxChecked(vgui::Panel* panel) +{ + m_pApplyButton->SetEnabled(true); + + CheckButton *button = dynamic_cast(panel); + if (button) + { + if (!Q_stricmp(button->GetName(), "SpeedoShow")) + { + m_pSpeedometerShowLastJump->SetEnabled(button->IsSelected()); + m_pSpeedometerShowVerticalVel->SetEnabled(button->IsSelected()); + m_pSpeedometerUnits->SetEnabled(button->IsSelected()); + m_pSpeedometerColorize->SetEnabled(button->IsSelected()); + } + else if (!Q_stricmp(button->GetName(), "SyncShow")) + { + m_pSyncType->SetEnabled(button->IsSelected()); + m_pSyncShowBar->SetEnabled(button->IsSelected()); + m_pSyncColorize->SetEnabled(button->IsSelected()); + } + } +} \ 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 new file mode 100644 index 0000000000..4b1a290e26 --- /dev/null +++ b/mp/src/game/client/momentum/ui/VersionWarnPanel.cpp @@ -0,0 +1,143 @@ +//The following include files are necessary to allow your MyPanel.cpp to compile. +#include "cbase.h" +#include "IVersionWarnPanel.h" +using namespace vgui; +#include +#include +#include +#include + +#include "momentum/mom_shareddefs.h" + +#include "tier0/memdbgon.h" + +//CVersionWarnPanel class: Tutorial example 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") +{ + SetParent(parent); + + SetKeyBoardInputEnabled(true); + SetMouseInputEnabled(true); + + SetProportional(true); + SetTitleBarVisible(true); + SetMinimizeButtonVisible(false); + SetMaximizeButtonVisible(false); + SetCloseButtonVisible(true); + SetSizeable(false); + SetMoveable(true); + SetVisible(false); + + + 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) + { + Assert("Missing one more gameui controls from ui/versionwarnpanel.res"); + } + +} + +//Class: CMyPanelInterface Class. Used for construction. +class CVersionWarnPanelInterface : public VersionWarnPanel +{ +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"); + +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, 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); + } +} + +void CVersionWarnPanel::OnCommand(const char* pcCommand) +{ + BaseClass::OnCommand(pcCommand); + + if (!Q_stricmp(pcCommand, "turnoff")) + { + SetVisible(false); + Close(); + } +} + +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 diff --git a/mp/src/game/client/momentum/ui/hud_fillablebar.h b/mp/src/game/client/momentum/ui/hud_fillablebar.h new file mode 100644 index 0000000000..e96ad7e003 --- /dev/null +++ b/mp/src/game/client/momentum/ui/hud_fillablebar.h @@ -0,0 +1,113 @@ +#include "cbase.h" +#include "view.h" +#include "menu.h" +#include "iclientmode.h" +#include "utlvector.h" +#include "hudelement.h" +#include +#include "text_message.h" +#include "hud_macros.h" +#include "weapon_selection.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +class CHudFillableBar : public CHudElement, public vgui::Panel +{ + DECLARE_CLASS_SIMPLE(CHudFillableBar, vgui::Panel); + +public: + + CHudFillableBar(const char* pElementName) : CHudElement(pElementName), Panel(g_pClientMode->GetViewport(), pElementName){} + + void Init(void) + { + SetPaintBackgroundEnabled(false); + SetValue(m_flInitialValue); + }; + virtual void Reset(void) {}; + virtual bool ShouldDraw(void) { return CHudElement::ShouldDraw(); } + + void Paint() + { + Paint(m_FillColor); + } + + void Paint(Color BoxColor) + { + if (GetCurrentValue() != 0) + { + DrawBox(m_flxPos, m_flyPos, m_flWide * (GetCurrentValue() / 100), m_flTall, BoxColor, 1); + } + DrawHollowBox(m_flxPos, m_flyPos, m_flWide, m_flTall, m_BackgroundColor, 1, 2, 2); + } + virtual void OnThink() + { + if (m_flInterpTime > 0 && m_flInterpFromTime > 0) + { + if (m_flInterpTime + m_flInterpFromTime < gpGlobals->curtime) + { + SetValue(m_flDesiredValue, 0); + } + else if (m_flInterpFromTime != gpGlobals->curtime) + { + float newvalue = (gpGlobals->curtime - m_flInterpFromTime) / m_flInterpTime; + SetValue(m_flDesiredValue * newvalue); + } + } + } + void PaintString(const wchar_t *text, int textlen, vgui::HFont& font, int x, int y); + + // Direct setvalue. Use override for interpolation + // @pPercent: max->100 , min->0 + void SetValue(float pPercent) + { + m_flValue = clamp(pPercent, 0, 100); + } + // Sets the new % value of the filled box. If pInterpTime > 0, a interpolation is made. + // @pPercent: max->100 , min->0 + void SetValue(float pPercent, float pInterpTime) + { + m_flDesiredValue = clamp(pPercent, 0, 100); + if (pInterpTime > 0) + { + m_flInterpTime = pInterpTime; + m_flInterpFromTime = gpGlobals->curtime; + } + else + { + m_flInterpTime = 0; + m_flInterpFromTime = 0; + m_flValue = m_flDesiredValue; + m_flDesiredValue = -1; + } + } + float GetCurrentValue() { return m_flValue; } + +private: + void(*SelectFunc)(int); + CPanelAnimationVarAliasType(float, m_flxPos, "xpos", "0.0", "proportional_float"); + CPanelAnimationVarAliasType(float, m_flyPos, "ypos", "0.0", "proportional_float"); + CPanelAnimationVarAliasType(float, m_flTall, "tall", "0", "proportional_float"); + CPanelAnimationVarAliasType(float, m_flWide, "wide", "0", "proportional_float"); + CPanelAnimationVar(float, m_flInitialValue, "InitialValue", "0.0"); + CPanelAnimationVar(Color, m_BackgroundColor, "BackgroundColor", "FgColor"); + CPanelAnimationVar(Color, m_FillColor, "FillColor", "FgColor"); + + // Last value is the % of the box that is filled (From left to right) + float m_flValue; + // When not -1, it is the value we want the bar to draw + float m_flDesiredValue; + // Time it will take to interpolate to the next value. Checks against m_flInterpFromTime. 0 while not used + float m_flInterpTime; + // When did we start interpolating? + float m_flInterpFromTime; + +}; \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/hud_keypress.cpp b/mp/src/game/client/momentum/ui/hud_keypress.cpp new file mode 100644 index 0000000000..25c2cacefa --- /dev/null +++ b/mp/src/game/client/momentum/ui/hud_keypress.cpp @@ -0,0 +1,211 @@ +#include "cbase.h" +#include "hudelement.h" +#include "hud_macros.h" +#include "iclientmode.h" +#include "in_buttons.h" +#include "input.h" + +#include +#include +#include +#include +#include + +#include "mom_shareddefs.h" +#include "mom_player_shared.h" +#include "mom_event_listener.h" + +using namespace vgui; + +static ConVar showkeys("mom_showkeypresses", "1", FCVAR_CLIENTDLL | FCVAR_ARCHIVE | FCVAR_REPLICATED, + "Toggles showing keypresses and strafe/jump counter\n"); + +class CHudKeyPressDisplay : public CHudElement, public Panel +{ + DECLARE_CLASS_SIMPLE(CHudKeyPressDisplay, Panel); + +public: + CHudKeyPressDisplay(); + CHudKeyPressDisplay(const char *pElementName); + virtual bool ShouldDraw() + { + return showkeys.GetBool() && g_MOMEventListener && !g_MOMEventListener->m_bMapFinished && CHudElement::ShouldDraw(); //don't show during map finished dialog + } + virtual void OnThink(); + virtual void Paint(); + virtual void Init(); + virtual void Reset(); + void DrawKeyTemplates(); + virtual void ApplySchemeSettings(IScheme *pScheme) + { + Panel::ApplySchemeSettings(pScheme); + SetBgColor(Color::Color(0,0,0,1)); //empty background, 1 alpha (out of 255) so game text doesnt obscure our text + } +protected: + CPanelAnimationVar(HFont, m_hTextFont, "TextFont", "Default"); + CPanelAnimationVar(HFont, m_hWordTextFont, "WordTextFont", "Default"); + CPanelAnimationVar(HFont, m_hCounterTextFont, "CounterTextFont", "Default"); + CPanelAnimationVar(Color, m_Normal, "KeyPressedColor", "Panel.Fg"); + CPanelAnimationVar(Color, m_darkGray, "KeyOutlineColor", "Dark Gray"); + CPanelAnimationVarAliasType(float, top_row_ypos, "top_row_ypos", "5", + "proportional_float"); + CPanelAnimationVarAliasType(float, mid_row_ypos, "mid_row_ypos", "20", + "proportional_float"); + CPanelAnimationVarAliasType(float, lower_row_ypos, "lower_row_ypos", "35", + "proportional_float"); + CPanelAnimationVarAliasType(float, jump_row_ypos, "jump_row_ypos", "60", + "proportional_float"); + CPanelAnimationVarAliasType(float, duck_row_ypos, "duck_row_ypos", "70", + "proportional_float"); + CPanelAnimationVarAliasType(float, strafe_count_xpos, "strafe_count_xpos", "80", + "proportional_float"); + CPanelAnimationVarAliasType(float, jump_count_xpos, "jump_count_xpos", "80", + "proportional_float"); +private: + int GetTextCenter(HFont font, wchar_t *wstring); + + int m_nButtons, m_nStrafes, m_nJumps; + bool m_bShouldDrawCounts; + wchar_t m_pwfwd[BUFSIZESHORT]; + wchar_t m_pwleft[BUFSIZESHORT]; + wchar_t m_pwback[BUFSIZESHORT]; + wchar_t m_pwright[BUFSIZESHORT]; + wchar_t m_pwjump[BUFSIZELOCL]; + wchar_t m_pwduck[BUFSIZELOCL]; +}; + +DECLARE_HUDELEMENT(CHudKeyPressDisplay); + +CHudKeyPressDisplay::CHudKeyPressDisplay(const char *pElementName) : +CHudElement(pElementName), Panel(g_pClientMode->GetViewport(), "CHudKeyPressDisplay") +{ + SetProportional(true); + SetKeyBoardInputEnabled(false); + SetMouseInputEnabled(false); + SetHiddenBits(HIDEHUD_WEAPONSELECTION); +} +void CHudKeyPressDisplay::Init() +{ + //init wchar with display values + wcscpy(m_pwfwd, L"W"); + wcscpy(m_pwleft, L"A"); + wcscpy(m_pwback, L"S"); + wcscpy(m_pwright, L"D"); + + //localize jump and duck strings + wchar_t *uJumpUnicode = g_pVGuiLocalize->Find("#MOM_Jump"); + Q_wcsncpy(m_pwjump, uJumpUnicode, sizeof(m_pwjump)); //use buffer-safe wcscpy so we don't crash on startup if localization file is corrupted + wchar_t *uDuckUnicode = g_pVGuiLocalize->Find("#MOM_Duck"); + Q_wcsncpy(m_pwduck, uDuckUnicode, sizeof(m_pwduck)); +} +void CHudKeyPressDisplay::Paint() +{ + //first, semi-transparent key templates + DrawKeyTemplates(); + //then, color the key in if it's pressed + surface()->DrawSetTextColor(m_Normal); + surface()->DrawSetTextFont(m_hTextFont); + if (m_nButtons & IN_FORWARD) + { + surface()->DrawSetTextPos(GetTextCenter(m_hTextFont, m_pwfwd), top_row_ypos); + surface()->DrawPrintText(m_pwfwd, wcslen(m_pwfwd)); + } + if (m_nButtons & IN_MOVELEFT) + { + int text_left = GetTextCenter(m_hTextFont, m_pwleft) - UTIL_ComputeStringWidth(m_hTextFont, m_pwleft); + surface()->DrawSetTextPos(text_left, mid_row_ypos); + surface()->DrawPrintText(m_pwleft, wcslen(m_pwleft)); + } + if (m_nButtons & IN_BACK) + { + surface()->DrawSetTextPos(GetTextCenter(m_hTextFont, m_pwback), lower_row_ypos); + surface()->DrawPrintText(m_pwback, wcslen(m_pwback)); + } + if (m_nButtons & IN_MOVERIGHT) + { + int text_right = GetTextCenter(m_hTextFont, m_pwright) + UTIL_ComputeStringWidth(m_hTextFont, m_pwright); + surface()->DrawSetTextPos(text_right, mid_row_ypos); + surface()->DrawPrintText(m_pwright, wcslen(m_pwright)); + } + //reset text font for jump/duck + surface()->DrawSetTextFont(m_hWordTextFont); + + if (m_nButtons & IN_JUMP) + { + surface()->DrawSetTextPos(GetTextCenter(m_hWordTextFont, m_pwjump), jump_row_ypos); + surface()->DrawPrintText(m_pwjump, wcslen(m_pwjump)); + } + if (m_nButtons & IN_DUCK) + { + surface()->DrawSetTextPos(GetTextCenter(m_hWordTextFont, m_pwduck), duck_row_ypos); + surface()->DrawPrintText(m_pwduck, wcslen(m_pwduck)); + } + // ---------- + if (m_bShouldDrawCounts) + { + surface()->DrawSetTextFont(m_hCounterTextFont); + + wchar_t strafes[BUFSIZESHORT]; + char cstr_strafes[BUFSIZESHORT]; + Q_snprintf(cstr_strafes, sizeof(cstr_strafes), "( %i )", m_nStrafes); + g_pVGuiLocalize->ConvertANSIToUnicode(cstr_strafes, strafes, sizeof(strafes)); + + surface()->DrawSetTextPos(strafe_count_xpos, mid_row_ypos); + surface()->DrawPrintText(strafes, wcslen(strafes)); + + wchar_t jumps[BUFSIZESHORT]; + char cstr_jumps[BUFSIZESHORT]; + Q_snprintf(cstr_jumps, sizeof(cstr_jumps), "( %i )", m_nJumps); + g_pVGuiLocalize->ConvertANSIToUnicode(cstr_jumps, jumps, sizeof(jumps)); + + surface()->DrawSetTextPos(jump_count_xpos, jump_row_ypos); + surface()->DrawPrintText(jumps, wcslen(jumps)); + } +} +void CHudKeyPressDisplay::OnThink() +{ + m_nButtons = ::input->GetButtonBits(0); + if (g_MOMEventListener) + { //we should only draw the strafe/jump counters when the timer is running + m_bShouldDrawCounts = g_MOMEventListener->m_bTimerIsRunning; + m_nStrafes = g_MOMEventListener->m_iTotalStrafes; + m_nJumps = g_MOMEventListener->m_iTotalJumps; + } +} +void CHudKeyPressDisplay::Reset() +{ + //reset buttons member in case a button gets stuck + m_nButtons = NULL; +} +int CHudKeyPressDisplay::GetTextCenter(HFont font, wchar_t *wstring) +{ + return GetWide() / 2 - UTIL_ComputeStringWidth(font, wstring) / 2; +} +void CHudKeyPressDisplay::DrawKeyTemplates() +{ + //first draw all keys on screen in a dark gray + surface()->DrawSetTextColor(m_darkGray); + surface()->DrawSetTextFont(m_hTextFont); + //fwd + surface()->DrawSetTextPos(GetTextCenter(m_hTextFont, m_pwfwd), top_row_ypos); + surface()->DrawPrintText(m_pwfwd, wcslen(m_pwfwd)); + //left + int text_left = GetTextCenter(m_hTextFont, m_pwleft) - UTIL_ComputeStringWidth(m_hTextFont, m_pwleft); + surface()->DrawSetTextPos(text_left, mid_row_ypos); + surface()->DrawPrintText(m_pwleft, wcslen(m_pwleft)); + //back + surface()->DrawSetTextPos(GetTextCenter(m_hTextFont, m_pwback), lower_row_ypos); + surface()->DrawPrintText(m_pwback, wcslen(m_pwback)); + //right + int text_right = GetTextCenter(m_hTextFont, m_pwright) + UTIL_ComputeStringWidth(m_hTextFont, m_pwright); + surface()->DrawSetTextPos(text_right, mid_row_ypos); + surface()->DrawPrintText(m_pwright, wcslen(m_pwright)); + //reset text font for jump/duck + surface()->DrawSetTextFont(m_hWordTextFont); + //jump + surface()->DrawSetTextPos(GetTextCenter(m_hWordTextFont, m_pwjump), jump_row_ypos); + surface()->DrawPrintText(m_pwjump, wcslen(m_pwjump)); + //duck + surface()->DrawSetTextPos(GetTextCenter(m_hWordTextFont, m_pwduck), duck_row_ypos); + surface()->DrawPrintText(m_pwduck, wcslen(m_pwduck)); +} \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/hud_mapfinished.cpp b/mp/src/game/client/momentum/ui/hud_mapfinished.cpp new file mode 100644 index 0000000000..b5da623afe --- /dev/null +++ b/mp/src/game/client/momentum/ui/hud_mapfinished.cpp @@ -0,0 +1,380 @@ +#include "cbase.h" +#include "hudelement.h" +#include "hud_numericdisplay.h" +#include "hud_macros.h" +#include "iclientmode.h" +#include "view.h" +#include "menu.h" +#include "time.h" + +#include +#include +#include +#include +#include +#include + +#include "vgui_helpers.h" +#include "mom_shareddefs.h" +#include "mom_player_shared.h" +#include "mom_shareddefs.h" +#include "mom_event_listener.h" +#include "util\mom_util.h" + +#include "tier0/memdbgon.h" + +using namespace vgui; + +class CHudMapFinishedDialog : public CHudElement, public Panel +{ + DECLARE_CLASS_SIMPLE(CHudMapFinishedDialog, Panel); + +public: + CHudMapFinishedDialog(); + CHudMapFinishedDialog(const char *pElementName); + virtual bool ShouldDraw() + { + C_MomentumPlayer *pPlayer = ToCMOMPlayer(CBasePlayer::GetLocalPlayer()); + return pPlayer && g_MOMEventListener && g_MOMEventListener->m_bMapFinished; + } + virtual void Paint(); + virtual void OnThink(); + virtual void Init(); + virtual void Reset() + { + //default values + m_iTotalStrafes = 0; + m_iTotalJumps = 0; + m_flAvgSpeed = 0; + m_flEndSpeed = 0; + m_flStartSpeed = 0; + m_flMaxSpeed = 0; + m_flAvgSync = 0; + m_flAvgSync2 = 0; + strcpy(m_pszRunTime, "00:00:00.000"); + } + virtual void ApplySchemeSettings(IScheme *pScheme) + { + Panel::ApplySchemeSettings(pScheme); + SetBgColor(GetSchemeColor("MOM.Panel.Bg", pScheme)); + } +protected: + CPanelAnimationVar(HFont, m_hTextFont, "TextFont", "Default"); + CPanelAnimationVarAliasType(float, time_xpos, "time_xpos", "30", + "proportional_float"); + CPanelAnimationVarAliasType(float, time_ypos, "time_ypos", "5", + "proportional_float"); + CPanelAnimationVarAliasType(float, strafes_xpos, "strafes_xpos", "30", + "proportional_float"); + CPanelAnimationVarAliasType(float, strafes_ypos, "strafes_ypos", "25", + "proportional_float"); + CPanelAnimationVarAliasType(float, jumps_xpos, "jumps_xpos", "30", + "proportional_float"); + CPanelAnimationVarAliasType(float, jumps_ypos, "jumps_ypos", "45", + "proportional_float"); + CPanelAnimationVarAliasType(float, sync_xpos, "sync_xpos", "30", + "proportional_float"); + CPanelAnimationVarAliasType(float, sync_ypos, "sync_ypos", "65", + "proportional_float"); + CPanelAnimationVarAliasType(float, sync2_xpos, "sync2_xpos", "30", + "proportional_float"); + CPanelAnimationVarAliasType(float, sync2_ypos, "sync2_ypos", "85", + "proportional_float"); + CPanelAnimationVarAliasType(float, startvel_xpos, "startvel_xpos", "30", + "proportional_float"); + CPanelAnimationVarAliasType(float, startvel_ypos, "startvel_ypos", "65", + "proportional_float"); + CPanelAnimationVarAliasType(float, endvel_xpos, "endvel_xpos", "30", + "proportional_float"); + CPanelAnimationVarAliasType(float, endvel_ypos, "endvel_ypos", "65", + "proportional_float"); + CPanelAnimationVarAliasType(float, avgvel_xpos, "avgvel_xpos", "30", + "proportional_float"); + CPanelAnimationVarAliasType(float, avgvel_ypos, "avgvel_ypos", "65", + "proportional_float"); + CPanelAnimationVarAliasType(float, maxvel_xpos, "maxvel_xpos", "30", + "proportional_float"); + CPanelAnimationVarAliasType(float, maxvel_ypos, "maxvel_ypos", "65", + "proportional_float"); + CPanelAnimationVarAliasType(float, runsave_ypos, "runsave_ypos", "65", + "proportional_float"); + CPanelAnimationVarAliasType(float, runupload_ypos, "runupload_ypos", "65", + "proportional_float"); + +private: + wchar_t m_pwTimeLabel[BUFSIZELOCL]; + char m_pszStringTimeLabel[BUFSIZELOCL]; + wchar_t m_pwStrafesLabel[BUFSIZELOCL]; + char m_pszStringStrafesLabel[BUFSIZELOCL]; + wchar_t m_pwJumpsLabel[BUFSIZELOCL]; + char m_pszStringJumpsLabel[BUFSIZELOCL]; + wchar_t m_pwSyncLabel[BUFSIZELOCL]; + char m_pszStringSyncLabel[BUFSIZELOCL]; + wchar_t m_pwSync2Label[BUFSIZELOCL]; + char m_pszStringSync2Label[BUFSIZELOCL]; + wchar_t m_pwStartSpeedLabel[BUFSIZELOCL]; + char m_pszStartSpeedLabel[BUFSIZELOCL]; + wchar_t m_pwEndSpeedLabel[BUFSIZELOCL]; + char m_pszEndSpeedLabel[BUFSIZELOCL]; + wchar_t m_pwAvgSpeedLabel[BUFSIZELOCL]; + char m_pszAvgSpeedLabel[BUFSIZELOCL]; + wchar_t m_pwMaxSpeedLabel[BUFSIZELOCL]; + char m_pszMaxSpeedLabel[BUFSIZELOCL]; + + wchar_t m_pwRunSavedLabel[BUFSIZELOCL]; + char m_pszRunSavedLabel[BUFSIZELOCL]; + wchar_t m_pwRunNotSavedLabel[BUFSIZELOCL]; + char m_pszRunNotSavedLabel[BUFSIZELOCL]; + wchar_t m_pwRunUploadedLabel[BUFSIZELOCL]; + char m_pszRunUploadedLabel[BUFSIZELOCL]; + wchar_t m_pwRunNotUploadedLabel[BUFSIZELOCL]; + char m_pszRunNotUploadedLabel[BUFSIZELOCL]; + + char m_pszRunTime[BUFSIZETIME]; + char m_pszAvgSync[BUFSIZELOCL], m_pszAvgSync2[BUFSIZELOCL]; + int m_iTotalJumps, m_iTotalStrafes; + float m_flAvgSync, m_flAvgSync2; + float m_flStartSpeed, m_flEndSpeed, m_flAvgSpeed, m_flMaxSpeed; + + char runSaveLocalized[BUFSIZELOCL], runNotSaveLocalized[BUFSIZELOCL], + runUploadLocalized[BUFSIZELOCL], runNotUploadLocalized[BUFSIZELOCL]; + + char maxVelLocalized[BUFSIZELOCL], avgVelLocalized[BUFSIZELOCL], endVelLocalized[BUFSIZELOCL], + startVelLocalized[BUFSIZELOCL], sync2Localized[BUFSIZELOCL], syncLocalized[BUFSIZELOCL], + strafeLocalized[BUFSIZELOCL], jumpLocalized[BUFSIZELOCL], timeLocalized[BUFSIZELOCL]; + + + bool m_bRunSaved, m_bRunUploaded; +}; + +DECLARE_HUDELEMENT(CHudMapFinishedDialog); + +CHudMapFinishedDialog::CHudMapFinishedDialog(const char *pElementName) : +CHudElement(pElementName), Panel(g_pClientMode->GetViewport(), "CHudMapFinishedDialog") +{ + SetProportional(true); + SetKeyBoardInputEnabled(false); + SetMouseInputEnabled(false); + SetHiddenBits(HIDEHUD_WEAPONSELECTION); +} +void CHudMapFinishedDialog::Init() +{ + Reset(); + //cache localization files + + wchar_t *uTimeUnicode = g_pVGuiLocalize->Find("#MOM_RunTime"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uTimeUnicode ? uTimeUnicode : L"#MOM_RunTime", timeLocalized, BUFSIZELOCL); + + wchar_t *uJumpUnicode = g_pVGuiLocalize->Find("#MOM_JumpCount"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uJumpUnicode ? uJumpUnicode : L"#MOM_JumpCount", jumpLocalized, BUFSIZELOCL); + + wchar_t *uStrafeUnicode = g_pVGuiLocalize->Find("#MOM_StrafeCount"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uStrafeUnicode ? uStrafeUnicode : L"#MOM_StrafeCount", strafeLocalized, BUFSIZELOCL); + + wchar_t *uSyncUnicode = g_pVGuiLocalize->Find("#MOM_AvgSync"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uSyncUnicode ? uSyncUnicode : L"#MOM_AvgSync", syncLocalized, BUFSIZELOCL); + + wchar_t *uSync2Unicode = g_pVGuiLocalize->Find("#MOM_AvgSync2"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uSync2Unicode ? uSync2Unicode : L"#MOM_AvgSync2", sync2Localized, BUFSIZELOCL); + + wchar_t *uStartVelUnicode = g_pVGuiLocalize->Find("#MOM_StartVel"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uStartVelUnicode ? uStartVelUnicode : L"#MOM_StartVel", startVelLocalized, BUFSIZELOCL); + + wchar_t *uendVelUnicode = g_pVGuiLocalize->Find("#MOM_EndVel"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uendVelUnicode ? uendVelUnicode : L"#MOM_EndVel", endVelLocalized, BUFSIZELOCL); + + wchar_t *uavgVelUnicode = g_pVGuiLocalize->Find("#MOM_AvgVel"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uavgVelUnicode ? uavgVelUnicode : L"#MOM_AvgVel", avgVelLocalized, BUFSIZELOCL); + + wchar_t *umaxVelUnicode = g_pVGuiLocalize->Find("#MOM_MaxVel"); + g_pVGuiLocalize->ConvertUnicodeToANSI(umaxVelUnicode ? umaxVelUnicode : L"#MOM_MaxVel", maxVelLocalized, BUFSIZELOCL); + + // --- RUN SAVING NOTIFICATION --- + wchar_t *urunSaveUnicode = g_pVGuiLocalize->Find("#MOM_RunSaved"); + g_pVGuiLocalize->ConvertUnicodeToANSI(urunSaveUnicode ? urunSaveUnicode : L"#MOM_RunSaved", runSaveLocalized, BUFSIZELOCL); + + wchar_t *urunNotSaveUnicode = g_pVGuiLocalize->Find("#MOM_RunNotSaved"); + g_pVGuiLocalize->ConvertUnicodeToANSI(urunNotSaveUnicode ? urunNotSaveUnicode : L"#MOM_RunNotSaved", runNotSaveLocalized, BUFSIZELOCL); + + wchar_t *urunUploadUnicode = g_pVGuiLocalize->Find("#MOM_RunUploaded"); + g_pVGuiLocalize->ConvertUnicodeToANSI(urunUploadUnicode ? urunUploadUnicode : L"#MOM_RunUploaded", runUploadLocalized, BUFSIZELOCL); + + wchar_t *urunNotUploadUnicode = g_pVGuiLocalize->Find("#MOM_RunNotUploaded"); + g_pVGuiLocalize->ConvertUnicodeToANSI(urunNotUploadUnicode ? urunNotUploadUnicode : L"#MOM_RunNotUploaded", runNotUploadLocalized, BUFSIZELOCL); +} +void CHudMapFinishedDialog::Paint() +{ + //text color + surface()->DrawSetTextFont(m_hTextFont); + surface()->DrawSetTextColor(GetFgColor()); + + // --- RUN TIME --- + Q_snprintf(m_pszStringTimeLabel, sizeof(m_pszStringTimeLabel), "%s %s", + timeLocalized, // run time localization + m_pszRunTime // run time string + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszStringTimeLabel, m_pwTimeLabel, sizeof(m_pwTimeLabel)); + + surface()->DrawSetTextPos(time_xpos, time_ypos); + surface()->DrawPrintText(m_pwTimeLabel, wcslen(m_pwTimeLabel)); + // --------------------- + + // --- JUMP COUNT --- + Q_snprintf(m_pszStringJumpsLabel, sizeof(m_pszStringJumpsLabel), "%s %i", + jumpLocalized, // total jump localization + m_iTotalJumps // total jump int + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszStringJumpsLabel, m_pwJumpsLabel, sizeof(m_pwJumpsLabel)); + + surface()->DrawSetTextPos(jumps_xpos, jumps_ypos); + surface()->DrawPrintText(m_pwJumpsLabel, wcslen(m_pwJumpsLabel)); + // --------------------- + + // --- STRAFE COUNT --- + Q_snprintf(m_pszStringStrafesLabel, sizeof(m_pszStringStrafesLabel), "%s %i", + strafeLocalized, // total strafe localization + m_iTotalStrafes //total strafes int + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszStringStrafesLabel, m_pwStrafesLabel, sizeof(m_pwStrafesLabel)); + + surface()->DrawSetTextPos(strafes_xpos, strafes_ypos); + surface()->DrawPrintText(m_pwStrafesLabel, wcslen(m_pwStrafesLabel)); + // --------------------- + + // --- AVG SYNC --- + Q_snprintf(m_pszAvgSync, sizeof(m_pszStringSyncLabel), "%.2f", m_flAvgSync); //convert floating point avg sync to 2 decimal place string + Q_snprintf(m_pszStringSyncLabel, sizeof(m_pszStringSyncLabel), "%s %s", + syncLocalized, // avg sync localization + m_pszAvgSync // avg sync float + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszStringSyncLabel, m_pwSyncLabel, sizeof(m_pwSyncLabel)); + + surface()->DrawSetTextPos(sync_xpos, sync_ypos); + surface()->DrawPrintText(m_pwSyncLabel, wcslen(m_pwSyncLabel)); + // --------------------- + + // --- AVG SYNC 2--- + Q_snprintf(m_pszAvgSync2, sizeof(m_pszStringSync2Label), "%.2f", m_flAvgSync2); //convert floating point avg sync to 2 decimal place string + Q_snprintf(m_pszStringSync2Label, sizeof(m_pszStringSync2Label), "%s %s", + sync2Localized, // avg sync localization + m_pszAvgSync2 // avg sync float + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszStringSync2Label, m_pwSync2Label, sizeof(m_pwSync2Label)); + + surface()->DrawSetTextPos(sync2_xpos, sync2_ypos); + surface()->DrawPrintText(m_pwSync2Label, wcslen(m_pwSync2Label)); + // --------------------- + + // --- STARTING VELOCITY--- + Q_snprintf(m_pszStartSpeedLabel, sizeof(m_pszStartSpeedLabel), "%s %f", + startVelLocalized, + m_flStartSpeed + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszStartSpeedLabel, m_pwStartSpeedLabel, sizeof(m_pwStartSpeedLabel)); + + surface()->DrawSetTextPos(startvel_xpos, startvel_ypos); + surface()->DrawPrintText(m_pwStartSpeedLabel, wcslen(m_pwStartSpeedLabel)); + // --------------------- + + // --- ENDING VELOCITY--- + Q_snprintf(m_pszEndSpeedLabel, sizeof(m_pszEndSpeedLabel), "%s %f", + endVelLocalized, + m_flEndSpeed + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszEndSpeedLabel, m_pwEndSpeedLabel, sizeof(m_pwEndSpeedLabel)); + + surface()->DrawSetTextPos(endvel_xpos, endvel_ypos); + surface()->DrawPrintText(m_pwEndSpeedLabel, wcslen(m_pwEndSpeedLabel)); + // --------------------- + + // --- AVG VELOCITY--- + Q_snprintf(m_pszAvgSpeedLabel, sizeof(m_pszAvgSpeedLabel), "%s %f", + avgVelLocalized, + m_flAvgSpeed + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszAvgSpeedLabel, m_pwAvgSpeedLabel, sizeof(m_pwAvgSpeedLabel)); + + surface()->DrawSetTextPos(avgvel_xpos, avgvel_ypos); + surface()->DrawPrintText(m_pwAvgSpeedLabel, wcslen(m_pwAvgSpeedLabel)); + // --------------------- + + // --- MAX VELOCITY--- + Q_snprintf(m_pszMaxSpeedLabel, sizeof(m_pszMaxSpeedLabel), "%s %f", + maxVelLocalized, + m_flMaxSpeed + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszMaxSpeedLabel, m_pwMaxSpeedLabel, sizeof(m_pwMaxSpeedLabel)); + + surface()->DrawSetTextPos(maxvel_xpos, maxvel_ypos); + surface()->DrawPrintText(m_pwMaxSpeedLabel, wcslen(m_pwAvgSpeedLabel)); + // --------------------- + + // ---- RUN SAVING AND UPLOADING ---- + + // -- run save -- + Q_snprintf(m_bRunSaved ? m_pszRunSavedLabel : m_pszRunNotSavedLabel, + m_bRunSaved ? sizeof(m_pszRunSavedLabel) : sizeof(m_pszRunNotSavedLabel), "%s", + m_bRunSaved ? runSaveLocalized : runNotSaveLocalized); + + g_pVGuiLocalize->ConvertANSIToUnicode( + m_bRunSaved ? m_pszRunSavedLabel : m_pszRunNotSavedLabel, + m_bRunSaved ? m_pwRunSavedLabel : m_pwRunNotSavedLabel, + m_bRunSaved ? sizeof(m_pwRunSavedLabel) : sizeof(m_pwRunNotSavedLabel)); + + // -- run upload -- + Q_snprintf(m_bRunUploaded ? m_pszRunUploadedLabel : m_pszRunNotUploadedLabel, + m_bRunUploaded ? sizeof(m_pszRunUploadedLabel) : sizeof(m_pszRunNotUploadedLabel), "%s", + m_bRunUploaded ? runUploadLocalized : runNotUploadLocalized); + + g_pVGuiLocalize->ConvertANSIToUnicode( + m_bRunUploaded ? m_pszRunUploadedLabel : m_pszRunNotUploadedLabel, + m_bRunUploaded ? m_pwRunUploadedLabel : m_pwRunNotUploadedLabel, + m_bRunUploaded ? sizeof(m_pwRunUploadedLabel) : sizeof(m_pwRunNotUploadedLabel)); + + int save_text_xpos = GetWide() / 2 - UTIL_ComputeStringWidth(m_hTextFont, + m_bRunSaved ? m_pwRunSavedLabel : m_pwRunNotSavedLabel) / 2; //center label + + surface()->DrawSetTextPos(save_text_xpos, runsave_ypos); + surface()->DrawSetTextColor(m_bRunSaved ? GetFgColor() : COLOR_RED); + surface()->DrawPrintText(m_bRunSaved ? m_pwRunSavedLabel : m_pwRunNotSavedLabel, + m_bRunSaved ? wcslen(m_pwRunSavedLabel) : wcslen(m_pwRunNotSavedLabel)); + + int upload_text_xpos = GetWide() / 2 - UTIL_ComputeStringWidth(m_hTextFont, + m_bRunUploaded ? m_pwRunUploadedLabel : m_pwRunNotUploadedLabel) / 2; //center label + + surface()->DrawSetTextPos(upload_text_xpos, runupload_ypos); + surface()->DrawSetTextColor(m_bRunUploaded ? GetFgColor() : COLOR_RED); + surface()->DrawPrintText(m_bRunUploaded ? m_pwRunUploadedLabel : m_pwRunNotUploadedLabel, + m_bRunUploaded ? wcslen(m_pwRunUploadedLabel) : wcslen(m_pwRunNotUploadedLabel)); + // ---------------- + // ------------------------------ +} +void CHudMapFinishedDialog::OnThink() +{ + C_MomentumPlayer *pPlayer = ToCMOMPlayer(CBasePlayer::GetLocalPlayer()); + + if (g_MOMEventListener) + { + m_bRunSaved = g_MOMEventListener->m_bTimeDidSave; + m_bRunUploaded = g_MOMEventListener->m_bTimeDidUpload; + m_flAvgSpeed = g_MOMEventListener->m_flVelocityAvg; + m_flMaxSpeed = g_MOMEventListener->m_flVelocityMax; + m_flStartSpeed = g_MOMEventListener->m_flStartSpeed; + m_flEndSpeed = g_MOMEventListener->m_flEndSpeed; + m_flAvgSync2 = g_MOMEventListener->m_flStrafeSync2Avg; + m_flAvgSync = g_MOMEventListener->m_flStrafeSyncAvg; + m_iTotalJumps = g_MOMEventListener->m_iTotalJumps; + m_iTotalStrafes = g_MOMEventListener->m_iTotalStrafes; + } + if (pPlayer != nullptr) + mom_UTIL.FormatTime(pPlayer->m_nLastRunTime, gpGlobals->interval_per_tick, m_pszRunTime); +} \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/hud_menu_static.cpp b/mp/src/game/client/momentum/ui/hud_menu_static.cpp index 001aa21d96..1150cfd1e3 100644 --- a/mp/src/game/client/momentum/ui/hud_menu_static.cpp +++ b/mp/src/game/client/momentum/ui/hud_menu_static.cpp @@ -268,10 +268,10 @@ void CHudMenuStatic::ProcessText(void) void CHudMenuStatic::ApplySchemeSettings(vgui::IScheme *pScheme) { - BaseClass::ApplySchemeSettings(pScheme); - SetPaintBackgroundEnabled(false); textFont = pScheme->GetFont("Default", true); + SetFgColor(GetSchemeColor("MOM.Panel.Fg", pScheme)); + SetBgColor(GetSchemeColor("MOM.Panel.Bg", pScheme)); // set our size int screenWide, screenTall; int x, y; diff --git a/mp/src/game/client/momentum/ui/hud_speedometer.cpp b/mp/src/game/client/momentum/ui/hud_speedometer.cpp new file mode 100644 index 0000000000..dace1e5c2d --- /dev/null +++ b/mp/src/game/client/momentum/ui/hud_speedometer.cpp @@ -0,0 +1,252 @@ +#include "cbase.h" +#include "hud_numericdisplay.h" +#include "hudelement.h" +#include "iclientmode.h" +#include "vgui_helpers.h" + +#include +#include +#include +#include +#include +#include + +#include "mom_player_shared.h" +#include "momentum/util/mom_util.h" +#include "vphysics_interface.h" +#include "mom_event_listener.h" +#include + +using namespace vgui; + +static ConVar speedometer_hvel("mom_speedometer_hvel", "0", + FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, + "If set to 1, doesn't take the vertical velocity component into account.\n", true, 0, + true, 1); + +static ConVar speedometer_units("mom_speedometer_units", "1", + FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, + "Changes the units of measure of the speedmeter.\n 1: Units per second. \n 2: " + "Kilometers per hour. \n 3: Miles per hour.\n", + true, 1, true, 3); + +static ConVar speedometer_draw("mom_drawspeedometer", "1", + FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, + "Toggles displaying the speedometer.\n", true, 0, true, 1); + +static ConVar speedometer_colorize("mom_speedometer_colorize", "1", + FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, + "Toggles speedometer colorization based on acceleration.\n", true, 0, true, 1); + +static ConVar speedometer_lastjump("mom_speedometer_showlastjumpvel", "1", + FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, + "Toggles showing player velocity at last jump (XY only). \n", true, 0, true, 1); + +class CHudSpeedMeter : public CHudElement, public CHudNumericDisplay +{ + DECLARE_CLASS_SIMPLE(CHudSpeedMeter, CHudNumericDisplay); + + public: + CHudSpeedMeter(const char *pElementName); + virtual void Init() { Reset(); } + virtual void VidInit() { Reset(); } + virtual void Paint(); + virtual void PaintNumbers(HFont font, int xpos, int ypos, int value, bool atLeast2Digits); + virtual void Reset() + { + // We set the proper LabelText based on mom_speedmeter_units value + switch (speedometer_units.GetInt()) + { + case 2: + SetLabelText(L"KM/H"); + break; + case 3: + SetLabelText(L"MPH"); + break; + case 1: + default: + SetLabelText(L""); //don't draw label if we are on UPS mode (it's a bit redundant) + break; + } + SetDisplayValue(0); + SetSecondaryValue(0); + m_flNextColorizeCheck = 0; + } + virtual void OnThink(); + virtual bool ShouldDraw() { return speedometer_draw.GetBool() && CHudElement::ShouldDraw(); } + virtual void ApplySchemeSettings(IScheme *pScheme) + { + Panel::ApplySchemeSettings(pScheme); + normalColor = GetSchemeColor("MOM.Speedometer.Normal", pScheme); + increaseColor = GetSchemeColor("MOM.Speedometer.Increase", pScheme); + decreaseColor = GetSchemeColor("MOM.Speedometer.Decrease", pScheme); + SetBgColor(_bgColor); + m_LabelColor = normalColor; + } + bool ShouldColorize() { return speedometer_colorize.GetBool(); } + private: + float m_flNextColorizeCheck; + float m_flLastVelocity; + float m_flLastJumpVelocity; + + int m_iRoundedVel, m_iRoundedLastJump; + Color m_lastColor; + Color m_currentColor; + Color normalColor, increaseColor, decreaseColor; +protected: + CPanelAnimationVar(Color, _bgColor, "BgColor", "Blank"); +}; + +DECLARE_HUDELEMENT(CHudSpeedMeter); + +CHudSpeedMeter::CHudSpeedMeter(const char *pElementName) + : CHudElement(pElementName), CHudNumericDisplay(g_pClientMode->GetViewport(), "HudSpeedMeter") +{ + // This is already set for HUD elements, but still... + SetProportional(true); + SetKeyBoardInputEnabled(false); + SetMouseInputEnabled(false); + SetHiddenBits(HIDEHUD_WEAPONSELECTION); +} + +void CHudSpeedMeter::OnThink() +{ + Vector velocity = vec3_origin; + C_MomentumPlayer *pPlayer = ToCMOMPlayer(CBasePlayer::GetLocalPlayer()); + if (pPlayer) + { + velocity = pPlayer->GetLocalVelocity(); + float lastJumpVel = pPlayer->m_flLastJumpVel; + // Remove the vertical component if necessary + if (speedometer_hvel.GetBool()) + { + velocity.z = 0; + } + + // Conversions based on https://developer.valvesoftware.com/wiki/Dimensions#Map_Grid_Units:_quick_reference + float vel = (float)velocity.Length(); + switch (speedometer_units.GetInt()) + { + case 2: + // 1 unit = 19.05mm -> 0.01905m -> 0.00001905Km(/s) -> 0.06858Km(/h) + vel *= 0.06858; + lastJumpVel *= 0.06858; + SetLabelText(L"KM/H"); + break; + case 3: + // 1 unit = 0.75", 1 mile = 63360. 0.75 / 63360 ~~> 0.00001184"(/s) ~~> 0.04262MPH + vel *= 0.04262; + lastJumpVel *= 0.04262; + SetLabelText(L"MPH"); + break; + case 1: + default: + // We do nothing but break out of the switch, as default vel is already in UPS + SetLabelText(L""); + break; + } + + // only called if we need to update color + if (ShouldColorize()) + { + if (m_flNextColorizeCheck <= gpGlobals->curtime) + { + if (m_flLastVelocity != 0) + { + m_currentColor = mom_UTIL.GetColorFromVariation(abs(vel) - abs(m_flLastVelocity), 2.0f, normalColor, + increaseColor, decreaseColor); + } + else + { + m_currentColor = normalColor; + } + m_lastColor = m_PrimaryValueColor = m_currentColor; + m_flLastVelocity = vel; + m_flNextColorizeCheck = gpGlobals->curtime + MOM_COLORIZATION_CHECK_FREQUENCY; + } + //reset last jump velocity when we restart a run by entering the start zone + //if (m_eventListener->m_bPlayerInsideStartZone) + // m_flLastJumpVelocity = 0; + if (pPlayer->m_flLastJumpVel == 0) + { + m_SecondaryValueColor = normalColor; + } + else if (m_flLastJumpVelocity != pPlayer->m_flLastJumpVel) + { + m_SecondaryValueColor = + mom_UTIL.GetColorFromVariation(abs(pPlayer->m_flLastJumpVel) - abs(m_flLastJumpVelocity), 0.0f, + normalColor, increaseColor, decreaseColor); + m_flLastJumpVelocity = pPlayer->m_flLastJumpVel; + } + } + else + { + m_SecondaryValueColor = m_PrimaryValueColor = normalColor; + } + //center text + + m_iRoundedVel = round(vel); + m_iRoundedLastJump = round(lastJumpVel); + SetDisplayValue(m_iRoundedVel); + SetShouldDisplaySecondaryValue(speedometer_lastjump.GetBool()); + SetSecondaryValue(m_iRoundedLastJump); + } +} +void CHudSpeedMeter::Paint() +{ + char speedoValue[BUFSIZELOCL], lastJumpvValue[BUFSIZELOCL]; + wchar_t pw_SpeedoValue[BUFSIZELOCL], pw_LastJumpvValue[BUFSIZELOCL]; + Q_snprintf(speedoValue, sizeof(speedoValue), "%d", m_iRoundedVel); + Q_snprintf(lastJumpvValue, sizeof(lastJumpvValue), "%d", m_iRoundedLastJump); + + g_pVGuiLocalize->ConvertANSIToUnicode(speedoValue, pw_SpeedoValue, sizeof(pw_SpeedoValue)); + g_pVGuiLocalize->ConvertANSIToUnicode(lastJumpvValue, pw_LastJumpvValue, sizeof(pw_LastJumpvValue)); + + text_xpos = GetWide() / 2 - UTIL_ComputeStringWidth(m_hTextFont, m_LabelText) / 2; + digit_xpos = GetWide() / 2 - UTIL_ComputeStringWidth(m_hNumberFont, pw_SpeedoValue) / 2; + digit2_xpos = GetWide() / 2 - UTIL_ComputeStringWidth(m_hSmallNumberFont, pw_LastJumpvValue) / 2; + + BaseClass::Paint(); +} +//we override this here so the last jump vel display doesnt have a double 0 +void CHudSpeedMeter::PaintNumbers(HFont font, int xpos, int ypos, int value, bool atLeast2Digits) +{ + + surface()->DrawSetTextFont(font); + wchar_t unicode[6]; + if (!m_bIsTime) + { + if (atLeast2Digits && value < 10) + { + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d", value); + } + else + { + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d", value); + } + } + else + { + int iMinutes = value / 60; + int iSeconds = value - iMinutes * 60; + + if (iSeconds < 10) + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d`0%d", iMinutes, iSeconds); + else + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d`%d", iMinutes, iSeconds); + } + + // adjust the position to take into account 3 characters + int charWidth = surface()->GetCharacterWidth(font, '0'); + if (value < 100 && m_bIndent) + { + xpos += charWidth; + } + if (value < 10 && m_bIndent) + { + xpos += charWidth; + } + + surface()->DrawSetTextPos(xpos, ypos); + surface()->DrawUnicodeString(unicode); +} diff --git a/mp/src/game/client/momentum/ui/hud_strafesync.cpp b/mp/src/game/client/momentum/ui/hud_strafesync.cpp new file mode 100644 index 0000000000..be6fa9d611 --- /dev/null +++ b/mp/src/game/client/momentum/ui/hud_strafesync.cpp @@ -0,0 +1,276 @@ +#include "cbase.h" +#include "hud_fillablebar.h" +#include "hud_numericdisplay.h" +#include "hudelement.h" +#include "iclientmode.h" +#include "mom_player_shared.h" +#include "momentum/util/mom_util.h" +#include "vphysics_interface.h" +#include "mom_event_listener.h" +#include + +using namespace vgui; + +static ConVar strafesync_draw("mom_strafesync_draw", "1", FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, + "Toggles displaying the strafesync data.\n", true, 0, true, 1); + +static ConVar strafesync_drawbar("mom_strafesync_drawbar", "1", FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, + "Toggles displaying the visual strafesync bar.\n", true, 0, true, 1); + +static ConVar strafesync_type( + "mom_strafesync_type", "1", FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, + "1: Sync1 (perfect strafe ticks / total strafe ticks)\n 2: Sync2 (accel ticks / total strafe ticks)\n", true, 1, + true, 2); + +static ConVar strafesync_colorize("mom_strafesync_colorize", "2", + FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, + "Toggles strafesync data colorization type based on acceleration. 0 to disable\n", + true, 0, true, 2); + +#define SYNC_COLORIZE_DEADZONE 0 +////////////////////////////////////////// +// CHudStrafeSyncDisplay // +////////////////////////////////////////// +class CHudStrafeSyncDisplay : public CHudElement, public CHudNumericDisplay +{ + DECLARE_CLASS_SIMPLE(CHudStrafeSyncDisplay, CHudNumericDisplay); + + public: + CHudStrafeSyncDisplay(const char *pElementName); + void OnThink(); + bool ShouldDraw() + { + C_MomentumPlayer *pPlayer = ToCMOMPlayer(CBasePlayer::GetLocalPlayer()); + return pPlayer && strafesync_draw.GetBool() && CHudElement::ShouldDraw() && g_MOMEventListener + && g_MOMEventListener->m_bTimerIsRunning; + } + virtual void Reset() + { + m_flNextColorizeCheck = 0; + m_flLastStrafeSync = 0; + m_localStrafeSync = 0; + m_lastColor = normalColor; + m_currentColor = normalColor; + } + void ApplySchemeSettings(IScheme *pScheme) + { + Panel::ApplySchemeSettings(pScheme); + SetFgColor(GetSchemeColor("White", pScheme)); + SetBgColor(_bgColor); + normalColor = GetSchemeColor("MOM.Speedometer.Normal", pScheme); + increaseColor = GetSchemeColor("MOM.Speedometer.Increase", pScheme); + decreaseColor = GetSchemeColor("MOM.Speedometer.Decrease", pScheme); + digit_xpos_initial = digit_xpos; + } + bool ShouldColorize() { return strafesync_colorize.GetInt() > 0; } + void Paint(); + + private: + float m_flNextColorizeCheck; + float m_flLastStrafeSync; + + float m_localStrafeSync; + Color m_lastColor; + Color m_currentColor; + Color normalColor, increaseColor, decreaseColor; + + float digit_xpos_initial; +protected: + CPanelAnimationVar(Color, _bgColor, "BgColor", "Blank"); +}; + +DECLARE_HUDELEMENT(CHudStrafeSyncDisplay); + +CHudStrafeSyncDisplay::CHudStrafeSyncDisplay(const char *pElementName) + : CHudElement(pElementName), CHudNumericDisplay(g_pClientMode->GetViewport(), "CHudSyncMeter") +{ + SetHiddenBits(HIDEHUD_WEAPONSELECTION); +} +void CHudStrafeSyncDisplay::OnThink() +{ + C_MomentumPlayer *pPlayer = ToCMOMPlayer(CBasePlayer::GetLocalPlayer()); + if (strafesync_type.GetInt() == 1) // sync1 + m_localStrafeSync = pPlayer->m_flStrafeSync; + else if (strafesync_type.GetInt() == 2) // sync2 + m_localStrafeSync = pPlayer->m_flStrafeSync2; + else + m_localStrafeSync = 0; + + float clampedStrafeSync = clamp(m_localStrafeSync, 0, 100); + + switch (strafesync_colorize.GetInt()) + { + case 1: + if (m_flNextColorizeCheck <= gpGlobals->curtime) + { + m_flLastStrafeSync != 0 + ? m_currentColor = mom_UTIL.GetColorFromVariation(m_localStrafeSync - m_flLastStrafeSync, SYNC_COLORIZE_DEADZONE, + normalColor, increaseColor, decreaseColor) + : m_currentColor = normalColor; + + m_lastColor = m_currentColor; + m_flLastStrafeSync = m_localStrafeSync; + m_flNextColorizeCheck = gpGlobals->curtime + MOM_COLORIZATION_CHECK_FREQUENCY; + } + break; + case 2: + if (m_localStrafeSync == 0) + { + m_currentColor = normalColor; + } + else if (m_localStrafeSync > 90) + { + m_currentColor = increaseColor; + } + else if (m_localStrafeSync < 75) + { + m_currentColor = decreaseColor; + } + else + { + m_currentColor = normalColor; + } + break; + case 0: + default: + m_currentColor = normalColor; + break; + } + SetDisplayValue(clampedStrafeSync); + + SetSecondaryValue((clampedStrafeSync - Floor2Int(clampedStrafeSync)) * 100); + + SetShouldDisplaySecondaryValue(clampedStrafeSync != 0 && clampedStrafeSync != 100); + + if (clampedStrafeSync == 0) + { + digit_xpos = GetWide() / 2 - UTIL_ComputeStringWidth(m_hNumberFont,"0") / 2; + } + else + { + digit_xpos = digit_xpos_initial; + } + + m_PrimaryValueColor = m_SecondaryValueColor = m_currentColor; +} +void CHudStrafeSyncDisplay::Paint() +{ + if (ShouldDraw()) + BaseClass::Paint(); + if (strafesync_type.GetInt() == 2) + { + SetLabelText(L"Sync 2"); + } + else + { + SetLabelText(L"Sync"); + } + text_xpos = GetWide() / 2 - UTIL_ComputeStringWidth(m_hTextFont, m_LabelText) / 2; +} +////////////////////////////////////////// +// CHudStrafeSyncBar // +////////////////////////////////////////// +class CHudStrafeSyncBar : public CHudFillableBar +{ + DECLARE_CLASS_SIMPLE(CHudStrafeSyncBar, CHudFillableBar); + + public: + CHudStrafeSyncBar(const char *pElementName); + void OnThink(); + bool ShouldDraw() + { + C_MomentumPlayer *pPlayer = ToCMOMPlayer(CBasePlayer::GetLocalPlayer()); + return (pPlayer && strafesync_drawbar.GetBool() && CHudElement::ShouldDraw() && g_MOMEventListener + && g_MOMEventListener->m_bTimerIsRunning); + } + virtual void Reset() + { + m_flNextColorizeCheck = 0; + m_flLastStrafeSync = 0; + m_localStrafeSync = 0; + m_lastColor = normalColor; + m_currentColor = normalColor; + } + void ApplySchemeSettings(IScheme *pScheme) + { + Panel::ApplySchemeSettings(pScheme); + SetFgColor(GetSchemeColor("White", pScheme)); + normalColor = GetSchemeColor("MOM.Speedometer.Normal", pScheme); + increaseColor = GetSchemeColor("MOM.Speedometer.Increase", pScheme); + decreaseColor = GetSchemeColor("MOM.Speedometer.Decrease", pScheme); + } + void Paint(); + bool ShouldColorize() { return strafesync_colorize.GetInt() > 0; } + + private: + float m_flNextColorizeCheck; + float m_flLastStrafeSync; + + float m_localStrafeSync; + Color m_lastColor; + Color m_currentColor; + Color normalColor, increaseColor, decreaseColor; + +}; + +DECLARE_HUDELEMENT(CHudStrafeSyncBar); + +CHudStrafeSyncBar::CHudStrafeSyncBar(const char *pElementName) : CHudFillableBar("CHudSyncBar") +{ + SetHiddenBits(HIDEHUD_WEAPONSELECTION); +} +void CHudStrafeSyncBar::Paint() +{ + if (ShouldDraw()) + BaseClass::Paint(m_currentColor); +} +void CHudStrafeSyncBar::OnThink() +{ + C_MomentumPlayer *pPlayer = ToCMOMPlayer(CBasePlayer::GetLocalPlayer()); + if (pPlayer == nullptr) + return; + if (strafesync_type.GetInt() == 1) // sync1 + m_localStrafeSync = pPlayer->m_flStrafeSync; + else if (strafesync_type.GetInt() == 2) // sync2 + m_localStrafeSync = pPlayer->m_flStrafeSync2; + switch (strafesync_colorize.GetInt()) + { + case 1: + if (m_flNextColorizeCheck <= gpGlobals->curtime) + { + m_flLastStrafeSync != 0 + ? m_currentColor = mom_UTIL.GetColorFromVariation(m_localStrafeSync - m_flLastStrafeSync, SYNC_COLORIZE_DEADZONE, + normalColor, increaseColor, decreaseColor) + : m_currentColor = normalColor; + + m_lastColor = m_currentColor; + m_flLastStrafeSync = m_localStrafeSync; + m_flNextColorizeCheck = gpGlobals->curtime + MOM_COLORIZATION_CHECK_FREQUENCY; + } + break; + case 2: + if (m_localStrafeSync == 0) + { + m_currentColor = normalColor; + } + if (m_localStrafeSync > 90) + { + m_currentColor = increaseColor; + } + else if (m_localStrafeSync < 75) + { + m_currentColor = decreaseColor; + } + else + { + m_currentColor = normalColor; + } + break; + case 0: + default: + SetFgColor(normalColor); + m_currentColor = normalColor; + break; + } + SetValue(m_localStrafeSync); +} diff --git a/mp/src/game/client/momentum/ui/timer.cpp b/mp/src/game/client/momentum/ui/hud_timer.cpp similarity index 56% rename from mp/src/game/client/momentum/ui/timer.cpp rename to mp/src/game/client/momentum/ui/hud_timer.cpp index a0175ad035..462b7af545 100644 --- a/mp/src/game/client/momentum/ui/timer.cpp +++ b/mp/src/game/client/momentum/ui/hud_timer.cpp @@ -5,8 +5,7 @@ #include "iclientmode.h" #include "view.h" #include "menu.h" - -using namespace vgui; +#include "vgui_helpers.h" #include #include @@ -15,19 +14,20 @@ using namespace vgui; #include #include -#include "vgui_helpers.h" +#include "mom_event_listener.h" #include "momentum/util/mom_util.h" +#include "mom_player_shared.h" +#include "mom_shareddefs.h" #include "tier0/memdbgon.h" -#define BUFSIZETIME (sizeof("00:00:00.0000")+1) -#define BUFSIZELOCL (73) +using namespace vgui; static ConVar mom_timer("mom_timer", "1", - FCVAR_DONTRECORD | FCVAR_CLIENTDLL | FCVAR_ARCHIVE, + FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Turn the timer display on/off\n"); -static ConVar timer_mode("mom_timer_mode", "0", FCVAR_DONTRECORD | FCVAR_CLIENTDLL | FCVAR_ARCHIVE | FCVAR_REPLICATED, +static ConVar timer_mode("mom_timer_mode", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE | FCVAR_REPLICATED, "Set what type of timer you want.\n0 = Generic Timer (no splits)\n1 = Splits by Checkpoint\n"); class C_Timer : public CHudElement, public Panel @@ -43,6 +43,11 @@ class C_Timer : public CHudElement, public Panel { return mom_timer.GetBool() && CHudElement::ShouldDraw(); } + virtual void ApplySchemeSettings(IScheme *pScheme) + { + Panel::ApplySchemeSettings(pScheme); + SetFgColor(GetSchemeColor("MOM.Panel.Fg", pScheme)); + } void MsgFunc_Timer_State(bf_read &msg); void MsgFunc_Timer_Reset(bf_read &msg); void MsgFunc_Timer_Checkpoint(bf_read &msg); @@ -51,40 +56,21 @@ class C_Timer : public CHudElement, public Panel virtual void Paint(); int GetCurrentTime(); bool m_bIsRunning; + bool m_bTimerRan; int m_iStartTick; -private: - int m_iStageCurrent; - int m_iStageCount; - int initialTall; - wchar_t m_pwCurrentTime[BUFSIZETIME]; - char m_pszString[BUFSIZETIME]; - wchar_t m_pwCurrentCheckpoints[BUFSIZELOCL]; - char m_pszStringCps[BUFSIZELOCL]; - wchar_t m_pwCurrentStages[BUFSIZELOCL]; - char m_pszStringStages[BUFSIZELOCL]; - CUtlMap map; - int m_iTotalTicks; - bool m_bWereCheatsActivated = false; - bool m_bShowCheckpoints; - int m_iCheckpointCount; - int m_iCheckpointCurrent; - protected: CPanelAnimationVar(float, m_flBlur, "Blur", "0"); CPanelAnimationVar(Color, m_TextColor, "TextColor", "FgColor"); CPanelAnimationVar(Color, m_Ammo2Color, "Ammo2Color", "FgColor"); - CPanelAnimationVar(HFont, m_hNumberFont, "NumberFont", "HudNumbers"); - CPanelAnimationVar(HFont, m_hNumberGlowFont, "NumberGlowFont", - "HudNumbersGlow"); - CPanelAnimationVar(HFont, m_hSmallNumberFont, "SmallNumberFont", - "HudNumbersSmall"); - CPanelAnimationVar(HFont, m_hTextFont, "TextFont", "Default"); + CPanelAnimationVar(HFont, m_hTextFont, "TextFont", "HudHintTextLarge"); + CPanelAnimationVar(HFont, m_hTimerFont, "TimerFont", "HudNumbersSmallBold"); + CPanelAnimationVar(HFont, m_hSmallTextFont, "SmallTextFont", "HudNumbersSmall"); - CPanelAnimationVarAliasType(bool, center_time, "centerTime", "1", + CPanelAnimationVarAliasType(bool, center_time, "centerTime", "0", "BOOL"); - CPanelAnimationVarAliasType(float, time_xpos, "time_xpos", "50", + CPanelAnimationVarAliasType(float, time_xpos, "time_xpos", "0", "proportional_float"); CPanelAnimationVarAliasType(float, time_ypos, "time_ypos", "2", "proportional_float"); @@ -100,6 +86,33 @@ class C_Timer : public CHudElement, public Panel "proportional_float"); CPanelAnimationVarAliasType(float, stage_ypos, "stage_ypos", "40", "proportional_float"); +private: + int m_iStageCurrent; + int m_iStageCount; + int initialTall; + wchar_t m_pwCurrentTime[BUFSIZETIME]; + char m_pszString[BUFSIZETIME]; + wchar_t m_pwCurrentCheckpoints[BUFSIZELOCL]; + char m_pszStringCps[BUFSIZELOCL]; + wchar_t m_pwCurrentStages[BUFSIZELOCL]; + char m_pszStringStages[BUFSIZELOCL]; + wchar_t m_pwCurrentStatus[BUFSIZELOCL]; + char m_pszStringStatus[BUFSIZELOCL]; + wchar_t m_pwStageTime[BUFSIZETIME]; + char m_pszStageTimeString[BUFSIZETIME]; + wchar_t m_pwStageTimeLabel[BUFSIZELOCL]; + char m_pszStageTimeLabelString[BUFSIZELOCL]; + + CUtlMap map; + int m_iTotalTicks; + bool m_bWereCheatsActivated = false; + bool m_bShowCheckpoints; + int m_iCheckpointCount; + int m_iCheckpointCurrent; + Color panelColor; + char stLocalized[BUFSIZELOCL], cpLocalized[BUFSIZELOCL], linearLocalized[BUFSIZELOCL], + startZoneLocalized[BUFSIZELOCL], mapFinishedLocalized[BUFSIZELOCL], practiceModeLocalized[BUFSIZELOCL], + noTimerLocalized[BUFSIZELOCL]; }; DECLARE_HUDELEMENT(C_Timer); @@ -130,11 +143,34 @@ void C_Timer::Init() initialTall = 48; m_iTotalTicks = 0; //Reset(); + + //cache localization strings + wchar_t *uCPUnicode = g_pVGuiLocalize->Find("#MOM_Checkpoint"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uCPUnicode ? uCPUnicode : L"#MOM_Checkpoint", cpLocalized, BUFSIZELOCL); + + wchar_t *uStageUnicode = g_pVGuiLocalize->Find("#MOM_Stage"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uStageUnicode ? uStageUnicode : L"#MOM_Stage", stLocalized, BUFSIZELOCL); + + wchar_t *uLinearUnicode = g_pVGuiLocalize->Find("#MOM_Linear"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uLinearUnicode ? uLinearUnicode : L"#MOM_Linear", linearLocalized, BUFSIZELOCL); + + wchar_t *uStartZoneUnicode = g_pVGuiLocalize->Find("#MOM_InsideStartZone"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uStartZoneUnicode ? uStartZoneUnicode : L"#MOM_InsideStartZone", startZoneLocalized, BUFSIZELOCL); + + wchar_t *uMapFinishedUnicode = g_pVGuiLocalize->Find("#MOM_MapFinished"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uMapFinishedUnicode ? uMapFinishedUnicode : L"#MOM_MapFinished", mapFinishedLocalized, BUFSIZELOCL); + + wchar_t *uPracticeModeUnicode = g_pVGuiLocalize->Find("#MOM_PracticeMode"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uPracticeModeUnicode ? uPracticeModeUnicode : L"#MOM_PracticeMode", practiceModeLocalized, BUFSIZELOCL); + + wchar_t *uNoTimerUnicode = g_pVGuiLocalize->Find("#MOM_NoTimer"); + g_pVGuiLocalize->ConvertUnicodeToANSI(uNoTimerUnicode ? uNoTimerUnicode : L"#MOM_NoTimer", noTimerLocalized, BUFSIZELOCL); } void C_Timer::Reset() { m_bIsRunning = false; + m_bTimerRan = false; m_iTotalTicks = 0; m_iStageCount = 0; m_iStageCurrent = 0; @@ -155,10 +191,10 @@ void C_Timer::MsgFunc_Timer_State(bf_read &msg) bool started = msg.ReadOneBit(); m_bIsRunning = started; m_iStartTick = (int) msg.ReadLong(); - C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); + C_MomentumPlayer *pPlayer = ToCMOMPlayer(C_BasePlayer::GetLocalPlayer()); if (!pPlayer) return; - // MOM_TODO: Create HUD animations for states + if (started) { //VGUI_ANIMATE("TimerStart"); @@ -166,6 +202,7 @@ void C_Timer::MsgFunc_Timer_State(bf_read &msg) if (pPlayer != NULL) { pPlayer->EmitSound("Momentum.StartTimer"); + m_bTimerRan = true; } } else // stopped @@ -173,7 +210,7 @@ void C_Timer::MsgFunc_Timer_State(bf_read &msg) // Compare times. if (m_bWereCheatsActivated) //EY, CHEATER, STOP { - Msg("sv_cheats was set to 1, thus making the run not valid \n"); + DevWarning("sv_cheats was set to 1, thus making the run not valid \n"); } else //He didn't cheat, we can carry on { @@ -187,6 +224,7 @@ void C_Timer::MsgFunc_Timer_State(bf_read &msg) if (pPlayer != NULL) { pPlayer->EmitSound("Momentum.StopTimer"); + pPlayer->m_nLastRunTime = gpGlobals->tickcount - m_iStartTick; } //MOM_TODO: (Beta+) show scoreboard animation with new position on leaderboards? @@ -215,41 +253,24 @@ void C_Timer::MsgFunc_Timer_StageCount(bf_read &msg) { m_iStageCount = (int) msg.ReadLong(); } - int C_Timer::GetCurrentTime() { - if (m_bIsRunning) m_iTotalTicks = gpGlobals->tickcount - m_iStartTick; + //HACKHACK: The client timer stops 1 tick behind the server timer for unknown reasons, + //so we add an extra tick here to make them line up again + if (m_bIsRunning) + m_iTotalTicks = gpGlobals->tickcount - m_iStartTick + 1; return m_iTotalTicks; } void C_Timer::Paint(void) { - mom_UTIL.FormatTime(GetCurrentTime(), gpGlobals->interval_per_tick, m_pszString); - - //float m_flSecondsTime = ((float) GetCurrentTime()) * gpGlobals->interval_per_tick; - - /*int hours = m_flSecondsTime / (60.0f * 60.0f); - int minutes = fmod(m_flSecondsTime / 60.0f, 60.0f); - int seconds = fmod(m_flSecondsTime, 60.0f); - int millis = fmod(m_flSecondsTime, 1.0f) * 1000.0f; - - Q_snprintf(m_pszString, sizeof(m_pszString), "%02d:%02d:%02d.%03d", - hours, //hours - minutes, //minutes - seconds, //seconds - millis //millis - );*/ - - + mom_UTIL.FormatTime(GetCurrentTime(), gpGlobals->interval_per_tick, m_pszString, 2); g_pVGuiLocalize->ConvertANSIToUnicode( m_pszString, m_pwCurrentTime, sizeof(m_pwCurrentTime)); + //find out status of checkpoints (linear vs checkpoints) if (m_bShowCheckpoints) { - char cpLocalized[BUFSIZELOCL]; - wchar_t *uCPUnicode = g_pVGuiLocalize->Find("#MOM_Checkpoint"); - g_pVGuiLocalize->ConvertUnicodeToANSI(uCPUnicode ? uCPUnicode : L"#MOM_Checkpoint", cpLocalized, BUFSIZELOCL); - Q_snprintf(m_pszStringCps, sizeof(m_pszStringCps), "%s %i/%i", cpLocalized, // Checkpoint localization m_iCheckpointCurrent, //CurrentCP @@ -260,39 +281,61 @@ void C_Timer::Paint(void) } if (m_iStageCount > 1) { - char stLocalized[BUFSIZELOCL]; - wchar_t *uStageUnicode = g_pVGuiLocalize->Find("#MOM_Stage"); - g_pVGuiLocalize->ConvertUnicodeToANSI(uStageUnicode ? uStageUnicode : L"#MOM_Stage", stLocalized, BUFSIZELOCL); Q_snprintf(m_pszStringStages, sizeof(m_pszStringStages), "%s %i/%i", stLocalized, // Stage localization m_iStageCurrent, // Current Stage m_iStageCount // Total number of stages ); + if (m_iStageCurrent > 1) + { + mom_UTIL.FormatTime(g_MOMEventListener->m_iStageTicks[g_MOMEventListener->m_iCurrentStage], gpGlobals->interval_per_tick, m_pszStageTimeString); + Q_snprintf(m_pszStageTimeLabelString, sizeof(m_pszStageTimeLabelString), "(%s)", + m_pszStageTimeString, + m_pszStageTimeLabelString + ); + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszStageTimeLabelString, m_pwStageTimeLabel, sizeof(m_pwStageTimeLabel)); + } } else //it's a linear map { - char linearLocalized[25]; - wchar_t *uLinearUnicode = g_pVGuiLocalize->Find("#MOM_Linear"); - g_pVGuiLocalize->ConvertUnicodeToANSI(uLinearUnicode ? uLinearUnicode : L"#MOM_Linear", linearLocalized, 25); Q_snprintf(m_pszStringStages, sizeof(m_pszStringStages), linearLocalized); } - g_pVGuiLocalize->ConvertANSIToUnicode( m_pszStringStages, m_pwCurrentStages, sizeof(m_pwCurrentStages)); + //find out status of timer (start zone/end zone/practice mode) + if (g_MOMEventListener->m_bPlayerInsideStartZone) + { + Q_snprintf(m_pszStringStatus, sizeof(m_pszStringStatus), startZoneLocalized); + } + else if (g_MOMEventListener->m_bPlayerInsideEndZone && g_MOMEventListener->m_bMapFinished) //player finished map with timer running + { + Q_snprintf(m_pszStringStatus, sizeof(m_pszStringStatus), mapFinishedLocalized); + } + else if (g_MOMEventListener->m_bPlayerHasPracticeMode) + { + Q_snprintf(m_pszStringStatus, sizeof(m_pszStringStatus), practiceModeLocalized); + } + else //no timer + { + Q_snprintf(m_pszStringStatus, sizeof(m_pszStringStatus), noTimerLocalized); + } + g_pVGuiLocalize->ConvertANSIToUnicode( + m_pszStringStatus, m_pwCurrentStatus, sizeof(m_pwCurrentStatus)); + // Draw the text label. - surface()->DrawSetTextFont(m_hTextFont); + surface()->DrawSetTextFont(m_bIsRunning ? m_hTimerFont : m_hTextFont); surface()->DrawSetTextColor(GetFgColor()); - // Draw current time. int dummy, totalWide; - + // Draw current time. GetSize(totalWide, dummy); if (center_time) { int timeWide; - surface()->GetTextSize(m_hTextFont, m_pwCurrentTime, timeWide, dummy); + surface()->GetTextSize(m_bIsRunning ? m_hTimerFont : m_hTextFont, m_bIsRunning ? m_pwCurrentTime : m_pwCurrentStatus, timeWide, dummy); int offsetToCenter = ((totalWide - timeWide) / 2); surface()->DrawSetTextPos(offsetToCenter, time_ypos); } @@ -300,14 +343,17 @@ void C_Timer::Paint(void) { surface()->DrawSetTextPos(time_xpos, time_ypos); } - surface()->DrawPrintText(m_pwCurrentTime, wcslen(m_pwCurrentTime)); + //draw either timer display or the timer status + surface()->DrawPrintText(m_bIsRunning ? m_pwCurrentTime : m_pwCurrentStatus, m_bIsRunning ? wcslen(m_pwCurrentTime) : wcslen(m_pwCurrentStatus)); + + surface()->DrawSetTextFont(m_hSmallTextFont); if (m_bShowCheckpoints) { if (center_cps) { int cpsWide; - surface()->GetTextSize(m_hTextFont, m_pwCurrentCheckpoints, cpsWide, dummy); + surface()->GetTextSize(m_hSmallTextFont, m_pwCurrentCheckpoints, cpsWide, dummy); int offsetToCenter = ((totalWide - cpsWide) / 2); surface()->DrawSetTextPos(offsetToCenter, cps_ypos); } @@ -316,18 +362,26 @@ void C_Timer::Paint(void) surface()->DrawPrintText(m_pwCurrentCheckpoints, wcslen(m_pwCurrentCheckpoints)); } - - // MOM_TODO: Print this only if map gamemode is supported - if (center_stage) + else //don't draw stages when drawing checkpoints, and vise versa { - int stageWide; - surface()->GetTextSize(m_hTextFont, m_pwCurrentStages, stageWide, dummy); - int offsetToCenter = ((totalWide - stageWide) / 2); - surface()->DrawSetTextPos(offsetToCenter, stage_ypos); - } - else - surface()->DrawSetTextPos(stage_xpos, stage_ypos); + // MOM_TODO: Print this only if map gamemode is supported + if (center_stage) + { + int stageWide; + surface()->GetTextSize(m_hSmallTextFont, m_pwCurrentStages, stageWide, dummy); + int offsetToCenter = ((totalWide - stageWide) / 2); + surface()->DrawSetTextPos(offsetToCenter, stage_ypos); + } + else + surface()->DrawSetTextPos(stage_xpos, stage_ypos); - surface()->DrawPrintText(m_pwCurrentStages, wcslen(m_pwCurrentStages)); + surface()->DrawPrintText(m_pwCurrentStages, wcslen(m_pwCurrentStages)); + if (m_iStageCurrent > 1) //only draw stage timer if we are on stage 2 or above. + { + int text_xpos = GetWide() / 2 - UTIL_ComputeStringWidth(m_hSmallTextFont, m_pwStageTimeLabel) / 2; + surface()->DrawSetTextPos(text_xpos, cps_ypos); + surface()->DrawPrintText(m_pwStageTimeLabel, wcslen(m_pwStageTimeLabel)); + } + } } \ No newline at end of file diff --git a/mp/src/game/client/momentum/ui/versionwarn.cpp b/mp/src/game/client/momentum/ui/hud_versionwarn.cpp similarity index 95% rename from mp/src/game/client/momentum/ui/versionwarn.cpp rename to mp/src/game/client/momentum/ui/hud_versionwarn.cpp index f82261c8e0..7b23d8746a 100644 --- a/mp/src/game/client/momentum/ui/versionwarn.cpp +++ b/mp/src/game/client/momentum/ui/hud_versionwarn.cpp @@ -6,7 +6,6 @@ #include "view.h" #include "menu.h" #include "time.h" -#define BUFSIZELOCL (73) using namespace vgui; #include @@ -16,21 +15,19 @@ using namespace vgui; #include #include "vgui_helpers.h" - -#include "tier0/memdbgon.h" #include "mom_shareddefs.h" -using namespace vgui; +#include "tier0/memdbgon.h" class CHudVersionWarn : public CHudElement, public Panel { DECLARE_CLASS_SIMPLE(CHudVersionWarn, Panel); - + public: CHudVersionWarn(const char *pElementName); virtual bool ShouldDraw() { - return true; + return CHudElement::ShouldDraw(); } virtual void Paint(); @@ -45,12 +42,12 @@ class CHudVersionWarn : public CHudElement, public Panel DECLARE_HUDELEMENT(CHudVersionWarn); - CHudVersionWarn::CHudVersionWarn(const char *pElementName) : CHudElement(pElementName), Panel(g_pClientMode->GetViewport(), "CHudVersionWarn") { SetProportional(true); SetKeyBoardInputEnabled(false); SetMouseInputEnabled(false); + SetHiddenBits(HIDEHUD_WEAPONSELECTION); } void CHudVersionWarn::Init() @@ -59,7 +56,7 @@ void CHudVersionWarn::Init() char strVersion[BUFSIZELOCL]; wchar_t *uVersionUnicode = g_pVGuiLocalize->Find("#MOM_BuildVersion"); g_pVGuiLocalize->ConvertUnicodeToANSI(uVersionUnicode ? uVersionUnicode : L"#MOM_BuildVersion", strVersion, BUFSIZELOCL); - + Q_snprintf(m_pszStringVersion, sizeof(m_pszStringVersion), "%s %s", strVersion, // BuildVerison localization MOM_CURRENT_VERSION @@ -74,4 +71,4 @@ void CHudVersionWarn::Paint() surface()->DrawSetTextFont(m_hTextFont); surface()->DrawSetTextColor(225, 225, 225, 225); surface()->DrawPrintText(uVersionText, wcslen(uVersionText)); -} \ No newline at end of file +} diff --git a/mp/src/game/client/momentum/ui/speedometer.cpp b/mp/src/game/client/momentum/ui/speedometer.cpp deleted file mode 100644 index 6d08fd6c0b..0000000000 --- a/mp/src/game/client/momentum/ui/speedometer.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "cbase.h" -#include "hudelement.h" -#include "hud_numericdisplay.h" -#include "iclientmode.h" -#include -#include "vphysics_interface.h" - -using namespace vgui; - -static ConVar speedmeter_hvel("mom_speedmeter_hvel", "0", FCVAR_DONTRECORD | FCVAR_CLIENTDLL | FCVAR_ARCHIVE, - "If set to 1, doesn't take the vertical velocity component into account.\n", true, 0, true, 1); - -static ConVar speedmeter_units("mom_speedmeter_units", "1",FCVAR_DONTRECORD | FCVAR_ARCHIVE | FCVAR_CLIENTDLL, - "Changes the units of measure of the speedmeter. \n 1: Units per second. \n 2: Kilometers per hour. \n 3: Milles per hour.\n",true, 1, true, 3); - -static ConVar speedmeter_draw("mom_drawspeedmeter", "1", FCVAR_CLIENTDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_ARCHIVE, - "Toggles displaying the speedmeter.\n", true, 0, true, 1); - -class CHudSpeedMeter : public CHudElement, public CHudNumericDisplay -{ - DECLARE_CLASS_SIMPLE(CHudSpeedMeter, CHudNumericDisplay); - -public: - CHudSpeedMeter(const char *pElementName); - virtual void Init() - { - Reset(); - } - virtual void VidInit() - { - Reset(); - } - virtual void Reset() - { - //We set the proper LabelText based on mom_speedmeter_units value - switch (speedmeter_units.GetInt()) - { - case 1: - SetLabelText(L"UPS"); - break; - case 2: - SetLabelText(L"KM/H"); - break; - case 3: - SetLabelText(L"MPH"); - break; - default: - //If its value is not supported, USP is assumed (Even though this shouln't happen as Max and Min values are set) - SetLabelText(L"UPS"); - break; - } - SetDisplayValue(0); - } - virtual void OnThink(); - virtual bool ShouldDraw() - { - return speedmeter_draw.GetBool() && CHudElement::ShouldDraw(); - } -}; - -DECLARE_HUDELEMENT(CHudSpeedMeter); - - -CHudSpeedMeter::CHudSpeedMeter(const char *pElementName) : CHudElement(pElementName), CHudNumericDisplay(g_pClientMode->GetViewport(), "HudSpeedMeter") -{ - // This is already set for HUD elements, but still... - SetProportional(true); - SetKeyBoardInputEnabled(false); - SetMouseInputEnabled(false); - SetHiddenBits(HIDEHUD_WEAPONSELECTION); -} - -void CHudSpeedMeter::OnThink() -{ - Vector velocity = vec3_origin; - C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); - if (player) { - velocity = player->GetLocalVelocity(); - - // Remove the vertical component if necessary - if (!speedmeter_hvel.GetBool()) - { - velocity.z = 0; - } - - //Conversions based on https://developer.valvesoftware.com/wiki/Dimensions#Map_Grid_Units:_quick_reference - float vel = (float)velocity.Length(); - switch (speedmeter_units.GetInt()) - { - case 1: - //We do nothing but break out of the switch, as default vel is already in UPS - SetLabelText(L"UPS"); - break; - case 2: - //1 unit = 19.05mm -> 0.01905m -> 0.00001905Km(/s) -> 0.06858Km(/h) - vel = vel * 0.06858; - SetLabelText(L"KM/H"); - break; - case 3: - //1 unit = 0.75", 1 mile = 63360. 0.75 / 63360 ~~> 0.00001184"(/s) ~~> 0.04262MPH - vel = vel * 0.04262; - SetLabelText(L"MPH"); - break; - default: - //We do nothing but break out of the switch, as default vel is already in UPS - SetLabelText(L"UPS"); - break; - } - //With this round we ensure that the speed is as precise as possible, instead of taking the floor value of the float - SetDisplayValue(round(vel)); - } -} - - diff --git a/mp/src/game/client/vgui_int.cpp b/mp/src/game/client/vgui_int.cpp index 12cb50b66b..8bccfd63bc 100644 --- a/mp/src/game/client/vgui_int.cpp +++ b/mp/src/game/client/vgui_int.cpp @@ -26,6 +26,8 @@ //Momentum #include "momentum/ui/MapSelection/IMapSelector.h" +#include "momentum/ui/IVersionWarnPanel.h" +#include "momentum/ui/IMomentumSettingsPanel.h" #ifdef SIXENSE #include "sixense/in_sixense.h" @@ -227,6 +229,9 @@ void VGui_CreateGlobalPanels( void ) //Momentum mapselector->Create(gameMenu); + versionwarnpanel->Create(gameMenu); + momentum_settings->Create(gameMenu); + } void VGui_Shutdown() diff --git a/mp/src/game/server/momentum/Timer.cpp b/mp/src/game/server/momentum/Timer.cpp index db9b79aa42..db403d3c81 100644 --- a/mp/src/game/server/momentum/Timer.cpp +++ b/mp/src/game/server/momentum/Timer.cpp @@ -11,6 +11,14 @@ void CTimer::Start(int start) m_iStartTick = start; SetRunning(true); DispatchStateMessage(); + + IGameEvent *timeStartEvent = gameeventmanager->CreateEvent("timer_started"); + + if (timeStartEvent) + { + timeStartEvent->SetBool("timer_isrunning", true); + gameeventmanager->FireEvent(timeStartEvent); + } } void CTimer::PostTime() @@ -24,14 +32,13 @@ void CTimer::PostTime() int ticks = gpGlobals->tickcount - m_iStartTick; TickSet::Tickrate tickRate = TickSet::GetCurrentTickrate(); - + //Build URL char webURL[512]; Q_snprintf(webURL, 512, "http://momentum-mod.org/postscore/%llu/%s/%i/%s", steamID, map, ticks, tickRate.sType); DevLog("Ticks sent to server: %i\n", ticks); - //Build request mom_UTIL.PostTime(webURL); } @@ -72,6 +79,7 @@ void CTimer::LoadLocalTimes(const char *szMapname) Q_strcat(timesFilePath, szMapname, MAX_PATH); Q_strncat(timesFilePath, c_timesExt, MAX_PATH); KeyValues *timesKV = new KeyValues(szMapname); + if (timesKV->LoadFromFile(filesystem, timesFilePath, "MOD")) { for (KeyValues *kv = timesKV->GetFirstSubKey(); kv; kv = kv->GetNextKey()) @@ -80,6 +88,33 @@ void CTimer::LoadLocalTimes(const char *szMapname) t.ticks = Q_atoi(kv->GetName()); t.tickrate = kv->GetFloat("rate"); t.date = (time_t) kv->GetInt("date"); + + for (KeyValues *subKv = kv->GetFirstSubKey(); subKv; subKv = subKv->GetNextKey()) + { + if (!Q_strnicmp(subKv->GetName(), "stage", strlen("stage"))) + { + int i = Q_atoi(subKv->GetName()); //atoi will ignore "stage" and only return the stage number + t.stageticks[i] = subKv->GetInt("ticks"); + t.stagevel[i] = subKv->GetInt("stage_enter_vel"); + t.stageavgsync[i] = subKv->GetFloat("avg_sync"); + t.stageavgsync2[i] = subKv->GetFloat("avg_sync2"); + t.stageavgvel[i] = subKv->GetFloat("avg_vel"); + t.stagemaxvel[i] = subKv->GetFloat("max_vel"); + t.stagejumps[i] = subKv->GetInt("num_jumps"); + t.stagestrafes[i] = subKv->GetInt("num_strafes"); + } + if (!Q_strcmp(subKv->GetName(), "total")) + { + t.jumps = subKv->GetInt("jumps"); + t.strafes = subKv->GetInt("strafes"); + t.avgsync = subKv->GetFloat("avgsync"); + t.avgsync2 = subKv->GetFloat("avgsync2"); + t.avgvel = subKv->GetFloat("avgvel"); + t.maxvel = subKv->GetFloat("maxvel"); + t.startvel = subKv->GetFloat("startvel"); + t.endvel = subKv->GetFloat("endvel"); + } + } localTimes.AddToTail(t); } } @@ -97,6 +132,8 @@ void CTimer::SaveTime() KeyValues *timesKV = new KeyValues(szMapName); int count = localTimes.Count(); + IGameEvent *runSaveEvent = gameeventmanager->CreateEvent("run_save"); + for (int i = 0; i < count; i++) { Time t = localTimes[i]; @@ -105,7 +142,39 @@ void CTimer::SaveTime() KeyValues *pSubkey = new KeyValues(timeName); pSubkey->SetFloat("rate", t.tickrate); pSubkey->SetInt("date", t.date); + + KeyValues *pOverallKey = new KeyValues("total"); + pOverallKey->SetInt("jumps", t.jumps); + pOverallKey->SetInt("strafes", t.strafes); + pOverallKey->SetFloat("avgsync", t.avgsync); + pOverallKey->SetFloat("avgsync2", t.avgsync2); + pOverallKey->SetFloat("startvel", t.startvel); + pOverallKey->SetFloat("endvel", t.endvel); + pOverallKey->SetFloat("avgvel", t.avgvel); + pOverallKey->SetFloat("maxvel", t.maxvel); + + char stageName[9]; // "stage 64\0" + if (GetStageCount() > 1) + { + for (int i = 1; i <= GetStageCount(); i++) + { + Q_snprintf(stageName, sizeof(stageName), "stage %d", i); + + KeyValues *pStageKey = new KeyValues(stageName); + pStageKey->SetInt("ticks", t.stageticks[i]); + pStageKey->SetInt("num_jumps", t.stagejumps[i]); + pStageKey->SetInt("num_strafes", t.stagestrafes[i]); + pStageKey->SetFloat("avg_sync", t.stageavgsync[i]); + pStageKey->SetFloat("avg_sync2", t.stageavgsync2[i]); + pStageKey->SetFloat("avg_vel", t.stageavgvel[i]); + pStageKey->SetFloat("max_vel", t.stagemaxvel[i]); + pStageKey->SetFloat("stage_enter_vel", t.stagevel[i]); + pSubkey->AddSubKey(pStageKey); + } + } + timesKV->AddSubKey(pSubkey); + pSubkey->AddSubKey(pOverallKey); } char file[MAX_PATH]; @@ -113,20 +182,25 @@ void CTimer::SaveTime() Q_strcat(file, szMapName, MAX_PATH); Q_strncat(file, c_timesExt, MAX_PATH); - if (timesKV->SaveToFile(filesystem, file, "MOD", true)) + if (timesKV->SaveToFile(filesystem, file, "MOD", true) && runSaveEvent) { + runSaveEvent->SetBool("run_saved", true); + gameeventmanager->FireEvent(runSaveEvent); Log("Successfully saved new time!\n"); - IGameEvent *savedEvent = gameeventmanager->CreateEvent("runtime_saved"); - if (savedEvent) - gameeventmanager->FireEvent(savedEvent); + //initialize events resource file } - timesKV->deleteThis(); } void CTimer::Stop(bool endTrigger /* = false */) { - if (endTrigger && !m_bWereCheatsActivated) + CMomentumPlayer *pPlayer = ToCMOMPlayer(UTIL_GetLocalPlayer()); + + IGameEvent *runSaveEvent = gameeventmanager->CreateEvent("run_save"); + IGameEvent *timeStopEvent = gameeventmanager->CreateEvent("timer_started"); + IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone"); + + if (endTrigger && !m_bWereCheatsActivated && pPlayer) { // Post time to leaderboards if they're online // and if cheats haven't been turned on this session @@ -138,14 +212,54 @@ void CTimer::Stop(bool endTrigger /* = false */) t.ticks = gpGlobals->tickcount - m_iStartTick; t.tickrate = gpGlobals->interval_per_tick; time(&t.date); + + //stage 0 is overall stats + t.jumps = pPlayer->m_nStageJumps[0]; + t.strafes = pPlayer->m_nStageStrafes[0]; + t.avgsync = pPlayer->m_flStageStrafeSyncAvg[0]; + t.avgsync2 = pPlayer->m_flStageStrafeSync2Avg[0]; + t.avgvel = pPlayer->m_flStageVelocityAvg[0]; + t.maxvel = pPlayer->m_flStageVelocityMax[0]; + t.startvel = pPlayer->m_flStartSpeed; + t.endvel = pPlayer->m_flEndSpeed; + if (GetStageCount() > 1) //don't save stage specific stats if we are on a linear map + { + for (int i = 1; i <= GetStageCount(); i++) //stages start at 1 since stage 0 is overall stats + { + t.stageticks[i] = m_iStageEnterTick[i]; //add each stage's total time in ticks + t.stagejumps[i] = pPlayer->m_nStageJumps[i]; + t.stagestrafes[i] = pPlayer->m_nStageStrafes[i]; + t.stageavgsync[i] = pPlayer->m_flStageStrafeSyncAvg[i]; + t.stageavgsync2[i] = pPlayer->m_flStageStrafeSync2Avg[i]; + t.stageavgvel[i] = pPlayer->m_flStageVelocityAvg[i]; + t.stagemaxvel[i] = pPlayer->m_flStageVelocityMax[i]; + t.stagevel[i] = pPlayer->m_flStageEnterVelocity[i]; + } + } + localTimes.AddToTail(t); SaveTime(); } + else if (runSaveEvent) //reset run saved status to false if we cant or didn't save + { + runSaveEvent->SetBool("run_saved", false); + gameeventmanager->FireEvent(runSaveEvent); + } + if (timeStopEvent) + { + timeStopEvent->SetBool("timer_isrunning", false); + gameeventmanager->FireEvent(timeStopEvent); + } + if (mapZoneEvent) + { + mapZoneEvent->SetInt("current_stage", 0); + mapZoneEvent->SetInt("stage_ticks", 0); + gameeventmanager->FireEvent(mapZoneEvent); + } SetRunning(false); DispatchStateMessage(); } - void CTimer::OnMapEnd(const char *pMapName) { if (IsRunning()) @@ -180,7 +294,22 @@ void CTimer::RequestStageCount() } m_iStageCount = iCount; } - +//This function is called every time CTriggerStage::StartTouch is called +int CTimer::GetStageTicks(int stage) +{ + if (stage == 1) + m_iStageEnterTick[stage] = m_iStartTick; //stage "enter" for start zone is actually exit tick + else if (stage > 1) //only compare pb/show time for stages after start zone + { + if (stage > m_iLastStage) + { + m_iStageEnterTick[stage] = gpGlobals->tickcount - m_iStartTick; //compare stage time diff + } + + } + m_iLastStage = stage; + return m_iStageEnterTick[stage]; +} void CTimer::DispatchResetMessage() { CSingleUserRecipientFilter user(UTIL_GetLocalPlayer()); @@ -287,15 +416,31 @@ void CTimer::EnablePractice(CBasePlayer *pPlayer) { pPlayer->SetParent(NULL); pPlayer->SetMoveType(MOVETYPE_NOCLIP); - ClientPrint(pPlayer, HUD_PRINTCONSOLE, "Practice mode on!\n"); + ClientPrint(pPlayer, HUD_PRINTCONSOLE, "Practice mode ON!\n"); pPlayer->AddEFlags(EFL_NOCLIP_ACTIVE); g_Timer.Stop(false); + + IGameEvent *pracModeEvent = gameeventmanager->CreateEvent("practice_mode"); + if (pracModeEvent) + { + pracModeEvent->SetBool("has_practicemode", true); + gameeventmanager->FireEvent(pracModeEvent); + } + } void CTimer::DisablePractice(CBasePlayer *pPlayer) { pPlayer->RemoveEFlags(EFL_NOCLIP_ACTIVE); ClientPrint(pPlayer, HUD_PRINTCONSOLE, "Practice mode OFF!\n"); pPlayer->SetMoveType(MOVETYPE_WALK); + + IGameEvent *pracModeEvent = gameeventmanager->CreateEvent("practice_mode"); + if (pracModeEvent) + { + pracModeEvent->SetBool("has_practicemode", false); + gameeventmanager->FireEvent(pracModeEvent); + } + } bool CTimer::IsPracticeMode(CBaseEntity *pOther) { @@ -476,9 +621,14 @@ class CTimerCommands return; Vector velocity = pPlayer->GetAbsVelocity(); - if (pPlayer->GetMoveType() != MOVETYPE_NOCLIP && velocity.Length2DSqr() == 0) - g_Timer.EnablePractice(pPlayer); - else //player is either already in practice mode or currently moving. + if (!g_Timer.IsPracticeMode(pPlayer)) + { + if (velocity.Length2DSqr() != 0) + DevLog("You cannot enable practice mode while moving!\n"); + else + g_Timer.EnablePractice(pPlayer); + } + else //player is either already in practice mode g_Timer.DisablePractice(pPlayer); } }; diff --git a/mp/src/game/server/momentum/Timer.h b/mp/src/game/server/momentum/Timer.h index ed5fb71253..b0adccf611 100644 --- a/mp/src/game/server/momentum/Timer.h +++ b/mp/src/game/server/momentum/Timer.h @@ -62,13 +62,14 @@ class CTimer DispatchStageMessage(); } CTriggerStage *GetCurrentStage() { return m_pCurrentStage.Get(); } + int GetCurrentStageNumber() { return m_pCurrentStage.Get()->GetStageNumber(); } // Calculates the stage count // Stores the result on m_iStageCount void RequestStageCount(); // Gets the total stage count int GetStageCount() { return m_iStageCount; }; - + int GetStageTicks(int stageNum); //--------- CheckpointMenu stuff -------------------------------- // Gets the current menu checkpoint index int GetCurrentCPMenuStep() { return m_iCurrentStepCP; } @@ -149,20 +150,30 @@ class CTimer int m_iStageCount; int m_iStartTick; + int m_iLastStage = 0; + int m_iStageEnterTick[MAX_STAGES]; bool m_bIsRunning; bool m_bWereCheatsActivated; + CHandle m_pStartTrigger; CHandle m_pCurrentCheckpoint; CHandle m_pCurrentStage; struct Time { - //The amount of ticks took to complete - int ticks; - //Tickrate the run was done on - float tickrate; - //Date achieved - time_t date; + //overall run stats: + int ticks; //The amount of ticks took to complete + float tickrate; //Tickrate the run was done on + time_t date; //Date achieved + int jumps, strafes; + float maxvel, avgvel, startvel, endvel; + float avgsync, avgsync2; + + //stage specific stats: + int stageticks[MAX_STAGES]; //time in ticks for that stage + float stagevel[MAX_STAGES], stageavgvel[MAX_STAGES], stagemaxvel[MAX_STAGES], + stageavgsync[MAX_STAGES], stageavgsync2[MAX_STAGES]; //no stage end vel since it's the same as the next stage start vel + int stagejumps[MAX_STAGES], stagestrafes[MAX_STAGES]; }; struct Checkpoint diff --git a/mp/src/game/server/momentum/mapzones.cpp b/mp/src/game/server/momentum/mapzones.cpp index c972a15b06..f2ef37ae6b 100644 --- a/mp/src/game/server/momentum/mapzones.cpp +++ b/mp/src/game/server/momentum/mapzones.cpp @@ -36,9 +36,8 @@ CMapzone::~CMapzone() CMapzone::CMapzone(const int pType, Vector* pPos, QAngle* pRot, Vector* pScaleMins, Vector* pScaleMaxs, const int pIndex, const bool pShouldStop, const bool pShouldTilt, - const float pHoldTime, const bool pLimitSpeed, - const float pMaxLeaveSpeed, const float pBhopLeaveSpeed, const float flYaw, - const string_t pLinkedEnt, const bool pCheckOnlyXY, const bool pLimitBhop) + const float pHoldTime, const bool pLimitSpeed, const float pBhopLeaveSpeed, const float flYaw, + const string_t pLinkedEnt, const bool pCheckOnlyXY) { m_type = pType; m_pos = pPos; @@ -50,12 +49,10 @@ CMapzone::CMapzone(const int pType, Vector* pPos, QAngle* pRot, Vector* pScaleMi m_shouldResetAngles = pShouldTilt; m_holdTimeBeforeTeleport = pHoldTime; m_limitingspeed = pLimitSpeed; - m_maxleavespeed = pMaxLeaveSpeed; m_bhopleavespeed = pBhopLeaveSpeed; m_yaw = flYaw; m_linkedent = pLinkedEnt; m_onlyxycheck = pCheckOnlyXY; - m_limitbhop = pLimitBhop; } void CMapzone::SpawnZone() @@ -65,10 +62,7 @@ void CMapzone::SpawnZone() case MOMZONETYPE_START: m_trigger = (CTriggerTimerStart *) CreateEntityByName("trigger_momentum_timer_start"); ((CTriggerTimerStart *) m_trigger)->SetIsLimitingSpeed(m_limitingspeed); - ((CTriggerTimerStart *) m_trigger)->SetMaxLeaveSpeed(m_maxleavespeed); - ((CTriggerTimerStart *) m_trigger)->SetBhopLeaveSpeed(m_bhopleavespeed); - ((CTriggerTimerStart *) m_trigger)->SetIsLimitingSpeedOnlyXY(m_onlyxycheck); - ((CTriggerTimerStart *) m_trigger)->SetIsLimitingBhop(m_limitbhop); + ((CTriggerTimerStart *) m_trigger)->SetMaxLeaveSpeed(m_bhopleavespeed); if ( m_yaw != NO_LOOK ) { ((CTriggerTimerStart *) m_trigger)->SetHasLookAngles(true); @@ -158,11 +152,8 @@ static void saveZonFile(const char* szMapName) subKey = new KeyValues("start"); if (pTrigger) { - subKey->SetFloat("leavespeed", pTrigger->GetMaxLeaveSpeed()); - subKey->SetFloat("bhopleavespeed", pTrigger->GetBhopLeaveSpeed()); + subKey->SetFloat("bhopleavespeed", pTrigger->GetMaxLeaveSpeed()); subKey->SetBool("limitingspeed", pTrigger->IsLimitingSpeed()); - subKey->SetBool("onlyxy", pTrigger->IsLimitingSpeedOnlyXY()); - subKey->SetBool("limitingspeedbhop", pTrigger->IsLimitingBhop()); if (pTrigger->GetHasLookAngles()) subKey->SetFloat("yaw", pTrigger->GetLookAngles()[YAW] ); } @@ -363,8 +354,6 @@ bool CMapzoneData::LoadFromFile(const char *szMapName) //int destinationIndex = -1; bool limitingspeed = true; bool checkonlyxy = true; - bool limitbhop = true; - float maxleavespeed = 290.0f; float bhopleavespeed = 250.0f; const char * linkedtrigger = NULL; @@ -374,11 +363,8 @@ bool CMapzoneData::LoadFromFile(const char *szMapName) { zoneType = MOMZONETYPE_START; limitingspeed = cp->GetBool("limitingspeed"); - maxleavespeed = cp->GetFloat("leavespeed"); bhopleavespeed = cp->GetFloat("bhopleavespeed"); start_yaw = cp->GetFloat("yaw", NO_LOOK); - checkonlyxy = cp->GetBool("onlyxy", true); - limitbhop = cp->GetBool("limitingspeedbhop", true); } else if (Q_strcmp(cp->GetName(), "checkpoint") == 0) { @@ -432,7 +418,7 @@ bool CMapzoneData::LoadFromFile(const char *szMapName) // Add element m_zones.AddToTail(new CMapzone(zoneType, pos, rot, scaleMins, scaleMaxs, index, shouldStop, shouldTilt, - holdTime, limitingspeed, maxleavespeed, bhopleavespeed, start_yaw, MAKE_STRING(linkedtrigger), checkonlyxy, limitbhop)); + holdTime, limitingspeed, bhopleavespeed, start_yaw, MAKE_STRING(linkedtrigger), checkonlyxy)); } DevLog("Successfully loaded map zone file %s!\n", zoneFilePath); toReturn = true; diff --git a/mp/src/game/server/momentum/mapzones.h b/mp/src/game/server/momentum/mapzones.h index 9973b1be0e..1d21ba12cd 100644 --- a/mp/src/game/server/momentum/mapzones.h +++ b/mp/src/game/server/momentum/mapzones.h @@ -22,8 +22,8 @@ class CMapzone CMapzone(); CMapzone(const int, Vector*, QAngle*, Vector*, Vector*, const int, const bool, const bool, const float, - const bool, const float, const float, const float, - const string_t, const bool, const bool); + const bool, const float, const float, + const string_t, const bool); ~CMapzone(); void SpawnZone(); diff --git a/mp/src/game/server/momentum/mapzones_edit.cpp b/mp/src/game/server/momentum/mapzones_edit.cpp index 6c5ad4f3d4..1a7cee1909 100644 --- a/mp/src/game/server/momentum/mapzones_edit.cpp +++ b/mp/src/game/server/momentum/mapzones_edit.cpp @@ -10,7 +10,6 @@ static ConVar mom_zone_grid("mom_zone_grid", "8", FCVAR_CHEAT, "Set grid size. 0 static ConVar mom_zone_defzone("mom_zone_defzone", "start", FCVAR_CHEAT, "If no zone type is passed to mom_zone_mark, use this.\n"); static ConVar mom_zone_start_limitspdmethod("mom_zone_start_limitspdmethod", "1", FCVAR_CHEAT, "0 = Take into account player z-velocity, 1 = Ignore z-velocity.\n", true, 0, true, 1); static ConVar mom_zone_stage_num("mom_zone_stage_num", "0", FCVAR_CHEAT, "Set stage number. Should start from 2. 0 to automatically find one.\n", true, 0, false, 0); -static ConVar mom_zone_start_maxleavespeed("mom_zone_start_maxleavespeed", "290", FCVAR_CHEAT, "Max leave speed. 0 to disable.\n", true, 0, false, 0); static ConVar mom_zone_start_maxbhopleavespeed("mom_zone_start_maxbhopleavespeed", "250", FCVAR_CHEAT, "Max leave speed if player bhopped. 0 to disable.\n", true, 0, false, 0); //static ConVar mom_zone_cp_num( "mom_zone_cp_num", "0", FCVAR_CHEAT, "Checkpoint number. 0 to automatically find one." ); @@ -262,27 +261,16 @@ void CMapzoneEdit::SetZoneProps(CBaseEntity *pEnt) //validate pointers if (pStart) { - if (mom_zone_start_maxleavespeed.GetFloat() > 0.0) - { - pStart->SetMaxLeaveSpeed(mom_zone_start_maxleavespeed.GetFloat()); - pStart->SetIsLimitingSpeed(true); - } - else - { - pStart->SetIsLimitingSpeed(false); - } //bhop speed limit if (mom_zone_start_maxbhopleavespeed.GetFloat() > 0.0) { - pStart->SetBhopLeaveSpeed(mom_zone_start_maxbhopleavespeed.GetFloat()); - pStart->SetIsLimitingBhop(true); + pStart->SetMaxLeaveSpeed(mom_zone_start_maxbhopleavespeed.GetFloat()); + pStart->SetIsLimitingSpeed(true); } else { - pStart->SetIsLimitingBhop(false); + pStart->SetIsLimitingSpeed(false); } - pStart->SetIsLimitingSpeedOnlyXY(mom_zone_start_limitspdmethod.GetBool()); - return; } diff --git a/mp/src/game/server/momentum/mom_player.cpp b/mp/src/game/server/momentum/mom_player.cpp index a8acfb5b6f..e62bd40998 100644 --- a/mp/src/game/server/momentum/mom_player.cpp +++ b/mp/src/game/server/momentum/mom_player.cpp @@ -1,8 +1,13 @@ #include "cbase.h" #include "mom_player.h" +#include "mom_triggers.h" +#include "in_buttons.h" +#include "Timer.h" #include "tier0/memdbgon.h" +#define AVERAGE_STATS_INTERVAL 0.1 + IMPLEMENT_SERVERCLASS_ST(CMomentumPlayer, DT_MOM_Player) SendPropInt(SENDINFO(m_iShotsFired)), SendPropInt(SENDINFO(m_iDirection)), @@ -10,15 +15,23 @@ SendPropBool(SENDINFO(m_bResumeZoom)), SendPropInt(SENDINFO(m_iLastZoom)), SendPropBool(SENDINFO(m_bAutoBhop)), SendPropBool(SENDINFO(m_bDidPlayerBhop)), +SendPropInt(SENDINFO(m_iSuccessiveBhops)), +SendPropFloat(SENDINFO(m_flStrafeSync)), +SendPropFloat(SENDINFO(m_flStrafeSync2)), +SendPropFloat(SENDINFO(m_flLastJumpVel)), END_SEND_TABLE() BEGIN_DATADESC(CMomentumPlayer) DEFINE_THINKFUNC(CheckForBhop), +DEFINE_THINKFUNC(UpdateRunStats), +DEFINE_THINKFUNC(CalculateAverageStats), +DEFINE_THINKFUNC(LimitSpeedInStartZone), END_DATADESC() LINK_ENTITY_TO_CLASS(player, CMomentumPlayer); PRECACHE_REGISTER(player); + CMomentumPlayer::CMomentumPlayer() { m_flPunishTime = -1; @@ -29,7 +42,7 @@ CMomentumPlayer::~CMomentumPlayer() {} void CMomentumPlayer::Precache() { -// Name of our entity's model + // Name of our entity's model #define ENTITY_MODEL "models/gibs/airboat_broken_engine.mdl" PrecacheModel(ENTITY_MODEL); @@ -55,7 +68,44 @@ void CMomentumPlayer::Spawn() DisableAutoBhop(); break; } - SetThink(&CMomentumPlayer::CheckForBhop); // Pass a function pointer + // Reset all bool gameevents + IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone"); + IGameEvent *runSaveEvent = gameeventmanager->CreateEvent("run_save"); + IGameEvent *timerStartEvent = gameeventmanager->CreateEvent("timer_started"); + IGameEvent *practiceModeEvent = gameeventmanager->CreateEvent("practice_mode"); + if (mapZoneEvent) + { + mapZoneEvent->SetBool("inside_startzone", false); + mapZoneEvent->SetBool("inside_endzone", false); + mapZoneEvent->SetBool("map_finished", false); + mapZoneEvent->SetInt("current_stage", 0); + mapZoneEvent->SetInt("stage_ticks", 0); + gameeventmanager->FireEvent(mapZoneEvent); + } + if (runSaveEvent) + { + runSaveEvent->SetBool("run_saved", false); + runSaveEvent->SetBool("run_posted", false); + gameeventmanager->FireEvent(runSaveEvent); + } + if (timerStartEvent) + { + timerStartEvent->SetBool("timer_isrunning", false); + gameeventmanager->FireEvent(timerStartEvent); + } + if (practiceModeEvent) + { + practiceModeEvent->SetBool("has_practicemode", false); + gameeventmanager->FireEvent(practiceModeEvent); + } + RegisterThinkContext("THINK_EVERY_TICK"); + RegisterThinkContext("CURTIME"); + RegisterThinkContext("THINK_AVERAGE_STATS"); + RegisterThinkContext("CURTIME_FOR_START"); + SetContextThink(&CMomentumPlayer::UpdateRunStats, gpGlobals->curtime + gpGlobals->interval_per_tick, "THINK_EVERY_TICK"); + SetContextThink(&CMomentumPlayer::CheckForBhop, gpGlobals->curtime, "CURTIME"); + SetContextThink(&CMomentumPlayer::CalculateAverageStats, gpGlobals->curtime + AVERAGE_STATS_INTERVAL, "THINK_AVERAGE_STATS"); + SetContextThink(&CMomentumPlayer::LimitSpeedInStartZone, gpGlobals->curtime, "CURTIME_FOR_START"); SetNextThink(gpGlobals->curtime); } @@ -159,7 +209,6 @@ void CMomentumPlayer::DisableAutoBhop() m_bAutoBhop = false; DevLog("Disabled autobhop\n"); } -bool CMomentumPlayer::HasAutoBhop() { return m_bAutoBhop; } void CMomentumPlayer::CheckForBhop() { if (GetGroundEntity() != NULL) @@ -167,8 +216,198 @@ void CMomentumPlayer::CheckForBhop() m_flTicksOnGround += gpGlobals->interval_per_tick; // true is player is on ground for less than 10 ticks, false if they are on ground for more s m_bDidPlayerBhop = (m_flTicksOnGround < NUM_TICKS_TO_BHOP * gpGlobals->interval_per_tick) != 0; + if (!m_bDidPlayerBhop) + m_iSuccessiveBhops = 0; + if (m_nButtons & IN_JUMP) + { + m_flLastJumpVel = GetLocalVelocity().Length2D(); + m_iSuccessiveBhops++; + if (g_Timer.IsRunning()) + { + int currentStage = g_Timer.GetCurrentStageNumber(); + m_nStageJumps[0]++; + m_nStageJumps[currentStage]++; + } + } } else m_flTicksOnGround = 0; - SetNextThink(gpGlobals->curtime); -} \ No newline at end of file + + SetNextThink(gpGlobals->curtime, "CURTIME"); +} +void CMomentumPlayer::UpdateRunStats() +{ + //should velocity be XY or XYZ? + ConVarRef hvel("mom_speedometer_hvel"); + IGameEvent *playerMoveEvent = gameeventmanager->CreateEvent("keypress"); + float velocity = hvel.GetBool() ? GetLocalVelocity().Length2D() : GetLocalVelocity().Length(); + + if (g_Timer.IsRunning()) + { + int currentStage = g_Timer.GetCurrentStageNumber(); + if (!m_bPrevTimerRunning) //timer started on this tick + { + //Reset old run stats + ResetRunStats(); + m_flStartSpeed = GetLocalVelocity().Length2D(); //prestrafe should always be XY only + //Comapre against successive bhops to avoid incrimenting when the player was in the air without jumping (for surf) + if (GetGroundEntity() == NULL && m_iSuccessiveBhops) + { + m_nStageJumps[0]++; + } + } + if (m_nButtons & IN_MOVELEFT && !(m_nPrevButtons & IN_MOVELEFT)) + { + m_nStageStrafes[0]++; + m_nStageStrafes[currentStage]++; + } + else if (m_nButtons & IN_MOVERIGHT && !(m_nPrevButtons & IN_MOVERIGHT)) + { + m_nStageStrafes[0]++; + m_nStageStrafes[currentStage]++; + } + // ---- MAX VELOCITY ---- + if (velocity > m_flStageVelocityMax[0]) + m_flStageVelocityMax[0] = velocity; + //also do max velocity per stage + if (velocity > m_flStageVelocityMax[currentStage]) + m_flStageVelocityMax[currentStage] = velocity; + // ---------- + + // --- STAGE ENTER VELOCITY --- + } + // ---- STRAFE SYNC ----- + float SyncVelocity = GetLocalVelocity().Length2DSqr(); //we always want HVEL for checking velocity sync + if (!(GetFlags() & (FL_ONGROUND | FL_INWATER)) && GetMoveType() != MOVETYPE_LADDER) + { + if (EyeAngles().y > m_qangLastAngle.y) //player turned left + { + m_nStrafeTicks++; + if ((m_nButtons & IN_MOVELEFT) && !(m_nButtons & IN_MOVERIGHT)) + m_nPerfectSyncTicks++; + if (SyncVelocity > m_flLastSyncVelocity) + m_nAccelTicks++; + } + else if (EyeAngles().y < m_qangLastAngle.y) //player turned right + { + m_nStrafeTicks++; + if ((m_nButtons & IN_MOVERIGHT) && !(m_nButtons & IN_MOVELEFT)) + m_nPerfectSyncTicks++; + if (SyncVelocity > m_flLastSyncVelocity) + m_nAccelTicks++; + } + } + if (m_nStrafeTicks && m_nAccelTicks && m_nPerfectSyncTicks) + { + m_flStrafeSync = ((float)m_nPerfectSyncTicks / (float)m_nStrafeTicks) * 100; // ticks strafing perfectly / ticks strafing + m_flStrafeSync2 = ((float)m_nAccelTicks / (float)m_nStrafeTicks) * 100; // ticks gaining speed / ticks strafing + } + // ---------- + + + m_qangLastAngle = EyeAngles(); + m_flLastSyncVelocity = SyncVelocity; + //this might be used in a later update + //m_flLastVelocity = velocity; + + m_bPrevTimerRunning = g_Timer.IsRunning(); + m_nPrevButtons = m_nButtons; + + if (playerMoveEvent) + { + playerMoveEvent->SetInt("num_strafes", m_nStageStrafes[0]); + playerMoveEvent->SetInt("num_jumps", m_nStageJumps[0]); + if ((m_nButtons & IN_JUMP && GetGroundEntity() != NULL) || m_nButtons & IN_MOVELEFT | IN_MOVERIGHT) + gameeventmanager->FireEvent(playerMoveEvent); + } + + //think once per tick + SetNextThink(gpGlobals->curtime + gpGlobals->interval_per_tick, "THINK_EVERY_TICK"); +} +void CMomentumPlayer::ResetRunStats() +{ + m_nPerfectSyncTicks = 0; + m_nStrafeTicks = 0; + m_nAccelTicks = 0; + m_flStrafeSync = 0; + m_flStrafeSync2 = 0; + + for (int i = 0; i < MAX_STAGES; i++) + { + m_nStageAvgCount[i] = 0; + m_nStageJumps[i] = 0; + m_nStageStrafes[i] = 0; + m_flStageTotalSync[i] = 0; + m_flStageTotalSync2[i] = 0; + m_flStageTotalVelocity[i] = 0; + m_flStageVelocityMax[i] = 0; + m_flStageVelocityAvg[i] = 0; + m_flStageStrafeSyncAvg[i] = 0; + m_flStageStrafeSync2Avg[i] = 0; + } +} +void CMomentumPlayer::CalculateAverageStats() +{ + ConVarRef hvel("mom_speedometer_hvel"); + + if (g_Timer.IsRunning()) + { + int currentStage = g_Timer.GetCurrentStageNumber(); + + m_flStageTotalSync[currentStage] += m_flStrafeSync; + m_flStageTotalSync2[currentStage] += m_flStrafeSync2; + m_flStageTotalVelocity[currentStage] += hvel.GetBool() ? GetLocalVelocity().Length2D() : GetLocalVelocity().Length(); + + m_nStageAvgCount[currentStage]++; + + m_flStageStrafeSyncAvg[currentStage] = m_flStageTotalSync[currentStage] / float(m_nStageAvgCount[currentStage]); + m_flStageStrafeSync2Avg[currentStage] = m_flStageTotalSync2[currentStage] / float(m_nStageAvgCount[currentStage]); + m_flStageVelocityAvg[currentStage] = m_flStageTotalVelocity[currentStage] / float(m_nStageAvgCount[currentStage]); + + //stage 0 is "overall" - also update these as well, no matter which stage we are on + m_flStageTotalSync[0] += m_flStrafeSync; + m_flStageTotalSync2[0] += m_flStrafeSync2; + m_flStageTotalVelocity[0] += hvel.GetBool() ? GetLocalVelocity().Length2D() : GetLocalVelocity().Length(); + m_nStageAvgCount[0]++; + + m_flStageStrafeSyncAvg[0] = m_flStageTotalSync[currentStage] / float(m_nStageAvgCount[currentStage]); + m_flStageStrafeSync2Avg[0] = m_flStageTotalSync2[currentStage] / float(m_nStageAvgCount[currentStage]); + m_flStageVelocityAvg[0] = m_flStageTotalVelocity[currentStage] / float(m_nStageAvgCount[currentStage]); + } + + // think once per 0.1 second interval so we avoid making the totals extremely large + SetNextThink(gpGlobals->curtime + AVERAGE_STATS_INTERVAL, "THINK_AVERAGE_STATS"); +} +//This limits the player's speed in the start zone, depending on which gamemode the player is currently playing. +//On surf/other, it only limits practice mode speed. On bhop/scroll, it limits the movement speed above a certain threshhold, and +//clamps the player's velocity if they go above it. This is to prevent prespeeding and is different per gamemode due to the different +//respective playstyles of surf and bhop. +void CMomentumPlayer::LimitSpeedInStartZone() +{ + ConVarRef gm("mom_gamemode"); + CTriggerTimerStart *startTrigger = g_Timer.GetStartTrigger(); + bool bhopGameMode = (gm.GetInt() == MOMGM_BHOP || gm.GetInt() == MOMGM_SCROLL); + if (m_bInsideStartZone) + { + if (GetGroundEntity() == NULL && !g_Timer.IsPracticeMode(this)) //don't count ticks in air if we're in practice mode + m_nTicksInAir++; + else + m_nTicksInAir = 0; + + //set bhop flag to true so we can't prespeed with practice mode + if (g_Timer.IsPracticeMode(this)) m_bDidPlayerBhop = true; + + //depending on gamemode, limit speed outright when player exceeds punish vel + if (bhopGameMode && ((!g_Timer.IsRunning() && m_nTicksInAir > MAX_AIRTIME_TICKS))) + { + Vector velocity = GetLocalVelocity(); + float PunishVelSquared = startTrigger->GetPunishSpeed()*startTrigger->GetPunishSpeed(); + if (velocity.Length2DSqr() > PunishVelSquared) //more efficent to check agaisnt the square of velocity + { + velocity = (velocity / velocity.Length()) * startTrigger->GetPunishSpeed(); + SetAbsVelocity(Vector(velocity.x, velocity.y, velocity.z)); + } + } + } + SetNextThink(gpGlobals->curtime, "CURTIME_FOR_START"); +} diff --git a/mp/src/game/server/momentum/mom_player.h b/mp/src/game/server/momentum/mom_player.h index 47d455a630..5ff4431e60 100644 --- a/mp/src/game/server/momentum/mom_player.h +++ b/mp/src/game/server/momentum/mom_player.h @@ -63,10 +63,14 @@ class CMomentumPlayer : public CBasePlayer void EnableAutoBhop(); void DisableAutoBhop(); - bool HasAutoBhop(); + bool HasAutoBhop() { return m_bAutoBhop; } bool DidPlayerBhop() { return m_bDidPlayerBhop; } // think function for detecting if player bhopped void CheckForBhop(); + void UpdateRunStats(); + void ResetRunStats(); + void CalculateAverageStats(); + void LimitSpeedInStartZone(); CNetworkVar(int, m_iShotsFired); CNetworkVar(int, m_iDirection); @@ -74,6 +78,10 @@ class CMomentumPlayer : public CBasePlayer CNetworkVar(int, m_iLastZoom); CNetworkVar(bool, m_bAutoBhop); CNetworkVar(bool, m_bDidPlayerBhop); + CNetworkVar(int, m_iSuccessiveBhops); + CNetworkVar(float, m_flStrafeSync); //eyeangle based, perfect strafes / total strafes + CNetworkVar(float, m_flStrafeSync2); //acceleration based, strafes speed gained / total strafes + CNetworkVar(float, m_flLastJumpVel); void GetBulletTypeParameters(int iBulletType, float &fPenetrationPower, float &flPenetrationDistance); @@ -91,7 +99,20 @@ class CMomentumPlayer : public CBasePlayer int GetLastBlock() { return m_iLastBlock; } float GetPunishTime() { return m_flPunishTime; } - private: + //stats: gets transmitted via IGameEvent + float m_flStartSpeed, m_flEndSpeed; + + //stage stats. index 0 is overall stats + int m_nStageJumps[MAX_STAGES], m_nStageStrafes[MAX_STAGES]; + float m_flStageVelocityMax[MAX_STAGES], m_flStageVelocityAvg[MAX_STAGES], + m_flStageStrafeSyncAvg[MAX_STAGES], m_flStageStrafeSync2Avg[MAX_STAGES], m_flStageEnterVelocity[MAX_STAGES]; + + //for calc avg + int m_nStageAvgCount[MAX_STAGES]; + float m_flStageTotalSync[MAX_STAGES], m_flStageTotalSync2[MAX_STAGES], m_flStageTotalVelocity[MAX_STAGES]; + + bool m_bInsideStartZone; +private: CountdownTimer m_ladderSurpressionTimer; Vector m_lastLadderNormal; Vector m_lastLadderPos; @@ -104,5 +125,20 @@ class CMomentumPlayer : public CBasePlayer friend class CMomentumGameMovement; float m_flPunishTime; int m_iLastBlock; + + //for strafe sync + float m_flLastVelocity, m_flLastSyncVelocity; + QAngle m_qangLastAngle; + + int m_nPerfectSyncTicks; + int m_nStrafeTicks; + int m_nAccelTicks; + + bool m_bPrevTimerRunning; + int m_nPrevButtons; + + //Start zone thinkfunc + int m_nTicksInAir; + const int MAX_AIRTIME_TICKS = 15; //The player can spend this many ticks in the air inside the start zone before their speed is limited }; #endif // MOMPLAYER_H \ No newline at end of file diff --git a/mp/src/game/server/momentum/mom_triggers.cpp b/mp/src/game/server/momentum/mom_triggers.cpp index 9ad6126fcd..7528d09fbf 100644 --- a/mp/src/game/server/momentum/mom_triggers.cpp +++ b/mp/src/game/server/momentum/mom_triggers.cpp @@ -6,12 +6,14 @@ #include "tier0/memdbgon.h" + // CBaseMomentumTrigger void CBaseMomentumTrigger::Spawn() { BaseClass::Spawn(); // temporary m_debugOverlays |= (OVERLAY_BBOX_BIT | OVERLAY_TEXT_BIT); + } //---------- CTriggerStage ----------------------------------------------------------------- @@ -27,6 +29,58 @@ void CTriggerStage::StartTouch(CBaseEntity *pOther) if (pOther->IsPlayer()) { g_Timer.SetCurrentStage(this); + + int stageNum = this->GetStageNumber(); + CMomentumPlayer *pPlayer = ToCMOMPlayer(pOther); + if (stageNum > 1) //Only for stages other than the first one; first stage stats NEED to be OnEndTouch + { + IGameEvent *stageEvent = gameeventmanager->CreateEvent("new_stage"); + if (stageEvent) + { + stageEvent->SetInt("stage_num", stageNum); + stageEvent->SetInt("stage_ticks", g_Timer.GetStageTicks(stageNum)); + stageEvent->SetFloat("avg_sync", pPlayer->m_flStageStrafeSyncAvg[stageNum]); + stageEvent->SetFloat("avg_sync2", pPlayer->m_flStageStrafeSync2Avg[stageNum]); + stageEvent->SetFloat("avg_vel", pPlayer->m_flStageVelocityAvg[stageNum]); + stageEvent->SetFloat("max_vel", pPlayer->m_flStageVelocityMax[stageNum]); + stageEvent->SetInt("num_strafes", pPlayer->m_nStageStrafes[stageNum]); + stageEvent->SetInt("num_jumps", pPlayer->m_nStageJumps[stageNum]); + + ConVarRef hvel("mom_speedometer_hvel"); + pPlayer->m_flStageEnterVelocity[stageNum] = hvel.GetBool() ? pPlayer->GetLocalVelocity().Length2D() : pPlayer->GetLocalVelocity().Length(); + stageEvent->SetFloat("stage_enter_vel", pPlayer->m_flStageEnterVelocity[stageNum]); + gameeventmanager->FireEvent(stageEvent); + } + } + } +} +void CTriggerStage::EndTouch(CBaseEntity *pOther) +{ + BaseClass::EndTouch(pOther); + if (pOther->IsPlayer()) + { + int stageNum = this->GetStageNumber(); + if (stageNum == 1) //redundant check for this being the first stage so we have to save stats on on EXIT rather than enter + { + CMomentumPlayer *pPlayer = ToCMOMPlayer(pOther); + IGameEvent *stageEvent = gameeventmanager->CreateEvent("new_stage"); + if (stageEvent) + { + stageEvent->SetInt("stage_num", stageNum); + stageEvent->SetInt("stage_ticks", g_Timer.GetStageTicks(stageNum)); + stageEvent->SetFloat("avg_sync", pPlayer->m_flStageStrafeSyncAvg[stageNum]); + stageEvent->SetFloat("avg_sync2", pPlayer->m_flStageStrafeSync2Avg[stageNum]); + stageEvent->SetFloat("avg_vel", pPlayer->m_flStageVelocityAvg[stageNum]); + stageEvent->SetFloat("max_vel", pPlayer->m_flStageVelocityMax[stageNum]); + stageEvent->SetInt("num_strafes", pPlayer->m_nStageStrafes[stageNum]); + stageEvent->SetInt("num_jumps", pPlayer->m_nStageJumps[stageNum]); + + ConVarRef hvel("mom_speedometer_hvel"); + pPlayer->m_flStageEnterVelocity[stageNum] = hvel.GetBool() ? pPlayer->GetLocalVelocity().Length2D() : pPlayer->GetLocalVelocity().Length(); + stageEvent->SetFloat("stage_enter_vel", pPlayer->m_flStageEnterVelocity[stageNum]); + gameeventmanager->FireEvent(stageEvent); + } + } } } //------------------------------------------------------------------------------------------ @@ -35,40 +89,45 @@ void CTriggerStage::StartTouch(CBaseEntity *pOther) LINK_ENTITY_TO_CLASS(trigger_momentum_timer_start, CTriggerTimerStart); BEGIN_DATADESC(CTriggerTimerStart) -DEFINE_KEYFIELD(m_fMaxLeaveSpeed, FIELD_FLOAT, "leavespeed"), DEFINE_KEYFIELD(m_fBhopLeaveSpeed, FIELD_FLOAT, "bhopleavespeed"), DEFINE_KEYFIELD(m_angLook, FIELD_VECTOR, "lookangles") END_DATADESC() void CTriggerTimerStart::EndTouch(CBaseEntity *pOther) { - if (pOther->IsPlayer() && !g_Timer.IsPracticeMode(pOther)) // do not start timer if player is in practice mode. + if (pOther->IsPlayer()) { - g_Timer.Start(gpGlobals->tickcount); + CMomentumPlayer *pPlayer = ToCMOMPlayer(pOther); - if (IsLimitingSpeed()) + //surf or other gamemodes has timer start on exiting zone, bhop timer starts when the player jumps + if (!g_Timer.IsPracticeMode(pOther) && !g_Timer.IsRunning()) // do not start timer if player is in practice mode or it's already running. { - Vector velocity = pOther->GetAbsVelocity(); - if (IsLimitingSpeedOnlyXY()) + if (IsLimitingSpeed()) { - // Isn't it nice how Vector2D.h doesn't have Normalize() on it? - // It only has a NormalizeInPlace... Not simple enough for me + Vector velocity = pOther->GetAbsVelocity(); + // Isn't it nice how Vector2D.h doesn't have Normalize() on it? + // It only has a NormalizeInPlace... Not simple enough for me Vector2D vel2D = velocity.AsVector2D(); - if (velocity.AsVector2D().IsLengthGreaterThan(m_bDidPlayerBhop ? m_fBhopLeaveSpeed : m_fMaxLeaveSpeed)) + if (pPlayer->DidPlayerBhop()) { - vel2D = ((vel2D / vel2D.Length()) * (m_bDidPlayerBhop ? m_fBhopLeaveSpeed : m_fMaxLeaveSpeed)); - pOther->SetAbsVelocity(Vector(vel2D.x, vel2D.y, velocity.z)); + if (velocity.AsVector2D().IsLengthGreaterThan(m_fBhopLeaveSpeed)) + { + vel2D = ((vel2D / vel2D.Length()) * (m_fBhopLeaveSpeed)); + pOther->SetAbsVelocity(Vector(vel2D.x, vel2D.y, velocity.z)); + } } + g_Timer.Start(gpGlobals->tickcount); } - // XYZ limit (this is likely never going to be used, or at least, it shouldn't be) - else - { - if (velocity.IsLengthGreaterThan((m_bDidPlayerBhop ? m_fBhopLeaveSpeed : m_fMaxLeaveSpeed))) - pOther->SetAbsVelocity(velocity.Normalized() * - (m_bDidPlayerBhop ? m_fBhopLeaveSpeed : m_fMaxLeaveSpeed)); - } + } + pPlayer->m_bInsideStartZone = false; + } + IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone"); + if (mapZoneEvent) + { + mapZoneEvent->SetBool("inside_startzone", false); + gameeventmanager->FireEvent(mapZoneEvent); } // stop thinking on end touch SetNextThink(-1); @@ -78,10 +137,26 @@ void CTriggerTimerStart::EndTouch(CBaseEntity *pOther) void CTriggerTimerStart::StartTouch(CBaseEntity *pOther) { g_Timer.SetStartTrigger(this); - if (pOther->IsPlayer() && g_Timer.IsRunning()) + + if (pOther->IsPlayer()) + { + CMomentumPlayer *pPlayer = ToCMOMPlayer(pOther); + pPlayer->m_bInsideStartZone = true; + pPlayer->m_flLastJumpVel = 0; //also reset last jump velocity when we enter the start zone + + if (g_Timer.IsRunning()) + { + g_Timer.Stop(false); + g_Timer.DispatchResetMessage(); + //lower the player's speed if they try to jump back into the start zone + } + } + IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone"); + if (mapZoneEvent) { - g_Timer.Stop(false); - g_Timer.DispatchResetMessage(); + mapZoneEvent->SetBool("inside_startzone", true); + mapZoneEvent->SetBool("map_finished", false); + gameeventmanager->FireEvent(mapZoneEvent); } // start thinking SetNextThink(gpGlobals->curtime); @@ -91,20 +166,16 @@ void CTriggerTimerStart::StartTouch(CBaseEntity *pOther) void CTriggerTimerStart::Spawn() { // We don't want negative velocities (We're checking against an absolute value) - m_fMaxLeaveSpeed = abs(m_fMaxLeaveSpeed); - m_fBhopLeaveSpeed = abs(m_fBhopLeaveSpeed); m_angLook.z = 0.0f; // Reset roll since mappers will never stop ruining everything. BaseClass::Spawn(); } - -void CTriggerTimerStart::SetMaxLeaveSpeed(float pMaxLeaveSpeed) { m_fMaxLeaveSpeed = abs(pMaxLeaveSpeed); } - -void CTriggerTimerStart::SetBhopLeaveSpeed(float pBhopMaxLeaveSpeed) { m_fBhopLeaveSpeed = abs(pBhopMaxLeaveSpeed); } - -void CTriggerTimerStart::SetIsLimitingSpeed(bool pIsLimitingSpeed) +void CTriggerTimerStart::SetMaxLeaveSpeed(float pBhopLeaveSpeed) { m_fBhopLeaveSpeed = pBhopLeaveSpeed; } +void CTriggerTimerStart::SetPunishSpeed(float pPunishSpeed) { m_fPunishSpeed = abs(pPunishSpeed); } +void CTriggerTimerStart::SetLookAngles(QAngle newang) { m_angLook = newang; } +void CTriggerTimerStart::SetIsLimitingSpeed(bool bIsLimitSpeed) { - if (pIsLimitingSpeed) + if (bIsLimitSpeed) { if (!HasSpawnFlags(SF_LIMIT_LEAVE_SPEED)) { @@ -119,43 +190,6 @@ void CTriggerTimerStart::SetIsLimitingSpeed(bool pIsLimitingSpeed) } } } - -void CTriggerTimerStart::SetIsLimitingSpeedOnlyXY(bool pIsLimitingSpeedOnlyXY) -{ - if (pIsLimitingSpeedOnlyXY) - { - if (!HasSpawnFlags(SF_LIMIT_LEAVE_SPEED_ONLYXY)) - { - AddSpawnFlags(SF_LIMIT_LEAVE_SPEED_ONLYXY); - } - } - else - { - if (HasSpawnFlags(SF_LIMIT_LEAVE_SPEED_ONLYXY)) - { - RemoveSpawnFlags(SF_LIMIT_LEAVE_SPEED_ONLYXY); - } - } -} - -void CTriggerTimerStart::SetIsLimitingBhop(bool bIsLimitBhop) -{ - if (bIsLimitBhop) - { - if (!HasSpawnFlags(SF_LIMIT_LEAVE_SPEED_BHOP)) - { - AddSpawnFlags(SF_LIMIT_LEAVE_SPEED_BHOP); - } - } - else - { - if (HasSpawnFlags(SF_LIMIT_LEAVE_SPEED_BHOP)) - { - RemoveSpawnFlags(SF_LIMIT_LEAVE_SPEED_BHOP); - } - } -} - void CTriggerTimerStart::SetHasLookAngles(bool bHasLook) { if (bHasLook) @@ -173,24 +207,6 @@ void CTriggerTimerStart::SetHasLookAngles(bool bHasLook) } } } -void CTriggerTimerStart::SetLookAngles(QAngle newang) { m_angLook = newang; } -void CTriggerTimerStart::Think() -{ - // for limit bhop in start zone - CMomentumPlayer *pPlayer = ToCMOMPlayer(UTIL_GetLocalPlayer()); - // We don't check for player inside trigger here since the Think() function - // is only called if we are inside (see StartTouch & EndTouch defined above) - if (pPlayer && IsLimitingBhop()) - { - if (pPlayer->DidPlayerBhop()) - m_bDidPlayerBhop = true; - else - m_bDidPlayerBhop = false; - } - - SetNextThink(gpGlobals->curtime); - BaseClass::Think(); -} //---------------------------------------------------------------------------------------------- //----------- CTriggerTimerStop ---------------------------------------------------------------- @@ -198,10 +214,54 @@ LINK_ENTITY_TO_CLASS(trigger_momentum_timer_stop, CTriggerTimerStop); void CTriggerTimerStop::StartTouch(CBaseEntity *pOther) { + CMomentumPlayer *pPlayer = ToCMOMPlayer(UTIL_GetLocalPlayer()); + + IGameEvent *timerStopEvent = gameeventmanager->CreateEvent("timer_stopped"); + IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone"); + ConVarRef hvel("mom_speedometer_hvel"); + BaseClass::StartTouch(pOther); // If timer is already stopped, there's nothing to stop (No run state effect to play) if (pOther->IsPlayer() && g_Timer.IsRunning()) + { + //send run stats via GameEventManager + if (timerStopEvent) + { + timerStopEvent->SetFloat("avg_sync", pPlayer->m_flStageStrafeSyncAvg[0]); + timerStopEvent->SetFloat("avg_sync2", pPlayer->m_flStageStrafeSync2Avg[0]); + timerStopEvent->SetFloat("avg_vel", pPlayer->m_flStageVelocityAvg[0]); + timerStopEvent->SetFloat("start_vel", pPlayer->m_flStartSpeed); + float endvel = hvel.GetBool() ? pPlayer->GetLocalVelocity().Length2D() : pPlayer->GetLocalVelocity().Length(); + timerStopEvent->SetFloat("end_vel", endvel); + + if (endvel > pPlayer->m_flStageVelocityMax[0]) + timerStopEvent->SetFloat("max_vel", endvel); + else + timerStopEvent->SetFloat("max_vel", pPlayer->m_flStageVelocityMax[0]); + + pPlayer->m_flEndSpeed = endvel; //we have to set end speed here or else it will be saved as 0 + timerStopEvent->SetInt("num_strafes", pPlayer->m_nStageStrafes[0]); + timerStopEvent->SetInt("num_jumps", pPlayer->m_nStageJumps[0]); + gameeventmanager->FireEvent(timerStopEvent); + } + if (mapZoneEvent) mapZoneEvent->SetBool("map_finished", true); //broadcast that we finished the map with a timer running g_Timer.Stop(true); + } + if (mapZoneEvent) + { + mapZoneEvent->SetBool("inside_endzone", true); + gameeventmanager->FireEvent(mapZoneEvent); + } +} +void CTriggerTimerStop::EndTouch(CBaseEntity* pOther) +{ + IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone"); + if (mapZoneEvent) + { + mapZoneEvent->SetBool("map_finished", false); //once we leave endzone, we no longer want to display end stats again + mapZoneEvent->SetBool("inside_endzone", false); + gameeventmanager->FireEvent(mapZoneEvent); + } } //---------------------------------------------------------------------------------------------- diff --git a/mp/src/game/server/momentum/mom_triggers.h b/mp/src/game/server/momentum/mom_triggers.h index cd5f96d934..987f8c5541 100644 --- a/mp/src/game/server/momentum/mom_triggers.h +++ b/mp/src/game/server/momentum/mom_triggers.h @@ -11,10 +11,8 @@ // spawnflags enum { //CTriggerTimerStart - SF_LIMIT_LEAVE_SPEED = 0x0001, // Limit max leave speed to m_fMaxLeaveSpeed? + SF_LIMIT_LEAVE_SPEED = 0x0001, // Limit speed if player bhopped in start zone? SF_USE_LOOKANGLES = 0x0002, // Use look angles? - SF_LIMIT_LEAVE_SPEED_ONLYXY = 0x0004, // Limit speed without taking into account hvel (Z axis) - SF_LIMIT_LEAVE_SPEED_BHOP = 0x0008, // Limit bhop in start zone? //CTriggerOneHop SF_TELEPORT_RESET_ONEHOP = 0x0010, // Reset hop state if player hops onto another different onehop //CTriggerLimitMove @@ -28,6 +26,7 @@ enum { SF_PUSH_ONSTART = 0x0400, // Modify player velocity on StartTouch SF_PUSH_ONEND = 0x0800, // Modify player velocity on EndTouch }; + // CBaseMomentumTrigger class CBaseMomentumTrigger : public CTriggerMultiple { @@ -44,6 +43,7 @@ class CTriggerTimerStop : public CBaseMomentumTrigger public: void StartTouch(CBaseEntity*); + void EndTouch(CBaseEntity*); }; // CTriggerTeleportEnt @@ -96,6 +96,7 @@ class CTriggerStage : public CTriggerCheckpoint public: void StartTouch(CBaseEntity*); + void EndTouch(CBaseEntity*); void Spawn() { SetCheckpointNumber(-1); @@ -120,38 +121,29 @@ class CTriggerTimerStart : public CTriggerStage void EndTouch(CBaseEntity*); void StartTouch(CBaseEntity*); void Spawn(); - void Think(); // The start is always the first stage/checkpoint int GetCheckpointNumber() { return -1; }//Override int GetStageNumber() { return 1; } - float GetMaxLeaveSpeed() { return m_fMaxLeaveSpeed; } - void SetMaxLeaveSpeed(float pMaxSpeed); - float GetBhopLeaveSpeed() { return m_fBhopLeaveSpeed; } - void SetBhopLeaveSpeed(float pBhopLeaveSpeed); + float GetMaxLeaveSpeed() { return m_fBhopLeaveSpeed; } + void SetMaxLeaveSpeed(float maxLeaveSpeed); void SetLookAngles(QAngle newang); QAngle GetLookAngles() { return m_angLook; } + void SetPunishSpeed(float pPunishSpeed); + float GetPunishSpeed() { return m_fPunishSpeed; } //spawnflags bool IsLimitingSpeed() { return HasSpawnFlags(SF_LIMIT_LEAVE_SPEED); } void SetIsLimitingSpeed(bool pIsLimitingSpeed); void SetHasLookAngles(bool bHasLook); bool GetHasLookAngles() { return HasSpawnFlags(SF_USE_LOOKANGLES); } - bool IsLimitingSpeedOnlyXY() { return HasSpawnFlags(SF_LIMIT_LEAVE_SPEED_ONLYXY); } - void SetIsLimitingSpeedOnlyXY(bool pIsLimitingSpeedOnlyXY); - bool IsLimitingBhop() { return HasSpawnFlags(SF_LIMIT_LEAVE_SPEED_BHOP); } - void SetIsLimitingBhop(bool bIsLimitBhop); private: QAngle m_angLook = QAngle(0, 0, 0); - // How fast can the player leave the start trigger? - float m_fMaxLeaveSpeed = 290; - - //limitbhop stuff + //How fast can player leave start trigger if they bhopped? float m_fBhopLeaveSpeed = 250; - //default false, so if SF_LIMIT_BHOP is not set we don't do any bhop limit stuff - bool m_bDidPlayerBhop {false}; + float m_fPunishSpeed = 200; }; // CFilterCheckpoint diff --git a/mp/src/game/server/momentum/server_events.cpp b/mp/src/game/server/momentum/server_events.cpp index 0fb20afb86..cdc6edef0e 100644 --- a/mp/src/game/server/momentum/server_events.cpp +++ b/mp/src/game/server/momentum/server_events.cpp @@ -3,7 +3,7 @@ #include "mapzones.h" #include "Timer.h" #include "mapzones_edit.h" -#include "momentum/mom_shareddefs.h" + #include "tier0/memdbgon.h" @@ -16,6 +16,10 @@ namespace Momentum { 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... diff --git a/mp/src/game/shared/momentum/mom_shareddefs.h b/mp/src/game/shared/momentum/mom_shareddefs.h index f42b0b7db4..c8b7fd256d 100644 --- a/mp/src/game/shared/momentum/mom_shareddefs.h +++ b/mp/src/game/shared/momentum/mom_shareddefs.h @@ -26,4 +26,13 @@ typedef enum MOMGM // If you have any doubts, please refer to http://semver.org/ #define MOM_CURRENT_VERSION "0.2.7" +#define MOM_COLORIZATION_CHECK_FREQUENCY 0.1f + +//buffers for cstr variables +#define BUFSIZETIME (sizeof("00:00:00.000")+1) +#define BUFSIZELOCL (73) +#define BUFSIZESHORT 10 + +#define MAX_STAGES 64 + #endif // MOM_SHAREDDEFS_H \ No newline at end of file diff --git a/mp/src/game/shared/momentum/util/mom_util.cpp b/mp/src/game/shared/momentum/util/mom_util.cpp index bc78321183..1f624a62fb 100644 --- a/mp/src/game/shared/momentum/util/mom_util.cpp +++ b/mp/src/game/shared/momentum/util/mom_util.cpp @@ -1,7 +1,8 @@ #include "cbase.h" #include "mom_util.h" #include "filesystem.h" - +#include "momentum/mom_shareddefs.h" +#include "mom_player_shared.h" #include "tier0/memdbgon.h" extern IFileSystem* filesystem; @@ -38,6 +39,8 @@ void MomentumUtil::PostTimeCallback(HTTPRequestCompleted_t *pCallback, bool bIOF uint8 *pData = new uint8[size]; steamapicontext->SteamHTTP()->GetHTTPResponseBodyData(pCallback->m_hRequest, pData, size); + IGameEvent *mapFinishedEvent = gameeventmanager->CreateEvent("run_save"); + JsonValue val;//Outer object JsonAllocator alloc; char* pDataPtr = reinterpret_cast(pData); @@ -60,12 +63,24 @@ void MomentumUtil::PostTimeCallback(HTTPRequestCompleted_t *pCallback, bool bIOF { DevLog("RESPONSE WAS TRUE!\n"); // Necesary so TimeDisplay scoreboard knows it has to update; - IGameEvent *postEvent = gameeventmanager->CreateEvent("runtime_posted"); - if (postEvent) - gameeventmanager->FireEvent(postEvent); + if (mapFinishedEvent) + { + mapFinishedEvent->SetBool("run_posted", true); + gameeventmanager->FireEvent(mapFinishedEvent); + } + //MOM_TODO: Once the server updates this to contain more info, parse and do more with the response } + // @tuxx: this bit of code SHOULD be changing the bool for run_posted only, but for some reason it seems to + // change the bool for run_saved as well. I can guess it's because they are in the same event, and the value was changed for + // run_saved but not fired. Either way, still really annoying. + + //else if (mapFinishedEvent) + //{ + // mapFinishedEvent->SetBool("run_posted", false); + // gameeventmanager->FireEvent(mapFinishedEvent); + //} } } else @@ -104,12 +119,12 @@ void MomentumUtil::DownloadMap(const char* szMapname) //CreateAndSendHTTPReq(zonFileURL, &cbDownloadCallback, &MomentumUtil::DownloadCallback); } - void MomentumUtil::CreateAndSendHTTPReq(const char* szURL, CCallResult* callback, CCallResult::func_t func) { HTTPRequestHandle handle = steamapicontext->SteamHTTP()->CreateHTTPRequest(k_EHTTPMethodGET, szURL); SteamAPICall_t apiHandle; + if (steamapicontext->SteamHTTP()->SendHTTPRequest(handle, &apiHandle)) { callback->Set(apiHandle, this, func); @@ -121,9 +136,43 @@ void MomentumUtil::CreateAndSendHTTPReq(const char* szURL, CCallResultSteamHTTP()->GetHTTPResponseBodySize(pCallback->m_hRequest, &size); + uint8 *pData = new uint8[size]; + steamapicontext->SteamHTTP()->GetHTTPResponseBodyData(pCallback->m_hRequest, pData, size); + char* pDataPtr = reinterpret_cast(pData); + const char separator[2] = "."; + CSplitString storedVersion = CSplitString(MOM_CURRENT_VERSION, separator); + CSplitString repoVersion = CSplitString(pDataPtr, separator); + + 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))) + { + ConVarRef("cl_showversionwarnpanel").SetValue(versionValue); + } + steamapicontext->SteamHTTP()->ReleaseHTTPRequest(pCallback->m_hRequest); +} + #endif -void MomentumUtil::FormatTime(float ticks, float rate, char *pOut) +void MomentumUtil::FormatTime(float ticks, float rate, char *pOut, int precision) { float m_flSecondsTime = ticks * rate; @@ -131,13 +180,59 @@ void MomentumUtil::FormatTime(float ticks, float rate, char *pOut) int minutes = fmod(m_flSecondsTime / 60.0f, 60.0f); int seconds = fmod(m_flSecondsTime, 60.0f); int millis = fmod(m_flSecondsTime, 1.0f) * 1000.0f; + int hundredths = millis / 10; + int tenths = millis / 100; + + switch (precision) + { + case 0: + if (hours > 0) + Q_snprintf(pOut, BUFSIZETIME, "%d:%02d:%02d", hours, minutes, seconds); + else if (minutes > 0) + Q_snprintf(pOut, BUFSIZETIME, "%d:%02d", minutes, seconds); + else + Q_snprintf(pOut, BUFSIZETIME, "%d", seconds); + break; + case 1: + if (hours > 0) + Q_snprintf(pOut, BUFSIZETIME, "%d:%02d:%02d.%d", hours, minutes, seconds, tenths); + else if (minutes > 0) + Q_snprintf(pOut, BUFSIZETIME, "%d:%02d.%d", minutes, seconds, tenths); + else + Q_snprintf(pOut, BUFSIZETIME, "%d.%d", seconds, tenths); + break; + case 2: + if (hours > 0) + Q_snprintf(pOut, BUFSIZETIME, "%d:%02d:%02d.%02d", hours, minutes, seconds, hundredths); + else if (minutes > 0) + Q_snprintf(pOut, BUFSIZETIME, "%d:%02d.%02d", minutes, seconds, hundredths); + else + Q_snprintf(pOut, BUFSIZETIME, "%d.%02d", seconds, hundredths); + break; + case 3: + if (hours > 0) + Q_snprintf(pOut, BUFSIZETIME, "%d:%02d:%02d.%03d", hours, minutes, seconds, millis); + else if (minutes > 0) + Q_snprintf(pOut, BUFSIZETIME, "%d:%02d.%03d", minutes, seconds, millis); + else + Q_snprintf(pOut, BUFSIZETIME, "%d.%03d", seconds, millis); + break; + } + +} + +Color MomentumUtil::GetColorFromVariation(float variation, float deadZone, Color normalcolor, Color increasecolor, Color decreasecolor) +{ + //variation is current velocity minus previous velocity. + Color pFinalColor = normalcolor; + deadZone = abs(deadZone); + + if (variation < -deadZone) //our velocity decreased + pFinalColor = decreasecolor; + else if (variation > deadZone) //our velocity increased + pFinalColor = increasecolor; - Q_snprintf(pOut, 15, "%02d:%02d:%02d.%03d", - hours, - minutes, - seconds, - millis - ); + return pFinalColor; } MomentumUtil mom_UTIL; \ No newline at end of file diff --git a/mp/src/game/shared/momentum/util/mom_util.h b/mp/src/game/shared/momentum/util/mom_util.h index acbe38debe..c297a52c1a 100644 --- a/mp/src/game/shared/momentum/util/mom_util.h +++ b/mp/src/game/shared/momentum/util/mom_util.h @@ -22,13 +22,19 @@ class MomentumUtil CCallResult cbDownloadCallback; CCallResult cbPostTimeCallback; + + void GetRemoteRepoModVersion(); + + CCallResult cbVersionCallback; + void VersionCallback(HTTPRequestCompleted_t*, bool); + #endif - //Formats time in ticks by a given tickrate into - //"HH:MM:SS.mmmm" - void FormatTime(float ticks, float rate, char *pOut); + Color GetColorFromVariation(float variation, float deadZone, Color normalcolor, Color increasecolor, Color decreasecolor); - + //Formats time in ticks by a given tickrate into time. Includes minutes if time > minutes, hours if time > hours, etc + //Precision is miliseconds by default + void FormatTime(float ticks, float rate, char *pOut, int precision = 3); }; extern MomentumUtil mom_UTIL;