|
|
@@ -5,12 +5,15 @@ using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
+using System.IO.Compression;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
+using static FactorioModManager.ModWorker;
|
|
|
+
|
|
|
namespace FactorioModManager
|
|
|
{
|
|
|
public partial class Form1 : Form
|
|
|
@@ -72,7 +75,7 @@ namespace FactorioModManager
|
|
|
};
|
|
|
foreach (Control control in this.Controls)
|
|
|
{
|
|
|
- MakeLinksClicable(control);
|
|
|
+ MakeLinksClickable(control);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -87,6 +90,7 @@ namespace FactorioModManager
|
|
|
{
|
|
|
for (int i = 0; i < Worker.InstalledMods.Count; i++)
|
|
|
{
|
|
|
+ ModWorker.Mod mod = Worker.InstalledMods[i];
|
|
|
ListViewItem item = listView1.Items.Add("");
|
|
|
item.SubItems[0].Tag = Worker.InstalledMods[i].Enabled;
|
|
|
item.SubItems[0].Text = "";
|
|
|
@@ -110,7 +114,7 @@ namespace FactorioModManager
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
- private void MakeLinksClicable(Control control)
|
|
|
+ private void MakeLinksClickable(Control control)
|
|
|
{
|
|
|
if (control is LinkLabel)
|
|
|
{
|
|
|
@@ -124,7 +128,7 @@ namespace FactorioModManager
|
|
|
{
|
|
|
foreach (Control ctrl in control.Controls)
|
|
|
{
|
|
|
- MakeLinksClicable(ctrl);
|
|
|
+ MakeLinksClickable(ctrl);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -216,13 +220,17 @@ namespace FactorioModManager
|
|
|
e.DrawDefault = true;
|
|
|
}
|
|
|
|
|
|
+ private bool setStateForce = false;
|
|
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
+ if (!userClick) return;
|
|
|
+ setStateForce = true;
|
|
|
for(int i = 0; i < listView1.Items.Count; i++)
|
|
|
{
|
|
|
listView1.Items[i].SubItems[0].Tag = checkBox1.Checked;
|
|
|
listView1.Items[i].Checked = checkBox1.Checked;
|
|
|
}
|
|
|
+ setStateForce = false;
|
|
|
listView1.Refresh();
|
|
|
}
|
|
|
|
|
|
@@ -281,13 +289,14 @@ namespace FactorioModManager
|
|
|
|
|
|
private void listView1_ItemChecked(object sender, ItemCheckedEventArgs e)
|
|
|
{
|
|
|
- /*bool flag = true;
|
|
|
+ //Worker.InstalledMods[e.Item.Index].Enabled = e.Item.Checked;
|
|
|
+ /*if (setStateForce) return;
|
|
|
+ bool flag = true;
|
|
|
foreach(ListViewItem item in listView1.Items)
|
|
|
{
|
|
|
flag = flag && item.Checked;
|
|
|
}
|
|
|
- checkBox1.Checked = flag;
|
|
|
- Worker.InstalledMods[e.Item.Index].Enabled = e.Item.Checked;*/
|
|
|
+ checkBox1.Checked = flag;*/
|
|
|
}
|
|
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
|
@@ -343,7 +352,60 @@ namespace FactorioModManager
|
|
|
|
|
|
private void exportModPackToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
+ SaveFileDialog dialog = new SaveFileDialog();
|
|
|
+ dialog.Filter = "*.fmpack|*.fmpack";
|
|
|
+ dialog.FileName = "factorio_mods.fmpack";
|
|
|
+ dialog.InitialDirectory = Directory.GetCurrentDirectory();
|
|
|
+ if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
+ {
|
|
|
+ FileStream zp = File.Create(dialog.FileName);
|
|
|
+ ZipArchive result = new ZipArchive(zp,ZipArchiveMode.Create,false);
|
|
|
+
|
|
|
+ ZipArchiveEntry entry = result.CreateEntry("mod-list.json");
|
|
|
+ using(StreamWriter sw = new StreamWriter(entry.Open()))
|
|
|
+ {
|
|
|
+ sw.WriteLine(Worker.GetModList(true));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Mod> mods = Worker.InstalledMods.Where(x => x.Enabled).ToList();
|
|
|
+ foreach (Mod mod in mods)
|
|
|
+ {
|
|
|
+ if (DLC_MODS.Contains(mod.Name)) continue;
|
|
|
|
|
|
+ using (Stream modInZip = result.CreateEntry(mod.FileName).Open())
|
|
|
+ {
|
|
|
+ byte[] file = File.ReadAllBytes(Path.Combine(Settings.GamePath, mod.FileName));
|
|
|
+ modInZip.Write(file,0,file.Length);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ using (Stream modInZip = result.CreateEntry("mod-settings.dat").Open())
|
|
|
+ {
|
|
|
+ byte[] file = File.ReadAllBytes(Path.Combine(Settings.GamePath, "mod-settings.dat"));
|
|
|
+ modInZip.Write(file, 0, file.Length);
|
|
|
+ }
|
|
|
+ result.Dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool userClick = false;
|
|
|
+ private void listView1_MouseDown(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ userClick = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void listView1_MouseUp(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ userClick = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkBox1_MouseDown(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ userClick = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkBox1_MouseUp(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ userClick = false;
|
|
|
}
|
|
|
|
|
|
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
|