Advertisement
Guest User

Untitled

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