Ejemplo n.º 1
0
        public static void OnMenuEnable(AC.Menu _menu)
        {
            // This function is called whenever a menu is enabled.

            if (_menu.title == "Pause")
            {
                MenuElement saveButton = _menu.GetElementWithName("SaveButton");

                if (saveButton)
                {
                    saveButton.isVisible = !PlayerMenus.IsSavingLocked();
                }

                _menu.Recalculate();
            }
        }
Ejemplo n.º 2
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.IsSavingPossible)
            {
                return(ProcessResult(!PlayerMenus.IsSavingLocked(this), actions));
            }

            return(ProcessResult(CheckCondition(actualNumber), actions));
        }
Ejemplo n.º 3
0
        private void PerformSaveOrLoad()
        {
            ClearAllEvents();

            if (saveHandling == SaveHandling.ContinueFromLastSave || saveHandling == SaveHandling.LoadGame)
            {
                EventManager.OnFinishLoading += OnComplete;
                EventManager.OnFailLoading   += OnComplete;
            }
            else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame)
            {
                EventManager.OnFinishSaving += OnComplete;
                EventManager.OnFailSaving   += OnComplete;
            }

            if ((saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.ContinueFromLastSave) && doSelectiveLoad)
            {
                KickStarter.saveSystem.SetSelectiveLoadOptions(selectiveLoad);
            }

            string newSaveLabel = "";

            if (customLabel && ((updateLabel && saveHandling == SaveHandling.OverwriteExistingSave) || saveHandling == AC.SaveHandling.SaveNewGame))
            {
                if (selectSaveType != SelectSaveType.Autosave)
                {
                    GVar gVar = GlobalVariables.GetVariable(varID);
                    if (gVar != null)
                    {
                        newSaveLabel = gVar.GetValue(Options.GetLanguage());
                    }
                    else
                    {
                        ACDebug.LogWarning("Could not " + saveHandling.ToString() + " - no variable found.");
                        return;
                    }
                }
            }

            int i = Mathf.Max(0, saveIndex);

            if (saveHandling == SaveHandling.ContinueFromLastSave)
            {
                SaveSystem.ContinueGame();
                return;
            }

            if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave)
            {
                if (selectSaveType == SelectSaveType.Autosave)
                {
                    if (saveHandling == SaveHandling.LoadGame)
                    {
                        SaveSystem.LoadAutoSave();
                        return;
                    }
                    else
                    {
                        if (PlayerMenus.IsSavingLocked(this))
                        {
                            ACDebug.LogWarning("Cannot save at this time - either blocking ActionLists, a Conversation is active, or saving has been manually locked.");
                            OnComplete();
                        }
                        else
                        {
                            SaveSystem.SaveAutoSave();
                        }
                        return;
                    }
                }
                else if (selectSaveType == SelectSaveType.SlotIndexFromVariable)
                {
                    GVar gVar = GlobalVariables.GetVariable(slotVarID);
                    if (gVar != null)
                    {
                        i = gVar.val;
                    }
                    else
                    {
                        ACDebug.LogWarning("Could not get save slot index - no variable found.");
                        return;
                    }
                }
            }

            if (menuName != "" && elementName != "")
            {
                MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                if (menuElement != null && menuElement is MenuSavesList)
                {
                    MenuSavesList menuSavesList = (MenuSavesList)menuElement;
                    i += menuSavesList.GetOffset();
                }
                else
                {
                    ACDebug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'.");
                }
            }
            else
            {
                ACDebug.LogWarning("No SavesList element referenced when trying to find slot slot " + i.ToString());
            }

            if (saveHandling == SaveHandling.LoadGame)
            {
                SaveSystem.LoadGame(i, -1, false);
            }
            else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame)
            {
                if (PlayerMenus.IsSavingLocked(this))
                {
                    ACDebug.LogWarning("Cannot save at this time - either blocking ActionLists, a Conversation is active, or saving has been manually locked.");
                    OnComplete();
                }
                else
                {
                    if (saveHandling == SaveHandling.OverwriteExistingSave)
                    {
                        SaveSystem.SaveGame(i, -1, false, updateLabel, newSaveLabel);
                    }
                    else if (saveHandling == SaveHandling.SaveNewGame)
                    {
                        SaveSystem.SaveNewGame(updateLabel, newSaveLabel);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        override public float Run()
        {
            string newSaveLabel = "";

            if (customLabel && ((updateLabel && saveHandling == SaveHandling.OverwriteExistingSave) || saveHandling == AC.SaveHandling.SaveNewGame))
            {
                if (selectSaveType != SelectSaveType.Autosave)
                {
                    GVar gVar = GlobalVariables.GetVariable(varID);
                    if (gVar != null)
                    {
                        newSaveLabel = gVar.textVal;
                    }
                    else
                    {
                        Debug.LogWarning("Could not " + saveHandling.ToString() + " - no variable found.");
                        return(0f);
                    }
                }
            }

            int i = Mathf.Max(0, saveIndex);

            if (saveHandling == SaveHandling.ContinueFromLastSave)
            {
                SaveSystem.ContinueGame();
                return(0f);
            }

            if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave)
            {
                if (selectSaveType == SelectSaveType.Autosave)
                {
                    if (saveHandling == SaveHandling.LoadGame)
                    {
                        SaveSystem.LoadAutoSave();
                        return(0f);
                    }
                    else
                    {
                        if (!PlayerMenus.IsSavingLocked(this))
                        {
                            SaveSystem.SaveAutoSave();
                        }
                        else
                        {
                            Debug.LogWarning("Cannot save at this time - either blocking ActionLists, a Converation is active, or saving has been manually locked.");
                        }
                        return(0f);
                    }
                }
                else if (selectSaveType == SelectSaveType.SlotIndexFromVariable)
                {
                    GVar gVar = GlobalVariables.GetVariable(slotVarID);
                    if (gVar != null)
                    {
                        i = gVar.val;
                    }
                    else
                    {
                        Debug.LogWarning("Could not create profile - no variable found.");
                        return(0f);
                    }
                }
            }

            if (menuName != "" && elementName != "")
            {
                MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                if (menuElement != null && menuElement is MenuSavesList)
                {
                    MenuSavesList menuSavesList = (MenuSavesList)menuElement;
                    i += menuSavesList.GetOffset();
                }
                else
                {
                    Debug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'.");
                }
            }
            else
            {
                Debug.LogWarning("No SavesList element referenced when trying to find slot slot " + i.ToString());
            }

            if (saveHandling == SaveHandling.LoadGame)
            {
                SaveSystem.LoadGame(i, -1, false);
            }
            else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame)
            {
                if (!PlayerMenus.IsSavingLocked(this))
                {
                    if (saveHandling == SaveHandling.OverwriteExistingSave)
                    {
                        SaveSystem.SaveGame(i, -1, false, updateLabel, newSaveLabel);
                    }
                    else if (saveHandling == SaveHandling.SaveNewGame)
                    {
                        SaveSystem.SaveNewGame(updateLabel, newSaveLabel);
                    }
                }
                else
                {
                    Debug.LogWarning("Cannot save at this time - either blocking ActionLists, a Converation is active, or saving has been manually locked.");
                }
            }
            return(0f);
        }
        /**
         * <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;
            }

            eventSlot = _slot;
            ClearAllEvents();

            switch (saveListType)
            {
            case AC_SaveListType.Save:
                if (autoHandle)
                {
                    if (PlayerMenus.IsSavingLocked(null, true))
                    {
                        return;
                    }

                    EventManager.OnFinishSaving += OnCompleteSave;
                    EventManager.OnFailSaving   += OnFailSaveLoad;

                    if (newSaveSlot && _slot == (numSlots - 1))
                    {
                        SaveSystem.SaveNewGame();

                        if (KickStarter.settingsManager.orderSavesByUpdateTime)
                        {
                            offset = 0;
                        }
                        else
                        {
                            Shift(AC_ShiftInventory.ShiftNext, 1);
                        }
                    }
                    else
                    {
                        SaveSystem.SaveGame(_slot + offset, GetOptionID(_slot), fixedOption || allowEmptySlots);
                    }
                }
                else
                {
                    RunActionList(_slot);
                }
                break;

            case AC_SaveListType.Load:
                if (autoHandle)
                {
                    EventManager.OnFinishLoading += OnCompleteLoad;
                    EventManager.OnFailLoading   += OnFailSaveLoad;

                    SaveSystem.LoadGame(_slot + offset, GetOptionID(_slot), fixedOption || allowEmptySlots);
                }
                else
                {
                    RunActionList(_slot);
                }
                break;

            case AC_SaveListType.Import:
                EventManager.OnFinishImporting += OnCompleteImport;
                EventManager.OnFailImporting   += OnFailImport;

                SaveSystem.ImportGame(_slot + offset, GetOptionID(_slot), fixedOption || allowEmptySlots);
                break;
            }

            base.ProcessClick(_menu, _slot, _mouseState);
        }
Ejemplo n.º 6
0
        protected void PerformSaveOrLoad()
        {
            ClearAllEvents();

            if (saveHandling == SaveHandling.ContinueFromLastSave || saveHandling == SaveHandling.LoadGame)
            {
                EventManager.OnFinishLoading += OnFinishLoading;
                EventManager.OnFailLoading   += OnFail;
            }
            else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame)
            {
                EventManager.OnFinishSaving += OnFinishSaving;
                EventManager.OnFailSaving   += OnFail;
            }

            if ((saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.ContinueFromLastSave) && doSelectiveLoad)
            {
                KickStarter.saveSystem.SetSelectiveLoadOptions(selectiveLoad);
            }

            string newSaveLabel = string.Empty;

            if (customLabel && ((updateLabel && saveHandling == SaveHandling.OverwriteExistingSave) || saveHandling == AC.SaveHandling.SaveNewGame))
            {
                if (selectSaveType != SelectSaveType.Autosave)
                {
                    GVar gVar = GlobalVariables.GetVariable(varID);
                    if (gVar != null)
                    {
                        newSaveLabel = gVar.GetValue(Options.GetLanguage());
                    }
                    else
                    {
                        LogWarning("Could not " + saveHandling.ToString() + " - no variable found.");
                        return;
                    }
                }
            }

            int i = saveIndex;

            if (saveHandling == SaveHandling.ContinueFromLastSave)
            {
                SaveSystem.ContinueGame();
                return;
            }

            if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave)
            {
                if (selectSaveType == SelectSaveType.Autosave)
                {
                    if (saveHandling == SaveHandling.LoadGame)
                    {
                        SaveSystem.LoadAutoSave();
                        return;
                    }
                    else
                    {
                        if (PlayerMenus.IsSavingLocked(this, true))
                        {
                            OnComplete();
                        }
                        else
                        {
                            SaveSystem.SaveAutoSave();
                        }
                        return;
                    }
                }
                else if (selectSaveType == SelectSaveType.SlotIndexFromVariable)
                {
                    GVar gVar = GlobalVariables.GetVariable(slotVarID);
                    if (gVar != null)
                    {
                        i = gVar.IntegerValue;
                    }
                    else
                    {
                        LogWarning("Could not get save slot index - no variable found.");
                        return;
                    }
                }
            }

            if (selectSaveType != SelectSaveType.Autosave && selectSaveType != SelectSaveType.SetSaveID)
            {
                if (!string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(elementName))
                {
                    MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                    if (menuElement != null && menuElement is MenuSavesList)
                    {
                        MenuSavesList menuSavesList = (MenuSavesList)menuElement;
                        i += menuSavesList.GetOffset();
                    }
                    else
                    {
                        LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'.");
                    }
                }
                else
                {
                    LogWarning("No SavesList element referenced when trying to find slot slot " + i.ToString());
                }
            }

            if (saveHandling == SaveHandling.LoadGame)
            {
                if (selectSaveType == SelectSaveType.SetSaveID)
                {
                    SaveSystem.LoadGame(i);
                }
                else
                {
                    SaveSystem.LoadGame(i, -1, false);
                }
            }
            else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame)
            {
                if (PlayerMenus.IsSavingLocked(this, true))
                {
                    OnComplete();
                }
                else
                {
                    if (saveHandling == SaveHandling.OverwriteExistingSave)
                    {
                        if (selectSaveType == SelectSaveType.SetSaveID)
                        {
                            SaveSystem.SaveGame(0, i, true, updateLabel, newSaveLabel);
                        }
                        else
                        {
                            SaveSystem.SaveGame(i, -1, false, updateLabel, newSaveLabel);
                        }
                    }
                    else if (saveHandling == SaveHandling.SaveNewGame)
                    {
                        SaveSystem.SaveNewGame(updateLabel, newSaveLabel);
                    }
                }
            }
        }
Ejemplo n.º 7
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());
        }
Ejemplo n.º 8
0
        private void SaveFileGUI()
        {
            iSaveFileHandler    saveFileHandler          = SaveSystem.SaveFileHandler;
            iOptionsFileHandler optionsFileHandler       = Options.OptionsFileHandler;
            iFileFormatHandler  fileFormatHandler        = SaveSystem.FileFormatHandler;
            iFileFormatHandler  optionsFileFormatHandler = SaveSystem.OptionsFileFormatHandler;

            if (optionsFileHandler == null)
            {
                EditorGUILayout.HelpBox("No Options File Handler assigned - one must be set in order to locate Profile Data.", MessageType.Warning);
                return;
            }

            if (saveFileHandler == null)
            {
                EditorGUILayout.HelpBox("No Save File Handler assigned - one must be set in order to locate Save Data.", MessageType.Warning);
                return;
            }

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showHandlers = CustomGUILayout.ToggleHeader(showHandlers, "File and format handlers");
            if (showHandlers)
            {
                if (saveFileHandler != null)
                {
                    EditorGUILayout.LabelField("Save file location:", saveFileHandler.GetType().Name);
                }

                if (optionsFileHandler != null)
                {
                    EditorGUILayout.LabelField("Options location:", optionsFileHandler.GetType().Name);
                }

                if (fileFormatHandler != null)
                {
                    EditorGUILayout.LabelField("File format:", fileFormatHandler.GetType().Name);
                }

                if (optionsFileFormatHandler != null && fileFormatHandler == null || (optionsFileFormatHandler.GetType().Name != fileFormatHandler.GetType().Name))
                {
                    EditorGUILayout.LabelField("Options format:", optionsFileFormatHandler.GetType().Name);
                }

                EditorGUILayout.HelpBox("Save format and location handlers can be modified through script - see the Manual's 'Custom save formats and handling' chapter.", MessageType.Info);
            }
            EditorGUILayout.EndVertical();

            if (settingsManager.useProfiles)
            {
                EditorGUILayout.Space();

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                showProfiles = CustomGUILayout.ToggleHeader(showProfiles, "Profiles");
                if (showProfiles)
                {
                    bool foundSome = false;

                    for (int profileID = 0; profileID < Options.maxProfiles; profileID++)
                    {
                        if (optionsFileHandler.DoesProfileExist(profileID))
                        {
                            foundSome = true;
                            OptionsData tempOptionsData = Options.LoadPrefsFromID(profileID, false, false);

                            string label = profileID.ToString() + ": " + tempOptionsData.label;
                            if (profileID == Options.GetActiveProfileID())
                            {
                                label += " (ACTIVE)";
                            }

                            if (GUILayout.Toggle(selectedProfileID == profileID, label, "Button"))
                            {
                                if (selectedProfileID != profileID)
                                {
                                    selectedProfileID = profileID;
                                    selectedSaveIndex = -1;
                                    foundSaveFiles.Clear();
                                }
                            }
                        }
                    }

                    if (!foundSome)
                    {
                        selectedProfileID = -1;
                        EditorGUILayout.HelpBox("No save profiles found.", MessageType.Warning);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            else
            {
                selectedProfileID = 0;
            }

            if (selectedProfileID < 0 || !optionsFileHandler.DoesProfileExist(selectedProfileID))
            {
                EditorGUILayout.HelpBox("No save profiles found! Run the game to create a new save profile", MessageType.Warning);
                return;
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showProfile = CustomGUILayout.ToggleHeader(showProfile, "Profile " + selectedProfileID + ": Properties");
            if (showProfile)
            {
                OptionsData prefsData = GetPrefsData(selectedProfileID);
                if (prefsData != null)
                {
                    EditorGUILayout.LabelField("Label:", prefsData.label);
                    EditorGUILayout.LabelField("ID:", prefsData.ID.ToString());
                    EditorGUILayout.LabelField("Language:", prefsData.language.ToString());
                    if (prefsData.language != prefsData.voiceLanguage)
                    {
                        EditorGUILayout.LabelField("Voice language:", prefsData.voiceLanguage.ToString());
                    }
                    EditorGUILayout.LabelField("Show subtitles:", prefsData.showSubtitles.ToString());
                    EditorGUILayout.LabelField("SFX volume:", prefsData.sfxVolume.ToString());
                    EditorGUILayout.LabelField("Music volume:", prefsData.musicVolume.ToString());
                    EditorGUILayout.LabelField("Speech volume:", prefsData.speechVolume.ToString());

                    if (KickStarter.variablesManager != null)
                    {
                        List <GVar> linkedVariables = SaveSystem.UnloadVariablesData(prefsData.linkedVariables, KickStarter.variablesManager.vars, true);
                        foreach (GVar linkedVariable in linkedVariables)
                        {
                            if (linkedVariable.link == VarLink.OptionsData)
                            {
                                EditorGUILayout.LabelField(linkedVariable.label + ":", linkedVariable.GetValue());
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Linked Variables:", prefsData.linkedVariables);
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (settingsManager.useProfiles)
                    {
                        GUI.enabled = (selectedProfileID != Options.GetActiveProfileID());
                        if (GUILayout.Button("Make active"))
                        {
                            SwitchActiveProfile(selectedProfileID);
                        }
                        GUI.enabled = true;
                    }
                    if (GUILayout.Button("Delete profile"))
                    {
                        bool canDelete = EditorUtility.DisplayDialog("Delete profile?", "Are you sure you want to delete profile #" + selectedProfileID + "? This operation cannot be undone.", "Yes", "No");
                        if (canDelete)
                        {
                            Options.DeleteProfilePrefs(selectedProfileID);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            foundSaveFiles = saveFileHandler.GatherSaveFiles(selectedProfileID);

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showSaves = CustomGUILayout.ToggleHeader(showSaves, "Save game files");
            if (showSaves)
            {
                if (foundSaveFiles != null)
                {
                    for (int saveIndex = 0; saveIndex < foundSaveFiles.Count; saveIndex++)
                    {
                        SaveFile saveFile = foundSaveFiles[saveIndex];
                        string   label    = saveFile.saveID.ToString() + ": " + saveFile.label;

                        if (GUILayout.Toggle(selectedSaveIndex == saveIndex, label, "Button"))
                        {
                            selectedSaveIndex = saveIndex;
                        }
                    }
                }

                if (foundSaveFiles == null || foundSaveFiles.Count == 0)
                {
                    selectedSaveIndex = -1;
                    EditorGUILayout.HelpBox("No save game files found.", MessageType.Warning);
                }

                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                GUI.enabled = Application.isPlaying;
                if (GUILayout.Button("Autosave"))
                {
                    if (!PlayerMenus.IsSavingLocked(null, true))
                    {
                        SwitchActiveProfile(selectedProfileID);
                        SaveSystem.SaveAutoSave();
                    }
                }
                if (GUILayout.Button("Save new"))
                {
                    if (!PlayerMenus.IsSavingLocked(null, true))
                    {
                        SwitchActiveProfile(selectedProfileID);
                        SaveSystem.SaveNewGame();
                    }
                }
                GUI.enabled = (foundSaveFiles != null && foundSaveFiles.Count > 0);
                if (GUILayout.Button("Delete all saves"))
                {
                    bool canDelete = EditorUtility.DisplayDialog("Delete all save files?", "Are you sure you want to delete all save files? This operation cannot be undone.", "Yes", "No");
                    if (canDelete)
                    {
                        saveFileHandler.DeleteAll(selectedProfileID);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();

            if (selectedSaveIndex < 0 || foundSaveFiles == null || selectedSaveIndex >= foundSaveFiles.Count)
            {
                return;
            }

            EditorGUILayout.Space();

            SaveFile selectedSaveFile = foundSaveFiles[selectedSaveIndex];

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showSave = CustomGUILayout.ToggleHeader(showSave, "Save game " + selectedSaveIndex + ": Properties");
            if (showSave)
            {
                EditorGUILayout.LabelField("Label:", selectedSaveFile.label);
                EditorGUILayout.LabelField("ID:", selectedSaveFile.saveID.ToString());

                CustomGUILayout.MultiLineLabelGUI("Filename:", selectedSaveFile.fileName);

                EditorGUILayout.LabelField("Timestamp:", selectedSaveFile.updatedTime.ToString());
                if (!string.IsNullOrEmpty(selectedSaveFile.screenshotFilename))
                {
                    CustomGUILayout.MultiLineLabelGUI("Filename:", selectedSaveFile.screenshotFilename);
                }
                EditorGUILayout.LabelField("Is auto-save?", selectedSaveFile.isAutoSave.ToString());

                GUILayout.BeginHorizontal();
                GUI.enabled = Application.isPlaying;
                if (GUILayout.Button("Load"))
                {
                    SwitchActiveProfile(selectedProfileID);
                    SaveSystem.LoadGame(0, selectedSaveFile.saveID, true);
                }
                if (GUILayout.Button("Save over"))
                {
                    if (!PlayerMenus.IsSavingLocked(null, true))
                    {
                        SwitchActiveProfile(selectedProfileID);
                        SaveSystem.SaveGame(0, selectedSaveFile.saveID, true);
                    }
                }
                GUI.enabled = true;

                if (GUILayout.Button("Delete"))
                {
                    bool canDelete = EditorUtility.DisplayDialog("Delete save file?", "Are you sure you want to delete the save file " + selectedSaveFile.label + "? This operation cannot be undone.", "Yes", "No");
                    if (canDelete)
                    {
                        saveFileHandler.Delete(selectedSaveFile);
                    }
                }
                GUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showSaveData = CustomGUILayout.ToggleHeader(showSaveData, "Save game " + selectedSaveIndex + ": Data");
            if (showSaveData)
            {
                if (GUI.changed || !runCache)
                {
                    CacheSaveData(saveFileHandler, selectedSaveFile);
                }

                if (cachedSaveData != null)
                {
                    cachedSaveData.ShowGUI();
                }

                if (cachedLevelData != null)
                {
                    for (int i = 0; i < cachedLevelData.Count; i++)
                    {
                        GUILayout.Box(string.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1));
                        EditorGUILayout.LabelField("Scene data " + i.ToString() + ":", CustomStyles.subHeader);
                        cachedLevelData[i].ShowGUI();
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 9
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));
        }