Display autodetected path location better

Autodetect location not stored in a button path will show up as "???";
check the typical homebrew autodetect paths, then display the parent
folder

eg, Path.Combine(root, "3ds", "Checkpoint", "saves");
shave off "saves" to return X:\3ds\Checkpoint

add range checks to label translation
This commit is contained in:
Kurt
2018-07-18 19:32:57 -07:00
parent c69b50daae
commit e5d95bf178
2 changed files with 16 additions and 4 deletions

View File

@@ -51,8 +51,10 @@ public SAV_FolderList(Action<SaveFile> openSaveFile)
for (int i = 0; i < TempTranslationLabels.Count; i++)
{
var text = TempTranslationLabels[i].Text;
dgDataRecent.Columns[i].HeaderText = text;
dgDataBackup.Columns[i].HeaderText = text;
if (i < dgDataRecent.ColumnCount)
dgDataRecent.Columns[i].HeaderText = text;
if (i < dgDataBackup.ColumnCount)
dgDataBackup.Columns[i].HeaderText = text;
CB_FilterColumn.Items[i+1] = text;
}
@@ -173,7 +175,15 @@ public CustomFolderPath(string path, string display)
private string GetParentFolderName(SaveFile first)
{
var parent = Paths.Find(z => first.FileFolder.StartsWith(z.Path));
return parent?.DisplayText ?? "???";
if (parent != null)
return parent.DisplayText;
// likely an autodetect location; try to get a decent filename
var backups = PathUtilWindows.GetFoldersToCheck(Enumerable.Empty<string>());
var path = backups.FirstOrDefault(z => first.FilePath.StartsWith(z));
if (path == null)
return "???";
return Directory.GetParent(path).Name; // trim off the first subfolder of the autodetect location
}
private sealed class SaveList<T> : SortableBindingList<T> { }
@@ -344,6 +354,8 @@ private void SetRowFilter()
private void GetFilterText(DataGridView dg)
{
if (dg.RowCount == 0)
return;
var cm = (CurrencyManager)BindingContext[dg.DataSource];
cm.SuspendBinding();
int column = CB_FilterColumn.SelectedIndex - 1;

View File

@@ -114,7 +114,7 @@ public static IEnumerable<SaveFile> GetSaveFiles(IEnumerable<string> extra)
return byMostRecent.Select(SaveUtil.GetVariantSAV);
}
private static IEnumerable<string> GetFoldersToCheck(IEnumerable<string> extra)
public static IEnumerable<string> GetFoldersToCheck(IEnumerable<string> extra)
{
var foldersToCheck = extra.Where(f => f?.Length > 0);