Beispiel #1
0
        private void ShouldDeleteSaves()
        {
            int[] currentKeys = GameManager.Instance.SaveLoadManager.GetCharacterSaveKeys(GameManager.Instance.PlayerEntity.Name);

            if (currentKeys.Length >= autosaveLimit)
            {
                List <SaveInfo_v1> saveList = new List <SaveInfo_v1>();
                foreach (var key in currentKeys)
                {
                    SaveInfo_v1 saveFolder = GameManager.Instance.SaveLoadManager.GetSaveInfo(key);
                    if (saveFolder.saveName.Contains("Autosave"))
                    {
                        saveList.Add(saveFolder);
                    }
                }

                saveList.Sort(delegate(SaveInfo_v1 sv1, SaveInfo_v1 sv2) {
                    return(sv1.dateAndTime.realTime.CompareTo(sv2.dateAndTime.realTime));
                });

                while (saveList.Count >= autosaveLimit)
                {
                    SaveInfo_v1 saveToDelete = saveList[0];
                    int         saveIdx      = GameManager.Instance.SaveLoadManager.FindSaveFolderByNames(GameManager.Instance.PlayerEntity.Name, saveToDelete.saveName);
                    GameManager.Instance.SaveLoadManager.DeleteSaveFolder(saveIdx);
                    saveList.RemoveAt(0);
                }
            }
        }
Beispiel #2
0
        void UpdateSavesList()
        {
            // Clear saves list
            savesList.ClearItems();

            // Get most recent save
            int mostRecentSave = GameManager.Instance.SaveLoadManager.FindMostRecentSave();

            if (mode == Modes.LoadGame && mostRecentSave == -1)
            {
                // No saves found, prompt to load a classic save
                promptLabel.Text = HardStrings.noSavesFound;
                return;
            }
            else
            {
                // If set to display most recent character use that instead
                if (displayMostRecentChar)
                {
                    SaveInfo_v1 latestSaveInfo = GameManager.Instance.SaveLoadManager.GetSaveInfo(mostRecentSave);
                    currentPlayerName = latestSaveInfo.characterName;
                }
            }

            // Build list of saves
            List <SaveInfo_v1> saves = new List <SaveInfo_v1>();

            int[] saveKeys = GameManager.Instance.SaveLoadManager.GetCharacterSaveKeys(currentPlayerName);
            foreach (int key in saveKeys)
            {
                SaveInfo_v1 saveInfo = GameManager.Instance.SaveLoadManager.GetSaveInfo(key);
                saves.Add(saveInfo);
            }

            // Order by save time
            List <SaveInfo_v1> orderedSaves = saves.OrderByDescending(o => o.dateAndTime.realTime).ToList();

            // Updates saves list
            foreach (SaveInfo_v1 saveInfo in orderedSaves)
            {
                savesList.AddItem(saveInfo.saveName);
            }
            savesScroller.TotalUnits = savesList.Count;

            // Update prompt
            string promptText = string.Empty;

            if (mode == Modes.SaveGame)
            {
                promptText = savePromptText;
            }
            else if (mode == Modes.LoadGame)
            {
                promptText = loadPromptText;
            }
            promptLabel.Text = string.Format("{0} for '{1}'", promptText, currentPlayerName);
        }
        void UpdateSelectedSaveInfo()
        {
            // Clear info if no save selected
            if (saveNameTextBox.Text.Length == 0 || savesList.SelectedIndex < 0)
            {
                screenshotPanel.BackgroundTexture = null;
                saveVersionLabel.Text             = string.Empty;
                saveFolderLabel.Text             = string.Empty;
                saveTimeLabel.Text               = string.Empty;
                gameTimeLabel.Text               = string.Empty;
                renameSaveButton.BackgroundColor = namePanelBackgroundColor;
                deleteSaveButton.BackgroundColor = namePanelBackgroundColor;
                return;
            }

            // Get save key
            int key = GameManager.Instance.SaveLoadManager.FindSaveFolderByNames(currentPlayerName, saveNameTextBox.Text);

            if (key == -1)
            {
                return;
            }

            // Destroy old background texture
            if (screenshotPanel.BackgroundTexture)
            {
                UnityEngine.Object.Destroy(screenshotPanel.BackgroundTexture);
                screenshotPanel.BackgroundTexture = null;
            }

            // Get save info and texture
            string      path        = GameManager.Instance.SaveLoadManager.GetSaveFolder(key);
            SaveInfo_v1 saveInfo    = GameManager.Instance.SaveLoadManager.GetSaveInfo(key);
            Texture2D   saveTexture = GameManager.Instance.SaveLoadManager.GetSaveScreenshot(key);

            if (saveTexture != null)
            {
                screenshotPanel.BackgroundTexture = saveTexture;
            }

            // Show save info
            DaggerfallDateTime dfDateTime = new DaggerfallDateTime();

            dfDateTime.FromSeconds(saveInfo.dateAndTime.gameTime);
            saveVersionLabel.Text            = string.Format("V{0}", saveInfo.saveVersion);
            saveFolderLabel.Text             = Path.GetFileName(path);
            saveTimeLabel.Text               = DateTime.FromBinary(saveInfo.dateAndTime.realTime).ToLongDateString();
            gameTimeLabel.Text               = dfDateTime.MidDateTimeString();
            renameSaveButton.BackgroundColor = saveButtonBackgroundColor;
            deleteSaveButton.BackgroundColor = cancelButtonBackgroundColor;
        }