Skip to content

Commit b3fe542

Browse files
committed
[FlashpointManager] Add Settings tab with missing file checker
1 parent d99d4cb commit b3fe542

12 files changed

Lines changed: 735 additions & 114 deletions

FlashpointManager/FlashpointManager.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,15 @@
270270
</ItemGroup>
271271
<ItemGroup>
272272
<Compile Include="src\Common.cs" />
273+
<Compile Include="src\Forms\CheckFiles.cs">
274+
<SubType>Form</SubType>
275+
</Compile>
276+
<Compile Include="src\Forms\CheckFiles.Designer.cs">
277+
<DependentUpon>CheckFiles.cs</DependentUpon>
278+
</Compile>
279+
<Compile Include="src\Forms\Settings.cs">
280+
<SubType>Form</SubType>
281+
</Compile>
273282
<Compile Include="src\Forms\Operate.cs">
274283
<SubType>Form</SubType>
275284
</Compile>
@@ -287,6 +296,9 @@
287296
<Compile Include="src\TriStateTreeView.cs">
288297
<SubType>Component</SubType>
289298
</Compile>
299+
<EmbeddedResource Include="src\Forms\CheckFiles.resx">
300+
<DependentUpon>CheckFiles.cs</DependentUpon>
301+
</EmbeddedResource>
290302
<EmbeddedResource Include="src\Forms\Operate.resx">
291303
<DependentUpon>Operate.cs</DependentUpon>
292304
</EmbeddedResource>

FlashpointManager/src/Common.cs

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Diagnostics;
43
using System.Drawing;
54
using System.IO;
65
using System.Linq;
76
using System.Windows.Forms;
87
using System.Xml;
98

10-
namespace FlashpointInstaller
9+
namespace FlashpointManager
1110
{
1211
namespace Common
1312
{
@@ -179,15 +178,21 @@ public static class FPM
179178

180179
// Name of configuration file
181180
public static string ConfigFile { get; set; } = "fpm.cfg";
182-
// Internet location of component list XML
183-
public static string ListURL { get; set; } = "https://nexus-dev.unstable.life/repository/stable/components.xml";
181+
// Internet locations of component list XMLs
182+
public static class RepoXmlTemplates
183+
{
184+
public const string Stable = "https://nexus-dev.unstable.life/repository/stable/components.xml";
185+
public const string Development = "https://nexus-dev.unstable.life/repository/development/components.xml";
186+
}
187+
public static string RepoXml { get; set; } = RepoXmlTemplates.Stable;
184188
// Path to the local Flashpoint copy
185-
public static string SourcePath { get; set; } = Debugger.IsAttached
186-
? Path.Combine(Path.GetPathRoot(AppDomain.CurrentDomain.BaseDirectory), "Flashpoint")
187-
: Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), ".."));
189+
public static string SourcePath { get; set; } = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), ".."));
188190

189-
// Controls whether components are being updated instead of added or removed
190-
public static bool UpdateMode { get; set; } = false;
191+
// Controls which components the operate tab adds and removes
192+
// 0 = Download/remove selected components
193+
// 1 = Reinstall outdated components
194+
// 2 = Reinstall broken components
195+
public static int OperateMode { get; set; } = 0;
191196
// Controls whether the update tab is selected at launch
192197
public static bool OpenUpdateTab { get; set; } = false;
193198
// Controls whether the launcher should be opened upon the manager closing
@@ -205,6 +210,8 @@ public static class ComponentTracker
205210
public static List<Component> Downloaded { get; set; } = new List<Component>();
206211
// Returns all outdated components
207212
public static List<Component> Outdated { get; set; } = new List<Component>();
213+
// Returns all components with missing files
214+
public static List<Component> Broken { get; set; } = new List<Component>();
208215
}
209216

210217
// Performs an operation on every node in the specified TreeNodeCollection
@@ -309,16 +316,18 @@ public static void SyncManager(bool init = false)
309316

310317
var component = new Component(node);
311318

312-
bool outdated = false;
313319
bool downloaded = ComponentTracker.Downloaded.Exists(c => c.ID == component.ID);
320+
bool outdated = false;
314321

315322
if (downloaded)
316323
{
317324
string localHash = File.ReadLines(component.InfoFile).First().Split(' ')[0];
318325
outdated = localHash != component.Hash && component.ID != "core-database";
319326
}
320-
321-
if (!downloaded && component.Required) outdated = true;
327+
else if (component.Required)
328+
{
329+
outdated = true;
330+
}
322331

323332
if (outdated)
324333
{
@@ -374,6 +383,21 @@ public static void SyncManager(bool init = false)
374383
{
375384
Main.UpdateButton.Enabled = false;
376385
}
386+
387+
Main.LocationBox.Text = SourcePath;
388+
389+
switch (RepoXml)
390+
{
391+
case RepoXmlTemplates.Stable:
392+
Main.StableRepo.Checked = true;
393+
break;
394+
case RepoXmlTemplates.Development:
395+
Main.DevRepo.Checked = true;
396+
break;
397+
default:
398+
Main.CustomRepo.Checked = true;
399+
break;
400+
}
377401
}
378402

379403
// Deletes a file as well as any directories made empty by its deletion

FlashpointManager/src/Forms/CheckFiles.Designer.cs

Lines changed: 148 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using System.Windows.Forms;
7+
8+
using FlashpointManager.Common;
9+
10+
namespace FlashpointManager.src.Forms
11+
{
12+
public partial class CheckFiles : Form
13+
{
14+
public CheckFiles() => InitializeComponent();
15+
16+
private async void CheckFiles_Load(object sender, EventArgs e)
17+
{
18+
FPM.ComponentTracker.Broken.Clear();
19+
20+
await Task.Run(() =>
21+
{
22+
FPM.IterateXML(FPM.XmlTree.GetElementsByTagName("list")[0].ChildNodes, node =>
23+
{
24+
if (node.Name != "component") return;
25+
26+
var component = new Component(node);
27+
28+
if (!component.Downloaded) return;
29+
30+
bool added = false;
31+
32+
foreach (string file in File.ReadLines(component.InfoFile).Skip(1))
33+
{
34+
if (!File.Exists(Path.Combine(FPM.SourcePath, file)))
35+
{
36+
if (!added)
37+
{
38+
FPM.ComponentTracker.Broken.Add(component);
39+
added = true;
40+
}
41+
42+
var item = new ListViewItem();
43+
item.Text = component.Title;
44+
item.SubItems.Add(file);
45+
46+
FileList.Invoke((MethodInvoker)delegate { FileList.Items.Add(item); });
47+
}
48+
}
49+
});
50+
});
51+
52+
FileListLoading.Visible = false;
53+
FileList.Visible = true;
54+
RedownloadButton.Enabled = FileList.Items.Count > 0;
55+
}
56+
57+
private void FileMessage_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
58+
{
59+
Process.Start(
60+
new ProcessStartInfo("https://bluemaxima.org/flashpoint/datahub/Troubleshooting_Antivirus_Interference")
61+
{
62+
UseShellExecute = true
63+
}
64+
);
65+
}
66+
67+
private void RedownloadButton_Click(object sender, EventArgs e)
68+
{
69+
FPM.OperateMode = 2;
70+
71+
new Operate().ShowDialog();
72+
73+
Close();
74+
}
75+
76+
private void CancelButton_Click(object sender, EventArgs e) => Close();
77+
}
78+
}

0 commit comments

Comments
 (0)