/**
         * <summary>Performs what should happen when the element is clicked on.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_slot">The index number of ths slot that was clicked</param>
         * <param name = "_mouseState">The state of the mouse button</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState == GameState.Cutscene)
            {
                return;
            }

            base.ProcessClick(_menu, _slot, _mouseState);

            if (autoHandle)
            {
                bool isSuccess = false;

                if (fixedOption)
                {
                    isSuccess = Options.SwitchProfileID(optionToShow);
                }
                else
                {
                    isSuccess = KickStarter.options.SwitchProfile(_slot + offset, showActive);
                }

                if (isSuccess)
                {
                    RunActionList(_slot);
                }
            }
            else
            {
                RunActionList(_slot);
            }
        }
示例#2
0
 private void SwitchActiveProfile(int profileID)
 {
     if (Options.GetActiveProfileID() != profileID)
     {
         Options.SwitchProfileID(profileID);
     }
 }
        override public float Run()
        {
            if (!KickStarter.settingsManager.useProfiles)
            {
                ACDebug.LogWarning("Save game profiles are not enabled - please set in Settings Manager to use this Action.");
                return(0f);
            }

            string newProfileLabel = "";

            if ((manageProfileType == ManageProfileType.CreateProfile && useCustomLabel) || manageProfileType == ManageProfileType.RenameProfile)
            {
                GVar gVar = GlobalVariables.GetVariable(varID);
                if (gVar != null)
                {
                    newProfileLabel = gVar.textVal;
                }
                else
                {
                    ACDebug.LogWarning("Could not " + manageProfileType.ToString() + " - no variable found.");
                    return(0f);
                }
            }

            if (manageProfileType == ManageProfileType.CreateProfile)
            {
                KickStarter.options.CreateProfile(newProfileLabel);
            }
            else if (manageProfileType == ManageProfileType.DeleteProfile ||
                     manageProfileType == ManageProfileType.RenameProfile ||
                     manageProfileType == ManageProfileType.SwitchActiveProfile)
            {
                if (deleteProfileType == DeleteProfileType.ActiveProfile)
                {
                    if (manageProfileType == ManageProfileType.DeleteProfile)
                    {
                        KickStarter.saveSystem.DeleteProfile();
                    }
                    else if (manageProfileType == ManageProfileType.RenameProfile)
                    {
                        KickStarter.options.RenameProfile(newProfileLabel);
                    }
                    return(0f);
                }
                else if (deleteProfileType == DeleteProfileType.SetProfileID)
                {
                    int profileID = Mathf.Max(0, profileIndex);

                    if (manageProfileType == ManageProfileType.DeleteProfile)
                    {
                        KickStarter.saveSystem.DeleteProfileID(profileID);
                    }
                    else if (manageProfileType == ManageProfileType.RenameProfile)
                    {
                        KickStarter.options.RenameProfileID(newProfileLabel, profileID);
                    }
                    else if (manageProfileType == ManageProfileType.SwitchActiveProfile)
                    {
                        Options.SwitchProfileID(profileID);
                    }
                }
                else if (deleteProfileType == DeleteProfileType.SetSlotIndex ||
                         deleteProfileType == DeleteProfileType.SlotIndexFromVariable)
                {
                    int i = Mathf.Max(0, profileIndex);

                    if (deleteProfileType == DeleteProfileType.SlotIndexFromVariable)
                    {
                        GVar gVar = GlobalVariables.GetVariable(slotVarID);
                        if (gVar != null)
                        {
                            i = gVar.val;
                        }
                        else
                        {
                            ACDebug.LogWarning("Could not " + manageProfileType.ToString() + " - no variable found.");
                            return(0f);
                        }
                    }

                    bool includeActive = true;
                    if (menuName != "" && elementName != "")
                    {
                        MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                        if (menuElement != null && menuElement is MenuProfilesList)
                        {
                            MenuProfilesList menuProfilesList = (MenuProfilesList)menuElement;

                            if (menuProfilesList.fixedOption)
                            {
                                ACDebug.LogWarning("Cannot refer to ProfilesLst " + elementName + " in Menu " + menuName + ", as it lists a fixed profile ID only!");
                                return(0f);
                            }

                            i            += menuProfilesList.GetOffset();
                            includeActive = menuProfilesList.showActive;
                        }
                        else
                        {
                            ACDebug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'.");
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning("No ProfilesList element referenced when trying to delete profile slot " + i.ToString());
                    }

                    if (manageProfileType == ManageProfileType.DeleteProfile)
                    {
                        KickStarter.saveSystem.DeleteProfile(i, includeActive);
                    }
                    else if (manageProfileType == ManageProfileType.RenameProfile)
                    {
                        KickStarter.options.RenameProfile(newProfileLabel, i, includeActive);
                    }
                    else if (manageProfileType == ManageProfileType.SwitchActiveProfile)
                    {
                        KickStarter.options.SwitchProfile(i, includeActive);
                    }
                }
            }

            return(0f);
        }