PKHeX/PKHeX.Core/Editing/Saves/Management/SavePreview.cs
Kurt 0d45075d4b
Rewrite settings handling; enhance some user experiences (#3193)
- Settings now stored as json next to exe
- Settings now exposes all legality checking setttings that can be changed
- Slot hovering now can play cries in MGDB/PKMDB/etc, not just the main boxes.
- Enhanced hover text for mystery gifts and encounters that have movesets
- Show recently loaded save files in ctrl-f browser
- Toggle auto-load savefile setting to be none/detect-latest/last-loaded
- Custom extensions & extra backup paths can now be configured directly in the json settings
- Settings editor now uses propertygrid & tabs.
2021-04-11 18:09:54 -07:00

49 lines
1.7 KiB
C#

using System.Collections.Generic;
using System.IO;
namespace PKHeX.Core
{
/// <summary>
/// Bindable Summary of a <see cref="SaveFile"/> for use in a sortable table.
/// </summary>
public sealed class SavePreview
{
public readonly SaveFile Save;
public readonly string FilePath;
public SavePreview(SaveFile sav, string parent, string path)
{
Save = sav;
Folder = parent;
FilePath = path;
}
public SavePreview(SaveFile sav, List<INamedFolderPath> paths)
{
var meta = sav.Metadata;
var dir = meta.FileFolder;
const string notFound = "???";
var parent = dir == null ? notFound : paths.Find(z => dir.StartsWith(z.Path))?.DisplayText ?? new DirectoryInfo(dir).Name;
Save = sav;
Folder = parent;
FilePath = meta.FilePath ?? notFound;
}
public string OT => Save.OT;
public int G => Save.Generation;
public GameVersion Game => Save.Version;
public string Played => Save.PlayTimeString.PadLeft(9, '0');
public string FileTime => File.GetLastWriteTimeUtc(FilePath).ToString("yyyy.MM.dd:hh:mm:ss");
public string TID => Save.Generation >= 7 ? Save.TrainerID7.ToString("000000") : Save.TID.ToString("00000");
public string SID => Save.Generation >= 7 ? Save.TrainerSID7.ToString("0000") : Save.SID.ToString("00000");
// ReSharper disable once MemberCanBePrivate.Local
// ReSharper disable once UnusedAutoPropertyAccessor.Local
public string Folder { get; }
public string Name => Path.GetFileName(FilePath);
}
}