123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968 |
- /*
- ===========================================================================
- Doom 3 BFG Edition GPL Source Code
- Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
- This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
- 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
- #include "../../idLib/precompiled.h"
- #include "../Game_local.h"
- extern idCVar pm_stamina;
- extern idCVar in_useJoystick;
- extern idCVar flashlight_batteryDrainTimeMS;
- /*
- ========================
- idMenuScreen_HUD::Initialize
- ========================
- */
- void idMenuScreen_HUD::Initialize( idMenuHandler * data ) {
- idMenuScreen::Initialize( data );
- }
- /*
- ========================
- idMenuScreen_HUD::ShowScreen
- ========================
- */
- void idMenuScreen_HUD::ShowScreen( const mainMenuTransition_t transitionType ) {
- if ( menuData != NULL ) {
- menuGUI = menuData->GetGUI();
- }
- if ( menuGUI == NULL ) {
- return;
- }
- idSWFScriptObject & root = menuGUI->GetRootObject();
- playerInfo = root.GetNestedObj( "_bottomLeft", "playerInfo", "info" );
- stamina = root.GetNestedObj( "_bottomLeft", "stamina" );
- locationName = root.GetNestedText( "_bottomLeft", "location", "txtVal" );
- tipInfo = root.GetNestedObj( "_left", "tip" );
- if ( playerInfo ) {
- healthBorder = playerInfo->GetNestedSprite( "healthBorder", "damage" );
- healthPulse = playerInfo->GetNestedSprite( "healthBorder", "pulse" );
- armorFrame = playerInfo->GetNestedSprite( "armorFrame" );
- }
- // Security Update
- security = root.GetNestedSprite( "_center", "security" );
- securityText = root.GetNestedText( "_center", "security", "info", "txtVal" );
- // 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" );
- // Video Download
- newVideoDownload = root.GetNestedSprite( "_center", "videoDownload" );
- newVideoHeading = root.GetNestedText( "_center", "videoDownload", "info", "txtHeading" );
- newVideo = root.GetNestedSprite( "_bottomLeft", "newVideo" );
- // Audio Log
- audioLog = root.GetNestedSprite( "_bottomLeft", "audioLog" );
- // Radio Communication
- communication = root.GetNestedSprite( "_bottomLeft", "communication" );
- // Oxygen
- oxygen = root.GetNestedSprite( "_bottomLeft", "oxygen" );
- flashlight = root.GetNestedSprite( "_bottomLeft", "flashlight" );
- // Objective
- objective = root.GetNestedSprite( "_right", "objective" );
- objectiveComplete = root.GetNestedSprite( "_right", "objectiveComplete" );
- // Ammo Info
- ammoInfo = root.GetNestedSprite( "_bottomRight", "ammoInfo" );
- bsInfo = root.GetNestedSprite( "_bottomRight", "bsInfo" );
- soulcubeInfo = root.GetNestedSprite( "_bottomRight", "soulcube" );
- // 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
- if ( showSoulCubeInfoOnLoad == true ) {
- showSoulCubeInfoOnLoad = false;
- UpdateSoulCube( true );
- }
- // Weapon pills
- weaponPills = root.GetNestedObj( "_bottomRight", "weaponState" );
- weaponImg = root.GetNestedSprite( "_bottomRight", "weaponIcon" );
- weaponName = root.GetNestedObj( "_bottomRight", "weaponName" );
- // Pickup Info
- newWeapon = root.GetNestedSprite( "_center", "newWeapon" );
- pickupInfo = root.GetNestedSprite( "_bottomLeft", "pickupInfo" );
- newItem = root.GetNestedSprite( "_left", "newItem" );
- // Cursors
- talkCursor = root.GetNestedSprite( "_center", "crosshairTalk" );
- combatCursor = root.GetNestedSprite( "_center", "crosshairCombat" );
- grabberCursor = root.GetNestedSprite( "_center", "crosshairGrabber" );
- respawnMessage = root.GetNestedSprite( "_center", "respawnMessage" );
- // 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" );
- // Functions
- class idTriggerNewPDAOrVideo : public idSWFScriptFunction_RefCounted {
- public:
- 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();
- }
- private:
- idMenuScreen_HUD * screen;
- };
- menuGUI->SetGlobal( "toggleNewNotification", new idTriggerNewPDAOrVideo( this ) );
- }
- /*
- ========================
- idMenuScreen_HUD::HideScreen
- ========================
- */
- void idMenuScreen_HUD::HideScreen( const mainMenuTransition_t transitionType ) {
-
- }
- /*
- ========================
- idMenuScreen_HUD::Update
- ========================
- */
- void idMenuScreen_HUD::Update() {
- idPlayer * player = gameLocal.GetLocalPlayer();
- if ( player == NULL ) {
- return;
- }
-
- idMenuScreen::Update();
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateHealth
- ========================
- */
- void idMenuScreen_HUD::UpdateHealthArmor( idPlayer * player ) {
- if ( !playerInfo || !player ) {
- return;
- }
- if ( common->IsMultiplayer() ) {
- playerInfo->GetSprite()->SetYPos( 20.0f );
- } else {
- playerInfo->GetSprite()->SetYPos( 0.0f );
- }
- idSWFTextInstance * txtVal = playerInfo->GetNestedText( "health", "txtVal" );
- if ( txtVal != NULL ) {
- txtVal->SetText( va( "%d", player->health ) );
- txtVal->SetStrokeInfo( true, 0.75f, 1.5f );
- // Set the damage color
- swfColorRGBA_t color;
- color.r = 255;
- color.a = 255;
- uint8 gbColor;
- if ( player->health > 60 ) {
- gbColor = 255;
- } else if ( player->health > 30 ) {
- gbColor = 156;
- } else {
- gbColor = 0;
- }
- color.g = gbColor;
- color.b = gbColor;
- txtVal->color = color;
- }
- txtVal = playerInfo->GetNestedText( "armor", "txtVal" );
- if ( txtVal != NULL ) {
- txtVal->SetText( va( "%d", player->inventory.armor ) );
- txtVal->SetStrokeInfo( true, 0.75f, 1.5f );
- if ( armorFrame != NULL ) {
- if ( player->inventory.armor == 0 ) {
- armorFrame->StopFrame( 2 );
- } else {
- armorFrame->StopFrame( 1 );
- }
- }
- }
- if ( healthBorder != NULL ) {
- healthBorder->StopFrame( 100 - player->health + 1 );
- }
- if ( healthPulse != NULL ) {
- if ( player->healthPulse ) {
- player->StartSound( "snd_healthpulse", SND_CHANNEL_ITEM, 0, false, NULL );
- player->healthPulse = false;
- healthPulse->SetVisible( true );
- healthPulse->PlayFrame( "rollOn" );
- }
- if ( player->healthTake ) {
- player->StartSound( "snd_healthtake", SND_CHANNEL_ITEM, 0, false, NULL );
- player->healthTake = false;
- healthPulse->SetVisible( true );
- healthPulse->PlayFrame( "rollOn" );
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateStamina
- ========================
- */
- void idMenuScreen_HUD::UpdateStamina( idPlayer * player ) {
- if ( !stamina || !player ) {
- return;
- }
- idSWFSpriteInstance * stamSprite = stamina->GetSprite();
- if ( stamSprite != NULL ) {
- if ( common->IsMultiplayer() ) {
- stamSprite->SetVisible( false );
- } else {
- float max_stamina = pm_stamina.GetFloat();
- if ( !max_stamina ) {
- stamSprite->SetVisible( false );
- } else {
- stamSprite->SetVisible( true );
- float staminaPercent = idMath::Ftoi( 100.0f * player->stamina / max_stamina );
- stamSprite->StopFrame( staminaPercent + 1 );
- }
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateLocation
- ========================
- */
- void idMenuScreen_HUD::UpdateWeaponInfo( idPlayer * player ) {
- if ( !player || !ammoInfo ) {
- return;
- }
- idEntityPtr<idWeapon> weapon = player->weapon;
- assert( weapon.GetEntity() );
- int inClip = weapon.GetEntity()->AmmoInClip();
- int ammoAmount = weapon.GetEntity()->AmmoAvailable();
- //Make sure the hud always knows how many bloodstone charges there are
- int ammoRequired;
- int bloodstoneAmmo = 0;
- if ( player->weapon_bloodstone >= 0 ) {
- ammo_t ammo_i = player->inventory.AmmoIndexForWeaponClass( "weapon_bloodstone_passive", &ammoRequired );
- bloodstoneAmmo = player->inventory.HasAmmo( ammo_i, ammoRequired );
- }
- if ( bsInfo ) {
- if ( bloodstoneAmmo > 0 ) {
- bsInfo->SetVisible( true );
- bsInfo->StopFrame( bloodstoneAmmo + 1 );
- } else {
- bsInfo->SetVisible( false );
- }
- }
- if ( ammoAmount == -1 || player->GetCurrentWeaponSlot() == player->weapon_bloodstone || player->GetCurrentWeaponSlot() == player->weapon_soulcube ) {
- ammoInfo->SetVisible( false );
- } else {
- idStr totalAmmo;
- idStr playerAmmo;
- idStr playerClip;
- bool showClip = true;
- //Hack to stop the bloodstone ammo to display when it is being activated
- if ( !weapon.GetEntity()->IsReady() ) {
- // show infinite ammo
- playerAmmo = "";
- totalAmmo = "";
- } else {
- // 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 );
- }
- if ( !weapon.GetEntity()->ClipSize() ) {
- showClip = false;
- }
- bool ammoEmpty = ( ammoAmount == 0 );
- bool clipEmpty = ( weapon.GetEntity()->ClipSize() ? inClip == 0 : false );
- bool clipLow = ( weapon.GetEntity()->ClipSize() ? inClip <= weapon.GetEntity()->LowAmmo() : false );
- //Hack to stop the bloodstone ammo to display when it is being activated
- if ( player->GetCurrentWeaponSlot() == player->weapon_bloodstone ) {
- ammoEmpty = false;
- clipEmpty = false;
- clipLow = false;
- }
- if ( showClip ) {
- ammoInfo->SetVisible( true );
- ammoInfo->StopFrame( 1 );
- if ( common->IsMultiplayer() ) {
- ammoInfo->SetYPos( 20.0f );
- } else {
- ammoInfo->SetYPos( 0.0f );
- }
- 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 ) {
- clipLowSprite->SetVisible( false );
- clipEmptySprite->SetVisible( true );
- txtClipSprite->StopFrame( 3 );
- } else if ( clipLow ) {
- clipLowSprite->SetVisible( true );
- clipEmptySprite->SetVisible( false );
- txtClipSprite->StopFrame( 2 );
- } else {
- clipLowSprite->SetVisible( false );
- clipEmptySprite->SetVisible( false );
- txtClipSprite->StopFrame( 1 );
- }
- if ( txtClip != NULL ) {
- txtClip->SetText( playerAmmo );
- txtClip->SetStrokeInfo( true, 0.75f, 1.5f );
- }
- }
- if ( txtAmmo != NULL ) {
-
- if ( ammoEmptySprite && txtAmmoSprite ) {
- if ( ammoEmpty ) {
- ammoEmptySprite->SetVisible( true );
- txtAmmoSprite->StopFrame( 2 );
- } else {
- ammoEmptySprite->SetVisible( false );
- txtAmmoSprite->StopFrame( 1 );
- }
- }
- txtAmmo->SetText( totalAmmo );
- txtAmmo->SetStrokeInfo( true, 0.75f, 1.5f );
- }
- } else {
- ammoInfo->SetVisible( true );
- ammoInfo->StopFrame( 2 );
- if ( common->IsMultiplayer() ) {
- ammoInfo->SetYPos( 20.0f );
- } else {
- ammoInfo->SetYPos( 0.0f );
- }
- idSWFTextInstance * txtAmmo = ammoInfo->GetScriptObject()->GetNestedText( "info", "txtVal" );
- if ( txtAmmo != NULL ) {
- txtAmmo->SetText( totalAmmo );
- txtAmmo->SetStrokeInfo( true, 0.75f, 1.5f );
- }
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::GiveWeapon
- ========================
- */
- void idMenuScreen_HUD::GiveWeapon( idPlayer * player, int weaponIndex ) {
- if ( common->IsMultiplayer() ) {
- return;
- }
- const char *weapnum = va( "def_weapon%d", weaponIndex );
- const char *weap = player->spawnArgs.GetString( weapnum );
- if ( weap != NULL && *weap != NULL ) {
- const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
- if ( weaponDef != NULL ) {
- const char * hudIconName = weaponDef->dict.GetString( "hudIcon" );
- if ( hudIconName[ 0 ] == '\0' ) {
- idLib::Warning( "idMenuScreen_HUD: Missing hudIcon for weapon %s", weap );
- return;
- }
- const idMaterial * hudIcon = declManager->FindMaterial( hudIconName, false );
- if ( newWeapon != NULL ) {
- newWeapon->SetVisible( true );
- newWeapon->PlayFrame( 2 );
- idSWFSpriteInstance * topImg = newWeapon->GetScriptObject()->GetNestedSprite( "topImg" );
- idSWFSpriteInstance * botImg = newWeapon->GetScriptObject()->GetNestedSprite( "botImg" );
- if ( topImg && botImg ) {
- topImg->SetMaterial( hudIcon );
- botImg->SetMaterial( hudIcon );
- }
- }
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateWeaponStates
- ========================
- */
- void idMenuScreen_HUD::UpdatePickupInfo( int index, const idStr & name ) {
- if ( !pickupInfo ) {
- return;
- }
- idSWFTextInstance * txtItem = pickupInfo->GetScriptObject()->GetNestedText( va( "item%d", index ), "txtVal" );
- if ( txtItem != NULL ) {
- txtItem->SetText( name );
- txtItem->SetStrokeInfo( true, 0.6f, 2.0f );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::IsPickupListReady
- ========================
- */
- bool idMenuScreen_HUD::IsPickupListReady() {
- if ( !pickupInfo ) {
- return false;
- }
- if ( pickupInfo->GetCurrentFrame() == 1 ) {
- return true;
- }
- return false;
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateWeaponStates
- ========================
- */
- void idMenuScreen_HUD::ShowPickups() {
- if ( !pickupInfo ) {
- return;
- }
- pickupInfo->SetVisible( true );
- pickupInfo->PlayFrame( "rollOn" );
- }
- /*
- ========================
- idMenuScreen_HUD::SetCursorState
- ========================
- */
- void idMenuScreen_HUD::SetCursorState( idPlayer * player, cursorState_t state, int set ) {
- switch ( state ) {
- case CURSOR_TALK: {
- cursorNone = 0;
- cursorTalking = set;
- break;
- }
- case CURSOR_IN_COMBAT: {
- cursorNone = 0;
- cursorInCombat = set;
- break;
- }
- case CURSOR_ITEM: {
- cursorNone = 0;
- cursorItem = set;
- break;
- }
- case CURSOR_GRABBER: {
- cursorNone = 0;
- cursorGrabber = set;
- break;
- }
- case CURSOR_NONE: {
- // so that talk button still appears for 3D view
- if ( cursorState != CURSOR_TALK || cursorTalking != 1 ) {
- cursorTalking = 0;
- cursorGrabber = 0;
- cursorInCombat = 0;
- cursorItem = 0;
- cursorNone = 1;
- }
- break;
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::SetCursorText
- ========================
- */
- void idMenuScreen_HUD::SetCursorText( const idStr & action, const idStr & focus ) {
- cursorAction = action;
- cursorFocus = focus;
- }
- /*
- ========================
- idMenuScreen_HUD::CombatCursorFlash
- ========================
- */
- void idMenuScreen_HUD::CombatCursorFlash() {
- if ( cursorInCombat ) {
- if ( cursorState == CURSOR_IN_COMBAT ) {
- if ( combatCursor ) {
- combatCursor->PlayFrame( "hit" );
- }
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateCursorState
- ========================
- */
- void idMenuScreen_HUD::UpdateCursorState() {
- if ( !cursorTalking && !cursorInCombat && !cursorGrabber && !cursorItem ) {
- cursorNone = true;
- cursorState = CURSOR_NONE;
- // hide all cursors
- if ( combatCursor ) {
- combatCursor->StopFrame( 1 );
- combatCursor->SetVisible( false );
- }
- if ( talkCursor ) {
- talkCursor->StopFrame( 1 );
- talkCursor->SetVisible( false );
- }
- if ( grabberCursor ) {
- grabberCursor->StopFrame( 1 );
- grabberCursor->SetVisible( false );
- }
-
- } else {
- if ( cursorTalking ) {
- if ( cursorTalking == 1 ) { // ready to talk
- } else if ( cursorTalking == 2 ) { // already talking / busy
- }
- if ( cursorState != CURSOR_TALK ) {
-
- if ( combatCursor ) {
- combatCursor->StopFrame( 1 );
- combatCursor->SetVisible( false );
- }
- if ( grabberCursor ) {
- grabberCursor->StopFrame( 1 );
- grabberCursor->SetVisible( false );
- }
- // play roll on
- if ( talkCursor ) {
- talkCursor->SetVisible( true );
- talkCursor->PlayFrame( 2 );
- 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() ) {
- txtAction->tooltip = true;
- keyBindings_t bind = idKeyInput::KeyBindingsFromBinding( "_use", true );
- idStr actionText = idLocalization::GetString( cursorAction );
- if ( !bind.mouse.IsEmpty() ) {
- actionText.Append( " [" );
- actionText.Append( bind.mouse );
- actionText.Append( "]" );
- } else if ( !bind.keyboard.IsEmpty() ) {
- actionText.Append( " [" );
- actionText.Append( bind.keyboard );
- actionText.Append( "]" );
- }
-
- txtAction->SetText( actionText );
- } else {
- txtAction->tooltip = false;
- txtAction->SetText( cursorAction );
- }
- txtAction->SetStrokeInfo( true, 0.75f, 1.5f );
- float actionLength = txtAction->GetTextLength();
- if ( topBacking ) {
- if ( !cursorAction.IsEmpty() ) {
- topBacking->SetXPos( actionLength );
- } else {
- topBacking->SetXPos( -75.0f );
- }
- }
- }
- if ( txtFocus ) {
- txtFocus->SetText( cursorFocus );
- txtFocus->SetStrokeInfo( true, 0.75f, 1.5f );
- float focusLength = txtFocus->GetTextLength();
- if ( bottomBacking ) {
- if ( !cursorFocus.IsEmpty() ) {
- bottomBacking->SetXPos( focusLength );
- } else {
- bottomBacking->SetXPos( -75.0f );
- }
- }
- }
- if ( txtPrompt ) {
- if ( in_useJoystick.GetBool() ) {
- txtPrompt->tooltip = true;
- txtPrompt->SetText( "_use" );
- } else {
- txtPrompt->tooltip = false;
- txtPrompt->SetText( "" );
- }
- }
- }
- cursorState = CURSOR_TALK;
- }
- } else if ( cursorGrabber ) {
- if ( talkCursor ) {
- talkCursor->StopFrame( 1 );
- talkCursor->SetVisible( false );
- }
- if ( combatCursor ) {
- combatCursor->StopFrame( 1 );
- combatCursor->SetVisible( false );
- }
- if ( cursorState != CURSOR_GRABBER ) {
- if ( grabberCursor ) {
- grabberCursor->SetVisible( true );
- grabberCursor->PlayFrame( "loop" );
- }
- }
- cursorState = CURSOR_GRABBER;
- } else if ( cursorItem ) {
- cursorState = CURSOR_ITEM;
- } else if ( cursorInCombat ) {
- if ( cursorState == CURSOR_TALK ) {
- if ( talkCursor ) {
- talkCursor->StopFrame( 1 );
- talkCursor->SetVisible( false );
- }
- if ( combatCursor ) {
- combatCursor->SetVisible( true );
- combatCursor->PlayFrame( "rollOn" );
- }
- // play cursor roll on
- } else if ( cursorState != CURSOR_IN_COMBAT ) {
- if ( grabberCursor ) {
- grabberCursor->StopFrame( 1 );
- grabberCursor->SetVisible( false );
- }
- // set cursor visible
- if ( combatCursor ) {
- combatCursor->SetVisible( true );
- combatCursor->StopFrame( 2 );
- }
- }
- cursorState = CURSOR_IN_COMBAT;
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateSoulCube
- ========================
- */
- void idMenuScreen_HUD::UpdateSoulCube( bool ready ) {
- if ( !soulcubeInfo ) {
- return;
- }
- if ( ready && !soulcubeInfo->IsVisible() ) {
- soulcubeInfo->SetVisible( true );
- soulcubeInfo->PlayFrame( "rollOn" );
- } else if ( !ready ) {
- soulcubeInfo->PlayFrame( "rollOff" );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::ShowRespawnMessage
- ========================
- */
- void idMenuScreen_HUD::ShowRespawnMessage( bool show ) {
- if ( !respawnMessage ) {
- return;
- }
- if ( show ) {
- respawnMessage->SetVisible( true );
- respawnMessage->PlayFrame( "rollOn" );
- idSWFTextInstance * message = respawnMessage->GetScriptObject()->GetNestedText( "info", "txtMessage" );
- if ( message != NULL ) {
- message->tooltip = true;
- message->SetText( "#str_respawn_message" );
- message->SetStrokeInfo( true );
- }
- } else {
- if ( respawnMessage->IsVisible() ) {
- respawnMessage->PlayFrame( "rollOff" );
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateWeaponStates
- ========================
- */
- void idMenuScreen_HUD::UpdateWeaponStates( idPlayer * player, bool weaponChanged ) {
- if ( !weaponPills ) {
- return;
- }
- if ( player == NULL ) {
- return;
- }
- idStr displayName;
- if ( common->IsMultiplayer() ) {
- if ( !mpWeapons || player->GetIdealWeapon() == 0 ) {
- return;
- }
- weaponPills->GetSprite()->SetVisible( false );
- if ( weaponChanged ) {
- mpWeapons->GetSprite()->SetVisible( true );
- mpWeapons->GetSprite()->PlayFrame( "rollOn" );
- int weaponDefIndex = -1;
- idList< idStr > weaponDefNames;
- // start at 1 so we skip the fists
- for ( int i = 1; i < MAX_WEAPONS; ++i ) {
- if ( player->inventory.weapons & ( 1 << i ) ) {
- if ( i == player->GetIdealWeapon() ) {
- weaponDefIndex = weaponDefNames.Num();
- }
- weaponDefNames.Append( va( "def_weapon%d", i ) );
- }
- }
- int numRightWeapons = 0;
- int numLeftWeapons = 0;
-
- if ( weaponDefNames.Num() == 2 ) {
- numRightWeapons = 1 - weaponDefIndex;
- numLeftWeapons = weaponDefIndex;
- } else if ( weaponDefNames.Num() == 3 ) {
- numRightWeapons = 1;
- numLeftWeapons = 1;
- } else if ( weaponDefNames.Num() > 3 ) {
- numRightWeapons = 2;
- numLeftWeapons = 2;
- }
- for ( int i = -2; i < 3; ++i ) {
- bool hide = false;
-
- if ( i < 0 && idMath::Abs( i ) > numLeftWeapons ) {
- hide = true;
- } else if ( i > numRightWeapons ) {
- hide = true;
- } else if ( weaponDefNames.Num() == 0 ) {
- hide = true;
- }
- int index = i;
- if ( i < 0 ) {
- index = 2 + idMath::Abs( i );
- }
-
- 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 ) {
- mpWeapons->GetSprite()->SetVisible( false );
- break;
- }
- if ( hide ) {
- topValid->SetVisible( false );
- botValid->SetVisible( false );
- topInvalid->SetVisible( false );
- botInvalid->SetVisible( false );
- continue;
- }
- int weaponIndex = weaponDefIndex + i;
- if ( weaponIndex < 0 ) {
- weaponIndex = weaponDefNames.Num() + weaponIndex;
- } else if ( weaponIndex >= weaponDefNames.Num() ) {
- weaponIndex = ( weaponIndex - weaponDefNames.Num() );
- }
-
- int weapState = 1;
- const idMaterial * hudIcon = NULL;
- const char * weapNum = weaponDefNames[ weaponIndex ];
- const char * weap = player->spawnArgs.GetString( weapNum );
- if ( weap != NULL && *weap != NULL ) {
- const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
- if ( weaponDef != NULL ) {
- hudIcon = declManager->FindMaterial( weaponDef->dict.GetString( "hudIcon" ), false );
- if ( i == 0 ) {
- displayName = weaponDef->dict.GetString( "display_name" );
- weapState++;
- }
- }
- if ( !player->inventory.HasAmmo( weap, true, player ) ) {
- weapState = 0;
- }
- }
- topValid->SetVisible( false );
- botValid->SetVisible( false );
- topInvalid->SetVisible( false );
- botInvalid->SetVisible( false );
- topValid->SetMaterial( hudIcon );
- botValid->SetMaterial( hudIcon );
- topInvalid->SetMaterial( hudIcon );
- botInvalid->SetMaterial( hudIcon );
-
- if ( weapState == 0 ) {
- botInvalid->SetVisible( true );
- if ( i == 0 ) {
- topInvalid->SetVisible( true );
- }
- } else if ( weapState == 2 ) {
- topValid->SetVisible( true );
- botValid->SetVisible( true );
- } else {
- botValid->SetVisible( true );
- }
- }
- }
- } else {
- bool hasWeapons = false;
- const idMaterial * hudIcon = NULL;
- for ( int i = 0; i < MAX_WEAPONS; i++ ) {
- const char *weapnum = va( "def_weapon%d", i );
- int weapstate = 0;
- if ( player->inventory.weapons & ( 1 << i ) ) {
- hasWeapons = true;
- const char *weap = player->spawnArgs.GetString( weapnum );
- if ( weap != NULL && *weap != NULL ) {
- weapstate++;
- }
- if ( player->GetIdealWeapon() == i ) {
- const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
- if ( weaponDef != NULL ) {
- hudIcon = declManager->FindMaterial( weaponDef->dict.GetString( "hudIcon" ), false );
- displayName = weaponDef->dict.GetString( "display_name" );
- }
- weapstate++;
- }
- }
- idSWFSpriteInstance * pill = weaponPills->GetNestedSprite( va( "pill%d", i ) );
- if ( pill ) {
- pill->StopFrame( weapstate + 1 );
- }
- }
- if ( !hasWeapons ) {
- weaponPills->GetSprite()->SetVisible( false );
- } else {
- weaponPills->GetSprite()->SetVisible( true );
- }
- if ( weaponImg ) {
- if ( weaponChanged && hudIcon != NULL ) {
- weaponImg->SetVisible( true );
- weaponImg->PlayFrame( 2 );
- idSWFSpriteInstance * topImg = weaponImg->GetScriptObject()->GetNestedSprite( "topImg" );
- idSWFSpriteInstance * botImg = weaponImg->GetScriptObject()->GetNestedSprite( "botImg" );
- if ( topImg != NULL && botImg != NULL ) {
- topImg->SetMaterial( hudIcon );
- botImg->SetMaterial( hudIcon );
- }
- /*if ( weaponName && weaponName->GetSprite() ) {
- weaponName->GetSprite()->SetVisible( true );
- weaponName->GetSprite()->PlayFrame( 2 );
- idSWFTextInstance * txtVal = weaponName->GetNestedText( "info", "txtVal" );
- if ( txtVal != NULL ) {
- txtVal->SetText( displayName );
- txtVal->SetStrokeInfo( true, 0.6f, 2.0f );
- }
- }*/
- }
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateLocation
- ========================
- */
- void idMenuScreen_HUD::UpdateLocation( idPlayer * player ) {
- if ( !locationName || !player ) {
- return;
- }
- idPlayer * playertoLoc = player;
- if( player->spectating && player->spectator != player->entityNumber ) {
- playertoLoc = static_cast< idPlayer* >( gameLocal.entities[ player->spectator ] );
- if( playertoLoc == NULL ) {
- playertoLoc = player;
- }
- }
- idLocationEntity *locationEntity = gameLocal.LocationForPoint( playertoLoc->GetEyePosition() );
- if ( locationEntity ) {
- locationName->SetText( locationEntity->GetLocation() );
- } else {
- locationName->SetText( idLocalization::GetString( "#str_02911" ) );
- }
- locationName->SetStrokeInfo( true, 0.6f, 2.0f );
- }
- /*
- ========================
- idMenuScreen_HUD::ShowTip
- ========================
- */
- void idMenuScreen_HUD::ShowTip( const char * title, const char * tip ) {
- if ( !tipInfo ) {
- return;
- }
- idSWFSpriteInstance * tipSprite = tipInfo->GetSprite();
-
- if ( !tipSprite ) {
- return;
- }
- tipSprite->SetVisible( true );
- tipSprite->PlayFrame( "rollOn" );
- idSWFTextInstance * txtTitle = tipInfo->GetNestedText( "info", "txtTitle" );
- idSWFTextInstance * txtTip = tipInfo->GetNestedText( "info", "txtTip" );
- if ( txtTitle != NULL ) {
- txtTitle->SetText( title );
- txtTitle->SetStrokeInfo( true, 0.75f, 1.5f );
- }
- if ( txtTip != NULL ) {
- txtTip->SetText( tip );
- txtTip->tooltip = true;
- txtTip->SetStrokeInfo( true, 0.75f, 1.5f );
- int numLines = txtTip->CalcNumLines();
- if ( numLines == 0 ) {
- numLines = 1;
- }
- idSWFSpriteInstance * backing = tipInfo->GetNestedSprite( "info", "backing" );
- if ( backing != NULL ) {
- backing->StopFrame( numLines );
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::HideTip
- ========================
- */
- void idMenuScreen_HUD::HideTip() {
- if ( !tipInfo ) {
- return;
- }
- idSWFSpriteInstance * tipSprite = tipInfo->GetSprite();
- if ( !tipSprite ) {
- return;
- }
- tipSprite->SetVisible( true );
- tipSprite->PlayFrame( "rollOff" );
- }
- /*
- ========================
- idMenuScreen_HUD::DownloadPDA
- ========================
- */
- void idMenuScreen_HUD::DownloadPDA( const idDeclPDA * pda, bool newSecurity ) {
- if ( newPDADownload ) {
- newPDADownload->SetVisible( true );
- newPDADownload->PlayFrame( "rollOn" );
- newPDAName = newPDADownload->GetScriptObject()->GetNestedText( "info", "txtName" );
- newPDAHeading = newPDADownload->GetScriptObject()->GetNestedText( "info", "txtHeading" );
-
- if ( newPDAName && GetSWFObject() != NULL ) {
- idStr pdaName = pda->GetPdaName();
- pdaName.RemoveColors();
- GetSWFObject()->SetGlobal( "pdaNameDownload", pdaName );
- newPDAName->SetStrokeInfo( true, 0.9f, 2.0f );
- }
- if ( newPDAHeading && GetSWFObject() != NULL ) {
- GetSWFObject()->SetGlobal( "pdaDownloadHeading", "#str_02031" );
- newPDAHeading->SetStrokeInfo( true, 0.9f, 2.0f );
- }
- }
- if ( newSecurity ) {
- UpdatedSecurity();
- }
- }
- /*
- ========================
- idMenuScreen_HUD::DownloadVideo
- ========================
- */
- void idMenuScreen_HUD::DownloadVideo() {
- if ( newVideoDownload ) {
- newVideoDownload->SetVisible( true );
- newVideoDownload->PlayFrame( "rollOn" );
-
- newVideoHeading = newVideoDownload->GetScriptObject()->GetNestedText( "info", "txtHeading" );
- if ( newVideoHeading ) {
- newVideoHeading->SetText( "#str_02033" );
- newVideoHeading->SetStrokeInfo( true, 0.9f, 2.0f );
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdatedSecurity
- ========================
- */
- void idMenuScreen_HUD::UpdatedSecurity() {
- if ( security != NULL && securityText != NULL ) {
- security->SetVisible( true );
- security->PlayFrame( "rollOn" );
- securityText->SetText( "#str_02032" );
- securityText->SetStrokeInfo( true, 0.9f, 2.0f );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::ClearNewPDAInfo
- ========================
- */
- void idMenuScreen_HUD::ClearNewPDAInfo() {
- ToggleNewVideo( false );
- ToggleNewPDA( false );
- if ( security ) {
- security->StopFrame( 1 );
- }
- if ( newPDADownload ) {
- newPDADownload->StopFrame( 1 );
- }
- if ( newVideoDownload ) {
- newVideoDownload->StopFrame( 1 );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdatedSecurity
- ========================
- */
- void idMenuScreen_HUD::ToggleNewVideo( bool show ) {
- if ( !newVideo ) {
- return;
- }
- if ( show && !newVideo->IsVisible() ) {
- newVideo->SetVisible( true );
- newVideo->PlayFrame( "rollOn" );
- } else if ( !show ) {
- newVideo->StopFrame( 1 );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdatedSecurity
- ========================
- */
- void idMenuScreen_HUD::ToggleNewPDA( bool show ) {
- if ( !newPDA ) {
- return;
- }
- if ( show && !newPDA->IsVisible() ) {
- newPDA->SetVisible( true );
- newPDA->PlayFrame( "rollOn" );
- } else if ( !show ) {
- newPDA->StopFrame( 1 );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdatedSecurity
- ========================
- */
- void idMenuScreen_HUD::UpdateAudioLog( bool show ) {
- if ( !audioLog ) {
- return;
- }
- if ( show && !audioLog->IsVisible() ) {
- audioLog->SetVisible( true );
- audioLog->StopFrame( "2" );
- for ( int index = 0; index < 13; ++index ) {
- idSWFSpriteInstance * node = audioLog->GetScriptObject()->GetNestedSprite( "bar", va( "node%d", index ) );
- if ( node != NULL ) {
- int frame = gameLocal.random.RandomInt( 100 );
- node->SetScale( 100.0f, frame );
- float toFrame = gameLocal.random.RandomFloat();
- node->SetMoveToScale( -1.0f, toFrame );
- }
- }
- } else if ( !show ) {
- audioLog->StopFrame( 1 );
- } else if ( show ) {
- if ( audioLogPrevTime == 0 ) {
- audioLogPrevTime = gameLocal.time;
- }
- for ( int index = 0; index < 13; ++index ) {
- idSWFSpriteInstance * node = audioLog->GetScriptObject()->GetNestedSprite( "bar", va( "node%d", index ) );
- if ( node != NULL ) {
- float diff = gameLocal.time - audioLogPrevTime;
- float speed = ( diff / 350.0f ) * 100.0f;
- if ( !node->UpdateMoveToScale( speed ) ) {
- int frame = gameLocal.random.RandomInt( 100 );
- float scale = frame / 100.0f;
- node->SetMoveToScale( -1.0f, scale );
- }
- }
- }
- audioLogPrevTime = gameLocal.time;
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdatedSecurity
- ========================
- */
- void idMenuScreen_HUD::UpdateCommunication( bool show, idPlayer * player ) {
- if ( !communication || !player ) {
- return;
- }
- bool oxygenChanged = false;
- if ( inVaccuum != oxygenComm ) {
- oxygenChanged = true;
- }
- if ( show && !communication->IsVisible() ) {
- communication->SetVisible( true );
- if ( inVaccuum ) {
- communication->StopFrame( "oxygen" );
- } else {
- communication->StopFrame( "2" );
- }
- for ( int index = 0; index < 16; ++index ) {
- idSWFSpriteInstance * node = communication->GetScriptObject()->GetNestedSprite( "info", "bar", va( "node%d", index ) );
- if ( node != NULL ) {
- int frame = gameLocal.random.RandomInt( 100 );
- node->SetScale( 100.0f, frame );
- float toFrame = gameLocal.random.RandomFloat();
- node->SetMoveToScale( -1.0f, toFrame );
- }
- }
- } else if ( !show ) {
- communication->StopFrame( 1 );
- } else if ( show ) {
- if ( oxygenChanged ) {
- if ( inVaccuum ) {
- communication->PlayFrame( "rollUp" );
- } else {
- communication->PlayFrame( "rollDown" );
- }
- }
- if ( commPrevTime == 0 ) {
- commPrevTime = gameLocal.time;
- }
- for ( int index = 0; index < 16; ++index ) {
- idSWFSpriteInstance * node = communication->GetScriptObject()->GetNestedSprite( "info", "bar", va( "node%d", index ) );
- if ( node != NULL ) {
- float diff = gameLocal.time - commPrevTime;
- float speed = ( diff / 350.0f ) * 100.0f;
- if ( !node->UpdateMoveToScale( speed ) ) {
- int frame = gameLocal.random.RandomInt( 100 );
- float scale = frame / 100.0f;
- node->SetMoveToScale( -1.0f, scale );
- }
- }
- }
- commPrevTime = gameLocal.time;
- }
-
- oxygenComm = inVaccuum;
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateOxygen
- ========================
- */
- void idMenuScreen_HUD::UpdateOxygen( bool show, int val ) {
- if ( !oxygen ) {
- return;
- }
- if ( show ) {
- if ( !oxygen->IsVisible() ) {
- inVaccuum = true;
- oxygen->SetVisible( true );
- oxygen->PlayFrame( "rollOn" );
- }
- idSWFSpriteInstance * info = oxygen->GetScriptObject()->GetNestedSprite( "info" );
- if ( info != NULL ) {
- info->StopFrame( val + 1 );
- }
- idSWFSpriteInstance * goodFrame = oxygen->GetScriptObject()->GetNestedSprite( "goodFrame" );
- idSWFSpriteInstance * badFrame = oxygen->GetScriptObject()->GetNestedSprite( "badFrame" );
- if ( goodFrame != NULL && badFrame != NULL ) {
- if ( val + 1 >= 36 ) {
- goodFrame->SetVisible( true );
- badFrame->SetVisible( false );
- } else {
- goodFrame->SetVisible( false );
- badFrame->SetVisible( true );
- }
- }
- idSWFTextInstance * txtVal = oxygen->GetScriptObject()->GetNestedText( "info", "txtHeading" );
- if ( txtVal != NULL ) {
- txtVal->SetText( "#str_00100922" );
- txtVal->SetStrokeInfo( true, 0.9f, 2.0f );
- }
- txtVal = oxygen->GetScriptObject()->GetNestedText( "info", "txtVal" );
- if ( txtVal != NULL ) {
- txtVal->SetText( va( "%d", val ) );
- txtVal->SetStrokeInfo( true, 0.9f, 2.0f );
- }
-
- } else if ( !show ) {
- inVaccuum = false;
- oxygen->StopFrame( 1 );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::SetupObjective
- ========================
- */
- void idMenuScreen_HUD::SetupObjective( const idStr & title, const idStr & desc, const idMaterial * screenshot ) {
- objTitle = title;
- objDesc = desc;
- objScreenshot = screenshot;
- }
- /*
- ========================
- idMenuScreen_HUD::SetupObjective
- ========================
- */
- void idMenuScreen_HUD::SetupObjectiveComplete( const idStr & title ) {
- objCompleteTitle = title;
- }
- /*
- ========================
- idMenuScreen_HUD::ShowObjective
- ========================
- */
- void idMenuScreen_HUD::ShowObjective( bool complete ) {
- if ( complete ) {
- if ( !objectiveComplete ) {
- return;
- }
- objectiveComplete->SetVisible( true );
- objectiveComplete->PlayFrame( "rollOn" );
- 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 ) {
- txtComplete->SetStrokeInfo( true, 0.9f, 2.0f );
- if ( rightArrow != NULL ) {
- rightArrow->SetXPos( txtComplete->GetTextLength() + 30.0f );
- }
- }
- if ( txtTitle != NULL ) {
- txtTitle->SetText( objCompleteTitle );
- txtTitle->SetStrokeInfo( true, 0.9f, 2.0f );
- }
- } else {
- if ( !objective ) {
- return;
- }
- objective->SetVisible( true );
- objective->PlayFrame( "rollOn" );
- 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 ) {
- txtNew->SetStrokeInfo( true, 0.9f, 2.0f );
- if ( rightArrow != NULL ) {
- rightArrow->SetXPos( txtNew->GetTextLength() + 55.0f );
- }
- }
- if ( txtTitle != NULL ) {
- txtTitle->SetText( objTitle );
- txtTitle->SetStrokeInfo( true, 0.9f, 2.0f );
- }
- if ( txtDesc ) {
- txtDesc->SetText( objDesc );
- }
- if ( img != NULL ) {
- img->SetMaterial( objScreenshot );
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::HideObjective
- ========================
- */
- void idMenuScreen_HUD::HideObjective( bool complete ) {
- if ( complete ) {
- if ( !objectiveComplete ) {
- return;
- }
- objectiveComplete->PlayFrame( "rollOff" );
- } else {
- if ( !objective ) {
- return;
- }
- objective->PlayFrame( "rollOff" );
- }
- }
- //******************************************************************************************
- // MULTIPLAYER FUNCITONS
- //******************************************************************************************
- /*
- ========================
- idMenuScreen_HUD::ToggleMPInfo
- ========================
- */
- void idMenuScreen_HUD::ToggleMPInfo( bool show, bool showTeams, bool isCTF ) {
- if ( !mpInfo ) {
- return;
- }
- if ( show ) {
- mpInfo->SetVisible( true );
- 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 ) {
- redFlag->SetVisible( isCTF );
- }
- if ( blueFlag ) {
- blueFlag->SetVisible( isCTF );
- }
- if ( !showTeams ) {
- if ( redTeam ) {
- redTeam->SetVisible( false );
- }
- if ( blueTeam ) {
- blueTeam->SetVisible( false );
- }
- } else {
- if ( redTeam ) {
- redTeam->SetVisible( true );
- }
- if ( blueTeam ) {
- blueTeam->SetVisible( true );
- }
- }
-
- } else {
- mpInfo->SetVisible( false );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::SetFlagState
- ========================
- */
- void idMenuScreen_HUD::SetFlagState( int team, int state ) {
- if ( !mpInfo ) {
- return;
- }
-
- idSWFSpriteInstance * flag = NULL;
- if ( team == 0 ) {
- flag = mpInfo->GetScriptObject()->GetNestedSprite( "redFlag" );
- } else if ( team == 1 ) {
- flag = mpInfo->GetScriptObject()->GetNestedSprite( "blueFlag" );
- }
- if ( flag ) {
- if ( state == 3 ) { //FLAGSTATUS_NONE
- flag->StopFrame( 1 );
- } else {
- flag->SetVisible( true );
- flag->StopFrame( state + 2 );
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::SetTeamScore
- ========================
- */
- void idMenuScreen_HUD::SetTeamScore( int team, int score ) {
- if ( !mpInfo ) {
- return;
- }
- idSWFTextInstance * txtScore = NULL;
- if ( team == 0 ) {
- txtScore = mpInfo->GetScriptObject()->GetNestedText( "redTeam", "txtRedScore" );
- } else if ( team == 1 ) {
- txtScore = mpInfo->GetScriptObject()->GetNestedText( "blueTeam", "txtBlueScore" );
- }
- if ( txtScore ) {
- txtScore->SetText( va( "%i", score ) );
- txtScore->SetStrokeInfo( true, 0.75f, 1.5f );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::SetTeam
- ========================
- */
- void idMenuScreen_HUD::SetTeam( int team ) {
- if ( !mpInfo ) {
- return;
- }
- idSWFSpriteInstance * teamBacking = mpInfo->GetScriptObject()->GetNestedSprite( "teamBack" );
- if ( teamBacking ) {
- if ( team < 0 ) {
- teamBacking->StopFrame( 3 );
- } else {
- teamBacking->StopFrame( team + 1 );
- }
- }
- }
- /*
- ========================
- idMenuScreen_HUD::TriggerHitTarget
- ========================
- */
- void idMenuScreen_HUD::TriggerHitTarget( bool show, const idStr & target, int color ) {
- if ( !mpHitInfo ) {
- return;
- }
- if ( show ) {
- mpHitInfo->SetVisible( true );
- mpHitInfo->PlayFrame( "rollOn" );
- if ( menuGUI ) {
- menuGUI->SetGlobal( "hitTargetName", target.c_str() );
- }
- idSWFSpriteInstance * backing = mpHitInfo->GetScriptObject()->GetNestedSprite( "bgColor" );
- if ( backing ) {
- if ( color <= 0 || !gameLocal.mpGame.IsGametypeTeamBased() ) {
- color = 1;
- }
- backing->StopFrame( color );
- }
- } else {
- mpHitInfo->PlayFrame( "rollOff" );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::ToggleLagged
- ========================
- */
- void idMenuScreen_HUD::ToggleLagged( bool show ) {
- if ( !mpConnection ) {
- return;
- }
- mpConnection->SetVisible( show );
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateGameTime
- ========================
- */
- void idMenuScreen_HUD::UpdateGameTime( const char * time ) {
- if ( !mpTime ) {
- return;
- }
- UpdateMessage( false, "" );
- mpTime->SetText( time );
- mpTime->SetStrokeInfo( true, 0.75f, 1.5f );
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateMessage
- ========================
- */
- void idMenuScreen_HUD::UpdateMessage( bool show, const idStr & message ) {
- if ( !mpMessage ) {
- return;
- }
- if ( show ) {
- if ( mpTime ) {
- mpTime->SetText( "" );
- }
- mpMessage->SetText( message );
- mpMessage->SetStrokeInfo( true, 0.75f, 1.5f );
- } else {
- mpMessage->SetText( "" );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::ShowNewItem
- ========================
- */
- void idMenuScreen_HUD::ShowNewItem( const char * name, const char * icon ) {
- if ( !newItem ) {
- return;
- }
- newItem->SetVisible( true );
- newItem->PlayFrame( "rollOn" );
- 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 ) {
- topImg->SetMaterial( mat );
- botImg->SetMaterial( mat );
- }
- if ( heading != NULL ) {
- heading->SetText( "#str_02027" );
- heading->SetStrokeInfo( true, 0.75f, 1.5f );
- }
- if ( itemName != NULL ) {
- itemName->SetText( name );
- itemName->SetStrokeInfo( true, 0.75f, 1.5f );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateFlashlight
- ========================
- */
- void idMenuScreen_HUD::UpdateFlashlight( idPlayer * player ) {
- if ( !player || !flashlight ) {
- return;
- }
- if ( player->flashlightBattery != flashlight_batteryDrainTimeMS.GetInteger() ) {
- flashlight->StopFrame( 2 );
- flashlight->SetVisible( true );
- idSWFSpriteInstance * batteryLife = flashlight->GetScriptObject()->GetNestedSprite( "info" );
- if ( batteryLife ) {
- float power = ( (float)player->flashlightBattery / (float)flashlight_batteryDrainTimeMS.GetInteger() ) * 100.0f;
- batteryLife->StopFrame( power );
- }
- } else {
- flashlight->StopFrame( 1 );
- }
- }
- /*
- ========================
- idMenuScreen_HUD::UpdateChattingHud
- ========================
- */
- void idMenuScreen_HUD::UpdateChattingHud( idPlayer * player ) {
- if ( !mpChatObject || !GetSWFObject() ) {
- return;
- }
- idSWF * gui = GetSWFObject();
- if ( player->isChatting == 0 ) {
- if ( mpChatObject->GetCurrentFrame() != 1 ) {
- mpChatObject->StopFrame( 1 );
- gui->ForceInhibitControl( false );
- gui->SetGlobal( "focusWindow", NULL );
- }
- } else {
- if ( !mpChatObject->IsVisible() ) {
- mpChatObject->SetVisible( true );
- mpChatObject->PlayFrame( "rollOn" );
- gui->ForceInhibitControl( true );
- idSWFTextInstance * txtType = mpChatObject->GetScriptObject()->GetNestedText( "info", "saybox" );
- int length = 0;
- if ( txtType ) {
- if ( player->isChatting == 1 ) {
- txtType->SetText( "#str_swf_talk_all" );
- } else if ( player->isChatting == 2 ) {
- txtType->SetText( "#str_swf_talk_team" );
- }
- txtType->SetStrokeInfo( true );
- length = txtType->GetTextLength();
- }
- idSWFSpriteInstance * sayBox = mpChatObject->GetScriptObject()->GetNestedSprite( "info", "textEntry" );
- if ( sayBox ) {
- sayBox->SetXPos( length + 10 );
- }
- idSWFTextInstance * say = mpChatObject->GetScriptObject()->GetNestedText( "info", "textEntry", "txtVal" );
- if ( say != NULL ) {
- say->SetIgnoreColor( false );
- say->SetText( "" );
- say->SetStrokeInfo( true );
- say->renderMode = SWF_TEXT_RENDER_AUTOSCROLL;
- }
- idSWFScriptObject * const sayObj = mpChatObject->GetScriptObject()->GetNestedObj( "info", "textEntry", "txtVal" );
- if ( sayObj != NULL ) {
- gui->SetGlobal( "focusWindow", sayObj );
-
- class idPostTextChat : public idSWFScriptFunction_RefCounted {
- public:
- idPostTextChat( idPlayer * _player, idSWFTextInstance * _text ) {
- player = _player;
- text = _text;
- }
- idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
- if ( !player || !text ) {
- return idSWFScriptVar();
- }
- idStr val = text->text;
- val.Replace( "\'", "" );
- val.Replace( "\"", "" );
- idStr command;
- if ( player->isChatting == 2 ) {
- command = va( "sayTeam %s\n", val.c_str() );
- } else {
- command = va( "say %s\n", val.c_str() );
- }
- cmdSystem->BufferCommandText( CMD_EXEC_NOW, command.c_str() );
- player->isChatting = 0;
- return idSWFScriptVar();
- }
- idPlayer * player;
- idSWFTextInstance * text;
- };
- class idCancelTextChat : public idSWFScriptFunction_RefCounted {
- public:
- idCancelTextChat( idPlayer * _player ) {
- player = _player;
- }
- idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
- if ( !player ) {
- return idSWFScriptVar();
- }
- player->isChatting = 0;
- return idSWFScriptVar();
- }
- idPlayer * player;
- };
- sayObj->Set( "onPress", new ( TAG_SWF ) idPostTextChat( player, say ) );
- idSWFScriptObject * const shortcutKeys = gui->GetGlobal( "shortcutKeys" ).GetObject();
- if ( verify( shortcutKeys != NULL ) ) {
- shortcutKeys->Set( "ENTER", sayObj );
- shortcutKeys->Set( "ESCAPE", new ( TAG_SWF ) idCancelTextChat( player ) );
- }
- }
- }
- }
- }
|