diff --git a/game/client/client_dod.vpc b/game/client/client_dod.vpc new file mode 100644 index 00000000..94f093c0 --- /dev/null +++ b/game/client/client_dod.vpc @@ -0,0 +1,246 @@ +//----------------------------------------------------------------------------- +// CLIENT_DOD.VPC +// +// Project Script +//----------------------------------------------------------------------------- + +$Macro SRCDIR "..\.." +$Macro GAMENAME "dod" + +$Include "$SRCDIR\game\client\client_base.vpc" + +$Configuration +{ + $Compiler + { + $AdditionalIncludeDirectories "$BASE;dod,.\dod\VGUI,$SRCDIR\game\shared\dod" + $PreprocessorDefinitions "$BASE;DOD_DLL;ENABLE_HTML_WINDOW" + } +} + +$Project "Client (DOD)" +{ + $Folder "Source Files" + { + -$File "$SRCDIR\game\shared\weapon_parse_default.cpp" + -$File "history_resource.cpp" + -$File "hud_hintdisplay.cpp" + + $File "hud_voicestatus.cpp" + + $File "$SRCDIR\game\shared\playerclass_info_parse.cpp" + $File "$SRCDIR\game\shared\playerclass_info_parse.h" + + $Folder "Day of Defeat DLL" + { + $File "$SRCDIR\game\shared\dod\achievements_dod.cpp" + $File "dod\c_dod_basegrenade.cpp" + $File "dod\c_dod_basegrenade.h" + $File "dod\c_dod_baserocket.cpp" + $File "dod\c_dod_bombdispenser.cpp" + $File "dod\c_dod_bombtarget.cpp" + $File "dod\c_dod_objective_resource.cpp" + $File "dod\c_dod_objective_resource.h" + $File "dod\c_dod_player.cpp" + $File "dod\c_dod_player.h" + $File "dod\c_dod_playerresource.cpp" + $File "dod\c_dod_playerresource.h" + $File "dod\c_dod_smokegrenade.cpp" + $File "dod\c_dod_smokegrenade.h" + $File "dod\c_dod_team.cpp" + $File "dod\c_dod_team.h" + $File "dod\c_grenadetrail.cpp" + $File "dod\c_grenadetrail.h" + $File "dod\c_te_firebullets.cpp" + $File "dod\clientmode_dod.cpp" + $File "dod\clientmode_dod.h" + $File "dod\dod_fx_explosions.cpp" + $File "$SRCDIR\game\shared\dod\dod_gamemovement.cpp" + $File "$SRCDIR\game\shared\dod\dod_gamerules.cpp" + $File "$SRCDIR\game\shared\dod\dod_gamerules.h" + $File "dod\dod_headiconmanager.cpp" + $File "dod\dod_headiconmanager.h" + $File "dod\dod_hud_ammo.cpp" + $File "dod\dod_hud_areacapicon.cpp" + $File "dod\dod_hud_capturepanel.cpp" + $File "dod\dod_hud_capturepanel.h" + $File "dod\dod_hud_chat.cpp" + $File "dod\dod_hud_chat.h" + $File "dod\dod_hud_crosshair.cpp" + $File "dod\dod_hud_crosshair.h" + $File "dod\dod_hud_damageindicator.cpp" + $File "dod\dod_hud_deathnotice.cpp" + $File "dod\dod_hud_freezepanel.cpp" + $File "dod\dod_hud_freezepanel.h" + $File "dod\dod_hud_health.cpp" + $File "dod\dod_hud_hintdisplay.cpp" + $File "dod\dod_hud_history_resource.cpp" + $File "dod\dod_hud_objectiveicons.cpp" + $File "dod\dod_hud_playerstatus_ammo.cpp" + $File "dod\dod_hud_playerstatus_ammo.h" + $File "dod\dod_hud_playerstatus_fireselect.cpp" + $File "dod\dod_hud_playerstatus_fireselect.h" + $File "dod\dod_hud_playerstatus_health.cpp" + $File "dod\dod_hud_playerstatus_health.h" + $File "dod\dod_hud_playerstatus_mgheat.cpp" + $File "dod\dod_hud_playerstatus_mgheat.h" + $File "dod\dod_hud_playerstatus_stamina.cpp" + $File "dod\dod_hud_playerstatus_stamina.h" + $File "dod\dod_hud_playerstatus_tnt.cpp" + $File "dod\dod_hud_playerstatus_weapon.cpp" + $File "dod\dod_hud_playerstatus_weapon.h" + $File "dod\dod_hud_playerstatuspanel.cpp" + $File "dod\dod_hud_readyrestart.cpp" + $File "dod\dod_hud_restartround.cpp" + $File "dod\dod_hud_scope.cpp" + $File "dod\dod_hud_spec_crosshair.cpp" + $File "dod\dod_hud_spec_crosshair.h" + $File "dod\dod_hud_target_id.cpp" + $File "dod\dod_hud_tnt_pickup.cpp" + $File "dod\dod_hud_warmuplabel.cpp" + $File "dod\dod_hud_weaponselection.cpp" + $File "dod\dod_hud_winpanel.cpp" + $File "dod\dod_hud_winpanel.h" + $File "dod\dod_in_main.cpp" + $File "$SRCDIR\game\shared\dod\dod_player_shared.cpp" + $File "$SRCDIR\game\shared\dod\dod_player_shared.h" + $File "$SRCDIR\game\shared\dod\dod_playeranimstate.cpp" + $File "$SRCDIR\game\shared\dod\dod_playeranimstate.h" + $File "$SRCDIR\game\shared\dod\dod_playerclass_info_parse.cpp" + $File "$SRCDIR\game\shared\dod\dod_playerclass_info_parse.h" + $File "dod\dod_playerstats.cpp" + $File "dod\dod_playerstats.h" + $File "dod\dod_prediction.cpp" + $File "$SRCDIR\game\shared\dod\dod_round_timer.cpp" + $File "$SRCDIR\game\shared\dod\dod_shareddefs.cpp" + $File "$SRCDIR\game\shared\dod\dod_shareddefs.h" + $File "$SRCDIR\game\shared\dod\dod_usermessages.cpp" + $File "dod\dod_view_scene.cpp" + $File "dod\dod_view_scene.h" + $File "$SRCDIR\game\shared\dod\dod_viewmodel.cpp" + $File "$SRCDIR\game\shared\dod\dod_viewmodel.h" + $File "$SRCDIR\game\shared\dod\dod_weapon_parse.cpp" + $File "$SRCDIR\game\shared\dod\dod_weapon_parse.h" + $File "dod\VGUI\backgroundpanel.cpp" + $File "dod\VGUI\backgroundpanel.h" + $File "dod\VGUI\dodbutton.cpp" + $File "dod\VGUI\dodbutton.h" + $File "dod\VGUI\dodclassmenu.cpp" + $File "dod\VGUI\dodclassmenu.h" + $File "dod\VGUI\dodclientscoreboard.cpp" + $File "dod\VGUI\dodclientscoreboard.h" + $File "dod\VGUI\dodcornercutpanel.cpp" + $File "dod\VGUI\dodcornercutpanel.h" + $File "dod\VGUI\dodmenubackground.cpp" + $File "dod\VGUI\dodmenubackground.h" + $File "dod\VGUI\dodmouseoverpanelbutton.h" + $File "dod\VGUI\dodoverview.cpp" + $File "dod\VGUI\dodoverview.h" + $File "dod\VGUI\dodrandombutton.h" + $File "dod\VGUI\dodspectatorgui.cpp" + $File "dod\VGUI\dodspectatorgui.h" + $File "dod\VGUI\dodteammenu.cpp" + $File "dod\VGUI\dodteammenu.h" + $File "dod\VGUI\dodtextwindow.cpp" + $File "dod\VGUI\dodtextwindow.h" + $File "dod\VGUI\dodviewport.cpp" + $File "dod\VGUI\dodviewport.h" + $File "dod\fx_dod_blood.cpp" + $File "dod\fx_dod_blood.h" + $File "dod\fx_dod_ejectbrass.cpp" + $File "dod\fx_dod_filmgrain.cpp" + $File "dod\fx_dod_impact.cpp" + $File "dod\fx_dod_knifeslash.cpp" + $File "dod\fx_dod_muzzleflash.cpp" + $File "dod\fx_dod_muzzleflash.h" + $File "$SRCDIR\game\shared\dod\fx_dod_shared.cpp" + $File "$SRCDIR\game\shared\dod\fx_dod_shared.h" + $File "dod\fx_dod_tracers.cpp" + $File "dod\VGUI\idodviewportmsgs.h" + $File "dod\VGUI\vgui_rootpanel_dod.cpp" + $File "dod\VGUI\vgui_rootpanel_dod.h" + $File "$SRCDIR\game\shared\dod\weapon_30cal.cpp" + $File "$SRCDIR\game\shared\dod\weapon_amerknife.cpp" + $File "$SRCDIR\game\shared\dod\weapon_bar.cpp" + $File "$SRCDIR\game\shared\dod\weapon_bazooka.cpp" + $File "$SRCDIR\game\shared\dod\weapon_c96.cpp" + $File "$SRCDIR\game\shared\dod\weapon_colt.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodbase.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodbase.h" + $File "$SRCDIR\game\shared\dod\weapon_dodbasebomb.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodbasebomb.h" + $File "$SRCDIR\game\shared\dod\weapon_dodbasegrenade.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodbasegrenade.h" + $File "$SRCDIR\game\shared\dod\weapon_dodbasegun.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodbasegun.h" + $File "$SRCDIR\game\shared\dod\weapon_dodbasemelee.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodbasemelee.h" + $File "$SRCDIR\game\shared\dod\weapon_dodbaserpg.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodbaserpg.h" + $File "$SRCDIR\game\shared\dod\weapon_dodbipodgun.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodbipodgun.h" + $File "$SRCDIR\game\shared\dod\weapon_dodfireselect.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodfireselect.h" + $File "$SRCDIR\game\shared\dod\weapon_dodfullauto.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodfullauto.h" + $File "$SRCDIR\game\shared\dod\weapon_dodfullauto_punch.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodfullauto_punch.h" + $File "$SRCDIR\game\shared\dod\weapon_dodsemiauto.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodsemiauto.h" + $File "$SRCDIR\game\shared\dod\weapon_dodsniper.cpp" + $File "$SRCDIR\game\shared\dod\weapon_dodsniper.h" + $File "$SRCDIR\game\shared\dod\weapon_explodinghandgrenade.cpp" + $File "$SRCDIR\game\shared\dod\weapon_explodingstickgrenade.cpp" + $File "$SRCDIR\game\shared\dod\weapon_garand.cpp" + $File "$SRCDIR\game\shared\dod\weapon_handgrenade.cpp" + $File "$SRCDIR\game\shared\dod\weapon_k98.cpp" + $File "$SRCDIR\game\shared\dod\weapon_k98_scoped.cpp" + $File "$SRCDIR\game\shared\dod\weapon_m1carbine.cpp" + $File "$SRCDIR\game\shared\dod\weapon_mg42.cpp" + $File "$SRCDIR\game\shared\dod\weapon_mg42.h" + $File "$SRCDIR\game\shared\dod\weapon_mp40.cpp" + $File "$SRCDIR\game\shared\dod\weapon_mp44.cpp" + $File "$SRCDIR\game\shared\dod\weapon_p38.cpp" + $File "$SRCDIR\game\shared\dod\weapon_pschreck.cpp" + $File "$SRCDIR\game\shared\dod\weapon_riflegrenade.cpp" + $File "$SRCDIR\game\shared\dod\weapon_riflegrenade.h" + $File "$SRCDIR\game\shared\dod\weapon_riflegrenade_ger.cpp" + $File "$SRCDIR\game\shared\dod\weapon_riflegrenade_ger_live.cpp" + $File "$SRCDIR\game\shared\dod\weapon_riflegrenade_us.cpp" + $File "$SRCDIR\game\shared\dod\weapon_riflegrenade_us_live.cpp" + $File "$SRCDIR\game\shared\dod\weapon_smokegrenade_ger.cpp" + $File "$SRCDIR\game\shared\dod\weapon_smokegrenade_us.cpp" + $File "$SRCDIR\game\shared\dod\weapon_spade.cpp" + $File "$SRCDIR\game\shared\dod\weapon_spring.cpp" + $File "$SRCDIR\game\shared\dod\weapon_stickgrenade.cpp" + $File "$SRCDIR\game\shared\dod\weapon_thompson.cpp" + } + + $Folder "game_controls" + { + $File "game_controls\buymenu.cpp" + $File "game_controls\buysubmenu.cpp" + $File "game_controls\classmenu.cpp" + } + + $Folder "IFM" + { + $File "$SRCDIR\game\shared\weapon_ifmbase.cpp" + $File "$SRCDIR\game\shared\weapon_ifmbase.h" + $File "$SRCDIR\game\shared\weapon_ifmbasecamera.cpp" + $File "$SRCDIR\game\shared\weapon_ifmbasecamera.h" + $File "$SRCDIR\game\shared\weapon_ifmsteadycam.cpp" + } + } + + $Folder "Header Files" + { + + $Folder "game_controls header files" + { + $File "game_controls\buymenu.h" + $File "game_controls\buysubmenu.h" + $File "game_controls\classmenu.h" + } + } +} diff --git a/game/client/client_hl1.vpc b/game/client/client_hl1.vpc new file mode 100644 index 00000000..d9a9f37f --- /dev/null +++ b/game/client/client_hl1.vpc @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +// CLIENT_HL1.VPC +// +// Project Script +//----------------------------------------------------------------------------- + +$Macro SRCDIR "..\.." +$Macro GAMENAME "hl1" + +$Include "$SRCDIR\game\client\client_base.vpc" + +$Configuration +{ + $Compiler + { + $AdditionalIncludeDirectories "$BASE;.\hl1,.\hl2,.\hl2\elements,$SRCDIR\game\shared\hl1,$SRCDIR\game\shared\hl2" + $PreprocessorDefinitions "$BASE;HL1_CLIENT_DLL" + } +} + +$Project "Client (HL1)" +{ + $Folder "Source Files" + { + -$File "geiger.cpp" + -$File "history_resource.cpp" + -$File "train.cpp" + + $File "c_team_objectiveresource.cpp" + $File "c_team_objectiveresource.h" + $File "hud_chat.cpp" + $File "$SRCDIR\game\shared\predicted_viewmodel.cpp" + $File "$SRCDIR\game\shared\predicted_viewmodel.h" + + $Folder "HL2 DLL" + { + $File "hl2\c_antlion_dust.cpp" + $File "hl2\c_basehelicopter.cpp" + $File "hl2\c_basehelicopter.h" + $File "hl2\c_basehlcombatweapon.h" + $File "hl2\c_corpse.cpp" + $File "hl2\c_corpse.h" + $File "hl2\c_hl2_playerlocaldata.h" + $File "hl2\c_rotorwash.cpp" + $File "$SRCDIR\game\shared\hl2\citadel_effects_shared.h" + $File "$SRCDIR\game\shared\hl2\env_headcrabcanister_shared.h" + $File "hl2\fx_bugbait.cpp" + $File "$SRCDIR\game\shared\hl2\hl2_shareddefs.h" + $File "hl2\hl_in_main.cpp" + $File "hl2\hl_prediction.cpp" + $File "hl2\vgui_rootpanel_hl2.cpp" + } + + $Folder "HL1 DLL" + { + $File "hl1\c_hl1mp_player.cpp" + $File "$SRCDIR\game\shared\hl1\hl1_basecombatweapon_shared.cpp" + $File "$SRCDIR\game\shared\hl1\hl1_basecombatweapon_shared.h" + $File "hl1\hl1_c_legacytempents.cpp" + $File "hl1\hl1_c_player.cpp" + $File "hl1\hl1_c_player.h" + $File "hl1\hl1_c_rpg_rocket.cpp" + $File "hl1\hl1_c_weapon__stubs.cpp" + $File "hl1\hl1_clientmode.cpp" + $File "hl1\hl1_clientmode.h" + $File "hl1\hl1_fx_gauss.cpp" + $File "hl1\hl1_fx_gibs.cpp" + $File "hl1\hl1_fx_impacts.cpp" + $File "hl1\hl1_fx_shelleject.cpp" + $File "$SRCDIR\game\shared\hl1\hl1_gamemovement.cpp" + $File "$SRCDIR\game\shared\hl1\hl1_gamemovement.h" + $File "$SRCDIR\game\shared\hl1\hl1_gamerules.cpp" + $File "hl1\hl1_hud_ammo.cpp" + $File "hl1\hl1_hud_battery.cpp" + $File "hl1\hl1_hud_damageindicator.cpp" + $File "hl1\hl1_hud_damagetiles.cpp" + $File "hl1\hl1_hud_flashlight.cpp" + $File "hl1\hl1_hud_geiger.cpp" + $File "hl1\hl1_hud_health.cpp" + $File "hl1\hl1_hud_history_resource.cpp" + $File "hl1\hl1_hud_numbers.cpp" + $File "hl1\hl1_hud_numbers.h" + $File "hl1\hl1_hud_train.cpp" + $File "hl1\hl1_hud_weaponselection.cpp" + $File "$SRCDIR\game\shared\hl1\hl1_player_shared.cpp" + $File "$SRCDIR\game\shared\hl1\hl1_player_shared.h" + $File "$SRCDIR\game\shared\hl1\hl1_usermessages.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_basecombatweapon_shared.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_357.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_crossbow.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_egon.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_gauss.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_glock.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_handgrenade.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_hornetgun.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_mp5.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_rpg.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_sachel.cpp" + $File "$SRCDIR\game\shared\hl1\hl1mp_weapon_shotgun.cpp" + $File "$SRCDIR\game\server\hl1\hl1_weapon_crowbar.cpp" + } + } +} diff --git a/game/client/client_portal.vpc b/game/client/client_portal.vpc new file mode 100644 index 00000000..78dc9649 --- /dev/null +++ b/game/client/client_portal.vpc @@ -0,0 +1,196 @@ +//----------------------------------------------------------------------------- +// CLIENT_PORTAL.VPC +// +// Project Script +//----------------------------------------------------------------------------- + +$Macro SRCDIR "..\.." +$Macro GAMENAME "portal" + +$Include "$SRCDIR\game\client\client_base.vpc" + +$Configuration +{ + $Compiler + { + $AdditionalIncludeDirectories ".\hl2;.\hl2\elements;.\portal;.\portal\vgui;$SRCDIR\game\shared\hl2;$SRCDIR\game\shared\Multiplayer;$SRCDIR\gcsdk\steamextra;$SRCDIR\game\shared\portal;$BASE" + $PreprocessorDefinitions "$BASE;PORTAL;HL2_EPISODIC;HL2_CLIENT_DLL" + } +} + +$Project "Client (Portal)" +{ + $Folder "Source Files" + { + -$File "$SRCDIR\game\shared\weapon_parse_default.cpp" + $File "hud_chat.cpp" + $File "c_team_objectiveresource.cpp" + $File "c_team_objectiveresource.h" + + $Folder "HL2 DLL" + { + $File "episodic\flesh_internal_material_proxy.cpp" + $File "$SRCDIR\game\shared\hl2\basehlcombatweapon_shared.cpp" + $File "hl2\c_antlion_dust.cpp" + $File "hl2\c_ar2_explosion.cpp" + $File "hl2\c_barnacle.cpp" + $File "hl2\c_barney.cpp" + $File "hl2\c_basehelicopter.cpp" + $File "hl2\c_basehelicopter.h" + $File "hl2\c_basehlcombatweapon.cpp" + $File "hl2\c_basehlcombatweapon.h" + $File "hl2\c_basehlplayer.cpp" + $File "hl2\c_basehlplayer.h" + $File "hl2\c_citadel_effects.cpp" + $File "hl2\c_corpse.cpp" + $File "hl2\c_corpse.h" + $File "hl2\c_env_alyxtemp.cpp" + $File "hl2\c_env_headcrabcanister.cpp" + $File "hl2\c_env_starfield.cpp" + $File "hl2\c_func_tankmortar.cpp" + $File "hl2\c_hl2_playerlocaldata.cpp" + $File "hl2\c_hl2_playerlocaldata.h" + $File "hl2\c_info_teleporter_countdown.cpp" + $File "hl2\c_npc_antlionguard.cpp" + $File "hl2\c_npc_combinegunship.cpp" + $File "hl2\c_npc_manhack.cpp" + $File "hl2\c_npc_rollermine.cpp" + $File "hl2\c_plasma_beam_node.cpp" + $File "hl2\c_prop_combine_ball.cpp" + $File "hl2\c_prop_combine_ball.h" + $File "hl2\c_rotorwash.cpp" + $File "hl2\c_script_intro.cpp" + $File "$SRCDIR\game\shared\script_intro_shared.cpp" + $File "hl2\c_strider.cpp" + $File "hl2\c_te_concussiveexplosion.cpp" + $File "hl2\c_te_flare.cpp" + $File "hl2\c_thumper_dust.cpp" + $File "hl2\c_vehicle_airboat.cpp" + $File "hl2\c_vehicle_cannon.cpp" + $File "hl2\c_vehicle_crane.cpp" + $File "hl2\c_vehicle_crane.h" + $File "hl2\c_vehicle_prisoner_pod.cpp" + $File "episodic\c_vort_charge_token.cpp" + $File "hl2\c_weapon_crossbow.cpp" + $File "episodic\c_weapon_hopwire.cpp" + $File "episodic\c_vehicle_jeep_episodic.cpp" + $File "hl2\hud_radar.cpp" + $File "hl2\c_weapon_stunstick.cpp" + $File "$SRCDIR\game\shared\hl2\citadel_effects_shared.h" + $File "hl2\clientmode_hlnormal.h" + $File "death.cpp" + $File "$SRCDIR\game\shared\hl2\env_headcrabcanister_shared.cpp" + $File "$SRCDIR\game\shared\hl2\env_headcrabcanister_shared.h" + $File "hl2\fx_antlion.cpp" + $File "hl2\fx_bugbait.cpp" + $File "hl2\fx_hl2_impacts.cpp" + $File "hl2\fx_hl2_tracers.cpp" + $File "$SRCDIR\game\shared\hl2\hl2_gamerules.cpp" + $File "$SRCDIR\game\shared\hl2\hl2_gamerules.h" + $File "$SRCDIR\game\shared\hl2\hl2_shareddefs.h" + $File "$SRCDIR\game\shared\hl2\hl_gamemovement.cpp" + $File "$SRCDIR\game\shared\hl2\hl_gamemovement.h" + $File "hl2\hl_in_main.cpp" + $File "hl2\hl_prediction.cpp" + $File "hl2\hud_ammo.cpp" + $File "hl2\hud_battery.cpp" + $File "hl2\hud_blood.cpp" + $File "hl2\hud_bonusprogress.cpp" + $File "hl2\hud_credits.cpp" + $File "hl2\hud_damageindicator.cpp" + $File "hl2\hud_flashlight.cpp" + $File "hl2\hud_health.cpp" + $File "hl2\hud_poisondamageindicator.cpp" + $File "hud_squadstatus.cpp" + $File "hl2\hud_suitpower.cpp" + $File "hl2\hud_suitpower.h" + $File "hl2\hud_weaponselection.cpp" + $File "hl2\hud_zoom.cpp" + $File "hl2\shieldproxy.cpp" + $File "$SRCDIR\game\shared\hl2\survival_gamerules.cpp" + $File "hl2\vgui_rootpanel_hl2.cpp" + } + + $Folder "Portal" + { + $File "$SRCDIR\game\shared\portal\achievements_portal.cpp" + $File "portal\c_env_lightraill_endpoint.cpp" + $File "portal\c_env_portal_path_track.cpp" + $File "portal\c_func_liquidportal.cpp" + $File "portal\c_func_liquidportal.h" + $File "portal\c_neurotoxin_countdown.cpp" + $File "portal\c_neurotoxin_countdown.h" + $File "portal\c_npc_portal_turret_floor.cpp" + $File "portal\c_npc_rocket_turret.cpp" + $File "portal\c_portal_player.cpp" + $File "portal\c_portal_player.h" + $File "portal\C_PortalGhostRenderable.cpp" + $File "portal\C_PortalGhostRenderable.h" + $File "portal\c_prop_energy_ball.cpp" + $File "portal\c_prop_portal.cpp" + $File "portal\c_prop_portal.h" + $File "portal\c_prop_portal_stats_display.cpp" + $File "portal\c_prop_portal_stats_display.h" + $File "portal\clientmode_portal.cpp" + $File "portal\clientmode_portal.h" + $File "$SRCDIR\game\shared\portal\env_lightrail_endpoint_shared.h" + $File "$SRCDIR\game\shared\portal\env_portal_path_track_shared.h" + $File "portal\fx_portal.cpp" + $File "portal\hud_quickinfo.cpp" + $File "portal\MaterialProxy_Portal_PickAlphaMask.cpp" + $File "portal\materialproxy_portalstatic.cpp" + $File "$SRCDIR\game\shared\Multiplayer\multiplayer_animstate.cpp" + $File "$SRCDIR\game\shared\Multiplayer\multiplayer_animstate.h" + $File "$SRCDIR\game\shared\portal\portal_collideable_enumerator.cpp" + $File "$SRCDIR\game\shared\portal\portal_collideable_enumerator.h" + $File "portal\portal_credits.cpp" + $File "portal\Portal_DynamicMeshRenderingUtils.cpp" + $File "portal\Portal_DynamicMeshRenderingUtils.h" + $File "$SRCDIR\game\shared\portal\portal_gamemovement.cpp" + $File "$SRCDIR\game\shared\portal\portal_gamerules.cpp" + $File "$SRCDIR\game\shared\portal\portal_gamerules.h" + $File "portal\portal_hud_crosshair.cpp" + $File "portal\portal_hud_crosshair.h" + $File "$SRCDIR\game\shared\portal\portal_player_shared.cpp" + $File "$SRCDIR\game\shared\portal\portal_player_shared.h" + $File "$SRCDIR\game\shared\portal\portal_playeranimstate.cpp" + $File "$SRCDIR\game\shared\portal\portal_playeranimstate.h" + $File "portal\portal_render_targets.cpp" + $File "portal\portal_render_targets.h" + $File "$SRCDIR\game\shared\portal\portal_shareddefs.cpp" + $File "$SRCDIR\game\shared\portal\portal_shareddefs.h" + $File "$SRCDIR\game\shared\portal\portal_usermessages.cpp" + $File "$SRCDIR\game\shared\portal\portal_util_shared.cpp" + $File "$SRCDIR\game\shared\portal\portal_util_shared.h" + $File "$SRCDIR\game\shared\portal\prop_portal_shared.cpp" + $File "$SRCDIR\game\shared\portal\prop_portal_shared.h" + $File "$SRCDIR\game\shared\portal\PortalSimulation.cpp" + $File "$SRCDIR\game\shared\portal\PortalSimulation.h" + $File "$SRCDIR\game\shared\portal\StaticCollisionPolyhedronCache.cpp" + $File "$SRCDIR\game\shared\portal\StaticCollisionPolyhedronCache.h" + $File "portal\PortalRender.cpp" + $File "portal\PortalRender.h" + $File "portal\c_portal_radio.cpp" + $File "portal\portalrenderable_flatbasic.cpp" + $File "portal\portalrenderable_flatbasic.h" + $File "portal\vgui_portal_stats_display_screen.cpp" + $File "portal\vgui_neurotoxin_countdown_screen.cpp" + $File "$SRCDIR\game\shared\portal\portal_weapon_parse.cpp" + + $Folder "Weapons" + { + $File "portal\c_weapon_physcannon.cpp" + $File "portal\c_weapon_portalgun.cpp" + $File "portal\c_weapon_portalgun.h" + $File "portal\c_weapon_stubs_portal.cpp" + $File "$SRCDIR\game\shared\portal\weapon_portalbase.cpp" + $File "$SRCDIR\game\shared\portal\weapon_portalbase.h" + $File "$SRCDIR\game\shared\portal\weapon_portalbasecombatweapon.cpp" + $File "$SRCDIR\game\shared\portal\weapon_portalbasecombatweapon.h" + $File "$SRCDIR\game\shared\portal\weapon_portalgun_shared.cpp" + $File "$SRCDIR\game\shared\portal\weapon_portalgun_shared.h" + } + } + } +} + diff --git a/game/client/dod/VGUI/backgroundpanel.cpp b/game/client/dod/VGUI/backgroundpanel.cpp new file mode 100644 index 00000000..9783c21c --- /dev/null +++ b/game/client/dod/VGUI/backgroundpanel.cpp @@ -0,0 +1,677 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "backgroundpanel.h" + +#include +#include +#include +#include +#include +#include "vgui_controls/BuildGroup.h" +#include "vgui_controls/BitmapImagePanel.h" + +using namespace vgui; + +#define DEBUG_WINDOW_RESIZING 0 +#define DEBUG_WINDOW_REPOSITIONING 0 + +//----------------------------------------------------------------------------- +const int NumSegments = 7; +static int coord[NumSegments+1] = { + 0, + 1, + 2, + 3, + 4, + 6, + 9, + 10 +}; + +//----------------------------------------------------------------------------- +void DrawRoundedBackground( Color bgColor, int wide, int tall ) +{ + int x1, x2, y1, y2; + surface()->DrawSetColor(bgColor); + surface()->DrawSetTextColor(bgColor); + + int i; + + // top-left corner -------------------------------------------------------- + int xDir = 1; + int yDir = -1; + int xIndex = 0; + int yIndex = NumSegments - 1; + int xMult = 1; + int yMult = 1; + int x = 0; + int y = 0; + for ( i=0; iDrawFilledRect( x1, y1, x2, y2 ); + + xIndex += xDir; + yIndex += yDir; + } + + // top-right corner ------------------------------------------------------- + xDir = 1; + yDir = -1; + xIndex = 0; + yIndex = NumSegments - 1; + x = wide; + y = 0; + xMult = -1; + yMult = 1; + for ( i=0; iDrawFilledRect( x1, y1, x2, y2 ); + xIndex += xDir; + yIndex += yDir; + } + + // bottom-right corner ---------------------------------------------------- + xDir = 1; + yDir = -1; + xIndex = 0; + yIndex = NumSegments - 1; + x = wide; + y = tall; + xMult = -1; + yMult = -1; + for ( i=0; iDrawFilledRect( x1, y1, x2, y2 ); + xIndex += xDir; + yIndex += yDir; + } + + // bottom-left corner ----------------------------------------------------- + xDir = 1; + yDir = -1; + xIndex = 0; + yIndex = NumSegments - 1; + x = 0; + y = tall; + xMult = 1; + yMult = -1; + for ( i=0; iDrawFilledRect( x1, y1, x2, y2 ); + xIndex += xDir; + yIndex += yDir; + } + + // paint between top left and bottom left --------------------------------- + x1 = 0; + x2 = coord[NumSegments]; + y1 = coord[NumSegments]; + y2 = tall - coord[NumSegments]; + surface()->DrawFilledRect( x1, y1, x2, y2 ); + + // paint between left and right ------------------------------------------- + x1 = coord[NumSegments]; + x2 = wide - coord[NumSegments]; + y1 = 0; + y2 = tall; + surface()->DrawFilledRect( x1, y1, x2, y2 ); + + // paint between top right and bottom right ------------------------------- + x1 = wide - coord[NumSegments]; + x2 = wide; + y1 = coord[NumSegments]; + y2 = tall - coord[NumSegments]; + surface()->DrawFilledRect( x1, y1, x2, y2 ); +} + +//----------------------------------------------------------------------------- +void DrawRoundedBorder( Color borderColor, int wide, int tall ) +{ + int x1, x2, y1, y2; + surface()->DrawSetColor(borderColor); + surface()->DrawSetTextColor(borderColor); + + int i; + + // top-left corner -------------------------------------------------------- + int xDir = 1; + int yDir = -1; + int xIndex = 0; + int yIndex = NumSegments - 1; + int xMult = 1; + int yMult = 1; + int x = 0; + int y = 0; + for ( i=0; iDrawFilledRect( x1, y1, x2, y2 ); + + xIndex += xDir; + yIndex += yDir; + } + + // top-right corner ------------------------------------------------------- + xDir = 1; + yDir = -1; + xIndex = 0; + yIndex = NumSegments - 1; + x = wide; + y = 0; + xMult = -1; + yMult = 1; + for ( i=0; iDrawFilledRect( x1, y1, x2, y2 ); + xIndex += xDir; + yIndex += yDir; + } + + // bottom-right corner ---------------------------------------------------- + xDir = 1; + yDir = -1; + xIndex = 0; + yIndex = NumSegments - 1; + x = wide; + y = tall; + xMult = -1; + yMult = -1; + for ( i=0; iDrawFilledRect( x1, y1, x2, y2 ); + xIndex += xDir; + yIndex += yDir; + } + + // bottom-left corner ----------------------------------------------------- + xDir = 1; + yDir = -1; + xIndex = 0; + yIndex = NumSegments - 1; + x = 0; + y = tall; + xMult = 1; + yMult = -1; + for ( i=0; iDrawFilledRect( x1, y1, x2, y2 ); + xIndex += xDir; + yIndex += yDir; + } + + // top -------------------------------------------------------------------- + x1 = coord[NumSegments]; + x2 = wide - coord[NumSegments]; + y1 = 0; + y2 = 1; + surface()->DrawFilledRect( x1, y1, x2, y2 ); + + // bottom ----------------------------------------------------------------- + x1 = coord[NumSegments]; + x2 = wide - coord[NumSegments]; + y1 = tall - 1; + y2 = tall; + surface()->DrawFilledRect( x1, y1, x2, y2 ); + + // left ------------------------------------------------------------------- + x1 = 0; + x2 = 1; + y1 = coord[NumSegments]; + y2 = tall - coord[NumSegments]; + surface()->DrawFilledRect( x1, y1, x2, y2 ); + + // right ------------------------------------------------------------------ + x1 = wide - 1; + x2 = wide; + y1 = coord[NumSegments]; + y2 = tall - coord[NumSegments]; + surface()->DrawFilledRect( x1, y1, x2, y2 ); +} + +//----------------------------------------------------------------------------- +class CaptionLabel : public Label +{ +public: + CaptionLabel(Panel *parent, const char *panelName, const char *text) : Label(parent, panelName, text) + { + } + + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ) + { + Label::ApplySchemeSettings( pScheme ); + SetFont( pScheme->GetFont( "MenuTitle", IsProportional() ) ); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: transform a normalized value into one that is scaled based the minimum +// of the horizontal and vertical ratios +//----------------------------------------------------------------------------- +static int GetAlternateProportionalValueFromNormal(int normalizedValue) +{ + int wide, tall; + GetHudSize( wide, tall ); + int proH, proW; + surface()->GetProportionalBase( proW, proH ); + double scaleH = (double)tall / (double)proH; + double scaleW = (double)wide / (double)proW; + double scale = (scaleW < scaleH) ? scaleW : scaleH; + + return (int)( normalizedValue * scale ); +} + +//----------------------------------------------------------------------------- +// Purpose: transform a standard scaled value into one that is scaled based the minimum +// of the horizontal and vertical ratios +//----------------------------------------------------------------------------- +int GetAlternateProportionalValueFromScaled(vgui::HScheme hScheme, int scaledValue) +{ + return GetAlternateProportionalValueFromNormal( scheme()->GetProportionalNormalizedValueEx( hScheme, scaledValue ) ); +} + +//----------------------------------------------------------------------------- +// Purpose: moves and resizes a single control +//----------------------------------------------------------------------------- +static void RepositionControl( Panel *pPanel ) +{ + int x, y, w, h; + pPanel->GetBounds(x, y, w, h); + +#if DEBUG_WINDOW_RESIZING + int x1, y1, w1, h1; + pPanel->GetBounds(x1, y1, w1, h1); + int x2, y2, w2, h2; + x2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(),x1 ); + y2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(),y1 ); + w2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(),w1 ); + h2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(),h1 ); +#endif + + x = GetAlternateProportionalValueFromScaled(pPanel->GetScheme(),x); + y = GetAlternateProportionalValueFromScaled(pPanel->GetScheme(),y); + w = GetAlternateProportionalValueFromScaled(pPanel->GetScheme(),w); + h = GetAlternateProportionalValueFromScaled(pPanel->GetScheme(),h); + + pPanel->SetBounds(x, y, w, h); + +#if DEBUG_WINDOW_RESIZING + DevMsg( "Resizing '%s' from (%d,%d) %dx%d to (%d,%d) %dx%d -- initially was (%d,%d) %dx%d\n", + pPanel->GetName(), x1, y1, w1, h1, x, y, w, h, x2, y2, w2, h2 ); +#endif +} + +//----------------------------------------------------------------------------- +// Purpose: Sets colors etc for background image panels +//----------------------------------------------------------------------------- +void ApplyBackgroundSchemeSettings( EditablePanel *pWindow, vgui::IScheme *pScheme ) +{ + Color bgColor = Color( 255, 255, 255, pScheme->GetColor( "BgColor", Color( 0, 0, 0, 0 ) )[3] ); + Color fgColor = pScheme->GetColor( "FgColor", Color( 0, 0, 0, 0 ) ); + + if ( !pWindow ) + return; + + CBitmapImagePanel *pBitmapPanel; + + // corners -------------------------------------------- + pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "TopLeftPanel" )); + if ( pBitmapPanel ) + { + pBitmapPanel->setImageColor( bgColor ); + } + pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "TopRightPanel" )); + if ( pBitmapPanel ) + { + pBitmapPanel->setImageColor( bgColor ); + } + pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "BottomLeftPanel" )); + if ( pBitmapPanel ) + { + pBitmapPanel->setImageColor( bgColor ); + } + pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "BottomRightPanel" )); + if ( pBitmapPanel ) + { + pBitmapPanel->setImageColor( bgColor ); + } + + // background ----------------------------------------- + pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "TopSolid" )); + if ( pBitmapPanel ) + { + pBitmapPanel->setImageColor( bgColor ); + } + pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "UpperMiddleSolid" )); + if ( pBitmapPanel ) + { + pBitmapPanel->setImageColor( bgColor ); + } + pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "LowerMiddleSolid" )); + if ( pBitmapPanel ) + { + pBitmapPanel->setImageColor( bgColor ); + } + pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "BottomSolid" )); + if ( pBitmapPanel ) + { + pBitmapPanel->setImageColor( bgColor ); + } + + // Logo ----------------------------------------------- +/* pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "ExclamationPanel" )); + if ( pBitmapPanel ) + { + pBitmapPanel->setImageColor( fgColor ); + } +*/ +} + +//----------------------------------------------------------------------------- +// Purpose: Re-aligns background image panels so they are touching. +//----------------------------------------------------------------------------- +static void FixupBackgroundPanels( EditablePanel *pWindow, int offsetX, int offsetY ) +{ + if ( !pWindow ) + return; + + int screenWide, screenTall; + pWindow->GetSize( screenWide, screenTall ); + + int inset = GetAlternateProportionalValueFromNormal( 20 ); + int cornerSize = GetAlternateProportionalValueFromNormal( 10 ); + + int titleHeight = GetAlternateProportionalValueFromNormal( 42 ); + int mainHeight = GetAlternateProportionalValueFromNormal( 376 ); + + int logoSize = titleHeight; + + int captionInset = GetAlternateProportionalValueFromNormal( 76 ); + + Panel *pPanel; + + // corners -------------------------------------------- + pPanel = pWindow->FindChildByName( "TopLeftPanel" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( offsetX + inset, offsetY + inset, cornerSize, cornerSize ); + } + + pPanel = pWindow->FindChildByName( "TopRightPanel" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, offsetY + inset, cornerSize, cornerSize ); + } + + pPanel = pWindow->FindChildByName( "BottomLeftPanel" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize ); + } + + pPanel = pWindow->FindChildByName( "BottomRightPanel" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize ); + } + + // background ----------------------------------------- + pPanel = pWindow->FindChildByName( "TopSolid" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( offsetX + inset + cornerSize, offsetY + inset, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize ); + } + + pPanel = pWindow->FindChildByName( "UpperMiddleSolid" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( offsetX + inset, offsetY + inset + cornerSize, screenWide - 2*offsetX - 2*inset, titleHeight ); + } + + pPanel = pWindow->FindChildByName( "LowerMiddleSolid" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( offsetX + inset + cornerSize, screenTall - offsetY - inset - cornerSize, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize ); + } + + pPanel = pWindow->FindChildByName( "BottomSolid" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize - mainHeight, screenWide - 2*offsetX - 2*inset, mainHeight ); + } + + // transparent border --------------------------------- + pPanel = pWindow->FindChildByName( "TopClear" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( 0, 0, screenWide, offsetY + inset ); + } + + pPanel = pWindow->FindChildByName( "BottomClear" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( 0, screenTall - offsetY - inset, screenWide, offsetY + inset ); + } + + pPanel = pWindow->FindChildByName( "LeftClear" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( 0, offsetY + inset, offsetX + inset, screenTall - 2*offsetY - 2*inset ); + } + + pPanel = pWindow->FindChildByName( "RightClear" ); + if ( pPanel ) + { + pPanel->SetZPos( -20 ); + pPanel->SetBounds( screenWide - offsetX - inset, offsetY + inset, offsetX + inset, screenTall - 2*offsetY - 2*inset ); + } + + // Logo ----------------------------------------------- +/* int logoInset = (cornerSize + titleHeight - logoSize)/2; + pPanel = pWindow->FindChildByName( "ExclamationPanel" ); + if ( pPanel ) + { + pPanel->SetZPos( -19 ); // higher than the background + pPanel->SetBounds( offsetX + inset + logoInset, offsetY + inset + logoInset, logoSize, logoSize ); + } +*/ + // Title caption -------------------------------------- + pPanel = dynamic_cast< Label * >(pWindow->FindChildByName( "CaptionLabel" )); + if ( pPanel ) + { + pPanel->SetZPos( -19 ); // higher than the background + pPanel->SetBounds( offsetX + captionInset/*inset + 2*logoInset + logoSize*/, offsetY + inset /*+ logoInset*/, screenWide, logoSize ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Creates background image panels +//----------------------------------------------------------------------------- +void CreateBackground( EditablePanel *pWindow ) +{ + // corners -------------------------------------------- + new CBitmapImagePanel( pWindow, "TopLeftPanel", "gfx/vgui/round_corner_nw" ); + new CBitmapImagePanel( pWindow, "TopRightPanel", "gfx/vgui/round_corner_ne" ); + new CBitmapImagePanel( pWindow, "BottomLeftPanel", "gfx/vgui/round_corner_sw" ); + new CBitmapImagePanel( pWindow, "BottomRightPanel", "gfx/vgui/round_corner_se" ); + + // background ----------------------------------------- + new CBitmapImagePanel( pWindow, "TopSolid", "gfx/vgui/solid_background" ); + new CBitmapImagePanel( pWindow, "UpperMiddleSolid", "gfx/vgui/solid_background" ); + new CBitmapImagePanel( pWindow, "LowerMiddleSolid", "gfx/vgui/solid_background" ); + new CBitmapImagePanel( pWindow, "BottomSolid", "gfx/vgui/solid_background" ); + + // transparent border --------------------------------- + new CBitmapImagePanel( pWindow, "TopClear", "gfx/vgui/trans_background" ); + new CBitmapImagePanel( pWindow, "BottomClear", "gfx/vgui/trans_background" ); + new CBitmapImagePanel( pWindow, "LeftClear", "gfx/vgui/trans_background" ); + new CBitmapImagePanel( pWindow, "RightClear", "gfx/vgui/trans_background" ); + + // Logo ----------------------------------------------- +// new CBitmapImagePanel( pWindow, "ExclamationPanel", "gfx/vgui/TF_logo" ); + + // Title caption -------------------------------------- + Panel *pPanel = dynamic_cast< Label * >(pWindow->FindChildByName( "CaptionLabel" )); + if ( !pPanel ) + new CaptionLabel( pWindow, "CaptionLabel", "" ); +} + +void ResizeWindowControls( EditablePanel *pWindow, int tall, int wide, int offsetX, int offsetY ) +{ + if (!pWindow || !pWindow->GetBuildGroup() || !pWindow->GetBuildGroup()->GetPanelList()) + return; + + CUtlVector *panelList = pWindow->GetBuildGroup()->GetPanelList(); + CUtlVector resizedPanels; + CUtlVector movedPanels; + + // Resize to account for 1.25 aspect ratio (1280x1024) screens + { + for ( int i = 0; i < panelList->Size(); ++i ) + { + PHandle handle = (*panelList)[i]; + + Panel *panel = handle.Get(); + + bool found = false; + for ( int j = 0; j < resizedPanels.Size(); ++j ) + { + if (panel == resizedPanels[j]) + found = true; + } + + if (!panel || found) + { + continue; + } + + resizedPanels.AddToTail( panel ); // don't move a panel more than once + + if ( panel != pWindow ) + { + RepositionControl( panel ); + } + } + } + + // and now re-center them. Woohoo! + for ( int i = 0; i < panelList->Size(); ++i ) + { + PHandle handle = (*panelList)[i]; + + Panel *panel = handle.Get(); + + bool found = false; + for ( int j = 0; j < movedPanels.Size(); ++j ) + { + if (panel == movedPanels[j]) + found = true; + } + + if (!panel || found) + { + continue; + } + + movedPanels.AddToTail( panel ); // don't move a panel more than once + + if ( panel != pWindow ) + { + int x, y; + + panel->GetPos( x, y ); + panel->SetPos( x + offsetX, y + offsetY ); + +#if DEBUG_WINDOW_REPOSITIONING + DevMsg( "Repositioning '%s' from (%d,%d) to (%d,%d) -- a distance of (%d,%d)\n", + panel->GetName(), x, y, x + offsetX, y + offsetY, offsetX, offsetY ); +#endif + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Resizes windows to fit completely on-screen (for 1280x1024), and +// centers them on the screen. Sub-controls are also resized and moved. +//----------------------------------------------------------------------------- +void LayoutBackgroundPanel( EditablePanel *pWindow ) +{ + if ( !pWindow ) + return; + + int screenW, screenH; + GetHudSize( screenW, screenH ); + + int wide, tall; + pWindow->GetSize( wide, tall ); + + int offsetX = 0; + int offsetY = 0; + + // Slide everything over to the center + pWindow->SetBounds( 0, 0, screenW, screenH ); + + if ( wide != screenW || tall != screenH ) + { + wide = GetAlternateProportionalValueFromScaled(pWindow->GetScheme(), wide); + tall = GetAlternateProportionalValueFromScaled(pWindow->GetScheme(), tall); + + offsetX = (screenW - wide)/2; + offsetY = (screenH - tall)/2; + + ResizeWindowControls( pWindow, tall, wide, offsetX, offsetY ); + } + + // now that the panels are moved/resized, look for some bg panels, and re-align them + FixupBackgroundPanels( pWindow, offsetX, offsetY ); +} + +//----------------------------------------------------------------------------- + diff --git a/game/client/dod/VGUI/backgroundpanel.h b/game/client/dod/VGUI/backgroundpanel.h new file mode 100644 index 00000000..7006aebd --- /dev/null +++ b/game/client/dod/VGUI/backgroundpanel.h @@ -0,0 +1,53 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DODBACKGROUND_H +#define DODBACKGROUND_H + +#include +#include + +//----------------------------------------------------------------------------- +// Purpose: Creates background image panels +//----------------------------------------------------------------------------- +void CreateBackground( vgui::EditablePanel *pWindow ); + +//----------------------------------------------------------------------------- +// Purpose: Resizes windows to fit completely on-screen (for 1280x1024), and +// centers them on the screen. Sub-controls are also resized and moved. +//----------------------------------------------------------------------------- +void LayoutBackgroundPanel( vgui::EditablePanel *pWindow ); + +//----------------------------------------------------------------------------- +// Purpose: Sets colors etc for background image panels +//----------------------------------------------------------------------------- +void ApplyBackgroundSchemeSettings( vgui::EditablePanel *pWindow, vgui::IScheme *pScheme ); + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void ResizeWindowControls( vgui::EditablePanel *pWindow, int tall, int wide, int offsetX, int offsetY ); + +//----------------------------------------------------------------------------- +// Purpose: transform a standard scaled value into one that is scaled based the minimum +// of the horizontal and vertical ratios +//----------------------------------------------------------------------------- +int GetAlternateProportionalValueFromScaled( vgui::HScheme hScheme, int scaledValue ); + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void DrawRoundedBackground( Color bgColor, int wide, int tall ); + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void DrawRoundedBorder( Color borderColor, int wide, int tall ); + +//----------------------------------------------------------------------------- + +#endif // DODBACKGROUND_H diff --git a/game/client/dod/VGUI/dodbutton.cpp b/game/client/dod/VGUI/dodbutton.cpp new file mode 100644 index 00000000..11e0adeb --- /dev/null +++ b/game/client/dod/VGUI/dodbutton.cpp @@ -0,0 +1,99 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "dodbutton.h" + +#include +#include + +// memdbgon must be the last include file in a .cpp file!!! +#include + +using namespace vgui; + +//=============================================== +// CDODButtonShape - drawing class for dod button shape +//=============================================== +void CDODButtonShape::DrawShapedBorder( int x, int y, int wide, int tall, Color fgcolor ) +{ + int halfheight = tall / 3; + + surface()->DrawSetColor(fgcolor); + + // top + surface()->DrawLine( 0, 1, wide-1, 1 ); + + // left + surface()->DrawLine( 1, 1, 1, tall-1 ); + + // bottom + surface()->DrawLine( 0, tall-1, wide-halfheight, tall-1 ); + + // right + surface()->DrawLine( wide-1, 0, wide-1, tall-halfheight ); + + // diagonal + surface()->DrawLine( wide-1, tall-halfheight-1, wide-halfheight-1, tall-1 ); +} + +void CDODButtonShape::DrawShapedBackground( int x, int y, int wide, int tall, Color bgcolor ) +{ + int halfheight = tall / 3; + + if ( m_iWhiteTexture < 0 ) + { + m_iWhiteTexture = vgui::surface()->CreateNewTextureID(); + vgui::surface()->DrawSetTextureFile( m_iWhiteTexture, "vgui/white" , true, false); + } + + surface()->DrawSetColor(bgcolor); + surface()->DrawSetTexture( m_iWhiteTexture ); + + Vertex_t verts[5]; + + verts[0].Init( Vector2D( 0, 0 ) ); + verts[1].Init( Vector2D( wide-1, 0 ) ); + verts[2].Init( Vector2D( wide-1, tall-halfheight ) ); + verts[3].Init( Vector2D( wide-halfheight, tall-1 ) ); + verts[4].Init( Vector2D( 0, tall-1 ) ); + + surface()->DrawTexturedPolygon(5, verts); + + surface()->DrawSetTexture(0); +} + +//=============================================== +// CDODButton - shaped button +//=============================================== +void CDODButton::PaintBackground() +{ + int wide, tall; + GetSize(wide,tall); + DrawShapedBackground( 0, 0, wide, tall, GetBgColor() ); +} + +void CDODButton::PaintBorder() +{ + int wide, tall; + GetSize(wide,tall); + DrawShapedBorder( 0, 0, wide, tall, GetFgColor() ); +} + +//=============================================== +// CDODProgressBar - used for weapon stat bars +//=============================================== +void CDODProgressBar::ApplySchemeSettings(IScheme *pScheme) +{ + BaseClass::ApplySchemeSettings(pScheme); + + SetFgColor( GetSchemeColor("ClassMenuLight", pScheme ) ); + SetBgColor( GetSchemeColor("ClassMenuDark", pScheme ) ); + SetBarInset(0); + SetSegmentInfo( 0, 1 ); + SetBorder(NULL); +} \ No newline at end of file diff --git a/game/client/dod/VGUI/dodbutton.h b/game/client/dod/VGUI/dodbutton.h new file mode 100644 index 00000000..dd1870bb --- /dev/null +++ b/game/client/dod/VGUI/dodbutton.h @@ -0,0 +1,88 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DOD_BUTTON_H +#define DOD_BUTTON_H + +#include "mouseoverpanelbutton.h" +#include "KeyValues.h" +#include +#include +#include + +// a button with the bottom right corner cut out + +/* + +|``````````````| +| PRESS ME! | +|_____________/ + +*/ + +class CDODButtonShape +{ +public: + CDODButtonShape() + { + m_iWhiteTexture = -1; + } + + void DrawShapedBorder( int x, int y, int wide, int tall, Color fgcolor ); + void DrawShapedBackground( int x, int y, int wide, int tall, Color bgcolor ); + +protected: + int m_iWhiteTexture; +}; + +class CDODButton : public vgui::Button, public CDODButtonShape +{ +private: + DECLARE_CLASS_SIMPLE( CDODButton, vgui::Button ); + +public: + CDODButton(vgui::Panel *parent ) : + vgui::Button( parent, "DODButton", "" ) + { + } + +protected: + virtual void PaintBackground(); + virtual void PaintBorder(); +}; + +class CDODClassInfoPanel : public vgui::EditablePanel +{ +private: + DECLARE_CLASS_SIMPLE( CDODClassInfoPanel, vgui::EditablePanel ); + +public: + CDODClassInfoPanel( vgui::Panel *parent, const char *panelName ) : vgui::EditablePanel( parent, panelName ) + { + } + + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + virtual vgui::Panel *CreateControlByName( const char *controlName ); +}; + + +// Solid coloured progress bar with no border +class CDODProgressBar : public vgui::ProgressBar +{ +private: + DECLARE_CLASS_SIMPLE( CDODProgressBar, vgui::ProgressBar ); + +public: + CDODProgressBar(vgui::Panel *parent) : vgui::ProgressBar( parent, "statBar" ) + { + } + +protected: + virtual void ApplySchemeSettings(vgui::IScheme *pScheme); +}; + +#endif //DOD_BUTTON_H \ No newline at end of file diff --git a/game/client/dod/VGUI/dodclassmenu.cpp b/game/client/dod/VGUI/dodclassmenu.cpp new file mode 100644 index 00000000..a32d1af2 --- /dev/null +++ b/game/client/dod/VGUI/dodclassmenu.cpp @@ -0,0 +1,353 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "dodclassmenu.h" + +#include +#include +#include +#include +#include + +#include "hud.h" // for gEngfuncs +#include "c_dod_player.h" +#include "c_dod_team.h" + +#include "imagemouseoverbutton.h" + +#include "dodmouseoverpanelbutton.h" +#include "dodrandombutton.h" +#include "IconPanel.h" + +#include "IGameUIFuncs.h" // for key bindings + +extern IGameUIFuncs *gameuifuncs; // for key binding details + +using namespace vgui; + +extern ConVar hud_classautokill; +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +Panel *CDODClassInfoPanel::CreateControlByName( const char *controlName ) +{ + if( !Q_stricmp( "ProgressBar", controlName ) ) + { + return new CDODProgressBar(this); + } + else if ( !Q_stricmp( "CIconPanel", controlName ) ) + { + return new CIconPanel(this, "icon_panel"); + } + else + { + return BaseClass::CreateControlByName( controlName ); + } +} + +void CDODClassInfoPanel::ApplySchemeSettings( IScheme *pScheme ) +{ + RichText *pClassInfo = dynamic_cast(FindChildByName("classInfo")); + + if ( pClassInfo ) + { + pClassInfo->SetBorder(pScheme->GetBorder("NoBorder")); + pClassInfo->SetBgColor(pScheme->GetColor("Blank", Color(0,0,0,0))); + } + + BaseClass::ApplySchemeSettings( pScheme ); +} + +CDODClassMenu::CDODClassMenu(IViewPort *pViewPort) : CClassMenu(pViewPort) +{ + m_mouseoverButtons.RemoveAll(); + m_iClassMenuKey = BUTTON_CODE_INVALID; + m_pInitialButton = NULL; + + m_pBackground = SETUP_PANEL( new CDODMenuBackground( this ) ); + + m_pClassInfoPanel = new CDODClassInfoPanel( this, "ClassInfoPanel" ); + + vgui::ivgui()->AddTickSignal( GetVPanel() ); + + m_iActivePlayerClass = -1; + m_iLastPlayerClassCount = -1; + + m_pClassNumLabel[0] = new Label( this, "class_1_num", "" ); + m_pClassNumLabel[1] = new Label( this, "class_2_num", "" ); + m_pClassNumLabel[2] = new Label( this, "class_3_num", "" ); + m_pClassNumLabel[3] = new Label( this, "class_4_num", "" ); + m_pClassNumLabel[4] = new Label( this, "class_5_num", "" ); + m_pClassNumLabel[5] = new Label( this, "class_6_num", "" ); + + m_pClassFullLabel[0] = new Label( this, "class_1_full", "" ); + m_pClassFullLabel[1] = new Label( this, "class_2_full", "" ); + m_pClassFullLabel[2] = new Label( this, "class_3_full", "" ); + m_pClassFullLabel[3] = new Label( this, "class_4_full", "" ); + m_pClassFullLabel[4] = new Label( this, "class_5_full", "" ); + m_pClassFullLabel[5] = new Label( this, "class_6_full", "" ); + + m_pSuicideOption = new CheckButton( this, "suicide_option", "Sky is blue?" ); +} + +void CDODClassMenu::ShowPanel( bool bShow ) +{ + if ( bShow ) + { + engine->CheckPoint( "ClassMenu" ); + + m_iClassMenuKey = gameuifuncs->GetButtonCodeForBind( "changeclass" ); + + m_pSuicideOption->SetSelected( hud_classautokill.GetBool() ); + } + + for( int i = 0; i< GetChildCount(); i++ ) + { + CImageMouseOverButton *button = + dynamic_cast *>(GetChild(i)); + + if ( button ) + { + if( button == m_pInitialButton && bShow == true ) + button->ShowPage(); + else + button->HidePage(); + } + } + + CDODRandomButton *pRandom = + dynamic_cast *>( FindChildByName("random") ); + + if ( pRandom ) + pRandom->HidePage(); + + // recalc position of checkbox, since it doesn't do right alignment + m_pSuicideOption->SizeToContents(); + + int x, y, wide, tall; + m_pSuicideOption->GetBounds( x, y, wide, tall ); + + int parentW, parentH; + GetSize( parentW, parentH ); + + x = parentW / 2; // - wide; + m_pSuicideOption->SetPos( x, y ); + + BaseClass::ShowPanel( bShow ); +} + +void CDODClassMenu::OnKeyCodePressed( KeyCode code ) +{ +#ifdef REFRESH_CLASSMENU_TOOL + + if ( code == KEY_PAD_MULTIPLY ) + { + OnRefreshClassMenu(); + } +#endif + + if ( m_iClassMenuKey != BUTTON_CODE_INVALID && m_iClassMenuKey == code ) + { + ShowPanel( false ); + } + else + { + BaseClass::OnKeyCodePressed( code ); + } +} + +void CDODClassMenu::Update() +{ + C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer(); + + if ( pPlayer && pPlayer->m_Shared.DesiredPlayerClass() == PLAYERCLASS_UNDEFINED ) + { + SetVisibleButton( "CancelButton", false ); + } + else + { + SetVisibleButton( "CancelButton", true ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +Panel *CDODClassMenu::CreateControlByName( const char *controlName ) +{ + if ( !Q_stricmp( "DODMouseOverPanelButton", controlName ) ) + { + return new CDODMouseOverButton( this, NULL, m_pClassInfoPanel ); + } + else if( !Q_stricmp( "DODButton", controlName ) ) + { + return new CDODButton(this); + } + else if( !Q_stricmp( "DODRandomButton", controlName ) ) + { + return new CDODRandomButton(this, NULL, m_pClassInfoPanel ); + } + else if ( !Q_stricmp( "ImageButton", controlName ) ) + { + CImageMouseOverButton *newButton = new CImageMouseOverButton( this, NULL, m_pClassInfoPanel ); + + if( !m_pInitialButton ) + { + m_pInitialButton = newButton; + } + + return newButton; + } + else if ( !Q_stricmp( "CIconPanel", controlName ) ) + { + return new CIconPanel(this, "icon_panel"); + } + else + { + return BaseClass::CreateControlByName( controlName ); + } +} + +//----------------------------------------------------------------------------- +// Catch the mouseover event and set the active class +//----------------------------------------------------------------------------- +void CDODClassMenu::OnShowPage( const char *pagename ) +{ + // change which class we are counting based on class name + + // turn the button name into a classname + + char buf[64]; + + Q_snprintf( buf, sizeof(buf), "cls_%s", pagename ); + + C_DODTeam *pTeam = dynamic_cast( GetGlobalTeam(GetTeamNumber()) ); + + if( !pTeam ) + return; + + // Pull the index of this class via IsClassOnTeam + if ( !pTeam->IsClassOnTeam( buf, m_iActivePlayerClass ) ) + { + Assert( !"bad class name on class button" ); + } + + UpdateNumClassLabel(); +} + +//----------------------------------------------------------------------------- +// Draw nothing +//----------------------------------------------------------------------------- +void CDODClassMenu::PaintBackground( void ) +{ +} + +//----------------------------------------------------------------------------- +// Do things that should be done often, eg number of players in the +// selected class +//----------------------------------------------------------------------------- +void CDODClassMenu::OnTick( void ) +{ + //When a player changes teams, their class and team values don't get here + //necessarily before the command to update the class menu. This leads to the cancel button + //being visible and people cancelling before they have a class. check for class == DOD_CLASS_NONE and if so + //hide the cancel button + + if ( !IsVisible() ) + return; + + C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer(); + + if( pPlayer && pPlayer->m_Shared.PlayerClass() == PLAYERCLASS_UNDEFINED ) + { + SetVisibleButton("CancelButton", false); + } + + UpdateNumClassLabel(); + + BaseClass::OnTick(); +} + +void CDODClassMenu::UpdateNumClassLabel( void ) +{ + int iClassCount[NUM_CLASSES]; + // Initialize to zero. Was previously used uninitialized. + int iClassLimit[NUM_CLASSES] = {}; + + // count how many of this class there are + C_DODTeam *pTeam = dynamic_cast( GetGlobalTeam(GetTeamNumber()) ); + + if ( !pTeam ) + return; + + char buf[16]; + + for( int i=0;iCountPlayersOfThisClass( i ); + + if ( !m_pClassNumLabel[i] || !m_pClassFullLabel[i] ) + continue; + + if ( pTeam->IsClassOnTeam( i ) ) + { + // FIXME - store pointers to these cvars + const CDODPlayerClassInfo &pClassInfo = pTeam->GetPlayerClassInfo( i ); + ConVar *pLimitCvar = ( ConVar * )cvar->FindVar( pClassInfo.m_szLimitCvar ); + + if ( pLimitCvar ) + iClassLimit[i] = MIN( 32, pLimitCvar->GetInt() ); + } + + if ( iClassLimit[i] < 0 || iClassCount[i] < iClassLimit[i] ) + m_pClassFullLabel[i]->SetVisible( false ); + else + m_pClassFullLabel[i]->SetVisible( true ); + + if ( iClassLimit[i] > -1 ) + { + // draw "3 / 4" + Q_snprintf( buf, sizeof(buf), "%d / %d", iClassCount[i], iClassLimit[i] ); + } + else + { + // just "3" + Q_snprintf( buf, sizeof(buf), "x %d", iClassCount[i] ); + } + + m_pClassNumLabel[i]->SetText( buf ); + } +} + +void CDODClassMenu::SetVisible( bool state ) +{ + BaseClass::SetVisible( state ); +} + +void CDODClassMenu::OnSuicideOptionChanged( vgui::Panel *Panel ) +{ + hud_classautokill.SetValue( m_pSuicideOption->IsSelected() ); +} + +#ifdef REFRESH_CLASSMENU_TOOL + + void CDODClassMenu::OnRefreshClassMenu( void ) + { + for( int i = 0; i< GetChildCount(); i++ ) + { + CImageMouseOverButton *button = + dynamic_cast *>(GetChild(i)); + + if ( button ) + { + button->RefreshClassPage(); + } + } + } + +#endif diff --git a/game/client/dod/VGUI/dodclassmenu.h b/game/client/dod/VGUI/dodclassmenu.h new file mode 100644 index 00000000..ba253479 --- /dev/null +++ b/game/client/dod/VGUI/dodclassmenu.h @@ -0,0 +1,129 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DODCLASSMENU_H +#define DODCLASSMENU_H +#ifdef _WIN32 +#pragma once +#endif + +#include +#include +#include +#include +#include "cbase.h" +#include "dod_gamerules.h" +#include "dodmenubackground.h" +#include "dodbutton.h" +#include "imagemouseoverbutton.h" +#include "IconPanel.h" +#include + +using namespace vgui; + +#define NUM_CLASSES 6 + +class CDODClassMenu : public CClassMenu +{ +private: + DECLARE_CLASS_SIMPLE( CDODClassMenu, CClassMenu ); + +public: + CDODClassMenu(IViewPort *pViewPort); + + virtual void Update( void ); + virtual Panel *CreateControlByName( const char *controlName ); + virtual void OnTick( void ); + virtual void PaintBackground( void ); + virtual void OnKeyCodePressed(KeyCode code); + virtual void SetVisible( bool state ); + + MESSAGE_FUNC_CHARPTR( OnShowPage, "ShowPage", page ); + + virtual void ShowPanel(bool bShow); + + void UpdateNumClassLabel( void ); + + virtual int GetTeamNumber( void ) = 0; + +#ifdef REFRESH_CLASSMENU_TOOL + MESSAGE_FUNC( OnRefreshClassMenu, "refresh_classes" ); +#endif + + MESSAGE_FUNC_PTR( OnSuicideOptionChanged, "CheckButtonChecked", panel ); + +private: + CDODClassInfoPanel *m_pClassInfoPanel; + CDODMenuBackground *m_pBackground; + CheckButton *m_pSuicideOption; + + CImageMouseOverButton *m_pInitialButton; + int m_iActivePlayerClass; + int m_iLastPlayerClassCount; + int m_iLastClassLimit; + + ButtonCode_t m_iClassMenuKey; + + vgui::Label *m_pClassNumLabel[NUM_CLASSES]; + vgui::Label *m_pClassFullLabel[NUM_CLASSES]; +}; + +//----------------------------------------------------------------------------- +// Purpose: Draws the U.S. class menu +//----------------------------------------------------------------------------- + +class CDODClassMenu_Allies : public CDODClassMenu +{ +private: + DECLARE_CLASS_SIMPLE( CDODClassMenu_Allies, CDODClassMenu ); + +public: + CDODClassMenu_Allies(IViewPort *pViewPort) : BaseClass(pViewPort) + { + LoadControlSettings( "Resource/UI/ClassMenu_Allies.res" ); + } + + virtual const char *GetName( void ) + { + return PANEL_CLASS_ALLIES; + } + + virtual int GetTeamNumber( void ) + { + return TEAM_ALLIES; + } + +}; + + +//----------------------------------------------------------------------------- +// Purpose: Draws the Wermacht class menu +//----------------------------------------------------------------------------- + +class CDODClassMenu_Axis : public CDODClassMenu +{ +private: + DECLARE_CLASS_SIMPLE( CDODClassMenu_Axis, CDODClassMenu ); + +public: + CDODClassMenu_Axis(IViewPort *pViewPort) : BaseClass(pViewPort) + { + LoadControlSettings( "Resource/UI/ClassMenu_Axis.res" ); + } + + virtual const char *GetName( void ) + { + return PANEL_CLASS_AXIS; + } + + virtual int GetTeamNumber( void ) + { + return TEAM_AXIS; + } +}; + +#endif // DODCLASSMENU_H diff --git a/game/client/dod/VGUI/dodclientscoreboard.cpp b/game/client/dod/VGUI/dodclientscoreboard.cpp new file mode 100644 index 00000000..d26351d1 --- /dev/null +++ b/game/client/dod/VGUI/dodclientscoreboard.cpp @@ -0,0 +1,621 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "hud.h" +#include "dodclientscoreboard.h" +#include "c_team.h" +#include "c_dod_team.h" +#include "c_dod_playerresource.h" +#include "c_dod_player.h" +#include "dod_gamerules.h" +#include "backgroundpanel.h" + +#include + +#include +#include +#include +#include +#include +#include + +#include "voice_status.h" + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CDODClientScoreBoardDialog::CDODClientScoreBoardDialog( IViewPort *pViewPort ):CClientScoreBoardDialog( pViewPort ) +{ + m_pPlayerListAllies = new SectionedListPanel( this, "PlayerListAllies" ); + m_pPlayerListAxis = new SectionedListPanel( this, "PlayerListAxis" ); + + m_iImageDead = 0; + m_iImageDominated = 0; + m_iImageNemesis = 0; + + m_pAllies_PlayerCount = new Label( this, "Allies_PlayerCount", "" ); + m_pAllies_Score = new Label( this, "Allies_Score", "" ); + m_pAllies_Kills = new Label( this, "Allies_Kills", "" ); + m_pAllies_Deaths = new Label( this, "Allies_Deaths", "" ); + m_pAllies_Ping = new Label( this, "Allies_Ping", "" ); + + m_pAxis_PlayerCount = new Label( this, "Axis_PlayerCount", "" ); + m_pAxis_Score = new Label( this, "Axis_Score", "" ); + m_pAxis_Kills = new Label( this, "Axis_Kills", "" ); + m_pAxis_Deaths = new Label( this, "Axis_Deaths", "" ); + m_pAxis_Ping = new Label( this, "Axis_Ping", "" ); + + ListenForGameEvent( "server_spawn" ); + SetDialogVariable( "server", "" ); + SetVisible( false ); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +CDODClientScoreBoardDialog::~CDODClientScoreBoardDialog() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Paint background for rounded corners +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::PaintBackground() +{ + int wide, tall; + GetSize( wide, tall ); + + DrawRoundedBackground( m_bgColor, wide, tall ); +} + +//----------------------------------------------------------------------------- +// Purpose: Paint border for rounded corners +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::PaintBorder() +{ + int wide, tall; + GetSize( wide, tall ); + + DrawRoundedBorder( m_borderColor, wide, tall ); +} + +//----------------------------------------------------------------------------- +// Purpose: Apply scheme settings +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::ApplySchemeSettings( vgui::IScheme *pScheme ) +{ + BaseClass::ApplySchemeSettings( pScheme ); + + LoadControlSettings( "Resource/UI/scoreboard.res" ); + + m_bgColor = GetSchemeColor( "SectionedListPanel.BgColor", GetBgColor(), pScheme ); + m_borderColor = pScheme->GetColor( "Yellow", Color( 251, 206, 60, 255 ) ); + + SetBgColor( Color( 0, 0, 0, 0 ) ); + SetBorder( pScheme->GetBorder( "BaseBorder" ) ); + + if ( m_pImageList ) + { + m_iImageDead = m_pImageList->AddImage( scheme()->GetImage( "../hud/leaderboard_dead", true ) ); + m_iImageDominated = m_pImageList->AddImage( scheme()->GetImage( "../hud/leaderboard_dominated", true ) ); + m_iImageNemesis = m_pImageList->AddImage( scheme()->GetImage( "../hud/leaderboard_nemesis", true ) ); + + // resize the images to our resolution + for (int i = 1; i < m_pImageList->GetImageCount(); i++ ) + { + int wide = 13, tall = 13; + m_pImageList->GetImage(i)->SetSize(scheme()->GetProportionalScaledValueEx( GetScheme(), wide ), scheme()->GetProportionalScaledValueEx( GetScheme(),tall ) ); + } + } + + if ( m_pPlayerListAllies ) + { + m_pPlayerListAllies->SetImageList( m_pImageList, false ); + m_pPlayerListAllies->SetBgColor( Color( 0, 0, 0, 0 ) ); + m_pPlayerListAllies->SetBorder( NULL ); + m_pPlayerListAllies->SetVisible( true ); + } + + if ( m_pPlayerListAxis ) + { + m_pPlayerListAxis->SetImageList( m_pImageList, false ); + m_pPlayerListAxis->SetBgColor( Color( 0, 0, 0, 0 ) ); + m_pPlayerListAxis->SetBorder( NULL ); + m_pPlayerListAxis->SetVisible( true ); + } + + // turn off the default player list since we have our own + if ( m_pPlayerList ) + { + m_pPlayerList->SetVisible( false ); + } + + if ( m_pAllies_PlayerCount && m_pAllies_Score && m_pAllies_Kills && m_pAllies_Deaths && m_pAllies_Ping ) + { + m_pAllies_PlayerCount->SetFgColor( COLOR_DOD_GREEN ); + m_pAllies_Score->SetFgColor( COLOR_DOD_GREEN ); + m_pAllies_Kills->SetFgColor( COLOR_DOD_GREEN ); + m_pAllies_Deaths->SetFgColor( COLOR_DOD_GREEN ); + m_pAllies_Ping->SetFgColor( COLOR_DOD_GREEN ); + } + + if ( m_pAxis_PlayerCount && m_pAxis_Score && m_pAxis_Kills && m_pAxis_Deaths && m_pAxis_Ping ) + { + m_pAxis_PlayerCount->SetFgColor( COLOR_DOD_RED ); + m_pAxis_Score->SetFgColor( COLOR_DOD_RED ); + m_pAxis_Kills->SetFgColor( COLOR_DOD_RED ); + m_pAxis_Deaths->SetFgColor( COLOR_DOD_RED ); + m_pAxis_Ping->SetFgColor( COLOR_DOD_RED ); + } + + SetVisible( false ); + Reset(); +} + +//----------------------------------------------------------------------------- +// Purpose: Resets the scoreboard panel +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::Reset() +{ + InitPlayerList( m_pPlayerListAllies, TEAM_ALLIES ); + InitPlayerList( m_pPlayerListAxis, TEAM_AXIS ); +} + +//----------------------------------------------------------------------------- +// Purpose: Sorts players +//----------------------------------------------------------------------------- +bool CDODClientScoreBoardDialog::DODPlayerSortFunc( vgui::SectionedListPanel *list, int itemID1, int itemID2 ) +{ + KeyValues *it1 = list->GetItemData( itemID1 ); + KeyValues *it2 = list->GetItemData( itemID2 ); + Assert( it1 && it2 ); + + // first compare score + int v1 = it1->GetInt( "score" ); + int v2 = it2->GetInt( "score" ); + if ( v1 > v2 ) + return true; + else if ( v1 < v2 ) + return false; + + // then compare frags + v1 = it1->GetInt( "frags" ); + v2 = it2->GetInt( "frags" ); + if ( v1 > v2 ) + return true; + else if ( v1 < v2 ) + return false; + + // next compare deaths + v1 = it1->GetInt( "deaths" ); + v2 = it2->GetInt( "deaths" ); + if ( v1 > v2 ) + return false; + else if ( v1 < v2 ) + return true; + + // if score and deaths are the same, use player index to get deterministic sort + int iPlayerIndex1 = it1->GetInt( "playerIndex" ); + int iPlayerIndex2 = it2->GetInt( "playerIndex" ); + return ( iPlayerIndex1 > iPlayerIndex2 ); +} + +//----------------------------------------------------------------------------- +// Purpose: Inits the player list in a list panel +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::InitPlayerList( SectionedListPanel *pPlayerList, int teamNumber ) +{ + pPlayerList->SetVerticalScrollbar( false ); + pPlayerList->RemoveAll(); + pPlayerList->RemoveAllSections(); + pPlayerList->AddSection( 0, "Players", DODPlayerSortFunc ); + pPlayerList->SetSectionAlwaysVisible( 0, true ); + pPlayerList->SetSectionFgColor( 0, Color( 255, 255, 255, 255 ) ); + pPlayerList->SetBgColor( Color( 0, 0, 0, 0 ) ); + pPlayerList->SetBorder( NULL ); + + // set the section to have the team color + if ( teamNumber && GameResources() ) + { + pPlayerList->SetSectionFgColor( 0, GameResources()->GetTeamColor( teamNumber ) ); + } + + // Avatars are always displayed at 32x32 regardless of resolution + pPlayerList->AddColumnToSection( 0, "avatar", "", SectionedListPanel::COLUMN_IMAGE | SectionedListPanel::COLUMN_CENTER, m_iProportionalAvatarWidth ); + pPlayerList->AddColumnToSection( 0, "name", "", 0, m_iNameWidth ); + pPlayerList->AddColumnToSection( 0, "status", "", SectionedListPanel::COLUMN_IMAGE | SectionedListPanel::COLUMN_CENTER, m_iStatusWidth ); + pPlayerList->AddColumnToSection( 0, "class", "", 0, m_iClassWidth ); + pPlayerList->AddColumnToSection( 0, "score", "", SectionedListPanel::COLUMN_RIGHT, m_iScoreWidth ); + pPlayerList->AddColumnToSection( 0, "frags", "", SectionedListPanel::COLUMN_RIGHT, m_iFragsWidth ); + pPlayerList->AddColumnToSection( 0, "deaths", "", SectionedListPanel::COLUMN_RIGHT, m_iDeathWidth ); + pPlayerList->AddColumnToSection( 0, "ping", "", SectionedListPanel::COLUMN_RIGHT, m_iPingWidth ); +} + +//----------------------------------------------------------------------------- +// Purpose: Updates the dialog +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::Update() +{ + UpdateTeamInfo(); + UpdatePlayerList(); + UpdateSpectatorList(); + MoveToCenterOfScreen(); + + // update every second + m_fNextUpdateTime = gpGlobals->curtime + 1.0f; +} + +//----------------------------------------------------------------------------- +// Purpose: Updates information about teams +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::UpdateTeamInfo() +{ + // update the team sections in the scoreboard + for ( int teamIndex = TEAM_ALLIES; teamIndex <= TEAM_AXIS; teamIndex++ ) + { + wchar_t *teamName = NULL;; + C_DODTeam *team = dynamic_cast( GetGlobalTeam(teamIndex) ); + if ( team ) + { + // choose dialog variables to set depending on team + const char *pDialogVarTeamScore = NULL; + const char *pDialogVarTeamPlayerCount = NULL; + const char *pDialogVarTeamPing = NULL; + const char *pDialogVarTeamDeaths = NULL; + const char *pDialogVarTeamFrags = NULL; + switch ( teamIndex ) + { + case TEAM_ALLIES: + teamName = g_pVGuiLocalize->Find( "#Teamname_Allies" ); + pDialogVarTeamScore = "allies_teamscore"; + pDialogVarTeamPlayerCount = "allies_teamplayercount"; + pDialogVarTeamPing = "allies_teamping"; + pDialogVarTeamDeaths = "allies_teamdeaths"; + pDialogVarTeamFrags = "allies_teamfrags"; + break; + case TEAM_AXIS: + teamName = g_pVGuiLocalize->Find( "#Teamname_Axis" ); + pDialogVarTeamScore = "axis_teamscore"; + pDialogVarTeamPlayerCount = "axis_teamplayercount"; + pDialogVarTeamPing = "axis_teamping"; + pDialogVarTeamDeaths = "axis_teamdeaths"; + pDialogVarTeamFrags = "axis_teamfrags"; + break; + default: + Assert( false ); + break; + } + + // update team name + wchar_t name[64]; + wchar_t string1[1024]; + wchar_t wNumPlayers[6]; + _snwprintf( wNumPlayers, ARRAYSIZE( wNumPlayers ), L"%i", team->Get_Number_Players() ); + if ( !teamName && team ) + { + g_pVGuiLocalize->ConvertANSIToUnicode( team->Get_Name(), name, sizeof( name ) ); + teamName = name; + } + if ( team->Get_Number_Players() == 1 ) + { + g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#scoreboard_Player" ), 2, teamName, wNumPlayers ); + } + else + { + g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#scoreboard_Players" ), 2, teamName, wNumPlayers ); + } + + // set # of players for team in dialog + SetDialogVariable( pDialogVarTeamPlayerCount, string1 ); + + // Rounds won ( + tick ) + wchar_t wTeamScore[128]; + wchar_t wRoundsWon[8]; + wchar_t wTickScore[8]; + _snwprintf( wRoundsWon, ARRAYSIZE( wRoundsWon ), L"%i", team->GetRoundsWon() ); + _snwprintf( wTickScore, ARRAYSIZE( wTickScore ), L"%i", team->Get_Score() ); + g_pVGuiLocalize->ConstructString( wTeamScore, sizeof(wTeamScore), g_pVGuiLocalize->Find( "#scoreboard_teamscore" ), 2, wRoundsWon, wTickScore ); + + // set team score in dialog + SetDialogVariable( pDialogVarTeamScore, wTeamScore ); + + int kills = 0; + int deaths = 0; + int pingsum = 0; + int numcounted = 0; + int ping; + + for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ ) + { + if( g_PR->IsConnected( playerIndex ) && g_PR->GetTeam( playerIndex ) == teamIndex ) + { + ping = g_PR->GetPing( playerIndex ); + kills += g_PR->GetPlayerScore( playerIndex ); + deaths += g_PR->GetDeaths( playerIndex ); + + if ( ping >= 1 ) + { + pingsum += ping; + numcounted++; + } + } + } + + if ( numcounted > 0 ) + { + int ping = (int)( (float)pingsum / (float)numcounted ); + SetDialogVariable( pDialogVarTeamPing, ping ); + } + else + { + SetDialogVariable( pDialogVarTeamPing, "" ); + } + + SetDialogVariable( pDialogVarTeamFrags, kills ); + SetDialogVariable( pDialogVarTeamDeaths, deaths ); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Updates the player list +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::UpdatePlayerList() +{ + m_pPlayerListAllies->RemoveAll(); + m_pPlayerListAxis->RemoveAll(); + + C_DOD_PlayerResource *dod_PR = dynamic_cast( g_PR ); + if ( !dod_PR ) + return; + + C_DODPlayer *pLocalPlayer = C_DODPlayer::GetLocalDODPlayer(); + if ( !pLocalPlayer ) + return; + + int iLocalPlayerIndex = GetLocalPlayerIndex(); + + for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ ) + { + if( g_PR->IsConnected( playerIndex ) ) + { + SectionedListPanel *pPlayerList = NULL; + switch ( g_PR->GetTeam( playerIndex ) ) + { + case TEAM_ALLIES: + pPlayerList = m_pPlayerListAllies; + break; + case TEAM_AXIS: + pPlayerList = m_pPlayerListAxis; + break; + } + + if ( pPlayerList == NULL ) + { + continue; + } + + KeyValues *pKeyValues = new KeyValues( "data" ); + GetPlayerScoreInfo( playerIndex, pKeyValues ); + + if ( pLocalPlayer->m_Shared.IsPlayerDominatingMe( playerIndex ) ) + { + // if local player is dominated by this player, show a nemesis icon + pKeyValues->SetString( "class", "#Scoreboard_Nemesis" ); + pKeyValues->SetInt( "status", m_iImageNemesis ); + } + else if ( pLocalPlayer->m_Shared.IsPlayerDominated( playerIndex) ) + { + // if this player is dominated by the local player, show the domination icon + pKeyValues->SetString( "class", "#Scoreboard_Dominated" ); + pKeyValues->SetInt( "status", m_iImageDominated ); + } + + int itemID = pPlayerList->AddItem( 0, pKeyValues ); + Color clr = g_PR->GetTeamColor( g_PR->GetTeam( playerIndex ) ); + pPlayerList->SetItemFgColor( itemID, clr ); + + if ( playerIndex == iLocalPlayerIndex ) + { + pPlayerList->SetSelectedItem( itemID ); + } + + pKeyValues->deleteThis(); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Updates the spectator list +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::UpdateSpectatorList() +{ + char szSpectatorList[512] = "" ; + int nSpectators = 0; + for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ ) + { + if ( ShouldShowAsSpectator( playerIndex ) ) + { + if ( nSpectators > 0 ) + { + Q_strncat( szSpectatorList, ", ", ARRAYSIZE( szSpectatorList ) ); + } + + Q_strncat( szSpectatorList, g_PR->GetPlayerName( playerIndex ), ARRAYSIZE( szSpectatorList ) ); + nSpectators++; + } + } + + wchar_t wzSpectators[512] = L""; + if ( nSpectators > 0 ) + { + const char *pchFormat = ( 1 == nSpectators ? "#ScoreBoard_Spectator" : "#ScoreBoard_Spectators" ); + + wchar_t wzSpectatorCount[16]; + wchar_t wzSpectatorList[1024]; + _snwprintf( wzSpectatorCount, ARRAYSIZE( wzSpectatorCount ), L"%i", nSpectators ); + g_pVGuiLocalize->ConvertANSIToUnicode( szSpectatorList, wzSpectatorList, sizeof( wzSpectatorList ) ); + g_pVGuiLocalize->ConstructString( wzSpectators, sizeof(wzSpectators), g_pVGuiLocalize->Find( pchFormat), 2, wzSpectatorCount, wzSpectatorList ); + } + + SetDialogVariable( "spectators", wzSpectators ); +} + +//----------------------------------------------------------------------------- +// Purpose: Returns whether the specified player index is a spectator +//----------------------------------------------------------------------------- +bool CDODClientScoreBoardDialog::ShouldShowAsSpectator( int iPlayerIndex ) +{ + C_DOD_PlayerResource *dod_PR = dynamic_cast( g_PR ); + if ( !dod_PR ) + return false; + + // see if player is connected + if ( dod_PR->IsConnected( iPlayerIndex ) ) + { + // either spectator or unassigned team should show in spectator list + int iTeam = dod_PR->GetTeam( iPlayerIndex ); + if ( TEAM_SPECTATOR == iTeam || TEAM_UNASSIGNED == iTeam ) + return true; + } + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: Event handler +//----------------------------------------------------------------------------- +void CDODClientScoreBoardDialog::FireGameEvent( IGameEvent *event ) +{ + const char *type = event->GetName(); + + if ( 0 == Q_strcmp( type, "server_spawn" ) ) + { + // set server name in scoreboard + const char *hostname = event->GetString( "hostname" ); + wchar_t wzHostName[256]; + wchar_t wzServerLabel[256]; + g_pVGuiLocalize->ConvertANSIToUnicode( hostname, wzHostName, sizeof( wzHostName ) ); + g_pVGuiLocalize->ConstructString( wzServerLabel, sizeof(wzServerLabel), g_pVGuiLocalize->Find( "#Scoreboard_Server" ), 1, wzHostName ); + SetDialogVariable( "server", wzServerLabel ); + } + + if( IsVisible() ) + { + Update(); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Adds a new row to the scoreboard, from the playerinfo structure +//----------------------------------------------------------------------------- +bool CDODClientScoreBoardDialog::GetPlayerScoreInfo( int playerIndex, KeyValues *kv ) +{ + C_DOD_PlayerResource *dod_PR = dynamic_cast( g_PR ); + if ( !dod_PR ) + return true; + + // Clean up the player name + const char *oldName = g_PR->GetPlayerName( playerIndex ); + int bufsize = strlen( oldName ) * 2 + 1; + char *newName = (char *)_alloca( bufsize ); + UTIL_MakeSafeName( oldName, newName, bufsize ); + kv->SetString( "name", newName ); + + kv->SetInt( "playerIndex", playerIndex ); + kv->SetInt( "score", dod_PR->GetScore( playerIndex ) ); + kv->SetInt( "frags", g_PR->GetPlayerScore( playerIndex ) ); + kv->SetInt( "deaths", g_PR->GetDeaths( playerIndex ) ); + kv->SetString( "class", "" ); + + UpdatePlayerAvatar( playerIndex, kv ); + + if ( g_PR->GetPing( playerIndex ) < 1 ) + { + if ( g_PR->IsFakePlayer( playerIndex ) ) + { + kv->SetString( "ping", "BOT" ); + } + else + { + kv->SetString( "ping", "" ); + } + } + else + { + kv->SetInt( "ping", g_PR->GetPing( playerIndex ) ); + } + + C_DODPlayer *pLocalPlayer = C_DODPlayer::GetLocalDODPlayer(); + if ( !pLocalPlayer ) + return true; + + int team = g_PR->GetTeam( playerIndex ); + int localteam = pLocalPlayer->GetTeamNumber(); + + // If we are on a team that shows class/status, and the local player is allowed to see this information + if( ( localteam == TEAM_SPECTATOR || localteam == TEAM_UNASSIGNED || team == localteam ) ) + { + // class name + if( g_PR->IsConnected( playerIndex ) ) + { + C_DODTeam *pTeam = dynamic_cast( GetGlobalTeam( team ) ); + + Assert( pTeam ); + + int cls = dod_PR->GetPlayerClass( playerIndex ); + + char szClassName[64]; + szClassName[0] = '\0'; + + if( cls != PLAYERCLASS_UNDEFINED ) + { + const CDODPlayerClassInfo &info = pTeam->GetPlayerClassInfo( cls ); + + g_pVGuiLocalize->ConvertUnicodeToANSI( g_pVGuiLocalize->Find( info.m_szPrintName ), szClassName, sizeof(szClassName) ); + } + + kv->SetString( "class", szClassName ); + } + else + { + Assert(0); + } + + // status + // display whether player is alive or dead (all players see this for all other players on both teams) + kv->SetInt( "status", g_PR->IsAlive( playerIndex ) ? 0 : m_iImageDead ); + } + + if ( g_PR->IsHLTV( playerIndex ) ) + { + // show #spectators in class field, it's transmitted as player's score + char numspecs[32]; + Q_snprintf( numspecs, sizeof( numspecs ), "%i Spectators", m_HLTVSpectators ); + kv->SetString( "class", numspecs ); + } + + return true; +} + +void CDODClientScoreBoardDialog::ShowPanel( bool bShow ) +{ + BaseClass::ShowPanel( bShow ); + + int iRenderGroup = gHUD.LookupRenderGroupIndexByName( "global" ); + + if ( bShow ) + { + gHUD.LockRenderGroup( iRenderGroup ); + } + else + { + gHUD.UnlockRenderGroup( iRenderGroup ); + } +} \ No newline at end of file diff --git a/game/client/dod/VGUI/dodclientscoreboard.h b/game/client/dod/VGUI/dodclientscoreboard.h new file mode 100644 index 00000000..e70c6ec2 --- /dev/null +++ b/game/client/dod/VGUI/dodclientscoreboard.h @@ -0,0 +1,79 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DODCLIENTSCOREBOARDDIALOG_H +#define DODCLIENTSCOREBOARDDIALOG_H +#ifdef _WIN32 +#pragma once +#endif + +#include +#include "dod_shareddefs.h" + +//----------------------------------------------------------------------------- +// Purpose: Game ScoreBoard +//----------------------------------------------------------------------------- +class CDODClientScoreBoardDialog : public CClientScoreBoardDialog +{ +private: + DECLARE_CLASS_SIMPLE( CDODClientScoreBoardDialog, CClientScoreBoardDialog ); + +public: + CDODClientScoreBoardDialog( IViewPort *pViewPort ); + ~CDODClientScoreBoardDialog(); + + virtual void Reset(); + virtual void Update(); + + virtual void PaintBackground(); + virtual void PaintBorder(); + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + + virtual void ShowPanel( bool bShow ); + +private: + void InitPlayerList( vgui::SectionedListPanel *pPlayerList, int teamNumber ); + void UpdateTeamInfo(); + void UpdatePlayerList(); + void UpdateSpectatorList(); + bool GetPlayerScoreInfo( int playerIndex, KeyValues *outPlayerInfo ); + + bool ShouldShowAsSpectator( int iPlayerIndex ); + void FireGameEvent( IGameEvent *event ); + + static bool DODPlayerSortFunc( vgui::SectionedListPanel *list, int itemID1, int itemID2 ); + + Color m_bgColor; + Color m_borderColor; + + int m_iImageDead; + int m_iImageDominated; + int m_iImageNemesis; + + // player lists + vgui::SectionedListPanel *m_pPlayerListAllies; + vgui::SectionedListPanel *m_pPlayerListAxis; + + CPanelAnimationVarAliasType( int, m_iStatusWidth, "status_width", "35", "proportional_int" ); + CPanelAnimationVarAliasType( int, m_iFragsWidth, "frags_width", "30", "proportional_int" ); + CPanelAnimationVarAliasType( int, m_iProportionalAvatarWidth, "avatar_width_prop", "34", "proportional_int" ); + + vgui::Label *m_pAllies_PlayerCount; + vgui::Label *m_pAllies_Score; + vgui::Label *m_pAllies_Kills; + vgui::Label *m_pAllies_Deaths; + vgui::Label *m_pAllies_Ping; + + vgui::Label *m_pAxis_PlayerCount; + vgui::Label *m_pAxis_Score; + vgui::Label *m_pAxis_Kills; + vgui::Label *m_pAxis_Deaths; + vgui::Label *m_pAxis_Ping; +}; + + +#endif // DODCLIENTSCOREBOARDDIALOG_H diff --git a/game/client/dod/VGUI/dodcornercutpanel.cpp b/game/client/dod/VGUI/dodcornercutpanel.cpp new file mode 100644 index 00000000..bc8dc684 --- /dev/null +++ b/game/client/dod/VGUI/dodcornercutpanel.cpp @@ -0,0 +1,245 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" +#include +#include +#include +#include +#include "dodcornercutpanel.h" + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CDoDCutEditablePanel::CDoDCutEditablePanel( vgui::Panel *parent, const char *name ) : vgui::EditablePanel( parent, name ) +{ + m_nCornerToCut = DOD_CORNERCUT_PANEL_BOTTOMRIGHT; + m_nCornerCutSize = 1; + + memset( m_szBackgroundTexture, 0, sizeof( m_szBackgroundTexture ) ); + memset( m_szBackgroudColor, 0, sizeof( m_szBackgroudColor ) ); + memset( m_szBorderColor, 0, sizeof( m_szBorderColor ) ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDCutEditablePanel::SetBorder( vgui::IBorder *border ) +{ + BaseClass::SetBorder( border ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDCutEditablePanel::ApplySettings( KeyValues *inResourceData ) +{ + BaseClass::ApplySettings( inResourceData ); + + // check to see if we have a new name assigned + Q_strncpy( m_szBackgroundTexture, inResourceData->GetString( "BackgroundTexture", "vgui/white" ), sizeof( m_szBackgroundTexture ) ); + Q_strncpy( m_szBackgroudColor, inResourceData->GetString( "BackgroundColor", "HudPanelForeground" ), sizeof( m_szBackgroudColor ) ); + Q_strncpy( m_szBorderColor, inResourceData->GetString( "BackgroundBorder", "HudPanelBorder" ), sizeof( m_szBorderColor ) ); + + m_iBackgroundTexture = vgui::surface()->DrawGetTextureId( m_szBackgroundTexture ); + if ( m_iBackgroundTexture == -1 ) + { + m_iBackgroundTexture = vgui::surface()->CreateNewTextureID(); + } + + vgui::surface()->DrawSetTextureFile( m_iBackgroundTexture, m_szBackgroundTexture, true, true ); + + m_nCornerCutSize = inResourceData->GetInt( "CornerCutSize", 1 ); + + // scale the cut size to our screen co-ords + if ( IsProportional() ) + { + m_nCornerCutSize = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), m_nCornerCutSize ); + } + + const char *pszCorner = inResourceData->GetString( "CornerToCut", "" ); + if ( pszCorner ) + { + if ( !Q_strcmp( pszCorner, "bottom_right" ) ) + { + m_nCornerToCut = DOD_CORNERCUT_PANEL_BOTTOMRIGHT; + } + else if ( !Q_strcmp( pszCorner, "bottom_left" ) ) + { + m_nCornerToCut = DOD_CORNERCUT_PANEL_BOTTOMLEFT; + } + else if ( !Q_strcmp( pszCorner, "top_right" ) ) + { + m_nCornerToCut = DOD_CORNERCUT_PANEL_TOPRIGHT; + + } + else if ( !Q_strcmp( pszCorner, "top_left" ) ) + { + m_nCornerToCut = DOD_CORNERCUT_PANEL_TOPLEFT; + } + } + + InvalidateLayout( false, true ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDCutEditablePanel::GetSettings( KeyValues *outResourceData ) +{ + BaseClass::GetSettings( outResourceData ); + + outResourceData->SetString( "BackgroundTexture", m_szBackgroundTexture); + outResourceData->SetString( "BackgroundColor", m_szBackgroudColor); + outResourceData->SetString( "BackgroundBorder", m_szBorderColor); + outResourceData->SetFloat( "CornerCutSize", m_nCornerCutSize ); + + const char *pszCorner = NULL; + switch( m_nCornerToCut ) + { + case DOD_CORNERCUT_PANEL_TOPLEFT: + pszCorner = "top_left"; + break; + case DOD_CORNERCUT_PANEL_TOPRIGHT: + pszCorner = "top_right"; + break; + case DOD_CORNERCUT_PANEL_BOTTOMLEFT: + pszCorner = "bottom_left"; + break; + case DOD_CORNERCUT_PANEL_BOTTOMRIGHT: + default: + pszCorner = "bottom_right"; + break; + } + outResourceData->SetString( "CornerToCut", pszCorner ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDCutEditablePanel::ApplySchemeSettings( vgui::IScheme *pScheme ) +{ + BaseClass::ApplySchemeSettings( pScheme ); + + SetBorder( NULL ); + + m_clrBackground = pScheme->GetColor( m_szBackgroudColor, GetFgColor() ); + m_clrBorder = pScheme->GetColor( m_szBorderColor, GetBgColor() ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDCutEditablePanel::PaintBackground() +{ + vgui::Vertex_t lineverts[5]; + vgui::Vertex_t verts[5]; + + int nwide, ntall; + GetSize( nwide, ntall ); + + int wide = nwide - 1; // -1 because we can't draw all the way out to the width of our panel (it gets clipped), we can only draw to width - 1 + int tall = ntall - 1; // (same as above) + + switch ( m_nCornerToCut ) + { + case DOD_CORNERCUT_PANEL_TOPLEFT: + verts[0].Init( Vector2D( m_nCornerCutSize, 0 ) ); + verts[1].Init( Vector2D( wide, 0 ) ); + verts[2].Init( Vector2D( wide, tall ) ); + verts[3].Init( Vector2D( 0, tall ) ); + verts[4].Init( Vector2D( 0, m_nCornerCutSize ) ); + + lineverts[0].Init( Vector2D( m_nCornerCutSize-1, 0 ) ); + lineverts[1].Init( Vector2D( wide, 0 ) ); + lineverts[2].Init( Vector2D( wide, tall ) ); + lineverts[3].Init( Vector2D( 0, tall ) ); + lineverts[4].Init( Vector2D( 0, m_nCornerCutSize-1 ) ); + + break; + + case DOD_CORNERCUT_PANEL_TOPRIGHT: + verts[0].Init( Vector2D( 0, 0 ) ); + verts[1].Init( Vector2D( wide - m_nCornerCutSize, 0 ) ); + verts[2].Init( Vector2D( wide, m_nCornerCutSize ) ); + verts[3].Init( Vector2D( wide, tall ) ); + verts[4].Init( Vector2D( 0, tall ) ); + + lineverts[0].Init( Vector2D( 0, 0 ) ); + lineverts[1].Init( Vector2D( wide - m_nCornerCutSize, 0 ) ); + lineverts[2].Init( Vector2D( wide, m_nCornerCutSize ) ); + lineverts[3].Init( Vector2D( wide, tall ) ); + lineverts[4].Init( Vector2D( 0, tall ) ); + + break; + + case DOD_CORNERCUT_PANEL_BOTTOMLEFT: + verts[0].Init( Vector2D( 0, 0 ) ); + verts[1].Init( Vector2D( wide, 0 ) ); + verts[2].Init( Vector2D( wide, tall ) ); + verts[3].Init( Vector2D( m_nCornerCutSize, tall ) ); + verts[4].Init( Vector2D( 0, tall - m_nCornerCutSize ) ); + + lineverts[0].Init( Vector2D( 0, 0 ) ); + lineverts[1].Init( Vector2D( wide, 0 ) ); + lineverts[2].Init( Vector2D( wide, tall ) ); + lineverts[3].Init( Vector2D( m_nCornerCutSize, tall ) ); + lineverts[4].Init( Vector2D( 0, tall - m_nCornerCutSize ) ); + + break; + + case DOD_CORNERCUT_PANEL_BOTTOMRIGHT: + default: + verts[0].Init( Vector2D( 0, 0 ) ); + verts[1].Init( Vector2D( wide, 0 ) ); + verts[2].Init( Vector2D( wide, tall - m_nCornerCutSize + 1 ) ); + verts[3].Init( Vector2D( wide - m_nCornerCutSize + 1, tall ) ); + verts[4].Init( Vector2D( 0, tall ) ); + + lineverts[0].Init( Vector2D( 0, 0 ) ); + lineverts[1].Init( Vector2D( wide, 0 ) ); + lineverts[2].Init( Vector2D( wide, tall - m_nCornerCutSize ) ); + lineverts[3].Init( Vector2D( wide - m_nCornerCutSize, tall ) ); + lineverts[4].Init( Vector2D( 0, tall ) ); + + break; + } + + vgui::surface()->DrawSetTexture( m_iBackgroundTexture ); + vgui::surface()->DrawSetColor( m_clrBackground ); + vgui::surface()->DrawTexturedPolygon( 5, verts ); + + vgui::surface()->DrawSetColor( m_clrBorder ); + vgui::surface()->DrawTexturedPolyLine( lineverts, 5 ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDCutEditablePanel::SetBackGroundColor( const char *pszNewColor ) +{ + if ( !pszNewColor ) + { + return; + } + + Q_strncpy( m_szBackgroudColor, pszNewColor, sizeof( m_szBackgroudColor ) ); + InvalidateLayout( false, true ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDCutEditablePanel::SetBorderColor( const char *pszNewColor ) +{ + if ( !pszNewColor ) + { + return; + } + + Q_strncpy( m_szBorderColor, pszNewColor, sizeof( m_szBorderColor ) ); + InvalidateLayout( false, true ); +} \ No newline at end of file diff --git a/game/client/dod/VGUI/dodcornercutpanel.h b/game/client/dod/VGUI/dodcornercutpanel.h new file mode 100644 index 00000000..8ac15a67 --- /dev/null +++ b/game/client/dod/VGUI/dodcornercutpanel.h @@ -0,0 +1,66 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DOD_CORNERCUTPANEL_H +#define DOD_CORNERCUTPANEL_H +#ifdef _WIN32 +#pragma once +#endif + +#include "cbase.h" +#include +#include + +#include "dod_shareddefs.h" + + +//----------------------------------------------------------------------------- +// Purpose: Draws the corner-cut background panels +//----------------------------------------------------------------------------- +class CDoDCutEditablePanel : public vgui::EditablePanel +{ +public: + DECLARE_CLASS_SIMPLE( CDoDCutEditablePanel, vgui::EditablePanel ); + + CDoDCutEditablePanel( vgui::Panel *parent, const char *name ); + + virtual void PaintBackground(); + + virtual void SetBorder( vgui::IBorder *border ); + + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + + virtual void SetVisible( bool state ) + { + BaseClass::SetVisible( state ); + } + + virtual void ApplySettings( KeyValues *inResourceData ); + virtual void GetSettings( KeyValues *outResourceData ); + + virtual void SetCornerToCut( int nCorner ){ m_nCornerToCut = nCorner; } + virtual void SetCornerCutSize( int nCutSize ){ m_nCornerCutSize = nCutSize; } + virtual void SetBackGroundColor( const char *pszNewColor ); + virtual void SetBorderColor( const char *pszNewColor ); + +private: + + int m_iBackgroundTexture; + + int m_nCornerToCut; + int m_nCornerCutSize; + + char m_szBackgroundTexture[128]; + char m_szBackgroudColor[128]; + char m_szBorderColor[128]; + + Color m_clrBackground; + Color m_clrBorder; +}; + +#endif // DOD_CORNERCUTPANEL_H + diff --git a/game/client/dod/VGUI/dodmenubackground.cpp b/game/client/dod/VGUI/dodmenubackground.cpp new file mode 100644 index 00000000..4851f2ed --- /dev/null +++ b/game/client/dod/VGUI/dodmenubackground.cpp @@ -0,0 +1,89 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include +#include "dodmenubackground.h" + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CDODMenuBackground::CDODMenuBackground(Panel *parent) : EditablePanel(parent, "MenuBackground") +{ + SetProportional(true); + SetVisible(true); + + SetZPos( -1 ); + + LoadControlSettings("Resource/UI/MenuBackground.res"); +} + +void CDODMenuBackground::Init( void ) +{ + m_iBackgroundTexture = vgui::surface()->CreateNewTextureID(); + vgui::surface()->DrawSetTextureFile( m_iBackgroundTexture, "vgui/white", true, false); +} + +void CDODMenuBackground::ApplySchemeSettings( IScheme *pScheme ) +{ + int top[8]; + int main[8]; + int box[8]; + int i; + for( i=0;i<8;i++ ) + { + top[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iTopDims[i]); + main[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iMainDims[i]); + box[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iBoxDims[i]); + + if ( i < 6 ) + m_LineDims[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iLineDims[i]); + } + + m_BackgroundTopVerts[0].Init( Vector2D( top[0], top[1] ) ); + m_BackgroundTopVerts[1].Init( Vector2D( top[2], top[3] ) ); + m_BackgroundTopVerts[2].Init( Vector2D( top[4], top[5] ) ); + m_BackgroundTopVerts[3].Init( Vector2D( top[6], top[7] ) ); + + m_BackgroundMainVerts[0].Init( Vector2D( main[0], main[1] ) ); + m_BackgroundMainVerts[1].Init( Vector2D( main[2], main[3] ) ); + m_BackgroundMainVerts[2].Init( Vector2D( main[4], main[5] ) ); + m_BackgroundMainVerts[3].Init( Vector2D( main[6], main[7] ) ); + + m_BoxVerts[0].Init( Vector2D( box[0], box[1] ) ); + m_BoxVerts[1].Init( Vector2D( box[2], box[3] ) ); + m_BoxVerts[2].Init( Vector2D( box[4], box[5] ) ); + m_BoxVerts[3].Init( Vector2D( box[6], box[7] ) ); + + BaseClass::ApplySchemeSettings(pScheme); +} + +//----------------------------------------------------------------------------- +// Purpose: paint the dod style background +//----------------------------------------------------------------------------- +void CDODMenuBackground::Paint(void) +{ + vgui::surface()->DrawSetColor(128,110,53,235); + vgui::surface()->DrawSetTexture( m_iBackgroundTexture ); + + //top background + vgui::surface()->DrawTexturedPolygon( 4, m_BackgroundTopVerts ); + + //main background + vgui::surface()->DrawTexturedPolygon( 4, m_BackgroundMainVerts ); + + // top white line + vgui::surface()->DrawSetColor(255,255,255,196); + vgui::surface()->DrawLine( m_LineDims[0], m_LineDims[1], m_LineDims[2], m_LineDims[3] ); + vgui::surface()->DrawLine( m_LineDims[2], m_LineDims[3], m_LineDims[4], m_LineDims[5] ); + + // top white box + vgui::surface()->DrawTexturedPolygon( 4, m_BoxVerts ); +} + diff --git a/game/client/dod/VGUI/dodmenubackground.h b/game/client/dod/VGUI/dodmenubackground.h new file mode 100644 index 00000000..a79b1458 --- /dev/null +++ b/game/client/dod/VGUI/dodmenubackground.h @@ -0,0 +1,74 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DODMENUBACKGROUND_H +#define DODMENUBACKGROUND_H +#ifdef _WIN32 +#pragma once +#endif + +#include +#include +#include "vgui_controls/BitmapImagePanel.h" + +using namespace vgui; + +static int iTopDims[8] = +{ + 41, 30, + 562, 30, + 599, 67, + 41, 67 +}; + +static int iMainDims[8] = +{ + 41, 67, + 599, 67, + 599, 465, + 41, 465 +}; + +static int iBoxDims[8] = +{ + 69, 83, + 86, 83, + 86, 89, + 69, 89 +}; + +static int iLineDims[6] = +{ + 69, 89, + 558, 89, + 568, 99 +}; + +class CDODMenuBackground : public vgui::EditablePanel +{ +private: + DECLARE_CLASS_SIMPLE( CDODMenuBackground, vgui::EditablePanel ); + +public: + CDODMenuBackground( Panel *parent); + + void Init(); + void ApplySchemeSettings( IScheme *pScheme ); + + virtual void Paint( void ); + +private: + vgui::Vertex_t m_BackgroundTopVerts[4]; + vgui::Vertex_t m_BackgroundMainVerts[4]; + vgui::Vertex_t m_BoxVerts[4]; + + int m_LineDims[6]; + + int m_iBackgroundTexture; +}; + +#endif //DODMENUBACKGROUND_H \ No newline at end of file diff --git a/game/client/dod/VGUI/dodmouseoverpanelbutton.h b/game/client/dod/VGUI/dodmouseoverpanelbutton.h new file mode 100644 index 00000000..45218231 --- /dev/null +++ b/game/client/dod/VGUI/dodmouseoverpanelbutton.h @@ -0,0 +1,72 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DOD_MOUSE_OVER_BUTTON_H +#define DOD_MOUSE_OVER_BUTTON_H + +#include "dodbutton.h" +#include "mouseoverpanelbutton.h" + +template +class CDODMouseOverButton : public MouseOverButton, public CDODButtonShape +{ +private: + //DECLARE_CLASS_SIMPLE( CDODMouseOverButton, MouseOverButton ); + +public: + CDODMouseOverButton(vgui::Panel *parent, const char *panelName, T *templatePanel ) : + MouseOverButton( parent, panelName, templatePanel ) + { + } + +protected: + virtual void PaintBackground(); + virtual void PaintBorder(); + +public: + virtual void ShowPage( void ); + virtual void HidePage( void ); +}; + +//=============================================== +// CDODMouseOverButton - shaped mouseover button +//=============================================== +template +void CDODMouseOverButton::PaintBackground() +{ + int wide, tall; + this->GetSize(wide,tall); + DrawShapedBackground( 0, 0, wide, tall, this->GetBgColor() ); +} + +template +void CDODMouseOverButton::PaintBorder() +{ + int wide, tall; + this->GetSize(wide,tall); + DrawShapedBorder( 0, 0, wide, tall, this->GetFgColor() ); +} + +template +void CDODMouseOverButton::ShowPage( void ) +{ + MouseOverButton::ShowPage(); + + // send message to parent that we triggered something + this->PostActionSignal( new KeyValues("ShowPage", "page", this->GetName() ) ); +} + +template +void CDODMouseOverButton::HidePage( void ) +{ + MouseOverButton::HidePage(); + + // send message to parent that we triggered something + this->PostActionSignal( new KeyValues("ShowPage", "page", this->GetName() ) ); +} + +#endif // DOD_MOUSE_OVER_BUTTON_H \ No newline at end of file diff --git a/game/client/dod/VGUI/dodoverview.cpp b/game/client/dod/VGUI/dodoverview.cpp new file mode 100644 index 00000000..9d9da3b5 --- /dev/null +++ b/game/client/dod/VGUI/dodoverview.cpp @@ -0,0 +1,977 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include +#include +#include "dod_shareddefs.h" +#include "dodoverview.h" +#include "c_playerresource.h" +#include "c_dod_objective_resource.h" +#include "usermessages.h" +#include "coordsize.h" +#include "clientmode.h" +#include +#include "voice_status.h" +#include "spectatorgui.h" +#include "dod_hud_freezepanel.h" + +using namespace vgui; + +void __MsgFunc_UpdateRadar(bf_read &msg) +{ + if ( !g_pMapOverview ) + return; + + int iPlayerEntity = msg.ReadByte(); + + while ( iPlayerEntity > 0 ) + { + int x = msg.ReadSBitLong( COORD_INTEGER_BITS-1 ) * 4; + int y = msg.ReadSBitLong( COORD_INTEGER_BITS-1 ) * 4; + int a = msg.ReadSBitLong( 9 ); + + Vector origin( x, y, 0 ); + QAngle angles( 0, a, 0 ); + + g_pMapOverview->SetPlayerPositions( iPlayerEntity-1, origin, angles ); + + iPlayerEntity = msg.ReadByte(); // read index for next player + } +} + +extern ConVar _overview_mode; +ConVar _cl_minimapzoom( "_cl_minimapzoom", "1", FCVAR_ARCHIVE ); +ConVar _overview_mode( "_overview_mode", "1", FCVAR_ARCHIVE, "Overview mode - 0=off, 1=inset, 2=full\n", true, 0, true, 2 ); + + +CDODMapOverview *GetDODOverview( void ) +{ + return dynamic_cast(g_pMapOverview); +} + +// overview_togglezoom rotates through 3 levels of zoom for the small map +//----------------------------------------------------------------------- +void ToggleZoom( void ) +{ + if ( !GetDODOverview() ) + return; + + GetDODOverview()->ToggleZoom(); +} +static ConCommand overview_togglezoom( "overview_togglezoom", ToggleZoom ); + +// overview_largemap toggles showing the large map +//------------------------------------------------ +void ShowLargeMap( void ) +{ + if ( !GetDODOverview() ) + return; + + GetDODOverview()->ShowLargeMap(); +} +static ConCommand overview_showlargemap( "+overview_largemap", ShowLargeMap ); + +void HideLargeMap( void ) +{ + if ( !GetDODOverview() ) + return; + + GetDODOverview()->HideLargeMap(); +} +static ConCommand overview_hidelargemap( "-overview_largemap", HideLargeMap ); + +//-------------------------------- +// map border ? +// icon minimum zoom +// flag swipes +// grenades +// chatting icon +// voice com icon +//--------------------------------- + +DECLARE_HUDELEMENT( CDODMapOverview ); + +ConVar dod_overview_voice_icon_size( "dod_overview_voice_icon_size", "64", FCVAR_ARCHIVE ); + +CDODMapOverview::CDODMapOverview( const char *pElementName ) : BaseClass( pElementName ) +{ + InitTeamColorsAndIcons(); + m_flIconSize = 96.0f; + m_iLastMode = MAP_MODE_OFF; + usermessages->HookMessage( "UpdateRadar", __MsgFunc_UpdateRadar ); +} + +void CDODMapOverview::Update() +{ + UpdateCapturePoints(); + + BaseClass::Update(); +} + +void CDODMapOverview::VidInit( void ) +{ + m_pC4Icon = gHUD.GetIcon( "icon_c4" ); + m_pExplodedIcon = gHUD.GetIcon( "icon_c4_exploded" ); + m_pC4PlantedBG = gHUD.GetIcon( "icon_c4_planted_bg" ); + m_pIconDefended = gHUD.GetIcon( "icon_defended" ); + + BaseClass::VidInit(); +} + +void CDODMapOverview::UpdateCapturePoints() +{ + if ( !g_pObjectiveResource ) + return; + + Color colorGreen(0,255,0,255); + + if ( !g_pObjectiveResource ) + return; + + for( int i=0;iGetNumControlPoints();i++ ) + { + // check if CP is visible at all + if( !g_pObjectiveResource->IsCPVisible(i) ) + { + if ( m_CapturePoints[i] != 0 ) + { + // remove capture point from map + RemoveObject( m_CapturePoints[i] ); + m_CapturePoints[i] = 0; + } + + continue; + } + + // ok, show CP + int iOwningTeam = g_pObjectiveResource->GetOwningTeam(i); + int iCappingTeam = g_pObjectiveResource->GetCappingTeam(i); + + int iOwningIcon = g_pObjectiveResource->GetIconForTeam( i, iOwningTeam ); + if ( iOwningIcon <= 0 ) + continue; // baah + + const char *textureName = GetMaterialNameFromIndex( iOwningIcon ); + + int objID = m_CapturePoints[i]; + + if ( objID == 0 ) + { + // add object if not already there + objID = m_CapturePoints[i] = AddObject( textureName, 0, -1 ); + + // objective positions never change (so far) + SetObjectPosition( objID, g_pObjectiveResource->GetCPPosition(i), vec3_angle ); + + AddObjectFlags( objID, MAP_OBJECT_ALIGN_TO_MAP ); + } + + SetObjectIcon( objID, textureName, 128.0 ); + + + int iBombs = g_pObjectiveResource->GetBombsRemaining( i ); + if ( iBombs > 0 ) + { + char text[8]; + Q_snprintf( text, sizeof(text), "%d", iBombs ); + SetObjectText( objID, text, colorGreen ); + } + //Draw the number of cappers below the icon + else if ( iCappingTeam != TEAM_UNASSIGNED ) + { + int numPlayers = g_pObjectiveResource->GetNumPlayersInArea( i, iCappingTeam ); + int requiredPlayers = g_pObjectiveResource->GetRequiredCappers( i, iCappingTeam ); + + if( requiredPlayers > 1 ) + { + char text[8]; + Q_snprintf( text, sizeof(text), "%d/%d", numPlayers, requiredPlayers ); + SetObjectText( objID, text, colorGreen ); + } + else + { + SetObjectText( objID, NULL, colorGreen ); + } + } + else + { + SetObjectText( objID, NULL, colorGreen ); + } + + float flBombTime = g_pObjectiveResource->GetBombTimeForPoint( i ); + + //Draw cap percentage + if( iCappingTeam != TEAM_UNASSIGNED ) + { + SetObjectStatus( objID, g_pObjectiveResource->GetCPCapPercentage(i), colorGreen ); + } + else if ( flBombTime > 0 ) + { + float flPercentRemaining = ( flBombTime / DOD_BOMB_TIMER_LENGTH ); + + SetObjectStatus( objID, flPercentRemaining, colorGreen ); + } + else + { + SetObjectStatus( objID, -1, colorGreen ); // turn it off + } + + } +} + +void CDODMapOverview::InitTeamColorsAndIcons() +{ + BaseClass::InitTeamColorsAndIcons(); + + m_TeamColors[TEAM_ALLIES] = COLOR_DOD_GREEN; + m_TeamIcons[TEAM_ALLIES] = AddIconTexture( "sprites/minimap_icons/aplayer" ); + m_CameraIcons[TEAM_ALLIES] = AddIconTexture( "sprites/minimap_icons/allies_camera" ); + + + m_TeamColors[TEAM_AXIS] = COLOR_DOD_RED; + m_TeamIcons[TEAM_AXIS] = AddIconTexture( "sprites/minimap_icons/gplayer" ); + m_CameraIcons[TEAM_AXIS] = AddIconTexture( "sprites/minimap_icons/axis_camera" ); + + Q_memset( m_flPlayerChatTime, 0, sizeof(m_flPlayerChatTime ) ); + m_iVoiceIcon = AddIconTexture( "voice/icntlk_pl" ); + m_iChatIcon = AddIconTexture( "sprites/minimap_icons/voiceIcon" ); + + Q_memset( m_CapturePoints, 0, sizeof(m_CapturePoints) ); +} + +void CDODMapOverview::DrawCamera() +{ + C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer(); + + if ( !localPlayer ) + return; + + int iTexture = m_CameraIcons[localPlayer->GetTeamNumber()]; + + if ( localPlayer->IsObserver() || iTexture <= 0 ) + { + BaseClass::DrawCamera(); + } + else + { + MapObject_t obj; + memset( &obj, 0, sizeof(MapObject_t) ); + + obj.icon = iTexture; + obj.position = localPlayer->GetAbsOrigin(); + obj.size = m_flIconSize * 1.5; + obj.angle = localPlayer->EyeAngles(); + obj.status = -1; + + DrawIcon( &obj ); + + DrawVoiceIconForPlayer( localPlayer->entindex() - 1 ); + } +} + +void CDODMapOverview::FireGameEvent( IGameEvent *event ) +{ + const char * type = event->GetName(); + + if ( Q_strcmp(type, "player_death") == 0 ) + { + MapPlayer_t *player = GetPlayerByUserID( event->GetInt("userid") ); + + if ( player && CanPlayerBeSeen( player ) ) + { + // create skull icon for 3 seconds + int handle = AddObject( "sprites/minimap_icons/death", 0, 3 ); + SetObjectText( handle, player->name, player->color ); + SetObjectPosition( handle, player->position, player->angle ); + } + } + else if ( Q_strcmp(type, "game_newmap") == 0 ) + { + SetMode( _overview_mode.GetInt() ); + } + + BaseClass::FireGameEvent( event ); +} + +// rules that define if you can see a player on the overview or not +bool CDODMapOverview::CanPlayerBeSeen(MapPlayer_t *player) +{ + C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer(); + + if ( !localPlayer || !player ) + return false; + + // don't draw ourselves + if ( localPlayer->entindex() == (player->index+1) ) + return false; + + // if local player is on spectator team, he can see everyone + if ( localPlayer->GetTeamNumber() <= TEAM_SPECTATOR ) + return true; + + // we never track unassigned or real spectators + if ( player->team <= TEAM_SPECTATOR ) + return false; + + // ingame and as dead player we can only see our own teammates + return (localPlayer->GetTeamNumber() == player->team ); +} + +void CDODMapOverview::ShowLargeMap( void ) +{ + // remember old mode + m_iLastMode = GetMode(); + + // if we hit the toggle while full, set to disappear when we release + if ( m_iLastMode == MAP_MODE_FULL ) + m_iLastMode = MAP_MODE_OFF; + + SetMode( MAP_MODE_FULL ); +} + +void CDODMapOverview::HideLargeMap( void ) +{ + SetMode( m_iLastMode ); +} + +void CDODMapOverview::ToggleZoom( void ) +{ + if ( GetMode() != MAP_MODE_INSET ) + return; + + int iZoomLevel = ( _cl_minimapzoom.GetInt() + 1 ) % DOD_MAP_ZOOM_LEVELS; + + _cl_minimapzoom.SetValue( iZoomLevel ); + + switch( _cl_minimapzoom.GetInt() ) + { + case 0: + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel1" ); + break; + case 1: + default: + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel2" ); + break; + } +} + +void CDODMapOverview::SetMode(int mode) +{ + m_flChangeSpeed = 0; // change size instantly + + if ( mode == MAP_MODE_OFF ) + { + ShowPanel( false ); + + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapOff" ); + } + else if ( mode == MAP_MODE_INSET ) + { + switch( _cl_minimapzoom.GetInt() ) + { + case 0: + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel1" ); + break; + case 1: + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel2" ); + break; + case 2: + default: + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel3" ); + break; + } + + C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); + + if ( pPlayer ) + SetFollowEntity( pPlayer->entindex() ); + + ShowPanel( true ); + + if ( m_nMode == MAP_MODE_FULL ) + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapScaleToSmall" ); + else + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SnapToSmall" ); + } + else if ( mode == MAP_MODE_FULL ) + { + SetFollowEntity( 0 ); + + ShowPanel( true ); + + if ( m_nMode == MAP_MODE_INSET ) + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "ZoomToLarge" ); + else + g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SnapToLarge" ); + } + + // finally set mode + m_nMode = mode; + + // save in a cvar for archive + _overview_mode.SetValue( m_nMode ); + + UpdateSizeAndPosition(); +} + +void CDODMapOverview::UpdateSizeAndPosition() +{ + // move back up if the spectator menu is not visible + if ( !g_pSpectatorGUI || ( !g_pSpectatorGUI->IsVisible() && GetMode() == MAP_MODE_INSET ) ) + { + int x,y,w,h; + + GetBounds( x,y,w,h ); + + y = YRES(5); // hax, align to top of the screen + + SetBounds( x,y,w,h ); + } + + BaseClass::UpdateSizeAndPosition(); +} + +void CDODMapOverview::AddGrenade( C_DODBaseGrenade *pGrenade ) +{ + C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer(); + + if ( !localPlayer ) + return; + + int localTeam = localPlayer->GetTeamNumber(); + + // Spectators can see all grenades + // players can only see them if they are on the same team + if ( localTeam == TEAM_SPECTATOR || ( localTeam == pGrenade->GetTeamNumber() ) ) + { + AddObject( pGrenade->GetOverviewSpriteName(), pGrenade->entindex(), -1 ); + } +} + +void CDODMapOverview::RemoveGrenade( C_DODBaseGrenade *pGrenade ) +{ + RemoveObjectByIndex( pGrenade->entindex() ); +} + +ConVar cl_voicetest( "cl_voicetest", "0", FCVAR_CHEAT ); +ConVar cl_overview_chat_time( "cl_overview_chat_time", "2.0", FCVAR_ARCHIVE ); + +void CDODMapOverview::PlayerChat( int index ) +{ + m_flPlayerChatTime[index-1] = gpGlobals->curtime + cl_overview_chat_time.GetFloat(); +} + +void CDODMapOverview::DrawMapPlayers() +{ + BaseClass::DrawMapPlayers(); + + C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer(); + + Assert( localPlayer ); + + int iLocalPlayer = localPlayer->entindex() - 1; + + for (int i=0; ihealth <= 0 ) // don't draw dead players / spectators + continue; + + DrawVoiceIconForPlayer( i ); + } +} + +void CDODMapOverview::DrawVoiceIconForPlayer( int playerIndex ) +{ + Assert( playerIndex >= 0 && playerIndex < MAX_PLAYERS ); + + MapPlayer_t *player = &m_Players[playerIndex]; + + // if they just sent a chat msg, or are using voice, or did a hand signal or voice command + // draw a chat icon + + if ( cl_voicetest.GetInt() || GetClientVoiceMgr()->IsPlayerSpeaking( player->index+1 ) ) + { + MapObject_t obj; + memset( &obj, 0, sizeof(MapObject_t) ); + + obj.icon = m_iVoiceIcon; + obj.position = player->position; + obj.size = dod_overview_voice_icon_size.GetFloat(); + obj.status = -1; + + DrawIcon( &obj ); + } + else if ( m_flPlayerChatTime[player->index] > gpGlobals->curtime ) + { + MapObject_t obj; + memset( &obj, 0, sizeof(MapObject_t) ); + + obj.icon = m_iChatIcon; + obj.position = player->position; + obj.size = dod_overview_voice_icon_size.GetFloat(); + obj.status = -1; + + DrawIcon( &obj ); + } +} + +bool CDODMapOverview::DrawIcon( MapObject_t *obj ) +{ + for ( int i=0;iobjectID == m_CapturePoints[i] && obj->objectID != 0 ) + { + return DrawCapturePoint( i, obj ); + } + } + + return BaseClass::DrawIcon( obj ); +} + +void CDODMapOverview::DrawQuad( Vector pos, int scale, float angle, int textureID, int alpha ) +{ + Vector offset; + offset.z = 0; + + offset.x = -scale; offset.y = scale; + VectorYawRotate( offset, angle, offset ); + Vector2D pos1 = WorldToMap( pos + offset ); + + offset.x = scale; offset.y = scale; + VectorYawRotate( offset, angle, offset ); + Vector2D pos2 = WorldToMap( pos + offset ); + + offset.x = scale; offset.y = -scale; + VectorYawRotate( offset, angle, offset ); + Vector2D pos3 = WorldToMap( pos + offset ); + + offset.x = -scale; offset.y = -scale; + VectorYawRotate( offset, angle, offset ); + Vector2D pos4 = WorldToMap( pos + offset ); + + Vertex_t points[4] = + { + Vertex_t( MapToPanel ( pos1 ), Vector2D(0,0) ), + Vertex_t( MapToPanel ( pos2 ), Vector2D(1,0) ), + Vertex_t( MapToPanel ( pos3 ), Vector2D(1,1) ), + Vertex_t( MapToPanel ( pos4 ), Vector2D(0,1) ) + }; + + surface()->DrawSetColor( 255, 255, 255, alpha ); + surface()->DrawSetTexture( textureID ); + surface()->DrawTexturedPolygon( 4, points ); +} + +bool CDODMapOverview::DrawCapturePoint( int iCP, MapObject_t *obj ) +{ + int textureID = obj->icon; + Vector pos = obj->position; + float scale = obj->size; + float angle = 0; + + Vector2D pospanel = WorldToMap( pos ); + pospanel = MapToPanel( pospanel ); + + if ( !IsInPanel( pospanel ) ) + return false; // player is not within overview panel + + int iBombsRequired = g_pObjectiveResource->GetBombsRequired( iCP ); + + if ( iBombsRequired ) + { + if ( g_pObjectiveResource->IsBombSetAtPoint( iCP ) ) + { + // draw swipe over blank icon + + // 'white' icon + int iBlankIcon = g_pObjectiveResource->GetCPTimerCapIcon( iCP ); + const char *textureName = GetMaterialNameFromIndex( iBlankIcon ); + DrawQuad( pos, scale, 0, AddIconTexture( textureName ), 255 ); + + // the circular swipe + float flBombTime = g_pObjectiveResource->GetBombTimeForPoint( iCP ); + float flPercentRemaining = ( flBombTime / DOD_BOMB_TIMER_LENGTH ); + + DrawBombTimerSwipeIcon( pos, scale, textureID, flPercentRemaining ); + } + else + { + DrawQuad( pos, scale, 0, textureID, 255 ); + } + } + else + { + // draw capture swipe + DrawQuad( pos, scale, 0, textureID, 255 ); + + int iCappingTeam = g_pObjectiveResource->GetCappingTeam( iCP ); + + if ( iCappingTeam != TEAM_UNASSIGNED ) + { + int iCapperIcon = g_pObjectiveResource->GetCPCappingIcon( iCP ); + const char *textureName = GetMaterialNameFromIndex( iCapperIcon ); + + float flCapPercent = g_pObjectiveResource->GetCPCapPercentage(iCP); + bool bSwipeLeft = ( iCappingTeam == TEAM_AXIS ) ? true : false; + + DrawHorizontalSwipe( pos, scale, AddIconTexture( textureName ), flCapPercent, bSwipeLeft ); + } + + // fixup for noone is capping, but someone is in the area + int iNumAllies = g_pObjectiveResource->GetNumPlayersInArea( iCP, TEAM_ALLIES ); + int iNumAxis = g_pObjectiveResource->GetNumPlayersInArea( iCP, TEAM_AXIS ); + + int iOwningTeam = g_pObjectiveResource->GetOwningTeam( iCP ); + if ( iCappingTeam == TEAM_UNASSIGNED ) + { + if ( iNumAllies > 0 && iNumAxis == 0 && iOwningTeam != TEAM_ALLIES ) + { + iCappingTeam = TEAM_ALLIES; + } + else if ( iNumAxis > 0 && iNumAllies == 0 && iOwningTeam != TEAM_AXIS ) + { + iCappingTeam = TEAM_AXIS; + } + } + + if ( iCappingTeam != TEAM_UNASSIGNED ) + { + // Draw the number of cappers below the icon + int numPlayers = g_pObjectiveResource->GetNumPlayersInArea( iCP, iCappingTeam ); + int requiredPlayers = g_pObjectiveResource->GetRequiredCappers( iCP, iCappingTeam ); + + if ( requiredPlayers > 1 ) + { + numPlayers = MIN( numPlayers, requiredPlayers ); + + wchar_t wText[6]; + _snwprintf( wText, sizeof(wText)/sizeof(wchar_t), L"%d/%d", numPlayers, requiredPlayers ); + + int wide, tall; + surface()->GetTextSize( m_hIconFont, wText, wide, tall ); + + int x = pospanel.x-(wide/2); + int y = pospanel.y; + + // match the offset that MapOverview uses + y += GetPixelOffset( scale ) + 4; + + // draw black shadow text + surface()->DrawSetTextColor( 0, 0, 0, 255 ); + surface()->DrawSetTextPos( x+1, y ); + surface()->DrawPrintText( wText, wcslen(wText) ); + + // draw name in color + surface()->DrawSetTextColor( g_PR->GetTeamColor( iCappingTeam ) ); + surface()->DrawSetTextPos( x, y ); + surface()->DrawPrintText( wText, wcslen(wText) ); + } + } + } + + // draw bombs underneath if necessary + if ( iBombsRequired > 0 ) + { + int iBombsRemaining = g_pObjectiveResource->GetBombsRemaining( iCP ); + bool bBombPlanted = g_pObjectiveResource->IsBombSetAtPoint( iCP ); + + // draw bomb state underneath + float flBombIconScale = scale * 0.5; + + + switch( iBombsRequired ) + { + case 1: + { + Vector bombPos = pos; + bombPos.y -= scale * 1.5; + + switch( iBombsRemaining ) + { + case 0: + DrawQuad( bombPos, flBombIconScale, angle, m_pExplodedIcon->textureId, 255 ); + break; + case 1: + if ( bBombPlanted ) + { + // draw the background behind 1 + int alpha = (float)( abs( sin(2*gpGlobals->curtime) ) * 205.0 + 50.0 ); + DrawQuad( bombPos, flBombIconScale*2, angle, m_pC4PlantedBG->textureId, alpha ); + } + DrawQuad( bombPos, flBombIconScale, angle, m_pC4Icon->textureId, 255 ); + break; + } + } + break; + case 2: + { + Vector bombPos1, bombPos2; + bombPos1 = bombPos2 = pos; + bombPos1.y = bombPos2.y = pos.y - scale * 1.5; + + bombPos1.x = pos.x - scale * 0.5; + bombPos2.x = pos.x + scale * 0.5; + + switch( iBombsRemaining ) + { + case 0: + DrawQuad( bombPos1, flBombIconScale, angle, m_pExplodedIcon->textureId, 255 ); + DrawQuad( bombPos2, flBombIconScale, angle, m_pExplodedIcon->textureId, 255 ); + break; + case 1: + if ( bBombPlanted ) + { + // draw the background behind 1 + int alpha = (float)( abs( sin(2*gpGlobals->curtime) ) * 205.0 + 50.0 ); + DrawQuad( bombPos1, flBombIconScale*2, angle, m_pC4PlantedBG->textureId, alpha ); + } + DrawQuad( bombPos1, flBombIconScale, angle, m_pC4Icon->textureId, 255 ); + DrawQuad( bombPos2, flBombIconScale, angle, m_pExplodedIcon->textureId, 255 ); + break; + case 2: + if ( bBombPlanted ) + { + // draw the background behind 2 + int alpha = (float)( abs( sin(2*gpGlobals->curtime) ) * 205.0 + 50.0 ); + DrawQuad( bombPos2, flBombIconScale*2, angle, m_pC4PlantedBG->textureId, alpha ); + } + DrawQuad( bombPos1, flBombIconScale, angle, m_pC4Icon->textureId, 255 ); + DrawQuad( bombPos2, flBombIconScale, angle, m_pC4Icon->textureId, 255 ); + break; + } + } + break; + } + + // draw shield over top + if ( g_pObjectiveResource->IsBombBeingDefused( iCP ) ) + { + DrawQuad( pos, scale * 0.75, angle, m_pIconDefended->textureId, 255 ); + } + } + + return true; +} + +void CDODMapOverview::DrawBombTimerSwipeIcon( Vector pos, int scale, int textureID, float flPercentRemaining ) +{ + const float flCompleteCircle = ( 2.0f * M_PI ); + const float fl90degrees = flCompleteCircle * 0.25f; + const float fl45degrees = fl90degrees * 0.5f; + + float flEndAngle = flCompleteCircle * flPercentRemaining; // clockwise + + typedef struct + { + Vector2D vecTrailing; + Vector2D vecLeading; + } icon_quadrant_t; + + /* + Quadrants are numbered 0 - 7 counter-clockwise + _________________ + | 0 | 7 | + | | | + | 1 | 6 | + ----------------- + | 2 | 5 | + | | | + | 3 | 4 | + ----------------- + */ + + // Encode the leading and trailing edge of each quadrant + // in the range 0.0 -> 1.0 + + icon_quadrant_t quadrants[8]; + quadrants[0].vecTrailing.Init( 0.5, 0.0 ); + quadrants[0].vecLeading.Init( 0.0, 0.0 ); + + quadrants[1].vecTrailing.Init( 0.0, 0.0 ); + quadrants[1].vecLeading.Init( 0.0, 0.5 ); + + quadrants[2].vecTrailing.Init( 0.0, 0.5 ); + quadrants[2].vecLeading.Init( 0.0, 1.0 ); + + quadrants[3].vecTrailing.Init( 0.0, 1.0 ); + quadrants[3].vecLeading.Init( 0.5, 1.0 ); + + quadrants[4].vecTrailing.Init( 0.5, 1.0 ); + quadrants[4].vecLeading.Init( 1.0, 1.0 ); + + quadrants[5].vecTrailing.Init( 1.0, 1.0 ); + quadrants[5].vecLeading.Init( 1.0, 0.5 ); + + quadrants[6].vecTrailing.Init( 1.0, 0.5 ); + quadrants[6].vecLeading.Init( 1.0, 0.0 ); + + quadrants[7].vecTrailing.Init( 1.0, 0.0 ); + quadrants[7].vecLeading.Init( 0.5, 0.0 ); + + surface()->DrawSetColor( 255, 255, 255, 255 ); + surface()->DrawSetTexture( textureID ); + + Vector2D uvMid( 0.5, 0.5 ); + Vector2D newPos( pos.x - scale, pos.y + scale ); + + int j; + for ( j=0;j<=7;j++ ) + { + float flMinAngle = j * fl45degrees; + + float flAngle = clamp( flEndAngle - flMinAngle, 0, fl45degrees ); + + if ( flAngle <= 0 ) + { + // past our quadrant, draw nothing + continue; + } + else + { + // draw our segment + vgui::Vertex_t vert[3]; + + // vert 0 is mid ( 0.5, 0.5 ) + + Vector2D pos0 = WorldToMap( pos ); + vert[0].Init( MapToPanel( pos0 ), uvMid ); + + int xdir = 0, ydir = 0; + + switch( j ) + { + case 0: + case 7: + //right + xdir = 1; + ydir = 0; + break; + + case 1: + case 2: + //up + xdir = 0; + ydir = -1; + break; + + case 3: + case 4: + //left + xdir = -1; + ydir = 0; + break; + + case 5: + case 6: + //down + xdir = 0; + ydir = 1; + break; + } + + Vector vec1; + Vector2D uv1; + + // vert 1 is the variable vert based on leading edge + vec1.x = newPos.x + quadrants[j].vecTrailing.x * scale*2 - xdir * tan(flAngle) * scale; + vec1.y = newPos.y - quadrants[j].vecTrailing.y * scale*2 + ydir * tan(flAngle) * scale; + + uv1.x = quadrants[j].vecTrailing.x - xdir * abs( quadrants[j].vecLeading.x - quadrants[j].vecTrailing.x ) * tan(flAngle); + uv1.y = quadrants[j].vecTrailing.y - ydir * abs( quadrants[j].vecLeading.y - quadrants[j].vecTrailing.y ) * tan(flAngle); + + Vector2D pos1 = WorldToMap( vec1 ); + vert[1].Init( MapToPanel( pos1 ), uv1 ); + + // vert 2 is our trailing edge + Vector vec2; + + vec2.x = newPos.x + quadrants[j].vecTrailing.x * scale*2; + vec2.y = newPos.y - quadrants[j].vecTrailing.y * scale*2; + + Vector2D pos2 = WorldToMap( vec2 ); + vert[2].Init( MapToPanel( pos2 ), quadrants[j].vecTrailing ); + + surface()->DrawTexturedPolygon( 3, vert ); + } + } +} + +void CDODMapOverview::DrawHorizontalSwipe( Vector pos, int scale, int textureID, float flCapPercentage, bool bSwipeLeft ) +{ + float flIconSize = scale * 2; + float width = ( flIconSize * flCapPercentage ); + + float uv1 = 0.0f; + float uv2 = 1.0f; + + Vector2D uv11( uv1, uv2 ); + Vector2D uv21( flCapPercentage, uv2 ); + Vector2D uv22( flCapPercentage, uv1 ); + Vector2D uv12( uv1, uv1 ); + + // reversing the direction of the swipe effect + if ( bSwipeLeft ) + { + uv11.x = uv2 - flCapPercentage; + uv21.x = uv2; + uv22.x = uv2; + uv12.x = uv2 - flCapPercentage; + } + + float flXPos = pos.x - scale; + float flYPos = pos.y - scale; + + Vector upperLeft( flXPos, flYPos, 0 ); + Vector upperRight( flXPos + width, flYPos, 0 ); + Vector lowerRight( flXPos + width, flYPos + flIconSize, 0 ); + Vector lowerLeft ( flXPos, flYPos + flIconSize, 0 ); + + /// reversing the direction of the swipe effect + if ( bSwipeLeft ) + { + upperLeft.x = flXPos + flIconSize - width; + upperRight.x = flXPos + flIconSize; + lowerRight.x = flXPos + flIconSize; + lowerLeft.x = flXPos + flIconSize - width; + } + + vgui::Vertex_t vert[4]; + + Vector2D pos0 = WorldToMap( upperLeft ); + vert[0].Init( MapToPanel( pos0 ), uv11 ); + + Vector2D pos3 = WorldToMap( lowerLeft ); + vert[1].Init( MapToPanel( pos3 ), uv12 ); + + Vector2D pos2 = WorldToMap( lowerRight ); + vert[2].Init( MapToPanel( pos2 ), uv22 ); + + Vector2D pos1 = WorldToMap( upperRight ); + vert[3].Init( MapToPanel( pos1 ), uv21 ); + + surface()->DrawSetColor( 255, 255, 255, 255 ); + surface()->DrawSetTexture( textureID ); + surface()->DrawTexturedPolygon( 4, vert ); +} + + +bool CDODMapOverview::IsVisible( void ) +{ + if ( IsTakingAFreezecamScreenshot() ) + return false; + + return BaseClass::IsVisible(); +} \ No newline at end of file diff --git a/game/client/dod/VGUI/dodoverview.h b/game/client/dod/VGUI/dodoverview.h new file mode 100644 index 00000000..879d7b2c --- /dev/null +++ b/game/client/dod/VGUI/dodoverview.h @@ -0,0 +1,81 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DODOVERVIEW_H +#define DODOVERVIEW_H + +#include +#include "dod_shareddefs.h" +#include "c_dod_basegrenade.h" + +class CDODMapOverview : public CMapOverview +{ + DECLARE_CLASS_SIMPLE( CDODMapOverview, CMapOverview ); + + CDODMapOverview( const char *pElementName ); + + int m_CameraIcons[MAX_TEAMS]; + int m_CapturePoints[MAX_CONTROL_POINTS]; + + void ShowLargeMap( void ); + void HideLargeMap( void ); + void ToggleZoom( void ); + + void AddGrenade( C_DODBaseGrenade *pGrenade ); + void RemoveGrenade( C_DODBaseGrenade *pGrenade ); + + void PlayerChat( int index ); + + void DrawQuad( Vector pos, int scale, float angle, int textureID, int alpha ); + void DrawBombTimerSwipeIcon( Vector pos, int scale, int textureID, float flPercentRemaining ); + void DrawHorizontalSwipe( Vector pos, int scale, int textureID, float flCapPercentage, bool bSwipeLeft ); + bool DrawCapturePoint( int iCP, MapObject_t *obj ); + + virtual void VidInit( void ); + + virtual bool IsVisible( void ); + +protected: + virtual void SetMode(int mode); + virtual void InitTeamColorsAndIcons(); + virtual void FireGameEvent( IGameEvent *event ); + virtual void DrawCamera(); + virtual void DrawMapPlayers(); + virtual void Update(); + virtual void UpdateSizeAndPosition(); + + // rules that define if you can see a player on the overview or not + virtual bool CanPlayerBeSeen(MapPlayer_t *player); + + void DrawVoiceIconForPlayer( int playerIndex ); + + virtual bool DrawIcon( MapObject_t *obj ); + +protected: + void UpdateCapturePoints(); + +private: + int m_iLastMode; + + CUtlVector m_Grenades; + + int m_iVoiceIcon; + int m_iChatIcon; + + float m_flPlayerChatTime[MAX_PLAYERS]; + + CHudTexture *m_pC4Icon; + CHudTexture *m_pExplodedIcon; + CHudTexture *m_pC4PlantedBG; + CHudTexture *m_pIconDefended; + +#define DOD_MAP_ZOOM_LEVELS 2 +}; + +extern CDODMapOverview *GetDODOverview( void ); + +#endif // DODOVERVIEW_H diff --git a/game/client/dod/VGUI/dodrandombutton.h b/game/client/dod/VGUI/dodrandombutton.h new file mode 100644 index 00000000..a846972e --- /dev/null +++ b/game/client/dod/VGUI/dodrandombutton.h @@ -0,0 +1,93 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DOD_RANDOM_BUTTON_H +#define DOD_RANDOM_BUTTON_H + +#include "dodmouseoverpanelbutton.h" + +// CDODRandomButton - has the lower left corner cut out +// and does mouseover + +/* + +|''''''''''''''''| +| 9. Random | + \_______________| + */ + +template +class CDODRandomButton : public CDODMouseOverButton +{ +private: + //DECLARE_CLASS_SIMPLE( CDODRandomButton, CDODMouseOverButton ); + +public: + CDODRandomButton(vgui::Panel *parent, const char *panelName, T *templatePanel ) : + CDODMouseOverButton( parent, panelName, templatePanel ) + { + } + +protected: + virtual void PaintBackground(); + virtual void PaintBorder(); +}; + +//=============================================== +// CDODRandomButton - differently shaped button +//=============================================== +template +void CDODRandomButton::PaintBackground() +{ + int wide, tall; + this->GetSize(wide,tall); + + int inset = tall; + + if ( CDODRandomButton::m_iWhiteTexture < 0 ) + { + CDODRandomButton::m_iWhiteTexture = vgui::surface()->CreateNewTextureID(); + vgui::surface()->DrawSetTextureFile( CDODRandomButton::m_iWhiteTexture, "vgui/white" , true, false); + } + + surface()->DrawSetColor(this->GetBgColor()); + surface()->DrawSetTexture( CDODRandomButton::m_iWhiteTexture ); + + Vertex_t verts[4]; + + verts[0].Init( Vector2D( 0, 0 ) ); + verts[1].Init( Vector2D( wide-1, 0 ) ); + verts[2].Init( Vector2D( wide-1, tall-1 ) ); + verts[3].Init( Vector2D( inset, tall-1 ) ); + + surface()->DrawTexturedPolygon(4, verts); +} + +template +void CDODRandomButton::PaintBorder() +{ + int wide, tall; + this->GetSize(wide,tall); + + int inset = tall; + + surface()->DrawSetColor(this->GetFgColor()); + + // top + surface()->DrawLine( 0, 1, wide-1, 1 ); + + // left + surface()->DrawLine( 1, 1, inset-1, tall-1 ); + + // bottom + surface()->DrawLine( inset-1, tall-1, wide-1, tall-1 ); + + // right + surface()->DrawLine( wide-1, 0, wide-1, tall-1 ); +} + +#endif //DOD_RANDOM_BUTTON_H \ No newline at end of file diff --git a/game/client/dod/VGUI/dodspectatorgui.cpp b/game/client/dod/VGUI/dodspectatorgui.cpp new file mode 100644 index 00000000..c4e1dd5c --- /dev/null +++ b/game/client/dod/VGUI/dodspectatorgui.cpp @@ -0,0 +1,194 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "dodspectatorgui.h" +#include "hud.h" +#include "dod_shareddefs.h" + +#include +#include +#include +#include "dod_gamerules.h" +#include "c_team.h" +#include "c_dod_team.h" +#include "c_dod_player.h" +#include "c_dod_playerresource.h" + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CDODSpectatorGUI::CDODSpectatorGUI(IViewPort *pViewPort) : CSpectatorGUI(pViewPort) +{ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CDODSpectatorGUI::NeedsUpdate( void ) +{ + if ( !C_BasePlayer::GetLocalPlayer() ) + return false; + + if( IsVisible() ) + return true; + + //if ( DODGameRules()->IsGameUnderTimeLimit() && m_nLastTime != DODGameRules()->GetTimeLeft() ) + // return true; + + if ( m_nLastSpecMode != C_BasePlayer::GetLocalPlayer()->GetObserverMode() ) + return true; + + if ( m_nLastSpecTarget != C_BasePlayer::GetLocalPlayer()->GetObserverTarget() ) + return true; + + return BaseClass::NeedsUpdate(); +} + +Color CDODSpectatorGUI::GetClientColor(int index) +{ + C_BasePlayer *player = ToBasePlayer( ClientEntityList().GetEnt( index) ); + + int team = player->GetTeamNumber(); + + Assert( team == TEAM_ALLIES || team == TEAM_AXIS || team == TEAM_SPECTATOR ); + + if ( GameResources() ) + return GameResources()->GetTeamColor( team ); + else + return Color( 255, 255, 255, 255 ); +} + +void CDODSpectatorGUI::Update() +{ + BaseClass::Update(); + + C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); + + if( pLocalPlayer ) + { + m_nLastSpecMode = pLocalPlayer->GetObserverMode(); + m_nLastSpecTarget = pLocalPlayer->GetObserverTarget(); + } + + UpdateTimer(); + + UpdateScores(); +} + +void CDODSpectatorGUI::UpdateTimer( void ) +{ + C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer(); + + if( !pPlayer || pPlayer->IsHLTV() ) + { + wchar_t wText[ 63 ]; + + int timer; + timer = (int)( DODGameRules()->GetTimeLeft() ); + if ( timer < 0 ) + timer = 0; + + _snwprintf ( wText, sizeof(wText)/sizeof(wchar_t), L"%d:%02d", (timer / 60), (timer % 60) ); + wText[62] = 0; + + SetDialogVariable( "timer", wText ); + SetDialogVariable( "reinforcements", wText ); + } + else if( pPlayer->GetTeamNumber() == TEAM_SPECTATOR ) + { + SetDialogVariable( "timer", L"" ); + SetDialogVariable( "reinforcements", L"" ); + } + else + { + SetDialogVariable( "timer", L"" ); + + // we need to know how much longer we are going to be in death cam + // once we know that, we can ask dodgamerules if we are going to make the next + // wave. If we aren't, gamerules can tell us the new time based on the reserve wave + float flSpawnEligibleTime; + + if ( pPlayer->GetObserverMode() == OBS_MODE_DEATHCAM ) + { + flSpawnEligibleTime = pPlayer->GetDeathTime() + DEATH_CAM_TIME; + } + else + flSpawnEligibleTime = 0; + + //will never return negative seconds + int timer = DODGameRules()->GetReinforcementTimerSeconds( pPlayer->GetTeamNumber(), flSpawnEligibleTime ); + + if( timer < 0 || ( pPlayer->GetObserverMode() == OBS_MODE_DEATHCAM ) ) + { + SetDialogVariable( "reinforcements", L"" ); + } + else + { + char szMins[4], szSecs[4]; + + int mins = timer / 60; + int secs = timer % 60; + + Q_snprintf( szMins, sizeof(szMins), "%d", mins ); + Q_snprintf( szSecs, sizeof(szSecs), "%d", secs ); + + wchar_t wMins[4], wSecs[4]; + g_pVGuiLocalize->ConvertANSIToUnicode(szMins, wMins, sizeof(wMins)); + g_pVGuiLocalize->ConvertANSIToUnicode(szSecs, wSecs, sizeof(wSecs)); + + wchar_t wLabel[128]; + + if ( mins == 1 ) //"1 minute" + { + g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_in_min" ), 2, wMins, wSecs ); + } + else if ( mins > 0 ) //"2 minutes" + { + g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_in_mins" ), 2, wMins, wSecs ); + } + else if ( secs == 1 ) //"1 second" + { + g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_in_sec" ), 1, wSecs ); + } + else if ( secs == 0 ) //"Prepare to Respawn" + { + g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_prepare_to_respawn" ), 0 ); + } + else //"2 seconds" + { + g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_in_secs" ), 1, wSecs ); + } + + SetDialogVariable( "reinforcements", wLabel ); + } + } +} + +void CDODSpectatorGUI::UpdateScores( void ) +{ + C_DODTeam *pAlliesTeam = static_cast( GetGlobalTeam(TEAM_ALLIES) ); + if ( pAlliesTeam ) + { + SetDialogVariable( "alliesscore", pAlliesTeam->GetRoundsWon() ); + } + + C_DODTeam *pAxisTeam = static_cast( GetGlobalTeam(TEAM_AXIS) ); + if ( pAxisTeam ) + { + SetDialogVariable( "axisscore", pAxisTeam->GetRoundsWon() ); + } +} + +bool CDODSpectatorGUI::ShouldShowPlayerLabel( int specmode ) +{ + return ( (specmode == OBS_MODE_IN_EYE) || + (specmode == OBS_MODE_CHASE) || + (specmode == OBS_MODE_DEATHCAM) ); +} \ No newline at end of file diff --git a/game/client/dod/VGUI/dodspectatorgui.h b/game/client/dod/VGUI/dodspectatorgui.h new file mode 100644 index 00000000..11b15b4b --- /dev/null +++ b/game/client/dod/VGUI/dodspectatorgui.h @@ -0,0 +1,46 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DODSPECTATORGUI_H +#define DODSPECTATORGUI_H +#ifdef _WIN32 +#pragma once +#endif + +#include + + +//----------------------------------------------------------------------------- +// Purpose: Cstrike Spectator UI +//----------------------------------------------------------------------------- +class CDODSpectatorGUI : public CSpectatorGUI +{ +private: + DECLARE_CLASS_SIMPLE( CDODSpectatorGUI, CSpectatorGUI ); + +public: + CDODSpectatorGUI( IViewPort *pViewPort ); + + virtual void Update( void ); + virtual bool NeedsUpdate( void ); + virtual Color GetClientColor(int index); + + virtual bool ShouldShowPlayerLabel( int specmode ); + + //virtual bool HasInputElements( void ) { return true; } + +protected: + + void UpdateTimer(); + void UpdateScores(); + + int m_nLastTime; + int m_nLastSpecMode; + CBaseEntity *m_nLastSpecTarget; +}; + +#endif // DODSPECTATORGUI_H diff --git a/game/client/dod/VGUI/dodteammenu.cpp b/game/client/dod/VGUI/dodteammenu.cpp new file mode 100644 index 00000000..e5d4c580 --- /dev/null +++ b/game/client/dod/VGUI/dodteammenu.cpp @@ -0,0 +1,285 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "dodteammenu.h" +#include +#include "hud.h" // for gEngfuncs +#include "c_dod_player.h" +#include "dod_gamerules.h" +#include +#include +#include +#include "c_dod_team.h" +#include "IGameUIFuncs.h" // for key bindings + +extern IGameUIFuncs *gameuifuncs; // for key binding details + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CDODTeamMenu::CDODTeamMenu(IViewPort *pViewPort) : CTeamMenu(pViewPort) +{ + m_pBackground = SETUP_PANEL( new CDODMenuBackground( this ) ); + + m_pPanel = new EditablePanel( this, "TeamImagePanel" );// team image panel + + m_pFirstButton = NULL; + + LoadControlSettings("Resource/UI/TeamMenu.res"); // reload this to catch DODButtons + + vgui::ivgui()->AddTickSignal( GetVPanel() ); + + m_iActiveTeam = TEAM_UNASSIGNED; + m_iLastPlayerCount = -1; +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +CDODTeamMenu::~CDODTeamMenu() +{ +} + +void CDODTeamMenu::ShowPanel(bool bShow) +{ + if ( bShow ) + { + engine->CheckPoint( "TeamMenu" ); //MATTTODO what is this? + + m_iTeamMenuKey = gameuifuncs->GetButtonCodeForBind( "changeteam" ); + } + + BaseClass::ShowPanel( bShow ); +} + +//----------------------------------------------------------------------------- +// Purpose: Make the first buttons page get displayed when the menu becomes visible +//----------------------------------------------------------------------------- +void CDODTeamMenu::SetVisible( bool state ) +{ + BaseClass::SetVisible( state ); + + for( int i = 0; i< GetChildCount(); i++ ) // get all the buy buttons to performlayout + { + CDODMouseOverButton *button = dynamic_cast *>(GetChild(i)); + if ( button ) + { + if( button == m_pFirstButton && state == true ) + button->ShowPage(); + else + button->HidePage(); + + button->InvalidateLayout(); + } + } + + if ( state ) + { + Panel *pAutoButton = FindChildByName( "autobutton" ); + if ( pAutoButton ) + { + pAutoButton->RequestFocus(); + } + } +} + +void CDODTeamMenu::OnTick( void ) +{ + C_DODTeam *pAllies = dynamic_cast( GetGlobalTeam(TEAM_ALLIES) ); + C_DODTeam *pAxis = dynamic_cast( GetGlobalTeam(TEAM_AXIS) ); + + if ( !pAllies || !pAxis ) + return; + + static int iLastAlliesCount = -1; + static int iLastAxisCount = -1; + + int iNumAllies = pAllies->Get_Number_Players(); + int iNumAxis = pAxis->Get_Number_Players(); + + if ( iNumAllies != iLastAlliesCount ) + { + iLastAlliesCount = iNumAllies; + + wchar_t wbuf[128]; + + if ( iNumAllies == 1 ) + { + g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), g_pVGuiLocalize->Find("#teammenu_numAllies_1"), 0 ); + } + else + { + wchar_t wnum[6]; + _snwprintf( wnum, ARRAYSIZE(wnum), L"%d", iNumAllies ); + g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), g_pVGuiLocalize->Find("#teammenu_numAllies"), 1, wnum ); + } + + Label *pLabel = dynamic_cast