Example #1
0
        /**
         * <summary>Renames a profile.</summary>
         * <param name = "newProfileLabel">The new label for the profile</param>
         * <param name = "profileIndex">The index in the MenuProfilesList element that represents the profile to delete. If it is set to its default, -2, the active profile will be deleted</param>
         * <param name = "includeActive">If True, then the MenuProfilesList element that the profile was selected from also displays the active profile</param>
         */
        public void RenameProfile(string newProfileLabel, int profileIndex = -2, bool includeActive = true)
        {
            if (!KickStarter.settingsManager.useProfiles || newProfileLabel.Length == 0)
            {
                return;
            }

            int profileID = KickStarter.options.ProfileIndexToID(profileIndex, includeActive);

            if (profileID == -1)
            {
                ACDebug.LogWarning("Invalid profile index: " + profileIndex + " - nothing to delete!");
                return;
            }
            else if (profileIndex == -2)
            {
                profileID = Options.GetActiveProfileID();
            }

            if (profileID == GetActiveProfileID())
            {
                optionsData.label = newProfileLabel;
                SavePrefs();
            }
            else if (PlayerPrefs.HasKey(GetPrefKeyName(profileID)))
            {
                OptionsData tempOptionsData = LoadPrefsFromID(profileID, false);
                tempOptionsData.label = newProfileLabel;
                SavePrefsToID(profileID, tempOptionsData, true);
            }

            KickStarter.playerMenus.RecalculateAll();
        }
Example #2
0
 private void SwitchActiveProfile(int profileID)
 {
     if (Options.GetActiveProfileID() != profileID)
     {
         Options.SwitchProfileID(profileID);
     }
 }
        protected string GetImportFilename(int saveID, string filePrefix, int profileID = -1)
        {
            if (profileID == -1)
            {
                profileID = Options.GetActiveProfileID();
            }

            return(filePrefix + KickStarter.saveSystem.GenerateSaveSuffix(saveID, profileID));
        }
        protected string GetSaveFilename(int saveID, int profileID = -1)
        {
            if (profileID == -1)
            {
                profileID = Options.GetActiveProfileID();
            }

            return(KickStarter.settingsManager.SavePrefix + KickStarter.saveSystem.GenerateSaveSuffix(saveID, profileID));
        }
        private string GetSaveFilename(int saveID, int profileID = -1, string extensionOverride = "")
        {
            if (profileID == -1)
            {
                profileID = Options.GetActiveProfileID();
            }

            string extension = (!string.IsNullOrEmpty(extensionOverride)) ? extensionOverride : KickStarter.saveSystem.GetSaveExtension();

            return(KickStarter.settingsManager.SavePrefix + KickStarter.saveSystem.GenerateSaveSuffix(saveID, profileID) + extension);
        }
Example #6
0
        private static void StatusWindow(int windowID)
        {
            if (sceneManagerSkin == null)
            {
                sceneManagerSkin = (GUISkin)Resources.Load("SceneManagerSkin");
            }
            GUI.skin = sceneManagerSkin;

            GUILayout.Label("Current game state: " + KickStarter.stateHandler.gameState.ToString());

            if (KickStarter.settingsManager.useProfiles)
            {
                GUILayout.Label("Current profile ID: " + Options.GetActiveProfileID());
            }

            if (KickStarter.player != null)
            {
                if (GUILayout.Button("Current player: " + KickStarter.player.gameObject.name))
                {
                                        #if UNITY_EDITOR
                    UnityEditor.EditorGUIUtility.PingObject(KickStarter.player.gameObject);
                                        #endif
                }
            }

            if (KickStarter.mainCamera != null)
            {
                KickStarter.mainCamera.DrawStatus();
            }

            if (KickStarter.stateHandler.gameState == GameState.DialogOptions && KickStarter.playerInput.IsInConversation())
            {
                if (GUILayout.Button("Conversation: " + KickStarter.playerInput.activeConversation.gameObject.name))
                {
                                        #if UNITY_EDITOR
                    UnityEditor.EditorGUIUtility.PingObject(KickStarter.playerInput.activeConversation.gameObject);
                                        #endif
                }
            }

            GUILayout.Space(4f);

            KickStarter.actionListManager.DrawStatus();
            KickStarter.actionListAssetManager.DrawStatus();

            if (KickStarter.actionListManager.IsGameplayBlocked())
            {
                GUILayout.Space(4f);
                GUILayout.Label("Gameplay is blocked");
            }

            GUI.DragWindow();
        }
Example #7
0
        /**
         * <summary>Renames a profile by referencing its entry in a MenuProfilesList element.</summary>
         * <param name = "newProfileLabel">The new label for the profile</param>
         * <param name = "profileIndex">The index in the MenuProfilesList element that represents the profile to rename. If it is set to its default, -2, the active profile will be renamed</param>
         * <param name = "includeActive">If True, then the MenuProfilesList element that the profile was selected from also displays the active profile</param>
         */
        public void RenameProfile(string newProfileLabel, int profileIndex = -2, bool includeActive = true)
        {
            if (!KickStarter.settingsManager.useProfiles || string.IsNullOrEmpty(newProfileLabel))
            {
                return;
            }

            int profileID = KickStarter.options.ProfileIndexToID(profileIndex, includeActive);

            if (profileID == -1)
            {
                ACDebug.LogWarning("Invalid profile index: " + profileIndex + " - nothing to delete!");
                return;
            }
            else if (profileIndex == -2)
            {
                profileID = Options.GetActiveProfileID();
            }

            RenameProfileID(newProfileLabel, profileID);
        }
Example #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();
        }
Example #9
0
        private void StatusWindow(int windowID)
        {
            GUISkin testSkin = (GUISkin)Resources.Load("SceneManagerSkin");

            GUI.skin = testSkin;

            GUILayout.Label("Current game state: " + KickStarter.stateHandler.gameState.ToString());

            if (KickStarter.settingsManager.useProfiles)
            {
                GUILayout.Label("Current profile ID: " + Options.GetActiveProfileID());
            }

            if (KickStarter.player != null)
            {
                if (GUILayout.Button("Current player: " + KickStarter.player.gameObject.name))
                {
                                        #if UNITY_EDITOR
                    UnityEditor.EditorGUIUtility.PingObject(KickStarter.player.gameObject);
                                        #endif
                }
            }

            if (KickStarter.mainCamera != null && KickStarter.mainCamera.attachedCamera != null && KickStarter.mainCamera.IsEnabled())
            {
                if (GUILayout.Button("Current camera: " + KickStarter.mainCamera.attachedCamera.gameObject.name))
                {
                                        #if UNITY_EDITOR
                    UnityEditor.EditorGUIUtility.PingObject(KickStarter.mainCamera.attachedCamera.gameObject);
                                        #endif
                }
            }

            if (KickStarter.stateHandler.gameState == GameState.DialogOptions && KickStarter.playerInput.IsInConversation())
            {
                if (GUILayout.Button("Conversation: " + KickStarter.playerInput.activeConversation.gameObject.name))
                {
                                        #if UNITY_EDITOR
                    UnityEditor.EditorGUIUtility.PingObject(KickStarter.playerInput.activeConversation.gameObject);
                                        #endif
                }
            }

            GUILayout.Space(4f);

            bool anyRunning = false;
            foreach (ActiveList activeList in activeLists)
            {
                if (activeList.IsRunning())
                {
                    anyRunning = true;
                    break;
                }
            }

            if (anyRunning)
            {
                GUILayout.Label("ActionLists running:");

                for (int i = 0; i < activeLists.Count; i++)
                {
                    activeLists[i].ShowGUI();
                }
            }

            anyRunning = false;
            foreach (ActiveList activeList in KickStarter.actionListAssetManager.activeLists)
            {
                if (activeList.IsRunning())
                {
                    anyRunning = true;
                    break;
                }
            }

            if (anyRunning)
            {
                GUILayout.Label("ActionList Assets running:");

                foreach (ActiveList activeList in KickStarter.actionListAssetManager.activeLists)
                {
                    activeList.ShowGUI();
                }
            }

            if (IsGameplayBlocked())
            {
                GUILayout.Space(4f);
                GUILayout.Label("Gameplay is blocked");
            }

            GUI.DragWindow();
        }