2020-06-15 19:11:05 +00:00
|
|
|
|
using GCMM.Properties;
|
2020-06-15 21:17:49 +00:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
2020-06-15 19:11:05 +00:00
|
|
|
|
using System;
|
2020-06-16 17:22:29 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-06-15 21:17:49 +00:00
|
|
|
|
using System.Diagnostics;
|
2020-06-15 19:11:05 +00:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.IO;
|
2020-06-15 21:17:49 +00:00
|
|
|
|
using System.IO.Compression;
|
2020-06-15 19:11:05 +00:00
|
|
|
|
using System.Linq;
|
2020-06-15 21:17:49 +00:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Reflection;
|
2020-06-15 19:11:05 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace GCMM
|
|
|
|
|
{
|
|
|
|
|
public partial class MainForm : Form
|
|
|
|
|
{
|
|
|
|
|
public MainForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-16 17:22:29 +00:00
|
|
|
|
private Dictionary<string, ModInfo> mods = new Dictionary<string, ModInfo>();
|
2020-06-17 21:56:18 +00:00
|
|
|
|
private string defaultInfo = @"
|
|
|
|
|
Gamecraft Mod Manager
|
|
|
|
|
|
|
|
|
|
If you click on a mod it will show some info about it. The install instructions there are for manual installs.
|
|
|
|
|
To get started, click on a mod and select Install mod. Most mods need GamecraftModdingAPI as well.
|
2020-06-18 16:28:07 +00:00
|
|
|
|
Then, simply click Play. This will first download and run the patcher (GCIPA) if needed.
|
|
|
|
|
If all goes well, after some time a modded Gamecraft should launch.
|
2020-06-17 21:56:18 +00:00
|
|
|
|
|
|
|
|
|
After a Gamecraft update there's a good chance that mods will break. If this happens you may get errors when trying to start Gamecraft.
|
|
|
|
|
Until updated versions are released, use the ""Run unpatched"" checkbox at the bottom to launch the game without mods.
|
|
|
|
|
|
|
|
|
|
You don't have to use the mod manager to run the game each time, though it will tell you about mod updates when they come.
|
|
|
|
|
However, make sure to click Play each time you want to switch between modded and unmodded.
|
|
|
|
|
|
|
|
|
|
Disclaimer:
|
|
|
|
|
This mod manager and the mods in the list are made by the ExMods developers. We are not associated with Freejam or Gamecraft. Modify Gamecraft at your own risk.
|
|
|
|
|
|
|
|
|
|
If you encounter an issue while the game is patched, report it to us. If you think it's an issue with the game, test again with the unpatched option checked before reporting to Freejam.
|
|
|
|
|
";
|
2020-06-16 17:22:29 +00:00
|
|
|
|
|
2020-06-15 19:11:05 +00:00
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-06-18 18:05:14 +00:00
|
|
|
|
if (Settings.Default.NeedsUpdate)
|
|
|
|
|
{
|
|
|
|
|
Settings.Default.Upgrade();
|
|
|
|
|
Settings.Default.NeedsUpdate = false;
|
|
|
|
|
Settings.Default.Save();
|
|
|
|
|
}
|
2020-06-15 19:11:05 +00:00
|
|
|
|
modlist.Items.Clear();
|
|
|
|
|
UpdateButton(installbtn, false);
|
2020-06-17 21:56:18 +00:00
|
|
|
|
modinfobox.Text = defaultInfo;
|
2020-06-15 19:11:05 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(Settings.Default.GamePath))
|
|
|
|
|
{
|
|
|
|
|
Settings.Default.GamePath = GetGameFolder();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(Settings.Default.GamePath))
|
|
|
|
|
Settings.Default.GamePath = SelectGameFolder();
|
|
|
|
|
else
|
|
|
|
|
MessageBox.Show("Found game at " + Settings.Default.GamePath);
|
|
|
|
|
Settings.Default.Save();
|
|
|
|
|
}
|
2020-06-15 21:17:49 +00:00
|
|
|
|
if(string.IsNullOrWhiteSpace(Settings.Default.GamePath))
|
|
|
|
|
{
|
|
|
|
|
status.Text = "Status: Game not found";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
CheckIfPatched();
|
|
|
|
|
GetInstalledMods();
|
2020-06-16 13:45:04 +00:00
|
|
|
|
GetAvailableMods();
|
2020-06-15 19:11:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-18 16:28:07 +00:00
|
|
|
|
private async void playbtn_Click(object sender, EventArgs e)
|
2020-06-15 21:17:49 +00:00
|
|
|
|
{
|
|
|
|
|
if (playbtn.ForeColor == Color.Green) return; //Disabled
|
2020-06-18 16:28:07 +00:00
|
|
|
|
await PatchStartGame(); //It will call EndWork();
|
2020-06-15 19:11:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void settingsbtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-06-15 21:17:49 +00:00
|
|
|
|
if (settingsbtn.ForeColor == Color.Green) return; //Disabled
|
2020-06-15 19:11:05 +00:00
|
|
|
|
var sf = new SettingsForm();
|
|
|
|
|
sf.ShowDialog(this);
|
|
|
|
|
}
|
2020-06-16 13:45:04 +00:00
|
|
|
|
|
|
|
|
|
private void modlist_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-06-17 13:08:22 +00:00
|
|
|
|
if (working) return;
|
2020-06-18 16:28:07 +00:00
|
|
|
|
modinfobox.Clear();
|
2020-06-17 13:08:22 +00:00
|
|
|
|
switch (modlist.SelectedItems.Count)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
2020-06-17 21:56:18 +00:00
|
|
|
|
modinfobox.Text = defaultInfo;
|
2020-06-17 13:08:22 +00:00
|
|
|
|
UpdateButton(installbtn, false);
|
|
|
|
|
UpdateButton(uninstallbtn, false);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
default:
|
|
|
|
|
installbtn.Text = "Install mod";
|
|
|
|
|
UpdateButton(installbtn, false);
|
|
|
|
|
UpdateButton(uninstallbtn, false);
|
2020-06-17 21:56:18 +00:00
|
|
|
|
bool install = false, update = false;
|
2020-06-17 13:08:22 +00:00
|
|
|
|
foreach (ListViewItem item in modlist.SelectedItems)
|
|
|
|
|
{
|
|
|
|
|
var mod = mods[item.Name];
|
|
|
|
|
if (modlist.SelectedItems.Count == 1)
|
2020-06-17 21:56:18 +00:00
|
|
|
|
{
|
|
|
|
|
bool up = mod.Version != null && mod.Version < mod.LatestVersion;
|
|
|
|
|
modinfobox.Text = ((up ? "New version available! " + mod.UpdateDetails + "\n\n"
|
|
|
|
|
: "") + mod.Description).Replace("\n", Environment.NewLine);
|
|
|
|
|
if(up)
|
|
|
|
|
{
|
|
|
|
|
modinfobox.Select(0, "New version available!".Length);
|
|
|
|
|
modinfobox.SelectionColor = Color.Aqua;
|
|
|
|
|
modinfobox.DeselectAll();
|
2020-06-18 16:28:07 +00:00
|
|
|
|
modinfobox.SelectionColor = modinfobox.ForeColor;
|
2020-06-17 21:56:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-17 13:08:22 +00:00
|
|
|
|
else
|
|
|
|
|
modinfobox.Text = modlist.SelectedItems.Count + " mods selected";
|
|
|
|
|
if (mod.DownloadURL != null && !(mod.LatestVersion <= mod.Version))
|
|
|
|
|
{
|
|
|
|
|
UpdateButton(installbtn, true);
|
|
|
|
|
if (mod.Version != null)
|
2020-06-17 21:56:18 +00:00
|
|
|
|
update = true;
|
2020-06-17 13:08:22 +00:00
|
|
|
|
else
|
2020-06-17 21:56:18 +00:00
|
|
|
|
install = true;
|
2020-06-17 13:08:22 +00:00
|
|
|
|
}
|
|
|
|
|
if (mod.Version != null)
|
|
|
|
|
UpdateButton(uninstallbtn, true);
|
|
|
|
|
}
|
2020-06-17 21:56:18 +00:00
|
|
|
|
if (install && update)
|
|
|
|
|
installbtn.Text = "Install and update mod";
|
|
|
|
|
else if (update)
|
|
|
|
|
installbtn.Text = "Update mod";
|
|
|
|
|
else
|
|
|
|
|
installbtn.Text = "Install mod";
|
2020-06-17 13:08:22 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-16 13:45:04 +00:00
|
|
|
|
|
2020-06-17 13:08:22 +00:00
|
|
|
|
private async void installbtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (installbtn.ForeColor == Color.Green) return; //Disabled
|
|
|
|
|
if (!BeginWork()) return;
|
|
|
|
|
foreach (ListViewItem item in modlist.SelectedItems)
|
|
|
|
|
{
|
2020-06-17 21:56:18 +00:00
|
|
|
|
var mod = mods[item.Name];
|
|
|
|
|
if (item.Group.Name == "installed" && (mod.DownloadURL == null || mod.LatestVersion <= mod.Version)) continue;
|
|
|
|
|
await InstallMod(mod);
|
2020-06-17 13:08:22 +00:00
|
|
|
|
}
|
|
|
|
|
EndWork();
|
2020-06-16 13:45:04 +00:00
|
|
|
|
}
|
2020-06-17 16:31:20 +00:00
|
|
|
|
|
|
|
|
|
private void uninstallbtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (uninstallbtn.ForeColor == Color.Green) return; //Disabled
|
|
|
|
|
foreach (ListViewItem item in modlist.SelectedItems)
|
|
|
|
|
{
|
|
|
|
|
if (item.Group.Name != "installed") continue;
|
|
|
|
|
UninstallMod(mods[item.Name]);
|
|
|
|
|
}
|
|
|
|
|
EndWork(); //Update button states
|
|
|
|
|
}
|
2020-06-17 21:56:18 +00:00
|
|
|
|
|
|
|
|
|
private void findlog_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
|
|
|
|
{
|
|
|
|
|
Process.Start("explorer.exe", "/select,"+Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"Low\Freejam\Gamecraft\Player.log");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void unpatched_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckIfPatched();
|
|
|
|
|
}
|
2020-06-15 19:11:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|