mirror of
https://github.com/muskit/MercuryConverter.git
synced 2026-06-02 20:24:26 -07:00
add data reading & selection table population
This commit is contained in:
+32
-10
@@ -6,14 +6,36 @@
|
||||
xmlns:progRing="clr-namespace:AvaloniaProgressRing;assembly=AvaloniaProgressRing"
|
||||
x:Class="MercuryConverter.UI.Dialogs.DataOpen"
|
||||
>
|
||||
<StackPanel Margin="12">
|
||||
<TextBlock Text="Select your data folder..."/>
|
||||
<progRing:ProgressRing Foreground="{DynamicResource SystemBaseMediumColor}"
|
||||
Width="36"
|
||||
Height="36"
|
||||
IsActive="True"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,15,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<Panel Margin="12">
|
||||
<StackPanel Name="SelectView" IsVisible="false">
|
||||
<TextBlock FontSize="24" FontWeight="Light" Text="select your data folder..."/>
|
||||
<progRing:ProgressRing Foreground="{DynamicResource SystemBaseMediumColor}"
|
||||
Width="36"
|
||||
Height="36"
|
||||
IsActive="True"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,15,0,0"/>
|
||||
</StackPanel>
|
||||
<StackPanel Name="ScanView" IsVisible="true">
|
||||
<TextBlock Name="ScanStatus" FontSize="24" FontWeight="Light" Text="scanning..."/>
|
||||
<TextBlock Name="ScanPath" Text="/there/is/a/path/here or whatever it is askljdhflksahdfliuahleifhu"/>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
|
||||
<progRing:ProgressRing Foreground="{DynamicResource SystemBaseMediumColor}"
|
||||
Width="36"
|
||||
Height="36"
|
||||
IsActive="True"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0,15,0,0"/>
|
||||
<StackPanel Margin="0 12 0 0" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Margin="6 0 0 0" Content="Cancel" />
|
||||
<Button Margin="6 0 0 0" Content="Open Data Folder" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<!-- <StackPanel Name="SelectErrorView" IsVisible="true">
|
||||
<TextBlock FontSize="24" FontWeight="Light" Text="couldn't fully open data folder"/>
|
||||
<TextBlock Text="Unable to open PATH: ERROR"/>
|
||||
<Button HorizontalAlignment="Right" Margin="0 12 0 0" Content="Open Data Folder" />
|
||||
</StackPanel> -->
|
||||
</Panel>
|
||||
</UserControl>
|
||||
@@ -1,40 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using MercuryConverter.Data;
|
||||
using UAssetAPI;
|
||||
using UAssetAPI.UnrealTypes;
|
||||
|
||||
namespace MercuryConverter.UI.Dialogs;
|
||||
|
||||
public partial class DataOpen : Window
|
||||
public partial class DataOpen : UserControl
|
||||
{
|
||||
public static DataOpen? Instance { get; private set; }
|
||||
public DataOpen()
|
||||
{
|
||||
Instance = this;
|
||||
InitializeComponent();
|
||||
BeginDirSelection();
|
||||
|
||||
if (!Design.IsDesignMode)
|
||||
Run();
|
||||
}
|
||||
|
||||
private void BeginDirSelection()
|
||||
public void Run()
|
||||
{
|
||||
Dispatcher.UIThread.Invoke(async () =>
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var path = ""; // TODO: set to current data path
|
||||
|
||||
// Content selection
|
||||
while (true)
|
||||
{
|
||||
var selectedPath = await BeginDirSelection();
|
||||
Console.WriteLine($"selectedPath={selectedPath}");
|
||||
if (selectedPath != "" && Directory.Exists(selectedPath))
|
||||
{
|
||||
path = selectedPath;
|
||||
break;
|
||||
}
|
||||
// Display error message
|
||||
|
||||
}
|
||||
|
||||
BeginDataScan(path);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task<string> BeginDirSelection()
|
||||
{
|
||||
IReadOnlyList<IStorageFolder>? dirSelection = null;
|
||||
|
||||
await Dispatcher.UIThread.Invoke(async () =>
|
||||
{
|
||||
// Update UI
|
||||
ScanView.IsVisible = false;
|
||||
SelectView.IsVisible = true;
|
||||
|
||||
await Task.Delay(200);
|
||||
var dirSelection = await GetTopLevel(this)!.StorageProvider.OpenFolderPickerAsync
|
||||
|
||||
dirSelection = await TopLevel.GetTopLevel(MainWindow.Instance)!.StorageProvider.OpenFolderPickerAsync
|
||||
(
|
||||
new FolderPickerOpenOptions
|
||||
{
|
||||
Title = "Open Data Folder",
|
||||
Title = "Locate Data Folder",
|
||||
AllowMultiple = false,
|
||||
}
|
||||
);
|
||||
|
||||
if (dirSelection.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var d = dirSelection!.First().TryGetLocalPath()!;
|
||||
});
|
||||
|
||||
if (dirSelection!.Count <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return dirSelection!.First().TryGetLocalPath()!;
|
||||
}
|
||||
|
||||
private void BeginDataScan(string dataPath)
|
||||
{
|
||||
Console.WriteLine(dataPath);
|
||||
// Update UI
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
SelectView.IsVisible = false;
|
||||
ScanStatus.Text = "scanning...";
|
||||
ScanPath.Text = dataPath;
|
||||
ScanView.IsVisible = true;
|
||||
});
|
||||
|
||||
Database.SetupNew(dataPath);
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,15 @@
|
||||
x:Class="MercuryConverter.UI.Dialogs.Welcome"
|
||||
>
|
||||
<StackPanel Margin="12">
|
||||
<TextBlock FontSize="36" HorizontalAlignment="Center">
|
||||
Welcome to <Bold>MercuryConverter</Bold>!
|
||||
<TextBlock FontSize="24" FontWeight="Light">
|
||||
welcome to <Run FontWeight="SemiBold" Text="mercury"/>converter!
|
||||
</TextBlock>
|
||||
<TextBlock HorizontalAlignment="Center">
|
||||
<InlineUIContainer BaselineAlignment="Bottom">
|
||||
<!-- TODO: move HOWTO to this repo -->
|
||||
<HyperlinkButton Content="Setup your data folder" Padding="0" NavigateUri="https://github.com/muskit/WacK-Repackager/blob/main/HOWTO.md" />
|
||||
<TextBlock HorizontalAlignment="Left" Padding="0 6 0 0">
|
||||
<InlineUIContainer>
|
||||
<HyperlinkButton Content="Setup your data folder" Padding="0" NavigateUri="https://github.com/muskit/MercuryConverter/blob/main/HOWTO.md" />
|
||||
</InlineUIContainer>
|
||||
before proceeding.
|
||||
</TextBlock>
|
||||
<Button Content="Open Data Folder" Click="ClickHandler" HorizontalAlignment="Center" Margin="0 8 0 0" />
|
||||
<Button Content="Open Data Folder" Click="ClickHandler" HorizontalAlignment="Right" Margin="0 24 0 0" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
Reference in New Issue
Block a user