Advertisement
Guest User

Untitled

a guest
Aug 29th, 2021
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.21 KB | None | 0 0
  1. /***********************************************************************/
  2. /** © 2015 CD PROJEKT S.A. All rights reserved.
  3. /** THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /** The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6. struct SJournalUpdate
  7. {
  8. var text : string;
  9. var title : string;
  10. var status : EJournalStatus;
  11. var journalEntry : CJournalBase;
  12. var iconPath : string;
  13. var panelName : name;
  14. var entryTag : name;
  15. var soundEvent : string;
  16. var isQuestUpdate : bool;
  17. var displayTime : float;
  18. var itemId : SItemUniqueId;
  19. var isItemUpdate : bool;
  20.  
  21. default title = ""; 4 ; } ;
  22.  
  23. class CR4HudModuleJournalUpdate extends CR4HudModuleBase
  24. {
  25. private var _bDuringDisplay : bool; default _bDuringDisplay = false;
  26.  
  27. private var m_fxShowJournalUpdateSFF : CScriptedFlashFunction;
  28. private var m_fxSetJournalUpdateStatusSFF : CScriptedFlashFunction;
  29. private var m_fxSetJournalUpdateStatusTextSFF : CScriptedFlashFunction;
  30. private var m_fxClearJournalUpdateSFF : CScriptedFlashFunction;
  31. private var m_fxSetIconSFF : CScriptedFlashFunction;
  32. private var m_fxHideItemInfo : CScriptedFlashFunction;
  33. private var m_fxPauseShowTimer : CScriptedFlashFunction;
  34.  
  35. private var questsUpdates : array< CJournalQuest>;
  36. private var journalUpdates : array< SJournalUpdate>;
  37. private var manager : CWitcherJournalManager;
  38. private var m_guiManager : CR4GuiManager;
  39. private var m_flashValueStorage : CScriptedFlashValueStorage;
  40. private var m_defaultInputBindings : array< SKeyBinding>;
  41. private var m_bookItemId : SItemUniqueId;
  42. private var m_bookPopupData : BookPopupFeedback;
  43. private var m_paintingPopupData : PaintingPopup;
  44.  
  45. private var bShowTimerStopped : bool;
  46. private var bWasRemoved : bool;
  47. private var defaultDisplayTime : float;
  48. private var defaultBookInfoDisplayTime : float;
  49. private var defaultTrackableDisplayTime : float;
  50.  
  51. default defaultDisplayTime = 3000;
  52. default defaultBookInfoDisplayTime = 6000;
  53. default defaultTrackableDisplayTime = 6000;
  54. default bWasRemoved = true;
  55. default bShowTimerStopped = false;
  56.  
  57. event OnConfigUI()
  58. {
  59. var flashModule : CScriptedFlashSprite;
  60. var hud : CR4ScriptedHud;
  61.  
  62. m_anchorName = "mcAnchorJournalUpdate";
  63. super.OnConfigUI();
  64.  
  65. flashModule = GetModuleFlash();
  66. m_flashValueStorage = GetModuleFlashValueStorage();
  67. m_fxShowJournalUpdateSFF = flashModule.GetMemberFlashFunction( "ShowJournalUpdate" );
  68. m_fxSetJournalUpdateStatusSFF = flashModule.GetMemberFlashFunction( "SetJournalUpdateStatus" );
  69. m_fxClearJournalUpdateSFF = flashModule.GetMemberFlashFunction( "ClearJournalUpdate" );
  70. m_fxSetIconSFF = flashModule.GetMemberFlashFunction( "SetIcon" );
  71. m_fxHideItemInfo = flashModule.GetMemberFlashFunction( "hideItemInfo" );
  72. m_fxPauseShowTimer = flashModule.GetMemberFlashFunction( "PauseShowTimer" );
  73.  
  74. manager = theGame.GetJournalManager();
  75. m_guiManager = theGame.GetGuiManager();
  76.  
  77. //---=== modFriendlyHUD ===---
  78. if( GetFHUDConfig().hideJournalUpdates )
  79. {
  80. ShowElement(false);
  81. }
  82. //---=== modFriendlyHUD ===---
  83.  
  84. hud = (CR4ScriptedHud)theGame.GetHud();
  85.  
  86.  
  87.  
  88.  
  89.  
  90. }
  91.  
  92. event OnTick( timeDelta : float )
  93. {
  94. var currentContext : name;
  95.  
  96. if( !theGame.IsPausedForReason( "Popup" ) )
  97. {
  98. if( !_bDuringDisplay )
  99. {
  100. if( CheckPending() )
  101. {
  102. DisplayPending();
  103. }
  104. }
  105. else if(journalUpdates.Size() > 0)
  106. {
  107. if( !CheckSceneAndCutsceneDisplay(journalUpdates[0].status,journalUpdates[0].isQuestUpdate) )
  108. {
  109. m_fxClearJournalUpdateSFF.InvokeSelf();
  110. OnRemoveUpdate();
  111. OnShowUpdateEnd();
  112. }
  113. }
  114. }
  115.  
  116. if( theGame.IsPaused() )
  117. {
  118. if ( !bShowTimerStopped )
  119. {
  120. bShowTimerStopped = true;
  121. m_fxPauseShowTimer.InvokeSelfOneArg( FlashArgBool( true ) );
  122. }
  123. }
  124. else
  125. {
  126. if ( bShowTimerStopped )
  127. {
  128. bShowTimerStopped = false;
  129. m_fxPauseShowTimer.InvokeSelfOneArg( FlashArgBool( false ) );
  130. }
  131. }
  132.  
  133.  
  134.  
  135. currentContext = theInput.GetContext();
  136.  
  137. if ( thePlayer.inv.IsIdValid( m_bookItemId ) && currentContext == 'Scene')
  138. {
  139. m_bookItemId = GetInvalidUniqueId();
  140. m_fxHideItemInfo.InvokeSelf();
  141. }
  142.  
  143. if( m_bookPopupData && currentContext == 'Scene' )
  144. {
  145. m_bookPopupData.ClosePopupOverlay();
  146. delete m_bookPopupData;
  147. }
  148. }
  149.  
  150. public function isBookInfoShown():bool
  151. {
  152. return thePlayer.inv.IsIdValid( m_bookItemId ) || m_bookPopupData;
  153. }
  154.  
  155. event OnInputHandled(NavCode:string, KeyCode:int, ActionId:int)
  156. {
  157.  
  158. }
  159.  
  160. function CheckPending() : bool
  161. {
  162. if( GetPendingSize() > 0 && theInput.GetContext() != 'RadialMenu' && theInput.GetContext() != 'Death' )
  163. {
  164. return true;
  165. }
  166. return false;
  167. }
  168.  
  169. function DisplayPending()
  170. {
  171. var title : string;
  172. var offset : int;
  173. var isTrackableQuest : bool;
  174. var isCutscene : bool;
  175. var itemId : SItemUniqueId;
  176. var lootPopup : CR4LootPopup;
  177.  
  178. if ( theGame.IsBlackscreen() || theGame.IsFading() )
  179. {
  180. return;
  181. }
  182.  
  183. //---=== modFriendlyHUD ===---
  184. if( GetFHUDConfig().hideJournalUpdates )
  185. {
  186. ShowElement(false);
  187. journalUpdates.Clear();
  188. return;
  189. }
  190. //---=== modFriendlyHUD ===---
  191.  
  192. _bDuringDisplay = true;
  193. isCutscene = theInput.GetContext() == 'Scene';
  194.  
  195.  
  196.  
  197. lootPopup = (CR4LootPopup)theGame.GetGuiManager().GetPopup('LootPopup');
  198. itemId = journalUpdates[0].itemId;
  199. if (thePlayer.inv.IsIdValid(itemId) && !isCutscene )
  200. {
  201. if (lootPopup)
  202. {
  203.  
  204. _bDuringDisplay = false;
  205. return;
  206. }
  207.  
  208. ShowElement(true);
  209. ShowItemInfo(itemId);
  210. journalUpdates.Erase(0);
  211. return;
  212. }
  213.  
  214.  
  215.  
  216.  
  217.  
  218. if( (CJournalQuest)journalUpdates[0].journalEntry )
  219. {
  220. if( !CheckSceneAndCutsceneDisplay(journalUpdates[0].status,journalUpdates[0].isQuestUpdate) )
  221. {
  222. if( journalUpdates.Size() > 0 )
  223. {
  224. journalUpdates.Erase(0);
  225. }
  226. _bDuringDisplay = false;
  227. return;
  228. }
  229. }
  230.  
  231. title = journalUpdates[0].title;
  232. offset = 1;
  233. if( journalUpdates[0].iconPath != "" )
  234. {
  235. offset +=4; }
  236.  
  237. m_fxSetJournalUpdateStatusSFF.InvokeSelfOneArg(FlashArgInt(journalUpdates[0].status + offset));
  238.  
  239. isTrackableQuest = IsTrackableQuest();
  240. if( journalUpdates[0].displayTime == 0 )
  241. {
  242. if (isTrackableQuest)
  243. {
  244. journalUpdates[0].displayTime = defaultTrackableDisplayTime;
  245. }
  246. else
  247. {
  248. journalUpdates[0].displayTime = defaultDisplayTime;
  249. }
  250. }
  251.  
  252. m_fxShowJournalUpdateSFF.InvokeSelfThreeArgs( FlashArgString(journalUpdates[0].text), FlashArgString(title), FlashArgNumber(journalUpdates[0].displayTime) );
  253. m_fxSetIconSFF.InvokeSelfOneArg(FlashArgString(journalUpdates[0].iconPath));
  254. ShowElement(true);
  255.  
  256.  
  257. if ( journalUpdates[0].soundEvent == "" )
  258. journalUpdates[0].soundEvent = "gui_ingame_quest_active";
  259.  
  260. if( journalUpdates[0].soundEvent != "" && bWasRemoved )
  261. {
  262. if( !( theGame.IsBlackscreen() || theGame.IsFading() ) )
  263. {
  264. //---=== modFriendlyHUD ===---
  265. if( !GetFHUDConfig().silentJournalUpdates )
  266. {
  267. OnPlaySoundEvent( journalUpdates[0].soundEvent );
  268. }
  269. //---=== modFriendlyHUD ===---
  270. }
  271. //---=== modFriendlyHUD ===---
  272. }
  273. }
  274.  
  275. m_defaultInputBindings .Clear();
  276. if( ( theInput.GetContext() != 'Scene' ) && ( journalUpdates[0].journalEntry || IsNameValid( journalUpdates[0].entryTag ) && !thePlayer.IsCiri() ) )
  277. {
  278. if( isTrackableQuest )
  279. {
  280. RegisterKeyBindings("panel_button_journal_track");
  281.  
  282. if( ShouldProcessTutorial( 'TutorialNotTrackedQuestUpdate' ) )
  283. {
  284. FactsAdd( 'tut_not_tracked_quest_updates' );
  285. }
  286. }
  287. SetButtons( ( (CJournalQuest)journalUpdates[0].journalEntry ) );
  288. }
  289. UpdateInputFeedback();
  290. bWasRemoved = false;
  291. }
  292.  
  293. private function ShowItemInfo(itemId : SItemUniqueId):void
  294. {
  295. var outKeysPC : array< EInputKey >;
  296. var itemInfoData : CScriptedFlashObject;
  297. var playerInv : CInventoryComponent;
  298. var itemName : string;
  299. var iconPath : string;
  300.  
  301. playerInv = thePlayer.inv;
  302. itemName = GetLocStringByKeyExt( playerInv.GetItemLocalizedNameByUniqueID( itemId ) );
  303. iconPath = playerInv.GetItemIconPathByUniqueID( itemId );
  304. m_bookItemId = itemId;
  305.  
  306. outKeysPC.Clear();
  307. theInput.GetPCKeysForAction( 'TrackQuest' ,outKeysPC );
  308.  
  309. theInput.RegisterListener( this, 'OnTrackQuest', 'TrackQuest' );
  310.  
  311.  
  312. itemInfoData = m_flashValueStorage.CreateTempFlashObject();
  313. itemInfoData.SetMemberFlashNumber("showTime", defaultBookInfoDisplayTime);
  314. itemInfoData.SetMemberFlashString("itemName", itemName);
  315. itemInfoData.SetMemberFlashString("iconPath", "img://" + iconPath);
  316. itemInfoData.SetMemberFlashString("buttonLabel", GetLocStringByKeyExt("panel_button_inventory_read"));
  317. itemInfoData.SetMemberFlashString("gpadCode", "gamepad_R_Hold");
  318.  
  319. if (outKeysPC.Size() > 0)
  320. {
  321. itemInfoData.SetMemberFlashInt("keyCode", outKeysPC[0]);
  322. }
  323. else
  324. {
  325. itemInfoData.SetMemberFlashInt("keyCode", -1);
  326. }
  327.  
  328.  
  329. m_flashValueStorage.SetFlashObject("hud.journalupdate.bookinfo", itemInfoData);
  330. }
  331.  
  332. private function ShowItemInfoPopup( itemId : SItemUniqueId )
  333. {
  334. var uiData : SInventoryItemUIData;
  335. var playerInv : CInventoryComponent;
  336. var itemName : name;
  337.  
  338. playerInv = thePlayer.inv;
  339.  
  340. if (m_bookPopupData)
  341. {
  342. delete m_bookPopupData;
  343. }
  344.  
  345. if (m_paintingPopupData)
  346. {
  347. delete m_paintingPopupData;
  348. }
  349.  
  350. if( playerInv.ItemHasTag( itemId, 'Painting' ) )
  351. {
  352. itemName = playerInv.GetItemName( itemId );
  353.  
  354. m_paintingPopupData = new PaintingPopup in this;
  355. m_paintingPopupData.SetMessageTitle( GetLocStringByKeyExt( playerInv.GetItemLocalizedNameByUniqueID( itemId ) ) );
  356. m_paintingPopupData.SetImagePath("img://icons/inventory/paintings/" + itemName + ".png");
  357. m_paintingPopupData.PauseGame = true;
  358.  
  359. theGame.RequestMenu('PopupMenu', m_paintingPopupData);
  360. }
  361. else
  362. {
  363. m_bookPopupData = new BookPopupFeedback in this;
  364. m_bookPopupData.SetMessageTitle( GetLocStringByKeyExt(playerInv.GetItemLocalizedNameByUniqueID(itemId)) );
  365. m_bookPopupData.SetMessageText( playerInv.GetBookText(itemId) );
  366. m_bookPopupData.curInventory = thePlayer.GetInventory();
  367. m_bookPopupData.PauseGame = true;
  368. m_bookPopupData.bookItemId = itemId;
  369.  
  370. theGame.RequestMenu('PopupMenu', m_bookPopupData);
  371. }
  372.  
  373. m_fxHideItemInfo.InvokeSelf();
  374. playerInv.ReadBook( itemId );
  375.  
  376.  
  377. }
  378.  
  379. private function RegisterKeyBindings(label : string):void
  380. {
  381. var outKeys : array< EInputKey >;
  382. var outKeysPC : array< EInputKey >;
  383.  
  384. outKeys.Clear();
  385. outKeysPC.Clear();
  386.  
  387. theInput.GetPadKeysForAction( 'TrackQuest' ,outKeys );
  388. theInput.GetPCKeysForAction( 'TrackQuest' ,outKeysPC );
  389. theInput.RegisterListener( this, 'OnTrackQuest', 'TrackQuest' );
  390.  
  391. if( outKeys.Size() + outKeysPC.Size() > 0 )
  392. {
  393. if (outKeysPC.Size() > 0)
  394. {
  395. AddInputBinding(label, "gamepad_R_Hold", outKeysPC[0]);
  396. }
  397. else
  398. {
  399. AddInputBinding(label, "gamepad_R_Hold", -1);
  400. }
  401. }
  402. }
  403.  
  404. function IsTrackableQuest() : bool
  405. {
  406. var curUpdatedQuest : CJournalQuest;
  407. var curTrackedQuest : CJournalQuest;
  408.  
  409. curUpdatedQuest = (CJournalQuest)manager.GetEntryByGuid(journalUpdates[0].journalEntry.guid);
  410.  
  411. if (!curUpdatedQuest)
  412. {
  413. curUpdatedQuest = (CJournalQuest)journalUpdates[0].journalEntry;
  414. }
  415.  
  416. curTrackedQuest = theGame.GetJournalManager().GetTrackedQuest();
  417. if(curUpdatedQuest && curUpdatedQuest != curTrackedQuest && journalUpdates[0].status < 2 && manager.GetEntryStatus(curUpdatedQuest) < 2)
  418. {
  419. return true;
  420. }
  421. return false;
  422. }
  423.  
  424. function GetQuestStatusTitle( status : EJournalStatus, questType : eQuestType ) : string
  425. {
  426. var str : string;
  427. if( questType == MonsterHunt )
  428. {
  429. switch(status)
  430. {
  431. case JS_Active :
  432. str = "panel_journal_monstercontract_update_active";
  433. break;
  434. case JS_Success :
  435. str = "panel_journal_monstercontract_update_success";
  436. break;
  437. case JS_Failed :
  438. str = "panel_journal_monstercontract_update_failed";
  439. break;
  440. case JS_Inactive :
  441. str = "panel_journal_monstercontract_update_new";
  442. break;
  443. }
  444. }
  445. else
  446. {
  447. switch(status)
  448. {
  449. case JS_Active :
  450. str = "panel_journal_quest_update_active";
  451. break;
  452. case JS_Success :
  453. str = "panel_journal_quest_update_success";
  454. break;
  455. case JS_Failed :
  456. str = "panel_journal_quest_update_failed";
  457. break;
  458. case JS_Inactive :
  459. str = "panel_journal_quest_update_new";
  460. break;
  461. }
  462. }
  463.  
  464. return GetLocStringByKeyExt(str);
  465. }
  466.  
  467. function GetPendingSize() : int
  468. {
  469. return journalUpdates.Size();
  470. }
  471.  
  472. function AddQuestUpdate(journalQuest : CJournalQuest, isQuestUpdate : bool ) : void
  473. {
  474. var newJournalUpdate : SJournalUpdate;
  475. var status : EJournalStatus;
  476.  
  477. newJournalUpdate.journalEntry = journalQuest;
  478. newJournalUpdate.text = GetLocStringById( journalQuest.GetTitleStringId() );
  479. newJournalUpdate.isQuestUpdate = isQuestUpdate;
  480. status = manager.GetEntryStatus(journalQuest);
  481.  
  482. if( thePlayer.IsNewQuest( newJournalUpdate.journalEntry.guid ) && status == JS_Active )
  483. {
  484. newJournalUpdate.status = JS_Inactive;
  485. newJournalUpdate.soundEvent = "gui_ingame_quest_active";
  486. theSound.lim_UnmuteAndRestart(); // modUnmuteAndRestart
  487. }
  488. else
  489. {
  490. newJournalUpdate.status = status;
  491. switch( status )
  492. {
  493. case JS_Active :
  494. newJournalUpdate.soundEvent = "gui_ingame_new_journal";
  495. break;
  496. case JS_Success :
  497. newJournalUpdate.soundEvent = "gui_ingame_quest_success";
  498. break;
  499. case JS_Failed :
  500. newJournalUpdate.soundEvent = "gui_ingame_quest_fail";
  501. break;
  502. }
  503. }
  504. newJournalUpdate.title = GetQuestStatusTitle(newJournalUpdate.status,journalQuest.GetType());
  505.  
  506. if( !HasQuestPendingUpdate( journalQuest, newJournalUpdate.status ) )
  507. {
  508. journalUpdates.PushBack(newJournalUpdate);
  509. }
  510. }
  511.  
  512. function CheckSceneAndCutsceneDisplay( status : EJournalStatus, isQuestUpdate : bool ) : bool
  513. {
  514. if( theInput.GetContext() == 'Scene' && journalUpdates[0].iconPath == "" )
  515. {
  516. if( isQuestUpdate )
  517. {
  518. if( status == JS_Success || status == JS_Failed )
  519. {
  520. return true;
  521. }
  522. else
  523. {
  524. return false;
  525. }
  526. }
  527. else
  528. {
  529. return false;
  530. }
  531. }
  532. return true;
  533. }
  534.  
  535. function AddCraftingSchematicUpdate( schematicName : name ) : void
  536. {
  537. var newJournalUpdate : SJournalUpdate;
  538. var m_definitionsManager : CDefinitionsManagerAccessor;
  539.  
  540.  
  541.  
  542. m_definitionsManager = theGame.GetDefinitionsManager();
  543. newJournalUpdate.text = GetLocStringByKeyExt( m_definitionsManager.GetItemLocalisationKeyName( schematicName ));
  544. // modCustomLocalizationFix++
  545. if (newJournalUpdate.text == "")
  546. newJournalUpdate.text = m_definitionsManager.GetItemLocalisationKeyName( schematicName );
  547. // modCustomLocalizationFix--
  548.  
  549. newJournalUpdate.status = JS_Inactive;
  550. newJournalUpdate.iconPath = m_definitionsManager.GetItemIconPath( schematicName );
  551. newJournalUpdate.panelName = 'CraftingMenu';
  552. newJournalUpdate.entryTag = schematicName;
  553. newJournalUpdate.soundEvent = "gui_ingame_new_journal";
  554.  
  555. newJournalUpdate.title = GetLocStringByKeyExt("panel_hud_craftingschematic_update_new_entry");
  556. journalUpdates.PushBack(newJournalUpdate);
  557.  
  558. }
  559.  
  560. function AddAlchemySchematicUpdate( schematicName : name ) : void
  561. {
  562. var newJournalUpdate : SJournalUpdate;
  563. var m_definitionsManager : CDefinitionsManagerAccessor;
  564.  
  565.  
  566.  
  567. m_definitionsManager = theGame.GetDefinitionsManager();
  568. newJournalUpdate.text = GetLocStringByKeyExt( m_definitionsManager.GetItemLocalisationKeyName( schematicName ));
  569. // modCustomLocalizationFix++
  570. if (newJournalUpdate.text == "")
  571. newJournalUpdate.text = m_definitionsManager.GetItemLocalisationKeyName( schematicName );
  572. // modCustomLocalizationFix--
  573.  
  574. newJournalUpdate.status = JS_Inactive;
  575. newJournalUpdate.iconPath = m_definitionsManager.GetItemIconPath( schematicName );
  576. newJournalUpdate.panelName = 'AlchemyMenu';
  577. newJournalUpdate.entryTag = schematicName;
  578. newJournalUpdate.soundEvent = "gui_ingame_new_journal";
  579.  
  580. newJournalUpdate.title = GetLocStringByKeyExt("panel_hud_alchemyschematic_update_new_entry");
  581. journalUpdates.PushBack(newJournalUpdate);
  582.  
  583. }
  584.  
  585. function AddQuestBookInfo( itemId : SItemUniqueId ):void
  586. {
  587. var newJournalUpdate : SJournalUpdate;
  588.  
  589. if ( !thePlayer.inv.IsIdValid(itemId) )
  590. {
  591. return;
  592. }
  593.  
  594. if (HasJournalPendingItemInfo() || m_paintingPopupData)
  595. {
  596.  
  597. }
  598. else
  599. {
  600. newJournalUpdate.itemId = itemId;
  601. newJournalUpdate.isItemUpdate = true;
  602. journalUpdates.PushBack(newJournalUpdate);
  603. }
  604. }
  605.  
  606. function AddJournalUpdate( journalEntry : CJournalBase, isDescription : bool ) : void
  607. {
  608. var newJournalUpdate : SJournalUpdate;
  609.  
  610. if( !HasJournalPendingUpdate(journalEntry) )
  611. {
  612. newJournalUpdate.text = GetEntryText(journalEntry);
  613. newJournalUpdate.journalEntry = journalEntry;
  614. newJournalUpdate.status = JS_Active;
  615. newJournalUpdate.soundEvent = "gui_ingame_new_journal";
  616.  
  617. newJournalUpdate.title = GetEntryTitle(journalEntry, isDescription);
  618. journalUpdates.PushBack(newJournalUpdate);
  619. }
  620. }
  621.  
  622. function GetEntryText( journalEntry : CJournalBase ) : string
  623. {
  624. var str : string;
  625. var creatureEntry : CJournalCreature;
  626. var glossaryEntry : CJournalGlossary;
  627. var characterEntry : CJournalCharacter;
  628.  
  629. creatureEntry = (CJournalCreature)journalEntry;
  630. glossaryEntry = (CJournalGlossary)journalEntry;
  631. characterEntry = (CJournalCharacter)journalEntry;
  632.  
  633. if( creatureEntry )
  634. {
  635. str = GetLocStringById( creatureEntry.GetNameStringId() );
  636. }
  637. else if( glossaryEntry )
  638. {
  639. str = GetLocStringById( glossaryEntry.GetTitleStringId() );
  640. }
  641. else if( characterEntry )
  642. {
  643. str = GetLocStringById( characterEntry.GetNameStringId() );
  644. }
  645.  
  646. return str;
  647. }
  648.  
  649. function GetEntryTitle( journalEntry : CJournalBase, isDescription : bool ) : string
  650. {
  651. var str : string;
  652. var creatureEntry : CJournalCreature;
  653. var glossaryEntry : CJournalGlossary;
  654. var characterEntry : CJournalCharacter;
  655.  
  656. creatureEntry = (CJournalCreature)journalEntry;
  657. glossaryEntry = (CJournalGlossary)journalEntry;
  658. characterEntry = (CJournalCharacter)journalEntry;
  659.  
  660. if( creatureEntry )
  661. {
  662. str = "panel_hud_journal_entry_bestiary";
  663. }
  664. else if( glossaryEntry )
  665. {
  666. str = "panel_hud_journal_entry_glossary";
  667. }
  668. else if( characterEntry )
  669. {
  670. str = "panel_hud_journal_entry_character";
  671. }
  672. if( isDescription )
  673. {
  674. str += "_update";
  675. }
  676. else
  677. {
  678. str += "_new";
  679. }
  680.  
  681. return GetLocStringByKeyExt(str);
  682. }
  683.  
  684. function AddLevelUpUpdate( level : int ) : void
  685. {
  686. var newJournalUpdate : SJournalUpdate;
  687. var arrInt : array<int>;
  688.  
  689. newJournalUpdate.soundEvent = "gui_ingame_level_up";
  690.  
  691. newJournalUpdate.text = GetLocStringByKeyExt("panel_character_availablepoints") + ": " + GetWitcherPlayer().levelManager.GetPointsFree(ESkillPoint);
  692. newJournalUpdate.status = JS_Active;
  693. newJournalUpdate.iconPath = "icons\skills\level_gained.png";
  694.  
  695. newJournalUpdate.displayTime = 7000;
  696.  
  697. arrInt.PushBack(level);
  698. newJournalUpdate.title = GetLocStringByKeyExtWithParams("panel_hud_level_update_level_reached",arrInt);
  699.  
  700. journalUpdates.PushBack(newJournalUpdate);
  701. }
  702.  
  703. function AddExperienceUpdate( exp : int ) : void
  704. {
  705. var newJournalUpdate : SJournalUpdate;
  706. var arrInt : array<int>;
  707.  
  708. if(exp <= 0)
  709. {
  710. return;
  711. }
  712.  
  713. newJournalUpdate.soundEvent = "";
  714. arrInt.PushBack(exp);
  715. newJournalUpdate.text = GetLocStringByKeyExtWithParams("hud_combat_log_gained_experience", arrInt);
  716. newJournalUpdate.status = JS_Active + 1;
  717. newJournalUpdate.iconPath = "icons\skills\exp_gained.png";
  718. newJournalUpdate.title = GetLocStringByKey("panel_hud_item_update_recived_experience");
  719. journalUpdates.PushBack(newJournalUpdate);
  720. }
  721.  
  722. function AddMapPinUpdate( mapPinName : name ) : void
  723. {
  724. var newJournalUpdate : SJournalUpdate;
  725. newJournalUpdate.text = GetLocStringByKeyExt( StrLower("map_location_"+mapPinName) );
  726. newJournalUpdate.status = JS_Active;
  727. newJournalUpdate.soundEvent = "gui_ingame_new_mappin";
  728. newJournalUpdate.title = GetLocStringByKeyExt("panel_hud_map_update_new_entry");
  729. journalUpdates.PushBack(newJournalUpdate);
  730. }
  731.  
  732. function AddItemRecivedDuringSceneUpdate( itemName : name, optional quantity : int ) : void
  733. {
  734. var newJournalUpdate : SJournalUpdate;
  735. var inv : CInventoryComponent;
  736. inv = GetWitcherPlayer().GetInventory();
  737.  
  738. newJournalUpdate.text = GetLocStringByKeyExt( inv.GetItemLocalizedNameByName( itemName ));
  739. // modCustomLocalizationFix++
  740. if (newJournalUpdate.text == "")
  741. newJournalUpdate.text = inv.GetItemLocalizedNameByName( itemName );
  742. // modCustomLocalizationFix--
  743. newJournalUpdate.status = JS_Inactive;
  744. newJournalUpdate.iconPath = inv.GetItemIconPathByName( itemName );
  745.  
  746. if( itemName == 'experience' )
  747. {
  748. newJournalUpdate.title = GetLocStringByKeyExt("panel_hud_item_update_recived_experience");
  749. }
  750. else
  751. {
  752. newJournalUpdate.title = GetLocStringByKeyExt("panel_hud_item_update_recived");
  753. newJournalUpdate.soundEvent = "gui_ingame_new_reward_item";
  754. }
  755. if( quantity > 1 )
  756. {
  757. newJournalUpdate.text += " x "+quantity;
  758. }
  759. journalUpdates.PushBack(newJournalUpdate);
  760. }
  761.  
  762. function HasQuestPendingUpdate( journalQuest : CJournalQuest, status : EJournalStatus ) : bool
  763. {
  764. var i : int;
  765.  
  766. if( status == JS_Active )
  767. {
  768. for( i = 0; i < journalUpdates.Size(); i += 1 )
  769. {
  770. if( journalUpdates[i].status != JS_Failed && journalUpdates[i].status != JS_Success )
  771. {
  772. if( journalUpdates[i].journalEntry.guid == journalQuest.guid )
  773. {
  774. return true;
  775. }
  776. }
  777. }
  778. }
  779. else if( status == JS_Success )
  780. {
  781. for( i = 0; i < journalUpdates.Size(); i += 1 )
  782. {
  783. if( journalUpdates[i].status == status )
  784. {
  785. if( journalUpdates[i].journalEntry.guid == journalQuest.guid )
  786. {
  787. return true;
  788. }
  789. }
  790. }
  791. }
  792.  
  793. return false;
  794. }
  795.  
  796. function HasJournalPendingUpdate( journalBase : CJournalBase ) : bool
  797. {
  798. var i : int;
  799.  
  800. for( i = 0; i < journalUpdates.Size(); i += 1 )
  801. {
  802. if( journalUpdates[i].journalEntry.guid == journalBase.guid )
  803. {
  804. return true;
  805. }
  806. }
  807. return false;
  808. }
  809.  
  810. function HasJournalPendingItemInfo() : bool
  811. {
  812. var i : int;
  813.  
  814. for( i = 0; i < journalUpdates.Size(); i += 1 )
  815. {
  816. if( journalUpdates[i].isItemUpdate )
  817. {
  818. return true;
  819. }
  820. }
  821. return false;
  822. }
  823.  
  824. function ForceAddJournalUpdateInfo(locKeyText : string, locKeyTitle : string ) : void
  825. {
  826. var newJournalUpdate : SJournalUpdate;
  827. var status : EJournalStatus;
  828.  
  829.  
  830.  
  831. if( locKeyText == "" || locKeyText == " ")
  832. {
  833. newJournalUpdate.text = GetTrackedQuestName();
  834. }
  835. else
  836. {
  837. newJournalUpdate.text = GetLocStringByKeyExt( locKeyText );
  838. }
  839. newJournalUpdate.status = JS_Active;
  840. if( locKeyTitle == "" || locKeyTitle == " ")
  841. {
  842. newJournalUpdate.title = GetQuestStatusTitle(newJournalUpdate.status,0);
  843. }
  844. else
  845. {
  846. newJournalUpdate.title = GetLocStringByKeyExt( locKeyTitle );
  847. }
  848. journalUpdates.PushBack(newJournalUpdate);
  849. }
  850.  
  851. function GetTrackedQuestName() : string
  852. {
  853. var trackedQuests : CJournalQuest;
  854. trackedQuests = manager.GetTrackedQuest();
  855. return GetLocStringById(trackedQuests.GetTitleStringId());
  856. }
  857.  
  858. event OnRemoveUpdate()
  859. {
  860. if( journalUpdates.Size() > 0 )
  861. {
  862. journalUpdates.Erase(0);
  863. }
  864. bWasRemoved = true;
  865. }
  866.  
  867. event OnShowUpdateEnd()
  868. {
  869. theInput.UnregisterListener( this, 'OnShowEntryInPanel' );
  870. thePlayer.UnblockAction( EIAB_OpenFastMenu, 'JournalUpdate' );
  871.  
  872. if(journalUpdates.Size() > 0 && (CJournalQuest)journalUpdates[0].journalEntry )
  873. {
  874. theInput.UnregisterListener( this, 'OnTrackQuest' );
  875.  
  876. }
  877.  
  878. m_bookItemId = GetInvalidUniqueId();
  879.  
  880. _bDuringDisplay = false;
  881. LogChannel('JOURNALUPDATE',"OnShowUpdateEnd "+journalUpdates.Size());
  882. }
  883.  
  884. event OnShowEntryInPanel( action : SInputAction )
  885. {
  886. if( IsReleased(action) && !thePlayer.IsCiri() )
  887. {
  888. LogChannel('JOURNALUPDATE',"OnShowEntryInPanel "+journalUpdates[0].journalEntry.baseName);
  889. OpenEntryInPanel();
  890. }
  891. }
  892.  
  893. event OnTrackQuest( action : SInputAction )
  894. {
  895. var l_quest : CJournalBase;
  896. var l_questStatus : EJournalStatus;
  897. var walkToggleAction : SInputAction;
  898.  
  899. l_quest = journalUpdates[0].journalEntry;
  900. walkToggleAction = theInput.GetAction('WalkToggle');
  901.  
  902. if ( IsReleased(action) && walkToggleAction.lastFrameValue < 0.7 && walkToggleAction.value < 0.7 && !thePlayer.IsCiri() )
  903. {
  904. if ( thePlayer.inv.IsIdValid(m_bookItemId) )
  905. {
  906. if ( !theGame.IsBlackscreen() && !theGame.IsFading() )
  907. {
  908. ShowItemInfoPopup(m_bookItemId);
  909. m_bookItemId = GetInvalidUniqueId();
  910. }
  911. }
  912. else
  913. if (l_quest)
  914. {
  915. l_questStatus = manager.GetEntryStatus( l_quest );
  916.  
  917. if( l_questStatus == JS_Active )
  918. {
  919. manager.SetTrackedQuest( l_quest );
  920. }
  921. }
  922. }
  923. }
  924.  
  925. function OpenEntryInPanel()
  926. {
  927. if( (CJournalQuest)journalUpdates[0].journalEntry )
  928. {
  929. OpenQuestPanel();
  930. }
  931. else if( (CJournalCreature)journalUpdates[0].journalEntry )
  932. {
  933. OpenGlossaryPanel('GlossaryBestiaryMenu');
  934. }
  935. else if( (CJournalCharacter)journalUpdates[0].journalEntry )
  936. {
  937. OpenGlossaryPanel('GlossaryEncyclopediaMenu');
  938. }
  939. else if( (CJournalGlossary)journalUpdates[0].journalEntry )
  940. {
  941. OpenGlossaryPanel('GlossaryEncyclopediaMenu');
  942. }
  943. else if( journalUpdates[0].entryTag )
  944. {
  945. OpenSchematicPanel();
  946. }
  947. }
  948.  
  949. function OpenGlossaryPanel( panelName : name )
  950. {
  951. var uiSavedData : SUISavedData;
  952. var journalEntry : CJournalBase;
  953.  
  954. if( thePlayer.IsActionAllowed(EIAB_OpenGlossary) )
  955. {
  956. journalEntry = journalUpdates[0].journalEntry;
  957. uiSavedData = m_guiManager.GetUISavedData(panelName);
  958. uiSavedData.selectedTag = journalEntry.GetUniqueScriptTag();
  959. uiSavedData.panelName = panelName;
  960. m_guiManager.UpdateUISavedData( panelName , uiSavedData.openedCategories, uiSavedData.selectedTag, uiSavedData.selectedModule );
  961.  
  962. uiSavedData = m_guiManager.GetUISavedData('GlossaryParent');
  963. uiSavedData.selectedTag = panelName;
  964. uiSavedData.panelName = 'GlossaryParent';
  965. m_guiManager.UpdateUISavedData( 'GlossaryParent' , uiSavedData.openedCategories, uiSavedData.selectedTag, uiSavedData.selectedModule );
  966. theGame.RequestMenuWithBackground( panelName, 'CommonMenu' );
  967. }
  968. }
  969.  
  970. function OpenSchematicPanel()
  971. {
  972. var uiSavedData : SUISavedData;
  973.  
  974. if( thePlayer.IsActionAllowed(EIAB_OpenGlossary) )
  975. {
  976. uiSavedData = m_guiManager.GetUISavedData(journalUpdates[0].panelName);
  977. uiSavedData.selectedTag = journalUpdates[0].entryTag;
  978. uiSavedData.panelName = journalUpdates[0].panelName;
  979. m_guiManager.UpdateUISavedData( journalUpdates[0].panelName , uiSavedData.openedCategories, uiSavedData.selectedTag, uiSavedData.selectedModule );
  980.  
  981. uiSavedData = m_guiManager.GetUISavedData('GlossaryParent');
  982. uiSavedData.selectedTag = journalUpdates[0].panelName;
  983. uiSavedData.panelName = 'GlossaryParent';
  984. m_guiManager.UpdateUISavedData( 'GlossaryParent' , uiSavedData.openedCategories, uiSavedData.selectedTag, uiSavedData.selectedModule );
  985. theGame.RequestMenuWithBackground( journalUpdates[0].panelName, 'CommonMenu' );
  986. }
  987. }
  988.  
  989. function OpenQuestPanel()
  990. {
  991. var uiSavedData : SUISavedData;
  992. var questEntry : CJournalQuest;
  993. var panelName : name;
  994.  
  995. if( thePlayer.IsActionAllowed(EIAB_OpenJournal) )
  996. {
  997. questEntry = (CJournalQuest)journalUpdates[0].journalEntry;
  998.  
  999. panelName = 'JournalQuestMenu';
  1000.  
  1001.  
  1002. uiSavedData = m_guiManager.GetUISavedData(panelName);
  1003. uiSavedData.selectedTag = questEntry.GetUniqueScriptTag();
  1004. uiSavedData.panelName = panelName;
  1005. m_guiManager.UpdateUISavedData( panelName , uiSavedData.openedCategories, questEntry.GetUniqueScriptTag(), uiSavedData.selectedModule );
  1006.  
  1007. uiSavedData = m_guiManager.GetUISavedData('JournalParent');
  1008. uiSavedData.selectedTag = panelName;
  1009. uiSavedData.panelName = 'JournalParent';
  1010. m_guiManager.UpdateUISavedData( 'JournalParent' , uiSavedData.openedCategories, uiSavedData.selectedTag, uiSavedData.selectedModule );
  1011. theGame.RequestMenuWithBackground( panelName, 'CommonMenu' );
  1012. }
  1013. }
  1014.  
  1015. protected function GatherBindersArray(out resultArray : CScriptedFlashArray, bindersList : array<SKeyBinding>, optional isContextBinding:bool)
  1016. {
  1017. var tempFlashObject : CScriptedFlashObject;
  1018. var bindingGFxData : CScriptedFlashObject;
  1019. var curBinding : SKeyBinding;
  1020. var bindingsCount : int;
  1021. var i : int;
  1022.  
  1023. bindingsCount = bindersList.Size();
  1024. for( i =0; i < bindingsCount; i += 1 )
  1025. {
  1026. curBinding = bindersList[i];
  1027. tempFlashObject = m_flashValueStorage.CreateTempFlashObject();
  1028. bindingGFxData = tempFlashObject.CreateFlashObject("red.game.witcher3.data.KeyBindingData");
  1029. bindingGFxData.SetMemberFlashString("gamepad_navEquivalent", curBinding.Gamepad_NavCode );
  1030. bindingGFxData.SetMemberFlashInt("keyboard_keyCode", curBinding.Keyboard_KeyCode );
  1031. bindingGFxData.SetMemberFlashString("label", GetLocStringByKeyExt(curBinding.LocalizationKey) );
  1032. bindingGFxData.SetMemberFlashString("isContextBinding", isContextBinding);
  1033. resultArray.PushBackFlashObject(bindingGFxData);
  1034. }
  1035. }
  1036.  
  1037. protected function UpdateInputFeedback():void
  1038. {
  1039. var gfxDataList : CScriptedFlashArray;
  1040. gfxDataList = m_flashValueStorage.CreateTempFlashArray();
  1041. GatherBindersArray(gfxDataList, m_defaultInputBindings );
  1042. m_flashValueStorage.SetFlashArray("hud.journalupdate.buttons.setup", gfxDataList);
  1043. }
  1044.  
  1045. function SetButtons( isJournalEntry : bool )
  1046. {
  1047. var outKeys : array< EInputKey >;
  1048. var outKeysPC : array< EInputKey >;
  1049.  
  1050.  
  1051. }
  1052.  
  1053. protected function AddInputBinding(label:string, padNavCode:string, optional keyboardKeyCode:int)
  1054. {
  1055. var bindingDef:SKeyBinding;
  1056. bindingDef.Gamepad_NavCode = padNavCode;
  1057. bindingDef.Keyboard_KeyCode = keyboardKeyCode;
  1058. bindingDef.LocalizationKey = label;
  1059. m_defaultInputBindings .PushBack(bindingDef);
  1060. }
  1061.  
  1062.  
  1063.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement