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);
        }
Esempio n. 2
0
        public override ActionEnd End(List <Action> actions)
        {
            switch (saveCheck)
            {
            case SaveCheck.NumberOfSaveGames:
                return(ProcessResult(CheckCondition(KickStarter.saveSystem.GetNumSaves(includeAutoSaves)), actions));

            case SaveCheck.NumberOfProfiles:
                return(ProcessResult(CheckCondition(KickStarter.options.GetNumProfiles()), actions));

            case SaveCheck.IsSlotEmpty:
                return(ProcessResult(!SaveSystem.DoesSaveExist(intValue, intValue, !checkByElementIndex), actions));

            case SaveCheck.DoesProfileExist:
                if (checkByElementIndex)
                {
                    int  i             = Mathf.Max(0, intValue);
                    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)
                            {
                                LogWarning("Cannot refer to ProfilesList " + elementName + " in Menu " + menuName + ", as it lists a fixed profile ID only!");
                                return(ProcessResult(false, actions));
                            }

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

                    return(ProcessResult(KickStarter.options.DoesProfileExist(i, includeActive), actions));
                }
                else
                {
                    // intValue is the profile ID
                    return(ProcessResult(Options.DoesProfileIDExist(intValue), actions));
                }

            case SaveCheck.DoesProfileNameExist:
                bool result = false;

                GVar gVar = GlobalVariables.GetVariable(profileVarID);
                if (gVar != null)
                {
                    string profileName = gVar.TextValue;
                    result = KickStarter.options.DoesProfileExist(profileName);
                }
                else
                {
                    LogWarning("Could not check for profile name - no variable found.");
                }

                return(ProcessResult(result, actions));

            case SaveCheck.IsSavingPossible:
                return(ProcessResult(!PlayerMenus.IsSavingLocked(this), actions));

            default:
                break;
            }

            return(GenerateStopActionEnd());
        }
Esempio n. 3
0
        override public ActionEnd End(List <AC.Action> actions)
        {
            int actualNumber = 0;

            if (saveCheck == SaveCheck.NumberOfSaveGames)
            {
                actualNumber = KickStarter.saveSystem.GetNumSaves(includeAutoSaves);
            }
            else if (saveCheck == SaveCheck.NumberOfProfiles)
            {
                actualNumber = KickStarter.options.GetNumProfiles();
            }
            else if (saveCheck == SaveCheck.IsSlotEmpty)
            {
                return(ProcessResult(!SaveSystem.DoesSaveExist(intValue, intValue, !checkByElementIndex), actions));
            }
            else if (saveCheck == SaveCheck.DoesProfileExist)
            {
                if (checkByElementIndex)
                {
                    int  i             = Mathf.Max(0, intValue);
                    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(ProcessResult(false, actions));
                            }

                            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());
                    }

                    bool result = KickStarter.options.DoesProfileExist(i, includeActive);
                    return(ProcessResult(result, actions));
                }
                else
                {
                    // intValue is the profile ID
                    bool result = Options.DoesProfileIDExist(intValue);
                    return(ProcessResult(result, actions));
                }
            }
            else if (saveCheck == SaveCheck.IsSavingPossible)
            {
                return(ProcessResult(!PlayerMenus.IsSavingLocked(this), actions));
            }

            return(ProcessResult(CheckCondition(actualNumber), actions));
        }