Skip to content

Commit 6f02d06

Browse files
committed
[FlashpointManager] Added check for existing Flashpoint copy, fixed category description
1 parent 9be590b commit 6f02d06

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

FlashpointInstaller/src/Common.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public static bool RedistInstalled
162162
}
163163

164164
// Pointer to destination path textbox
165-
private static string destinationPath = "";
165+
private static string destinationPath = Path.Combine(Path.GetPathRoot(AppDomain.CurrentDomain.BaseDirectory), "Flashpoint");
166166
public static string DestinationPath
167167
{
168168
get { return destinationPath; }
@@ -274,6 +274,30 @@ public static TreeNode AddNodeToList(XmlNode child, TreeNodeCollection parent, b
274274
// Checks if specified Flashpoint destination path is valid
275275
public static bool VerifyDestinationPath(string path)
276276
{
277+
bool alreadyExists = false;
278+
279+
IterateXML(XmlTree.GetElementsByTagName("list")[0].ChildNodes, node =>
280+
{
281+
if (node.Name != "component") return;
282+
283+
if (File.Exists(Path.Combine(path, "Components", $"{new Component(node).ID}.txt")))
284+
{
285+
alreadyExists = true;
286+
return;
287+
}
288+
});
289+
290+
if (alreadyExists)
291+
{
292+
MessageBox.Show(
293+
"Flashpoint is already installed to this directory! " +
294+
"Choose a different folder or uninstall the existing copy first.",
295+
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error
296+
);
297+
298+
return false;
299+
}
300+
277301
if (!Path.IsPathRooted(path))
278302
{
279303
MessageBox.Show(
@@ -313,13 +337,13 @@ public static bool VerifyDestinationPath(string path)
313337
}
314338

315339
// Checks if any dependencies were not marked for download by the user, and marks them accordingly
316-
public static void CheckDependencies(TreeView sourceTree)
340+
public static void CheckDependencies()
317341
{
318342
List<string> requiredDepends = new List<string>();
319343
List<string> missingDepends = new List<string>();
320344

321345
// First, fill out a list of dependencies
322-
IterateList(sourceTree.Nodes, node =>
346+
IterateList(Main.ComponentList.Nodes, node =>
323347
{
324348
if (node.Checked && node.Tag.GetType().ToString().EndsWith("Component"))
325349
{
@@ -328,7 +352,7 @@ public static void CheckDependencies(TreeView sourceTree)
328352
});
329353

330354
// Then make sure they're all marked for installation
331-
IterateList(sourceTree.Nodes, node =>
355+
IterateList(Main.ComponentList.Nodes, node =>
332356
{
333357
if (node.Tag.GetType().ToString().EndsWith("Component"))
334358
{

FlashpointInstaller/src/Forms/Main.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private void Main_Load(object sender, EventArgs e)
3434
Environment.Exit(1);
3535
}
3636

37-
FPM.DestinationPath = Path.Combine(Path.GetPathRoot(AppDomain.CurrentDomain.BaseDirectory), "Flashpoint");
37+
DestinationPath.Text = FPM.DestinationPath;
3838
}
3939

4040
private void Link_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
@@ -70,7 +70,7 @@ private void ComponentList_BeforeSelect(object _, TreeViewCancelEventArgs e)
7070
long categorySize = 0;
7171
FPM.IterateList(e.Node.Nodes, node =>
7272
{
73-
if (node.Checked && node.Tag.GetType().ToString().EndsWith("Component"))
73+
if (node.Tag.GetType().ToString().EndsWith("Component"))
7474
{
7575
categorySize += (node.Tag as Component).Size;
7676
}
@@ -102,7 +102,7 @@ private void DownloadButton_Click(object sender, EventArgs e)
102102
{
103103
if (!FPM.VerifyDestinationPath(FPM.DestinationPath)) return;
104104

105-
FPM.CheckDependencies(ComponentList);
105+
FPM.CheckDependencies();
106106

107107
if (!FPM.RedistInstalled)
108108
{

0 commit comments

Comments
 (0)