Skip to content

Commit

Permalink
Code cleanup ci skip
Browse files Browse the repository at this point in the history
Moved some code around, did a little bit or organizing.
  • Loading branch information
rjtwins committed Jun 24, 2020
1 parent b404709 commit 6a3a0d6
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 6 additions & 15 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Form1()
private void Form1_Load(object sender, EventArgs e)
{
this.logic = new MainLogic();
if (logic.TryLoadInstallDir())
if (logic.TryLoadProgramData())
{
this.textBox1.Text = logic.BasePath;
LoadAndFill(false);
Expand Down Expand Up @@ -143,6 +143,7 @@ private void SetVersionAndVender()
//Load mod data and fill in the list box..
private void LoadAndFill(bool FromClipboard)
{
KeyValuePair<string, bool> currentEntry = new KeyValuePair<string, bool>();
try
{
if (FromClipboard)
Expand All @@ -151,6 +152,7 @@ private void LoadAndFill(bool FromClipboard)
logic.Loadstuff();
foreach (KeyValuePair<string, bool> entry in logic.ModList)
{
currentEntry = entry;
string modName = entry.Key;
ListViewItem item1 = new ListViewItem("", 0);
item1.Checked = entry.Value;
Expand All @@ -161,23 +163,12 @@ private void LoadAndFill(bool FromClipboard)
listView1.Items.Add(item1);
}

this.logic.ProgramData.installdir = logic.BasePath;
this.logic.ProgramData.vendor = logic.Vendor;

string systemPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
string complete = Path.Combine(systemPath, @"MW5LoadOrderManager");
JsonSerializer serializer = new JsonSerializer();
serializer.Formatting = Formatting.Indented;
using (StreamWriter sw = new StreamWriter(complete + @"\ProgramData.json"))
using (JsonWriter writer = new JsonTextWriter(sw))
{
serializer.Serialize(writer, logic.ProgramData);
}
logic.SaveProgramData();
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
string message = "While loading and parsing mod.json files some unknown error has occurred, please contact the developer with a screen shot of the editor, the error message and your mod folder.";
string message = "While loading " + currentEntry.Key.ToString() + "something went wrong.";
string caption = "Error Loading";
MessageBoxButtons buttons = MessageBoxButtons.OK;
MessageBox.Show(message, caption, buttons);
Expand Down Expand Up @@ -269,7 +260,7 @@ private void button5_Click(object sender, EventArgs e)
private void button6_Click(object sender, EventArgs e)
{
ClearAll();
if (logic.TryLoadInstallDir())
if (logic.TryLoadProgramData())
{
LoadAndFill(false);
}
Expand Down
35 changes: 26 additions & 9 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ static class Program
{
/// <summary>
/// The main entry point for the application.
///
/// </summary>
[STAThread]
static void Main()
Expand All @@ -40,17 +39,20 @@ private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object s
public class MainLogic
{
public float Version = 0f;
public ProgramData ProgramData = new ProgramData();
public string Vendor = "";
public bool CreatedModlist = false;
public JObject parent;
public string CurrentFolderInsearch;
public bool InterruptSearch = false;
public string BasePath = "";
public ProgramData ProgramData = new ProgramData();

public JObject parent;
public string[] Directories;
public Dictionary<string, bool> ModList = new Dictionary<string, bool>();

public Dictionary<string, ModObject> ModDetails = new Dictionary<string, ModObject>();
public Dictionary<string, bool> ModList = new Dictionary<string, bool>();
public bool CreatedModlist = false;

public string CurrentFolderInsearch;
public bool InterruptSearch = false;

public string rawJson;

public void Loadstuff()
Expand Down Expand Up @@ -98,8 +100,8 @@ private bool CheckModsDir()
return true;
}

//Try and load install dir path from stored data files.
public bool TryLoadInstallDir()
//Try and load data from previous sessions
public bool TryLoadProgramData()
{
//Load install dir from previous session:
string systemPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
Expand Down Expand Up @@ -171,6 +173,21 @@ public void ParseDirectories()
}
}

public void SaveProgramData()
{
this.ProgramData.installdir = this.BasePath;
this.ProgramData.vendor = this.Vendor;

string complete = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\MW5LoadOrderManager";
JsonSerializer serializer = new JsonSerializer();
serializer.Formatting = Formatting.Indented;
using (StreamWriter sw = new StreamWriter(complete + @"\ProgramData.json"))
using (JsonWriter writer = new JsonTextWriter(sw))
{
serializer.Serialize(writer, this.ProgramData);
}
}

public void ModListParser()
{
try
Expand Down
2 changes: 1 addition & 1 deletion bin/Release/MW5 Mod Manager.application
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>pQ4Z5saC0ZsKnLQMujhCZ1Bj9YdU+eBrAHs/5afNacs=</dsig:DigestValue>
<dsig:DigestValue>+WoJeX8CLFZaQLRCBVhncFF8S6riVOc+Zdk2C3lPgvo=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
Expand Down
Binary file modified bin/Release/MW5 Mod Manager.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/Release/MW5 Mod Manager.exe.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>5f2645K64RbzU46ExxaXZ/PMWKb20PxHivMPY1NhJP8=</dsig:DigestValue>
<dsig:DigestValue>OntH1UoVcIt1v8ZEIe5AoleXbenDSItWktWW5XIWY9o=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
Expand Down
Binary file modified bin/Release/app.publish/MW5 Mod Manager.exe
Binary file not shown.

0 comments on commit 6a3a0d6

Please sign in to comment.