Skip to content

Commit 6bcdfb9

Browse files
committed
Move OperateMode to an Enum
1 parent a492264 commit 6bcdfb9

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

FlashpointManager/src/Common.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ protected static string GetAttribute(XmlNode node, string attribute, bool throwE
141141
return "";
142142
}
143143
}
144+
145+
public enum OperateMode {
146+
Modify,
147+
Update,
148+
Repair
149+
}
144150

145151
public static class FPM
146152
{
@@ -165,10 +171,7 @@ public static class RepoXmlTemplates
165171
public static string SourcePath { get; set; } = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), ".."));
166172

167173
// Controls which components the operate tab adds and removes
168-
// 0 = Download/remove selected components
169-
// 1 = Reinstall outdated components
170-
// 2 = Reinstall broken components
171-
public static int OperateMode { get; set; } = 0;
174+
public static OperateMode OperationMode { get; set; } = OperateMode.Modify;
172175
// Controls whether to apply accommodations for offline use
173176
public static bool OfflineMode { get; set; } = false;
174177
// Controls whether the update tab is selected at launch

FlashpointManager/src/Forms/CheckFiles.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private void FileMessage_LinkClicked(object sender, LinkLabelLinkClickedEventArg
7878

7979
private void RedownloadButton_Click(object sender, EventArgs e)
8080
{
81-
FPM.OperateMode = 2;
81+
FPM.OperationMode = OperateMode.Repair;
8282

8383
new Operate().ShowDialog();
8484

FlashpointManager/src/Forms/Main.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ private void ChangeButton_Click(object sender, EventArgs e)
118118
{
119119
if (!FPM.CheckDependencies()) return;
120120

121-
FPM.OperateMode = 0;
121+
FPM.OperationMode = OperateMode.Modify;
122122

123123
new Operate().ShowDialog();
124124
}
125125

126126
private void UpdateButton_Click(object sender, EventArgs e)
127127
{
128-
FPM.OperateMode = 1;
128+
FPM.OperationMode = OperateMode.Update;
129129

130130
new Operate().ShowDialog();
131131
}

FlashpointManager/src/Forms/Operate.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private async void Operation_Load(object sender, EventArgs e)
4040

4141
client.DownloadProgressChanged += OnDownloadProgressChanged;
4242

43-
if (FPM.OperateMode == 0)
43+
if (FPM.OperationMode == OperateMode.Modify)
4444
{
4545
FPM.IterateList(FPM.Main.ComponentList.Nodes, node =>
4646
{
@@ -59,7 +59,7 @@ private async void Operation_Load(object sender, EventArgs e)
5959
}
6060
});
6161
}
62-
else if (FPM.OperateMode == 1)
62+
else if (FPM.OperationMode == OperateMode.Update)
6363
{
6464
foreach (var component in FPM.ComponentTracker.Outdated)
6565
{
@@ -82,7 +82,7 @@ private async void Operation_Load(object sender, EventArgs e)
8282
}
8383
}
8484

85-
byteTotal = FPM.OperateMode != 0
85+
byteTotal = FPM.OperationMode != OperateMode.Modify
8686
? addedComponents.Sum(c => c.Size)
8787
: addedComponents.Concat(removedComponents).Sum(c => c.Size);
8888

@@ -261,7 +261,7 @@ private void RemoveComponents()
261261
removedFiles++;
262262

263263
double removeProgress = (double)removedFiles / totalFiles;
264-
double totalProgress = FPM.OperateMode != 0 ? 1 : (byteProgress + (removeProgress * totalSize)) / byteTotal;
264+
double totalProgress = FPM.OperationMode != OperateMode.Modify ? 1 : (byteProgress + (removeProgress * totalSize)) / byteTotal;
265265

266266
ProgressMeasure.Invoke((MethodInvoker)delegate
267267
{

0 commit comments

Comments
 (0)