2012-11-26 18:58:24 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Doom 3 BFG Edition GPL Source Code
2012-11-28 15:47:07 +00:00
Copyright ( C ) 1993 - 2012 id Software LLC , a ZeniMax Media company .
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ( " Doom 3 BFG Edition Source Code " ) .
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code . If not , see < http : //www.gnu.org/licenses/>.
In addition , the Doom 3 BFG Edition Source Code is also subject to certain additional terms . You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code . If not , please request a copy in writing from id Software at the address below .
If you have questions concerning this license or the applicable additional terms , you may contact in writing id Software LLC , c / o ZeniMax Media Inc . , Suite 120 , Rockville , Maryland 20850 USA .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
# pragma hdrstop
2012-12-22 15:18:19 +00:00
# include "precompiled.h"
2012-11-26 18:58:24 +00:00
# include "../Game_local.h"
extern idCVar pm_stamina ;
extern idCVar in_useJoystick ;
extern idCVar flashlight_batteryDrainTimeMS ;
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : Initialize
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : Initialize ( idMenuHandler * data )
{
2012-11-26 18:58:24 +00:00
idMenuScreen : : Initialize ( data ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : ShowScreen
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ShowScreen ( const mainMenuTransition_t transitionType )
{
if ( menuData ! = NULL )
{
2012-11-26 18:58:24 +00:00
menuGUI = menuData - > GetGUI ( ) ;
}
2012-11-28 15:47:07 +00:00
if ( menuGUI = = NULL )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idSWFScriptObject & root = menuGUI - > GetRootObject ( ) ;
2012-11-26 18:58:24 +00:00
playerInfo = root . GetNestedObj ( " _bottomLeft " , " playerInfo " , " info " ) ;
stamina = root . GetNestedObj ( " _bottomLeft " , " stamina " ) ;
locationName = root . GetNestedText ( " _bottomLeft " , " location " , " txtVal " ) ;
tipInfo = root . GetNestedObj ( " _left " , " tip " ) ;
2012-11-28 15:47:07 +00:00
if ( playerInfo )
{
2012-11-26 18:58:24 +00:00
healthBorder = playerInfo - > GetNestedSprite ( " healthBorder " , " damage " ) ;
healthPulse = playerInfo - > GetNestedSprite ( " healthBorder " , " pulse " ) ;
armorFrame = playerInfo - > GetNestedSprite ( " armorFrame " ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Security Update
security = root . GetNestedSprite ( " _center " , " security " ) ;
securityText = root . GetNestedText ( " _center " , " security " , " info " , " txtVal " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// PDA Download
newPDADownload = root . GetNestedSprite ( " _center " , " pdaDownload " ) ;
newPDAName = root . GetNestedText ( " _center " , " pdaDownload " , " info " , " txtName " ) ;
newPDAHeading = root . GetNestedText ( " _center " , " pdaDownload " , " info " , " txtHeading " ) ;
newPDA = root . GetNestedSprite ( " _bottomLeft " , " newPDA " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Video Download
newVideoDownload = root . GetNestedSprite ( " _center " , " videoDownload " ) ;
newVideoHeading = root . GetNestedText ( " _center " , " videoDownload " , " info " , " txtHeading " ) ;
newVideo = root . GetNestedSprite ( " _bottomLeft " , " newVideo " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Audio Log
audioLog = root . GetNestedSprite ( " _bottomLeft " , " audioLog " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Radio Communication
communication = root . GetNestedSprite ( " _bottomLeft " , " communication " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Oxygen
oxygen = root . GetNestedSprite ( " _bottomLeft " , " oxygen " ) ;
flashlight = root . GetNestedSprite ( " _bottomLeft " , " flashlight " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Objective
objective = root . GetNestedSprite ( " _right " , " objective " ) ;
objectiveComplete = root . GetNestedSprite ( " _right " , " objectiveComplete " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Ammo Info
ammoInfo = root . GetNestedSprite ( " _bottomRight " , " ammoInfo " ) ;
bsInfo = root . GetNestedSprite ( " _bottomRight " , " bsInfo " ) ;
soulcubeInfo = root . GetNestedSprite ( " _bottomRight " , " soulcube " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// If the player loaded a save with enough souls to use the cube, the icon wouldn't show. We're setting this flag in idPlayer::Restore so we can show the cube after loading a game
2012-11-28 15:47:07 +00:00
if ( showSoulCubeInfoOnLoad = = true )
{
2012-11-26 18:58:24 +00:00
showSoulCubeInfoOnLoad = false ;
UpdateSoulCube ( true ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Weapon pills
weaponPills = root . GetNestedObj ( " _bottomRight " , " weaponState " ) ;
weaponImg = root . GetNestedSprite ( " _bottomRight " , " weaponIcon " ) ;
weaponName = root . GetNestedObj ( " _bottomRight " , " weaponName " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Pickup Info
newWeapon = root . GetNestedSprite ( " _center " , " newWeapon " ) ;
pickupInfo = root . GetNestedSprite ( " _bottomLeft " , " pickupInfo " ) ;
newItem = root . GetNestedSprite ( " _left " , " newItem " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Cursors
talkCursor = root . GetNestedSprite ( " _center " , " crosshairTalk " ) ;
combatCursor = root . GetNestedSprite ( " _center " , " crosshairCombat " ) ;
grabberCursor = root . GetNestedSprite ( " _center " , " crosshairGrabber " ) ;
respawnMessage = root . GetNestedSprite ( " _center " , " respawnMessage " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// MP OBJECTS
mpInfo = root . GetNestedSprite ( " _top " , " mp_info " ) ;
mpHitInfo = root . GetNestedSprite ( " _bottom " , " hitInfo " ) ;
mpTime = root . GetNestedText ( " _top " , " mp_info " , " txtTime " ) ;
mpMessage = root . GetNestedText ( " _top " , " mp_info " , " txtInfo " ) ;
mpWeapons = root . GetNestedObj ( " _bottom " , " mpWeapons " ) ;
mpChatObject = root . GetNestedSprite ( " _left " , " mpChat " ) ;
mpConnection = root . GetNestedSprite ( " _center " , " connectionMsg " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Functions
2012-11-28 15:47:07 +00:00
class idTriggerNewPDAOrVideo : public idSWFScriptFunction_RefCounted
{
2012-11-26 18:58:24 +00:00
public :
2012-11-28 15:47:07 +00:00
idTriggerNewPDAOrVideo ( idMenuScreen_HUD * _screen ) :
screen ( _screen )
{
}
idSWFScriptVar Call ( idSWFScriptObject * thisObject , const idSWFParmList & parms )
{
if ( screen = = NULL )
{
return idSWFScriptVar ( ) ;
}
if ( parms . Num ( ) ! = 1 )
{
return idSWFScriptVar ( ) ;
}
bool pdaDownload = parms [ 0 ] . ToBool ( ) ;
if ( pdaDownload )
{
screen - > ToggleNewPDA ( true ) ;
}
else
{
screen - > ToggleNewVideo ( true ) ;
}
return idSWFScriptVar ( ) ;
}
2012-11-26 18:58:24 +00:00
private :
2012-11-28 15:47:07 +00:00
idMenuScreen_HUD * screen ;
2012-11-26 18:58:24 +00:00
} ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
menuGUI - > SetGlobal ( " toggleNewNotification " , new idTriggerNewPDAOrVideo ( this ) ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : HideScreen
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : HideScreen ( const mainMenuTransition_t transitionType )
{
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : Update
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : Update ( )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
idPlayer * player = gameLocal . GetLocalPlayer ( ) ;
if ( player = = NULL )
{
2012-11-26 18:58:24 +00:00
return ;
}
idMenuScreen : : Update ( ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateHealth
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateHealthArmor ( idPlayer * player )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! playerInfo | | ! player )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( common - > IsMultiplayer ( ) )
{
2012-11-26 18:58:24 +00:00
playerInfo - > GetSprite ( ) - > SetYPos ( 20.0f ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
playerInfo - > GetSprite ( ) - > SetYPos ( 0.0f ) ;
}
2012-11-28 15:47:07 +00:00
idSWFTextInstance * txtVal = playerInfo - > GetNestedText ( " health " , " txtVal " ) ;
if ( txtVal ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtVal - > SetText ( va ( " %d " , player - > health ) ) ;
txtVal - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// Set the damage color
swfColorRGBA_t color ;
color . r = 255 ;
color . a = 255 ;
uint8 gbColor ;
2012-11-28 15:47:07 +00:00
if ( player - > health > 60 )
{
2012-11-26 18:58:24 +00:00
gbColor = 255 ;
2012-11-28 15:47:07 +00:00
}
else if ( player - > health > 30 )
{
2012-11-26 18:58:24 +00:00
gbColor = 156 ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
gbColor = 0 ;
}
color . g = gbColor ;
color . b = gbColor ;
txtVal - > color = color ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
txtVal = playerInfo - > GetNestedText ( " armor " , " txtVal " ) ;
2012-11-28 15:47:07 +00:00
if ( txtVal ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtVal - > SetText ( va ( " %d " , player - > inventory . armor ) ) ;
txtVal - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
2012-11-28 15:47:07 +00:00
if ( armorFrame ! = NULL )
{
if ( player - > inventory . armor = = 0 )
{
2012-11-26 18:58:24 +00:00
armorFrame - > StopFrame ( 2 ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
armorFrame - > StopFrame ( 1 ) ;
}
}
}
2012-11-28 15:47:07 +00:00
if ( healthBorder ! = NULL )
{
2012-11-26 18:58:24 +00:00
healthBorder - > StopFrame ( 100 - player - > health + 1 ) ;
}
2012-11-28 15:47:07 +00:00
if ( healthPulse ! = NULL )
{
if ( player - > healthPulse )
{
2012-11-26 18:58:24 +00:00
player - > StartSound ( " snd_healthpulse " , SND_CHANNEL_ITEM , 0 , false , NULL ) ;
player - > healthPulse = false ;
healthPulse - > SetVisible ( true ) ;
healthPulse - > PlayFrame ( " rollOn " ) ;
}
2012-11-28 15:47:07 +00:00
if ( player - > healthTake )
{
2012-11-26 18:58:24 +00:00
player - > StartSound ( " snd_healthtake " , SND_CHANNEL_ITEM , 0 , false , NULL ) ;
player - > healthTake = false ;
healthPulse - > SetVisible ( true ) ;
healthPulse - > PlayFrame ( " rollOn " ) ;
}
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateStamina
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateStamina ( idPlayer * player )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! stamina | | ! player )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * stamSprite = stamina - > GetSprite ( ) ;
if ( stamSprite ! = NULL )
{
if ( common - > IsMultiplayer ( ) )
{
2012-11-26 18:58:24 +00:00
stamSprite - > SetVisible ( false ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
float max_stamina = pm_stamina . GetFloat ( ) ;
2012-11-28 15:47:07 +00:00
if ( ! max_stamina )
{
2012-11-26 18:58:24 +00:00
stamSprite - > SetVisible ( false ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
stamSprite - > SetVisible ( true ) ;
float staminaPercent = idMath : : Ftoi ( 100.0f * player - > stamina / max_stamina ) ;
stamSprite - > StopFrame ( staminaPercent + 1 ) ;
}
}
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateLocation
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateWeaponInfo ( idPlayer * player )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! player | | ! ammoInfo )
{
2012-11-26 18:58:24 +00:00
return ;
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
idEntityPtr < idWeapon > weapon = player - > weapon ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
assert ( weapon . GetEntity ( ) ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int inClip = weapon . GetEntity ( ) - > AmmoInClip ( ) ;
int ammoAmount = weapon . GetEntity ( ) - > AmmoAvailable ( ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
//Make sure the hud always knows how many bloodstone charges there are
int ammoRequired ;
int bloodstoneAmmo = 0 ;
2012-11-28 15:47:07 +00:00
if ( player - > weapon_bloodstone > = 0 )
{
2012-11-26 18:58:24 +00:00
ammo_t ammo_i = player - > inventory . AmmoIndexForWeaponClass ( " weapon_bloodstone_passive " , & ammoRequired ) ;
bloodstoneAmmo = player - > inventory . HasAmmo ( ammo_i , ammoRequired ) ;
}
2012-11-28 15:47:07 +00:00
if ( bsInfo )
{
if ( bloodstoneAmmo > 0 )
{
2012-11-26 18:58:24 +00:00
bsInfo - > SetVisible ( true ) ;
bsInfo - > StopFrame ( bloodstoneAmmo + 1 ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
bsInfo - > SetVisible ( false ) ;
}
}
2012-11-28 15:47:07 +00:00
if ( ammoAmount = = - 1 | | player - > GetCurrentWeaponSlot ( ) = = player - > weapon_bloodstone | | player - > GetCurrentWeaponSlot ( ) = = player - > weapon_soulcube )
{
2012-11-26 18:58:24 +00:00
ammoInfo - > SetVisible ( false ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
idStr totalAmmo ;
idStr playerAmmo ;
idStr playerClip ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
bool showClip = true ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
//Hack to stop the bloodstone ammo to display when it is being activated
2012-11-28 15:47:07 +00:00
if ( ! weapon . GetEntity ( ) - > IsReady ( ) )
{
2012-11-26 18:58:24 +00:00
// show infinite ammo
2012-11-28 15:47:07 +00:00
playerAmmo = " " ;
2012-11-26 18:58:24 +00:00
totalAmmo = " " ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
// show remaining ammo
totalAmmo = va ( " %i " , ammoAmount ) ;
playerAmmo = weapon . GetEntity ( ) - > ClipSize ( ) ? va ( " %i " , inClip ) : " -- " ; // how much in the current clip
playerClip = weapon . GetEntity ( ) - > ClipSize ( ) ? va ( " %i " , ammoAmount / weapon . GetEntity ( ) - > ClipSize ( ) ) : " -- " ;
//allAmmo = va( "%i/%i", inClip, ammoAmount );
2012-11-28 15:47:07 +00:00
}
if ( ! weapon . GetEntity ( ) - > ClipSize ( ) )
{
2012-11-26 18:58:24 +00:00
showClip = false ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
bool ammoEmpty = ( ammoAmount = = 0 ) ;
bool clipEmpty = ( weapon . GetEntity ( ) - > ClipSize ( ) ? inClip = = 0 : false ) ;
bool clipLow = ( weapon . GetEntity ( ) - > ClipSize ( ) ? inClip < = weapon . GetEntity ( ) - > LowAmmo ( ) : false ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
//Hack to stop the bloodstone ammo to display when it is being activated
2012-11-28 15:47:07 +00:00
if ( player - > GetCurrentWeaponSlot ( ) = = player - > weapon_bloodstone )
{
2012-11-26 18:58:24 +00:00
ammoEmpty = false ;
clipEmpty = false ;
clipLow = false ;
}
2012-11-28 15:47:07 +00:00
if ( showClip )
{
2012-11-26 18:58:24 +00:00
ammoInfo - > SetVisible ( true ) ;
ammoInfo - > StopFrame ( 1 ) ;
2012-11-28 15:47:07 +00:00
if ( common - > IsMultiplayer ( ) )
{
2012-11-26 18:58:24 +00:00
ammoInfo - > SetYPos ( 20.0f ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
ammoInfo - > SetYPos ( 0.0f ) ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * txtClipSprite = ammoInfo - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " clip " ) ;
idSWFSpriteInstance * clipLowSprite = ammoInfo - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " lowAmmo " ) ;
idSWFSpriteInstance * clipEmptySprite = ammoInfo - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " clipEmpty " ) ;
idSWFSpriteInstance * ammoEmptySprite = ammoInfo - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " noAmmo " ) ;
idSWFSpriteInstance * txtAmmoSprite = ammoInfo - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " ammoCount " ) ;
idSWFTextInstance * txtClip = ammoInfo - > GetScriptObject ( ) - > GetNestedText ( " info " , " clip " , " clipCount " , " txtVal " ) ;
idSWFTextInstance * txtAmmo = ammoInfo - > GetScriptObject ( ) - > GetNestedText ( " info " , " ammoCount " , " txtVal " ) ;
if ( txtClipSprite & & clipLowSprite & & clipEmptySprite )
{
if ( clipEmpty )
{
2012-11-26 18:58:24 +00:00
clipLowSprite - > SetVisible ( false ) ;
clipEmptySprite - > SetVisible ( true ) ;
txtClipSprite - > StopFrame ( 3 ) ;
2012-11-28 15:47:07 +00:00
}
else if ( clipLow )
{
2012-11-26 18:58:24 +00:00
clipLowSprite - > SetVisible ( true ) ;
clipEmptySprite - > SetVisible ( false ) ;
txtClipSprite - > StopFrame ( 2 ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
clipLowSprite - > SetVisible ( false ) ;
clipEmptySprite - > SetVisible ( false ) ;
txtClipSprite - > StopFrame ( 1 ) ;
}
2012-11-28 15:47:07 +00:00
if ( txtClip ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtClip - > SetText ( playerAmmo ) ;
txtClip - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
}
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( txtAmmo ! = NULL )
{
if ( ammoEmptySprite & & txtAmmoSprite )
{
if ( ammoEmpty )
{
2012-11-26 18:58:24 +00:00
ammoEmptySprite - > SetVisible ( true ) ;
txtAmmoSprite - > StopFrame ( 2 ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
ammoEmptySprite - > SetVisible ( false ) ;
txtAmmoSprite - > StopFrame ( 1 ) ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
txtAmmo - > SetText ( totalAmmo ) ;
txtAmmo - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
ammoInfo - > SetVisible ( true ) ;
ammoInfo - > StopFrame ( 2 ) ;
2012-11-28 15:47:07 +00:00
if ( common - > IsMultiplayer ( ) )
{
2012-11-26 18:58:24 +00:00
ammoInfo - > SetYPos ( 20.0f ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
ammoInfo - > SetYPos ( 0.0f ) ;
}
2012-11-28 15:47:07 +00:00
idSWFTextInstance * txtAmmo = ammoInfo - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtVal " ) ;
if ( txtAmmo ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtAmmo - > SetText ( totalAmmo ) ;
txtAmmo - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : GiveWeapon
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : GiveWeapon ( idPlayer * player , int weaponIndex )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( common - > IsMultiplayer ( ) )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
const char * weapnum = va ( " def_weapon%d " , weaponIndex ) ;
const char * weap = player - > spawnArgs . GetString ( weapnum ) ;
2012-12-11 22:48:55 +00:00
if ( weap ! = NULL & & * weap ! = ' \0 ' )
2012-11-28 15:47:07 +00:00
{
const idDeclEntityDef * weaponDef = gameLocal . FindEntityDef ( weap , false ) ;
if ( weaponDef ! = NULL )
{
const char * hudIconName = weaponDef - > dict . GetString ( " hudIcon " ) ;
if ( hudIconName [ 0 ] = = ' \0 ' )
{
2012-11-26 18:58:24 +00:00
idLib : : Warning ( " idMenuScreen_HUD: Missing hudIcon for weapon %s " , weap ) ;
return ;
}
2012-11-28 15:47:07 +00:00
const idMaterial * hudIcon = declManager - > FindMaterial ( hudIconName , false ) ;
if ( newWeapon ! = NULL )
{
2012-11-26 18:58:24 +00:00
newWeapon - > SetVisible ( true ) ;
newWeapon - > PlayFrame ( 2 ) ;
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * topImg = newWeapon - > GetScriptObject ( ) - > GetNestedSprite ( " topImg " ) ;
idSWFSpriteInstance * botImg = newWeapon - > GetScriptObject ( ) - > GetNestedSprite ( " botImg " ) ;
if ( topImg & & botImg )
{
2012-11-26 18:58:24 +00:00
topImg - > SetMaterial ( hudIcon ) ;
botImg - > SetMaterial ( hudIcon ) ;
}
}
}
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateWeaponStates
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdatePickupInfo ( int index , const idStr & name )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! pickupInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idSWFTextInstance * txtItem = pickupInfo - > GetScriptObject ( ) - > GetNestedText ( va ( " item%d " , index ) , " txtVal " ) ;
if ( txtItem ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtItem - > SetText ( name ) ;
txtItem - > SetStrokeInfo ( true , 0.6f , 2.0f ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : IsPickupListReady
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idMenuScreen_HUD : : IsPickupListReady ( )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! pickupInfo )
{
2012-11-26 18:58:24 +00:00
return false ;
}
2012-11-28 15:47:07 +00:00
if ( pickupInfo - > GetCurrentFrame ( ) = = 1 )
{
2012-11-26 18:58:24 +00:00
return true ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
return false ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateWeaponStates
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ShowPickups ( )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! pickupInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
pickupInfo - > SetVisible ( true ) ;
pickupInfo - > PlayFrame ( " rollOn " ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : SetCursorState
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : SetCursorState ( idPlayer * player , cursorState_t state , int set )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
switch ( state )
{
case CURSOR_TALK :
{
2012-11-26 18:58:24 +00:00
cursorNone = 0 ;
cursorTalking = set ;
break ;
}
2012-11-28 15:47:07 +00:00
case CURSOR_IN_COMBAT :
{
2012-11-26 18:58:24 +00:00
cursorNone = 0 ;
cursorInCombat = set ;
break ;
}
2012-11-28 15:47:07 +00:00
case CURSOR_ITEM :
{
2012-11-26 18:58:24 +00:00
cursorNone = 0 ;
cursorItem = set ;
break ;
2012-11-28 15:47:07 +00:00
}
case CURSOR_GRABBER :
{
2012-11-26 18:58:24 +00:00
cursorNone = 0 ;
cursorGrabber = set ;
break ;
}
2012-11-28 15:47:07 +00:00
case CURSOR_NONE :
{
2012-11-26 18:58:24 +00:00
// so that talk button still appears for 3D view
2012-11-28 15:47:07 +00:00
if ( cursorState ! = CURSOR_TALK | | cursorTalking ! = 1 )
{
2012-11-26 18:58:24 +00:00
cursorTalking = 0 ;
cursorGrabber = 0 ;
cursorInCombat = 0 ;
cursorItem = 0 ;
cursorNone = 1 ;
}
break ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : SetCursorText
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : SetCursorText ( const idStr & action , const idStr & focus )
{
2012-11-26 18:58:24 +00:00
cursorAction = action ;
cursorFocus = focus ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : CombatCursorFlash
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : CombatCursorFlash ( )
{
if ( cursorInCombat )
{
if ( cursorState = = CURSOR_IN_COMBAT )
{
if ( combatCursor )
{
2012-11-26 18:58:24 +00:00
combatCursor - > PlayFrame ( " hit " ) ;
}
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateCursorState
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateCursorState ( )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! cursorTalking & & ! cursorInCombat & & ! cursorGrabber & & ! cursorItem )
{
2012-11-26 18:58:24 +00:00
cursorNone = true ;
cursorState = CURSOR_NONE ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// hide all cursors
2012-11-28 15:47:07 +00:00
if ( combatCursor )
{
2012-11-26 18:58:24 +00:00
combatCursor - > StopFrame ( 1 ) ;
combatCursor - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
if ( talkCursor )
{
2012-11-26 18:58:24 +00:00
talkCursor - > StopFrame ( 1 ) ;
talkCursor - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
if ( grabberCursor )
{
2012-11-26 18:58:24 +00:00
grabberCursor - > StopFrame ( 1 ) ;
grabberCursor - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
}
else
{
if ( cursorTalking )
{
if ( cursorTalking = = 1 ) // ready to talk
{
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
else if ( cursorTalking = = 2 ) // already talking / busy
{
}
if ( cursorState ! = CURSOR_TALK )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( combatCursor )
{
2012-11-26 18:58:24 +00:00
combatCursor - > StopFrame ( 1 ) ;
combatCursor - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
if ( grabberCursor )
{
2012-11-26 18:58:24 +00:00
grabberCursor - > StopFrame ( 1 ) ;
grabberCursor - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// play roll on
2012-11-28 15:47:07 +00:00
if ( talkCursor )
{
2012-11-26 18:58:24 +00:00
talkCursor - > SetVisible ( true ) ;
talkCursor - > PlayFrame ( 2 ) ;
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * topBacking = talkCursor - > GetScriptObject ( ) - > GetNestedSprite ( " backing " , " topBar " ) ;
idSWFSpriteInstance * bottomBacking = talkCursor - > GetScriptObject ( ) - > GetNestedSprite ( " backing " , " botBar " ) ;
idSWFTextInstance * txtAction = talkCursor - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtAction " ) ;
idSWFTextInstance * txtFocus = talkCursor - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtFocus " ) ;
idSWFTextInstance * txtPrompt = talkCursor - > GetScriptObject ( ) - > GetNestedText ( " talkPrompt " , " txtPrompt " ) ;
if ( txtAction )
{
if ( ! in_useJoystick . GetBool ( ) )
{
2012-11-26 18:58:24 +00:00
txtAction - > tooltip = true ;
keyBindings_t bind = idKeyInput : : KeyBindingsFromBinding ( " _use " , true ) ;
idStr actionText = idLocalization : : GetString ( cursorAction ) ;
2012-11-28 15:47:07 +00:00
if ( ! bind . mouse . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
actionText . Append ( " [ " ) ;
actionText . Append ( bind . mouse ) ;
actionText . Append ( " ] " ) ;
2012-11-28 15:47:07 +00:00
}
else if ( ! bind . keyboard . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
actionText . Append ( " [ " ) ;
actionText . Append ( bind . keyboard ) ;
actionText . Append ( " ] " ) ;
}
txtAction - > SetText ( actionText ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
txtAction - > tooltip = false ;
txtAction - > SetText ( cursorAction ) ;
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
txtAction - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
float actionLength = txtAction - > GetTextLength ( ) ;
2012-11-28 15:47:07 +00:00
if ( topBacking )
{
if ( ! cursorAction . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
topBacking - > SetXPos ( actionLength ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
topBacking - > SetXPos ( - 75.0f ) ;
}
}
}
2012-11-28 15:47:07 +00:00
if ( txtFocus )
{
2012-11-26 18:58:24 +00:00
txtFocus - > SetText ( cursorFocus ) ;
txtFocus - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
float focusLength = txtFocus - > GetTextLength ( ) ;
2012-11-28 15:47:07 +00:00
if ( bottomBacking )
{
if ( ! cursorFocus . IsEmpty ( ) )
{
2012-11-26 18:58:24 +00:00
bottomBacking - > SetXPos ( focusLength ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
bottomBacking - > SetXPos ( - 75.0f ) ;
}
}
}
2012-11-28 15:47:07 +00:00
if ( txtPrompt )
{
if ( in_useJoystick . GetBool ( ) )
{
2012-11-26 18:58:24 +00:00
txtPrompt - > tooltip = true ;
txtPrompt - > SetText ( " _use " ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
txtPrompt - > tooltip = false ;
txtPrompt - > SetText ( " " ) ;
}
}
}
cursorState = CURSOR_TALK ;
}
2012-11-28 15:47:07 +00:00
}
else if ( cursorGrabber )
{
if ( talkCursor )
{
2012-11-26 18:58:24 +00:00
talkCursor - > StopFrame ( 1 ) ;
talkCursor - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
if ( combatCursor )
{
2012-11-26 18:58:24 +00:00
combatCursor - > StopFrame ( 1 ) ;
combatCursor - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
if ( cursorState ! = CURSOR_GRABBER )
{
if ( grabberCursor )
{
2012-11-26 18:58:24 +00:00
grabberCursor - > SetVisible ( true ) ;
grabberCursor - > PlayFrame ( " loop " ) ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
cursorState = CURSOR_GRABBER ;
2012-11-28 15:47:07 +00:00
}
else if ( cursorItem )
{
2012-11-26 18:58:24 +00:00
cursorState = CURSOR_ITEM ;
2012-11-28 15:47:07 +00:00
}
else if ( cursorInCombat )
{
if ( cursorState = = CURSOR_TALK )
{
if ( talkCursor )
{
2012-11-26 18:58:24 +00:00
talkCursor - > StopFrame ( 1 ) ;
talkCursor - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
if ( combatCursor )
{
2012-11-26 18:58:24 +00:00
combatCursor - > SetVisible ( true ) ;
combatCursor - > PlayFrame ( " rollOn " ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// play cursor roll on
2012-11-28 15:47:07 +00:00
}
else if ( cursorState ! = CURSOR_IN_COMBAT )
{
if ( grabberCursor )
{
2012-11-26 18:58:24 +00:00
grabberCursor - > StopFrame ( 1 ) ;
grabberCursor - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
// set cursor visible
2012-11-28 15:47:07 +00:00
if ( combatCursor )
{
2012-11-26 18:58:24 +00:00
combatCursor - > SetVisible ( true ) ;
combatCursor - > StopFrame ( 2 ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
cursorState = CURSOR_IN_COMBAT ;
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateSoulCube
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateSoulCube ( bool ready )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! soulcubeInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( ready & & ! soulcubeInfo - > IsVisible ( ) )
{
2012-11-26 18:58:24 +00:00
soulcubeInfo - > SetVisible ( true ) ;
soulcubeInfo - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
}
else if ( ! ready )
{
2012-11-26 18:58:24 +00:00
soulcubeInfo - > PlayFrame ( " rollOff " ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : ShowRespawnMessage
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ShowRespawnMessage ( bool show )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! respawnMessage )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( show )
{
2012-11-26 18:58:24 +00:00
respawnMessage - > SetVisible ( true ) ;
respawnMessage - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
idSWFTextInstance * message = respawnMessage - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtMessage " ) ;
if ( message ! = NULL )
{
2012-11-26 18:58:24 +00:00
message - > tooltip = true ;
message - > SetText ( " #str_respawn_message " ) ;
message - > SetStrokeInfo ( true ) ;
}
2012-11-28 15:47:07 +00:00
}
else
{
if ( respawnMessage - > IsVisible ( ) )
{
2012-11-26 18:58:24 +00:00
respawnMessage - > PlayFrame ( " rollOff " ) ;
}
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateWeaponStates
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateWeaponStates ( idPlayer * player , bool weaponChanged )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! weaponPills )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( player = = NULL )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idStr displayName ;
2012-11-28 15:47:07 +00:00
if ( common - > IsMultiplayer ( ) )
{
if ( ! mpWeapons | | player - > GetIdealWeapon ( ) = = 0 )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
weaponPills - > GetSprite ( ) - > SetVisible ( false ) ;
2012-11-28 15:47:07 +00:00
if ( weaponChanged )
{
2012-11-26 18:58:24 +00:00
mpWeapons - > GetSprite ( ) - > SetVisible ( true ) ;
mpWeapons - > GetSprite ( ) - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int weaponDefIndex = - 1 ;
idList < idStr > weaponDefNames ;
// start at 1 so we skip the fists
2012-11-28 15:47:07 +00:00
for ( int i = 1 ; i < MAX_WEAPONS ; + + i )
{
if ( player - > inventory . weapons & ( 1 < < i ) )
{
if ( i = = player - > GetIdealWeapon ( ) )
{
2012-11-26 18:58:24 +00:00
weaponDefIndex = weaponDefNames . Num ( ) ;
}
weaponDefNames . Append ( va ( " def_weapon%d " , i ) ) ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int numRightWeapons = 0 ;
int numLeftWeapons = 0 ;
2012-11-28 15:47:07 +00:00
if ( weaponDefNames . Num ( ) = = 2 )
{
2012-11-26 18:58:24 +00:00
numRightWeapons = 1 - weaponDefIndex ;
numLeftWeapons = weaponDefIndex ;
2012-11-28 15:47:07 +00:00
}
else if ( weaponDefNames . Num ( ) = = 3 )
{
2012-11-26 18:58:24 +00:00
numRightWeapons = 1 ;
numLeftWeapons = 1 ;
2012-11-28 15:47:07 +00:00
}
else if ( weaponDefNames . Num ( ) > 3 )
{
2012-11-26 18:58:24 +00:00
numRightWeapons = 2 ;
numLeftWeapons = 2 ;
}
2012-11-28 15:47:07 +00:00
for ( int i = - 2 ; i < 3 ; + + i )
{
2012-11-26 18:58:24 +00:00
bool hide = false ;
2012-11-28 15:47:07 +00:00
if ( i < 0 & & idMath : : Abs ( i ) > numLeftWeapons )
{
2012-11-26 18:58:24 +00:00
hide = true ;
2012-11-28 15:47:07 +00:00
}
else if ( i > numRightWeapons )
{
2012-11-26 18:58:24 +00:00
hide = true ;
2012-11-28 15:47:07 +00:00
}
else if ( weaponDefNames . Num ( ) = = 0 )
{
2012-11-26 18:58:24 +00:00
hide = true ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int index = i ;
2012-11-28 15:47:07 +00:00
if ( i < 0 )
{
2012-11-26 18:58:24 +00:00
index = 2 + idMath : : Abs ( i ) ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * topValid = mpWeapons - > GetNestedSprite ( " list " , va ( " weapon%i " , index ) , " topValid " ) ;
idSWFSpriteInstance * botValid = mpWeapons - > GetNestedSprite ( " list " , va ( " weapon%i " , index ) , " botValid " ) ;
idSWFSpriteInstance * topInvalid = mpWeapons - > GetNestedSprite ( " list " , va ( " weapon%i " , index ) , " topInvalid " ) ;
idSWFSpriteInstance * botInvalid = mpWeapons - > GetNestedSprite ( " list " , va ( " weapon%i " , index ) , " botInvalid " ) ;
if ( ! topValid | | ! botValid | | ! topInvalid | | ! botInvalid )
{
2012-11-26 18:58:24 +00:00
mpWeapons - > GetSprite ( ) - > SetVisible ( false ) ;
break ;
}
2012-11-28 15:47:07 +00:00
if ( hide )
{
2012-11-26 18:58:24 +00:00
topValid - > SetVisible ( false ) ;
botValid - > SetVisible ( false ) ;
topInvalid - > SetVisible ( false ) ;
botInvalid - > SetVisible ( false ) ;
continue ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
int weaponIndex = weaponDefIndex + i ;
2012-11-28 15:47:07 +00:00
if ( weaponIndex < 0 )
{
2012-11-26 18:58:24 +00:00
weaponIndex = weaponDefNames . Num ( ) + weaponIndex ;
2012-11-28 15:47:07 +00:00
}
else if ( weaponIndex > = weaponDefNames . Num ( ) )
{
2012-11-26 18:58:24 +00:00
weaponIndex = ( weaponIndex - weaponDefNames . Num ( ) ) ;
}
int weapState = 1 ;
2012-11-28 15:47:07 +00:00
const idMaterial * hudIcon = NULL ;
const char * weapNum = weaponDefNames [ weaponIndex ] ;
const char * weap = player - > spawnArgs . GetString ( weapNum ) ;
2012-12-11 22:48:55 +00:00
if ( weap ! = NULL & & * weap ! = ' \0 ' )
2012-11-28 15:47:07 +00:00
{
const idDeclEntityDef * weaponDef = gameLocal . FindEntityDef ( weap , false ) ;
if ( weaponDef ! = NULL )
{
2012-11-26 18:58:24 +00:00
hudIcon = declManager - > FindMaterial ( weaponDef - > dict . GetString ( " hudIcon " ) , false ) ;
2012-11-28 15:47:07 +00:00
if ( i = = 0 )
{
2012-11-26 18:58:24 +00:00
displayName = weaponDef - > dict . GetString ( " display_name " ) ;
weapState + + ;
}
2012-11-28 15:47:07 +00:00
}
if ( ! player - > inventory . HasAmmo ( weap , true , player ) )
{
2012-11-26 18:58:24 +00:00
weapState = 0 ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
topValid - > SetVisible ( false ) ;
botValid - > SetVisible ( false ) ;
topInvalid - > SetVisible ( false ) ;
botInvalid - > SetVisible ( false ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
topValid - > SetMaterial ( hudIcon ) ;
botValid - > SetMaterial ( hudIcon ) ;
topInvalid - > SetMaterial ( hudIcon ) ;
botInvalid - > SetMaterial ( hudIcon ) ;
2012-11-28 15:47:07 +00:00
if ( weapState = = 0 )
{
2012-11-26 18:58:24 +00:00
botInvalid - > SetVisible ( true ) ;
2012-11-28 15:47:07 +00:00
if ( i = = 0 )
{
2012-11-26 18:58:24 +00:00
topInvalid - > SetVisible ( true ) ;
}
2012-11-28 15:47:07 +00:00
}
else if ( weapState = = 2 )
{
2012-11-26 18:58:24 +00:00
topValid - > SetVisible ( true ) ;
botValid - > SetVisible ( true ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
botValid - > SetVisible ( true ) ;
}
}
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
bool hasWeapons = false ;
2012-11-28 15:47:07 +00:00
const idMaterial * hudIcon = NULL ;
for ( int i = 0 ; i < MAX_WEAPONS ; i + + )
{
const char * weapnum = va ( " def_weapon%d " , i ) ;
2012-11-26 18:58:24 +00:00
int weapstate = 0 ;
2012-11-28 15:47:07 +00:00
if ( player - > inventory . weapons & ( 1 < < i ) )
{
2012-11-26 18:58:24 +00:00
hasWeapons = true ;
2012-11-28 15:47:07 +00:00
const char * weap = player - > spawnArgs . GetString ( weapnum ) ;
2012-12-11 22:48:55 +00:00
if ( weap ! = NULL & & * weap ! = ' \0 ' )
2012-11-28 15:47:07 +00:00
{
2012-11-26 18:58:24 +00:00
weapstate + + ;
}
2012-11-28 15:47:07 +00:00
if ( player - > GetIdealWeapon ( ) = = i )
{
const idDeclEntityDef * weaponDef = gameLocal . FindEntityDef ( weap , false ) ;
if ( weaponDef ! = NULL )
{
2012-11-26 18:58:24 +00:00
hudIcon = declManager - > FindMaterial ( weaponDef - > dict . GetString ( " hudIcon " ) , false ) ;
displayName = weaponDef - > dict . GetString ( " display_name " ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
weapstate + + ;
}
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * pill = weaponPills - > GetNestedSprite ( va ( " pill%d " , i ) ) ;
if ( pill )
{
2012-11-26 18:58:24 +00:00
pill - > StopFrame ( weapstate + 1 ) ;
}
}
2012-11-28 15:47:07 +00:00
if ( ! hasWeapons )
{
2012-11-26 18:58:24 +00:00
weaponPills - > GetSprite ( ) - > SetVisible ( false ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
weaponPills - > GetSprite ( ) - > SetVisible ( true ) ;
}
2012-11-28 15:47:07 +00:00
if ( weaponImg )
{
if ( weaponChanged & & hudIcon ! = NULL )
{
2012-11-26 18:58:24 +00:00
weaponImg - > SetVisible ( true ) ;
weaponImg - > PlayFrame ( 2 ) ;
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * topImg = weaponImg - > GetScriptObject ( ) - > GetNestedSprite ( " topImg " ) ;
idSWFSpriteInstance * botImg = weaponImg - > GetScriptObject ( ) - > GetNestedSprite ( " botImg " ) ;
if ( topImg ! = NULL & & botImg ! = NULL )
{
2012-11-26 18:58:24 +00:00
topImg - > SetMaterial ( hudIcon ) ;
botImg - > SetMaterial ( hudIcon ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
/*if ( weaponName && weaponName->GetSprite() ) {
weaponName - > GetSprite ( ) - > SetVisible ( true ) ;
weaponName - > GetSprite ( ) - > PlayFrame ( 2 ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idSWFTextInstance * txtVal = weaponName - > GetNestedText ( " info " , " txtVal " ) ;
if ( txtVal ! = NULL ) {
txtVal - > SetText ( displayName ) ;
txtVal - > SetStrokeInfo ( true , 0.6f , 2.0f ) ;
}
} */
}
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateLocation
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateLocation ( idPlayer * player )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! locationName | | ! player )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idPlayer * playertoLoc = player ;
if ( player - > spectating & & player - > spectator ! = player - > entityNumber )
{
2012-11-26 18:58:24 +00:00
playertoLoc = static_cast < idPlayer * > ( gameLocal . entities [ player - > spectator ] ) ;
2012-11-28 15:47:07 +00:00
if ( playertoLoc = = NULL )
{
2012-11-26 18:58:24 +00:00
playertoLoc = player ;
}
}
2012-11-28 15:47:07 +00:00
idLocationEntity * locationEntity = gameLocal . LocationForPoint ( playertoLoc - > GetEyePosition ( ) ) ;
if ( locationEntity )
{
2012-11-26 18:58:24 +00:00
locationName - > SetText ( locationEntity - > GetLocation ( ) ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
locationName - > SetText ( idLocalization : : GetString ( " #str_02911 " ) ) ;
}
locationName - > SetStrokeInfo ( true , 0.6f , 2.0f ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : ShowTip
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ShowTip ( const char * title , const char * tip )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! tipInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * tipSprite = tipInfo - > GetSprite ( ) ;
if ( ! tipSprite )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
tipSprite - > SetVisible ( true ) ;
tipSprite - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
idSWFTextInstance * txtTitle = tipInfo - > GetNestedText ( " info " , " txtTitle " ) ;
idSWFTextInstance * txtTip = tipInfo - > GetNestedText ( " info " , " txtTip " ) ;
if ( txtTitle ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtTitle - > SetText ( title ) ;
txtTitle - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
}
2012-11-28 15:47:07 +00:00
if ( txtTip ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtTip - > SetText ( tip ) ;
txtTip - > tooltip = true ;
txtTip - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
int numLines = txtTip - > CalcNumLines ( ) ;
2012-11-28 15:47:07 +00:00
if ( numLines = = 0 )
{
2012-11-26 18:58:24 +00:00
numLines = 1 ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * backing = tipInfo - > GetNestedSprite ( " info " , " backing " ) ;
if ( backing ! = NULL )
{
2012-11-26 18:58:24 +00:00
backing - > StopFrame ( numLines ) ;
}
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : HideTip
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : HideTip ( )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! tipInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * tipSprite = tipInfo - > GetSprite ( ) ;
if ( ! tipSprite )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
tipSprite - > SetVisible ( true ) ;
tipSprite - > PlayFrame ( " rollOff " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : DownloadPDA
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : DownloadPDA ( const idDeclPDA * pda , bool newSecurity )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( newPDADownload )
{
2012-11-26 18:58:24 +00:00
newPDADownload - > SetVisible ( true ) ;
newPDADownload - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
newPDAName = newPDADownload - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtName " ) ;
newPDAHeading = newPDADownload - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtHeading " ) ;
2012-11-28 15:47:07 +00:00
if ( newPDAName & & GetSWFObject ( ) ! = NULL )
{
2012-11-26 18:58:24 +00:00
idStr pdaName = pda - > GetPdaName ( ) ;
pdaName . RemoveColors ( ) ;
GetSWFObject ( ) - > SetGlobal ( " pdaNameDownload " , pdaName ) ;
newPDAName - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
}
2012-11-28 15:47:07 +00:00
if ( newPDAHeading & & GetSWFObject ( ) ! = NULL )
{
GetSWFObject ( ) - > SetGlobal ( " pdaDownloadHeading " , " #str_02031 " ) ;
2012-11-26 18:58:24 +00:00
newPDAHeading - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
}
}
2012-11-28 15:47:07 +00:00
if ( newSecurity )
{
2012-11-26 18:58:24 +00:00
UpdatedSecurity ( ) ;
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : DownloadVideo
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : DownloadVideo ( )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( newVideoDownload )
{
2012-11-26 18:58:24 +00:00
newVideoDownload - > SetVisible ( true ) ;
newVideoDownload - > PlayFrame ( " rollOn " ) ;
newVideoHeading = newVideoDownload - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtHeading " ) ;
2012-11-28 15:47:07 +00:00
if ( newVideoHeading )
{
2012-11-26 18:58:24 +00:00
newVideoHeading - > SetText ( " #str_02033 " ) ;
newVideoHeading - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
}
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdatedSecurity
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdatedSecurity ( )
{
if ( security ! = NULL & & securityText ! = NULL )
{
2012-11-26 18:58:24 +00:00
security - > SetVisible ( true ) ;
security - > PlayFrame ( " rollOn " ) ;
securityText - > SetText ( " #str_02032 " ) ;
securityText - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : ClearNewPDAInfo
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ClearNewPDAInfo ( )
{
2012-11-26 18:58:24 +00:00
ToggleNewVideo ( false ) ;
ToggleNewPDA ( false ) ;
2012-11-28 15:47:07 +00:00
if ( security )
{
2012-11-26 18:58:24 +00:00
security - > StopFrame ( 1 ) ;
}
2012-11-28 15:47:07 +00:00
if ( newPDADownload )
{
2012-11-26 18:58:24 +00:00
newPDADownload - > StopFrame ( 1 ) ;
}
2012-11-28 15:47:07 +00:00
if ( newVideoDownload )
{
2012-11-26 18:58:24 +00:00
newVideoDownload - > StopFrame ( 1 ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdatedSecurity
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ToggleNewVideo ( bool show )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! newVideo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( show & & ! newVideo - > IsVisible ( ) )
{
2012-11-26 18:58:24 +00:00
newVideo - > SetVisible ( true ) ;
newVideo - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
}
else if ( ! show )
{
2012-11-26 18:58:24 +00:00
newVideo - > StopFrame ( 1 ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdatedSecurity
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ToggleNewPDA ( bool show )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! newPDA )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( show & & ! newPDA - > IsVisible ( ) )
{
2012-11-26 18:58:24 +00:00
newPDA - > SetVisible ( true ) ;
newPDA - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
}
else if ( ! show )
{
2012-11-26 18:58:24 +00:00
newPDA - > StopFrame ( 1 ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdatedSecurity
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateAudioLog ( bool show )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! audioLog )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( show & & ! audioLog - > IsVisible ( ) )
{
2012-11-26 18:58:24 +00:00
audioLog - > SetVisible ( true ) ;
audioLog - > StopFrame ( " 2 " ) ;
2012-11-28 15:47:07 +00:00
for ( int index = 0 ; index < 13 ; + + index )
{
idSWFSpriteInstance * node = audioLog - > GetScriptObject ( ) - > GetNestedSprite ( " bar " , va ( " node%d " , index ) ) ;
if ( node ! = NULL )
{
2012-11-26 18:58:24 +00:00
int frame = gameLocal . random . RandomInt ( 100 ) ;
node - > SetScale ( 100.0f , frame ) ;
float toFrame = gameLocal . random . RandomFloat ( ) ;
node - > SetMoveToScale ( - 1.0f , toFrame ) ;
}
}
2012-11-28 15:47:07 +00:00
}
else if ( ! show )
{
2012-11-26 18:58:24 +00:00
audioLog - > StopFrame ( 1 ) ;
2012-11-28 15:47:07 +00:00
}
else if ( show )
{
if ( audioLogPrevTime = = 0 )
{
2012-11-26 18:58:24 +00:00
audioLogPrevTime = gameLocal . time ;
}
2012-11-28 15:47:07 +00:00
for ( int index = 0 ; index < 13 ; + + index )
{
idSWFSpriteInstance * node = audioLog - > GetScriptObject ( ) - > GetNestedSprite ( " bar " , va ( " node%d " , index ) ) ;
if ( node ! = NULL )
{
2012-11-26 18:58:24 +00:00
float diff = gameLocal . time - audioLogPrevTime ;
float speed = ( diff / 350.0f ) * 100.0f ;
2012-11-28 15:47:07 +00:00
if ( ! node - > UpdateMoveToScale ( speed ) )
{
2012-11-26 18:58:24 +00:00
int frame = gameLocal . random . RandomInt ( 100 ) ;
float scale = frame / 100.0f ;
node - > SetMoveToScale ( - 1.0f , scale ) ;
}
}
}
audioLogPrevTime = gameLocal . time ;
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdatedSecurity
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateCommunication ( bool show , idPlayer * player )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! communication | | ! player )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
bool oxygenChanged = false ;
2012-11-28 15:47:07 +00:00
if ( inVaccuum ! = oxygenComm )
{
2012-11-26 18:58:24 +00:00
oxygenChanged = true ;
}
2012-11-28 15:47:07 +00:00
if ( show & & ! communication - > IsVisible ( ) )
{
2012-11-26 18:58:24 +00:00
communication - > SetVisible ( true ) ;
2012-11-28 15:47:07 +00:00
if ( inVaccuum )
{
2012-11-26 18:58:24 +00:00
communication - > StopFrame ( " oxygen " ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
communication - > StopFrame ( " 2 " ) ;
}
2012-11-28 15:47:07 +00:00
for ( int index = 0 ; index < 16 ; + + index )
{
idSWFSpriteInstance * node = communication - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " bar " , va ( " node%d " , index ) ) ;
if ( node ! = NULL )
{
2012-11-26 18:58:24 +00:00
int frame = gameLocal . random . RandomInt ( 100 ) ;
node - > SetScale ( 100.0f , frame ) ;
float toFrame = gameLocal . random . RandomFloat ( ) ;
node - > SetMoveToScale ( - 1.0f , toFrame ) ;
}
}
2012-11-28 15:47:07 +00:00
}
else if ( ! show )
{
2012-11-26 18:58:24 +00:00
communication - > StopFrame ( 1 ) ;
2012-11-28 15:47:07 +00:00
}
else if ( show )
{
if ( oxygenChanged )
{
if ( inVaccuum )
{
2012-11-26 18:58:24 +00:00
communication - > PlayFrame ( " rollUp " ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
communication - > PlayFrame ( " rollDown " ) ;
}
}
2012-11-28 15:47:07 +00:00
if ( commPrevTime = = 0 )
{
2012-11-26 18:58:24 +00:00
commPrevTime = gameLocal . time ;
}
2012-11-28 15:47:07 +00:00
for ( int index = 0 ; index < 16 ; + + index )
{
idSWFSpriteInstance * node = communication - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " bar " , va ( " node%d " , index ) ) ;
if ( node ! = NULL )
{
2012-11-26 18:58:24 +00:00
float diff = gameLocal . time - commPrevTime ;
float speed = ( diff / 350.0f ) * 100.0f ;
2012-11-28 15:47:07 +00:00
if ( ! node - > UpdateMoveToScale ( speed ) )
{
2012-11-26 18:58:24 +00:00
int frame = gameLocal . random . RandomInt ( 100 ) ;
float scale = frame / 100.0f ;
node - > SetMoveToScale ( - 1.0f , scale ) ;
}
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
commPrevTime = gameLocal . time ;
}
oxygenComm = inVaccuum ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateOxygen
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateOxygen ( bool show , int val )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! oxygen )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( show )
{
if ( ! oxygen - > IsVisible ( ) )
{
2012-11-26 18:58:24 +00:00
inVaccuum = true ;
oxygen - > SetVisible ( true ) ;
oxygen - > PlayFrame ( " rollOn " ) ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * info = oxygen - > GetScriptObject ( ) - > GetNestedSprite ( " info " ) ;
if ( info ! = NULL )
{
2012-11-26 18:58:24 +00:00
info - > StopFrame ( val + 1 ) ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * goodFrame = oxygen - > GetScriptObject ( ) - > GetNestedSprite ( " goodFrame " ) ;
idSWFSpriteInstance * badFrame = oxygen - > GetScriptObject ( ) - > GetNestedSprite ( " badFrame " ) ;
if ( goodFrame ! = NULL & & badFrame ! = NULL )
{
if ( val + 1 > = 36 )
{
2012-11-26 18:58:24 +00:00
goodFrame - > SetVisible ( true ) ;
badFrame - > SetVisible ( false ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
goodFrame - > SetVisible ( false ) ;
badFrame - > SetVisible ( true ) ;
}
}
2012-11-28 15:47:07 +00:00
idSWFTextInstance * txtVal = oxygen - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtHeading " ) ;
if ( txtVal ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtVal - > SetText ( " #str_00100922 " ) ;
txtVal - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
txtVal = oxygen - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtVal " ) ;
2012-11-28 15:47:07 +00:00
if ( txtVal ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtVal - > SetText ( va ( " %d " , val ) ) ;
txtVal - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
}
2012-11-28 15:47:07 +00:00
}
else if ( ! show )
{
2012-11-26 18:58:24 +00:00
inVaccuum = false ;
oxygen - > StopFrame ( 1 ) ;
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : SetupObjective
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : SetupObjective ( const idStr & title , const idStr & desc , const idMaterial * screenshot )
{
2012-11-26 18:58:24 +00:00
objTitle = title ;
objDesc = desc ;
objScreenshot = screenshot ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : SetupObjective
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : SetupObjectiveComplete ( const idStr & title )
{
2012-11-26 18:58:24 +00:00
objCompleteTitle = title ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : ShowObjective
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ShowObjective ( bool complete )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( complete )
{
if ( ! objectiveComplete )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
objectiveComplete - > SetVisible ( true ) ;
objectiveComplete - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
idSWFTextInstance * txtComplete = objectiveComplete - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtComplete " ) ;
idSWFTextInstance * txtTitle = objectiveComplete - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtTitle " ) ;
idSWFSpriteInstance * rightArrow = objectiveComplete - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " right_arrows " ) ;
if ( txtComplete ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtComplete - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
2012-11-28 15:47:07 +00:00
if ( rightArrow ! = NULL )
{
2012-11-26 18:58:24 +00:00
rightArrow - > SetXPos ( txtComplete - > GetTextLength ( ) + 30.0f ) ;
}
}
2012-11-28 15:47:07 +00:00
if ( txtTitle ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtTitle - > SetText ( objCompleteTitle ) ;
txtTitle - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
}
2012-11-28 15:47:07 +00:00
}
else
{
if ( ! objective )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
objective - > SetVisible ( true ) ;
objective - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
idSWFTextInstance * txtNew = objective - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtComplete " ) ;
idSWFTextInstance * txtTitle = objective - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtTitle " ) ;
idSWFTextInstance * txtDesc = objective - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtDesc " ) ;
idSWFSpriteInstance * img = objective - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " img " ) ;
idSWFSpriteInstance * rightArrow = objective - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " right_arrows " ) ;
if ( txtNew ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtNew - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
2012-11-28 15:47:07 +00:00
if ( rightArrow ! = NULL )
{
2012-11-26 18:58:24 +00:00
rightArrow - > SetXPos ( txtNew - > GetTextLength ( ) + 55.0f ) ;
}
}
2012-11-28 15:47:07 +00:00
if ( txtTitle ! = NULL )
{
2012-11-26 18:58:24 +00:00
txtTitle - > SetText ( objTitle ) ;
txtTitle - > SetStrokeInfo ( true , 0.9f , 2.0f ) ;
}
2012-11-28 15:47:07 +00:00
if ( txtDesc )
{
2012-11-26 18:58:24 +00:00
txtDesc - > SetText ( objDesc ) ;
}
2012-11-28 15:47:07 +00:00
if ( img ! = NULL )
{
2012-11-26 18:58:24 +00:00
img - > SetMaterial ( objScreenshot ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : HideObjective
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : HideObjective ( bool complete )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( complete )
{
if ( ! objectiveComplete )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
objectiveComplete - > PlayFrame ( " rollOff " ) ;
2012-11-28 15:47:07 +00:00
}
else
{
if ( ! objective )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
objective - > PlayFrame ( " rollOff " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
//******************************************************************************************
// MULTIPLAYER FUNCITONS
//******************************************************************************************
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : ToggleMPInfo
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ToggleMPInfo ( bool show , bool showTeams , bool isCTF )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! mpInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( show )
{
2012-11-26 18:58:24 +00:00
mpInfo - > SetVisible ( true ) ;
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * redTeam = mpInfo - > GetScriptObject ( ) - > GetNestedSprite ( " redTeam " ) ;
idSWFSpriteInstance * blueTeam = mpInfo - > GetScriptObject ( ) - > GetNestedSprite ( " blueTeam " ) ;
idSWFSpriteInstance * redFlag = mpInfo - > GetScriptObject ( ) - > GetNestedSprite ( " redFlag " ) ;
idSWFSpriteInstance * blueFlag = mpInfo - > GetScriptObject ( ) - > GetNestedSprite ( " blueFlag " ) ;
if ( redFlag )
{
2012-11-26 18:58:24 +00:00
redFlag - > SetVisible ( isCTF ) ;
}
2012-11-28 15:47:07 +00:00
if ( blueFlag )
{
2012-11-26 18:58:24 +00:00
blueFlag - > SetVisible ( isCTF ) ;
}
2012-11-28 15:47:07 +00:00
if ( ! showTeams )
{
if ( redTeam )
{
2012-11-26 18:58:24 +00:00
redTeam - > SetVisible ( false ) ;
2012-11-28 15:47:07 +00:00
}
if ( blueTeam )
{
2012-11-26 18:58:24 +00:00
blueTeam - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
}
else
{
if ( redTeam )
{
2012-11-26 18:58:24 +00:00
redTeam - > SetVisible ( true ) ;
2012-11-28 15:47:07 +00:00
}
if ( blueTeam )
{
2012-11-26 18:58:24 +00:00
blueTeam - > SetVisible ( true ) ;
}
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
mpInfo - > SetVisible ( false ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : SetFlagState
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : SetFlagState ( int team , int state )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! mpInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * flag = NULL ;
if ( team = = 0 )
{
2012-11-26 18:58:24 +00:00
flag = mpInfo - > GetScriptObject ( ) - > GetNestedSprite ( " redFlag " ) ;
2012-11-28 15:47:07 +00:00
}
else if ( team = = 1 )
{
2012-11-26 18:58:24 +00:00
flag = mpInfo - > GetScriptObject ( ) - > GetNestedSprite ( " blueFlag " ) ;
}
2012-11-28 15:47:07 +00:00
if ( flag )
{
if ( state = = 3 ) //FLAGSTATUS_NONE
{
2012-11-26 18:58:24 +00:00
flag - > StopFrame ( 1 ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
flag - > SetVisible ( true ) ;
flag - > StopFrame ( state + 2 ) ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : SetTeamScore
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : SetTeamScore ( int team , int score )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! mpInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idSWFTextInstance * txtScore = NULL ;
if ( team = = 0 )
{
2012-11-26 18:58:24 +00:00
txtScore = mpInfo - > GetScriptObject ( ) - > GetNestedText ( " redTeam " , " txtRedScore " ) ;
2012-11-28 15:47:07 +00:00
}
else if ( team = = 1 )
{
2012-11-26 18:58:24 +00:00
txtScore = mpInfo - > GetScriptObject ( ) - > GetNestedText ( " blueTeam " , " txtBlueScore " ) ;
}
2012-11-28 15:47:07 +00:00
if ( txtScore )
{
2012-11-26 18:58:24 +00:00
txtScore - > SetText ( va ( " %i " , score ) ) ;
txtScore - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : SetTeam
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : SetTeam ( int team )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! mpInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * teamBacking = mpInfo - > GetScriptObject ( ) - > GetNestedSprite ( " teamBack " ) ;
if ( teamBacking )
{
if ( team < 0 )
{
2012-11-26 18:58:24 +00:00
teamBacking - > StopFrame ( 3 ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
teamBacking - > StopFrame ( team + 1 ) ;
}
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : TriggerHitTarget
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : TriggerHitTarget ( bool show , const idStr & target , int color )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! mpHitInfo )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( show )
{
2012-11-26 18:58:24 +00:00
mpHitInfo - > SetVisible ( true ) ;
mpHitInfo - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
if ( menuGUI )
{
2012-11-26 18:58:24 +00:00
menuGUI - > SetGlobal ( " hitTargetName " , target . c_str ( ) ) ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * backing = mpHitInfo - > GetScriptObject ( ) - > GetNestedSprite ( " bgColor " ) ;
if ( backing )
{
if ( color < = 0 | | ! gameLocal . mpGame . IsGametypeTeamBased ( ) )
{
2012-11-26 18:58:24 +00:00
color = 1 ;
}
backing - > StopFrame ( color ) ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
mpHitInfo - > PlayFrame ( " rollOff " ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
2012-11-28 15:47:07 +00:00
idMenuScreen_HUD : : ToggleLagged
2012-11-26 18:58:24 +00:00
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ToggleLagged ( bool show )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! mpConnection )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
mpConnection - > SetVisible ( show ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateGameTime
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateGameTime ( const char * time )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! mpTime )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
UpdateMessage ( false , " " ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
mpTime - > SetText ( time ) ;
mpTime - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateMessage
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateMessage ( bool show , const idStr & message )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! mpMessage )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( show )
{
if ( mpTime )
{
2012-11-26 18:58:24 +00:00
mpTime - > SetText ( " " ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
mpMessage - > SetText ( message ) ;
mpMessage - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
mpMessage - > SetText ( " " ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : ShowNewItem
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : ShowNewItem ( const char * name , const char * icon )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! newItem )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
newItem - > SetVisible ( true ) ;
newItem - > PlayFrame ( " rollOn " ) ;
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * topImg = newItem - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " topImg " ) ;
idSWFSpriteInstance * botImg = newItem - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " botImg " ) ;
idSWFTextInstance * heading = newItem - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtTitle " ) ;
idSWFTextInstance * itemName = newItem - > GetScriptObject ( ) - > GetNestedText ( " info " , " txtItem " ) ;
const idMaterial * mat = declManager - > FindMaterial ( icon , false ) ;
if ( topImg ! = NULL & & botImg ! = NULL & & mat ! = NULL )
{
2012-11-26 18:58:24 +00:00
topImg - > SetMaterial ( mat ) ;
botImg - > SetMaterial ( mat ) ;
}
2012-11-28 15:47:07 +00:00
if ( heading ! = NULL )
{
2012-11-26 18:58:24 +00:00
heading - > SetText ( " #str_02027 " ) ;
heading - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
}
2012-11-28 15:47:07 +00:00
if ( itemName ! = NULL )
{
2012-11-26 18:58:24 +00:00
itemName - > SetText ( name ) ;
itemName - > SetStrokeInfo ( true , 0.75f , 1.5f ) ;
2012-11-28 15:47:07 +00:00
}
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateFlashlight
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateFlashlight ( idPlayer * player )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! player | | ! flashlight )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
if ( player - > flashlightBattery ! = flashlight_batteryDrainTimeMS . GetInteger ( ) )
{
2012-11-26 18:58:24 +00:00
flashlight - > StopFrame ( 2 ) ;
flashlight - > SetVisible ( true ) ;
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * batteryLife = flashlight - > GetScriptObject ( ) - > GetNestedSprite ( " info " ) ;
if ( batteryLife )
{
float power = ( ( float ) player - > flashlightBattery / ( float ) flashlight_batteryDrainTimeMS . GetInteger ( ) ) * 100.0f ;
2012-11-26 18:58:24 +00:00
batteryLife - > StopFrame ( power ) ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
flashlight - > StopFrame ( 1 ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idMenuScreen_HUD : : UpdateChattingHud
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idMenuScreen_HUD : : UpdateChattingHud ( idPlayer * player )
{
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
if ( ! mpChatObject | | ! GetSWFObject ( ) )
{
2012-11-26 18:58:24 +00:00
return ;
}
2012-11-28 15:47:07 +00:00
idSWF * gui = GetSWFObject ( ) ;
if ( player - > isChatting = = 0 )
{
if ( mpChatObject - > GetCurrentFrame ( ) ! = 1 )
{
2012-11-26 18:58:24 +00:00
mpChatObject - > StopFrame ( 1 ) ;
gui - > ForceInhibitControl ( false ) ;
2012-12-08 17:20:13 +00:00
2012-12-07 17:29:47 +00:00
// RB: 64 bit fixes, changed NULL to 0
gui - > SetGlobal ( " focusWindow " , 0 ) ;
// RB end
2012-11-26 18:58:24 +00:00
}
2012-11-28 15:47:07 +00:00
}
else
{
if ( ! mpChatObject - > IsVisible ( ) )
{
2012-11-26 18:58:24 +00:00
mpChatObject - > SetVisible ( true ) ;
mpChatObject - > PlayFrame ( " rollOn " ) ;
gui - > ForceInhibitControl ( true ) ;
2012-11-28 15:47:07 +00:00
idSWFTextInstance * txtType = mpChatObject - > GetScriptObject ( ) - > GetNestedText ( " info " , " saybox " ) ;
2012-11-26 18:58:24 +00:00
int length = 0 ;
2012-11-28 15:47:07 +00:00
if ( txtType )
{
if ( player - > isChatting = = 1 )
{
2012-11-26 18:58:24 +00:00
txtType - > SetText ( " #str_swf_talk_all " ) ;
2012-11-28 15:47:07 +00:00
}
else if ( player - > isChatting = = 2 )
{
2012-11-26 18:58:24 +00:00
txtType - > SetText ( " #str_swf_talk_team " ) ;
}
txtType - > SetStrokeInfo ( true ) ;
length = txtType - > GetTextLength ( ) ;
}
2012-11-28 15:47:07 +00:00
idSWFSpriteInstance * sayBox = mpChatObject - > GetScriptObject ( ) - > GetNestedSprite ( " info " , " textEntry " ) ;
if ( sayBox )
{
2012-11-26 18:58:24 +00:00
sayBox - > SetXPos ( length + 10 ) ;
}
2012-11-28 15:47:07 +00:00
idSWFTextInstance * say = mpChatObject - > GetScriptObject ( ) - > GetNestedText ( " info " , " textEntry " , " txtVal " ) ;
if ( say ! = NULL )
{
2012-11-26 18:58:24 +00:00
say - > SetIgnoreColor ( false ) ;
say - > SetText ( " " ) ;
say - > SetStrokeInfo ( true ) ;
say - > renderMode = SWF_TEXT_RENDER_AUTOSCROLL ;
}
2012-11-28 15:47:07 +00:00
idSWFScriptObject * const sayObj = mpChatObject - > GetScriptObject ( ) - > GetNestedObj ( " info " , " textEntry " , " txtVal " ) ;
if ( sayObj ! = NULL )
{
2012-11-26 18:58:24 +00:00
gui - > SetGlobal ( " focusWindow " , sayObj ) ;
2012-11-28 15:47:07 +00:00
class idPostTextChat : public idSWFScriptFunction_RefCounted
{
2012-11-26 18:58:24 +00:00
public :
2012-11-28 15:47:07 +00:00
idPostTextChat ( idPlayer * _player , idSWFTextInstance * _text )
{
2012-11-26 18:58:24 +00:00
player = _player ;
text = _text ;
}
2012-11-28 15:47:07 +00:00
idSWFScriptVar Call ( idSWFScriptObject * thisObject , const idSWFParmList & parms )
{
if ( ! player | | ! text )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
idStr val = text - > text ;
val . Replace ( " \' " , " " ) ;
val . Replace ( " \" " , " " ) ;
idStr command ;
2012-11-28 15:47:07 +00:00
if ( player - > isChatting = = 2 )
{
2012-11-26 18:58:24 +00:00
command = va ( " sayTeam %s \n " , val . c_str ( ) ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
command = va ( " say %s \n " , val . c_str ( ) ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
cmdSystem - > BufferCommandText ( CMD_EXEC_NOW , command . c_str ( ) ) ;
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
player - > isChatting = 0 ;
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
idPlayer * player ;
idSWFTextInstance * text ;
2012-11-26 18:58:24 +00:00
} ;
2012-11-28 15:47:07 +00:00
class idCancelTextChat : public idSWFScriptFunction_RefCounted
{
2012-11-26 18:58:24 +00:00
public :
2012-11-28 15:47:07 +00:00
idCancelTextChat ( idPlayer * _player )
{
2012-11-26 18:58:24 +00:00
player = _player ;
}
2012-11-28 15:47:07 +00:00
idSWFScriptVar Call ( idSWFScriptObject * thisObject , const idSWFParmList & parms )
{
if ( ! player )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
2012-11-26 18:58:24 +00:00
player - > isChatting = 0 ;
return idSWFScriptVar ( ) ;
}
2012-11-28 15:47:07 +00:00
idPlayer * player ;
2012-11-26 18:58:24 +00:00
} ;
2012-11-28 15:47:07 +00:00
sayObj - > Set ( " onPress " , new ( TAG_SWF ) idPostTextChat ( player , say ) ) ;
idSWFScriptObject * const shortcutKeys = gui - > GetGlobal ( " shortcutKeys " ) . GetObject ( ) ;
if ( verify ( shortcutKeys ! = NULL ) )
{
2012-11-26 18:58:24 +00:00
shortcutKeys - > Set ( " ENTER " , sayObj ) ;
2012-11-28 15:47:07 +00:00
shortcutKeys - > Set ( " ESCAPE " , new ( TAG_SWF ) idCancelTextChat ( player ) ) ;
2012-11-26 18:58:24 +00:00
}
}
}
}
}