Skip to content

Commit c781fb3

Browse files
committed
[FlashpointManager] Add support for multiple /download argument parameters
1 parent 4af4a5a commit c781fb3

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

FlashpointManager/src/Common.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ public static class FPM
190190
public static bool UpdateMode { get; set; } = false;
191191
// Controls whether the update tab is selected at launch
192192
public static bool OpenUpdateTab { get; set; } = false;
193-
// Controls which component (if any) will be automatically downloaded at launch
194-
public static string AutoDownload { get; set; } = "";
193+
// Controls components that will be automatically downloaded at launch
194+
public static List<string> AutoDownload { get; set; } = new List<string>();
195195

196196
// Total size of every downloaded component; managed by SyncManager() function
197197
public static long DownloadedSize { get; set; } = 0;

FlashpointManager/src/Forms/Main.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,17 @@ private void Main_Load(object sender, EventArgs e)
3737

3838
FPM.SyncManager();
3939

40-
if (FPM.AutoDownload.Length > 0)
40+
if (FPM.AutoDownload.Count > 0)
4141
{
42-
var query = ComponentList.Nodes.Find(FPM.AutoDownload, true);
43-
44-
if (query.Length > 0 && !query[0].Checked)
42+
foreach (string id in FPM.AutoDownload)
4543
{
46-
query[0].Checked = true;
47-
FPM.CheckDependencies(false);
48-
49-
ChangeButton_Click(this, new EventArgs());
44+
var query = ComponentList.Nodes.Find(id, true);
45+
if (query.Length > 0) query[0].Checked = true;
5046
}
5147

48+
FPM.CheckDependencies(false);
49+
ChangeButton_Click(this, new EventArgs());
50+
5251
Environment.Exit(0);
5352
}
5453

@@ -116,7 +115,7 @@ private void ChangeButton_Click(object sender, EventArgs e)
116115

117116
FPM.UpdateMode = false;
118117

119-
var operationWindow = new Operate() { TopMost = FPM.AutoDownload != "" };
118+
var operationWindow = new Operate() { TopMost = FPM.AutoDownload.Count > 0 };
120119
operationWindow.ShowDialog();
121120
}
122121

FlashpointManager/src/Forms/Operate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private async void Operation_Load(object sender, EventArgs e)
112112

113113
TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress, FPM.Main.Handle);
114114

115-
if (FPM.AutoDownload == "") FPM.SyncManager();
115+
if (FPM.AutoDownload.Count == 0) FPM.SyncManager();
116116

117117
cancelStatus = 2;
118118
Close();

FlashpointManager/src/Program.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,21 @@ static void Main(string[] args)
9696
else
9797
{
9898
// Automatically download component if /download argument is passed
99-
int index = args.ToList().FindIndex(v => v.ToLower() == "/download");
100-
if (index >= 0 && index < args.Length - 1)
99+
var argsList = args.ToList();
100+
int first = argsList.FindIndex(v => v.ToLower() == "/download");
101+
102+
if (first > -1 && first < argsList.Count - 1)
101103
{
102-
FPM.AutoDownload = args[index + 1].ToLower();
104+
int last = argsList.FindIndex(first + 1, v => v.StartsWith("/"));
105+
if (last == -1) last = argsList.Count;
106+
107+
FPM.AutoDownload.AddRange(argsList.Skip(first + 1).Take(last - first - 1));
103108
}
104109
}
105110
}
106111

107112
// Display the application window
108-
Application.Run(new Main() { Opacity = FPM.AutoDownload == "" ? 1 : 0 });
113+
Application.Run(new Main() { Opacity = FPM.AutoDownload.Count == 0 ? 1 : 0 });
109114
}
110115
}
111116
}

0 commit comments

Comments
 (0)