manager: allow parent path annotations

- Allows unlimited amount of `..\` or `../` at the start of DestPath string.
- Each of then will go back one folder.
- Similar to how Linux works or Visual Studio project styles.
- This allows us to install/update lwjgl3ify in PrismLauncher.
This commit is contained in:
Pascal
2025-06-27 09:10:18 +02:00
parent 09c1ac8b08
commit f5596ab0ba
4 changed files with 62 additions and 33 deletions

View File

@@ -36,6 +36,7 @@ partial class UpdatesCollectorUi
var resources = new System.ComponentModel.ComponentResourceManager(typeof(UpdatesCollectorUi));
tableLayoutPanel1 = new TableLayoutPanel();
radButton_Continue = new Telerik.WinControls.UI.RadButton();
radProgressBar1 = new Telerik.WinControls.UI.RadProgressBar();
radSplitContainer1 = new Telerik.WinControls.UI.RadSplitContainer();
splitPanel1 = new Telerik.WinControls.UI.SplitPanel();
tableLayoutPanel2 = new TableLayoutPanel();
@@ -44,9 +45,10 @@ partial class UpdatesCollectorUi
tableLayoutPanel3 = new TableLayoutPanel();
radListView_VersionTags = new Telerik.WinControls.UI.RadListView();
radWaitingBar1 = new Telerik.WinControls.UI.RadWaitingBar();
dotsRingWaitingBarIndicatorElement1 = new Telerik.WinControls.UI.DotsRingWaitingBarIndicatorElement();
dotsSpinnerWaitingBarIndicatorElement1 = new Telerik.WinControls.UI.DotsSpinnerWaitingBarIndicatorElement();
tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)radButton_Continue).BeginInit();
((System.ComponentModel.ISupportInitialize)radProgressBar1).BeginInit();
((System.ComponentModel.ISupportInitialize)radSplitContainer1).BeginInit();
radSplitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitPanel1).BeginInit();
@@ -64,12 +66,14 @@ partial class UpdatesCollectorUi
// tableLayoutPanel1
//
tableLayoutPanel1.AutoSize = true;
tableLayoutPanel1.ColumnCount = 2;
tableLayoutPanel1.ColumnCount = 3;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 200F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel1.Controls.Add(radButton_Continue, 1, 0);
tableLayoutPanel1.Controls.Add(radButton_Continue, 2, 0);
tableLayoutPanel1.Controls.Add(radProgressBar1, 0, 0);
tableLayoutPanel1.Dock = DockStyle.Bottom;
tableLayoutPanel1.Location = new Point(0, 420);
tableLayoutPanel1.Location = new Point(0, 419);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 1;
tableLayoutPanel1.RowStyles.Add(new RowStyle());
@@ -89,6 +93,15 @@ partial class UpdatesCollectorUi
radButton_Continue.TextAlignment = ContentAlignment.MiddleLeft;
radButton_Continue.TextImageRelation = TextImageRelation.ImageBeforeText;
//
// radProgressBar1
//
radProgressBar1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
radProgressBar1.Location = new Point(3, 3);
radProgressBar1.Name = "radProgressBar1";
radProgressBar1.Size = new Size(194, 24);
radProgressBar1.TabIndex = 2;
radProgressBar1.Visible = false;
//
// radSplitContainer1
//
radSplitContainer1.Controls.Add(splitPanel1);
@@ -96,11 +109,7 @@ partial class UpdatesCollectorUi
radSplitContainer1.Dock = DockStyle.Fill;
radSplitContainer1.Location = new Point(0, 0);
radSplitContainer1.Name = "radSplitContainer1";
//
//
//
radSplitContainer1.RootElement.MinSize = new Size(25, 25);
radSplitContainer1.Size = new Size(800, 420);
radSplitContainer1.Size = new Size(800, 419);
radSplitContainer1.TabIndex = 1;
radSplitContainer1.TabStop = false;
//
@@ -109,11 +118,7 @@ partial class UpdatesCollectorUi
splitPanel1.Controls.Add(tableLayoutPanel2);
splitPanel1.Location = new Point(0, 0);
splitPanel1.Name = "splitPanel1";
//
//
//
splitPanel1.RootElement.MinSize = new Size(25, 25);
splitPanel1.Size = new Size(516, 420);
splitPanel1.Size = new Size(516, 419);
splitPanel1.SizeInfo.AutoSizeScale = new SizeF(0.148241222F, 0F);
splitPanel1.SizeInfo.SplitterCorrection = new Size(118, 0);
splitPanel1.TabIndex = 0;
@@ -132,7 +137,7 @@ partial class UpdatesCollectorUi
tableLayoutPanel2.RowCount = 1;
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
tableLayoutPanel2.Size = new Size(516, 420);
tableLayoutPanel2.Size = new Size(516, 419);
tableLayoutPanel2.TabIndex = 1;
//
// radListView_Updates
@@ -148,7 +153,7 @@ partial class UpdatesCollectorUi
radListView_Updates.ItemSpacing = -1;
radListView_Updates.Location = new Point(3, 3);
radListView_Updates.Name = "radListView_Updates";
radListView_Updates.Size = new Size(510, 414);
radListView_Updates.Size = new Size(510, 413);
radListView_Updates.TabIndex = 0;
radListView_Updates.ViewType = Telerik.WinControls.UI.ListViewType.DetailsView;
radListView_Updates.SelectedItemChanged += RadListView_Updates_SelectedItemChanged;
@@ -159,11 +164,7 @@ partial class UpdatesCollectorUi
splitPanel2.Controls.Add(tableLayoutPanel3);
splitPanel2.Location = new Point(520, 0);
splitPanel2.Name = "splitPanel2";
//
//
//
splitPanel2.RootElement.MinSize = new Size(25, 25);
splitPanel2.Size = new Size(280, 420);
splitPanel2.Size = new Size(280, 419);
splitPanel2.SizeInfo.AutoSizeScale = new SizeF(-0.148241192F, 0F);
splitPanel2.SizeInfo.SplitterCorrection = new Size(-118, 0);
splitPanel2.TabIndex = 1;
@@ -182,7 +183,7 @@ partial class UpdatesCollectorUi
tableLayoutPanel3.RowCount = 1;
tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
tableLayoutPanel3.Size = new Size(280, 420);
tableLayoutPanel3.Size = new Size(280, 419);
tableLayoutPanel3.TabIndex = 0;
//
// radListView_VersionTags
@@ -196,7 +197,7 @@ partial class UpdatesCollectorUi
radListView_VersionTags.ItemSpacing = -1;
radListView_VersionTags.Location = new Point(3, 3);
radListView_VersionTags.Name = "radListView_VersionTags";
radListView_VersionTags.Size = new Size(274, 414);
radListView_VersionTags.Size = new Size(274, 413);
radListView_VersionTags.TabIndex = 0;
radListView_VersionTags.ViewType = Telerik.WinControls.UI.ListViewType.DetailsView;
radListView_VersionTags.SelectedIndexChanged += RadListView_VersionTags_SelectedIndexChanged;
@@ -204,27 +205,26 @@ partial class UpdatesCollectorUi
// radWaitingBar1
//
radWaitingBar1.AssociatedControl = radListView_Updates;
radWaitingBar1.Location = new Point(0, 0);
radWaitingBar1.Location = new Point(220, 171);
radWaitingBar1.Name = "radWaitingBar1";
radWaitingBar1.Size = new Size(70, 70);
radWaitingBar1.TabIndex = 2;
radWaitingBar1.Text = "radWaitingBar1";
radWaitingBar1.WaitingIndicators.Add(dotsRingWaitingBarIndicatorElement1);
radWaitingBar1.WaitingIndicators.Add(dotsSpinnerWaitingBarIndicatorElement1);
radWaitingBar1.WaitingIndicatorSize = new Size(100, 14);
radWaitingBar1.WaitingSpeed = 50;
radWaitingBar1.WaitingStyle = Telerik.WinControls.Enumerations.WaitingBarStyles.DotsRing;
radWaitingBar1.WaitingSpeed = 100;
radWaitingBar1.WaitingStyle = Telerik.WinControls.Enumerations.WaitingBarStyles.DotsSpinner;
//
// dotsRingWaitingBarIndicatorElement1
// dotsSpinnerWaitingBarIndicatorElement1
//
dotsRingWaitingBarIndicatorElement1.Name = "dotsRingWaitingBarIndicatorElement1";
dotsSpinnerWaitingBarIndicatorElement1.Name = "dotsSpinnerWaitingBarIndicatorElement1";
//
// UpdatesCollectorUi
//
AutoScaleBaseSize = new Size(7, 15);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(radWaitingBar1);
ClientSize = new Size(800, 449);
Controls.Add(radSplitContainer1);
Controls.Add(tableLayoutPanel1);
Icon = (Icon)resources.GetObject("$this.Icon");
@@ -234,6 +234,7 @@ partial class UpdatesCollectorUi
Shown += UpdatesCollectorUi_Shown;
tableLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)radButton_Continue).EndInit();
((System.ComponentModel.ISupportInitialize)radProgressBar1).EndInit();
((System.ComponentModel.ISupportInitialize)radSplitContainer1).EndInit();
radSplitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitPanel1).EndInit();
@@ -261,6 +262,7 @@ partial class UpdatesCollectorUi
private TableLayoutPanel tableLayoutPanel3;
private Telerik.WinControls.UI.RadListView radListView_Updates;
private Telerik.WinControls.UI.RadWaitingBar radWaitingBar1;
private Telerik.WinControls.UI.DotsRingWaitingBarIndicatorElement dotsRingWaitingBarIndicatorElement1;
private Telerik.WinControls.UI.RadListView radListView_VersionTags;
private Telerik.WinControls.UI.RadProgressBar radProgressBar1;
private Telerik.WinControls.UI.DotsSpinnerWaitingBarIndicatorElement dotsSpinnerWaitingBarIndicatorElement1;
}

View File

@@ -42,6 +42,12 @@ public partial class UpdatesCollectorUi : RadForm
{
var updates = await factory.FindUpdates(action, workspace.ModpackConfig?.MinecraftVersion, workspace.ModpackConfig?.ModLoader ?? ModLoader.Any);
BeginInvoke(() =>
{
radProgressBar1.Value1 += 1;
radProgressBar1.Text = $"{radProgressBar1.Value1} / {radProgressBar1.Maximum}";
});
if (updates == null || updates.Length == 0 || updates[0].Value == action.SourceTag)
continue;
@@ -96,8 +102,15 @@ public partial class UpdatesCollectorUi : RadForm
private async void UpdatesCollectorUi_Shown(object sender, EventArgs e)
{
radWaitingBar1.StartWaiting();
radProgressBar1.Value1 = 0;
radProgressBar1.Maximum = actions.Length;
radProgressBar1.Text = null;
radProgressBar1.Visible = true;
CurrentUpdates = await FindUpdates();
LoadUpdates(CurrentUpdates);
radProgressBar1.Visible = false;
radWaitingBar1.StopWaiting();
}

View File

@@ -67,4 +67,18 @@ public static class Extensions
return @this.UpdateUrl?.Replace("{ref}", @this.RefTag);
return @this.UpdateUrl;
}
public static string GetDestPath(this InstallAction @this, string installDir)
{
var path = @this.DestPath;
var root = Path.GetPathRoot(path);
var start = installDir;
while (root.Length == 3 && root.StartsWith(".."))
{
path = path[root.Length..];
root = Path.GetPathRoot(path);
start = Path.GetDirectoryName(start);
}
return Path.Combine(start, path);
}
}

View File

@@ -153,7 +153,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
foreach (InstallAction iaction in checkResult.Actions)
{
var destFilePath = Path.Combine(modpackInfo.LocaLPath, iaction.DestPath);
var destFilePath = iaction.GetDestPath(modpackInfo.LocaLPath);
var sourceUrl = updateConfig.PreferDirectLinks && !string.IsNullOrWhiteSpace(iaction.SourceUrl)
? iaction.GetSourceUrl(checkResult.LatestVersion, overwriteVersion: OverwriteVersion)
: await factory.ResolveSourceUrl(iaction, targetVersion: checkResult.LatestVersion, overwriteVersion: OverwriteVersion);