etlegacy icon indicating copy to clipboard operation
etlegacy copied to clipboard

HUD Rework

Open Helldembez opened this issue 2 years ago • 2 comments

So with the recent suggestions for HUD features we have reached a stage where it does more harm than good to add them in the current HUD code. Which leads to the necessity to refactor the HUD code to facilitate modern features and be user friendly to configure as well.

Since this is a big task to do right, we want to formulate a well thought out plan and structure. The start of this issue will contain WIP notes regarding said plan and structure.

General actions

  • [X] - Remove althudflags altogether
  • [ ] - Clean shoutcaster checks through all code since we use shoutcaster hud class?
  • [X] - Centralize draw functions
  • [x] - Think about a way to prevent repeating LMS checks
  • [ ] - Colour-blindness / impaired?

New general HUD customization structure

HUD elements can be divided into two categories:

  • Text-based elements (centerprint, clock, chat etc.)
  • Image-based elements (compass, stamina bar, weaponicon etc.)

The goal is to allow generic/specialized customization of every single HUD element without having to add a cvar for each of these generic parameters. The current custom HUD system closely represents this already, and is ultimately what we should aim for with every single HUD element. Special customization, specific to a certain HUD element, stays as a cvar (e.g. cg_numPopups). Based off these 2 categories, we can define some generic element values for each of them.

Text-based elements

  • Generic parameters:
  • [X] - Position (x/y)
  • [X] - Size/Scale (w/h)
  • [X] - RGBA color (text / background / border)
  • [x] - Shadow
  • [x] - Style (if applicable, think of cg_drawCrosshair - every value is a style)
  • [x] - Left/Right align (could perhaps be merged with style)
  • [X] - Visible (Y/N) (all / background / border)
  • [X] ~~Font~~ (cg_customFont1/2 instead ?)

Image-based elements

  • Generic parameters:
  • [X] - Position (x/y)
  • [X] - Size/Scale (w/h)
  • [x] - Alpha
  • [x] - Style (if applicable, think of cg_drawCrosshair - every value is a style)
  • [X] - Visible (Y/N) (all / background / border)

These generic parameters are simply adjusted in a HUD file, without needing a cvar.

Some things to consider:

  • [X] - Each HUD element should have a clear anchor point, preferably in the very top-left of the element (with some exceptions such as chat and popups which make more sense to have it at bottom left due to them expanding upwards vertically). When resized, the top/bottom left should stay exactly where it is, unlike now with certain HUD elements
  • [X] - Before getting rid of the generic X/Y etc cvars for current HUD elements, we need to have an easy way for players to customize these settings -> we need at least partially working HUD editor in-game
  • [ ] - Transitioning to this new HUD system for players should be made as easy as possible, possibly write some sort of HUD converter?

All related cvars

Print in console, create HUD element ? :
cl_showmouserate 
cl_showTimeDelta
cl_showSend
cl_showServerCommands 
cl_shownuments
cl_shownet
showdrop
showpackets

Create HUDs elements for shoutcast ?
cg_shoutcastGrenadeTrail
cg_shoutcastDrawHealth
cg_shoutcastDrawTeamNames
cg_shoutcastDrawPlayers

Create an HUD element for console ? 
con_numNotifies

Migrate to chat style ?
cg_voiceChats
cg_voiceText
cg_teamChatsOnly

Migrate to fireteam style ?
cg_fireteamNameAlign
cg_fireteamNameMaxChars

Create a field for range values ?
cg_automapzoom
cg_bannerTime 
cg_centertime
cg_numPopups
cg_popupTime --> there are 3 tempo for popup ...
cg_popupfadetime --> there are 3 tempo for popup ...
cg_popupstaytime --> there are 3 tempo for popup ...
cg_teamChatHeight
cg_teamChatTime

Not migrable cvars

cg_altHud --> can't be migrated for obvious reason
cg_announcer --> sound aren't part of HUD
cg_antilag --> in-game graphic for bullet tracer, not HUD element
cg_countryflags --> part of the scoreboard which is not an HUD element
cg_draw2D --> can't be migrated for obvious reason
cg_drawCrosshairPickups --> in-game graphic, not HUD element
cg_drawEnvAwareness --> not part of HUD element
cg_drawNotifyText --> not part of HUD element
cg_drawTeamOverlay (not used, kept for compatibility)
cg_drawUnit --> used by env awareness, which is used as in game graphic not HUD
cg_drawStatus --> used for menu debugs, not only part of HUD element
cg_drawSpectatorNames --> used in demo, shoutcast and more
cg_fireteamSprites --> in-game graphic, not HUD element
cg_fontscalesp --> this font isn't used for HUD element
cg_locationmaxchars --> used in different HUD elements
cg_popupLimboMenu --> (not used, kept for compatibility)
cg_predictItems --> not part of HUD element
cg_printObjectiveInfo --> not part of HUD element
cg_quickMessageAlt --> in-game voice chat menu, not part of HUD element
cg_railTrailTime -->in-game graphic, not HUD element
cg_scoreboard --> not an HUD elements
cg_scopedSensitivityScaler --> control in-game zoom behaviour, not HUD 
cg_sharetimerText --> will not be migrated (too complexe)
cg_shoutcastTeamNameRed --> will not be migrated (too complexe)
cg_shoutcastTeamNameBlue --> will not be migrated (too complexe)
cg_simpleItems --> in-game graphic, not HUD element
cg_simpleItemsScale --> in-game graphic, not HUD element
cg_teamChatMention --> used by chat in debriefing, can't be move
cg_visualEffects --> in-game graphic, not HUD element
cg_voiceSpriteTime --> in-game graphic, not HUD element

Removed cvars

cg_althudflags
cg_chatalpha
cg_chatBackgroundAlpha
cg_chatflags
cg_chatLineWidth
cg_chatScale
cg_chatShadow
cg_chatY
cg_chatX
cg_complaintPopUp 
cg_crosshairAlphaAlt
cg_crosshairColorAlt 
cg_crosshairAlpha
cg_crosshairColor
cg_crosshairHealth
cg_crosshairPulse
cg_crosshairSize
cg_crosshairX
cg_crosshairY
cg_cursorHints
cg_descriptiveText
cg_drawBuddies
cg_drawCompass
cg_drawCompassIcons
cg_drawCrosshairInfo
cg_drawCrosshairNames
cg_drawFireteamOverlay
cg_drawFPS
cg_drawPing
cg_drawReinforcementTime
cg_drawRoundTimer
cg_drawSnapshot
cg_drawSmallPopupIcons
cg_drawSpreadScale
cg_drawspeed
cg_drawTime
cg_drawWeaponIconFlash 
cg_fireteamAlpha
cg_fireteamBgAlpha
cg_fireteamlatchedclass
cg_fireteamLocationAlign
cg_fontScaleCN
cg_fontScaleCP
cg_fontScaleTP
cg_graphicObituaries
cg_healthDynamicColor
cg_lagometer
cg_popupBigFilter
cg_popupFilter
cg_popupShadow
cg_shoutcastDrawMinimap

HUD elements that are currently not customizable:

All done

Current components:

compass         
staminabar      
breathbar       
healthbar       
weaponchargebar 
healthtext      
xptext          
ranktext        
statsdisplay    
weaponicon      
weaponammo      
fireteam        
popupmessages   
powerups        
objectives      
hudhead         
cursorhints     
weaponstability 
livesleft       
roundtimer      
reinforcement   
spawntimer      
localtime       
votetext        
spectatortext   
limbotext       
followtext      
demotext        
missilecamera   
sprinttext      
breathtext      
weaponchargetext
fps             
snapshot        
ping            
speed           
lagometer       
disconnect      
chat			
spectatorstatus 
pmitemsbig      
warmuptitle     
warmuptext      
objectivetext   
centerprint     
banner
crosshair    
crosshairtext
crosshairbar 

Element specific features

  • [x] - Blinking / fade
  • [X] - Disable background

Individual characteristics of each component(new list that includes the not yet customizable elements):

  • Staminabar
  • [x] - Orientation: horizonatal / vertical
  • [x] - Color
  • [x] - Color-gradient
  • [x] - Transparancy
  • [X] - Additional % indicator (new/diff comp)
  • to be added

Software to be considered

  • janson/jasmine/JKG implementation
    • https://github.com/JKGDevs/JediKnightGalaxies/blob/master/JKGalaxies/ext_data/weapons/rifle_0_E-11_Rifle.wpn
    • https://github.com/JKGDevs/JediKnightGalaxies/blob/master/codemp/cgame/cg_weapons.cpp
  • https://playmorepromode.com/guides/cpma-super-hud

Helldembez avatar Apr 24 '22 18:04 Helldembez

for inspiration here is sample HUD file from Q3 CPMA:


!DEFAULT
{
	color 1 1 1 1
	fontsize 8 12
	font cpma
	textstyle 1
}

Console
{
	rect 0 0 640 48
	#monospace
	time 3000
	font threewave
}

WeaponList
{
	rect 0 64 48 16
	color 0.2 0.2 0.7 0.75
	font id
	fontsize 12 16
}


StatusBar_HealthIcon
{
	rect 200 448 24 24
	image "models/players/mynx/icon_pm.tga"
}

StatusBar_HealthCount
{
	rect 240 448 48 24
	font idblock
	fontsize 16 24
	textalign R
}



StatusBar_ArmorIcon
{
	rect 420 448 24 24
}

StatusBar_ArmorCount
{
	rect 352 448 32 32
	font idblock
	fontsize 16 24
}



FPS
{
	rect 0 0 640 12
	color 1 1 1 0.5
	textalign R
}


GameTime
{
	rect 0 16 640 16
	font id
	fontsize 12 16
	textalign R
	monospace
}


GameType
{
	rect 0 16 640 24
	fontsize 20 
	textalign C
	color 1 1 0.5 1
}


WarmupInfo
{
	rect 0 40 640 24
	fontsize 16
	textalign C
}


FollowMessage
{
	rect 0 466 640 12
	textalign C
}


SpecMessage
{
	rect 0 80 640 16
	fontsize 12 16
	textalign C
}


FragMessage
{
	rect 0 80 640 16
	fontsize 12 16
	textalign C
	time 1500
	fade 1 1 1 0.5
}


RankMessage
{
	rect 0 96 640 12
	textalign C
	time 1500
	fade 1 1 1 0.5
}


#PlayerSpeed
#{
#	rect 0 386 640 12
#	color 1 1 1 0.5
#	textalign R
#}


ItemPickup
{
	rect 24 384 640 16
	fontsize 12 16
	time 1500
	#fade 1 1 1 0.5
}


ItemPickupIcon
{
	rect 0 384 16 16
	time 1500
	# fading an image requires an alpha channel which the icons don't have  >:(
	#fade 1 1 1 0.5
}


TargetName
{
	rect 0 256 640 12
	textalign C
	time 500
}

TargetStatus
{
	rect 0 268 640 12
	textalign C
	time 500
	color 0.5 1 1 1
}


Chat1 { rect 0 372 640 12; time 3000; }
Chat2 { rect 0 360 640 12; time 3000; }
Chat3 { rect 0 348 640 12; time 3000; }
Chat4 { rect 0 336 640 12; time 3000; }
Chat5 { rect 0 324 640 12; time 3000; }
Chat6 { rect 0 312 640 12; time 3000; }
Chat7 { rect 0 300 640 12; time 3000; }
Chat8 { rect 0 288 640 12; time 3000; }


VoteMessageArena
{
	rect 0 60 640 16
	fontsize 12 16
	textalign C
}


VoteMessageWorld
{
	rect 0 76 640 16
	fontsize 12 16
	textalign C
	color 1 1 0 1
}


Score_Limit { rect 0 420 32 20; textalign R; fontsize 16 20; bgcolor 0.5 0.5 0.5 0.5; fill; }
Score_OWN   { rect 0 440 32 20; textalign R; fontsize 16 20; bgcolor 1 1 1 0.5; fill; }
Score_NME   { rect 0 460 32 20; textalign R; fontsize 16 20; bgcolor 0 1 0 0.5; fill; }


# that's all the DM stuff


!DEFAULT { bgcolor 0.5 0.5 0.5 0.5; textalign R; }
Team1 { rect 0 372 640 12; monospace; }
Team2 { rect 0 360 640 12; monospace; }
Team3 { rect 0 348 640 12; monospace; }
Team4 { rect 0 336 640 12; monospace; }
Team5 { rect 0 324 640 12; monospace; }
Team6 { rect 0 312 640 12; monospace; }
Team7 { rect 0 300 640 12; monospace; }
Team8 { rect 0 288 640 12; monospace; }
!DEFAULT { bgcolor 0 0 0 0; textalign L; }


# PowerUp1_Icon is also used for the O/D indicator in CTFS

PowerUp1_Icon { rect 608 264 32 32; }
PowerUp1_Time { rect 544 264 64 32; textalign R; fontsize 24 32; }

PowerUp2_Icon { rect 608 232 32 32; }
PowerUp2_Time { rect 544 232 64 32; textalign R; fontsize 24 32; }

PowerUp3_Icon { rect 608 200 32 32; }
PowerUp3_Time { rect 544 200 64 32; textalign R; fontsize 24 32; }

PowerUp4_Icon { rect 608 168 32 32; }
PowerUp4_Time { rect 544 168 64 32; textalign R; fontsize 24 32; }


FlagStatus_OWN { rect 608 400 32 32; color 1 1 1 1; }
FlagStatus_NME { rect 568 400 32 32; color 0 1 0 1; }


TeamCount_OWN { rect 620 40 20 20; bgcolor 0.5 0.5 0.5 0.5; fill; fontsize 12 16; }
TeamIcon_OWN  { rect 600 40 20 20; bgcolor 0.5 0.5 0.5 0.5; fill; image "models/players/mynx/icon_pm.tga"; }
TeamCount_NME { rect 620 64 20 20; bgcolor 0.5 0.5 0.5 0.5; fill; fontsize 12 16; }
TeamIcon_NME  { rect 600 64 20 20; bgcolor 0.5 0.5 0.5 0.5; fill; image "models/players/sarge/icon_pm.tga"; }

https://playmorepromode.com/guides/cpma-super-hud

mittermichal avatar Apr 25 '22 08:04 mittermichal

Alright, there is what has been so far :

Components :

  • All HUD components are accessible for modification
  • Current storage system is an extention of the existing one (more field in the hud file)
  • Each component use a specific callback which may call a generic function (mainly for text comp) called CG_DrawCompText and CG_DrawCompMultilineText.

HUD Editor :

  • All elements are available in the editor, selectable by click on it or from drop box
  • All the currents parameters are mutable through editor panel and by mouse / keyboard manipulation
  • Help panel available (toogable)
  • Basic HUD storage function available (clone / save / delete)
  • Deep selection by mouse possible
  • ...

TO DO:

  • [x] Clear cvars
  • [x] Add more parameters for components (Style, align, font ...)
  • [x] Clear UI menus option from all unused cvar
  • [x] Add shortcut to access HUD Editor from menu
  • [x] Enhanced editor panel cosmetics
  • [x] Merge CG_DrawCompText and CG_DrawCompMultilineText (and add fade handle ?)
  • [x] Transpose current hud.dat file to another format more userfriendly ?

Aranud avatar Jul 15 '22 12:07 Aranud