Interkarma / daggerfall-unity

Open source recreation of Daggerfall in the Unity engine
http://www.dfworkshop.net
MIT License
2.7k stars 327 forks source link

Added checkbox to show hidden folders during Daggerfall setup #2584

Closed KABoissonneault closed 5 months ago

KABoissonneault commented 6 months ago

Fixes #2487. Steam installs DF in a hidden folder by default on Linux, so it's pretty essential for these users.

image

image

I can find a DF installation in AppData just fine :)

image

KABoissonneault commented 6 months ago

On another subject, anyone knows why the path is limited to 43 characters? Can we increase that a bit, or does that break low resolutions?

KABoissonneault commented 5 months ago

This change should be a pretty quick review, and solves an important issue for Linux and Steam Deck users, and has no impact on the rest of the game.

petchema commented 5 months ago

I had the issue of ".." disappearing when toggling the "show hidden files" checkbox, at first I thought it could be because it's a hidden name, but it turns out the reason is that the ".." entry is handled specifically, and not inside RefreshFolders(). I can fix it by lifting that handling from FolderList_OnUseSelectedItem() to RefreshFolders(), hopefully this doesn't break anything?

diff --git a/Assets/Scripts/Game/UserInterface/FolderBrowser.cs b/Assets/Scripts/Game/UserInterface/FolderBrowser.cs
index 6eb38eced..cb0dbb66f 100644
--- a/Assets/Scripts/Game/UserInterface/FolderBrowser.cs
+++ b/Assets/Scripts/Game/UserInterface/FolderBrowser.cs
@@ -28,6 +28,8 @@ namespace DaggerfallWorkshop.Game.UserInterface
     /// </summary>
     public class FolderBrowser : Panel
     {
+        private const string parentDirectory = "..";
+
         int confirmButtonWidth = 35;
         int drivePanelWidth = 40;
         int pathPanelHeight = 12;
@@ -209,6 +211,11 @@ namespace DaggerfallWorkshop.Game.UserInterface
         {
             folders.Clear();
             folderList.ClearItems();
+
+            // Add return path
+            if (currentPath != drives[driveList.SelectedIndex])
+                folderList.AddItem(parentDirectory);
+
             try
             {
                 string[] directoryList = Directory.GetDirectories(currentPath);
@@ -332,7 +339,7 @@ namespace DaggerfallWorkshop.Game.UserInterface

             // Get new path
             string newPath = string.Empty;
-            if (folderList.SelectedItem == "..")
+            if (folderList.SelectedItem == parentDirectory)
             {
                 // Handle return path
                 DirectoryInfo info = new DirectoryInfo(currentPath);
@@ -351,14 +358,6 @@ namespace DaggerfallWorkshop.Game.UserInterface
                 currentPath = newPath;
                 RefreshFolders();
                 RaisePathChangedEvent();
-
-                // Add return path
-                if (currentPath != drives[driveList.SelectedIndex])
-                    folderList.AddItem("..", 0);
-
-                // Update scroller units
-                folderScroller.TotalUnits = folderList.Count;
-
                 UpdatePathText();
             }
         }