diff --git a/gamedir/CMakeLists.txt b/gamedir/CMakeLists.txt index b807fb0c..c72e5ebb 100644 --- a/gamedir/CMakeLists.txt +++ b/gamedir/CMakeLists.txt @@ -15,23 +15,28 @@ set( CLIENT_FILES ui/gfx/default_avatar.tga ui/gfx/hud/speaker.tga ui/gfx/hud/speaker_self.tga + ui/gfx/hud/ammo_357.tga + ui/gfx/hud/ammo_9mm.tga + ui/gfx/hud/ammo_bolt.tga + ui/gfx/hud/ammo_buckshot.tga + ui/gfx/hud/ammo_energy.tga + ui/gfx/hud/ammo_grenade_frag.tga + ui/gfx/hud/ammo_grenade_hornet.tga + ui/gfx/hud/ammo_grenade_mp5.tga + ui/gfx/hud/ammo_grenade_rpg.tga + ui/gfx/hud/ammo_grenade_satchel.tga + ui/gfx/hud/ammo_grenade_tripmine.tga + ui/gfx/hud/ammo_snark.tga + ui/gfx/hud/default_ammo.tga ui/gfx/muted_icon32.tga ui/gfx/vgui/800corner1.tga ui/gfx/vgui/800corner2.tga ui/gfx/vgui/800corner3.tga ui/gfx/vgui/800corner4.tga - ui/resource/Chat.res - ui/resource/ChatScheme.res - ui/resource/ChatSchemeBase.res - ui/resource/ClientScheme.res - ui/resource/ClientSchemeBase.res - ui/resource/ClientSourceScheme.res - ui/resource/ClientSourceSchemeBase.res - ui/resource/MOTD.res - ui/resource/ScorePanel.res - ui/resource/SpectatorInfoPanel.res - ui/resource/TeamMenu.res + ui/resource/fonts/HemiHead426-Regular.ttf + ui/resource/fonts/HemiHead426-Linux-Regular.ttf + ui/resource/fonts/boxrocket.ttf ui/resource/language/bugfixedhl_english.utf8.txt ui/resource/language/bugfixedhl_russian.utf8.txt @@ -45,8 +50,6 @@ set( CLIENT_FILES ui/resource/language/chat_spanish.utf8.txt ui/resource/language/chat_tchinese.utf8.txt - ui/resource/open_source_software.txt - ui/resource/options/AboutSubOptions.res ui/resource/options/ChatSubOptions.res ui/resource/options/ColorPicker.res @@ -62,6 +65,23 @@ set( CLIENT_FILES ui/resource/updater/UpdateFileReplaceDialog.res ui/resource/updater/UpdateNotificationDialog.res + ui/resource/Chat.res + ui/resource/ChatScheme.res + ui/resource/ChatSchemeBase.res + ui/resource/ClientScheme.res + ui/resource/ClientSchemeBase.res + ui/resource/ClientSourceScheme.res + ui/resource/ClientSourceSchemeBase.res + ui/resource/HudAmmo.res + ui/resource/HudAmmoSecondary.res + ui/resource/HudBattery.res + ui/resource/HudHealth.res + ui/resource/MOTD.res + ui/resource/open_source_software.txt + ui/resource/ScorePanel.res + ui/resource/SpectatorInfoPanel.res + ui/resource/TeamMenu.res + ui/scripts/HudAnimations.txt ui/scripts/HudLayout.res ui/scripts/HudLayoutBase.res diff --git a/gamedir/ui/gfx/hud/ammo_357.tga b/gamedir/ui/gfx/hud/ammo_357.tga new file mode 100644 index 00000000..1c8bcf74 Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_357.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_9mm.tga b/gamedir/ui/gfx/hud/ammo_9mm.tga new file mode 100644 index 00000000..9fdd093a Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_9mm.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_bolt.tga b/gamedir/ui/gfx/hud/ammo_bolt.tga new file mode 100644 index 00000000..794fc841 Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_bolt.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_buckshot.tga b/gamedir/ui/gfx/hud/ammo_buckshot.tga new file mode 100644 index 00000000..3ed4e4e4 Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_buckshot.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_energy.tga b/gamedir/ui/gfx/hud/ammo_energy.tga new file mode 100644 index 00000000..f2357b35 Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_energy.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_grenade_frag.tga b/gamedir/ui/gfx/hud/ammo_grenade_frag.tga new file mode 100644 index 00000000..72f1a05c Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_grenade_frag.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_grenade_hornet.tga b/gamedir/ui/gfx/hud/ammo_grenade_hornet.tga new file mode 100644 index 00000000..9e30c4a6 Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_grenade_hornet.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_grenade_mp5.tga b/gamedir/ui/gfx/hud/ammo_grenade_mp5.tga new file mode 100644 index 00000000..722fe838 Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_grenade_mp5.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_grenade_rpg.tga b/gamedir/ui/gfx/hud/ammo_grenade_rpg.tga new file mode 100644 index 00000000..88e33fad Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_grenade_rpg.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_grenade_satchel.tga b/gamedir/ui/gfx/hud/ammo_grenade_satchel.tga new file mode 100644 index 00000000..a1c86b07 Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_grenade_satchel.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_grenade_tripmine.tga b/gamedir/ui/gfx/hud/ammo_grenade_tripmine.tga new file mode 100644 index 00000000..32d9a06c Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_grenade_tripmine.tga differ diff --git a/gamedir/ui/gfx/hud/ammo_snark.tga b/gamedir/ui/gfx/hud/ammo_snark.tga new file mode 100644 index 00000000..a8bad554 Binary files /dev/null and b/gamedir/ui/gfx/hud/ammo_snark.tga differ diff --git a/gamedir/ui/gfx/hud/default_ammo.tga b/gamedir/ui/gfx/hud/default_ammo.tga new file mode 100644 index 00000000..8f306e8a Binary files /dev/null and b/gamedir/ui/gfx/hud/default_ammo.tga differ diff --git a/gamedir/ui/resource/ClientSchemeBase.res b/gamedir/ui/resource/ClientSchemeBase.res index 05ab5610..dba66c7e 100644 --- a/gamedir/ui/resource/ClientSchemeBase.res +++ b/gamedir/ui/resource/ClientSchemeBase.res @@ -528,6 +528,74 @@ Scheme "symbol" "1" } } + + // Custom fonts for VGUI2 HUD + HudNumbers + { + "1" + { + "name" "Hemi Head 426" [$WINDOWS] + "name" "Hemi Head 426 Linux" [!$WINDOWS] + "tall" "26" + "weight" "0" + "additive" "1" + "antialias" "1" + } + } + HudNumbersGlow + { + "1" + { + "name" "Hemi Head 426" [$WINDOWS] + "name" "Hemi Head 426 Linux" [!$WINDOWS] + "tall" "26" + "weight" "0" + "additive" "1" + "antialias" "1" + "blur" "4" + "scanlines" "2" + "custom" "1" + } + } + HudNumbersSmall + { + "1" + { + "name" "Hemi Head 426" [$WINDOWS] + "name" "Hemi Head 426 Linux" [!$WINDOWS] + "tall" "18" + "weight" "0" + "additive" "1" + "antialias" "1" + } + } + HudNumbersSmallGlow + { + "1" + { + "name" "Hemi Head 426" [$WINDOWS] + "name" "Hemi Head 426 Linux" [!$WINDOWS] + "tall" "18" + "weight" "0" + "additive" "1" + "antialias" "1" + "blur" "4" + "scanlines" "2" + "custom" "1" + } + } + Icons // for health, armor, etc. + { + "1" + { + "name" "BoxRocket" + "tall" "24" + "weight" "0" + "additive" "1" + "antialias" "1" + "custom" "1" + } + } } // @@ -933,7 +1001,9 @@ Scheme CustomFontFiles { "1" "resource/HALFLIFE2.ttf" - + "2" "ui/resource/fonts/HemiHead426-Regular.ttf" + "3" "ui/resource/fonts/HemiHead426-Linux-Regular.ttf" + "4" "ui/resource/fonts/boxrocket.ttf" } } \ No newline at end of file diff --git a/gamedir/ui/resource/HudAmmo.res b/gamedir/ui/resource/HudAmmo.res new file mode 100644 index 00000000..e20ab915 --- /dev/null +++ b/gamedir/ui/resource/HudAmmo.res @@ -0,0 +1,221 @@ +"ui/resource/HudAmmo.res" +{ + "HudAmmoPanel" + { + "ControlName" "CHudAmmoPanel" + "fieldName" "HudAmmoPanel" + "xpos" "r120" + "ypos" "r35" + "wide" "100" + "tall" "25" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "PaintBackgroundType" "2" + + "bgcolor_override" "0 0 0 96" + + // Divider bar + "divider_xpos" "60" + "divider_ypos" "4" + "divider_wide" "2" + "divider_tall" "18" + "divider_offcolor" "128 128 128 96" + + // Resize bar when weapon has no clip + "bar_shrink" "1" + "bar_wide" "80" + "bar_full_wide" "122" + "bar_xpos" "r100" + "bar_full_xpos" "r142" + + // Ammo icon position + "ammoicon_xpos" "60" + "ammoicon_full_xpos" "102" + "ammoicon_ypos" "4" + "ammoicon_wide" "16" + "ammoicon_tall" "16" + } + "Clip" + { + "ControlName" "Label" + "fieldName" "Clip" + "fgcolor_override" "255 160 0 255" + "xpos" "4" + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbers" + "labelText" "000" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "ClipGlow" + { + "ControlName" "Label" + "fieldName" "ClipGlow" + "fgcolor_override" "255 160 0 255" + "xpos" "4" + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbersGlow" + "labelText" "000" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "ClipBg" + { + "ControlName" "Label" + "fieldName" "ClipBg" + "fgcolor_override" "128 128 128 16" + "xpos" "4" + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbers" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "Ammo" + { + "ControlName" "Label" + "fieldName" "Ammo" + "fgcolor_override" "255 160 0 255" + "xpos" "50" + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbersSmall" + "labelText" "000" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "AmmoGlow" + { + "ControlName" "Label" + "fieldName" "AmmoGlow" + "fgcolor_override" "255 160 0 255" + "xpos" "50" + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbersSmallGlow" + "labelText" "000" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "AmmoBg" + { + "ControlName" "Label" + "fieldName" "AmmoBg" + "fgcolor_override" "128 128 128 16" + "xpos" "50" + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbersSmall" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } +} diff --git a/gamedir/ui/resource/HudAmmoSecondary.res b/gamedir/ui/resource/HudAmmoSecondary.res new file mode 100644 index 00000000..b6baebb1 --- /dev/null +++ b/gamedir/ui/resource/HudAmmoSecondary.res @@ -0,0 +1,121 @@ +"ui/resource/HudAmmoSecondary.res" +{ + "HudAmmoSecondaryPanel" + { + "ControlName" "CHudAmmoSecondaryPanel" + "fieldName" "HudAmmoSecondaryPanel" + "xpos" "r68" + "ypos" "r58" + "wide" "48" + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "PaintBackgroundType" "2" + + "bgcolor_override" "0 0 0 96" + + // Ammo icon position + "ammoicon_xpos" "30" + "ammoicon_ypos" "4" + "ammoicon_wide" "12" + "ammoicon_tall" "12" + } + "Ammo" + { + "ControlName" "Label" + "fieldName" "Ammo" + "fgcolor_override" "255 160 0 255" + "xpos" "4" [$WINDOWS] + "xpos" "6" [!$WINDOWS] + "ypos" "0" + "wide" "24" [$WINDOWS] + "wide" "27" [!$WINDOWS] + "tall" "22" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbersSmall" + "labelText" "000" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "AmmoGlow" + { + "ControlName" "Label" + "fieldName" "AmmoGlow" + "fgcolor_override" "255 160 0 255" + "xpos" "4" [$WINDOWS] + "xpos" "6" [!$WINDOWS] + "ypos" "0" + "wide" "24" [$WINDOWS] + "wide" "27" [!$WINDOWS] + "tall" "22" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbersSmallGlow" + "labelText" "00" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "AmmoBg" + { + "ControlName" "Label" + "fieldName" "AmmoBg" + "fgcolor_override" "128 128 128 16" + "xpos" "4" [$WINDOWS] + "xpos" "6" [!$WINDOWS] + "ypos" "0" + "wide" "24" [$WINDOWS] + "wide" "27" [!$WINDOWS] + "tall" "22" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbersSmall" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } +} diff --git a/gamedir/ui/resource/HudBattery.res b/gamedir/ui/resource/HudBattery.res new file mode 100644 index 00000000..bc2a27b9 --- /dev/null +++ b/gamedir/ui/resource/HudBattery.res @@ -0,0 +1,137 @@ +"ui/resource/HudBattery.res" +{ + "HudBatteryPanel" + { + "ControlName" "CHudBatteryPanel" + "fieldName" "HudBatteryPanel" + "xpos" "112" + "ypos" "r35" + "wide" "76" + "tall" "25" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "PaintBackgroundType" "2" + "bgcolor_override" "0 0 0 96" + } + "BatteryIcon" + { + "ControlName" "Label" + "fieldName" "BatteryIcon" + "xpos" "6" + "ypos" "0" + "wide" "144" + "tall" "18" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "Icons" + "labelText" "*" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "BatteryAmount" + { + "ControlName" "Label" + "fieldName" "BatteryAmount" + "xpos" "18" [$WINDOWS] + "xpos" "20" [!$WINDOWS] + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbers" + "labelText" "100" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "BatteryAmountBg" + { + "ControlName" "Label" + "fieldName" "BatteryAmountBg" + "fgcolor_override" "128 128 128 16" + "xpos" "18" [$WINDOWS] + "xpos" "20" [!$WINDOWS] + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbers" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "BatteryAmountGlow" + { + "ControlName" "Label" + "fieldName" "BatteryAmountGlow" + "xpos" "18" [$WINDOWS] + "xpos" "20" [!$WINDOWS] + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbersGlow" + "labelText" "100" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } +} diff --git a/gamedir/ui/resource/HudHealth.res b/gamedir/ui/resource/HudHealth.res new file mode 100644 index 00000000..56d8ef7f --- /dev/null +++ b/gamedir/ui/resource/HudHealth.res @@ -0,0 +1,140 @@ +"ui/resource/HudHealth.res" +{ + "HudHealthPanel" + { + "ControlName" "CHudHealthPanel" + "fieldName" "HudHealthPanel" + "xpos" "20" + "ypos" "r35" + "wide" "76" + "tall" "25" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "0" + "enabled" "1" + "tabPosition" "0" + "PaintBackgroundType" "2" + "bgcolor_override" "0 0 0 96" + } + "HealthIcon" + { + "ControlName" "Label" + "fieldName" "HealthIcon" + "fgcolor_override" "255 160 0 255" + "xpos" "6" + "ypos" "0" + "wide" "144" + "tall" "18" + "autoResize" "0" + "pinCorner" "0" + "RoundedCorners" "15" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "Icons" + "labelText" "+" + "textAlignment" "west" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "0" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "HealthAmount" + { + "ControlName" "Label" + "fieldName" "HealthAmount" + "fgcolor_override" "255 160 0 255" + "xpos" "18" [$WINDOWS] + "xpos" "20" [!$WINDOWS] + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbers" + "labelText" "100" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "HealthAmountBg" + { + "ControlName" "Label" + "fieldName" "HealthAmountBg" + "fgcolor_override" "128 128 128 16" + "xpos" "18" [$WINDOWS] + "xpos" "20" [!$WINDOWS] + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbers" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } + "HealthAmountGlow" + { + "ControlName" "Label" + "fieldName" "HealthAmountGlow" + "fgcolor_override" "255 160 0 255" + "xpos" "18" [$WINDOWS] + "xpos" "20" [!$WINDOWS] + "ypos" "4" + "wide" "50" [$WINDOWS] + "wide" "52" [!$WINDOWS] + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "pin_corner_to_sibling" "0" + "pin_to_sibling_corner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "Font" "HudNumbersGlow" + "labelText" "100" + "textAlignment" "east" + "dulltext" "0" + "brighttext" "0" + "wrap" "0" + "centerwrap" "0" + "textinsetx" "5" + "textinsety" "0" + "auto_wide_tocontents" "0" + "use_proportional_insets" "0" + } +} diff --git a/gamedir/ui/resource/fonts/HemiHead426-Linux-Regular.ttf b/gamedir/ui/resource/fonts/HemiHead426-Linux-Regular.ttf new file mode 100644 index 00000000..d3f1d56d Binary files /dev/null and b/gamedir/ui/resource/fonts/HemiHead426-Linux-Regular.ttf differ diff --git a/gamedir/ui/resource/fonts/HemiHead426-Regular.ttf b/gamedir/ui/resource/fonts/HemiHead426-Regular.ttf new file mode 100644 index 00000000..bd2a13b4 Binary files /dev/null and b/gamedir/ui/resource/fonts/HemiHead426-Regular.ttf differ diff --git a/gamedir/ui/resource/fonts/boxrocket.ttf b/gamedir/ui/resource/fonts/boxrocket.ttf new file mode 100644 index 00000000..f430c2b5 Binary files /dev/null and b/gamedir/ui/resource/fonts/boxrocket.ttf differ diff --git a/gamedir/ui/scripts/HudLayoutBase.res b/gamedir/ui/scripts/HudLayoutBase.res index 67f7b3e0..09828150 100644 --- a/gamedir/ui/scripts/HudLayoutBase.res +++ b/gamedir/ui/scripts/HudLayoutBase.res @@ -9,6 +9,13 @@ //----------------------------------------------------------// "Resource/HudLayout.res" { + "HudVanilla" + { + "statusbar_ypos" "r45" + "ammohistory_ypos" "r42" + "weapon_xpos" "150" + } + "HudChat" { "ControlName" "EditablePanel" diff --git a/src/game/client/CMakeLists.txt b/src/game/client/CMakeLists.txt index 6586e463..91038f1e 100644 --- a/src/game/client/CMakeLists.txt +++ b/src/game/client/CMakeLists.txt @@ -132,12 +132,11 @@ set( SOURCE_FILES hud/voice_status_self.cpp hud/voice_status_self.h + vgui/IViewportPanel.h vgui/avatar_image.cpp vgui/avatar_image.h vgui/client_motd.cpp vgui/client_motd.h - vgui/client_viewport.cpp - vgui/client_viewport.h vgui/command_menu.cpp vgui/command_menu.h vgui/crosshair_image.cpp @@ -150,6 +149,16 @@ set( SOURCE_FILES vgui/team_menu.h vgui/tga_image.cpp vgui/tga_image.h + vgui/client_viewport.cpp + vgui/client_viewport.h + vgui/hud_ammo.cpp + vgui/hud_ammo.h + vgui/hud_ammo_secondary.cpp + vgui/hud_ammo_secondary.h + vgui/hud_battery.cpp + vgui/hud_battery.h + vgui/hud_health.cpp + vgui/hud_health.h vgui/viewport_panel_names.h bhlcfg.cpp diff --git a/src/game/client/hud.cpp b/src/game/client/hud.cpp index b47f8bda..7aef31ea 100644 --- a/src/game/client/hud.cpp +++ b/src/game/client/hud.cpp @@ -128,6 +128,9 @@ ConVar hud_color("hud_color", "255 160 0", FCVAR_BHL_ARCHIVE, "Main color of HUD ConVar hud_color1("hud_color1", "0 255 0", FCVAR_BHL_ARCHIVE, "HUD color when >= 90%"); ConVar hud_color2("hud_color2", "255 160 0", FCVAR_BHL_ARCHIVE, "HUD color when [50%; 90%)"); ConVar hud_color3("hud_color3", "255 96 0", FCVAR_BHL_ARCHIVE, "HUD color when (25%; 50%)"); +ConVar hud_color4("hud_color4", "255 0 0", FCVAR_BHL_ARCHIVE, "HUD color when (0%; 25%)"); +ConVar hud_color_override("hud_color_override", "0", FCVAR_ARCHIVE, "Enables/disables HUD coloring according to amount"); +ConVar hud_custom("hud_custom", "0", FCVAR_BHL_ARCHIVE, "Custom HUD using VGUI2"); ConVar hud_draw("hud_draw", "1", FCVAR_ARCHIVE, "Opacity of the HUD"); ConVar hud_dim("hud_dim", "1", FCVAR_BHL_ARCHIVE, "Dim inactive HUD elements"); ConVar hud_scale("hud_scale", "0", FCVAR_BHL_ARCHIVE, "HUD Scale: Auto, 50%, 100%, 200%, 400% (restart required)"); @@ -736,6 +739,12 @@ Color CHud::GetHudColor(HudPart hudPart, int value) if (hudPart == HudPart::Common) return m_HudColor; + if (value <= 25 && hudPart != HudPart::Armor) + return m_HudColor4; + + if (hud_color_override.GetBool()) + return m_HudColor; + if (value >= 90) return m_HudColor1; @@ -745,7 +754,7 @@ Color CHud::GetHudColor(HudPart hudPart, int value) if (value > 25 || hudPart == HudPart::Armor) return m_HudColor3; - return Color(255, 0, 0, 255); + return m_HudColor4; } void CHud::GetHudColor(HudPart hudPart, int value, int &r, int &g, int &b) @@ -759,7 +768,8 @@ void CHud::GetHudColor(HudPart hudPart, int value, int &r, int &g, int &b) void CHud::GetHudAmmoColor(int value, int maxvalue, int &r, int &g, int &b) { Color c; - if (maxvalue == -1 || maxvalue == 0) + + if (maxvalue == -1 || maxvalue == 0 || hud_color_override.GetBool()) { // Custom weapons will use default colors c = m_HudColor; @@ -778,10 +788,7 @@ void CHud::GetHudAmmoColor(int value, int maxvalue, int &r, int &g, int &b) } else { - r = 255; - g = 0; - b = 0; - return; + c = m_HudColor4; } r = c.r(); @@ -789,6 +796,38 @@ void CHud::GetHudAmmoColor(int value, int maxvalue, int &r, int &g, int &b) b = c.b(); } + +std::pair CHud::GetHudDimAlphas(float &fade) +{ + constexpr float MIN_ALPHA1 = 0.0f; // We want glow effect to hide when not dimmed + constexpr float MIN_ALPHA2 = 200.0f; // We want normal text to be visible even when dimmed + + int a1 = 255; + int a2 = 255; + + if (!hud_dim.GetBool()) + { + a1 = MIN_ALPHA1; + a2 = MIN_ALPHA + ALPHA_POINTS_MAX; + fade = FADE_TIME; + } + else if (fade > 0) + { + fade -= m_flTimeDelta * HUD_FADE_RATE; + if (fade <= 0) + fade = 0; + float fadeProgress = fade / FADE_TIME; + a1 = MIN_ALPHA1 + fadeProgress * (255.0f - MIN_ALPHA1); + a2 = MIN_ALPHA2 + fadeProgress * (255.0f - MIN_ALPHA2); + } + else + { + a1 = MIN_ALPHA1; + a2 = MIN_ALPHA2; + } + return {a1, a2}; +} + float CHud::GetHudTransparency() { return clamp(hud_draw.GetFloat(), 0.f, 1.f); @@ -818,6 +857,7 @@ void CHud::UpdateHudColors() ParseColor(hud_color1.GetString(), m_HudColor1); ParseColor(hud_color2.GetString(), m_HudColor2); ParseColor(hud_color3.GetString(), m_HudColor3); + ParseColor(hud_color4.GetString(), m_HudColor4); } void CHud::UpdateSupportsCvar() diff --git a/src/game/client/hud.h b/src/game/client/hud.h index 45a82bcb..5f0f77ca 100644 --- a/src/game/client/hud.h +++ b/src/game/client/hud.h @@ -53,6 +53,9 @@ #define HUD_INTERMISSION 2 #define HUD_DRAW_ALWAYS 4 //!< Draw even if hud_draw = 0 +//! Speed at which HUD will fade out +constexpr float HUD_FADE_RATE = 20; + //! Fallback sprite resolution if the current one can't be found. constexpr int HUD_FALLBACK_RES = 640; @@ -222,6 +225,15 @@ class CHud void GetHudAmmoColor(int value, int maxvalue, int &r, int &g, int &b); + /** + * Calculate alphas for custom VGUI2 HUD when doing dimming effect. + * Alpha 1 is for glow effect, visible only when dimmed. + * Alpha 2 is for normal text, gets dimmed too. + * @param fade Fade timer. Decremented automatically. + * @returns Alpha 1 and alpha 2. + */ + std::pair GetHudDimAlphas(float &fade); + float GetHudTransparency(); ColorCodeAction GetColorCodeAction(); @@ -290,6 +302,7 @@ class CHud Color m_HudColor1; Color m_HudColor2; Color m_HudColor3; + Color m_HudColor4; Color m_ColorCodeColors[10]; ColorCodeAction m_ColorCodeAction; @@ -344,6 +357,7 @@ extern CHud gHUD; extern ConVar hud_draw; extern ConVar hud_dim; +extern ConVar hud_custom; extern ConVar default_fov; extern int g_iPlayerClass; diff --git a/src/game/client/hud/ammo.cpp b/src/game/client/hud/ammo.cpp index 9b0c9e05..4f8299c7 100644 --- a/src/game/client/hud/ammo.cpp +++ b/src/game/client/hud/ammo.cpp @@ -31,6 +31,8 @@ #include "crosshair.h" #include "menu.h" #include "vgui/client_viewport.h" +#include "vgui/hud_ammo.h" +#include "vgui/hud_ammo_secondary.h" ConVar hud_fastswitch("hud_fastswitch", "0", FCVAR_ARCHIVE, "Controls whether or not weapons can be selected in one keypress"); ConVar hud_weapon("hud_weapon", "0", FCVAR_BHL_ARCHIVE, "Controls displaying sprite of currently selected weapon"); @@ -858,10 +860,22 @@ void CHudAmmo::Draw(float flTime) int AmmoWidth; if (!(gHUD.m_iWeaponBits & (1 << (WEAPON_SUIT)))) + { + if (g_pViewport) { + g_pViewport->GetAmmoPanel()->ShowPanel(false); + g_pViewport->GetAmmoSecondaryPanel()->ShowPanel(false); + } return; + } if ((gHUD.m_iHideHUDDisplay & (HIDEHUD_WEAPONS | HIDEHUD_ALL))) + { + if (g_pViewport) { + g_pViewport->GetAmmoPanel()->ShowPanel(false); + g_pViewport->GetAmmoSecondaryPanel()->ShowPanel(false); + } return; + } // Draw Weapon Menu DrawWList(flTime); @@ -906,14 +920,21 @@ void CHudAmmo::Draw(float flTime) if (hud_weapon.GetBool()) { y = ScreenHeight - (m_pWeapon->rcInactive.bottom - m_pWeapon->rcInactive.top); - x = ScreenWidth - (8.5 * AmmoWidth) - (m_pWeapon->rcInactive.right - m_pWeapon->rcInactive.left); + x = ScreenWidth - (hud_custom.GetBool() ? g_pViewport->GetWeaponXPos() : (8.5 * AmmoWidth)) - (m_pWeapon->rcInactive.right - m_pWeapon->rcInactive.left); SPR_Set(m_pWeapon->hInactive, r, g, b); SPR_DrawAdditive(0, x, y, &m_pWeapon->rcInactive); } // SPR_Draw Ammo if ((pw->iAmmoType < 0) && (pw->iAmmo2Type < 0)) + { + if (g_pViewport) + { + g_pViewport->GetAmmoPanel()->ShowPanel(false); + g_pViewport->GetAmmoSecondaryPanel()->ShowPanel(false); + } return; + } int iFlags = DHN_DRAWZERO; // draw 0 values @@ -921,8 +942,27 @@ void CHudAmmo::Draw(float flTime) y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; y += (int)(gHUD.m_iFontHeight * 0.2f); + + if (g_pViewport) + { + if (hud_custom.GetBool()) + { + g_pViewport->GetAmmoPanel()->UpdateAmmoPanel(m_pWeapon, GetMaxClip(pw->szName), gWR.CountAmmo(pw->iAmmoType), gWR.CountAmmo(pw->iAmmo2Type)); + g_pViewport->GetAmmoSecondaryPanel()->UpdateAmmoSecondaryPanel(m_pWeapon, GetMaxClip(pw->szName), gWR.CountAmmo(pw->iAmmoType), gWR.CountAmmo(pw->iAmmo2Type)); + g_pViewport->GetAmmoPanel()->ShowPanel(true); + } + else + { + g_pViewport->GetAmmoPanel()->ShowPanel(false); + } + } + + if (hud_custom.GetBool()) + { + // Hide vanilla hud ammo + } // Does weapon have any ammo at all? - if (m_pWeapon->iAmmoType > 0) + else if (m_pWeapon->iAmmoType > 0) { int iIconWidth = m_pWeapon->rcAmmo.right - m_pWeapon->rcAmmo.left; @@ -972,7 +1012,7 @@ void CHudAmmo::Draw(float flTime) SPR_DrawAdditive(0, x, y - iOffset, &m_pWeapon->rcAmmo); } - // Does weapon have seconday ammo? + // Does weapon have secondary ammo? if (pw->iAmmo2Type > 0) { int iIconWidth = m_pWeapon->rcAmmo2.right - m_pWeapon->rcAmmo2.left; @@ -980,6 +1020,16 @@ void CHudAmmo::Draw(float flTime) // Do we have secondary ammo? if ((pw->iAmmo2Type != 0) && (gWR.CountAmmo(pw->iAmmo2Type) > 0)) { + if (hud_custom.GetBool()) + { + g_pViewport->GetAmmoSecondaryPanel()->ShowPanel(true); + return; // Hide vanilla secondary ammo + } + else + { + g_pViewport->GetAmmoSecondaryPanel()->ShowPanel(false); + } + a = alphaDim * gHUD.GetHudTransparency(); gHUD.GetHudAmmoColor(pw->iClip, GetMaxClip(pw->szName), r, g, b); ScaleColors(r, g, b, a); diff --git a/src/game/client/hud/ammohistory.cpp b/src/game/client/hud/ammohistory.cpp index 6cb58032..54cde6ff 100644 --- a/src/game/client/hud/ammohistory.cpp +++ b/src/game/client/hud/ammohistory.cpp @@ -24,13 +24,15 @@ #include #include "ammohistory.h" +#include "vgui/client_viewport.h" ConVar hud_drawhistory_time("hud_drawhistory_time", "5", FCVAR_BHL_ARCHIVE, "How long should ammo history stay up for in seconds"); HistoryResource gHR; +// Allow to change ammo history position when using custom HUD to avoid overlapping #define AMMO_PICKUP_GAP (gHR.iHistoryGap + 5) -#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2)) +#define AMMO_PICKUP_PICK_HEIGHT (((hud_custom.GetBool()) ? ScreenHeight - g_pViewport->GetAmmoHistoryYPos() : 32) + (gHR.iHistoryGap * 2)) #define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100) #define MAX_ITEM_NAME 32 diff --git a/src/game/client/hud/battery.cpp b/src/game/client/hud/battery.cpp index 01cb6983..49cf144b 100644 --- a/src/game/client/hud/battery.cpp +++ b/src/game/client/hud/battery.cpp @@ -24,6 +24,8 @@ #include "cl_util.h" #include "parsemsg.h" #include "battery.h" +#include "vgui/client_viewport.h" +#include "vgui/hud_battery.h" DEFINE_HUD_ELEM(CHudBattery); @@ -56,6 +58,9 @@ int CHudBattery::MsgFunc_Battery(const char *pszName, int iSize, void *pbuf) BEGIN_READ(pbuf, iSize); int battery = READ_SHORT(); + if (g_pViewport) + g_pViewport->GetBatteryPanel()->UpdateBatteryPanel(battery); + if (battery != m_iBat) { m_fFade = FADE_TIME; @@ -67,6 +72,9 @@ int CHudBattery::MsgFunc_Battery(const char *pszName, int iSize, void *pbuf) void CHudBattery::Draw(float flTime) { + if (hud_custom.GetBool()) + return; + if (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) return; diff --git a/src/game/client/hud/health.cpp b/src/game/client/hud/health.cpp index b3dd36f5..2e1de746 100644 --- a/src/game/client/hud/health.cpp +++ b/src/game/client/hud/health.cpp @@ -27,6 +27,8 @@ #include "cl_util.h" #include "parsemsg.h" #include "health.h" +#include "vgui/client_viewport.h" +#include "vgui/hud_health.h" #define PAIN_NAME "sprites/%d_pain.spr" #define DAMAGE_NAME "sprites/%d_dmg.spr" @@ -100,6 +102,9 @@ int CHudHealth::MsgFunc_Health(const char *pszName, int iSize, void *pbuf) BEGIN_READ(pbuf, iSize); int x = READ_BYTE(); + if (g_pViewport) + g_pViewport->GetHealthPanel()->UpdateHealthPanel(x); + m_iFlags |= HUD_ACTIVE; // Only update the fade if we've changed health @@ -169,6 +174,9 @@ void CHudHealth::Draw(float flTime) float a; int HealthWidth; + if (hud_custom.GetBool()) + return; + if ((gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly()) return; @@ -180,7 +188,7 @@ void CHudHealth::Draw(float flTime) else if (m_fFade > 0) { // Fade the health number back to dim - m_fFade -= (gHUD.m_flTimeDelta * 20); + m_fFade -= gHUD.m_flTimeDelta * HUD_FADE_RATE; if (m_fFade <= 0) m_fFade = 0; a = MIN_ALPHA + (m_fFade / FADE_TIME) * ALPHA_POINTS_FLASH; diff --git a/src/game/client/hud/statusbar.cpp b/src/game/client/hud/statusbar.cpp index 51af0bca..64cdfedd 100644 --- a/src/game/client/hud/statusbar.cpp +++ b/src/game/client/hud/statusbar.cpp @@ -27,6 +27,7 @@ #include "parsemsg.h" #include "statusbar.h" #include "text_message.h" +#include "vgui/client_viewport.h" #ifdef _TFC #define STATUSBAR_ID_LINE 2 @@ -190,7 +191,8 @@ void CHudStatusBar::Draw(float fTime) m_bReparseString = FALSE; } - int Y_START = ScreenHeight - 52; + // Allow to change status bar position when using custom HUD to avoid overlapping + int Y_START = hud_custom.GetBool() ? g_pViewport->GetStatusBarYPos() : ScreenHeight - 52; // Draw the status bar lines for (int i = 0; i < MAX_STATUSBAR_LINES; i++) diff --git a/src/game/client/hud_redraw.cpp b/src/game/client/hud_redraw.cpp index 7430918c..a2633b74 100644 --- a/src/game/client/hud_redraw.cpp +++ b/src/game/client/hud_redraw.cpp @@ -22,6 +22,8 @@ #include "cl_util.h" #include "hud/spectator.h" #include "vgui/client_viewport.h" +#include "vgui/hud_health.h" +#include "vgui/hud_battery.h" #include "results.h" #include "svc_messages.h" @@ -169,6 +171,21 @@ int CHud::Redraw(float flTime, int intermission) // if no redrawing is necessary // return 0; + bool showCustomHudPanels = + hud_draw.GetFloat() > 0 && + hud_custom.GetBool() && + (m_iWeaponBits & (1 << (WEAPON_SUIT))) && + !( + (m_iHideHUDDisplay & (HIDEHUD_ALL | HIDEHUD_HEALTH)) || + gEngfuncs.IsSpectateOnly() + ); + + if (g_pViewport) + { + g_pViewport->GetHealthPanel()->ShowPanel(showCustomHudPanels); + g_pViewport->GetBatteryPanel()->ShowPanel(showCustomHudPanels); + } + // draw all registered HUD elements if (hud_draw.GetFloat() > 0) { diff --git a/src/game/client/vgui/client_viewport.cpp b/src/game/client/vgui/client_viewport.cpp index d56cbfc0..fe243d30 100644 --- a/src/game/client/vgui/client_viewport.cpp +++ b/src/game/client/vgui/client_viewport.cpp @@ -18,6 +18,10 @@ #include "score_panel.h" #include "client_motd.h" #include "spectator_panel.h" +#include "hud_health.h" +#include "hud_battery.h" +#include "hud_ammo.h" +#include "hud_ammo_secondary.h" #include "team_menu.h" #include "command_menu.h" @@ -131,6 +135,28 @@ void CClientViewport::ReloadLayout() { // reload the .res file from disk LoadControlSettings(VGUI2_ROOT_DIR "scripts/HudLayout.res"); + m_pHudAmmoPanel->LoadControlSettings(VGUI2_ROOT_DIR "resource/HudAmmo.res"); + m_pHudHealthPanel->LoadControlSettings(VGUI2_ROOT_DIR "resource/HudHealth.res"); + m_pHudBatteryPanel->LoadControlSettings(VGUI2_ROOT_DIR "resource/HudBattery.res"); + m_pHudAmmoSecondaryPanel->LoadControlSettings(VGUI2_ROOT_DIR "resource/HudAmmoSecondary.res"); + + // Load custom positions for the vanilla HUD to avoid overlapping with the new HUD + KeyValues *layoutKV = new KeyValues("HudLayout"); + if (layoutKV->LoadFromFile(g_pFullFileSystem, VGUI2_ROOT_DIR "scripts/HudLayout.res")) + { + KeyValues *vanillaKV = layoutKV->FindKey("HudVanilla"); + if (vanillaKV) + { + const char* szStatusBarY = vanillaKV->GetString("statusbar_ypos", "0"); + const char* szAmmoHistoryY = vanillaKV->GetString("ammohistory_ypos", "0"); + const char* szWeaponX = vanillaKV->GetString("weapon_xpos", "0"); + + ComputePos(szStatusBarY, m_iStatusBarYPos, 0, GetTall(), true); + ComputePos(szAmmoHistoryY, m_iAmmoHistoryYPos, 0, GetTall(), true); + ComputePos(szWeaponX, m_iWeaponXPos, 0, GetWide(), true); + } + + } InvalidateLayout(true, true); } @@ -140,6 +166,10 @@ void CClientViewport::CreateDefaultPanels() AddNewPanel(m_pScorePanel = new CScorePanel()); AddNewPanel(m_pMOTD = new CClientMOTD()); AddNewPanel(m_pSpectatorPanel = new CSpectatorPanel()); + AddNewPanel(m_pHudHealthPanel = new CHudHealthPanel()); + AddNewPanel(m_pHudBatteryPanel = new CHudBatteryPanel()); + AddNewPanel(m_pHudAmmoPanel = new CHudAmmoPanel()); + AddNewPanel(m_pHudAmmoSecondaryPanel = new CHudAmmoSecondaryPanel()); AddNewPanel(m_pTeamMenu = new CTeamMenu()); AddNewPanel(m_pCommandMenu = new CCommandMenu()); } @@ -311,6 +341,41 @@ void CClientViewport::HideScoreBoard() m_pScorePanel->ShowPanel(false); } +CHudHealthPanel *CClientViewport::GetHealthPanel() +{ + return m_pHudHealthPanel; +} + +CHudBatteryPanel *CClientViewport::GetBatteryPanel() +{ + return m_pHudBatteryPanel; +} + +CHudAmmoPanel *CClientViewport::GetAmmoPanel() +{ + return m_pHudAmmoPanel; +} + +CHudAmmoSecondaryPanel *CClientViewport::GetAmmoSecondaryPanel() +{ + return m_pHudAmmoSecondaryPanel; +} + +int CClientViewport::GetAmmoHistoryYPos() +{ + return m_iAmmoHistoryYPos; +} + +int CClientViewport::GetStatusBarYPos() +{ + return m_iStatusBarYPos; +} + +int CClientViewport::GetWeaponXPos() +{ + return m_iWeaponXPos; +} + void CClientViewport::UpdateSpectatorPanel() { m_iUser1 = g_iUser1; diff --git a/src/game/client/vgui/client_viewport.h b/src/game/client/vgui/client_viewport.h index df1823b3..d18af5a7 100644 --- a/src/game/client/vgui/client_viewport.h +++ b/src/game/client/vgui/client_viewport.h @@ -39,8 +39,13 @@ enum class CScorePanel; class CClientMOTD; class CSpectatorPanel; +class CHudHealthPanel; +class CHudBatteryPanel; +class CHudAmmoPanel; +class CHudAmmoSecondaryPanel; class CTeamMenu; class CCommandMenu; +struct WEAPON; class CClientViewport : public vgui2::EditablePanel { @@ -63,6 +68,16 @@ class CClientViewport : public vgui2::EditablePanel void ShowVGUIMenu(int iMenu); void HideAllVGUIMenu(); + CHudHealthPanel *GetHealthPanel(); + CHudBatteryPanel *GetBatteryPanel(); + CHudAmmoPanel *GetAmmoPanel(); + CHudAmmoSecondaryPanel *GetAmmoSecondaryPanel(); + + // Allows to get custom positions to avoid overlapping with other panels + int GetAmmoHistoryYPos(); + int GetStatusBarYPos(); + int GetWeaponXPos(); + bool IsScoreBoardVisible(); void ShowScoreBoard(); void HideScoreBoard(); @@ -110,6 +125,10 @@ class CClientViewport : public vgui2::EditablePanel CScorePanel *m_pScorePanel = nullptr; CClientMOTD *m_pMOTD = nullptr; CSpectatorPanel *m_pSpectatorPanel = nullptr; + CHudHealthPanel *m_pHudHealthPanel = nullptr; + CHudBatteryPanel *m_pHudBatteryPanel = nullptr; + CHudAmmoPanel *m_pHudAmmoPanel = nullptr; + CHudAmmoSecondaryPanel *m_pHudAmmoSecondaryPanel = nullptr; CTeamMenu *m_pTeamMenu = nullptr; CCommandMenu *m_pCommandMenu = nullptr; @@ -131,6 +150,11 @@ class CClientViewport : public vgui2::EditablePanel float m_flMenuOpenTime = 0; bool m_bMenuIsKeyTapped = false; + // Custom HUD positions + int m_iStatusBarYPos = 0; + int m_iAmmoHistoryYPos = 0; + int m_iWeaponXPos = 0; + Color m_pTeamColors[5] = { Color(216, 216, 216, 255), // "Off" white (default) Color(153, 204, 255, 255), // Blue diff --git a/src/game/client/vgui/hud_ammo.cpp b/src/game/client/vgui/hud_ammo.cpp new file mode 100644 index 00000000..0f8810a3 --- /dev/null +++ b/src/game/client/vgui/hud_ammo.cpp @@ -0,0 +1,314 @@ +#include +#include +#include +#include +#include +#include "hud.h" +#include "client_vgui.h" +#include "client_viewport.h" +#include "hud_ammo.h" +#include "hud/ammo.h" +#include "vgui/tga_image.h" +#include "hud_renderer.h" + +CHudAmmoPanel::CHudAmmoPanel() + : BaseClass(nullptr, VIEWPORT_PANEL_HUD_AMMO) +{ + SetSize(100, 100); // Silence "parent not sized yet" warning + SetProportional(true); + + m_pDigitRightBgLabel = new vgui2::Label(this, "AmmoBg", "000"); + m_pDigitRightLabelGlow = new vgui2::Label(this, "AmmoGlow", "000"); + m_pDigitRightLabel = new vgui2::Label(this, "Ammo", "100"); + m_pDigitLeftBgLabel = new vgui2::Label(this, "ClipBg", "000"); + m_pDigitLeftLabelGlow = new vgui2::Label(this, "ClipGlow", "000"); + m_pDigitLeftLabel = new vgui2::Label(this, "Clip", "100"); + + // Default icon + m_pAmmoIcon = m_pAmmoIconDefault = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/default_ammo"); + + // Ammo icons + m_pAmmo357 = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_357"); + m_pAmmo9mm = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_9mm"); + m_pAmmoBolt = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_bolt"); + m_pAmmoBuckshot = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_buckshot"); + m_pAmmoEnergy = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_energy"); + m_pAmmoGrenadeFrag = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_grenade_frag"); + m_pAmmoGrenadeHornet = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_grenade_hornet"); + m_pAmmoGrenadeMP5 = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_grenade_mp5"); + m_pAmmoGrenadeRPG = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_grenade_rpg"); + m_pAmmoGrenadeSatchel = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_grenade_satchel"); + m_pAmmoGrenadeTripmine = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_grenade_tripmine"); + m_pAmmoSnark = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_snark"); + + LoadControlSettings(VGUI2_ROOT_DIR "resource/HudAmmo.res"); + + SetVisible(false); +} + +void CHudAmmoPanel::ApplySchemeSettings(vgui2::IScheme *pScheme) +{ + // Calculate positions here because variable binding doesn't support position flags. + ComputePos(m_szBarX, m_iBarX, GetWide(), GetParent() ? GetParent()->GetWide() : 0, true); + ComputePos(m_szBarFullX, m_iBarFullX, GetWide(), GetParent() ? GetParent()->GetWide() : 0, true); + + BaseClass::ApplySchemeSettings(pScheme); + SetPaintBackgroundEnabled(true); +} + +void CHudAmmoPanel::PaintBackground() +{ + // Draw the panel background + DrawBox(0, 0, GetWide(), GetTall(), GetBgColor(), 1.0f); + + // Determine icon position and bar color + int iconX = m_iAmmoIconFullX; + Color barColor = m_hudCurrentColor; + + if (m_iClip < 0) + { + if (m_iBarShrink) + { + iconX = m_iAmmoIconX; + barColor = Color{0, 0, 0, 0}; // Not visible when bar is shrunk + } + else + { + barColor = m_DividerOffColor; // Visible but dimmed + } + } + + // Draw the divider bar between clip and ammo + vgui2::surface()->DrawSetColor(barColor); + vgui2::surface()->DrawFilledRect(m_iDividerX, m_iDividerY, m_iDividerX + m_iDividerWide, m_iDividerY + m_iDividerTall); + + // Draw the ammo icon + if (m_hAmmoSpriteFallback) + { + int yOffset = (m_iAmmoIconTall - m_rcAmmoSpriteFallbackRect.GetHeight()) / 2; + CHudRenderer::SpriteSet(m_hAmmoSpriteFallback, m_hudCurrentColor.r(), m_hudCurrentColor.g(), m_hudCurrentColor.b()); + CHudRenderer::SpriteDrawAdditive(0, iconX, m_iAmmoIconY + yOffset, &m_rcAmmoSpriteFallbackRect); + } + else + { + m_pAmmoIcon->SetPos(iconX, m_iAmmoIconY); + m_pAmmoIcon->SetSize(m_iAmmoIconWide, m_iAmmoIconTall); + m_pAmmoIcon->SetColor(m_hudCurrentColor); + m_pAmmoIcon->Paint(); + } +} + +enum AmmoType +{ + AMMO_TYPE_BUCKSHOT = 1, + AMMO_TYPE_9MM = 2, + AMMO_TYPE_GRENADE_MP5 = 3, + AMMO_TYPE_357 = 4, + AMMO_TYPE_ENERGY = 5, + AMMO_TYPE_GRENADE_RPG = 6, + AMMO_TYPE_BOLT = 7, + AMMO_TYPE_GRENADE_TRIPMINE = 8, + AMMO_TYPE_GRENADE_SATCHEL = 9, + AMMO_TYPE_GRENADE_FRAG = 10, + AMMO_TYPE_SNARK = 11, + AMMO_TYPE_GRENADE_HORNET = 12 +}; + +void CHudAmmoPanel::UpdateAmmoPanel(WEAPON *pWeapon, int maxClip, int ammo1, int ammo2) +{ + if (pWeapon) + { + if (m_iAmmoCount != ammo1 || m_iClip != pWeapon->iClip) + { + m_fFade = FADE_TIME; // Reset fade timer + } + + m_iAmmoType = pWeapon->iAmmoType; + m_iAmmo2Type = pWeapon->iAmmo2Type; + m_iMax1 = pWeapon->iMax1; + m_iMax2 = pWeapon->iMax2; + m_iId = pWeapon->iId; + m_iClip = pWeapon->iClip; + m_iMaxClip = maxClip; + m_iAmmoCount = ammo1; + m_iAmmoCount2 = ammo2; + m_hAmmoSpriteFallback = 0; + + // Set the ammo icon based on the ammo type + switch (m_iAmmoType) + { + case AMMO_TYPE_9MM: + m_pAmmoIcon = m_pAmmo9mm; + break; + case AMMO_TYPE_357: + m_pAmmoIcon = m_pAmmo357; + break; + case AMMO_TYPE_BOLT: + m_pAmmoIcon = m_pAmmoBolt; + break; + case AMMO_TYPE_BUCKSHOT: + m_pAmmoIcon = m_pAmmoBuckshot; + break; + case AMMO_TYPE_ENERGY: + m_pAmmoIcon = m_pAmmoEnergy; + break; + case AMMO_TYPE_GRENADE_FRAG: + m_pAmmoIcon = m_pAmmoGrenadeFrag; + break; + case AMMO_TYPE_GRENADE_HORNET: + m_pAmmoIcon = m_pAmmoGrenadeHornet; + break; + case AMMO_TYPE_GRENADE_MP5: + m_pAmmoIcon = m_pAmmoGrenadeMP5; + break; + case AMMO_TYPE_GRENADE_RPG: + m_pAmmoIcon = m_pAmmoGrenadeRPG; + break; + case AMMO_TYPE_GRENADE_SATCHEL: + m_pAmmoIcon = m_pAmmoGrenadeSatchel; + break; + case AMMO_TYPE_GRENADE_TRIPMINE: + m_pAmmoIcon = m_pAmmoGrenadeTripmine; + break; + case AMMO_TYPE_SNARK: + m_pAmmoIcon = m_pAmmoSnark; + break; + default: + if (pWeapon->hAmmo && CHudRenderer::Get().IsAvailable()) + { + m_hAmmoSpriteFallback = pWeapon->hAmmo; + m_rcAmmoSpriteFallbackRect = pWeapon->rcAmmo; + } + else + { + m_pAmmoIcon = m_pAmmoIconDefault; + } + + break; + } + } +} + +const char *CHudAmmoPanel::GetName() +{ + return VIEWPORT_PANEL_HUD_AMMO; +} + +void CHudAmmoPanel::Reset() +{ +} + +void CHudAmmoPanel::OnThink() +{ + if (hud_draw.GetFloat() <= 0) + { + ShowPanel(false); + return; + } + + int r, g, b; + // Does weapon have any ammo at all? + if (m_iAmmoType > 0) + { + char buf[32]; + + // Does this weapon have a clip? + if (m_iClip >= 0) + { + gHUD.GetHudAmmoColor(m_iClip, m_iMaxClip, r, g, b); + + // Show left (clip) and right (ammo) digits + m_pDigitLeftLabel->SetVisible(true); + m_pDigitLeftLabelGlow->SetVisible(true); + m_pDigitRightLabel->SetVisible(true); + m_pDigitRightLabelGlow->SetVisible(true); + m_pDigitRightBgLabel->SetVisible(true); + + // Set clip text + snprintf(buf, sizeof(buf), "%d", m_iClip); + m_pDigitLeftLabel->SetText(buf); + m_pDigitLeftLabelGlow->SetText(buf); + + // Set ammo text + snprintf(buf, sizeof(buf), "%d", m_iAmmoCount); + m_pDigitRightLabel->SetText(buf); + m_pDigitRightLabelGlow->SetText(buf); + + // Position and size + SetPos(m_iBarFullX, GetYPos()); + SetSize(m_iBarFullWide, GetTall()); + } + else // No clip + { + gHUD.GetHudAmmoColor(m_iAmmoCount, m_iMax1, r, g, b); + + if (m_iBarShrink) + { + // Only show left digit for ammo + m_pDigitLeftLabel->SetVisible(true); + m_pDigitLeftLabelGlow->SetVisible(true); + m_pDigitRightLabel->SetVisible(false); + m_pDigitRightLabelGlow->SetVisible(false); + m_pDigitRightBgLabel->SetVisible(false); + + snprintf(buf, sizeof(buf), "%d", m_iAmmoCount); + m_pDigitLeftLabel->SetText(buf); + m_pDigitLeftLabelGlow->SetText(buf); + + SetPos(m_iBarX, GetYPos()); + SetSize(m_iBarWide, GetTall()); + } + else + { + // Only show right digit for ammo + m_pDigitLeftLabel->SetVisible(false); + m_pDigitLeftLabelGlow->SetVisible(false); + m_pDigitRightLabel->SetVisible(true); + m_pDigitRightLabelGlow->SetVisible(true); + m_pDigitRightBgLabel->SetVisible(true); + + snprintf(buf, sizeof(buf), "%d", m_iAmmoCount); + m_pDigitRightLabel->SetText(buf); + m_pDigitRightLabelGlow->SetText(buf); + + SetPos(m_iBarFullX, GetYPos()); + SetSize(m_iBarFullWide, GetTall()); + } + } + } + + // Show glow effect when dimmed, if not, set full alpha and hide glow digits + auto [a1, a2] = gHUD.GetHudDimAlphas(m_fFade); + + // Set colors for glow and normal digits + m_hudCurrentColor = Color(r, g, b, a1); + m_pDigitRightLabelGlow->SetFgColor(m_hudCurrentColor); + m_pDigitLeftLabelGlow->SetFgColor(m_hudCurrentColor); + + m_hudCurrentColor = Color(r, g, b, a2); + m_pDigitLeftLabel->SetFgColor(m_hudCurrentColor); + m_pDigitRightLabel->SetFgColor(m_hudCurrentColor); +} + +void CHudAmmoPanel::ShowPanel(bool state) +{ + if (state != IsVisible()) + { + SetVisible(state); + } +} + +vgui2::VPANEL CHudAmmoPanel::GetVPanel() +{ + return BaseClass::GetVPanel(); +} + +bool CHudAmmoPanel::IsVisible() +{ + return BaseClass::IsVisible(); +} + +void CHudAmmoPanel::SetParent(vgui2::VPANEL parent) +{ + BaseClass::SetParent(parent); +} diff --git a/src/game/client/vgui/hud_ammo.h b/src/game/client/vgui/hud_ammo.h new file mode 100644 index 00000000..aeef37b4 --- /dev/null +++ b/src/game/client/vgui/hud_ammo.h @@ -0,0 +1,100 @@ +#ifndef VGUI_HUD_AMMO_H +#define VGUI_HUD_AMMO_H + +#include +#include "global_consts.h" +#include "IViewportPanel.h" +#include "viewport_panel_names.h" + +namespace vgui2 +{ +class Label; +} + +class CTGAImage; + +class CHudAmmoPanel : public vgui2::EditablePanel, public IViewportPanel +{ +public: + DECLARE_CLASS_SIMPLE(CHudAmmoPanel, vgui2::EditablePanel); + + CHudAmmoPanel(); + virtual void ApplySchemeSettings(vgui2::IScheme *pScheme) override; + virtual void PaintBackground() override; + + void UpdateAmmoPanel(WEAPON *pWeapon, int maxClip, int ammo1, int ammo2); + + void OnThink() override; + + //IViewportPanel overrides + virtual const char *GetName() override; + virtual void Reset() override; + virtual void ShowPanel(bool state) override; + virtual vgui2::VPANEL GetVPanel() override; + virtual bool IsVisible() override; + virtual void SetParent(vgui2::VPANEL parent) override; + +private: + vgui2::Label *m_pDigitLeftLabel = nullptr; + vgui2::Label *m_pDigitLeftBgLabel = nullptr; + vgui2::Label *m_pDigitLeftLabelGlow = nullptr; + vgui2::Label *m_pDigitRightLabel = nullptr; + vgui2::Label *m_pDigitRightBgLabel = nullptr; + vgui2::Label *m_pDigitRightLabelGlow = nullptr; + + int m_iBarX = 0; + int m_iBarFullX = 0; + CPanelAnimationStringVar(32, m_szBarFullX, "bar_full_xpos", "100"); + CPanelAnimationStringVar(32, m_szBarX, "bar_xpos", "100"); + + CPanelAnimationVar(Color, m_DividerOffColor, "divider_offcolor", "128 128 128 96"); + CPanelAnimationVarAliasType(int, m_iDividerX, "divider_xpos", "1", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iDividerY, "divider_ypos", "1", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iDividerWide, "divider_wide", "1", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iDividerTall, "divider_tall", "1", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iBarWide, "bar_wide", "1", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iBarFullWide, "bar_full_wide", "1", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iBarShrink, "bar_shrink", "1", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iAmmoIconX, "ammoicon_xpos", "0", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iAmmoIconFullX, "ammoicon_full_xpos", "0", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iAmmoIconY, "ammoicon_ypos", "0", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iAmmoIconWide, "ammoicon_wide", "0", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iAmmoIconTall, "ammoicon_tall", "0", "proportional_int"); + + // TGA images for ammo types + CTGAImage *m_pAmmoIcon = nullptr; + CTGAImage *m_pAmmoIconDefault = nullptr; + CTGAImage *m_pAmmo357 = nullptr; + CTGAImage *m_pAmmo9mm = nullptr; + CTGAImage *m_pAmmoBolt = nullptr; + CTGAImage *m_pAmmoBuckshot = nullptr; + CTGAImage *m_pAmmoEnergy = nullptr; + CTGAImage *m_pAmmoGrenadeFrag = nullptr; + CTGAImage *m_pAmmoGrenadeHornet = nullptr; + CTGAImage *m_pAmmoGrenadeMP5 = nullptr; + CTGAImage *m_pAmmoGrenadeRPG = nullptr; + CTGAImage *m_pAmmoGrenadeSatchel = nullptr; + CTGAImage *m_pAmmoGrenadeTripmine = nullptr; + CTGAImage *m_pAmmoSnark = nullptr; + + // Fallback ammo sprite + HSPRITE m_hAmmoSpriteFallback = 0; + wrect_t m_rcAmmoSpriteFallbackRect = {}; + + float m_fFade = 0.0f; + Color m_hudCurrentColor{}; + + // Weapon data + char m_szName[MAX_WEAPON_NAME]; + int m_iAmmoType; + int m_iAmmo2Type; + int m_iMax1; + int m_iMax2; + int m_iId; + int m_iClip; + int m_iMaxClip; + int m_iAmmoCount; + int m_iAmmoCount2; +}; + +#endif diff --git a/src/game/client/vgui/hud_ammo_secondary.cpp b/src/game/client/vgui/hud_ammo_secondary.cpp new file mode 100644 index 00000000..a2f332da --- /dev/null +++ b/src/game/client/vgui/hud_ammo_secondary.cpp @@ -0,0 +1,208 @@ +#include +#include +#include +#include +#include +#include "hud.h" +#include "client_vgui.h" +#include "client_viewport.h" +#include "hud_ammo_secondary.h" +#include "hud/ammo.h" +#include "vgui/tga_image.h" +#include "hud_renderer.h" + +CHudAmmoSecondaryPanel::CHudAmmoSecondaryPanel() + : BaseClass(nullptr, VIEWPORT_PANEL_HUD_AMMO_SEC) +{ + SetSize(100, 100); // Silence "parent not sized yet" warning + SetProportional(true); + + m_pAmmoBgLabel = new vgui2::Label(this, "AmmoBg", "00"); + m_pAmmoLabelGlow = new vgui2::Label(this, "AmmoGlow", "00"); + m_pAmmoLabel = new vgui2::Label(this, "Ammo", "100"); + + // Default icon + m_pAmmoIcon = m_pAmmoIconDefault = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/default_ammo"); + + // Ammo icons + m_pAmmoGrenadeMP5 = new CTGAImage(VGUI2_ROOT_DIR "gfx/hud/ammo_grenade_mp5"); + + LoadControlSettings(VGUI2_ROOT_DIR "resource/HudAmmoSecondary.res"); + + SetVisible(false); +} + +void CHudAmmoSecondaryPanel::ApplySchemeSettings(vgui2::IScheme *pScheme) +{ + BaseClass::ApplySchemeSettings(pScheme); + SetPaintBackgroundEnabled(true); +} + +void CHudAmmoSecondaryPanel::PaintBackground() +{ + DrawBox(0, 0, GetWide(), GetTall(), GetBgColor(), 1.0f); + + if (m_hAmmoSpriteFallback) + { + int yOffset = (m_iAmmoIconTall - m_rcAmmoSpriteFallbackRect.GetHeight()) / 2; + CHudRenderer::SpriteSet(m_hAmmoSpriteFallback, m_hudCurrentColor.r(), m_hudCurrentColor.g(), m_hudCurrentColor.b()); + CHudRenderer::SpriteDrawAdditive(0, m_iAmmoIconX, m_iAmmoIconY + yOffset, &m_rcAmmoSpriteFallbackRect); + } + else + { + m_pAmmoIcon->SetPos(m_iAmmoIconX, m_iAmmoIconY); + m_pAmmoIcon->SetSize(m_iAmmoIconWide, m_iAmmoIconTall); + m_pAmmoIcon->SetColor(m_hudCurrentColor); + m_pAmmoIcon->Paint(); + } +} + +enum AmmoType +{ + AMMO_TYPE_BUCKSHOT = 1, + AMMO_TYPE_9MM = 2, + AMMO_TYPE_GRENADE_MP5 = 3, + AMMO_TYPE_357 = 4, + AMMO_TYPE_ENERGY = 5, + AMMO_TYPE_GRENADE_RPG = 6, + AMMO_TYPE_BOLT = 7, + AMMO_TYPE_GRENADE_TRIPMINE = 8, + AMMO_TYPE_GRENADE_SATCHEL = 9, + AMMO_TYPE_GRENADE_FRAG = 10, + AMMO_TYPE_SNARK = 11, + AMMO_TYPE_GRENADE_HORNET = 12 +}; + +void CHudAmmoSecondaryPanel::UpdateAmmoSecondaryPanel(WEAPON *pWeapon, int maxClip, int ammo1, int ammo2) +{ + if (pWeapon) + { + if (m_iAmmoCount != ammo1 || m_iClip != pWeapon->iClip) + { + m_fFade = FADE_TIME; // Reset fade timer + } + + m_iAmmoType = pWeapon->iAmmoType; + m_iAmmo2Type = pWeapon->iAmmo2Type; + m_iMax1 = pWeapon->iMax1; + m_iMax2 = pWeapon->iMax2; + m_iId = pWeapon->iId; + m_iClip = pWeapon->iClip; + m_iMaxClip = maxClip; + m_iAmmoCount = ammo1; + m_iAmmoCount2 = ammo2; + m_hAmmoSpriteFallback = 0; + + // Set the ammo icon based on the ammo type + switch (m_iAmmo2Type) + { + case AMMO_TYPE_GRENADE_MP5: + m_pAmmoIcon = m_pAmmoGrenadeMP5; + break; + default: + if (pWeapon->hAmmo2 && CHudRenderer::Get().IsAvailable()) + { + m_hAmmoSpriteFallback = pWeapon->hAmmo2; + m_rcAmmoSpriteFallbackRect = pWeapon->rcAmmo2; + } + else + { + m_pAmmoIcon = m_pAmmoIconDefault; + } + + break; + } + } +} + +const char *CHudAmmoSecondaryPanel::GetName() +{ + return VIEWPORT_PANEL_HUD_AMMO_SEC; +} + +void CHudAmmoSecondaryPanel::Reset() +{ +} + +void CHudAmmoSecondaryPanel::OnThink() +{ + if (hud_draw.GetFloat() <= 0) + { + ShowPanel(false); + return; + } + + int r, g, b; + // Does weapon have any ammo at all? + if (m_iAmmoType > 0) + { + // Does this weapon have a clip? + if (m_iClip >= 0) + { + // Get it from iClip + gHUD.GetHudAmmoColor(m_iClip, m_iMaxClip, r, g, b); + } + else + { + // Get it from iMax1 + gHUD.GetHudAmmoColor(m_iAmmoCount, m_iMax1, r, g, b); + } + } + + // Does this weapon have a secondary ammo type? + if (m_iAmmo2Type > 0) + { + if (m_iAmmoCount2 > 0) + ShowPanel(true); + else + ShowPanel(false); + } + else + { + ShowPanel(false); + } + + char buf[32]; + + snprintf(buf, sizeof(buf), "%d", m_iAmmoCount2); + m_pAmmoLabel->SetText(buf); + m_pAmmoLabelGlow->SetText(buf); + + // Glow effect will be visible only when dimmed + auto [a1, a2] = gHUD.GetHudDimAlphas(m_fFade); + + if (!hud_dim.GetBool()) + { + a2 = 255; + a1 = 0; + } + + m_hudCurrentColor = Color(r, g, b, a1); + m_pAmmoLabelGlow->SetFgColor(m_hudCurrentColor); + + m_hudCurrentColor = Color(r, g, b, a2); + m_pAmmoLabel->SetFgColor(m_hudCurrentColor); +} + +void CHudAmmoSecondaryPanel::ShowPanel(bool state) +{ + if (state != IsVisible()) + { + SetVisible(state); + } +} + +vgui2::VPANEL CHudAmmoSecondaryPanel::GetVPanel() +{ + return BaseClass::GetVPanel(); +} + +bool CHudAmmoSecondaryPanel::IsVisible() +{ + return BaseClass::IsVisible(); +} + +void CHudAmmoSecondaryPanel::SetParent(vgui2::VPANEL parent) +{ + BaseClass::SetParent(parent); +} diff --git a/src/game/client/vgui/hud_ammo_secondary.h b/src/game/client/vgui/hud_ammo_secondary.h new file mode 100644 index 00000000..59037f7d --- /dev/null +++ b/src/game/client/vgui/hud_ammo_secondary.h @@ -0,0 +1,72 @@ +#ifndef VGUI_HUD_AMMO_SECONDARY_H +#define VGUI_HUD_AMMO_SECONDARY_H + +#include +#include "global_consts.h" +#include "IViewportPanel.h" +#include "viewport_panel_names.h" + +namespace vgui2 +{ +class Label; +} + +class CTGAImage; + +class CHudAmmoSecondaryPanel : public vgui2::EditablePanel, public IViewportPanel +{ +public: + DECLARE_CLASS_SIMPLE(CHudAmmoSecondaryPanel, vgui2::EditablePanel); + + CHudAmmoSecondaryPanel(); + virtual void ApplySchemeSettings(vgui2::IScheme *pScheme) override; + virtual void PaintBackground() override; + + void UpdateAmmoSecondaryPanel(WEAPON *pWeapon, int maxClip, int ammo1, int ammo2); + + void OnThink() override; + + //IViewportPanel overrides + virtual const char *GetName() override; + virtual void Reset() override; + virtual void ShowPanel(bool state) override; + virtual vgui2::VPANEL GetVPanel() override; + virtual bool IsVisible() override; + virtual void SetParent(vgui2::VPANEL parent) override; + +private: + vgui2::Label *m_pAmmoLabel = nullptr; + vgui2::Label *m_pAmmoBgLabel = nullptr; + vgui2::Label *m_pAmmoLabelGlow = nullptr; + + CPanelAnimationVarAliasType(int, m_iAmmoIconX, "ammoicon_xpos", "0", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iAmmoIconY, "ammoicon_ypos", "0", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iAmmoIconWide, "ammoicon_wide", "0", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iAmmoIconTall, "ammoicon_tall", "0", "proportional_int"); + + // TGA images for ammo types + CTGAImage *m_pAmmoIcon = nullptr; + CTGAImage *m_pAmmoIconDefault = nullptr; + CTGAImage *m_pAmmoGrenadeMP5 = nullptr; + + // Fallback ammo sprite + HSPRITE m_hAmmoSpriteFallback = 0; + wrect_t m_rcAmmoSpriteFallbackRect = {}; + + float m_fFade = 0.0f; + Color m_hudCurrentColor{}; + + // Weapon data + char m_szName[MAX_WEAPON_NAME]; + int m_iAmmoType; + int m_iAmmo2Type; + int m_iMax1; + int m_iMax2; + int m_iId; + int m_iClip; + int m_iMaxClip; + int m_iAmmoCount; + int m_iAmmoCount2; +}; + +#endif diff --git a/src/game/client/vgui/hud_battery.cpp b/src/game/client/vgui/hud_battery.cpp new file mode 100644 index 00000000..86e62dc4 --- /dev/null +++ b/src/game/client/vgui/hud_battery.cpp @@ -0,0 +1,99 @@ +#include +#include +#include +#include +#include +#include "hud.h" +#include "cl_util.h" +#include "client_steam_context.h" +#include "client_vgui.h" +#include "client_viewport.h" +#include "hud_battery.h" + +CHudBatteryPanel::CHudBatteryPanel() + : BaseClass(nullptr, VIEWPORT_PANEL_HUD_BATTERY) +{ + SetSize(100, 100); // Silence "parent not sized yet" warning + SetProportional(true); + + m_pBatteryIcon = new vgui2::Label(this, "BatteryIcon", "a"); + m_pBatteryAmountBg = new vgui2::Label(this, "BatteryAmountBg", "000"); + m_pBatteryAmountGlow = new vgui2::Label(this, "BatteryAmountGlow", "100"); + m_pBatteryAmount = new vgui2::Label(this, "BatteryAmount", "100"); + + LoadControlSettings(VGUI2_ROOT_DIR "resource/HudBattery.res"); + + SetVisible(false); +} + +void CHudBatteryPanel::ApplySchemeSettings(vgui2::IScheme *pScheme) +{ + BaseClass::ApplySchemeSettings(pScheme); + SetPaintBackgroundEnabled(true); +} + +void CHudBatteryPanel::PaintBackground() +{ + DrawBox(0, 0, GetWide(), GetTall(), GetBgColor(), 1.0f); +} + +void CHudBatteryPanel::UpdateBatteryPanel(int amount) +{ + // Reset fade only if amount changed + if (amount != m_iBattery) + m_fFade = FADE_TIME; + + m_iBattery = amount; + + // Update health amount text + char buf[32]; + snprintf(buf, sizeof(buf), "%d", m_iBattery); + m_pBatteryAmount->SetText(buf); + m_pBatteryAmountGlow->SetText(buf); +} + +const char *CHudBatteryPanel::GetName() +{ + return VIEWPORT_PANEL_HUD_BATTERY; +} + +void CHudBatteryPanel::Reset() +{ +} + +void CHudBatteryPanel::OnThink() +{ + // Glow effect will be visible only when dimmed + auto [a1, a2] = gHUD.GetHudDimAlphas(m_fFade); + + Color currentColor = gHUD.GetHudColor(HudPart::Armor, m_iBattery); + currentColor[3] = a1; + m_pBatteryAmountGlow->SetFgColor(currentColor); + + currentColor[3] = a2; + m_pBatteryAmount->SetFgColor(currentColor); + m_pBatteryIcon->SetFgColor(currentColor); +} + +void CHudBatteryPanel::ShowPanel(bool state) +{ + if (state != IsVisible()) + { + SetVisible(state); + } +} + +vgui2::VPANEL CHudBatteryPanel::GetVPanel() +{ + return BaseClass::GetVPanel(); +} + +bool CHudBatteryPanel::IsVisible() +{ + return BaseClass::IsVisible(); +} + +void CHudBatteryPanel::SetParent(vgui2::VPANEL parent) +{ + BaseClass::SetParent(parent); +} diff --git a/src/game/client/vgui/hud_battery.h b/src/game/client/vgui/hud_battery.h new file mode 100644 index 00000000..20329fbd --- /dev/null +++ b/src/game/client/vgui/hud_battery.h @@ -0,0 +1,45 @@ +#ifndef VGUI_HUD_BATTERY_H +#define VGUI_HUD_BATTERY_H + +#include +#include "global_consts.h" +#include "IViewportPanel.h" +#include "viewport_panel_names.h" + +namespace vgui2 +{ +class Label; +} + +class CHudBatteryPanel : public vgui2::EditablePanel, public IViewportPanel +{ +public: + DECLARE_CLASS_SIMPLE(CHudBatteryPanel, vgui2::EditablePanel); + + CHudBatteryPanel(); + virtual void ApplySchemeSettings(vgui2::IScheme *pScheme) override; + virtual void PaintBackground() override; + + void UpdateBatteryPanel(int amount); + + void OnThink() override; + + //IViewportPanel overrides + virtual const char *GetName() override; + virtual void Reset() override; + virtual void ShowPanel(bool state) override; + virtual vgui2::VPANEL GetVPanel() override; + virtual bool IsVisible() override; + virtual void SetParent(vgui2::VPANEL parent) override; + +private: + vgui2::Label *m_pBatteryAmount = nullptr; + vgui2::Label *m_pBatteryAmountBg = nullptr; + vgui2::Label *m_pBatteryAmountGlow = nullptr; + vgui2::Label *m_pBatteryIcon = nullptr; + + float m_fFade = 0.0f; + int m_iBattery = 100; +}; + +#endif diff --git a/src/game/client/vgui/hud_health.cpp b/src/game/client/vgui/hud_health.cpp new file mode 100644 index 00000000..ed2c57d9 --- /dev/null +++ b/src/game/client/vgui/hud_health.cpp @@ -0,0 +1,99 @@ +#include +#include +#include +#include +#include +#include "hud.h" +#include "cl_util.h" +#include "client_steam_context.h" +#include "client_vgui.h" +#include "client_viewport.h" +#include "hud_health.h" + +CHudHealthPanel::CHudHealthPanel() + : BaseClass(nullptr, VIEWPORT_PANEL_HUD_HEALTH) +{ + SetSize(100, 100); // Silence "parent not sized yet" warning + SetProportional(true); + + m_pHealthIcon = new vgui2::Label(this, "HealthIcon", "b"); + m_pHealthAmountBg = new vgui2::Label(this, "HealthAmountBg", "000"); + m_pHealthAmountGlow = new vgui2::Label(this, "HealthAmountGlow", "100"); + m_pHealthAmount = new vgui2::Label(this, "HealthAmount", "100"); + + LoadControlSettings(VGUI2_ROOT_DIR "resource/HudHealth.res"); + + SetVisible(false); +} + +void CHudHealthPanel::ApplySchemeSettings(vgui2::IScheme *pScheme) +{ + BaseClass::ApplySchemeSettings(pScheme); + SetPaintBackgroundEnabled(true); +} + +void CHudHealthPanel::PaintBackground() +{ + DrawBox(0, 0, GetWide(), GetTall(), GetBgColor(), 1.0f); +} + +void CHudHealthPanel::UpdateHealthPanel(int health) +{ + // Reset fade only if health changed + if (health != m_iHealth) + m_fFade = FADE_TIME; + + m_iHealth = health; + + // Update health amount text + char buf[32]; + snprintf(buf, sizeof(buf), "%d", health); + m_pHealthAmount->SetText(buf); + m_pHealthAmountGlow->SetText(buf); +} + +const char *CHudHealthPanel::GetName() +{ + return VIEWPORT_PANEL_HUD_HEALTH; +} + +void CHudHealthPanel::Reset() +{ +} + +void CHudHealthPanel::OnThink() +{ + // Glow effect will be visible only when dimmed + auto [a1, a2] = gHUD.GetHudDimAlphas(m_fFade); + + Color currentColor = gHUD.GetHudColor(HudPart::Health, m_iHealth); + currentColor[3] = a1; + m_pHealthAmountGlow->SetFgColor(currentColor); + + currentColor[3] = a2; + m_pHealthAmount->SetFgColor(currentColor); + m_pHealthIcon->SetFgColor(currentColor); +} + +void CHudHealthPanel::ShowPanel(bool state) +{ + if (state != IsVisible()) + { + SetVisible(state); + } +} + +vgui2::VPANEL CHudHealthPanel::GetVPanel() +{ + return BaseClass::GetVPanel(); +} + +bool CHudHealthPanel::IsVisible() +{ + return BaseClass::IsVisible(); +} + +void CHudHealthPanel::SetParent(vgui2::VPANEL parent) +{ + BaseClass::SetParent(parent); +} diff --git a/src/game/client/vgui/hud_health.h b/src/game/client/vgui/hud_health.h new file mode 100644 index 00000000..a518f04e --- /dev/null +++ b/src/game/client/vgui/hud_health.h @@ -0,0 +1,45 @@ +#ifndef VGUI_HUD_HEALTH_H +#define VGUI_HUD_HEALTH_H + +#include +#include "global_consts.h" +#include "IViewportPanel.h" +#include "viewport_panel_names.h" + +namespace vgui2 +{ +class Label; +} + +class CHudHealthPanel : public vgui2::EditablePanel, public IViewportPanel +{ +public: + DECLARE_CLASS_SIMPLE(CHudHealthPanel, vgui2::EditablePanel); + + CHudHealthPanel(); + virtual void ApplySchemeSettings(vgui2::IScheme *pScheme) override; + virtual void PaintBackground() override; + + void UpdateHealthPanel(int health); + + void OnThink() override; + + //IViewportPanel overrides + virtual const char *GetName() override; + virtual void Reset() override; + virtual void ShowPanel(bool state) override; + virtual vgui2::VPANEL GetVPanel() override; + virtual bool IsVisible() override; + virtual void SetParent(vgui2::VPANEL parent) override; + +private: + vgui2::Label *m_pHealthAmount = nullptr; + vgui2::Label *m_pHealthAmountBg = nullptr; + vgui2::Label *m_pHealthAmountGlow = nullptr; + vgui2::Label *m_pHealthIcon = nullptr; + + float m_fFade = 0.0f; + int m_iHealth = 100; +}; + +#endif diff --git a/src/game/client/vgui/viewport_panel_names.h b/src/game/client/vgui/viewport_panel_names.h index f7220187..8730c9e2 100644 --- a/src/game/client/vgui/viewport_panel_names.h +++ b/src/game/client/vgui/viewport_panel_names.h @@ -4,6 +4,10 @@ #define VIEWPORT_PANEL_SCORE "ScorePanel" #define VIEWPORT_PANEL_MOTD "ClientMOTD" #define VIEWPORT_PANEL_SPECTATOR "SpectatorPanel" +#define VIEWPORT_PANEL_HUD_HEALTH "HudHealthPanel" +#define VIEWPORT_PANEL_HUD_BATTERY "HudBatteryPanel" +#define VIEWPORT_PANEL_HUD_AMMO "HudAmmoPanel" +#define VIEWPORT_PANEL_HUD_AMMO_SEC "HudAmmoSecondaryPanel" #define VIEWPORT_PANEL_TEAM_MENU "TeamMenu" #define VIEWPORT_PANEL_COMMAND_MENU "CommandMenu"