/// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="source">Source time to copy from.</param>
 public DaggerfallDateTime(DaggerfallDateTime source)
 {
     Year   = source.Year;
     Month  = source.Month;
     Day    = source.Day;
     Hour   = source.Hour;
     Minute = source.Minute;
     Second = source.Second;
 }
 /// <summary>
 /// True when this date time is greater than another date time.
 /// </summary>
 public bool GreaterThan(DaggerfallDateTime other)
 {
     if (this.ToSeconds() > other.ToSeconds())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 /// <summary>
 /// True when date times are equal.
 /// </summary>
 public bool Equals(DaggerfallDateTime other)
 {
     if (other.ToSeconds() == this.ToSeconds())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        /// <summary>
        /// Clone time to a new instance.
        /// </summary>
        /// <returns>DaggerfallDateTime clone.</returns>
        public DaggerfallDateTime Clone()
        {
            DaggerfallDateTime clone = new DaggerfallDateTime();

            clone.Year   = Year;
            clone.Month  = Month;
            clone.Day    = Day;
            clone.Hour   = Hour;
            clone.Minute = Minute;
            clone.Second = Second;

            return(clone);
        }
        void DisplaySaveStatsGUI()
        {
            if (currentSaveTree == null)
                return;

            EditorGUILayout.Space();
            GUILayoutHelper.Horizontal(() =>
            {
                EditorGUILayout.LabelField(new GUIContent("Version"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(currentSaveTree.Header.Version.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                string positionText = string.Format("X={0}, Y={1}, Z={2}, Base={3}",
                    currentSaveTree.Header.CharacterPosition.Position.WorldX,
                    currentSaveTree.Header.CharacterPosition.Position.YOffset,
                    currentSaveTree.Header.CharacterPosition.Position.WorldZ,
                    currentSaveTree.Header.CharacterPosition.Position.YBase);

                EditorGUILayout.LabelField(new GUIContent("Player Position", "Position of player in the world."), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(positionText, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                DFPosition mapPixel = MapsFile.WorldCoordToMapPixel(currentSaveTree.Header.CharacterPosition.Position.WorldX, currentSaveTree.Header.CharacterPosition.Position.WorldZ);
                string mapPixelText = string.Format("X={0}, Y={1}", mapPixel.X, mapPixel.Y);

                EditorGUILayout.LabelField(new GUIContent("Player Map Pixel", "Position of player on small map."), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(mapPixelText, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                DaggerfallDateTime time = new DaggerfallDateTime();
                time.FromClassicDaggerfallTime(currentSaveVars.GameTime);

                EditorGUILayout.LabelField(new GUIContent("Player Time", "World time of this save."), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(time.LongDateTimeString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                EditorGUILayout.LabelField(new GUIContent("LocationDetail records"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(currentSaveTree.LocationDetail.RecordCount.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            GUILayoutHelper.Horizontal(() =>
            {
                EditorGUILayout.LabelField(new GUIContent("RecordElement records"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                EditorGUILayout.SelectableLabel(currentSaveTree.RecordDictionary.Count.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            });
            //GUILayoutHelper.Horizontal(() =>
            //{
            //    EditorGUILayout.LabelField(new GUIContent("Header.Unknown"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
            //    EditorGUILayout.SelectableLabel(currentSaveTree.Header.Unknown.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            //});
            //GUILayoutHelper.Horizontal(() =>
            //{
            //    EditorGUILayout.LabelField(new GUIContent("CharacterPosition.Unknown"), GUILayout.Width(EditorGUIUtility.labelWidth - 4));
            //    EditorGUILayout.SelectableLabel(currentSaveTree.Header.CharacterPosition.Unknown.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            //});
        }
        public static int GetNatureArchive(DFLocation.ClimateTextureSet climateTextureSet, DaggerfallDateTime.Seasons worldSeason)
        {
            ClimateNatureSets natureSet = FromAPITextureSet(climateTextureSet);
            ClimateSeason climateSeason = ClimateSeason.Summer;
            if (worldSeason == DaggerfallDateTime.Seasons.Winter)
                climateSeason = ClimateSeason.Winter;

            return GetNatureArchive(natureSet, climateSeason);
        }
        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;
                deleteSaveButton.BackgroundColor = namePanelBackgroundColor;
                return;
            }

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

            // 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();
            deleteSaveButton.BackgroundColor = cancelButtonBackgroundColor;
        }
 /// <summary>
 /// True when this date time is less than another date time.
 /// </summary>
 public bool LessThan(DaggerfallDateTime other)
 {
     if (this.ToSeconds() < other.ToSeconds())
         return true;
     else
         return false;
 }
 /// <summary>
 /// True when date times are equal.
 /// </summary>
 public bool Equals(DaggerfallDateTime other)
 {
     if (other.ToSeconds() == this.ToSeconds())
         return true;
     else
         return false;
 }