예제 #1
0
        /**
         * <summary>Switches to a specific profile ID, provided that it exists.</summary>
         * <param name = "profileID">The unique identifier of the profile to switch to</param>
         * <returns>True if the switch was successful</returns>
         */
        public static bool SwitchProfileID(int profileID)
        {
            if (!Options.DoesProfileIDExist(profileID))
            {
                ACDebug.LogWarning("Cannot switch to profile ID " + profileID.ToString() + ", as it has not been created.");
                return(false);
            }

            SetActiveProfileID(profileID);
            LoadPrefs();

            ACDebug.Log("Switched to profile " + profileID.ToString() + ": '" + optionsData.label + "'");

            if (Application.isPlaying)
            {
                KickStarter.saveSystem.GatherSaveFiles();
                KickStarter.playerMenus.RecalculateAll();
            }

            return(true);
        }
예제 #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());
        }
예제 #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));
        }