Hird194

Found unexpected '}'

Oct 23rd, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.88 KB | None | 0 0
  1. /*
  2. Copyright © CD Projekt RED 2015
  3. */
  4.  
  5.  
  6.  
  7.  
  8.  
  9. class CR4MeditationClockMenu extends CR4MenuBase
  10. {
  11. private var m_fxSetBlockMeditation : CScriptedFlashFunction;
  12. private var m_fxSetCanMeditate : CScriptedFlashFunction;
  13. private var m_fxSetGeraltBackgroundVisible : CScriptedFlashFunction;
  14. private var canMeditateWait : bool;
  15. private var m_fxSet24HRFormat : CScriptedFlashFunction;
  16. //modFriendlyMeditation begin
  17. //private var isGameTimePaused : bool;
  18. //
  19. //private var BONUS_MEDITATION_TIME : int;
  20. //default BONUS_MEDITATION_TIME = 1;
  21.  
  22. private var BONUS_MEDITATION_TIME : int;
  23. default BONUS_MEDITATION_TIME = 1;
  24. private var isPlayerMeditatingInBed : bool;
  25. default isPlayerMeditatingInBed = false;
  26. private var meditationPressed : bool;
  27. default meditationPressed = false;
  28. private var witcher : W3PlayerWitcher;
  29. //modFriendlyMeditation end
  30. event OnConfigUI()
  31. {
  32. //modFriendlyMeditation begin
  33. //var commonMenu : CR4CommonMenu;
  34. var locCode : string;
  35. var initData : W3SingleMenuInitData;
  36. var initData : W3SingleMenuInitData;
  37. var l_bed : W3WitcherBed;
  38.  
  39. witcher = GetWitcherPlayer();
  40.  
  41. super.OnConfigUI();
  42.  
  43. //witcher.MeditationClockStart(this);
  44. SendCurrentTimeToAS();
  45. if( witcher.GetMeditationStartedByClock() && witcher.IsSkippingTime() )
  46. {
  47. m_flashValueStorage.SetFlashInt( "meditation.clock.hours.update", GameTimeHours(theGame.GetGameTime()) );
  48. m_flashValueStorage.SetFlashInt( "meditation.clock.hours", CeilF(witcher.GetMeditationTargetTime()) );
  49. }
  50.  
  51. m_fxSetBlockMeditation = m_flashModule.GetMemberFlashFunction( "SetBlockMeditation" );
  52. m_fxSet24HRFormat = m_flashModule.GetMemberFlashFunction( "Set24HRFormat" );
  53. m_fxSetGeraltBackgroundVisible = m_flashModule.GetMemberFlashFunction( "setGeraltBackgroundVisible" );
  54. m_fxSetBonusMeditationTime.InvokeSelfOneArg( FlashArgInt( BONUS_MEDITATION_TIME ) );
  55. m_fxSetBonusMeditationTime.InvokeSelfOneArg( FlashArgInt( witcher.fmedWitcherHouseBuffsHours ) );
  56.  
  57. if(GetWitcherPlayer().CanMeditate() && GetWitcherPlayer().CanMeditateWait(true))
  58. if( initData && initData.isBonusMeditationAvailable )
  59. if( FactsQuerySum( "PlayerInsideInnerWitcherHouse" ) > 0 )
  60. {
  61. l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  62. if( l_bed.GetWasUsed() )
  63.  
  64.  
  65. isPlayerMeditatingInBed = true;
  66. SetMeditationBonuses();
  67. }
  68. SetMeditationBonuses();
  69. }
  70. }
  71. // PN
  72. if (PNGetHunger() >= 50)
  73. canMeditateWait = false;
  74. // PN
  75.  
  76.  
  77. //initData = (W3SingleMenuInitData)GetMenuInitData();
  78.  
  79. if(GameplayFactsQuerySum("GamePausedNotByUI") > 0 && !thePlayer.IsInCombat())
  80. {
  81. canMeditateWait = false;
  82. witcher.MeditationRestoring(0);
  83. }
  84. else
  85. {
  86. theGame.Unpause("menus");
  87. canMeditateWait = witcher.ModCanMeditate(isPlayerMeditatingInBed);
  88. theGame.Pause("menus");
  89. }
  90.  
  91. m_fxSetGeraltBackgroundVisible.InvokeSelfOneArg(FlashArgBool(false));
  92. //if (canMeditateWait)
  93. //{
  94. // m_fxSetGeraltBackgroundVisible.InvokeSelfOneArg( FlashArgBool(true) );
  95. //}
  96.  
  97. m_fxSetBlockMeditation.InvokeSelfOneArg(FlashArgBool(!canMeditateWait));
  98.  
  99. locCode = GetCurrentTextLocCode();
  100. m_fxSet24HRFormat.InvokeSelfOneArg(FlashArgBool(locCode != "EN"));
  101.  
  102. RegisterActions();
  103. //modFriendlyMeditation end
  104. if (!canMeditateWait)
  105. {
  106.  
  107. }
  108.  
  109. event OnClosingMenu()
  110. {
  111. //modFriendlyMeditation begin
  112. //var commonMenu : CR4CommonMenu;
  113.  
  114. theGame.GetGuiManager().SendCustomUIEvent( 'ClosedMeditationClockMenu' );
  115.  
  116. //commonMenu = (CR4CommonMenu)m_parentMenu;
  117. //if (commonMenu)
  118. //{
  119. // commonMenu.SetMeditationMode(false);
  120.  
  121. if( commonMenu.GetIsPlayerMeditatingInBed() )
  122. {
  123. GetWitcherPlayer().ManageSleeping();
  124. }
  125. //
  126. // if( commonMenu.GetIsPlayerMeditatingInBed() )
  127. // {
  128. // GetWitcherPlayer().ManageSleeping();
  129. // }
  130. //}
  131.  
  132. GetWitcherPlayer().MeditationClockStop();
  133. //
  134. //GetWitcherPlayer().MeditationClockStop();
  135. UnregisterActions();
  136. //modFriendlyMeditation end
  137. }
  138.  
  139. event OnCloseMenu()
  140. {
  141. //modFriendlyMeditation begin
  142. //if(thePlayer.GetCurrentStateName() == 'MeditationWaiting')
  143. //{
  144. // MeditatingEnd();
  145. //}
  146. //
  147. //if (!theGame.IsPaused())
  148. //{
  149. // theGame.Pause("menus");
  150. //}
  151.  
  152. if( !meditationPressed && isPlayerMeditatingInBed )
  153. {
  154. if( !witcher.IsMeditating() && !witcher.IsSkippingTime() )
  155. witcher.ManageSleeping();
  156. }
  157.  
  158. GetWitcherPlayer().MeditationClockStop();
  159. UnregisterActions();
  160. //modFriendlyMeditation end
  161.  
  162. CloseMenu();
  163. if( m_parentMenu )
  164. {
  165. m_parentMenu.ChildRequestCloseMenu();
  166. }
  167. }
  168.  
  169. function SetButtons()
  170. {
  171. AddInputBinding("panel_button_common_exit", "escape-gamepad_B", -1);
  172. //modFriendlyMeditation begin
  173. if( witcher.IsMeditating() || witcher.IsSkippingTime() )
  174. AddInputBinding("panel_button_meditation_stop", "gamepad_Y", IK_C);
  175. //modFriendlyMeditation end
  176. super.SetButtons();
  177. }
  178.  
  179. //modFriendlyMeditation begin
  180. function RegisterActions()
  181. {
  182. theInput.StoreContext( 'MEDITATION_CLOCK_CONTEXT' );
  183. theInput.RegisterListener( this, 'OnMeditationStop', 'MeditationStop' );
  184. }
  185.  
  186. function UnregisterActions()
  187. {
  188. theInput.UnregisterListener( this, 'OnMeditationStop' );
  189. theInput.RestoreContext( 'MEDITATION_CLOCK_CONTEXT', false );
  190. }
  191.  
  192. event OnMeditationStop( action : SInputAction )
  193. {
  194. if( IsPressed(action) )
  195. {
  196. witcher.ModEndMeditation();
  197. }
  198. }
  199. //modFriendlyMeditation end
  200.  
  201. public function UpdateCurrentHours( ):void
  202. {
  203. var timeHours : int = GetCurrentDayTime( "hours" );
  204. var timeMinutes : int = GetCurrentDayTime( "minutes" );
  205. m_flashValueStorage.SetFlashInt( "meditation.clock.hours.update", timeHours );
  206. m_flashValueStorage.SetFlashInt( "meditation.clock.minutes", timeMinutes );
  207. }
  208.  
  209. public function SendCurrentTimeToAS():void
  210. {
  211. var timeHours : int = GetCurrentDayTime( "hours" );
  212. var timeMinutes : int = GetCurrentDayTime( "minutes" );
  213.  
  214. m_flashValueStorage.SetFlashInt( "meditation.clock.hours", timeHours );
  215. m_flashValueStorage.SetFlashInt( "meditation.clock.minutes", timeMinutes );
  216. }
  217.  
  218. event OnMeditate( dayTime : float )
  219. {
  220. var medd : W3PlayerWitcherStateMeditation;
  221.  
  222. if (!canMeditateWait)
  223. {
  224. ShowDisallowedNotification();
  225. }
  226. else
  227. {
  228. if (theGame.IsPaused())
  229. {
  230. theGame.Unpause("menus");
  231. }
  232.  
  233. if( GetWitcherPlayer().Meditate() )
  234. GetWitcherPlayer().Meditate();
  235.  
  236. //modFriendlyMeditation begin
  237. meditationPressed = true;
  238. UnregisterActions();
  239. if( witcher.ModStartMeditation( isPlayerMeditatingInBed, true, CeilF(dayTime) ) )
  240. OnPlaySoundEvent( "gui_meditation_start" );
  241.  
  242. LogChannel('CLOCK'," ** OnMeditate ** ");
  243. if(dayTime == GameTimeHours(theGame.GetGameTime()))
  244. return false;
  245.  
  246. medd = (W3PlayerWitcherStateMeditation)thePlayer.GetCurrentState();
  247. medd.MeditationWait(CeilF(dayTime));
  248.  
  249. // PN
  250. PNSetMeditationFlag();
  251. // PN
  252. StartWaiting();
  253. LogChannel('CLOCK'," ** OnMeditate ** ");
  254. if(dayTime == GameTimeHours(theGame.GetGameTime()))
  255. return false;
  256.  
  257. medd = (W3PlayerWitcherStateMeditation)thePlayer.GetCurrentState();
  258. medd.MeditationWait(CeilF(dayTime));
  259.  
  260.  
  261. StartWaiting();
  262. //LogChannel('CLOCK'," ** OnMeditate ** ");
  263. //if(dayTime == GameTimeHours(theGame.GetGameTime()))
  264. // return false;
  265. //
  266. //medd = (W3PlayerWitcherStateMeditation)thePlayer.GetCurrentState();
  267. //medd.MeditationWait(CeilF(dayTime));
  268. //
  269. //
  270. //StartWaiting();
  271. }
  272. //modFriendlyMeditation end
  273. }
  274.  
  275. event OnMeditateBlocked()
  276. {
  277. ShowDisallowedNotification();
  278. }
  279.  
  280. event OnStopMeditate()
  281. {
  282. //modFriendlyMeditation begin
  283. //var waitt : W3PlayerWitcherStateMeditationWaiting;
  284. //
  285. //if(thePlayer.GetCurrentStateName() == 'MeditationWaiting')
  286. //{
  287. // waitt = (W3PlayerWitcherStateMeditationWaiting)thePlayer.GetCurrentState();
  288. // if(waitt)
  289. // waitt.RequestWaitStop();
  290. //}
  291. //
  292. //MeditatingEnd();
  293. witcher.ModEndMeditation();
  294. //modFriendlyMeditation end
  295. }
  296.  
  297. function GetCurrentDayTime( type : string ) : int
  298. {
  299. var gameTime : GameTime = theGame.GetGameTime();
  300. var currentDays : int;
  301. var currentHours : int;
  302. var currentMinutes : int;
  303. var currentTime : int;
  304.  
  305. switch( type )
  306. {
  307. case "days" :
  308. {
  309. currentTime = GameTimeDays( gameTime );
  310. break;
  311. }
  312. case "hours" :
  313. {
  314. currentDays = GameTimeDays( gameTime );
  315. currentHours = GameTimeHours( gameTime );
  316. currentTime = currentHours ;
  317. break;
  318. }
  319. case "minutes" :
  320. {
  321. currentDays = GameTimeDays( gameTime );
  322. currentHours = GameTimeHours( gameTime );
  323. currentMinutes = GameTimeMinutes( gameTime );
  324. currentTime = currentMinutes;
  325. break;
  326. }
  327. }
  328. return currentTime;
  329. }
  330.  
  331.  
  332.  
  333.  
  334. //modFriendlyMeditation begin
  335. //public function StartWaiting():void
  336. //{
  337. // theGame.GetCityLightManager().SetUpdateEnabled( false );
  338. // m_flashValueStorage.SetFlashBool( "meditation.clock.blocked", true );
  339. // SetMenuNavigationEnabled(false);
  340. //}
  341. //
  342. //public function StopWaiting():void
  343. //{
  344. // m_flashValueStorage.SetFlashBool( "meditation.clock.blocked", false );
  345. // SetMenuNavigationEnabled(true);
  346. //}
  347. //
  348. //function MeditatingEnd()
  349. //{
  350. // theGame.GetCityLightManager().ForceUpdate();
  351. // theGame.GetCityLightManager().SetUpdateEnabled( true );
  352. // m_flashValueStorage.SetFlashBool( "meditation.clock.blocked", false );
  353. // SetMenuNavigationEnabled(true);
  354. //}
  355. //modFriendlyMeditation end
  356.  
  357. function PlayOpenSoundEvent()
  358. {
  359.  
  360.  
  361. }
  362.  
  363. private final function ShowDisallowedNotification()
  364. {
  365. if(thePlayer.IsInCombat())
  366. {
  367. showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_combat"));
  368. }
  369. else
  370. {
  371. showNotification(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
  372. }
  373.  
  374. OnPlaySoundEvent("gui_global_denied");
  375. }
  376. }
Add Comment
Please, Sign In to add comment