MenuScreen_HUD.cpp 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #pragma hdrstop
  21. #include "../../idLib/precompiled.h"
  22. #include "../Game_local.h"
  23. extern idCVar pm_stamina;
  24. extern idCVar in_useJoystick;
  25. extern idCVar flashlight_batteryDrainTimeMS;
  26. /*
  27. ========================
  28. idMenuScreen_HUD::Initialize
  29. ========================
  30. */
  31. void idMenuScreen_HUD::Initialize( idMenuHandler * data ) {
  32. idMenuScreen::Initialize( data );
  33. }
  34. /*
  35. ========================
  36. idMenuScreen_HUD::ShowScreen
  37. ========================
  38. */
  39. void idMenuScreen_HUD::ShowScreen( const mainMenuTransition_t transitionType ) {
  40. if ( menuData != NULL ) {
  41. menuGUI = menuData->GetGUI();
  42. }
  43. if ( menuGUI == NULL ) {
  44. return;
  45. }
  46. idSWFScriptObject & root = menuGUI->GetRootObject();
  47. playerInfo = root.GetNestedObj( "_bottomLeft", "playerInfo", "info" );
  48. stamina = root.GetNestedObj( "_bottomLeft", "stamina" );
  49. locationName = root.GetNestedText( "_bottomLeft", "location", "txtVal" );
  50. tipInfo = root.GetNestedObj( "_left", "tip" );
  51. if ( playerInfo ) {
  52. healthBorder = playerInfo->GetNestedSprite( "healthBorder", "damage" );
  53. healthPulse = playerInfo->GetNestedSprite( "healthBorder", "pulse" );
  54. armorFrame = playerInfo->GetNestedSprite( "armorFrame" );
  55. }
  56. // Security Update
  57. security = root.GetNestedSprite( "_center", "security" );
  58. securityText = root.GetNestedText( "_center", "security", "info", "txtVal" );
  59. // PDA Download
  60. newPDADownload = root.GetNestedSprite( "_center", "pdaDownload" );
  61. newPDAName = root.GetNestedText( "_center", "pdaDownload", "info", "txtName" );
  62. newPDAHeading = root.GetNestedText( "_center", "pdaDownload", "info", "txtHeading" );
  63. newPDA = root.GetNestedSprite( "_bottomLeft", "newPDA" );
  64. // Video Download
  65. newVideoDownload = root.GetNestedSprite( "_center", "videoDownload" );
  66. newVideoHeading = root.GetNestedText( "_center", "videoDownload", "info", "txtHeading" );
  67. newVideo = root.GetNestedSprite( "_bottomLeft", "newVideo" );
  68. // Audio Log
  69. audioLog = root.GetNestedSprite( "_bottomLeft", "audioLog" );
  70. // Radio Communication
  71. communication = root.GetNestedSprite( "_bottomLeft", "communication" );
  72. // Oxygen
  73. oxygen = root.GetNestedSprite( "_bottomLeft", "oxygen" );
  74. flashlight = root.GetNestedSprite( "_bottomLeft", "flashlight" );
  75. // Objective
  76. objective = root.GetNestedSprite( "_right", "objective" );
  77. objectiveComplete = root.GetNestedSprite( "_right", "objectiveComplete" );
  78. // Ammo Info
  79. ammoInfo = root.GetNestedSprite( "_bottomRight", "ammoInfo" );
  80. bsInfo = root.GetNestedSprite( "_bottomRight", "bsInfo" );
  81. soulcubeInfo = root.GetNestedSprite( "_bottomRight", "soulcube" );
  82. // 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
  83. if ( showSoulCubeInfoOnLoad == true ) {
  84. showSoulCubeInfoOnLoad = false;
  85. UpdateSoulCube( true );
  86. }
  87. // Weapon pills
  88. weaponPills = root.GetNestedObj( "_bottomRight", "weaponState" );
  89. weaponImg = root.GetNestedSprite( "_bottomRight", "weaponIcon" );
  90. weaponName = root.GetNestedObj( "_bottomRight", "weaponName" );
  91. // Pickup Info
  92. newWeapon = root.GetNestedSprite( "_center", "newWeapon" );
  93. pickupInfo = root.GetNestedSprite( "_bottomLeft", "pickupInfo" );
  94. newItem = root.GetNestedSprite( "_left", "newItem" );
  95. // Cursors
  96. talkCursor = root.GetNestedSprite( "_center", "crosshairTalk" );
  97. combatCursor = root.GetNestedSprite( "_center", "crosshairCombat" );
  98. grabberCursor = root.GetNestedSprite( "_center", "crosshairGrabber" );
  99. respawnMessage = root.GetNestedSprite( "_center", "respawnMessage" );
  100. // MP OBJECTS
  101. mpInfo = root.GetNestedSprite( "_top", "mp_info" );
  102. mpHitInfo = root.GetNestedSprite( "_bottom", "hitInfo" );
  103. mpTime = root.GetNestedText( "_top", "mp_info", "txtTime" );
  104. mpMessage = root.GetNestedText( "_top", "mp_info", "txtInfo" );
  105. mpWeapons = root.GetNestedObj( "_bottom", "mpWeapons" );
  106. mpChatObject = root.GetNestedSprite( "_left", "mpChat" );
  107. mpConnection = root.GetNestedSprite( "_center", "connectionMsg" );
  108. // Functions
  109. class idTriggerNewPDAOrVideo : public idSWFScriptFunction_RefCounted {
  110. public:
  111. idTriggerNewPDAOrVideo( idMenuScreen_HUD * _screen ) :
  112. screen( _screen ) {
  113. }
  114. idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
  115. if ( screen == NULL ) {
  116. return idSWFScriptVar();
  117. }
  118. if ( parms.Num() != 1 ) {
  119. return idSWFScriptVar();
  120. }
  121. bool pdaDownload = parms[0].ToBool();
  122. if ( pdaDownload ) {
  123. screen->ToggleNewPDA( true );
  124. } else {
  125. screen->ToggleNewVideo( true );
  126. }
  127. return idSWFScriptVar();
  128. }
  129. private:
  130. idMenuScreen_HUD * screen;
  131. };
  132. menuGUI->SetGlobal( "toggleNewNotification", new idTriggerNewPDAOrVideo( this ) );
  133. }
  134. /*
  135. ========================
  136. idMenuScreen_HUD::HideScreen
  137. ========================
  138. */
  139. void idMenuScreen_HUD::HideScreen( const mainMenuTransition_t transitionType ) {
  140. }
  141. /*
  142. ========================
  143. idMenuScreen_HUD::Update
  144. ========================
  145. */
  146. void idMenuScreen_HUD::Update() {
  147. idPlayer * player = gameLocal.GetLocalPlayer();
  148. if ( player == NULL ) {
  149. return;
  150. }
  151. idMenuScreen::Update();
  152. }
  153. /*
  154. ========================
  155. idMenuScreen_HUD::UpdateHealth
  156. ========================
  157. */
  158. void idMenuScreen_HUD::UpdateHealthArmor( idPlayer * player ) {
  159. if ( !playerInfo || !player ) {
  160. return;
  161. }
  162. if ( common->IsMultiplayer() ) {
  163. playerInfo->GetSprite()->SetYPos( 20.0f );
  164. } else {
  165. playerInfo->GetSprite()->SetYPos( 0.0f );
  166. }
  167. idSWFTextInstance * txtVal = playerInfo->GetNestedText( "health", "txtVal" );
  168. if ( txtVal != NULL ) {
  169. txtVal->SetText( va( "%d", player->health ) );
  170. txtVal->SetStrokeInfo( true, 0.75f, 1.5f );
  171. // Set the damage color
  172. swfColorRGBA_t color;
  173. color.r = 255;
  174. color.a = 255;
  175. uint8 gbColor;
  176. if ( player->health > 60 ) {
  177. gbColor = 255;
  178. } else if ( player->health > 30 ) {
  179. gbColor = 156;
  180. } else {
  181. gbColor = 0;
  182. }
  183. color.g = gbColor;
  184. color.b = gbColor;
  185. txtVal->color = color;
  186. }
  187. txtVal = playerInfo->GetNestedText( "armor", "txtVal" );
  188. if ( txtVal != NULL ) {
  189. txtVal->SetText( va( "%d", player->inventory.armor ) );
  190. txtVal->SetStrokeInfo( true, 0.75f, 1.5f );
  191. if ( armorFrame != NULL ) {
  192. if ( player->inventory.armor == 0 ) {
  193. armorFrame->StopFrame( 2 );
  194. } else {
  195. armorFrame->StopFrame( 1 );
  196. }
  197. }
  198. }
  199. if ( healthBorder != NULL ) {
  200. healthBorder->StopFrame( 100 - player->health + 1 );
  201. }
  202. if ( healthPulse != NULL ) {
  203. if ( player->healthPulse ) {
  204. player->StartSound( "snd_healthpulse", SND_CHANNEL_ITEM, 0, false, NULL );
  205. player->healthPulse = false;
  206. healthPulse->SetVisible( true );
  207. healthPulse->PlayFrame( "rollOn" );
  208. }
  209. if ( player->healthTake ) {
  210. player->StartSound( "snd_healthtake", SND_CHANNEL_ITEM, 0, false, NULL );
  211. player->healthTake = false;
  212. healthPulse->SetVisible( true );
  213. healthPulse->PlayFrame( "rollOn" );
  214. }
  215. }
  216. }
  217. /*
  218. ========================
  219. idMenuScreen_HUD::UpdateStamina
  220. ========================
  221. */
  222. void idMenuScreen_HUD::UpdateStamina( idPlayer * player ) {
  223. if ( !stamina || !player ) {
  224. return;
  225. }
  226. idSWFSpriteInstance * stamSprite = stamina->GetSprite();
  227. if ( stamSprite != NULL ) {
  228. if ( common->IsMultiplayer() ) {
  229. stamSprite->SetVisible( false );
  230. } else {
  231. float max_stamina = pm_stamina.GetFloat();
  232. if ( !max_stamina ) {
  233. stamSprite->SetVisible( false );
  234. } else {
  235. stamSprite->SetVisible( true );
  236. float staminaPercent = idMath::Ftoi( 100.0f * player->stamina / max_stamina );
  237. stamSprite->StopFrame( staminaPercent + 1 );
  238. }
  239. }
  240. }
  241. }
  242. /*
  243. ========================
  244. idMenuScreen_HUD::UpdateLocation
  245. ========================
  246. */
  247. void idMenuScreen_HUD::UpdateWeaponInfo( idPlayer * player ) {
  248. if ( !player || !ammoInfo ) {
  249. return;
  250. }
  251. idEntityPtr<idWeapon> weapon = player->weapon;
  252. assert( weapon.GetEntity() );
  253. int inClip = weapon.GetEntity()->AmmoInClip();
  254. int ammoAmount = weapon.GetEntity()->AmmoAvailable();
  255. //Make sure the hud always knows how many bloodstone charges there are
  256. int ammoRequired;
  257. int bloodstoneAmmo = 0;
  258. if ( player->weapon_bloodstone >= 0 ) {
  259. ammo_t ammo_i = player->inventory.AmmoIndexForWeaponClass( "weapon_bloodstone_passive", &ammoRequired );
  260. bloodstoneAmmo = player->inventory.HasAmmo( ammo_i, ammoRequired );
  261. }
  262. if ( bsInfo ) {
  263. if ( bloodstoneAmmo > 0 ) {
  264. bsInfo->SetVisible( true );
  265. bsInfo->StopFrame( bloodstoneAmmo + 1 );
  266. } else {
  267. bsInfo->SetVisible( false );
  268. }
  269. }
  270. if ( ammoAmount == -1 || player->GetCurrentWeaponSlot() == player->weapon_bloodstone || player->GetCurrentWeaponSlot() == player->weapon_soulcube ) {
  271. ammoInfo->SetVisible( false );
  272. } else {
  273. idStr totalAmmo;
  274. idStr playerAmmo;
  275. idStr playerClip;
  276. bool showClip = true;
  277. //Hack to stop the bloodstone ammo to display when it is being activated
  278. if ( !weapon.GetEntity()->IsReady() ) {
  279. // show infinite ammo
  280. playerAmmo = "";
  281. totalAmmo = "";
  282. } else {
  283. // show remaining ammo
  284. totalAmmo = va( "%i", ammoAmount );
  285. playerAmmo = weapon.GetEntity()->ClipSize() ? va( "%i", inClip ) : "--"; // how much in the current clip
  286. playerClip = weapon.GetEntity()->ClipSize() ? va( "%i", ammoAmount / weapon.GetEntity()->ClipSize() ) : "--";
  287. //allAmmo = va( "%i/%i", inClip, ammoAmount );
  288. }
  289. if ( !weapon.GetEntity()->ClipSize() ) {
  290. showClip = false;
  291. }
  292. bool ammoEmpty = ( ammoAmount == 0 );
  293. bool clipEmpty = ( weapon.GetEntity()->ClipSize() ? inClip == 0 : false );
  294. bool clipLow = ( weapon.GetEntity()->ClipSize() ? inClip <= weapon.GetEntity()->LowAmmo() : false );
  295. //Hack to stop the bloodstone ammo to display when it is being activated
  296. if ( player->GetCurrentWeaponSlot() == player->weapon_bloodstone ) {
  297. ammoEmpty = false;
  298. clipEmpty = false;
  299. clipLow = false;
  300. }
  301. if ( showClip ) {
  302. ammoInfo->SetVisible( true );
  303. ammoInfo->StopFrame( 1 );
  304. if ( common->IsMultiplayer() ) {
  305. ammoInfo->SetYPos( 20.0f );
  306. } else {
  307. ammoInfo->SetYPos( 0.0f );
  308. }
  309. idSWFSpriteInstance * txtClipSprite = ammoInfo->GetScriptObject()->GetNestedSprite( "info", "clip" );
  310. idSWFSpriteInstance * clipLowSprite = ammoInfo->GetScriptObject()->GetNestedSprite( "info", "lowAmmo" );
  311. idSWFSpriteInstance * clipEmptySprite = ammoInfo->GetScriptObject()->GetNestedSprite( "info", "clipEmpty" );
  312. idSWFSpriteInstance * ammoEmptySprite = ammoInfo->GetScriptObject()->GetNestedSprite( "info", "noAmmo" );
  313. idSWFSpriteInstance * txtAmmoSprite = ammoInfo->GetScriptObject()->GetNestedSprite( "info", "ammoCount" );
  314. idSWFTextInstance * txtClip = ammoInfo->GetScriptObject()->GetNestedText( "info", "clip", "clipCount", "txtVal" );
  315. idSWFTextInstance * txtAmmo = ammoInfo->GetScriptObject()->GetNestedText( "info", "ammoCount", "txtVal" );
  316. if ( txtClipSprite && clipLowSprite && clipEmptySprite ) {
  317. if ( clipEmpty ) {
  318. clipLowSprite->SetVisible( false );
  319. clipEmptySprite->SetVisible( true );
  320. txtClipSprite->StopFrame( 3 );
  321. } else if ( clipLow ) {
  322. clipLowSprite->SetVisible( true );
  323. clipEmptySprite->SetVisible( false );
  324. txtClipSprite->StopFrame( 2 );
  325. } else {
  326. clipLowSprite->SetVisible( false );
  327. clipEmptySprite->SetVisible( false );
  328. txtClipSprite->StopFrame( 1 );
  329. }
  330. if ( txtClip != NULL ) {
  331. txtClip->SetText( playerAmmo );
  332. txtClip->SetStrokeInfo( true, 0.75f, 1.5f );
  333. }
  334. }
  335. if ( txtAmmo != NULL ) {
  336. if ( ammoEmptySprite && txtAmmoSprite ) {
  337. if ( ammoEmpty ) {
  338. ammoEmptySprite->SetVisible( true );
  339. txtAmmoSprite->StopFrame( 2 );
  340. } else {
  341. ammoEmptySprite->SetVisible( false );
  342. txtAmmoSprite->StopFrame( 1 );
  343. }
  344. }
  345. txtAmmo->SetText( totalAmmo );
  346. txtAmmo->SetStrokeInfo( true, 0.75f, 1.5f );
  347. }
  348. } else {
  349. ammoInfo->SetVisible( true );
  350. ammoInfo->StopFrame( 2 );
  351. if ( common->IsMultiplayer() ) {
  352. ammoInfo->SetYPos( 20.0f );
  353. } else {
  354. ammoInfo->SetYPos( 0.0f );
  355. }
  356. idSWFTextInstance * txtAmmo = ammoInfo->GetScriptObject()->GetNestedText( "info", "txtVal" );
  357. if ( txtAmmo != NULL ) {
  358. txtAmmo->SetText( totalAmmo );
  359. txtAmmo->SetStrokeInfo( true, 0.75f, 1.5f );
  360. }
  361. }
  362. }
  363. }
  364. /*
  365. ========================
  366. idMenuScreen_HUD::GiveWeapon
  367. ========================
  368. */
  369. void idMenuScreen_HUD::GiveWeapon( idPlayer * player, int weaponIndex ) {
  370. if ( common->IsMultiplayer() ) {
  371. return;
  372. }
  373. const char *weapnum = va( "def_weapon%d", weaponIndex );
  374. const char *weap = player->spawnArgs.GetString( weapnum );
  375. if ( weap != NULL && *weap != NULL ) {
  376. const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
  377. if ( weaponDef != NULL ) {
  378. const char * hudIconName = weaponDef->dict.GetString( "hudIcon" );
  379. if ( hudIconName[ 0 ] == '\0' ) {
  380. idLib::Warning( "idMenuScreen_HUD: Missing hudIcon for weapon %s", weap );
  381. return;
  382. }
  383. const idMaterial * hudIcon = declManager->FindMaterial( hudIconName, false );
  384. if ( newWeapon != NULL ) {
  385. newWeapon->SetVisible( true );
  386. newWeapon->PlayFrame( 2 );
  387. idSWFSpriteInstance * topImg = newWeapon->GetScriptObject()->GetNestedSprite( "topImg" );
  388. idSWFSpriteInstance * botImg = newWeapon->GetScriptObject()->GetNestedSprite( "botImg" );
  389. if ( topImg && botImg ) {
  390. topImg->SetMaterial( hudIcon );
  391. botImg->SetMaterial( hudIcon );
  392. }
  393. }
  394. }
  395. }
  396. }
  397. /*
  398. ========================
  399. idMenuScreen_HUD::UpdateWeaponStates
  400. ========================
  401. */
  402. void idMenuScreen_HUD::UpdatePickupInfo( int index, const idStr & name ) {
  403. if ( !pickupInfo ) {
  404. return;
  405. }
  406. idSWFTextInstance * txtItem = pickupInfo->GetScriptObject()->GetNestedText( va( "item%d", index ), "txtVal" );
  407. if ( txtItem != NULL ) {
  408. txtItem->SetText( name );
  409. txtItem->SetStrokeInfo( true, 0.6f, 2.0f );
  410. }
  411. }
  412. /*
  413. ========================
  414. idMenuScreen_HUD::IsPickupListReady
  415. ========================
  416. */
  417. bool idMenuScreen_HUD::IsPickupListReady() {
  418. if ( !pickupInfo ) {
  419. return false;
  420. }
  421. if ( pickupInfo->GetCurrentFrame() == 1 ) {
  422. return true;
  423. }
  424. return false;
  425. }
  426. /*
  427. ========================
  428. idMenuScreen_HUD::UpdateWeaponStates
  429. ========================
  430. */
  431. void idMenuScreen_HUD::ShowPickups() {
  432. if ( !pickupInfo ) {
  433. return;
  434. }
  435. pickupInfo->SetVisible( true );
  436. pickupInfo->PlayFrame( "rollOn" );
  437. }
  438. /*
  439. ========================
  440. idMenuScreen_HUD::SetCursorState
  441. ========================
  442. */
  443. void idMenuScreen_HUD::SetCursorState( idPlayer * player, cursorState_t state, int set ) {
  444. switch ( state ) {
  445. case CURSOR_TALK: {
  446. cursorNone = 0;
  447. cursorTalking = set;
  448. break;
  449. }
  450. case CURSOR_IN_COMBAT: {
  451. cursorNone = 0;
  452. cursorInCombat = set;
  453. break;
  454. }
  455. case CURSOR_ITEM: {
  456. cursorNone = 0;
  457. cursorItem = set;
  458. break;
  459. }
  460. case CURSOR_GRABBER: {
  461. cursorNone = 0;
  462. cursorGrabber = set;
  463. break;
  464. }
  465. case CURSOR_NONE: {
  466. // so that talk button still appears for 3D view
  467. if ( cursorState != CURSOR_TALK || cursorTalking != 1 ) {
  468. cursorTalking = 0;
  469. cursorGrabber = 0;
  470. cursorInCombat = 0;
  471. cursorItem = 0;
  472. cursorNone = 1;
  473. }
  474. break;
  475. }
  476. }
  477. }
  478. /*
  479. ========================
  480. idMenuScreen_HUD::SetCursorText
  481. ========================
  482. */
  483. void idMenuScreen_HUD::SetCursorText( const idStr & action, const idStr & focus ) {
  484. cursorAction = action;
  485. cursorFocus = focus;
  486. }
  487. /*
  488. ========================
  489. idMenuScreen_HUD::CombatCursorFlash
  490. ========================
  491. */
  492. void idMenuScreen_HUD::CombatCursorFlash() {
  493. if ( cursorInCombat ) {
  494. if ( cursorState == CURSOR_IN_COMBAT ) {
  495. if ( combatCursor ) {
  496. combatCursor->PlayFrame( "hit" );
  497. }
  498. }
  499. }
  500. }
  501. /*
  502. ========================
  503. idMenuScreen_HUD::UpdateCursorState
  504. ========================
  505. */
  506. void idMenuScreen_HUD::UpdateCursorState() {
  507. if ( !cursorTalking && !cursorInCombat && !cursorGrabber && !cursorItem ) {
  508. cursorNone = true;
  509. cursorState = CURSOR_NONE;
  510. // hide all cursors
  511. if ( combatCursor ) {
  512. combatCursor->StopFrame( 1 );
  513. combatCursor->SetVisible( false );
  514. }
  515. if ( talkCursor ) {
  516. talkCursor->StopFrame( 1 );
  517. talkCursor->SetVisible( false );
  518. }
  519. if ( grabberCursor ) {
  520. grabberCursor->StopFrame( 1 );
  521. grabberCursor->SetVisible( false );
  522. }
  523. } else {
  524. if ( cursorTalking ) {
  525. if ( cursorTalking == 1 ) { // ready to talk
  526. } else if ( cursorTalking == 2 ) { // already talking / busy
  527. }
  528. if ( cursorState != CURSOR_TALK ) {
  529. if ( combatCursor ) {
  530. combatCursor->StopFrame( 1 );
  531. combatCursor->SetVisible( false );
  532. }
  533. if ( grabberCursor ) {
  534. grabberCursor->StopFrame( 1 );
  535. grabberCursor->SetVisible( false );
  536. }
  537. // play roll on
  538. if ( talkCursor ) {
  539. talkCursor->SetVisible( true );
  540. talkCursor->PlayFrame( 2 );
  541. idSWFSpriteInstance * topBacking = talkCursor->GetScriptObject()->GetNestedSprite( "backing", "topBar" );
  542. idSWFSpriteInstance * bottomBacking = talkCursor->GetScriptObject()->GetNestedSprite( "backing", "botBar" );
  543. idSWFTextInstance * txtAction = talkCursor->GetScriptObject()->GetNestedText( "info", "txtAction" );
  544. idSWFTextInstance * txtFocus = talkCursor->GetScriptObject()->GetNestedText( "info", "txtFocus" );
  545. idSWFTextInstance * txtPrompt = talkCursor->GetScriptObject()->GetNestedText( "talkPrompt", "txtPrompt" );
  546. if ( txtAction ) {
  547. if ( !in_useJoystick.GetBool() ) {
  548. txtAction->tooltip = true;
  549. keyBindings_t bind = idKeyInput::KeyBindingsFromBinding( "_use", true );
  550. idStr actionText = idLocalization::GetString( cursorAction );
  551. if ( !bind.mouse.IsEmpty() ) {
  552. actionText.Append( " [" );
  553. actionText.Append( bind.mouse );
  554. actionText.Append( "]" );
  555. } else if ( !bind.keyboard.IsEmpty() ) {
  556. actionText.Append( " [" );
  557. actionText.Append( bind.keyboard );
  558. actionText.Append( "]" );
  559. }
  560. txtAction->SetText( actionText );
  561. } else {
  562. txtAction->tooltip = false;
  563. txtAction->SetText( cursorAction );
  564. }
  565. txtAction->SetStrokeInfo( true, 0.75f, 1.5f );
  566. float actionLength = txtAction->GetTextLength();
  567. if ( topBacking ) {
  568. if ( !cursorAction.IsEmpty() ) {
  569. topBacking->SetXPos( actionLength );
  570. } else {
  571. topBacking->SetXPos( -75.0f );
  572. }
  573. }
  574. }
  575. if ( txtFocus ) {
  576. txtFocus->SetText( cursorFocus );
  577. txtFocus->SetStrokeInfo( true, 0.75f, 1.5f );
  578. float focusLength = txtFocus->GetTextLength();
  579. if ( bottomBacking ) {
  580. if ( !cursorFocus.IsEmpty() ) {
  581. bottomBacking->SetXPos( focusLength );
  582. } else {
  583. bottomBacking->SetXPos( -75.0f );
  584. }
  585. }
  586. }
  587. if ( txtPrompt ) {
  588. if ( in_useJoystick.GetBool() ) {
  589. txtPrompt->tooltip = true;
  590. txtPrompt->SetText( "_use" );
  591. } else {
  592. txtPrompt->tooltip = false;
  593. txtPrompt->SetText( "" );
  594. }
  595. }
  596. }
  597. cursorState = CURSOR_TALK;
  598. }
  599. } else if ( cursorGrabber ) {
  600. if ( talkCursor ) {
  601. talkCursor->StopFrame( 1 );
  602. talkCursor->SetVisible( false );
  603. }
  604. if ( combatCursor ) {
  605. combatCursor->StopFrame( 1 );
  606. combatCursor->SetVisible( false );
  607. }
  608. if ( cursorState != CURSOR_GRABBER ) {
  609. if ( grabberCursor ) {
  610. grabberCursor->SetVisible( true );
  611. grabberCursor->PlayFrame( "loop" );
  612. }
  613. }
  614. cursorState = CURSOR_GRABBER;
  615. } else if ( cursorItem ) {
  616. cursorState = CURSOR_ITEM;
  617. } else if ( cursorInCombat ) {
  618. if ( cursorState == CURSOR_TALK ) {
  619. if ( talkCursor ) {
  620. talkCursor->StopFrame( 1 );
  621. talkCursor->SetVisible( false );
  622. }
  623. if ( combatCursor ) {
  624. combatCursor->SetVisible( true );
  625. combatCursor->PlayFrame( "rollOn" );
  626. }
  627. // play cursor roll on
  628. } else if ( cursorState != CURSOR_IN_COMBAT ) {
  629. if ( grabberCursor ) {
  630. grabberCursor->StopFrame( 1 );
  631. grabberCursor->SetVisible( false );
  632. }
  633. // set cursor visible
  634. if ( combatCursor ) {
  635. combatCursor->SetVisible( true );
  636. combatCursor->StopFrame( 2 );
  637. }
  638. }
  639. cursorState = CURSOR_IN_COMBAT;
  640. }
  641. }
  642. }
  643. /*
  644. ========================
  645. idMenuScreen_HUD::UpdateSoulCube
  646. ========================
  647. */
  648. void idMenuScreen_HUD::UpdateSoulCube( bool ready ) {
  649. if ( !soulcubeInfo ) {
  650. return;
  651. }
  652. if ( ready && !soulcubeInfo->IsVisible() ) {
  653. soulcubeInfo->SetVisible( true );
  654. soulcubeInfo->PlayFrame( "rollOn" );
  655. } else if ( !ready ) {
  656. soulcubeInfo->PlayFrame( "rollOff" );
  657. }
  658. }
  659. /*
  660. ========================
  661. idMenuScreen_HUD::ShowRespawnMessage
  662. ========================
  663. */
  664. void idMenuScreen_HUD::ShowRespawnMessage( bool show ) {
  665. if ( !respawnMessage ) {
  666. return;
  667. }
  668. if ( show ) {
  669. respawnMessage->SetVisible( true );
  670. respawnMessage->PlayFrame( "rollOn" );
  671. idSWFTextInstance * message = respawnMessage->GetScriptObject()->GetNestedText( "info", "txtMessage" );
  672. if ( message != NULL ) {
  673. message->tooltip = true;
  674. message->SetText( "#str_respawn_message" );
  675. message->SetStrokeInfo( true );
  676. }
  677. } else {
  678. if ( respawnMessage->IsVisible() ) {
  679. respawnMessage->PlayFrame( "rollOff" );
  680. }
  681. }
  682. }
  683. /*
  684. ========================
  685. idMenuScreen_HUD::UpdateWeaponStates
  686. ========================
  687. */
  688. void idMenuScreen_HUD::UpdateWeaponStates( idPlayer * player, bool weaponChanged ) {
  689. if ( !weaponPills ) {
  690. return;
  691. }
  692. if ( player == NULL ) {
  693. return;
  694. }
  695. idStr displayName;
  696. if ( common->IsMultiplayer() ) {
  697. if ( !mpWeapons || player->GetIdealWeapon() == 0 ) {
  698. return;
  699. }
  700. weaponPills->GetSprite()->SetVisible( false );
  701. if ( weaponChanged ) {
  702. mpWeapons->GetSprite()->SetVisible( true );
  703. mpWeapons->GetSprite()->PlayFrame( "rollOn" );
  704. int weaponDefIndex = -1;
  705. idList< idStr > weaponDefNames;
  706. // start at 1 so we skip the fists
  707. for ( int i = 1; i < MAX_WEAPONS; ++i ) {
  708. if ( player->inventory.weapons & ( 1 << i ) ) {
  709. if ( i == player->GetIdealWeapon() ) {
  710. weaponDefIndex = weaponDefNames.Num();
  711. }
  712. weaponDefNames.Append( va( "def_weapon%d", i ) );
  713. }
  714. }
  715. int numRightWeapons = 0;
  716. int numLeftWeapons = 0;
  717. if ( weaponDefNames.Num() == 2 ) {
  718. numRightWeapons = 1 - weaponDefIndex;
  719. numLeftWeapons = weaponDefIndex;
  720. } else if ( weaponDefNames.Num() == 3 ) {
  721. numRightWeapons = 1;
  722. numLeftWeapons = 1;
  723. } else if ( weaponDefNames.Num() > 3 ) {
  724. numRightWeapons = 2;
  725. numLeftWeapons = 2;
  726. }
  727. for ( int i = -2; i < 3; ++i ) {
  728. bool hide = false;
  729. if ( i < 0 && idMath::Abs( i ) > numLeftWeapons ) {
  730. hide = true;
  731. } else if ( i > numRightWeapons ) {
  732. hide = true;
  733. } else if ( weaponDefNames.Num() == 0 ) {
  734. hide = true;
  735. }
  736. int index = i;
  737. if ( i < 0 ) {
  738. index = 2 + idMath::Abs( i );
  739. }
  740. idSWFSpriteInstance * topValid = mpWeapons->GetNestedSprite( "list", va( "weapon%i", index ), "topValid" );
  741. idSWFSpriteInstance * botValid = mpWeapons->GetNestedSprite( "list", va( "weapon%i", index ), "botValid" );
  742. idSWFSpriteInstance * topInvalid = mpWeapons->GetNestedSprite( "list", va( "weapon%i", index ), "topInvalid" );
  743. idSWFSpriteInstance * botInvalid = mpWeapons->GetNestedSprite( "list", va( "weapon%i", index ), "botInvalid" );
  744. if ( !topValid || !botValid || !topInvalid || !botInvalid ) {
  745. mpWeapons->GetSprite()->SetVisible( false );
  746. break;
  747. }
  748. if ( hide ) {
  749. topValid->SetVisible( false );
  750. botValid->SetVisible( false );
  751. topInvalid->SetVisible( false );
  752. botInvalid->SetVisible( false );
  753. continue;
  754. }
  755. int weaponIndex = weaponDefIndex + i;
  756. if ( weaponIndex < 0 ) {
  757. weaponIndex = weaponDefNames.Num() + weaponIndex;
  758. } else if ( weaponIndex >= weaponDefNames.Num() ) {
  759. weaponIndex = ( weaponIndex - weaponDefNames.Num() );
  760. }
  761. int weapState = 1;
  762. const idMaterial * hudIcon = NULL;
  763. const char * weapNum = weaponDefNames[ weaponIndex ];
  764. const char * weap = player->spawnArgs.GetString( weapNum );
  765. if ( weap != NULL && *weap != NULL ) {
  766. const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
  767. if ( weaponDef != NULL ) {
  768. hudIcon = declManager->FindMaterial( weaponDef->dict.GetString( "hudIcon" ), false );
  769. if ( i == 0 ) {
  770. displayName = weaponDef->dict.GetString( "display_name" );
  771. weapState++;
  772. }
  773. }
  774. if ( !player->inventory.HasAmmo( weap, true, player ) ) {
  775. weapState = 0;
  776. }
  777. }
  778. topValid->SetVisible( false );
  779. botValid->SetVisible( false );
  780. topInvalid->SetVisible( false );
  781. botInvalid->SetVisible( false );
  782. topValid->SetMaterial( hudIcon );
  783. botValid->SetMaterial( hudIcon );
  784. topInvalid->SetMaterial( hudIcon );
  785. botInvalid->SetMaterial( hudIcon );
  786. if ( weapState == 0 ) {
  787. botInvalid->SetVisible( true );
  788. if ( i == 0 ) {
  789. topInvalid->SetVisible( true );
  790. }
  791. } else if ( weapState == 2 ) {
  792. topValid->SetVisible( true );
  793. botValid->SetVisible( true );
  794. } else {
  795. botValid->SetVisible( true );
  796. }
  797. }
  798. }
  799. } else {
  800. bool hasWeapons = false;
  801. const idMaterial * hudIcon = NULL;
  802. for ( int i = 0; i < MAX_WEAPONS; i++ ) {
  803. const char *weapnum = va( "def_weapon%d", i );
  804. int weapstate = 0;
  805. if ( player->inventory.weapons & ( 1 << i ) ) {
  806. hasWeapons = true;
  807. const char *weap = player->spawnArgs.GetString( weapnum );
  808. if ( weap != NULL && *weap != NULL ) {
  809. weapstate++;
  810. }
  811. if ( player->GetIdealWeapon() == i ) {
  812. const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
  813. if ( weaponDef != NULL ) {
  814. hudIcon = declManager->FindMaterial( weaponDef->dict.GetString( "hudIcon" ), false );
  815. displayName = weaponDef->dict.GetString( "display_name" );
  816. }
  817. weapstate++;
  818. }
  819. }
  820. idSWFSpriteInstance * pill = weaponPills->GetNestedSprite( va( "pill%d", i ) );
  821. if ( pill ) {
  822. pill->StopFrame( weapstate + 1 );
  823. }
  824. }
  825. if ( !hasWeapons ) {
  826. weaponPills->GetSprite()->SetVisible( false );
  827. } else {
  828. weaponPills->GetSprite()->SetVisible( true );
  829. }
  830. if ( weaponImg ) {
  831. if ( weaponChanged && hudIcon != NULL ) {
  832. weaponImg->SetVisible( true );
  833. weaponImg->PlayFrame( 2 );
  834. idSWFSpriteInstance * topImg = weaponImg->GetScriptObject()->GetNestedSprite( "topImg" );
  835. idSWFSpriteInstance * botImg = weaponImg->GetScriptObject()->GetNestedSprite( "botImg" );
  836. if ( topImg != NULL && botImg != NULL ) {
  837. topImg->SetMaterial( hudIcon );
  838. botImg->SetMaterial( hudIcon );
  839. }
  840. /*if ( weaponName && weaponName->GetSprite() ) {
  841. weaponName->GetSprite()->SetVisible( true );
  842. weaponName->GetSprite()->PlayFrame( 2 );
  843. idSWFTextInstance * txtVal = weaponName->GetNestedText( "info", "txtVal" );
  844. if ( txtVal != NULL ) {
  845. txtVal->SetText( displayName );
  846. txtVal->SetStrokeInfo( true, 0.6f, 2.0f );
  847. }
  848. }*/
  849. }
  850. }
  851. }
  852. }
  853. /*
  854. ========================
  855. idMenuScreen_HUD::UpdateLocation
  856. ========================
  857. */
  858. void idMenuScreen_HUD::UpdateLocation( idPlayer * player ) {
  859. if ( !locationName || !player ) {
  860. return;
  861. }
  862. idPlayer * playertoLoc = player;
  863. if( player->spectating && player->spectator != player->entityNumber ) {
  864. playertoLoc = static_cast< idPlayer* >( gameLocal.entities[ player->spectator ] );
  865. if( playertoLoc == NULL ) {
  866. playertoLoc = player;
  867. }
  868. }
  869. idLocationEntity *locationEntity = gameLocal.LocationForPoint( playertoLoc->GetEyePosition() );
  870. if ( locationEntity ) {
  871. locationName->SetText( locationEntity->GetLocation() );
  872. } else {
  873. locationName->SetText( idLocalization::GetString( "#str_02911" ) );
  874. }
  875. locationName->SetStrokeInfo( true, 0.6f, 2.0f );
  876. }
  877. /*
  878. ========================
  879. idMenuScreen_HUD::ShowTip
  880. ========================
  881. */
  882. void idMenuScreen_HUD::ShowTip( const char * title, const char * tip ) {
  883. if ( !tipInfo ) {
  884. return;
  885. }
  886. idSWFSpriteInstance * tipSprite = tipInfo->GetSprite();
  887. if ( !tipSprite ) {
  888. return;
  889. }
  890. tipSprite->SetVisible( true );
  891. tipSprite->PlayFrame( "rollOn" );
  892. idSWFTextInstance * txtTitle = tipInfo->GetNestedText( "info", "txtTitle" );
  893. idSWFTextInstance * txtTip = tipInfo->GetNestedText( "info", "txtTip" );
  894. if ( txtTitle != NULL ) {
  895. txtTitle->SetText( title );
  896. txtTitle->SetStrokeInfo( true, 0.75f, 1.5f );
  897. }
  898. if ( txtTip != NULL ) {
  899. txtTip->SetText( tip );
  900. txtTip->tooltip = true;
  901. txtTip->SetStrokeInfo( true, 0.75f, 1.5f );
  902. int numLines = txtTip->CalcNumLines();
  903. if ( numLines == 0 ) {
  904. numLines = 1;
  905. }
  906. idSWFSpriteInstance * backing = tipInfo->GetNestedSprite( "info", "backing" );
  907. if ( backing != NULL ) {
  908. backing->StopFrame( numLines );
  909. }
  910. }
  911. }
  912. /*
  913. ========================
  914. idMenuScreen_HUD::HideTip
  915. ========================
  916. */
  917. void idMenuScreen_HUD::HideTip() {
  918. if ( !tipInfo ) {
  919. return;
  920. }
  921. idSWFSpriteInstance * tipSprite = tipInfo->GetSprite();
  922. if ( !tipSprite ) {
  923. return;
  924. }
  925. tipSprite->SetVisible( true );
  926. tipSprite->PlayFrame( "rollOff" );
  927. }
  928. /*
  929. ========================
  930. idMenuScreen_HUD::DownloadPDA
  931. ========================
  932. */
  933. void idMenuScreen_HUD::DownloadPDA( const idDeclPDA * pda, bool newSecurity ) {
  934. if ( newPDADownload ) {
  935. newPDADownload->SetVisible( true );
  936. newPDADownload->PlayFrame( "rollOn" );
  937. newPDAName = newPDADownload->GetScriptObject()->GetNestedText( "info", "txtName" );
  938. newPDAHeading = newPDADownload->GetScriptObject()->GetNestedText( "info", "txtHeading" );
  939. if ( newPDAName && GetSWFObject() != NULL ) {
  940. idStr pdaName = pda->GetPdaName();
  941. pdaName.RemoveColors();
  942. GetSWFObject()->SetGlobal( "pdaNameDownload", pdaName );
  943. newPDAName->SetStrokeInfo( true, 0.9f, 2.0f );
  944. }
  945. if ( newPDAHeading && GetSWFObject() != NULL ) {
  946. GetSWFObject()->SetGlobal( "pdaDownloadHeading", "#str_02031" );
  947. newPDAHeading->SetStrokeInfo( true, 0.9f, 2.0f );
  948. }
  949. }
  950. if ( newSecurity ) {
  951. UpdatedSecurity();
  952. }
  953. }
  954. /*
  955. ========================
  956. idMenuScreen_HUD::DownloadVideo
  957. ========================
  958. */
  959. void idMenuScreen_HUD::DownloadVideo() {
  960. if ( newVideoDownload ) {
  961. newVideoDownload->SetVisible( true );
  962. newVideoDownload->PlayFrame( "rollOn" );
  963. newVideoHeading = newVideoDownload->GetScriptObject()->GetNestedText( "info", "txtHeading" );
  964. if ( newVideoHeading ) {
  965. newVideoHeading->SetText( "#str_02033" );
  966. newVideoHeading->SetStrokeInfo( true, 0.9f, 2.0f );
  967. }
  968. }
  969. }
  970. /*
  971. ========================
  972. idMenuScreen_HUD::UpdatedSecurity
  973. ========================
  974. */
  975. void idMenuScreen_HUD::UpdatedSecurity() {
  976. if ( security != NULL && securityText != NULL ) {
  977. security->SetVisible( true );
  978. security->PlayFrame( "rollOn" );
  979. securityText->SetText( "#str_02032" );
  980. securityText->SetStrokeInfo( true, 0.9f, 2.0f );
  981. }
  982. }
  983. /*
  984. ========================
  985. idMenuScreen_HUD::ClearNewPDAInfo
  986. ========================
  987. */
  988. void idMenuScreen_HUD::ClearNewPDAInfo() {
  989. ToggleNewVideo( false );
  990. ToggleNewPDA( false );
  991. if ( security ) {
  992. security->StopFrame( 1 );
  993. }
  994. if ( newPDADownload ) {
  995. newPDADownload->StopFrame( 1 );
  996. }
  997. if ( newVideoDownload ) {
  998. newVideoDownload->StopFrame( 1 );
  999. }
  1000. }
  1001. /*
  1002. ========================
  1003. idMenuScreen_HUD::UpdatedSecurity
  1004. ========================
  1005. */
  1006. void idMenuScreen_HUD::ToggleNewVideo( bool show ) {
  1007. if ( !newVideo ) {
  1008. return;
  1009. }
  1010. if ( show && !newVideo->IsVisible() ) {
  1011. newVideo->SetVisible( true );
  1012. newVideo->PlayFrame( "rollOn" );
  1013. } else if ( !show ) {
  1014. newVideo->StopFrame( 1 );
  1015. }
  1016. }
  1017. /*
  1018. ========================
  1019. idMenuScreen_HUD::UpdatedSecurity
  1020. ========================
  1021. */
  1022. void idMenuScreen_HUD::ToggleNewPDA( bool show ) {
  1023. if ( !newPDA ) {
  1024. return;
  1025. }
  1026. if ( show && !newPDA->IsVisible() ) {
  1027. newPDA->SetVisible( true );
  1028. newPDA->PlayFrame( "rollOn" );
  1029. } else if ( !show ) {
  1030. newPDA->StopFrame( 1 );
  1031. }
  1032. }
  1033. /*
  1034. ========================
  1035. idMenuScreen_HUD::UpdatedSecurity
  1036. ========================
  1037. */
  1038. void idMenuScreen_HUD::UpdateAudioLog( bool show ) {
  1039. if ( !audioLog ) {
  1040. return;
  1041. }
  1042. if ( show && !audioLog->IsVisible() ) {
  1043. audioLog->SetVisible( true );
  1044. audioLog->StopFrame( "2" );
  1045. for ( int index = 0; index < 13; ++index ) {
  1046. idSWFSpriteInstance * node = audioLog->GetScriptObject()->GetNestedSprite( "bar", va( "node%d", index ) );
  1047. if ( node != NULL ) {
  1048. int frame = gameLocal.random.RandomInt( 100 );
  1049. node->SetScale( 100.0f, frame );
  1050. float toFrame = gameLocal.random.RandomFloat();
  1051. node->SetMoveToScale( -1.0f, toFrame );
  1052. }
  1053. }
  1054. } else if ( !show ) {
  1055. audioLog->StopFrame( 1 );
  1056. } else if ( show ) {
  1057. if ( audioLogPrevTime == 0 ) {
  1058. audioLogPrevTime = gameLocal.time;
  1059. }
  1060. for ( int index = 0; index < 13; ++index ) {
  1061. idSWFSpriteInstance * node = audioLog->GetScriptObject()->GetNestedSprite( "bar", va( "node%d", index ) );
  1062. if ( node != NULL ) {
  1063. float diff = gameLocal.time - audioLogPrevTime;
  1064. float speed = ( diff / 350.0f ) * 100.0f;
  1065. if ( !node->UpdateMoveToScale( speed ) ) {
  1066. int frame = gameLocal.random.RandomInt( 100 );
  1067. float scale = frame / 100.0f;
  1068. node->SetMoveToScale( -1.0f, scale );
  1069. }
  1070. }
  1071. }
  1072. audioLogPrevTime = gameLocal.time;
  1073. }
  1074. }
  1075. /*
  1076. ========================
  1077. idMenuScreen_HUD::UpdatedSecurity
  1078. ========================
  1079. */
  1080. void idMenuScreen_HUD::UpdateCommunication( bool show, idPlayer * player ) {
  1081. if ( !communication || !player ) {
  1082. return;
  1083. }
  1084. bool oxygenChanged = false;
  1085. if ( inVaccuum != oxygenComm ) {
  1086. oxygenChanged = true;
  1087. }
  1088. if ( show && !communication->IsVisible() ) {
  1089. communication->SetVisible( true );
  1090. if ( inVaccuum ) {
  1091. communication->StopFrame( "oxygen" );
  1092. } else {
  1093. communication->StopFrame( "2" );
  1094. }
  1095. for ( int index = 0; index < 16; ++index ) {
  1096. idSWFSpriteInstance * node = communication->GetScriptObject()->GetNestedSprite( "info", "bar", va( "node%d", index ) );
  1097. if ( node != NULL ) {
  1098. int frame = gameLocal.random.RandomInt( 100 );
  1099. node->SetScale( 100.0f, frame );
  1100. float toFrame = gameLocal.random.RandomFloat();
  1101. node->SetMoveToScale( -1.0f, toFrame );
  1102. }
  1103. }
  1104. } else if ( !show ) {
  1105. communication->StopFrame( 1 );
  1106. } else if ( show ) {
  1107. if ( oxygenChanged ) {
  1108. if ( inVaccuum ) {
  1109. communication->PlayFrame( "rollUp" );
  1110. } else {
  1111. communication->PlayFrame( "rollDown" );
  1112. }
  1113. }
  1114. if ( commPrevTime == 0 ) {
  1115. commPrevTime = gameLocal.time;
  1116. }
  1117. for ( int index = 0; index < 16; ++index ) {
  1118. idSWFSpriteInstance * node = communication->GetScriptObject()->GetNestedSprite( "info", "bar", va( "node%d", index ) );
  1119. if ( node != NULL ) {
  1120. float diff = gameLocal.time - commPrevTime;
  1121. float speed = ( diff / 350.0f ) * 100.0f;
  1122. if ( !node->UpdateMoveToScale( speed ) ) {
  1123. int frame = gameLocal.random.RandomInt( 100 );
  1124. float scale = frame / 100.0f;
  1125. node->SetMoveToScale( -1.0f, scale );
  1126. }
  1127. }
  1128. }
  1129. commPrevTime = gameLocal.time;
  1130. }
  1131. oxygenComm = inVaccuum;
  1132. }
  1133. /*
  1134. ========================
  1135. idMenuScreen_HUD::UpdateOxygen
  1136. ========================
  1137. */
  1138. void idMenuScreen_HUD::UpdateOxygen( bool show, int val ) {
  1139. if ( !oxygen ) {
  1140. return;
  1141. }
  1142. if ( show ) {
  1143. if ( !oxygen->IsVisible() ) {
  1144. inVaccuum = true;
  1145. oxygen->SetVisible( true );
  1146. oxygen->PlayFrame( "rollOn" );
  1147. }
  1148. idSWFSpriteInstance * info = oxygen->GetScriptObject()->GetNestedSprite( "info" );
  1149. if ( info != NULL ) {
  1150. info->StopFrame( val + 1 );
  1151. }
  1152. idSWFSpriteInstance * goodFrame = oxygen->GetScriptObject()->GetNestedSprite( "goodFrame" );
  1153. idSWFSpriteInstance * badFrame = oxygen->GetScriptObject()->GetNestedSprite( "badFrame" );
  1154. if ( goodFrame != NULL && badFrame != NULL ) {
  1155. if ( val + 1 >= 36 ) {
  1156. goodFrame->SetVisible( true );
  1157. badFrame->SetVisible( false );
  1158. } else {
  1159. goodFrame->SetVisible( false );
  1160. badFrame->SetVisible( true );
  1161. }
  1162. }
  1163. idSWFTextInstance * txtVal = oxygen->GetScriptObject()->GetNestedText( "info", "txtHeading" );
  1164. if ( txtVal != NULL ) {
  1165. txtVal->SetText( "#str_00100922" );
  1166. txtVal->SetStrokeInfo( true, 0.9f, 2.0f );
  1167. }
  1168. txtVal = oxygen->GetScriptObject()->GetNestedText( "info", "txtVal" );
  1169. if ( txtVal != NULL ) {
  1170. txtVal->SetText( va( "%d", val ) );
  1171. txtVal->SetStrokeInfo( true, 0.9f, 2.0f );
  1172. }
  1173. } else if ( !show ) {
  1174. inVaccuum = false;
  1175. oxygen->StopFrame( 1 );
  1176. }
  1177. }
  1178. /*
  1179. ========================
  1180. idMenuScreen_HUD::SetupObjective
  1181. ========================
  1182. */
  1183. void idMenuScreen_HUD::SetupObjective( const idStr & title, const idStr & desc, const idMaterial * screenshot ) {
  1184. objTitle = title;
  1185. objDesc = desc;
  1186. objScreenshot = screenshot;
  1187. }
  1188. /*
  1189. ========================
  1190. idMenuScreen_HUD::SetupObjective
  1191. ========================
  1192. */
  1193. void idMenuScreen_HUD::SetupObjectiveComplete( const idStr & title ) {
  1194. objCompleteTitle = title;
  1195. }
  1196. /*
  1197. ========================
  1198. idMenuScreen_HUD::ShowObjective
  1199. ========================
  1200. */
  1201. void idMenuScreen_HUD::ShowObjective( bool complete ) {
  1202. if ( complete ) {
  1203. if ( !objectiveComplete ) {
  1204. return;
  1205. }
  1206. objectiveComplete->SetVisible( true );
  1207. objectiveComplete->PlayFrame( "rollOn" );
  1208. idSWFTextInstance * txtComplete = objectiveComplete->GetScriptObject()->GetNestedText( "info", "txtComplete" );
  1209. idSWFTextInstance * txtTitle = objectiveComplete->GetScriptObject()->GetNestedText( "info", "txtTitle" );
  1210. idSWFSpriteInstance * rightArrow = objectiveComplete->GetScriptObject()->GetNestedSprite( "info", "right_arrows" );
  1211. if ( txtComplete != NULL ) {
  1212. txtComplete->SetStrokeInfo( true, 0.9f, 2.0f );
  1213. if ( rightArrow != NULL ) {
  1214. rightArrow->SetXPos( txtComplete->GetTextLength() + 30.0f );
  1215. }
  1216. }
  1217. if ( txtTitle != NULL ) {
  1218. txtTitle->SetText( objCompleteTitle );
  1219. txtTitle->SetStrokeInfo( true, 0.9f, 2.0f );
  1220. }
  1221. } else {
  1222. if ( !objective ) {
  1223. return;
  1224. }
  1225. objective->SetVisible( true );
  1226. objective->PlayFrame( "rollOn" );
  1227. idSWFTextInstance * txtNew = objective->GetScriptObject()->GetNestedText( "info", "txtComplete" );
  1228. idSWFTextInstance * txtTitle = objective->GetScriptObject()->GetNestedText( "info", "txtTitle" );
  1229. idSWFTextInstance * txtDesc = objective->GetScriptObject()->GetNestedText( "info", "txtDesc" );
  1230. idSWFSpriteInstance * img = objective->GetScriptObject()->GetNestedSprite( "info", "img" );
  1231. idSWFSpriteInstance * rightArrow = objective->GetScriptObject()->GetNestedSprite( "info", "right_arrows" );
  1232. if ( txtNew != NULL ) {
  1233. txtNew->SetStrokeInfo( true, 0.9f, 2.0f );
  1234. if ( rightArrow != NULL ) {
  1235. rightArrow->SetXPos( txtNew->GetTextLength() + 55.0f );
  1236. }
  1237. }
  1238. if ( txtTitle != NULL ) {
  1239. txtTitle->SetText( objTitle );
  1240. txtTitle->SetStrokeInfo( true, 0.9f, 2.0f );
  1241. }
  1242. if ( txtDesc ) {
  1243. txtDesc->SetText( objDesc );
  1244. }
  1245. if ( img != NULL ) {
  1246. img->SetMaterial( objScreenshot );
  1247. }
  1248. }
  1249. }
  1250. /*
  1251. ========================
  1252. idMenuScreen_HUD::HideObjective
  1253. ========================
  1254. */
  1255. void idMenuScreen_HUD::HideObjective( bool complete ) {
  1256. if ( complete ) {
  1257. if ( !objectiveComplete ) {
  1258. return;
  1259. }
  1260. objectiveComplete->PlayFrame( "rollOff" );
  1261. } else {
  1262. if ( !objective ) {
  1263. return;
  1264. }
  1265. objective->PlayFrame( "rollOff" );
  1266. }
  1267. }
  1268. //******************************************************************************************
  1269. // MULTIPLAYER FUNCITONS
  1270. //******************************************************************************************
  1271. /*
  1272. ========================
  1273. idMenuScreen_HUD::ToggleMPInfo
  1274. ========================
  1275. */
  1276. void idMenuScreen_HUD::ToggleMPInfo( bool show, bool showTeams, bool isCTF ) {
  1277. if ( !mpInfo ) {
  1278. return;
  1279. }
  1280. if ( show ) {
  1281. mpInfo->SetVisible( true );
  1282. idSWFSpriteInstance * redTeam = mpInfo->GetScriptObject()->GetNestedSprite( "redTeam" );
  1283. idSWFSpriteInstance * blueTeam = mpInfo->GetScriptObject()->GetNestedSprite( "blueTeam" );
  1284. idSWFSpriteInstance * redFlag = mpInfo->GetScriptObject()->GetNestedSprite( "redFlag" );
  1285. idSWFSpriteInstance * blueFlag = mpInfo->GetScriptObject()->GetNestedSprite( "blueFlag" );
  1286. if ( redFlag ) {
  1287. redFlag->SetVisible( isCTF );
  1288. }
  1289. if ( blueFlag ) {
  1290. blueFlag->SetVisible( isCTF );
  1291. }
  1292. if ( !showTeams ) {
  1293. if ( redTeam ) {
  1294. redTeam->SetVisible( false );
  1295. }
  1296. if ( blueTeam ) {
  1297. blueTeam->SetVisible( false );
  1298. }
  1299. } else {
  1300. if ( redTeam ) {
  1301. redTeam->SetVisible( true );
  1302. }
  1303. if ( blueTeam ) {
  1304. blueTeam->SetVisible( true );
  1305. }
  1306. }
  1307. } else {
  1308. mpInfo->SetVisible( false );
  1309. }
  1310. }
  1311. /*
  1312. ========================
  1313. idMenuScreen_HUD::SetFlagState
  1314. ========================
  1315. */
  1316. void idMenuScreen_HUD::SetFlagState( int team, int state ) {
  1317. if ( !mpInfo ) {
  1318. return;
  1319. }
  1320. idSWFSpriteInstance * flag = NULL;
  1321. if ( team == 0 ) {
  1322. flag = mpInfo->GetScriptObject()->GetNestedSprite( "redFlag" );
  1323. } else if ( team == 1 ) {
  1324. flag = mpInfo->GetScriptObject()->GetNestedSprite( "blueFlag" );
  1325. }
  1326. if ( flag ) {
  1327. if ( state == 3 ) { //FLAGSTATUS_NONE
  1328. flag->StopFrame( 1 );
  1329. } else {
  1330. flag->SetVisible( true );
  1331. flag->StopFrame( state + 2 );
  1332. }
  1333. }
  1334. }
  1335. /*
  1336. ========================
  1337. idMenuScreen_HUD::SetTeamScore
  1338. ========================
  1339. */
  1340. void idMenuScreen_HUD::SetTeamScore( int team, int score ) {
  1341. if ( !mpInfo ) {
  1342. return;
  1343. }
  1344. idSWFTextInstance * txtScore = NULL;
  1345. if ( team == 0 ) {
  1346. txtScore = mpInfo->GetScriptObject()->GetNestedText( "redTeam", "txtRedScore" );
  1347. } else if ( team == 1 ) {
  1348. txtScore = mpInfo->GetScriptObject()->GetNestedText( "blueTeam", "txtBlueScore" );
  1349. }
  1350. if ( txtScore ) {
  1351. txtScore->SetText( va( "%i", score ) );
  1352. txtScore->SetStrokeInfo( true, 0.75f, 1.5f );
  1353. }
  1354. }
  1355. /*
  1356. ========================
  1357. idMenuScreen_HUD::SetTeam
  1358. ========================
  1359. */
  1360. void idMenuScreen_HUD::SetTeam( int team ) {
  1361. if ( !mpInfo ) {
  1362. return;
  1363. }
  1364. idSWFSpriteInstance * teamBacking = mpInfo->GetScriptObject()->GetNestedSprite( "teamBack" );
  1365. if ( teamBacking ) {
  1366. if ( team < 0 ) {
  1367. teamBacking->StopFrame( 3 );
  1368. } else {
  1369. teamBacking->StopFrame( team + 1 );
  1370. }
  1371. }
  1372. }
  1373. /*
  1374. ========================
  1375. idMenuScreen_HUD::TriggerHitTarget
  1376. ========================
  1377. */
  1378. void idMenuScreen_HUD::TriggerHitTarget( bool show, const idStr & target, int color ) {
  1379. if ( !mpHitInfo ) {
  1380. return;
  1381. }
  1382. if ( show ) {
  1383. mpHitInfo->SetVisible( true );
  1384. mpHitInfo->PlayFrame( "rollOn" );
  1385. if ( menuGUI ) {
  1386. menuGUI->SetGlobal( "hitTargetName", target.c_str() );
  1387. }
  1388. idSWFSpriteInstance * backing = mpHitInfo->GetScriptObject()->GetNestedSprite( "bgColor" );
  1389. if ( backing ) {
  1390. if ( color <= 0 || !gameLocal.mpGame.IsGametypeTeamBased() ) {
  1391. color = 1;
  1392. }
  1393. backing->StopFrame( color );
  1394. }
  1395. } else {
  1396. mpHitInfo->PlayFrame( "rollOff" );
  1397. }
  1398. }
  1399. /*
  1400. ========================
  1401. idMenuScreen_HUD::ToggleLagged
  1402. ========================
  1403. */
  1404. void idMenuScreen_HUD::ToggleLagged( bool show ) {
  1405. if ( !mpConnection ) {
  1406. return;
  1407. }
  1408. mpConnection->SetVisible( show );
  1409. }
  1410. /*
  1411. ========================
  1412. idMenuScreen_HUD::UpdateGameTime
  1413. ========================
  1414. */
  1415. void idMenuScreen_HUD::UpdateGameTime( const char * time ) {
  1416. if ( !mpTime ) {
  1417. return;
  1418. }
  1419. UpdateMessage( false, "" );
  1420. mpTime->SetText( time );
  1421. mpTime->SetStrokeInfo( true, 0.75f, 1.5f );
  1422. }
  1423. /*
  1424. ========================
  1425. idMenuScreen_HUD::UpdateMessage
  1426. ========================
  1427. */
  1428. void idMenuScreen_HUD::UpdateMessage( bool show, const idStr & message ) {
  1429. if ( !mpMessage ) {
  1430. return;
  1431. }
  1432. if ( show ) {
  1433. if ( mpTime ) {
  1434. mpTime->SetText( "" );
  1435. }
  1436. mpMessage->SetText( message );
  1437. mpMessage->SetStrokeInfo( true, 0.75f, 1.5f );
  1438. } else {
  1439. mpMessage->SetText( "" );
  1440. }
  1441. }
  1442. /*
  1443. ========================
  1444. idMenuScreen_HUD::ShowNewItem
  1445. ========================
  1446. */
  1447. void idMenuScreen_HUD::ShowNewItem( const char * name, const char * icon ) {
  1448. if ( !newItem ) {
  1449. return;
  1450. }
  1451. newItem->SetVisible( true );
  1452. newItem->PlayFrame( "rollOn" );
  1453. idSWFSpriteInstance * topImg = newItem->GetScriptObject()->GetNestedSprite( "info", "topImg" );
  1454. idSWFSpriteInstance * botImg = newItem->GetScriptObject()->GetNestedSprite( "info", "botImg" );
  1455. idSWFTextInstance * heading = newItem->GetScriptObject()->GetNestedText( "info", "txtTitle" );
  1456. idSWFTextInstance * itemName = newItem->GetScriptObject()->GetNestedText( "info", "txtItem" );
  1457. const idMaterial * mat = declManager->FindMaterial( icon, false );
  1458. if ( topImg != NULL && botImg != NULL && mat != NULL ) {
  1459. topImg->SetMaterial( mat );
  1460. botImg->SetMaterial( mat );
  1461. }
  1462. if ( heading != NULL ) {
  1463. heading->SetText( "#str_02027" );
  1464. heading->SetStrokeInfo( true, 0.75f, 1.5f );
  1465. }
  1466. if ( itemName != NULL ) {
  1467. itemName->SetText( name );
  1468. itemName->SetStrokeInfo( true, 0.75f, 1.5f );
  1469. }
  1470. }
  1471. /*
  1472. ========================
  1473. idMenuScreen_HUD::UpdateFlashlight
  1474. ========================
  1475. */
  1476. void idMenuScreen_HUD::UpdateFlashlight( idPlayer * player ) {
  1477. if ( !player || !flashlight ) {
  1478. return;
  1479. }
  1480. if ( player->flashlightBattery != flashlight_batteryDrainTimeMS.GetInteger() ) {
  1481. flashlight->StopFrame( 2 );
  1482. flashlight->SetVisible( true );
  1483. idSWFSpriteInstance * batteryLife = flashlight->GetScriptObject()->GetNestedSprite( "info" );
  1484. if ( batteryLife ) {
  1485. float power = ( (float)player->flashlightBattery / (float)flashlight_batteryDrainTimeMS.GetInteger() ) * 100.0f;
  1486. batteryLife->StopFrame( power );
  1487. }
  1488. } else {
  1489. flashlight->StopFrame( 1 );
  1490. }
  1491. }
  1492. /*
  1493. ========================
  1494. idMenuScreen_HUD::UpdateChattingHud
  1495. ========================
  1496. */
  1497. void idMenuScreen_HUD::UpdateChattingHud( idPlayer * player ) {
  1498. if ( !mpChatObject || !GetSWFObject() ) {
  1499. return;
  1500. }
  1501. idSWF * gui = GetSWFObject();
  1502. if ( player->isChatting == 0 ) {
  1503. if ( mpChatObject->GetCurrentFrame() != 1 ) {
  1504. mpChatObject->StopFrame( 1 );
  1505. gui->ForceInhibitControl( false );
  1506. gui->SetGlobal( "focusWindow", NULL );
  1507. }
  1508. } else {
  1509. if ( !mpChatObject->IsVisible() ) {
  1510. mpChatObject->SetVisible( true );
  1511. mpChatObject->PlayFrame( "rollOn" );
  1512. gui->ForceInhibitControl( true );
  1513. idSWFTextInstance * txtType = mpChatObject->GetScriptObject()->GetNestedText( "info", "saybox" );
  1514. int length = 0;
  1515. if ( txtType ) {
  1516. if ( player->isChatting == 1 ) {
  1517. txtType->SetText( "#str_swf_talk_all" );
  1518. } else if ( player->isChatting == 2 ) {
  1519. txtType->SetText( "#str_swf_talk_team" );
  1520. }
  1521. txtType->SetStrokeInfo( true );
  1522. length = txtType->GetTextLength();
  1523. }
  1524. idSWFSpriteInstance * sayBox = mpChatObject->GetScriptObject()->GetNestedSprite( "info", "textEntry" );
  1525. if ( sayBox ) {
  1526. sayBox->SetXPos( length + 10 );
  1527. }
  1528. idSWFTextInstance * say = mpChatObject->GetScriptObject()->GetNestedText( "info", "textEntry", "txtVal" );
  1529. if ( say != NULL ) {
  1530. say->SetIgnoreColor( false );
  1531. say->SetText( "" );
  1532. say->SetStrokeInfo( true );
  1533. say->renderMode = SWF_TEXT_RENDER_AUTOSCROLL;
  1534. }
  1535. idSWFScriptObject * const sayObj = mpChatObject->GetScriptObject()->GetNestedObj( "info", "textEntry", "txtVal" );
  1536. if ( sayObj != NULL ) {
  1537. gui->SetGlobal( "focusWindow", sayObj );
  1538. class idPostTextChat : public idSWFScriptFunction_RefCounted {
  1539. public:
  1540. idPostTextChat( idPlayer * _player, idSWFTextInstance * _text ) {
  1541. player = _player;
  1542. text = _text;
  1543. }
  1544. idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
  1545. if ( !player || !text ) {
  1546. return idSWFScriptVar();
  1547. }
  1548. idStr val = text->text;
  1549. val.Replace( "\'", "" );
  1550. val.Replace( "\"", "" );
  1551. idStr command;
  1552. if ( player->isChatting == 2 ) {
  1553. command = va( "sayTeam %s\n", val.c_str() );
  1554. } else {
  1555. command = va( "say %s\n", val.c_str() );
  1556. }
  1557. cmdSystem->BufferCommandText( CMD_EXEC_NOW, command.c_str() );
  1558. player->isChatting = 0;
  1559. return idSWFScriptVar();
  1560. }
  1561. idPlayer * player;
  1562. idSWFTextInstance * text;
  1563. };
  1564. class idCancelTextChat : public idSWFScriptFunction_RefCounted {
  1565. public:
  1566. idCancelTextChat( idPlayer * _player ) {
  1567. player = _player;
  1568. }
  1569. idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
  1570. if ( !player ) {
  1571. return idSWFScriptVar();
  1572. }
  1573. player->isChatting = 0;
  1574. return idSWFScriptVar();
  1575. }
  1576. idPlayer * player;
  1577. };
  1578. sayObj->Set( "onPress", new ( TAG_SWF ) idPostTextChat( player, say ) );
  1579. idSWFScriptObject * const shortcutKeys = gui->GetGlobal( "shortcutKeys" ).GetObject();
  1580. if ( verify( shortcutKeys != NULL ) ) {
  1581. shortcutKeys->Set( "ENTER", sayObj );
  1582. shortcutKeys->Set( "ESCAPE", new ( TAG_SWF ) idCancelTextChat( player ) );
  1583. }
  1584. }
  1585. }
  1586. }
  1587. }