Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions Assets/Scripts/Game/UserInterface/FolderBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,6 +47,7 @@ public class FolderBrowser : Panel
VerticalScrollBar folderScroller = new VerticalScrollBar();
TextLabel pathLabel = new TextLabel();
Button confirmButton = new Button();
Checkbox showHiddenFilesCheck = new Checkbox();
Vector2 lastSize;

Color unselectedColor = new Color(0.8f, 0.8f, 0.8f, 1.0f);
Expand Down Expand Up @@ -136,6 +139,7 @@ void Setup()
Components.Add(folderPanel);
Components.Add(pathPanel);
Components.Add(confirmButton);
Components.Add(showHiddenFilesCheck);
AdjustPanels();

// Setup drive list
Expand Down Expand Up @@ -164,6 +168,12 @@ void Setup()
//folderScroller.OnScrollUp += FolderScroller_OnScrollUp;
//folderScroller.OnScrollDown += FolderScroller_OnScrollDown;

showHiddenFilesCheck.Label.Text = TextManager.Instance.GetText("MainMenu", "hiddenFolders");
showHiddenFilesCheck.Label.TextColor = unselectedColor;
showHiddenFilesCheck.CheckBoxColor = unselectedColor;
showHiddenFilesCheck.IsChecked = false;
showHiddenFilesCheck.OnToggleState += HiddenFileCheck_OnToggleState;

// Setup initial folder conditions
RefreshDrives();
RefreshFolders();
Expand Down Expand Up @@ -201,14 +211,19 @@ void RefreshFolders()
{
folders.Clear();
folderList.ClearItems();

// Add return path
if (currentPath != drives[driveList.SelectedIndex])
folderList.AddItem(parentDirectory);

try
{
string[] directoryList = Directory.GetDirectories(currentPath);

foreach (var directory in directoryList)
{
DirectoryInfo info = new DirectoryInfo(directory);
if ((info.Attributes & FileAttributes.Hidden) == 0)
if (showHiddenFilesCheck.IsChecked || (info.Attributes & FileAttributes.Hidden) == 0)
{
string name = Path.GetFileName(directory);
folders.Add(name);
Expand Down Expand Up @@ -280,6 +295,8 @@ void AdjustPanels()
confirmButton.Outline.Enabled = true;
confirmButton.Label.Text = confirmButtonText;
//confirmButton.Label.ShadowPosition = Vector2.zero;

showHiddenFilesCheck.Position = new Vector2(pathPanel.Position.x, pathPanel.Position.y + pathPanel.Size.y + 4);
}

void UpdatePathText()
Expand Down Expand Up @@ -322,7 +339,7 @@ private void FolderList_OnUseSelectedItem()

// Get new path
string newPath = string.Empty;
if (folderList.SelectedItem == "..")
if (folderList.SelectedItem == parentDirectory)
{
// Handle return path
DirectoryInfo info = new DirectoryInfo(currentPath);
Expand All @@ -342,13 +359,6 @@ private void FolderList_OnUseSelectedItem()
RefreshFolders();
RaisePathChangedEvent();

// Add return path
if (currentPath != drives[driveList.SelectedIndex])
folderList.AddItem("..", 0);

// Update scroller units
folderScroller.TotalUnits = folderList.Count;

UpdatePathText();
}
}
Expand All @@ -371,6 +381,11 @@ private void ConfirmButton_OnMouseClick(BaseScreenComponent sender, Vector2 posi
FolderList_OnUseSelectedItem();
}

private void HiddenFileCheck_OnToggleState()
{
RefreshFolders();
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void ShowGameFolderStage()
// Add help text
findArena2Tip = GetText("findArena2Tip");
pathValidated = GetText("pathValidated");
helpLabel.Position = new Vector2(0, 145);
helpLabel.Position = new Vector2(0, 150);
helpLabel.HorizontalAlignment = HorizontalAlignment.Center;
helpLabel.ShadowPosition = Vector2.zero;
helpLabel.Text = findArena2Tip;
Expand Down
1 change: 1 addition & 0 deletions Assets/StreamingAssets/Text/MainMenu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ missingWoods, it's missing WOODS.WLD
missingVideos, it's missing one or more .VID files
justNotValid, it does not appear to be valid
pathValidated, Great! This looks like a valid Daggerfall folder :)
hiddenFolders, Show Hidden Folders
testText, Test
okText, OK
keepSetting, Keep this setting? Changes will revert in 8 seconds.
Expand Down