feat: restore product-specific legacy project selection

This commit is contained in:
codex
2026-08-06 13:02:49 +03:00
parent 5c812f87fd
commit 72f127a427
3 changed files with 203 additions and 2 deletions
+67 -2
View File
@@ -15,8 +15,18 @@ public partial class MainWindow : System.Windows.Window
private readonly LegacyConfigurationAdapter adapter=new();
private LauncherProduct? selected;
private string? projectPath;
public MainWindow() { InitializeComponent(); Initialize(); }
internal MainWindow(LocalParityLaunchProfile profile) { localProfile=profile; InitializeComponent(); Initialize(); }
private string? manualRosterPath;
public MainWindow() { InitializeComponent(); WireSourceVerifiedSelection(); Initialize(); }
internal MainWindow(LocalParityLaunchProfile profile) { localProfile=profile; InitializeComponent(); WireSourceVerifiedSelection(); Initialize(); }
private void WireSourceVerifiedSelection()
{
SelectProjectButton.Click -= SelectProject_Click;
SelectProjectButton.Click += SelectProjectFile_Click;
AutomaticMode.Checked -= LoadMode_Changed;
ListMode.Checked -= LoadMode_Changed;
AutomaticMode.Checked += LoadModeChanged;
ListMode.Checked += LoadModeChanged;
}
private void Initialize()
{
var plant=new PlantProductDiscovery(new WindowsRegistryReader()).DiscoverPlant3D(2026);
@@ -34,7 +44,62 @@ public partial class MainWindow : System.Windows.Window
var path=Path.GetFullPath(dialog.FolderName); if(!Directory.Exists(path)){Status.Text="Выбранная папка недоступна.";return;} if(selected.Id is "plant3d" or "pnid" && !File.Exists(Path.Combine(path,"Project.xml"))){Status.Text="Выбранная папка не является проектом Plant 3D.";return;}
projectPath=path; ProjectPath.Text=path; ResolvePlugins();
}
private void SelectProjectFile_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (selected is null) return;
var product = LegacyProductSelections.For(selected.Id);
var dialog = new Microsoft.Win32.OpenFileDialog { Title = "Select project", Filter = product.Filter, CheckFileExists = true, Multiselect = false };
if (dialog.ShowDialog() != true) return;
try
{
projectPath = LegacyProductSelections.ValidateSelectedFile(product, dialog.FileName);
manualRosterPath = null;
ProjectPath.Text = Path.GetFileName(projectPath);
ResolvePluginsSourceVerified();
}
catch (Exception ex) { Status.Text = UserMessage(ex.Message); }
}
private void LoadModeChanged(object sender, System.Windows.RoutedEventArgs e)
{
if (projectPath is null || selected is null) return;
if (ListMode.IsChecked == true)
{
var dialog = new Microsoft.Win32.OpenFileDialog { Title = "Select download_list.xml", Filter = "download_list.xml (*.xml)|*.xml|All files (*.*)|*.*", CheckFileExists = true, Multiselect = false };
if (dialog.ShowDialog() != true) { AutomaticMode.IsChecked = true; return; }
manualRosterPath = dialog.FileName;
}
else manualRosterPath = null;
ResolvePluginsSourceVerified();
}
private void LoadMode_Changed(object sender,System.Windows.RoutedEventArgs e) { if(projectPath is not null)ResolvePlugins(); }
private void ResolvePluginsSourceVerified()
{
if (selected is null || projectPath is null) return;
if (localProfile is not null && selected.Id == "plant3d") { ResolvePlugins(); return; }
try
{
var product = LegacyProductSelections.For(selected.Id);
var plan = LegacyProductSelections.ReadRoster(product, projectPath, manualRosterPath, adapter);
Plugins.ItemsSource = plan.OrderedIds;
Plugins.IsEnabled = false;
PluginStatus.Text = $"List source: {plan.Source}.";
StartButton.IsEnabled = false;
Status.Text = plan.UnmappedIds.Count == 0
? "Packages for the selected plugins are not mapped to 2026 packages."
: $"Packages for {product.DisplayName} are not yet available for 2026: {string.Join(", ", plan.UnmappedIds)}";
}
catch (Exception ex)
{
Plugins.ItemsSource = null;
Plugins.IsEnabled = false;
StartButton.IsEnabled = false;
Status.Text = ex.Message == "LEGACY_DOWNLOAD_LIST_NOT_FOUND"
? "Для выбранного проекта не найден список плагинов"
: UserMessage(ex.Message);
}
}
private void ResolvePlugins()
{
if(selected is null||projectPath is null)return;