Skip to content

Commit 38749ce

Browse files
committed
[FlashpointManager] Improve operation performance, progress display
1 parent e556171 commit 38749ce

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

FlashpointManager/src/Common.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public static TreeNode AddNodeToList(XmlNode child, TreeNodeCollection parent)
271271
}
272272

273273
// Refreshes component lists and tracker objects with up-to-date information
274-
public static void SyncManager()
274+
public static void SyncManager(bool init = false)
275275
{
276276
ComponentTracker.Downloaded.Clear();
277277
ComponentTracker.Outdated.Clear();
@@ -286,13 +286,17 @@ public static void SyncManager()
286286
if (component.Downloaded)
287287
{
288288
ComponentTracker.Downloaded.Add(component);
289-
node.Checked = true;
289+
if (!node.Checked) node.Checked = true;
290290
}
291-
else
291+
else if (node.Checked)
292292
{
293293
node.Checked = false;
294294
}
295295
}
296+
else if (init)
297+
{
298+
node.Checked = node.Checked;
299+
}
296300
});
297301

298302
DownloadedSize = ComponentTracker.Downloaded.Sum(c => long.Parse(File.ReadLines(c.InfoFile).First().Split(' ')[1]));

FlashpointManager/src/Forms/Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private void Main_Load(object sender, EventArgs e)
3535
}
3636
}
3737

38-
FPM.SyncManager();
38+
FPM.SyncManager(true);
3939

4040
if (FPM.AutoDownload.Count > 0)
4141
{

FlashpointManager/src/Forms/Operate.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ private async void Operation_Load(object sender, EventArgs e)
7373
}
7474
}
7575

76-
byteTotal = removedComponents.Concat(addedComponents).Sum(c => c.Size);
76+
byteTotal = FPM.UpdateMode
77+
? addedComponents.Sum(c => c.Size)
78+
: addedComponents.Concat(removedComponents).Sum(c => c.Size);
7779

7880
foreach (var component in addedComponents)
7981
{
@@ -242,13 +244,12 @@ private void RemoveComponents()
242244

243245
foreach (string file in infoText)
244246
{
245-
string filePath = Path.Combine(FPM.SourcePath, file);
246-
double removeProgress = (double)removedFiles / totalFiles;
247-
double totalProgress = (byteProgress + (removeProgress * totalSize)) / byteTotal;
248-
249-
FPM.DeleteFileAndDirectories(filePath);
247+
FPM.DeleteFileAndDirectories(Path.Combine(FPM.SourcePath, file));
250248
removedFiles++;
251249

250+
double removeProgress = (double)removedFiles / totalFiles;
251+
double totalProgress = FPM.UpdateMode ? 1 : (byteProgress + (removeProgress * totalSize)) / byteTotal;
252+
252253
ProgressMeasure.Invoke((MethodInvoker)delegate
253254
{
254255
ProgressMeasure.Value = (int)((double)totalProgress * ProgressMeasure.Maximum);

0 commit comments

Comments
 (0)