Advertisement
Guest User

Untitled

a guest
Jul 8th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 62.20 KB | None | 0 0
  1. /***********************************************************************/
  2. /**     © 2016 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.  
  7. enum InGameMenuActionType
  8. {
  9.     IGMActionType_CommonMenu        = 0,
  10.     IGMActionType_Close             = 1,
  11.     IGMActionType_MenuHolder        = 2,
  12.     IGMActionType_MenuLastHolder    = 3,
  13.     IGMActionType_Load              = 4,
  14.     IGMActionType_Save              = 5,
  15.     IGMActionType_Quit              = 6,
  16.     IGMActionType_Preset            = 7,
  17.     IGMActionType_Toggle            = 8,
  18.     IGMActionType_List              = 9,
  19.     IGMActionType_Slider            = 10,
  20.     IGMActionType_LoadLastSave      = 11,
  21.     IGMActionType_Tutorials         = 12,
  22.     IGMActionType_Credits           = 13,
  23.     IGMActionType_Help              = 14,
  24.     IGMActionType_Controls          = 15,
  25.     IGMActionType_ControllerHelp    = 16,
  26.     IGMActionType_NewGame           = 17,
  27.     IGMActionType_CloseGame         = 18,
  28.     IGMActionType_UIRescale         = 19,
  29.     IGMActionType_Gamma             = 20,
  30.     IGMActionType_DebugStartQuest   = 21,
  31.     IGMActionType_Gwint             = 22,
  32.     IGMActionType_ImportSave        = 23,
  33.     IGMActionType_KeyBinds          = 24,
  34.     IGMActionType_Back              = 25,
  35.     IGMActionType_NewGamePlus       = 26,
  36.     IGMActionType_InstalledDLC      = 27,
  37.    
  38.     IGMActionType_Options           = 100
  39. };
  40.  
  41. enum EIngameMenuConstants
  42. {
  43.     IGMC_Difficulty_mask    =   7,   // (0111) bit mask as highest difficulty value is 4
  44.     IGMC_Tutorials_On       =   1024,
  45.     IGMC_Simulate_Import    =   2048,
  46.     IGMC_Import_Save        =   4096,
  47.     IGMC_EP1_Save           =   8192,
  48.     IGMC_New_game_plus      =   16384,
  49.     IGMC_EP2_Save           =   32768,
  50. }
  51.  
  52. struct newGameConfig
  53. {
  54.     var tutorialsOn : bool;
  55.     var difficulty : int;
  56.     var simulate_import : bool;
  57.     var import_save_index : int;
  58. }
  59.  
  60. class CR4IngameMenu extends CR4MenuBase
  61. {
  62.     protected var mInGameConfigWrapper  : CInGameConfigWrapper;
  63.     protected var inGameConfigBufferedWrapper : CInGameConfigBufferedWrapper;
  64.    
  65.     protected var currentNewGameConfig  : newGameConfig;
  66.    
  67.     private var m_fxNavigateBack        : CScriptedFlashFunction;
  68.     private var m_fxSetIsMainMenu       : CScriptedFlashFunction;
  69.     private var m_fxSetCurrentUsername  : CScriptedFlashFunction;
  70.     private var m_fxSetVersion          : CScriptedFlashFunction;
  71.     private var m_fxShowHelp            : CScriptedFlashFunction;
  72.     private var m_fxSetVisible          : CScriptedFlashFunction;
  73.     private var m_fxSetPanelMode        : CScriptedFlashFunction;
  74.     private var m_fxRemoveOption        : CScriptedFlashFunction;
  75.     private var m_fxSetGameLogoLanguage : CScriptedFlashFunction;
  76.     private var m_fxUpdateOptionValue   : CScriptedFlashFunction;
  77.     private var m_fxUpdateInputFeedback : CScriptedFlashFunction;
  78.     private var m_fxOnSaveScreenshotRdy : CScriptedFlashFunction;
  79.     private var m_fxSetIgnoreInput      : CScriptedFlashFunction;
  80.     private var m_fxForceEnterCurEntry  : CScriptedFlashFunction;
  81.     private var m_fxForceBackgroundVis  : CScriptedFlashFunction;
  82.     private var m_fxSetHardwareCursorOn : CScriptedFlashFunction;
  83.     private var m_fxSetExpansionText    : CScriptedFlashFunction;
  84.    
  85.     protected var loadConfPopup         : W3ApplyLoadConfirmation;
  86.     protected var saveConfPopup         : W3SaveGameConfirmation;
  87.     protected var newGameConfPopup      : W3NewGameConfirmation;
  88.     protected var actionConfPopup       : W3ActionConfirmation;
  89.     protected var deleteConfPopup       : W3DeleteSaveConf;
  90.     protected var diffChangeConfPopup   : W3DifficultyChangeConfirmation;
  91.     protected var isShowingSaveList     : bool; default isShowingSaveList = false;
  92.     protected var isShowingLoadList     : bool; default isShowingLoadList = false;
  93.    
  94.     protected var smartKeybindingEnabled : bool; default smartKeybindingEnabled = true;
  95.    
  96.     public var m_structureCreator       : IngameMenuStructureCreator;
  97.    
  98.     protected var isInLoadselector      : bool; default isInLoadselector = false;
  99.     protected var swapAcceptCancelChanged : bool; default swapAcceptCancelChanged = false;
  100.     protected var alternativeRadialInputChanged : bool; default alternativeRadialInputChanged = false;
  101.     protected var EnableUberMovement : bool; default EnableUberMovement = false;
  102.    
  103.     protected var shouldRefreshKinect   : bool; default shouldRefreshKinect = false;
  104.     public var isMainMenu               : bool;
  105.    
  106.     protected var managingPause     : bool; default managingPause = false;
  107.    
  108.     protected var updateInputDeviceRequired : bool; default updateInputDeviceRequired = false;
  109.    
  110.     protected var hasChangedOption      : bool;
  111.     default hasChangedOption = false;
  112.    
  113.     private var ignoreInput             : bool;
  114.     default ignoreInput = false;
  115.    
  116.     public var disableAccountPicker : bool;
  117.     default disableAccountPicker = false;
  118.    
  119.     protected var lastSetTag : int;
  120.    
  121.     protected var currentLangValue      : string;
  122.     protected var lastUsedLangValue     : string;
  123.     protected var currentSpeechLang     : string;
  124.     protected var lastUsedSpeechLang    : string;
  125.     private var languageName            : string;
  126.    
  127.     private var panelMode               : bool; default panelMode = false;
  128.    
  129.     public var lastSetDifficulty        : int;
  130.    
  131.     event /*flash*/ OnConfigUI()
  132.     {
  133.         var initDataObject      : W3MenuInitData;
  134.         var commonIngameMenu    : CR4CommonIngameMenu;
  135.         var commonMainMenuBase  : CR4CommonMainMenuBase;
  136.         var deathScreenMenu     : CR4DeathScreenMenu;
  137.         var audioLanguageName   : string;
  138.         var tempLanguageName    : string;
  139.         var username            : string;
  140.         var lootPopup           : CR4LootPopup;
  141.         var ep1StatusText       : string;
  142.         var ep2StatusText       : string;
  143.        
  144.         super.OnConfigUI();
  145.        
  146.         m_fxNavigateBack = m_flashModule.GetMemberFlashFunction("handleNavigateBack");
  147.         m_fxSetIsMainMenu = m_flashModule.GetMemberFlashFunction("setIsMainMenu");
  148.         m_fxSetCurrentUsername = m_flashModule.GetMemberFlashFunction("setCurrentUsername");
  149.         m_fxSetVersion = m_flashModule.GetMemberFlashFunction("setVersion");
  150.         m_fxShowHelp = m_flashModule.GetMemberFlashFunction("showHelpPanel");      
  151.         m_fxSetVisible = m_flashModule.GetMemberFlashFunction("setVisible");
  152.         m_fxSetPanelMode = m_flashModule.GetMemberFlashFunction("setPanelMode");
  153.         m_fxRemoveOption = m_flashModule.GetMemberFlashFunction("removeOption"); // WARNING - Current implementation only works top level
  154.         m_fxSetGameLogoLanguage = m_flashModule.GetMemberFlashFunction( "setGameLogoLanguage" );
  155.         m_fxUpdateOptionValue = m_flashModule.GetMemberFlashFunction( "updateOptionValue" );
  156.         m_fxUpdateInputFeedback = m_flashModule.GetMemberFlashFunction( "updateInputFeedback" );
  157.         m_fxOnSaveScreenshotRdy = m_flashModule.GetMemberFlashFunction( "onSaveScreenshotLoaded" );
  158.         m_fxSetIgnoreInput = m_flashModule.GetMemberFlashFunction( "setIgnoreInput" );
  159.         m_fxForceEnterCurEntry = m_flashModule.GetMemberFlashFunction( "forceEnterCurrentEntry" );
  160.         m_fxForceBackgroundVis = m_flashModule.GetMemberFlashFunction( "setForceBackgroundVisible" );
  161.         m_fxSetHardwareCursorOn = m_flashModule.GetMemberFlashFunction( "setHardwareCursorOn" );
  162.         m_fxSetExpansionText = m_flashModule.GetMemberFlashFunction( "setExpansionText" );
  163.        
  164.         m_structureCreator = new IngameMenuStructureCreator in this;
  165.         m_structureCreator.parentMenu = this;
  166.         m_structureCreator.m_flashValueStorage = m_flashValueStorage;
  167.         m_structureCreator.m_flashConstructor = m_flashValueStorage.CreateTempFlashObject();
  168.        
  169.         m_hideTutorial = false;
  170.         m_forceHideTutorial = false;
  171.         disableAccountPicker = false;
  172.        
  173.         theGame.LoadHudSettings();
  174.        
  175.         mInGameConfigWrapper = (CInGameConfigWrapper)theGame.GetInGameConfigWrapper();
  176.         inGameConfigBufferedWrapper = theGame.GetGuiManager().GetInGameConfigBufferedWrapper();
  177.        
  178.         lootPopup = (CR4LootPopup)theGame.GetGuiManager().GetPopup('LootPopup');
  179.            
  180.         if (lootPopup)
  181.         {
  182.             lootPopup.ClosePopup();
  183.         }
  184.        
  185.         commonIngameMenu = (CR4CommonIngameMenu)(GetParent());
  186.         commonMainMenuBase = (CR4CommonMainMenuBase)(GetParent());
  187.         deathScreenMenu = (CR4DeathScreenMenu)(GetParent());
  188.        
  189.         if (commonIngameMenu)
  190.         {
  191.             isMainMenu = false;
  192.             panelMode = false;
  193.             mInGameConfigWrapper.ActivateScriptTag('inGame');
  194.             mInGameConfigWrapper.DeactivateScriptTag('mainMenu');
  195.             //---=== modFriendlyHUD ===---
  196.             if ((!thePlayer.IsAlive() && !thePlayer.OnCheckUnconscious()) || theGame.HasBlackscreenRequested())// || theGame.IsDialogOrCutscenePlaying())
  197.             //---=== modFriendlyHUD ===---
  198.             {
  199.                 CloseMenu();
  200.                 return true;
  201.             }
  202.         }
  203.         else if (commonMainMenuBase)
  204.         {
  205.             isMainMenu = true;
  206.             panelMode = false;
  207.             mInGameConfigWrapper.ActivateScriptTag('mainMenu');
  208.             mInGameConfigWrapper.DeactivateScriptTag('inGame');
  209.            
  210.             StartShowingCustomDialogs();
  211.            
  212.             //---=== modFriendlyHUD ===---
  213.             if(!ShouldHideDLCIcons())
  214.             //---=== modFriendlyHUD ===---
  215.             {
  216.                 if (theGame.GetDLCManager().IsEP1Available())
  217.                 {
  218.                     ep1StatusText = GetLocStringByKeyExt("expansion_status_installed");
  219.                 }
  220.             if (theGame.GetDLCManager().IsEP1Available())
  221.             {
  222.                 ep1StatusText = GetLocStringByKeyExt("expansion_status_installed");
  223.             }
  224.             else
  225.             {
  226.                 ep1StatusText = GetLocStringByKeyExt("expansion_status_available");
  227.             }
  228.                 else
  229.                 {
  230.                     ep1StatusText = GetLocStringByKeyExt("expansion_status_available");
  231.                 }
  232.                
  233.                 if (theGame.GetDLCManager().IsEP2Available())
  234.                 {
  235.                     ep2StatusText = GetLocStringByKeyExt("expansion_status_installed");
  236.                 }
  237.                 else
  238.                 {
  239.             if (theGame.GetDLCManager().IsEP2Available())
  240.             {
  241.                 ep2StatusText = GetLocStringByKeyExt("expansion_status_installed");
  242.             }
  243.             else
  244.             {
  245.                 // make sure to change that also in other place!!!
  246.                     ep2StatusText = GetLocStringByKeyExt("expansion_status_available");
  247.                 }
  248.                 ep2StatusText = GetLocStringByKeyExt("menu_ep2_coming_date");
  249.             }
  250.            
  251.                 m_fxSetExpansionText.InvokeSelfTwoArgs(FlashArgString(ep1StatusText), FlashArgString(ep2StatusText));
  252.             }
  253.            
  254.             if (theGame.AreConfigResetInThisSession() && !theGame.HasShownConfigChangedMessage())
  255.             {
  256.                 showNotification(GetLocStringByKeyExt("update_warning_message"));
  257.                 OnPlaySoundEvent("gui_global_denied");
  258.                 theGame.SetHasShownConfigChangedMessage(true);
  259.             }
  260.         }
  261.         else if (deathScreenMenu)
  262.         {
  263.             isMainMenu = false;
  264.             panelMode = true;
  265.             mInGameConfigWrapper.DeactivateScriptTag('mainMenu');
  266.             mInGameConfigWrapper.DeactivateScriptTag('inGame');
  267.            
  268.             deathScreenMenu.HideInputFeedback();
  269.            
  270.             if (hasSaveDataToLoad())
  271.             {
  272.                 isInLoadselector = true;
  273.                 SendLoadData();
  274.                 m_fxSetPanelMode.InvokeSelfOneArg(FlashArgBool(true));
  275.             }
  276.             else
  277.             {
  278.                 CloseMenu();
  279.             }
  280.         }
  281.         else
  282.         {
  283.             initDataObject = (W3MenuInitData)GetMenuInitData();
  284.            
  285.             if (initDataObject && initDataObject.getDefaultState() == 'SaveGame')
  286.             {
  287.                 isMainMenu = false;
  288.                 panelMode = true;
  289.                
  290.                 managingPause = true;
  291.                 theInput.StoreContext( 'EMPTY_CONTEXT' );
  292.                 theGame.Pause('IngameMenu');
  293.                
  294.                 mInGameConfigWrapper.DeactivateScriptTag('mainMenu');
  295.                 mInGameConfigWrapper.DeactivateScriptTag('inGame');
  296.                
  297.                 SendSaveData();
  298.                 m_fxSetPanelMode.InvokeSelfOneArg(FlashArgBool(true));
  299.             }
  300.         }
  301.        
  302.         IngameMenu_UpdateDLCScriptTags();
  303.        
  304.         if (!panelMode)
  305.         {
  306.             m_fxSetIsMainMenu.InvokeSelfOneArg(FlashArgBool(isMainMenu)); //#J Needs to be called before setPlatform
  307.             if (isMainMenu)
  308.             {
  309.                 username = FixStringForFont(theGame.GetActiveUserDisplayName());
  310.                 m_fxSetCurrentUsername.InvokeSelfOneArg(FlashArgString(username));
  311.                 //theGame.GetGuiManager().ShowKinectMessage(); // Kinect unplugged for TTP#98732. Keeping code on offchance we bring it back
  312.                 m_fxSetVersion.InvokeSelfOneArg(FlashArgString(theGame.GetApplicationVersion()));
  313.             }
  314.             theGame.GetSecondScreenManager().SendGameMenuOpen();
  315.            
  316.             lastSetDifficulty = theGame.GetDifficultyLevel();
  317.            
  318.             currentLangValue = mInGameConfigWrapper.GetVarValue('Localization', 'Virtual_Localization_text');
  319.             lastUsedLangValue = currentLangValue;
  320.            
  321.             currentSpeechLang = mInGameConfigWrapper.GetVarValue('Localization', 'Virtual_Localization_speech');
  322.             lastUsedSpeechLang = currentSpeechLang;
  323.            
  324.             theGame.GetGameLanguageName(audioLanguageName,tempLanguageName);
  325.             if( tempLanguageName != languageName )
  326.             {
  327.                 languageName = tempLanguageName;
  328.                 m_fxSetGameLogoLanguage.InvokeSelfOneArg( FlashArgString(languageName) );
  329.             }
  330.            
  331.             PopulateMenuData();
  332.         }
  333.     }
  334.    
  335.     event OnRefresh()
  336.     {
  337.         var audioLanguageName   : string;
  338.         var tempLanguageName    : string;
  339.         var overlayPopupRef     : CR4OverlayPopup;
  340.         var username            : string;
  341.         var hud                 : CR4ScriptedHud;
  342.         var ep1StatusText       : string;
  343.         var ep2StatusText       : string;
  344.        
  345.         // Clear local variables (user might have changed, so we need to clear those variables)
  346.         currentLangValue = mInGameConfigWrapper.GetVarValue('Localization', 'Virtual_Localization_text');
  347.         lastUsedLangValue = currentLangValue;
  348.            
  349.         currentSpeechLang = mInGameConfigWrapper.GetVarValue('Localization', 'Virtual_Localization_speech');
  350.         lastUsedSpeechLang = currentSpeechLang;
  351.        
  352.         if (isMainMenu)
  353.         {
  354.             username = FixStringForFont(theGame.GetActiveUserDisplayName());
  355.             m_fxSetCurrentUsername.InvokeSelfOneArg(FlashArgString(username));
  356.            
  357.             PopulateMenuData();
  358.            
  359.             // Kinect unplugged for TTP#98732. Keeping code on offchance we bring it back
  360.             //if (shouldRefreshKinect)
  361.             //{
  362.             //  shouldRefreshKinect = false;
  363.             //  theGame.GetGuiManager().ShowKinectMessage();
  364.             //}
  365.         }
  366.        
  367.         UpdateAcceptCancelSwaping();
  368.         SetPlatformType(theGame.GetPlatform());
  369.         hud = (CR4ScriptedHud)(theGame.GetHud());
  370.         if (hud)
  371.         {
  372.             hud.UpdateAcceptCancelSwaping();
  373.         }
  374.        
  375.         overlayPopupRef = (CR4OverlayPopup) theGame.GetGuiManager().GetPopup('OverlayPopup');
  376.         if (overlayPopupRef)
  377.         {
  378.             overlayPopupRef.UpdateAcceptCancelSwaping();
  379.         }
  380.        
  381.         theGame.GetGameLanguageName(audioLanguageName,tempLanguageName);
  382.         if( tempLanguageName != languageName )
  383.         {
  384.             languageName = tempLanguageName;
  385.             m_fxSetGameLogoLanguage.InvokeSelfOneArg( FlashArgString(languageName) );
  386.             m_fxUpdateInputFeedback.InvokeSelf();
  387.             if (overlayPopupRef)
  388.             {
  389.                 overlayPopupRef.UpdateButtons();
  390.             }
  391.         }
  392.        
  393.         // this needs to be called also when ep1 is installed in main menu
  394.         //---=== modFriendlyHUD ===---
  395.         if(!ShouldHideDLCIcons())
  396.         //---=== modFriendlyHUD ===---
  397.         {
  398.             if (theGame.GetDLCManager().IsEP1Available())
  399.             {
  400.                 ep1StatusText = GetLocStringByKeyExt("expansion_status_installed");
  401.             }
  402.             else
  403.             {
  404.                 ep1StatusText = GetLocStringByKeyExt("expansion_status_available");
  405.             }
  406.             if (theGame.GetDLCManager().IsEP1Available())
  407.             {
  408.                 ep1StatusText = GetLocStringByKeyExt("expansion_status_installed");
  409.             }
  410.             else
  411.             {
  412.                 ep1StatusText = GetLocStringByKeyExt("expansion_status_available");
  413.             }
  414.            
  415.             if (theGame.GetDLCManager().IsEP2Available())
  416.             {
  417.                 ep2StatusText = GetLocStringByKeyExt("expansion_status_installed");
  418.             }
  419.             else
  420.             {
  421.                 // make sure to change that also in other place!!!
  422.                 ep2StatusText = GetLocStringByKeyExt("expansion_status_available");
  423.                 ep2StatusText = GetLocStringByKeyExt("menu_ep2_coming_date");
  424.             }
  425.            
  426.             m_fxSetExpansionText.InvokeSelfTwoArgs(FlashArgString(ep1StatusText), FlashArgString(ep2StatusText));
  427.         }
  428.         setArabicAligmentMode();
  429.     }
  430.    
  431.     function OnRequestSubMenu( menuName: name, optional initData : IScriptable )
  432.     {
  433.         RequestSubMenu(menuName, initData);
  434.         m_fxSetVisible.InvokeSelfOneArg(FlashArgBool(false));
  435.     }
  436.    
  437.     function ChildRequestCloseMenu()
  438.     {
  439.         m_fxSetVisible.InvokeSelfOneArg(FlashArgBool(true));
  440.     }
  441.    
  442.     event OnCloseMenu() // #B will be changed
  443.     {
  444.         CloseMenu();
  445.     }
  446.    
  447.     public function ReopenMenu()
  448.     {
  449.         var commonInGameMenu : CR4CommonIngameMenu;
  450.         var commonMainMenuBase : CR4CommonMainMenuBase;
  451.        
  452.         commonInGameMenu = (CR4CommonIngameMenu)m_parentMenu;
  453.         if(commonInGameMenu)
  454.         {
  455.             commonInGameMenu.reopenRequested = true;
  456.         }
  457.        
  458.         commonMainMenuBase = (CR4CommonMainMenuBase)m_parentMenu;
  459.         if ( commonMainMenuBase )
  460.         {
  461.             commonMainMenuBase.reopenRequested = true;
  462.         }
  463.        
  464.         CloseMenu();
  465.     }
  466.        
  467.     event /* C++ */ OnClosingMenu()
  468.     {
  469.         var commonInGameMenu : CR4CommonIngameMenu;
  470.         var commonMainMenuBase : CR4CommonMainMenuBase;
  471.         var deathScreenMenu : CR4DeathScreenMenu;
  472.         var controlsFeedbackModule : CR4HudModuleControlsFeedback;
  473.         var interactionModule : CR4HudModuleInteractions;
  474.         var hud : CR4ScriptedHud;
  475.        
  476.         SaveChangedSettings();
  477.        
  478.         theGame.GetSecondScreenManager().SendGameMenuClose();
  479.         super.OnClosingMenu();
  480.        
  481.         // #Y hud update
  482.         hud = (CR4ScriptedHud)(theGame.GetHud());
  483.         if (hud)
  484.         {
  485.             controlsFeedbackModule = (CR4HudModuleControlsFeedback)(hud.GetHudModule(NameToString('ControlsFeedbackModule')));
  486.             if (controlsFeedbackModule)
  487.             {
  488.                 controlsFeedbackModule.ForceModuleUpdate();
  489.             }
  490.            
  491.             interactionModule = (CR4HudModuleInteractions)(hud.GetHudModule(NameToString('InteractionsModule')));
  492.             if (interactionModule)
  493.             {
  494.                 interactionModule.ForceUpdateModule();
  495.             }
  496.         }
  497.        
  498.         if (managingPause)
  499.         {
  500.             managingPause = false;
  501.             theInput.RestoreContext( 'EMPTY_CONTEXT', true );
  502.             theGame.Unpause('IngameMenu');
  503.         }
  504.        
  505.         if (theGame.GetGuiManager().potalConfirmationPending)
  506.         {
  507.             theGame.GetGuiManager().ResumePortalConfirmationPendingMessage();
  508.         }
  509.        
  510.         if (m_structureCreator)
  511.         {
  512.             delete m_structureCreator;
  513.         }
  514.        
  515.         if (loadConfPopup)
  516.         {
  517.             delete loadConfPopup;
  518.         }
  519.        
  520.         if (saveConfPopup)
  521.         {
  522.             delete saveConfPopup;
  523.         }
  524.        
  525.         if (actionConfPopup)
  526.         {
  527.             delete actionConfPopup;
  528.         }
  529.        
  530.         if (newGameConfPopup)
  531.         {
  532.             delete newGameConfPopup;
  533.         }
  534.        
  535.         if (deleteConfPopup)
  536.         {
  537.             delete deleteConfPopup;
  538.         }
  539.        
  540.         if (diffChangeConfPopup)
  541.         {
  542.             delete diffChangeConfPopup;
  543.         }
  544.        
  545.         commonInGameMenu = (CR4CommonIngameMenu)m_parentMenu;
  546.         if(commonInGameMenu)
  547.         {
  548.             commonInGameMenu.ChildRequestCloseMenu();
  549.             return true;
  550.         }
  551.        
  552.         commonMainMenuBase = (CR4CommonMainMenuBase)m_parentMenu;
  553.         if ( commonMainMenuBase )
  554.         {
  555.             commonMainMenuBase.ChildRequestCloseMenu();
  556.             return true;
  557.         }
  558.        
  559.         deathScreenMenu = (CR4DeathScreenMenu)m_parentMenu;
  560.         if (deathScreenMenu)
  561.         {
  562.             deathScreenMenu.ChildRequestCloseMenu();
  563.             return true;
  564.         }
  565.     }
  566.    
  567.     // #Y TODO: array
  568.     protected function CloseCurrentPopup():void
  569.     {
  570.         if (loadConfPopup)
  571.         {
  572.             loadConfPopup.ClosePopupOverlay();
  573.         }
  574.         else if (saveConfPopup)
  575.         {
  576.             saveConfPopup.ClosePopupOverlay();
  577.         }      
  578.         else if (actionConfPopup)
  579.         {
  580.             actionConfPopup.ClosePopupOverlay();
  581.         }      
  582.         else if (newGameConfPopup)
  583.         {
  584.             newGameConfPopup.ClosePopupOverlay();
  585.         }      
  586.         else if (deleteConfPopup)
  587.         {
  588.             deleteConfPopup.ClosePopupOverlay();
  589.         }      
  590.         else if (diffChangeConfPopup)
  591.         {
  592.             diffChangeConfPopup.ClosePopupOverlay();
  593.         }
  594.     }
  595.    
  596.     public function SetIgnoreInput(value : bool) : void
  597.     {
  598.         if (value != ignoreInput)
  599.         {
  600.             ignoreInput = value;
  601.             m_fxSetIgnoreInput.InvokeSelfOneArg( FlashArgBool(value) );
  602.         }
  603.     }
  604.    
  605.     public function OnUserSignIn() : void
  606.     {
  607.         SetIgnoreInput(false);
  608.         CloseCurrentPopup();
  609.     }
  610.    
  611.     public function OnUserSignInCancelled() : void
  612.     {
  613.         SetIgnoreInput(false);
  614.         CloseCurrentPopup();
  615.     }
  616.    
  617.     public function OnSaveLoadingFailed() : void
  618.     {
  619.         SetIgnoreInput(false);
  620.         CloseCurrentPopup();
  621.     }
  622.    
  623.     event /*flash*/ OnItemActivated( actionType:int, menuTag:int ) : void
  624.     {
  625.         var l_DataFlashArray : CScriptedFlashArray;
  626.        
  627.         if (ignoreInput)
  628.         {
  629.             m_fxNavigateBack.InvokeSelf();
  630.         }
  631.         else
  632.         {
  633.             switch (actionType)
  634.             {
  635.             case IGMActionType_CommonMenu:
  636.                 theGame.RequestMenu( 'CommonMenu' );
  637.                 break;
  638.             case IGMActionType_MenuHolder:
  639.                 //commonIngameMenu = (CR4CommonIngameMenu)GetParent();
  640.                 //commonIngameMenu.OnRequestSubMenu( 'MainOptionsMenu', GetMenuInitData() );
  641.                 m_initialSelectionsToIgnore = 1;
  642.                 OnPlaySoundEvent( "gui_global_panel_open" );
  643.                 break;
  644.             case IGMActionType_MenuLastHolder:
  645.                 m_initialSelectionsToIgnore = 1;
  646.                 OnPlaySoundEvent( "gui_global_panel_open" );
  647.                 break;
  648.             case IGMActionType_Load:
  649.                 if (hasSaveDataToLoad())
  650.                 {
  651.                     SendLoadData();
  652.                 }
  653.                 else
  654.                 {
  655.                     // Cancel the navigation by going back
  656.                     m_fxNavigateBack.InvokeSelf();
  657.                 }
  658.                 isInLoadselector = true;
  659.                 break;
  660.             case IGMActionType_Save:
  661.                 if ( !theGame.AreSavesLocked() )
  662.                 {
  663.                     SendSaveData();
  664.                 }
  665.                 else
  666.                 {
  667.                     m_fxNavigateBack.InvokeSelf();
  668.                     theGame.GetGuiManager().DisplayLockedSavePopup();
  669.                 }
  670.                 isInLoadselector = false;
  671.                 break;
  672.             case IGMActionType_Quit:
  673.                 if (theGame.GetPlatform() == Platform_Xbox1)
  674.                 {
  675.                     ShowActionConfPopup(IGMActionType_Quit, "", GetLocStringByKeyExt("error_message_exit_game_x1"));
  676.                 }
  677.                 else if (theGame.GetPlatform() == Platform_PS4)
  678.                 {
  679.                     ShowActionConfPopup(IGMActionType_Quit, "", GetLocStringByKeyExt("error_message_exit_game_ps4"));
  680.                 }
  681.                 else
  682.                 {
  683.                     ShowActionConfPopup(IGMActionType_Quit, "", GetLocStringByKeyExt("error_message_exit_game"));
  684.                 }
  685.                 break;
  686.             case IGMActionType_Toggle:
  687.                 break;
  688.             case IGMActionType_List:
  689.                 break;
  690.             case IGMActionType_Slider:
  691.                 break;
  692.             case IGMActionType_LoadLastSave:
  693.                 LoadLastSave();
  694.                 break;
  695.             case IGMActionType_Close:
  696.                 //parentMenu.OnCloseMenu();
  697.                 break;
  698.             case IGMActionType_Tutorials:
  699.                 theGame.RequestMenuWithBackground( 'GlossaryTutorialsMenu', 'CommonMenu' );
  700.                 break;
  701.             case IGMActionType_Credits:
  702.                 theGame.GetGuiManager().RequestCreditsMenu(menuTag);
  703.                 break;
  704.             case IGMActionType_Help:
  705.                 showHelpPanel();
  706.                 break;
  707.             case IGMActionType_Options:
  708.                 if (theGame.GetPlatform() == Platform_PC)
  709.                 {
  710.                     m_fxSetHardwareCursorOn.InvokeSelfOneArg(FlashArgBool(mInGameConfigWrapper.GetVarValue('Rendering', 'HardwareCursor')));
  711.                 }
  712.                 l_DataFlashArray = IngameMenu_FillOptionsSubMenuData(m_flashValueStorage, isMainMenu);
  713.                
  714.                 m_initialSelectionsToIgnore = 1;
  715.                 OnPlaySoundEvent( "gui_global_panel_open" );
  716.                
  717.                 m_flashValueStorage.SetFlashArray( "ingamemenu.options.entries", l_DataFlashArray );
  718.                 break;
  719.             case IGMActionType_ControllerHelp:
  720.                 SendControllerData();
  721.                 break;
  722.             case IGMActionType_NewGame:
  723.                 TryStartNewGame(menuTag);
  724.                 break;
  725.             case IGMActionType_NewGamePlus:
  726.                 fetchNewGameConfigFromTag(menuTag);
  727.                 SendNewGamePlusSaves();
  728.                 break;
  729.             case IGMActionType_InstalledDLC:
  730.                 SendInstalledDLCList();
  731.                 break;
  732.             case IGMActionType_UIRescale:
  733.                 SendRescaleData();
  734.                 break;
  735.             case IGMActionType_DebugStartQuest:
  736.                 RequestSubMenu( 'MainDbgStartQuestMenu', GetMenuInitData() );
  737.                 break;
  738.             case IGMActionType_Gwint:
  739.                 GetRootMenu().CloseMenu();
  740.                 theGame.RequestMenu( 'DeckBuilder' );
  741.                 break;
  742.             case IGMActionType_ImportSave:
  743.                 lastSetTag = menuTag;
  744.                 fetchNewGameConfigFromTag( menuTag );
  745.                 SendImportSaveData( );
  746.                 break;
  747.             case IGMActionType_CloseGame:
  748.                 if (!isMainMenu)
  749.                 {
  750.                     ShowActionConfPopup(IGMActionType_CloseGame, "", GetLocStringByKeyExt("error_message_exit_game"));
  751.                 }
  752.                 else
  753.                 {
  754.                     theGame.RequestExit();
  755.                 }
  756.                 break;
  757.             case IGMActionType_KeyBinds:
  758.                 SendKeybindData();
  759.                 break;
  760.             }
  761.         }
  762.     }
  763.    
  764.     public function HandleLoadGameFailed():void
  765.     {
  766.         disableAccountPicker = false;
  767.         SetIgnoreInput(false);
  768.     }
  769.    
  770.     private function StartShowingCustomDialogs()
  771.     {
  772.        
  773.        
  774.        
  775.         if (theGame.GetInGameConfigWrapper().GetVarValue('Hidden', 'HasSeenGotyWelcomeMessage') == "false")
  776.         {
  777.         if (theGame.GetDLCManager().IsEP1Available() && theGame.GetInGameConfigWrapper().GetVarValue('Hidden', 'HasSeenEP1WelcomeMessage') == "false")
  778.         {
  779.             theGame.GetInGameConfigWrapper().SetVarValue('Hidden', 'HasSeenEP1WelcomeMessage', "true");
  780.                 prepareBigMessageGOTY( "menu_goty_starting_message_alt" );
  781.             prepareBigMessage( 1 );
  782.         }
  783.         if (theGame.GetDLCManager().IsEP2Available() && theGame.GetInGameConfigWrapper().GetVarValue('Hidden', 'HasSeenEP2WelcomeMessage') == "false")
  784.             else
  785.         {
  786.             theGame.GetInGameConfigWrapper().SetVarValue('Hidden', 'HasSeenEP2WelcomeMessage', "true");
  787.             prepareBigMessage( 2 );
  788.                 prepareBigMessageGOTY( "menu_goty_starting_message" );
  789.             }
  790.     }
  791.    
  792.     protected function prepareBigMessage( epIndex : int ):void
  793.     {
  794.         var l_DataFlashObject       : CScriptedFlashObject;
  795.        
  796.         l_DataFlashObject = m_flashValueStorage.CreateTempFlashObject();
  797.  
  798.         l_DataFlashObject.SetMemberFlashInt( "index", epIndex );
  799.         l_DataFlashObject.SetMemberFlashString( "tfTitle1", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_title_1") );
  800.         l_DataFlashObject.SetMemberFlashString( "tfTitle2", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_title_2") );
  801.         //---------------------------------//PATH TITLES
  802.         l_DataFlashObject.SetMemberFlashString( "tfTitlePath1", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_title_path_1") );
  803.         l_DataFlashObject.SetMemberFlashString( "tfTitlePath2", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_title_path_2") );
  804.         l_DataFlashObject.SetMemberFlashString( "tfTitlePath3", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_title_path_3") );
  805.         //---------------------------------//PATH DESCRIPTIONS
  806.         l_DataFlashObject.SetMemberFlashString( "tfDescPath1", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_title_path_1_description") );
  807.         l_DataFlashObject.SetMemberFlashString( "tfDescPath2", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_title_path_2_description") );
  808.         l_DataFlashObject.SetMemberFlashString( "tfDescPath3", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_title_path_3_description") );
  809.         //---------------------------------//WARNING/GOODLUCK FIELDS
  810.         l_DataFlashObject.SetMemberFlashString( "tfWarning", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_warning_level") );
  811.         l_DataFlashObject.SetMemberFlashString( "tfGoodLuck", GetLocStringByKeyExt("ep" + epIndex + "_installed_information_good_luck") );
  812.        
  813.         m_flashValueStorage.SetFlashObject( "ingamemenu.bigMessage" + epIndex, l_DataFlashObject );
  814.     }
  815.    
  816.    
  817.     protected function LoadLastSave():void
  818.     {
  819.         if (theGame.GetGuiManager().GetPopup('MessagePopup') && theGame.GetGuiManager().lastMessageData.messageId == UMID_ControllerDisconnected)
  820.         {
  821.             return;
  822.         }
  823.        
  824.         SetIgnoreInput(true);
  825.        
  826.         if (isMainMenu)
  827.         {
  828.             disableAccountPicker = true;
  829.         }
  830.        
  831.         theGame.LoadLastGameInit();
  832.     }
  833.    
  834.     protected function ShowActionConfPopup(action : int, title : string, description : string) : void
  835.     {
  836.         if (actionConfPopup)
  837.         {
  838.             delete actionConfPopup;
  839.         }
  840.        
  841.         actionConfPopup = new W3ActionConfirmation in this;
  842.         actionConfPopup.SetMessageTitle(title);
  843.         actionConfPopup.SetMessageText(description);
  844.         actionConfPopup.actionID = action;
  845.         actionConfPopup.menuRef = this;
  846.         actionConfPopup.BlurBackground = true;
  847.            
  848.         RequestSubMenu('PopupMenu', actionConfPopup);
  849.     }
  850.    
  851.     public function OnActionConfirmed(action:int) : void
  852.     {
  853.         var parentMenu : CR4MenuBase;
  854.        
  855.         parentMenu = (CR4MenuBase)GetParent();
  856.        
  857.         switch (action)
  858.         {
  859.         case IGMActionType_Quit:
  860.             {
  861.                 parentMenu.OnCloseMenu();
  862.                 theGame.RequestEndGame();
  863.                 break;
  864.             }
  865.         case IGMActionType_CloseGame:
  866.             {
  867.                 theGame.RequestExit();
  868.                 break;
  869.             }
  870.         }
  871.     }
  872.    
  873.     event /*flash*/ OnPresetApplied(groupId:name, targetPresetIndex:int)
  874.     {
  875.         hasChangedOption = true;
  876.         IngameMenu_ChangePresetValue(groupId, targetPresetIndex, this);
  877.        
  878.         if (groupId == 'Rendering' && !isMainMenu)
  879.         {
  880.             m_fxForceBackgroundVis.InvokeSelfOneArg(FlashArgBool(true));
  881.         }
  882.     }
  883.    
  884.     public function UpdateOptions(groupId:name)
  885.     {
  886.         var optionChangeContainer : CScriptedFlashObject;
  887.        
  888.         optionChangeContainer = m_flashValueStorage.CreateTempFlashObject();
  889.         IngameMenu_GatherOptionUpdatedValues(groupId, optionChangeContainer, m_flashValueStorage);
  890.        
  891.         m_flashValueStorage.SetFlashObject( "ingamemenu.optionValueChanges", optionChangeContainer );
  892.     }
  893.    
  894.     event /*flash*/ OnOptionValueChanged(groupId:int, optionName:name, optionValue:string)
  895.     {
  896.         var groupName:name;
  897.         var hud : CR4ScriptedHud;
  898.         var isValid : bool;
  899.         var isBuffered : bool;
  900.        
  901.         hasChangedOption = true;
  902.        
  903.         OnPlaySoundEvent( "gui_global_switch" );
  904.        
  905.         if (groupId == NameToFlashUInt('SpecialSettingsGroupId'))
  906.         {
  907.             HandleSpecialValueChanged(optionName, optionValue);
  908.             return true;
  909.         }
  910.        
  911.         if (optionName == 'HardwareCursor')
  912.         {
  913.             isValid = optionValue;
  914.             m_fxSetHardwareCursorOn.InvokeSelfOneArg(FlashArgBool(isValid));
  915.         }
  916.        
  917.         if (optionName == 'SwapAcceptCancel')
  918.         {
  919.             swapAcceptCancelChanged = true;
  920.         }
  921.        
  922.         if (optionName == 'AlternativeRadialMenuInputMode')
  923.         {
  924.             alternativeRadialInputChanged = true;
  925.         }
  926.        
  927.         if (optionName == 'EnableUberMovement')
  928.         {
  929.             if ( optionValue == "1" )
  930.                 theGame.EnableUberMovement( true );
  931.             else
  932.                 theGame.EnableUberMovement( false );
  933.         }
  934.        
  935.         if (optionName == 'GwentDifficulty')
  936.         {
  937.             if ( optionValue == "0" )
  938.                 FactsSet( 'gwent_difficulty' , 1 );
  939.             else if ( optionValue == "1" )
  940.                 FactsSet( 'gwent_difficulty' , 2 );
  941.             else if ( optionValue == "2" )
  942.                 FactsSet( 'gwent_difficulty' , 3 );
  943.            
  944.             return true;
  945.         }
  946.        
  947.         if (optionName == 'HardwareCursor')
  948.         {
  949.             updateInputDeviceRequired = true;
  950.         }
  951.        
  952.         groupName = mInGameConfigWrapper.GetGroupName(groupId);
  953.        
  954.         // Set var value in buffered in-game config or direct in-game config
  955.         isBuffered = mInGameConfigWrapper.DoGroupHasTag( groupName, 'buffered' );
  956.         if( isBuffered == false )
  957.         {
  958.             isBuffered = mInGameConfigWrapper.DoVarHasTag( groupName, optionName, 'buffered' );
  959.         }
  960.        
  961.         if( isBuffered == true )
  962.         {
  963.             inGameConfigBufferedWrapper.SetVarValue(groupName, optionName, optionValue);
  964.         }
  965.         else
  966.         {
  967.             mInGameConfigWrapper.SetVarValue(groupName, optionName, optionValue);
  968.         }
  969.        
  970.         theGame.OnConfigValueChanged(optionName, optionValue);
  971.        
  972.         if (groupName == 'Hud' || optionName == 'Subtitles')
  973.         {
  974.             hud = (CR4ScriptedHud)theGame.GetHud();
  975.            
  976.             if (hud)
  977.             {
  978.                 hud.UpdateHudConfig(optionName, true);
  979.             }
  980.         }
  981.        
  982.         if (groupName == 'Localization')
  983.         {
  984.             if (optionName == 'Virtual_Localization_text')
  985.             {
  986.                 currentLangValue = optionValue;
  987.             }
  988.             else if (optionName == 'Virtual_Localization_speech')
  989.             {
  990.                 currentSpeechLang = optionValue;
  991.             }
  992.         }
  993.        
  994.         if (groupName == 'Rendering' && !isMainMenu)
  995.         {
  996.             m_fxForceBackgroundVis.InvokeSelfOneArg(FlashArgBool(true));
  997.         }
  998.        
  999.         if (groupName == 'Rendering' && optionName == 'PreserveSystemGamma')
  1000.         {
  1001.             theGame.GetGuiManager().DisplayRestartGameToApplyAllChanges();
  1002.         }
  1003.     }
  1004.    
  1005.     protected function HandleSpecialValueChanged(optionName:name, optionValue:string):void
  1006.     {
  1007.         var intValue : int;
  1008.        
  1009.         if (optionName == 'GameDifficulty')
  1010.         {
  1011.             intValue = StringToInt(optionValue, 1);
  1012.            
  1013.             lastSetDifficulty = intValue + 1;
  1014.         }
  1015.     }
  1016.    
  1017.     public function OnGraphicsUpdated(keepChanges:bool):void
  1018.     {
  1019.         //if (graphicalChangesPending)
  1020.         //{
  1021.         //  theGame.Pause('IngameMenu');
  1022.         //}
  1023.         //m_fxNavigateBack.InvokeSelf(); // No need to do this anymore as you cannot stop the back navigation!
  1024.     }
  1025.    
  1026.     event /*flash*/ OnOptionPanelNavigateBack()
  1027.     {
  1028.         var graphicChangesPending:bool;
  1029.         var hud : CR4ScriptedHud;
  1030.        
  1031.         if (inGameConfigBufferedWrapper.AnyBufferedVarHasTag('refreshViewport'))
  1032.         {
  1033.             inGameConfigBufferedWrapper.ApplyNewValues();
  1034.             theGame.GetGuiManager().ShowProgressDialog(UMID_GraphicsRefreshing, "", "message_text_confirm_option_changes", true, UDB_OkCancel, 100, UMPT_GraphicsRefresh, '');
  1035.             ReopenMenu();
  1036.             return true;
  1037.         }
  1038.        
  1039.         hud = (CR4ScriptedHud)theGame.GetHud();
  1040.         if (hud)
  1041.         {
  1042.             hud.RefreshHudConfiguration();
  1043.         }
  1044.        
  1045.         thePlayer.SetAutoCameraCenter( inGameConfigBufferedWrapper.GetVarValue( 'Gameplay', 'AutoCameraCenter' ) );
  1046.         thePlayer.SetEnemyUpscaling( inGameConfigBufferedWrapper.GetVarValue( 'Gameplay', 'EnemyUpscaling' ) );
  1047.     }
  1048.    
  1049.     event /*flash*/ OnNavigatedBack()
  1050.     {
  1051.         var lowestDifficultyUsed : EDifficultyMode;
  1052.         var hud : CR4ScriptedHud;
  1053.         var overlayPopupRef : CR4OverlayPopup;
  1054.         var radialMenuModule : CR4HudModuleRadialMenu;
  1055.         var confirmResult : int;
  1056.        
  1057.         hud = (CR4ScriptedHud)(theGame.GetHud());
  1058.         overlayPopupRef = (CR4OverlayPopup) theGame.GetGuiManager().GetPopup('OverlayPopup');
  1059.        
  1060.         if( inGameConfigBufferedWrapper.IsEmpty() == false )
  1061.         {
  1062.             if (!inGameConfigBufferedWrapper.AnyBufferedVarHasTag('refreshViewport'))
  1063.             {
  1064.                 inGameConfigBufferedWrapper.FlushBuffer();
  1065.             }
  1066.            
  1067.             hasChangedOption = true;
  1068.         }
  1069.        
  1070.         if (currentLangValue != lastUsedLangValue || lastUsedSpeechLang != currentSpeechLang)
  1071.         {
  1072.             lastUsedLangValue = currentLangValue;
  1073.             lastUsedSpeechLang = currentSpeechLang;
  1074.             theGame.ReloadLanguage();
  1075.             //shouldRefreshKinect = true; // Kinect unplugged for TTP#98732. Keeping code on offchance we bring it back
  1076.         }
  1077.        
  1078.         if (swapAcceptCancelChanged)
  1079.         {
  1080.             swapAcceptCancelChanged = false;
  1081.             UpdateAcceptCancelSwaping();
  1082.            
  1083.             if (hud)
  1084.             {
  1085.                 hud.UpdateAcceptCancelSwaping();
  1086.             }
  1087.            
  1088.             if (overlayPopupRef)
  1089.             {
  1090.                 overlayPopupRef.UpdateAcceptCancelSwaping();
  1091.             }
  1092.         }
  1093.        
  1094.         if (alternativeRadialInputChanged)
  1095.         {
  1096.             alternativeRadialInputChanged = false;
  1097.            
  1098.             if (hud)
  1099.             {
  1100.                 radialMenuModule =  (CR4HudModuleRadialMenu)hud.GetHudModule( "RadialMenuModule" );
  1101.                 if (radialMenuModule)
  1102.                 {
  1103.                     radialMenuModule.UpdateInputMode();
  1104.                 }
  1105.             }
  1106.         }
  1107.        
  1108.         isShowingSaveList = false;
  1109.         isShowingLoadList = false;
  1110.        
  1111.         OnPlaySoundEvent( "gui_global_panel_close" );
  1112.        
  1113.         lowestDifficultyUsed = theGame.GetLowestDifficultyUsed();
  1114.        
  1115.         // This dialog is only for when lowering difficulty from the two hardest difficulties. There are no achievements for beating the game specifically
  1116.         // On Medium or Easy
  1117.         if (!isMainMenu && theGame.GetDifficultyLevel() != lastSetDifficulty && lowestDifficultyUsed > lastSetDifficulty && lowestDifficultyUsed > EDM_Medium)
  1118.         {
  1119.             diffChangeConfPopup = new W3DifficultyChangeConfirmation in this;
  1120.            
  1121.             diffChangeConfPopup.SetMessageTitle("");
  1122.            
  1123.             if (theGame.GetPlatform() == Platform_PS4)
  1124.             {
  1125.                 diffChangeConfPopup.SetMessageText(GetLocStringByKeyExt("difficulty_change_warning_message_PS4"));
  1126.             }
  1127.             else
  1128.             {
  1129.                 diffChangeConfPopup.SetMessageText(GetLocStringByKeyExt("difficulty_change_warning_message_X1"));
  1130.             }
  1131.            
  1132.             diffChangeConfPopup.menuRef = this;
  1133.             diffChangeConfPopup.targetDifficulty = lastSetDifficulty;
  1134.             diffChangeConfPopup.BlurBackground = true;
  1135.            
  1136.             RequestSubMenu('PopupMenu', diffChangeConfPopup);
  1137.         }
  1138.         else if (lastSetDifficulty != theGame.GetDifficultyLevel())
  1139.         {
  1140.             theGame.SetDifficultyLevel(lastSetDifficulty);
  1141.             theGame.OnDifficultyChanged(lastSetDifficulty);
  1142.         }
  1143.        
  1144.         SaveChangedSettings();
  1145.        
  1146.         if (overlayPopupRef && updateInputDeviceRequired)
  1147.         {
  1148.             updateInputDeviceRequired = false;
  1149.             overlayPopupRef.UpdateInputDevice();
  1150.         }
  1151.         thePlayer.UpdateValuesDK(); //Shaedhen - Atmospheric Nights
  1152.     }
  1153.    
  1154.     public function CancelDifficultyChange() : void
  1155.     {
  1156.         var difficultyIndex:int;
  1157.         var difficultyIndexAsString:string;
  1158.        
  1159.         lastSetDifficulty = theGame.GetDifficultyLevel();
  1160.        
  1161.         difficultyIndex = lastSetDifficulty - 1;
  1162.         difficultyIndexAsString = "" + difficultyIndex;
  1163.         m_fxUpdateOptionValue.InvokeSelfTwoArgs(FlashArgUInt(NameToFlashUInt('GameDifficulty')), FlashArgString(difficultyIndexAsString));
  1164.     }
  1165.    
  1166.     protected function SaveChangedSettings()
  1167.     {
  1168.         if (hasChangedOption)
  1169.         {
  1170.             hasChangedOption = false;
  1171.             theGame.SaveUserSettings();
  1172.             //---=== modFriendlyHUD ===---
  1173.             GetFHUDConfig().UpdateUserSettings();
  1174.             //---=== modFriendlyHUD ===---
  1175.         }
  1176.     }
  1177.    
  1178.     event /*flash*/ OnProfileChange()
  1179.     {
  1180.         if( !disableAccountPicker )
  1181.         {
  1182.             SetIgnoreInput(true);
  1183.             theGame.ChangeActiveUser();
  1184.         }
  1185.     }
  1186.    
  1187.     event /*flash*/ OnSaveGameCalled(type : ESaveGameType, saveArrayIndex : int)
  1188.     {
  1189.         var saves : array< SSavegameInfo >;
  1190.         var currentSave : SSavegameInfo;
  1191.        
  1192.         ignoreInput = true; // Set in flash side already
  1193.        
  1194.         if ( theGame.AreSavesLocked() )
  1195.         {
  1196.             theGame.GetGuiManager().DisplayLockedSavePopup();
  1197.             SetIgnoreInput(false);
  1198.             return false;
  1199.         }
  1200.    
  1201.         if (saveArrayIndex >= 0)
  1202.         {
  1203.             if (saveConfPopup)
  1204.             {
  1205.                 delete saveConfPopup;
  1206.             }
  1207.            
  1208.             theGame.ListSavedGames( saves );
  1209.             currentSave = saves[ saveArrayIndex ];
  1210.            
  1211.             saveConfPopup = new W3SaveGameConfirmation in this;
  1212.             saveConfPopup.SetMessageTitle("");
  1213.             if (theGame.GetPlatform() == Platform_Xbox1)
  1214.             {
  1215.                 saveConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_overwrite_save_x1"));
  1216.             }
  1217.             else if (theGame.GetPlatform() == Platform_PS4)
  1218.             {
  1219.                 saveConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_overwrite_save_ps4"));
  1220.             }
  1221.             else
  1222.             {
  1223.                 saveConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_overwrite_save"));
  1224.             }
  1225.             saveConfPopup.menuRef = this;
  1226.             saveConfPopup.type = currentSave.slotType;
  1227.             saveConfPopup.slot = currentSave.slotIndex;
  1228.             saveConfPopup.BlurBackground = true;
  1229.                
  1230.             RequestSubMenu('PopupMenu', saveConfPopup);
  1231.         }
  1232.         else
  1233.         {
  1234.             executeSave(type, -1);
  1235.             SetIgnoreInput(false);
  1236.         }
  1237.     }
  1238.    
  1239.     public function executeSave(type : ESaveGameType, slot : int)
  1240.     {
  1241.         var hadLoadable:bool;
  1242.        
  1243.         hadLoadable = hasSaveDataToLoad();
  1244.        
  1245.         theGame.SaveGame(type, slot);
  1246.         m_fxNavigateBack.InvokeSelf();
  1247.     }
  1248.    
  1249.     event /*flash*/ OnLoadGameCalled(type : ESaveGameType, saveListIndex : int)
  1250.     {
  1251.         var saveGameRef : SSavegameInfo;
  1252.         var saveGames       : array< SSavegameInfo >;
  1253.        
  1254.         if (ignoreInput)
  1255.         {
  1256.             return false;
  1257.         }
  1258.        
  1259.         disableAccountPicker = true;
  1260.        
  1261.         if (loadConfPopup)
  1262.         {
  1263.             delete loadConfPopup;
  1264.         }
  1265.        
  1266.         theGame.ListSavedGames( saveGames );
  1267.         saveGameRef = saveGames[saveListIndex];
  1268.        
  1269.         if (panelMode || (isMainMenu && !hasValidAutosaveData()))
  1270.         {
  1271.             LoadSaveRequested(saveGameRef);
  1272.         }
  1273.         else
  1274.         {
  1275.             loadConfPopup = new W3ApplyLoadConfirmation in this;
  1276.            
  1277.             if (theGame.GetPlatform() == Platform_Xbox1)
  1278.             {
  1279.                 loadConfPopup.SetMessageTitle(GetLocStringByKeyExt("panel_mainmenu_popup_load_title_x1"));
  1280.             }
  1281.             else if (theGame.GetPlatform() == Platform_PS4)
  1282.             {
  1283.                 loadConfPopup.SetMessageTitle(GetLocStringByKeyExt("panel_mainmenu_popup_load_title_ps4"));
  1284.             }
  1285.             else
  1286.             {
  1287.                 loadConfPopup.SetMessageTitle(GetLocStringByKeyExt("panel_mainmenu_popup_load_title"));        
  1288.             }
  1289.            
  1290.             if (isMainMenu)
  1291.             {
  1292.                 if (theGame.GetPlatform() == Platform_Xbox1)
  1293.                 {
  1294.                     loadConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_load_game_main_menu_x1"));
  1295.                 }
  1296.                 else if (theGame.GetPlatform() == Platform_PS4)
  1297.                 {
  1298.                     loadConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_load_game_main_menu_ps4"));
  1299.                 }
  1300.                 else
  1301.                 {
  1302.                     loadConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_load_game_main_menu"));
  1303.                 }
  1304.             }
  1305.             else
  1306.             {
  1307.                 if (theGame.GetPlatform() == Platform_Xbox1)
  1308.                 {
  1309.                     loadConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_load_game_x1"));
  1310.                 }
  1311.                 else if (theGame.GetPlatform() == Platform_PS4)
  1312.                 {
  1313.                     loadConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_load_game_ps4"));
  1314.                 }
  1315.                 else
  1316.                 {
  1317.                     loadConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_load_game"));
  1318.                 }
  1319.             }
  1320.             loadConfPopup.menuRef = this;
  1321.             loadConfPopup.saveSlotRef = saveGameRef;
  1322.             loadConfPopup.BlurBackground = true;
  1323.            
  1324.             SetIgnoreInput(true);
  1325.                    
  1326.             RequestSubMenu('PopupMenu', loadConfPopup);
  1327.         }
  1328.     }
  1329.    
  1330.     public function LoadSaveRequested(saveSlotRef : SSavegameInfo) : void
  1331.     {  
  1332.         if (theGame.GetGuiManager().GetPopup('MessagePopup') && theGame.GetGuiManager().lastMessageData.messageId == UMID_ControllerDisconnected)
  1333.         {
  1334.             SetIgnoreInput(false);
  1335.             disableAccountPicker = false;
  1336.             return;
  1337.         }
  1338.        
  1339.         SetIgnoreInput(true);
  1340.        
  1341.         if (isMainMenu)
  1342.         {
  1343.             disableAccountPicker = true;
  1344.         }
  1345.        
  1346.         theGame.LoadGameInit( saveSlotRef );
  1347.     }
  1348.    
  1349.     event /*flash*/ OnImportGameCalled(menuTag:int):void
  1350.     {
  1351.         var savesToImport : array< SSavegameInfo >;
  1352.         var difficulty:int;
  1353.         var tutorialsEnabled:bool;
  1354.         var simulateImport:bool;
  1355.         var maskResult:int;
  1356.         var progress : float;
  1357.        
  1358.         if (!theGame.IsContentAvailable('launch0'))
  1359.         {
  1360.             progress = theGame.ProgressToContentAvailable('launch0');
  1361.             theSound.SoundEvent("gui_global_denied");
  1362.             theGame.GetGuiManager().ShowProgressDialog(0, "", "error_message_new_game_not_ready", true, UDB_Ok, progress, UMPT_Content, 'launch0');
  1363.            
  1364.         }
  1365.         else
  1366.         {
  1367.             theGame.ListW2SavedGames( savesToImport );
  1368.            
  1369.             if ( menuTag < savesToImport.Size() )
  1370.             {
  1371.                 disableAccountPicker = true;
  1372.                
  1373.                 theGame.ClearInitialFacts();
  1374.                
  1375.                 if (theGame.ImportSave( savesToImport[ menuTag ] ))
  1376.                 {
  1377.                     currentNewGameConfig.import_save_index = menuTag;
  1378.                    
  1379.                     if ((lastSetTag & IGMC_New_game_plus) == IGMC_New_game_plus)
  1380.                     {
  1381.                         m_fxForceEnterCurEntry.InvokeSelf();
  1382.                     }
  1383.                     else
  1384.                     {
  1385.                         // Never want to simulate an import when actually importing haha
  1386.                         theGame.SetDifficultyLevel(currentNewGameConfig.difficulty);
  1387.                         TutorialMessagesEnable(currentNewGameConfig.tutorialsOn);
  1388.                        
  1389.                         if ( theGame.RequestNewGame( theGame.GetNewGameDefinitionFilename() ) )
  1390.                         {
  1391.                             OnPlaySoundEvent("gui_global_game_start");
  1392.                             OnPlaySoundEvent("mus_intro_usm");
  1393.                             GetRootMenu().CloseMenu();
  1394.                         }
  1395.                     }
  1396.                 }
  1397.                 else
  1398.                 {
  1399.                     showNotification(GetLocStringByKeyExt("import_witcher_two_failed"));
  1400.                     OnPlaySoundEvent("gui_global_denied");
  1401.                 }
  1402.             }
  1403.         }
  1404.     }
  1405.    
  1406.     event /*flash*/ OnNewGamePlusCalled(saveListIndex:int):void
  1407.     {
  1408.         var startGameStatus : ENewGamePlusStatus;
  1409.         var saveGameRef     : SSavegameInfo;
  1410.         var saveGames       : array< SSavegameInfo >;
  1411.         var errorMessage    : string;
  1412.         var progress : float;
  1413.        
  1414.         var requiredContent : name = 'content12';
  1415.        
  1416.         ignoreInput = true; // Set in flash side already
  1417.        
  1418.         if (!theGame.IsContentAvailable(requiredContent))
  1419.         {
  1420.             progress = theGame.ProgressToContentAvailable(requiredContent);
  1421.             theSound.SoundEvent("gui_global_denied");
  1422.             SetIgnoreInput(false);
  1423.             theGame.GetGuiManager().ShowProgressDialog(0, "", "error_message_new_game_not_ready", true, UDB_Ok, progress, UMPT_Content, requiredContent);
  1424.         }
  1425.         else
  1426.         {
  1427.             disableAccountPicker = true;
  1428.            
  1429.             theGame.ListSavedGames( saveGames );
  1430.             saveGameRef = saveGames[saveListIndex];
  1431.            
  1432.             if (currentNewGameConfig.import_save_index == -1 && currentNewGameConfig.simulate_import)
  1433.             {
  1434.                 theGame.AddInitialFact("simulate_import_ingame");
  1435.             }
  1436.            
  1437.             theGame.SetDifficultyLevel(currentNewGameConfig.difficulty);
  1438.            
  1439.             TutorialMessagesEnable(currentNewGameConfig.tutorialsOn);
  1440.            
  1441.             startGameStatus = theGame.StartNewGamePlus(saveGameRef);
  1442.            
  1443.             if (startGameStatus == NGP_Success)
  1444.             {
  1445.                 theGame.GetGuiManager().RequestMouseCursor(false);
  1446.                 OnPlaySoundEvent("gui_global_game_start");
  1447.                 OnPlaySoundEvent("mus_intro_usm");
  1448.                 GetRootMenu().CloseMenu();
  1449.             }
  1450.             else
  1451.             {
  1452.                 errorMessage = "";
  1453.                 SetIgnoreInput(false);
  1454.                 disableAccountPicker = false;
  1455.                
  1456.                 switch (startGameStatus)
  1457.                 {
  1458.                 case NGP_Invalid:
  1459.                     errorMessage = GetLocStringByKeyExt("newgame_plus_error_invalid");
  1460.                     break;
  1461.                 case NGP_CantLoad:
  1462.                     errorMessage = GetLocStringByKeyExt("newgame_plus_error_cantload");
  1463.                     break;
  1464.                 case NGP_TooOld:
  1465.                     errorMessage = GetLocStringByKeyExt("newgame_plus_error_too_old");
  1466.                     break;
  1467.                 case NGP_RequirementsNotMet:
  1468.                     errorMessage = GetLocStringByKeyExt("newgame_plus_error_requirementnotmet");
  1469.                     break;
  1470.                 case NGP_InternalError:
  1471.                     errorMessage = GetLocStringByKeyExt("newgame_plus_error_internalerror");
  1472.                     break;
  1473.                 case NGP_ContentRequired:
  1474.                     errorMessage = GetLocStringByKeyExt("newgame_plus_error_contentrequired");
  1475.                     break;
  1476.                 }
  1477.                
  1478.                 showNotification(errorMessage);
  1479.                 OnPlaySoundEvent("gui_global_denied");
  1480.             }
  1481.         }
  1482.     }
  1483.    
  1484.     event /*flash*/ OnDeleteSaveCalled(type : ESaveGameType, saveListIndex : int, isSaveMode:bool)
  1485.     {
  1486.         if (ignoreInput)
  1487.         {
  1488.             return false;
  1489.         }
  1490.        
  1491.         SetIgnoreInput(true);
  1492.        
  1493.         disableAccountPicker = true;
  1494.        
  1495.         if (deleteConfPopup)
  1496.         {
  1497.             delete deleteConfPopup;
  1498.         }
  1499.        
  1500.         deleteConfPopup = new W3DeleteSaveConf in this;
  1501.         deleteConfPopup.SetMessageTitle("");
  1502.         if (theGame.GetPlatform() == Platform_Xbox1)
  1503.         {
  1504.             deleteConfPopup.SetMessageText(GetLocStringByKeyExt("panel_mainmenu_confirm_delete_text_x1"));
  1505.         }
  1506.         else if (theGame.GetPlatform() == Platform_PS4)
  1507.         {
  1508.             deleteConfPopup.SetMessageText(GetLocStringByKeyExt("panel_mainmenu_confirm_delete_text_ps4"));
  1509.         }
  1510.         else
  1511.         {
  1512.             deleteConfPopup.SetMessageText(GetLocStringByKeyExt("panel_mainmenu_confirm_delete_text"));
  1513.         }
  1514.         deleteConfPopup.menuRef = this;
  1515.         deleteConfPopup.type = type;
  1516.         deleteConfPopup.slot = saveListIndex;
  1517.         deleteConfPopup.saveMode = isSaveMode;
  1518.         deleteConfPopup.BlurBackground = true;
  1519.            
  1520.         RequestSubMenu('PopupMenu', deleteConfPopup);
  1521.     }
  1522.    
  1523.     public function DeleteSave(type : ESaveGameType, saveListIndex : int, isSaveMode:bool)
  1524.     {
  1525.         var saves : array< SSavegameInfo >;
  1526.         var currentSave : SSavegameInfo;
  1527.         var numSavesBeforeDelete : int;
  1528.        
  1529.         theGame.ListSavedGames( saves );
  1530.        
  1531.         numSavesBeforeDelete = saves.Size();
  1532.        
  1533.         if (saveListIndex < saves.Size())
  1534.         {
  1535.             currentSave = saves[ saveListIndex ];
  1536.             theGame.DeleteSavedGame(currentSave);
  1537.         }
  1538.        
  1539.         if (numSavesBeforeDelete <= 1)
  1540.         {
  1541.             m_fxRemoveOption.InvokeSelfOneArg(FlashArgInt(NameToFlashUInt('Continue')));
  1542.             m_fxRemoveOption.InvokeSelfOneArg(FlashArgInt(NameToFlashUInt('LoadGame')));
  1543.            
  1544.             if (isInLoadselector)
  1545.             {
  1546.                 m_fxNavigateBack.InvokeSelf();
  1547.             }
  1548.             else
  1549.             {
  1550.                 SendSaveData();
  1551.             }
  1552.         }
  1553.         else
  1554.         {
  1555.             if (isSaveMode)
  1556.             {
  1557.                 SendSaveData();
  1558.             }
  1559.             else if (hasSaveDataToLoad())
  1560.             {
  1561.                 SendLoadData();
  1562.             }
  1563.         }
  1564.     }
  1565.    
  1566.     protected function showHelpPanel() : void
  1567.     {
  1568.         m_fxNavigateBack.InvokeSelf();
  1569.        
  1570.         theGame.DisplaySystemHelp();
  1571.     }
  1572.    
  1573.     public function TryStartNewGame(optionsArray : int):void
  1574.     {
  1575.         var progress : float;
  1576.        
  1577.         if (!theGame.IsContentAvailable('launch0'))
  1578.         {
  1579.             progress = theGame.ProgressToContentAvailable('launch0');
  1580.             theSound.SoundEvent("gui_global_denied");
  1581.             theGame.GetGuiManager().ShowProgressDialog(0, "", "error_message_new_game_not_ready", true, UDB_Ok, progress, UMPT_Content, 'launch0');
  1582.         }
  1583.         else
  1584.         {
  1585.             fetchNewGameConfigFromTag(optionsArray);
  1586.            
  1587.             if ((optionsArray & IGMC_EP2_Save) == IGMC_EP2_Save)
  1588.             {
  1589.                 // EP2 save loading
  1590.                 theGame.InitStandaloneDLCLoading('bob_000_000', currentNewGameConfig.difficulty);
  1591.             }
  1592.             else if ((optionsArray & IGMC_EP1_Save) == IGMC_EP1_Save)
  1593.             {
  1594.                 // EP1 save loading
  1595.                 theGame.InitStandaloneDLCLoading('ep1', currentNewGameConfig.difficulty);
  1596.             }
  1597.             else
  1598.             {
  1599.                 if (hasValidAutosaveData())
  1600.                 {
  1601.                     if (newGameConfPopup)
  1602.                     {
  1603.                         delete newGameConfPopup;
  1604.                     }
  1605.                    
  1606.                     newGameConfPopup = new W3NewGameConfirmation in this;
  1607.                     newGameConfPopup.SetMessageTitle("");
  1608.                     if (theGame.GetPlatform() == Platform_Xbox1)
  1609.                     {
  1610.                         newGameConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_start_game_x1"));  
  1611.                     }
  1612.                     else if (theGame.GetPlatform() == Platform_PS4)
  1613.                     {
  1614.                         newGameConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_start_game_ps4")); 
  1615.                     }
  1616.                     else
  1617.                     {
  1618.                         newGameConfPopup.SetMessageText(GetLocStringByKeyExt("error_message_start_game")); 
  1619.                     }
  1620.                     newGameConfPopup.menuRef = this;
  1621.                     newGameConfPopup.BlurBackground = true;
  1622.                        
  1623.                     RequestSubMenu('PopupMenu', newGameConfPopup);
  1624.                 }
  1625.                 else
  1626.                 {
  1627.                     NewGameRequested();
  1628.                 }
  1629.             }
  1630.         }
  1631.     }
  1632.    
  1633.     protected function fetchNewGameConfigFromTag(optionsTag : int):void
  1634.     {
  1635.         var maskResult:int;
  1636.        
  1637.         currentNewGameConfig.difficulty = optionsTag & IGMC_Difficulty_mask;
  1638.        
  1639.         maskResult = optionsTag & IGMC_Tutorials_On;
  1640.         currentNewGameConfig.tutorialsOn = (maskResult == IGMC_Tutorials_On);
  1641.        
  1642.         maskResult = optionsTag & IGMC_Import_Save;
  1643.         if (maskResult != IGMC_Import_Save)
  1644.         {
  1645.             currentNewGameConfig.import_save_index = -1;
  1646.         }
  1647.        
  1648.         maskResult = optionsTag & IGMC_Simulate_Import;
  1649.         currentNewGameConfig.simulate_import = (maskResult == IGMC_Simulate_Import);
  1650.     }
  1651.    
  1652.     public function NewGameRequested():void
  1653.     {
  1654.         disableAccountPicker = true;
  1655.        
  1656.         if (currentNewGameConfig.import_save_index == -1)
  1657.         {
  1658.             theGame.ClearInitialFacts();
  1659.         }
  1660.        
  1661.         if (currentNewGameConfig.import_save_index == -1 && currentNewGameConfig.simulate_import)
  1662.         {
  1663.             theGame.AddInitialFact("simulate_import_ingame");
  1664.         }
  1665.        
  1666.         theGame.SetDifficultyLevel(currentNewGameConfig.difficulty);
  1667.        
  1668.         TutorialMessagesEnable(currentNewGameConfig.tutorialsOn);
  1669.        
  1670.         StartNewGame();
  1671.     }
  1672.    
  1673.     event /*flash*/ OnUpdateRescale(hScale : float, vScale : float)
  1674.     {
  1675.         var hud : CR4ScriptedHud;
  1676.         var needRescale : bool;
  1677.        
  1678.         hud = (CR4ScriptedHud)theGame.GetHud();
  1679.         needRescale = false;
  1680.        
  1681.         if( theGame.GetUIHorizontalFrameScale() != hScale )
  1682.         {
  1683.             theGame.SetUIHorizontalFrameScale(hScale);
  1684.             mInGameConfigWrapper.SetVarValue('Hidden', 'uiHorizontalFrameScale', FloatToString(hScale));
  1685.             needRescale = true;
  1686.             hasChangedOption = true;
  1687.         }  
  1688.         if( theGame.GetUIVerticalFrameScale() != vScale )
  1689.         {
  1690.             theGame.SetUIVerticalFrameScale(vScale);
  1691.             mInGameConfigWrapper.SetVarValue('Hidden', 'uiVerticalFrameScale', FloatToString(vScale));
  1692.             needRescale = true;
  1693.             hasChangedOption = true;
  1694.         }  
  1695.        
  1696.         if( needRescale && hud )
  1697.         {
  1698.             hud.RescaleModules();
  1699.         }
  1700.     }
  1701.    
  1702.     public function ShowTutorialChosen(enabled:bool):void
  1703.     {
  1704.         TutorialMessagesEnable(enabled);
  1705.        
  1706.         StartNewGame();
  1707.     }
  1708.    
  1709.     public function StartNewGame():void
  1710.     {
  1711.         if (theGame.GetGuiManager().GetPopup('MessagePopup') && theGame.GetGuiManager().lastMessageData.messageId == UMID_ControllerDisconnected)
  1712.         {
  1713.             return;
  1714.         }
  1715.        
  1716.         if ( theGame.RequestNewGame( theGame.GetNewGameDefinitionFilename() ) )
  1717.         {
  1718.             theGame.GetGuiManager().RequestMouseCursor(false);
  1719.             OnPlaySoundEvent("gui_global_game_start");
  1720.             OnPlaySoundEvent("mus_intro_usm");
  1721.             GetRootMenu().CloseMenu();
  1722.         }
  1723.     }
  1724.    
  1725.     function PopulateMenuData()
  1726.     {
  1727.         var l_DataFlashArray        : CScriptedFlashArray;
  1728.         var l_ChildMenuFlashArray   : CScriptedFlashArray;
  1729.         var l_DataFlashObject       : CScriptedFlashObject;
  1730.         var l_subDataFlashObject    : CScriptedFlashObject;
  1731.        
  1732.         l_DataFlashArray = m_structureCreator.PopulateMenuData();
  1733.        
  1734.         m_flashValueStorage.SetFlashArray( "ingamemenu.entries", l_DataFlashArray );
  1735.     }
  1736.    
  1737.     protected function addInLoadOption():void
  1738.     {
  1739.         var l_DataFlashObject       : CScriptedFlashObject;
  1740.         var l_ChildMenuFlashArray   : CScriptedFlashArray;
  1741.        
  1742.         l_DataFlashObject = m_flashValueStorage.CreateTempFlashObject();
  1743.         l_DataFlashObject.SetMemberFlashString( "id", "mainmenu_loadgame");
  1744.         l_DataFlashObject.SetMemberFlashUInt(  "tag", NameToFlashUInt('LoadGame') );
  1745.         l_DataFlashObject.SetMemberFlashString(  "label", GetLocStringByKeyExt("panel_mainmenu_loadgame") );   
  1746.         //l_DataFlashObject.SetMemberFlashString(  "description", GetLocStringByKeyExt("panel_loadgame_description") );
  1747.         l_DataFlashObject.SetMemberFlashUInt( "type", IGMActionType_Load );
  1748.        
  1749.         l_ChildMenuFlashArray = m_flashValueStorage.CreateTempFlashArray();
  1750.         l_DataFlashObject.SetMemberFlashArray( "subElements", l_ChildMenuFlashArray );
  1751.        
  1752.         m_flashValueStorage.SetFlashObject( "ingamemenu.addloading", l_DataFlashObject );
  1753.     }
  1754.    
  1755.     event /*flash*/ OnBack()
  1756.     {
  1757.         CloseMenu();
  1758.     }
  1759.    
  1760.     public function HasSavesToImport() : bool
  1761.     {
  1762.         var savesToImport : array< SSavegameInfo >;
  1763.        
  1764.         theGame.ListW2SavedGames( savesToImport );
  1765.         return savesToImport.Size() != 0;
  1766.     }
  1767.  
  1768.     protected function SendImportSaveData()
  1769.     {
  1770.         var dataFlashArray  : CScriptedFlashArray;
  1771.        
  1772.         dataFlashArray = m_flashValueStorage.CreateTempFlashArray();
  1773.        
  1774.         IngameMenu_PopulateImportSaveData(m_flashValueStorage, dataFlashArray);
  1775.        
  1776.         m_initialSelectionsToIgnore = 1;
  1777.         OnPlaySoundEvent( "gui_global_panel_open" );
  1778.        
  1779.         isShowingSaveList = true;
  1780.         m_flashValueStorage.SetFlashArray( "ingamemenu.importSlots", dataFlashArray );
  1781.     }
  1782.    
  1783.     protected function hasValidAutosaveData() : bool
  1784.     {
  1785.         var currentSave : SSavegameInfo;
  1786.         var num : int;
  1787.         var i : int;
  1788.        
  1789.         num = theGame.GetNumSaveSlots( SGT_AutoSave );
  1790.         for ( i = 0; i < num; i = i + 1 )
  1791.         {
  1792.             if ( theGame.GetSaveInSlot( SGT_AutoSave, i, currentSave ) )
  1793.             {
  1794.                 return true;
  1795.             }
  1796.         }
  1797.        
  1798.         num = theGame.GetNumSaveSlots( SGT_CheckPoint );
  1799.         for ( i = 0; i < num; i = i + 1 )
  1800.         {
  1801.             if ( theGame.GetSaveInSlot( SGT_CheckPoint, i, currentSave ) )
  1802.             {
  1803.                 return true;
  1804.             }
  1805.         }
  1806.        
  1807.         return false;
  1808.     }
  1809.    
  1810.     public function HandleSaveListUpdate():void
  1811.     {
  1812.         if (isShowingSaveList)
  1813.         {
  1814.             SendSaveData();
  1815.         }
  1816.         else if (isShowingLoadList)
  1817.         {
  1818.             SendLoadData();
  1819.         }
  1820.        
  1821.         if (hasSaveDataToLoad())
  1822.         {
  1823.             addInLoadOption();
  1824.         }
  1825.     }
  1826.    
  1827.     protected function SendLoadData():void
  1828.     {
  1829.         var dataFlashArray  : CScriptedFlashArray;
  1830.        
  1831.         dataFlashArray = m_flashValueStorage.CreateTempFlashArray();
  1832.        
  1833.         PopulateSaveDataForSlotType(-1, dataFlashArray, false);
  1834.        
  1835.         m_initialSelectionsToIgnore = 1;
  1836.         OnPlaySoundEvent( "gui_global_panel_open" );
  1837.        
  1838.         if (dataFlashArray.GetLength() == 0)
  1839.         {
  1840.             m_fxNavigateBack.InvokeSelf();
  1841.         }
  1842.         else
  1843.         {
  1844.             isShowingLoadList = true;
  1845.             m_flashValueStorage.SetFlashArray( "ingamemenu.loadSlots", dataFlashArray );
  1846.         }
  1847.     }
  1848.    
  1849.    
  1850.     protected function SendSaveData():void
  1851.     {
  1852.         var dataFlashArray  : CScriptedFlashArray;
  1853.        
  1854.         dataFlashArray = m_flashValueStorage.CreateTempFlashArray();
  1855.        
  1856.         //PopulateSaveDataForSlotType(SGT_AutoSave, dataFlashArray, true);
  1857.         //PopulateSaveDataForSlotType(SGT_QuickSave, dataFlashArray, true);
  1858.         PopulateSaveDataForSlotType(SGT_Manual, dataFlashArray, true);
  1859.        
  1860.         m_initialSelectionsToIgnore = 1;
  1861.         OnPlaySoundEvent( "gui_global_panel_open" );
  1862.        
  1863.         isShowingSaveList = true;
  1864.         m_flashValueStorage.SetFlashArray( "ingamemenu.saveSlots", dataFlashArray );
  1865.        
  1866.         if ( theGame.ShouldShowSaveCompatibilityWarning() )
  1867.         {
  1868.             theGame.GetGuiManager().ShowUserDialog( UMID_SaveCompatWarning, "", "error_save_not_compatible", UDB_Ok );
  1869.         }
  1870.     }
  1871.    
  1872.     protected function SendNewGamePlusSaves():void
  1873.     {
  1874.         var dataFlashArray  : CScriptedFlashArray;
  1875.        
  1876.         dataFlashArray = m_flashValueStorage.CreateTempFlashArray();
  1877.        
  1878.         PopulateSaveDataForSlotType(-1, dataFlashArray, false);
  1879.        
  1880.         theGame.GetGuiManager().ShowUserDialog(0, "", "message_new_game_plus_reminder", UDB_Ok);
  1881.        
  1882.         if (dataFlashArray.GetLength() == 0)
  1883.         {
  1884.             OnPlaySoundEvent("gui_global_denied");
  1885.             showNotification(GetLocStringByKeyExt("mainmenu_newgame_plus_no_saves"));
  1886.             m_fxNavigateBack.InvokeSelf();
  1887.         }
  1888.         else
  1889.         {
  1890.             m_initialSelectionsToIgnore = 1;
  1891.             OnPlaySoundEvent( "gui_global_panel_open" );
  1892.             m_flashValueStorage.SetFlashArray( "ingamemenu.newGamePlusSlots", dataFlashArray );
  1893.         }
  1894.     }
  1895.    
  1896.     protected function PopulateSaveDataForSlotType(saveType:int, parentObject:CScriptedFlashArray, allowEmptySlot:bool):void
  1897.     {
  1898.         IngameMenu_PopulateSaveDataForSlotType(m_flashValueStorage, saveType, parentObject, allowEmptySlot);
  1899.     }
  1900.    
  1901.     event /*flash*/ OnLoadSaveImageCancelled():void
  1902.     {
  1903.         theGame.FreeScreenshotData();
  1904.     }
  1905.    
  1906.     event /*flash*/ OnScreenshotDataRequested(saveIndex:int):void
  1907.     {
  1908.         var targetSaveInfo  : SSavegameInfo;
  1909.         var saveGames       : array< SSavegameInfo >;
  1910.        
  1911.         theGame.ListSavedGames( saveGames );
  1912.        
  1913.         if (saveIndex >= 0 && saveIndex < saveGames.Size())
  1914.         {
  1915.             targetSaveInfo = saveGames[saveIndex];
  1916.            
  1917.             theGame.RequestScreenshotData(targetSaveInfo);
  1918.         }
  1919.     }
  1920.    
  1921.     event /*flash*/ OnCheckScreenshotDataReady():void
  1922.     {
  1923.         if (theGame.IsScreenshotDataReady())
  1924.         {
  1925.             m_fxOnSaveScreenshotRdy.InvokeSelf();
  1926.         }
  1927.     }
  1928.    
  1929.     protected function SendInstalledDLCList():void
  1930.     {
  1931.         var currentData : CScriptedFlashObject;
  1932.         var dataArray : CScriptedFlashArray;
  1933.         var dlcManager : CDLCManager;
  1934.         var i : int;
  1935.         var dlcList : array<name>;
  1936.        
  1937.         var currentName : string;
  1938.         var currentDesc : string;
  1939.        
  1940.         //var m_journalManager : CWitcherJournalManager;
  1941.        
  1942.         dataArray = m_flashValueStorage.CreateTempFlashArray();
  1943.        
  1944.         dlcManager = theGame.GetDLCManager();
  1945.         dlcManager.GetDLCs(dlcList);
  1946.        
  1947.         for (i = 0; i < dlcList.Size(); i += 1)
  1948.         {
  1949.             //if (dlcManager.IsDLCAvailable(dlcList[i]))
  1950.             //{
  1951.                 currentData = m_flashValueStorage.CreateTempFlashObject();
  1952.                
  1953.                 currentName = GetLocStringByKeyExt( "content_name_" + NameToString(dlcList[i]) );
  1954.                 currentDesc = "";//GetLocStringById( tempSubEntry.GetDescriptionStringId() );
  1955.                
  1956.                 if (currentName != "")
  1957.                 {
  1958.                     currentData.SetMemberFlashString("label", currentName);
  1959.                     currentData.SetMemberFlashString("desc", currentDesc);
  1960.                    
  1961.                     dataArray.PushBackFlashObject(currentData);
  1962.                 }
  1963.             //}
  1964.         }
  1965.        
  1966.         // WIP "content_name_" + NameToString(missingContent[i])
  1967.        
  1968.         m_flashValueStorage.SetFlashArray("ingamemenu.installedDLCs", dataArray);
  1969.     }
  1970.    
  1971.     protected function SendRescaleData():void
  1972.     {
  1973.         var currentData : CScriptedFlashObject;
  1974.        
  1975.         currentData = m_flashValueStorage.CreateTempFlashObject();
  1976.        
  1977.         currentData.SetMemberFlashNumber("initialHScale", theGame.GetUIHorizontalFrameScale() );
  1978.         currentData.SetMemberFlashNumber("initialVScale", theGame.GetUIVerticalFrameScale() );
  1979.        
  1980.         m_flashValueStorage.SetFlashObject("ingamemenu.uirescale", currentData);
  1981.     }
  1982.    
  1983.     protected function SendControllerData():void
  1984.     {
  1985.         var dataFlashArray : CScriptedFlashArray;
  1986.        
  1987.         if ( (W3ReplacerCiri)thePlayer )
  1988.         {
  1989.             dataFlashArray = InGameMenu_CreateControllerDataCiri(m_flashValueStorage);
  1990.         }
  1991.         else
  1992.         {
  1993.             dataFlashArray = InGameMenu_CreateControllerData(m_flashValueStorage);
  1994.         }
  1995.        
  1996.         m_flashValueStorage.SetFlashArray( "ingamemenu.gamepad.mappings", dataFlashArray );
  1997.     }
  1998.    
  1999.     protected function SendKeybindData():void
  2000.     {
  2001.         var dataFlashArray : CScriptedFlashArray;
  2002.        
  2003.         dataFlashArray = m_flashValueStorage.CreateTempFlashArray();
  2004.        
  2005.         IngameMenu_GatherKeybindData(dataFlashArray, m_flashValueStorage);
  2006.        
  2007.         m_flashValueStorage.SetFlashArray( "ingamemenu.keybindValues", dataFlashArray );
  2008.     }
  2009.    
  2010.     event /*flash*/ OnClearKeybind(keybindTag:name):void
  2011.     {
  2012.         hasChangedOption = true;
  2013.         mInGameConfigWrapper.SetVarValue('PCInput', keybindTag, "IK_None;IK_None"); // #J TODO, if we want to support two keybinds, this wont work as is
  2014.         SendKeybindData();
  2015.     }
  2016.    
  2017.     // #J Hopefully Temporary function as I cannot get the tags of an object right now :(
  2018.     // If we keep this and want to support overlap, may want to return a list of names instead of the first one found
  2019.     protected function GetKeybindGroupTag(keybindName : name) : name
  2020.     {
  2021.         if (mInGameConfigWrapper.DoVarHasTag('PCInput', keybindName, 'input_overlap1'))
  2022.         {
  2023.             return 'input_overlap1';
  2024.         }
  2025.         else if (mInGameConfigWrapper.DoVarHasTag('PCInput', keybindName, 'input_overlap2'))
  2026.         {
  2027.             return 'input_overlap2';
  2028.         }
  2029.         else if (mInGameConfigWrapper.DoVarHasTag('PCInput', keybindName, 'input_overlap3'))
  2030.         {
  2031.             return 'input_overlap3';
  2032.         }
  2033.         else if (mInGameConfigWrapper.DoVarHasTag('PCInput', keybindName, 'input_overlap4'))
  2034.         {
  2035.             return 'input_overlap4';
  2036.         }
  2037.         else if (mInGameConfigWrapper.DoVarHasTag('PCInput', keybindName, 'input_overlap5'))
  2038.         {
  2039.             return 'input_overlap5';
  2040.         }
  2041.         //---=== modFriendlyHUD ===---
  2042.         else if (mInGameConfigWrapper.DoVarHasTag('PCInput', keybindName, 'input_overlap_fhud1')
  2043.                     || keybindName == 'HoldToSeeEssentials' || keybindName == 'HubMenu')
  2044.         {
  2045.             return 'input_overlap_fhud1';
  2046.         }
  2047.         else if (mInGameConfigWrapper.DoVarHasTag('PCInput', keybindName, 'input_overlap_fhud2')
  2048.                     || keybindName == 'HoldToSeeCharStats' || keybindName == 'PanelChar')
  2049.         {
  2050.             return 'input_overlap_fhud2';
  2051.         }
  2052.         else if (mInGameConfigWrapper.DoVarHasTag('PCInput', keybindName, 'input_overlap_fhud3')
  2053.                     || keybindName == 'HoldToSeeMap' || keybindName == 'PanelMap')
  2054.         {
  2055.             return 'input_overlap_fhud3';
  2056.         }
  2057.         else if (mInGameConfigWrapper.DoVarHasTag('PCInput', keybindName, 'input_overlap_fhud4')
  2058.                     || keybindName == 'HoldToSeeQuests' || keybindName == 'PanelJour')
  2059.         {
  2060.             return 'input_overlap_fhud4';
  2061.         }
  2062.         //---=== modFriendlyHUD ===---
  2063.        
  2064.         return '';
  2065.     }
  2066.    
  2067.     event /*flash*/ OnChangeKeybind(keybindTag:name, newKeybindValue:EInputKey):void
  2068.     {
  2069.         var newSettingString : string;
  2070.         var exisitingKeybind : name;
  2071.         var groupIndex : int;
  2072.         var keybindChangedMessage : string;
  2073.         var numKeybinds : int;
  2074.         var i : int;
  2075.         var currentBindingTag : name;
  2076.        
  2077.         var iterator_KeybindName : name;
  2078.         var iterator_KeybindKey : string;
  2079.        
  2080.         hasChangedOption = true;
  2081.        
  2082.         newSettingString = newKeybindValue;
  2083.        
  2084.         // #J this code is what forces unique keybinds.
  2085.         //if (smartKeybindingEnabled)
  2086.         {
  2087.             groupIndex = IngameMenu_GetPCInputGroupIndex();
  2088.        
  2089.             if (groupIndex != -1)
  2090.             {
  2091.                 numKeybinds = mInGameConfigWrapper.GetVarsNumByGroupName('PCInput');
  2092.                 currentBindingTag = GetKeybindGroupTag(keybindTag);
  2093.                
  2094.                 for (i = 0; i < numKeybinds; i += 1)
  2095.                 {
  2096.                     iterator_KeybindName = mInGameConfigWrapper.GetVarName(groupIndex, i);
  2097.                     iterator_KeybindKey = mInGameConfigWrapper.GetVarValue('PCInput', iterator_KeybindName);
  2098.                    
  2099.                     iterator_KeybindKey = StrReplace(iterator_KeybindKey, ";IK_None", ""); // #J TODO, if we want to support two keybinds, this wont work as is
  2100.                     iterator_KeybindKey = StrReplace(iterator_KeybindKey, "IK_None;", "");
  2101.                    
  2102.                     if (iterator_KeybindKey == newSettingString && iterator_KeybindName != keybindTag &&
  2103.                         (currentBindingTag == '' || currentBindingTag != GetKeybindGroupTag(iterator_KeybindName)))
  2104.                     {
  2105.                         if (keybindChangedMessage != "")
  2106.                         {
  2107.                             keybindChangedMessage += ", ";
  2108.                         }
  2109.                         keybindChangedMessage += IngameMenu_GetLocalizedKeybindName(iterator_KeybindName);
  2110.                         OnClearKeybind(iterator_KeybindName);
  2111.                     }
  2112.                 }
  2113.             }
  2114.            
  2115.             if (keybindChangedMessage != "")
  2116.             {
  2117.                 keybindChangedMessage += " </br>" + GetLocStringByKeyExt("key_unbound_message");
  2118.                 showNotification(keybindChangedMessage);
  2119.             }
  2120.         }
  2121.        
  2122.         newSettingString = newKeybindValue + ";IK_None"; // #J TODO, if we want to support two keybinds, this wont work as is
  2123.         mInGameConfigWrapper.SetVarValue('PCInput', keybindTag, newSettingString);
  2124.         SendKeybindData();
  2125.     }
  2126.    
  2127.     event /*flash*/ OnSmartKeybindEnabledChanged(value:bool):void
  2128.     {
  2129.         smartKeybindingEnabled = value;
  2130.     }
  2131.    
  2132.     event /*flash*/ OnInvalidKeybindTried(keyCode:EInputKey):void
  2133.     {
  2134.         showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_now"));
  2135.         OnPlaySoundEvent("gui_global_denied");
  2136.     }
  2137.    
  2138.     event /*flash*/ OnLockedKeybindTried():void
  2139.     {
  2140.         showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_now"));
  2141.         OnPlaySoundEvent("gui_global_denied");
  2142.     }
  2143.    
  2144.     //---=== modFriendlyHUD ===---
  2145.     event /*flash*/ OnResetKeybinds():void
  2146.     function ShouldHideDLCIcons() : bool
  2147.     {
  2148.         return theGame.GetInGameConfigWrapper().GetVarValue('fhudMainMenu', 'fhudHideDLC');
  2149.     }
  2150.     //---=== modFriendlyHUD ===---
  2151.  
  2152.     {
  2153.         mInGameConfigWrapper.ResetGroupToDefaults('PCInput');
  2154.         SendKeybindData();
  2155.         showNotification(inGameMenu_TryLocalize("menu_option_reset_successful"));
  2156.        
  2157.         hasChangedOption = true;
  2158.     }
  2159.    
  2160.     function PlayOpenSoundEvent()
  2161.     {
  2162.     }
  2163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement