From 43db83717fc1fe5402c9a55d9e2c98bad527a812 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 16 Jun 2021 01:25:48 +0200 Subject: [PATCH] Read game version from the game, begin renaming to TBMM everywhere --- GCMM/AutoPatchingState.cs | 2 +- GCMM/Configuration.cs | 2 +- GCMM/CustomMessageBox.Designer.cs | 2 +- GCMM/CustomMessageBox.cs | 2 +- GCMM/DialogUtils.cs | 2 +- GCMM/GCMM.csproj | 5 +---- GCMM/Localization.Designer.cs | 4 ++-- GCMM/MainForm.Designer.cs | 2 +- GCMM/MainForm.cs | 16 +++++++--------- GCMM/MainModInstaller.cs | 2 +- GCMM/MainModList.cs | 25 ++++++++++++++----------- GCMM/MainPatcher.cs | 4 ++-- GCMM/MainUtils.cs | 30 ++++++++++++++++++++++++------ GCMM/ModInfo.cs | 2 +- GCMM/Program.cs | 2 +- GCMM/SettingsForm.Designer.cs | 2 +- GCMM/SettingsForm.cs | 2 +- GCMM/ZipArchiveExtensions.cs | 2 +- 18 files changed, 62 insertions(+), 46 deletions(-) diff --git a/GCMM/AutoPatchingState.cs b/GCMM/AutoPatchingState.cs index 42e7c88..8d4082a 100644 --- a/GCMM/AutoPatchingState.cs +++ b/GCMM/AutoPatchingState.cs @@ -1,4 +1,4 @@ -namespace GCMM +namespace TBMM { public enum AutoPatchingState { diff --git a/GCMM/Configuration.cs b/GCMM/Configuration.cs index 962ae15..dfb4304 100644 --- a/GCMM/Configuration.cs +++ b/GCMM/Configuration.cs @@ -1,7 +1,7 @@ using System.IO; using Newtonsoft.Json; -namespace GCMM +namespace TBMM { public class Configuration { diff --git a/GCMM/CustomMessageBox.Designer.cs b/GCMM/CustomMessageBox.Designer.cs index 7632691..a3f33e7 100644 --- a/GCMM/CustomMessageBox.Designer.cs +++ b/GCMM/CustomMessageBox.Designer.cs @@ -1,4 +1,4 @@ -namespace GCMM +namespace TBMM { partial class CustomMessageBox { diff --git a/GCMM/CustomMessageBox.cs b/GCMM/CustomMessageBox.cs index aedb083..b1e5db8 100644 --- a/GCMM/CustomMessageBox.cs +++ b/GCMM/CustomMessageBox.cs @@ -1,6 +1,6 @@ using System.Windows.Forms; -namespace GCMM +namespace TBMM { public partial class CustomMessageBox : Form { diff --git a/GCMM/DialogUtils.cs b/GCMM/DialogUtils.cs index d2b056a..139d7cd 100644 --- a/GCMM/DialogUtils.cs +++ b/GCMM/DialogUtils.cs @@ -1,6 +1,6 @@ using System.Windows.Forms; -namespace GCMM +namespace TBMM { public static class DialogUtils { diff --git a/GCMM/GCMM.csproj b/GCMM/GCMM.csproj index 983c24e..deb8382 100644 --- a/GCMM/GCMM.csproj +++ b/GCMM/GCMM.csproj @@ -6,7 +6,7 @@ true false favicon.ico - 1.4.0 + 1.5.0 NorbiPeti ExMods A mod manager for Techblox. It automatically downloads and runs GCIPA and allows the user to install mods. @@ -33,9 +33,6 @@ - - ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.CoreModule.dll - diff --git a/GCMM/Localization.Designer.cs b/GCMM/Localization.Designer.cs index 5dcac93..15a31fe 100644 --- a/GCMM/Localization.Designer.cs +++ b/GCMM/Localization.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace GCMM { +namespace TBMM { using System; @@ -39,7 +39,7 @@ namespace GCMM { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GCMM.Localization", typeof(Localization).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TBMM.Localization", typeof(Localization).Assembly); resourceMan = temp; } return resourceMan; diff --git a/GCMM/MainForm.Designer.cs b/GCMM/MainForm.Designer.cs index 618df9f..e1f0c63 100644 --- a/GCMM/MainForm.Designer.cs +++ b/GCMM/MainForm.Designer.cs @@ -1,4 +1,4 @@ -namespace GCMM +namespace TBMM { partial class MainForm { diff --git a/GCMM/MainForm.cs b/GCMM/MainForm.cs index fd71e08..f30b33a 100644 --- a/GCMM/MainForm.cs +++ b/GCMM/MainForm.cs @@ -9,14 +9,14 @@ using System.Resources; using System.Threading.Tasks; using System.Windows.Forms; -namespace GCMM +namespace TBMM { public partial class MainForm : Form { public MainForm() { InitializeComponent(); - resources = new ResourceManager("GCMM.Localization", Assembly.GetExecutingAssembly()); + resources = new ResourceManager("TBMM.Localization", Assembly.GetExecutingAssembly()); Configuration = Configuration.Load(); } @@ -25,21 +25,19 @@ namespace GCMM private readonly ResourceManager resources; private readonly Dictionary mods = new Dictionary(); private readonly ModInfo gcipa = new ModInfo { Author = "modtainers", Name = "GCIPA" }; - private readonly ModInfo gcmm = new ModInfo { Author = "NorbiPeti", Name = "GCMM" }; + private readonly ModInfo tbmm = new ModInfo { Author = "NorbiPeti", Name = "TBMM" }; private DateTime lastGameUpdateTime; private const string defaultInfo = @" Techblox Mod Manager If you click on a mod it will show some info about it. The install instructions there are usually for manual installs. To get started, click on a mod and select Install mod. Most mods need TechbloxModdingAPI as well so it'll be installed. -Then launch Techblox: if you enabled auto-patching then you can use the launcher but if you didn't then you must use the Play button. +Then launch Techblox by clicking on the Play button below. Mods are only loaded if you start the game from here. This will first download and run the patcher (GCIPA) if needed. If all goes well, after some time a modded Techblox should launch. After a Techblox update there's a good chance that mods will break. If this happens you may get errors when trying to start Techblox. Until updated versions are released, use the ""Disable mods"" checkbox at the bottom to launch the game without mods. -If you enabled auto-patching you will get a warning about this. - -If you don't have auto-patching enabled then you will need to run the mod manager each time Techblox updates and click ""Patch & Play"" or the game may not function properly. +If you launch the game through the launcher after an update and encounter an error, either repair the game or launch it through the mod manager. Disclaimer: This mod manager and the mods in the list are made by the ExMods developers. We are not associated with Freejam or Techblox. Modify Techblox at your own risk. @@ -130,8 +128,8 @@ You may also want to verify the game's files in the launcher. { if (mod.Updatable) addText("New version available! " + mod.UpdateDetails, Color.Aqua); - if (mod.LastUpdated < lastGameUpdateTime) - addText("Outdated mod! It may not work properly on the latest version of the game.", Color.DarkOrange); + if (mod.LastUpdated != default && mod.LastUpdated < lastGameUpdateTime) + addText("Outdated mod! It may not work properly on the current version of the game.", Color.DarkOrange); if (mod.Description != null) modinfobox.AppendText(mod.Description.Replace("\n", Environment.NewLine)); } diff --git a/GCMM/MainModInstaller.cs b/GCMM/MainModInstaller.cs index cd18cdd..aa64c67 100644 --- a/GCMM/MainModInstaller.cs +++ b/GCMM/MainModInstaller.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; -namespace GCMM +namespace TBMM { partial class MainForm { diff --git a/GCMM/MainModList.cs b/GCMM/MainModList.cs index ab1799f..0cdce74 100644 --- a/GCMM/MainModList.cs +++ b/GCMM/MainModList.cs @@ -11,7 +11,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace GCMM +namespace TBMM { partial class MainForm { @@ -53,11 +53,11 @@ namespace GCMM } try { - string mmpath = "GCMM.exe"; + string mmpath = "TBMM.exe"; if (File.Exists(mmpath)) { var an = AssemblyName.GetAssemblyName(mmpath); - gcmm.Version = an.Version; + tbmm.Version = an.Version; } } catch (BadImageFormatException) @@ -79,20 +79,21 @@ namespace GCMM var mod = new ModInfo { Author = sp[0].Trim(), - Name = sp[1].Trim() + Name = sp[1].Trim(), + LastUpdated = sp.Length > 2 ? DateTime.Parse(sp[2].Trim()) : default }; if (await FetchModInfo(mod, preview, true)) //If it's actually a mod AddUpdateModInList(mod); } } - if (gcmm.LatestVersion == null) //Only check once + if (tbmm.LatestVersion == null) //Only check once { await FetchModInfo(gcipa, preview, false); - await FetchModInfo(gcmm, preview, false); - if (gcmm.Updatable) - if (MessageBox.Show("There is a GCMM update available! Do you want to download it now? If yes, extract it over this installation.\n\n" + gcmm.UpdateDetails, "Mod Manager update", MessageBoxButtons.YesNo) + await FetchModInfo(tbmm, preview, false); + if (tbmm.Updatable) + if (MessageBox.Show("There is a TBMM update available! Do you want to download it now? If yes, extract it over this installation.\n\n" + tbmm.UpdateDetails, "Mod Manager update", MessageBoxButtons.YesNo) == DialogResult.Yes) - Process.Start(gcmm.DownloadURL); + Process.Start(tbmm.DownloadURL); } } @@ -134,7 +135,9 @@ namespace GCMM }); mod.DownloadURL = asset?["browser_download_url"]?.ToString(); - mod.LastUpdated = (DateTime)release["published_at"]; + var lastUpdated = (DateTime)release["published_at"]; + if (mod.LastUpdated < lastUpdated) + mod.LastUpdated = lastUpdated; //If there's a newer release than the last known working date var ver = verstr.Split('.').Select(str => int.Parse(str)).ToArray(); int getver(byte i) => ver.Length > i ? ver[i] : 0; //By default it sets values not present to -1, but we need them to be 0 @@ -189,7 +192,7 @@ namespace GCMM if (mod.LatestVersion != null && mod.Version != null && mod.Version < mod.LatestVersion) item.ForeColor = Color.Blue; else if (mod.LastUpdated != default && mod.LastUpdated < lastGameUpdateTime) - item.ForeColor = Color.DarkOrange; + item.ForeColor = Color.OrangeRed; else item.ForeColor = modlist.ForeColor; } diff --git a/GCMM/MainPatcher.cs b/GCMM/MainPatcher.cs index e0a00eb..7fa9ea0 100644 --- a/GCMM/MainPatcher.cs +++ b/GCMM/MainPatcher.cs @@ -7,7 +7,7 @@ using System.Net; using System.Threading.Tasks; using System.Windows.Forms; -namespace GCMM +namespace TBMM { partial class MainForm { @@ -103,7 +103,7 @@ namespace GCMM await Task.Delay(500); //The EnsureShown() call should download info about GCIPA if (gcipa.DownloadURL == null) { - MessageBox.Show("Could not get information about GCIPA in time. Please run GCMM manually."); + MessageBox.Show("Could not get information about GCIPA in time. Please run TBMM manually."); return retOpenedWindowShouldStay; } using (WebClient client = GetClient()) diff --git a/GCMM/MainUtils.cs b/GCMM/MainUtils.cs index 33cb895..d1a9f0e 100644 --- a/GCMM/MainUtils.cs +++ b/GCMM/MainUtils.cs @@ -7,9 +7,8 @@ using System.Net; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.Win32; -using Application = UnityEngine.Application; -namespace GCMM +namespace TBMM { partial class MainForm { @@ -100,9 +99,9 @@ namespace GCMM { if (!unpatched.Checked && MessageBox.Show("If the game updated just now, some mods may be incompatible or they may work just fine." + " Do you want to try running with mods?" + - "\n\nClick Yes to start the game with mods (after a small update or if you just installed GCMM)" + + "\n\nClick Yes to start the game with mods (after a small update or if you just installed TBMM)" + "\nClick No to disable mods before starting the game (after a major update)" + - "\n\nYou can always enable/disable mods by launching GCMM.", + "\n\nYou can always enable/disable mods by launching TBMM.", "Possible incompatibility warning", MessageBoxButtons.YesNo) == DialogResult.No) unpatched.Checked = true; } @@ -114,7 +113,7 @@ namespace GCMM return; if (MessageBox.Show("Mod update(s) available!\n\n" + updatable.Select(mod => mod.Name + " " + mod.LatestVersion).Aggregate((a, b) => a + "\n") - + "\n\nDo you want to update them now? You can also update later by opening GCMM.", + + "\n\nDo you want to update them now? You can also update later by opening TBMM.", "Update(s) available", MessageBoxButtons.YesNo) == DialogResult.No) return; foreach (var mod in updatable) @@ -196,7 +195,26 @@ namespace GCMM public DateTime GetGameVersionAsDate() { - return Convert.ToDateTime(Application.version); + if (Configuration.GamePath == null) return default; + using var fs = File.OpenRead(GamePath("\\TechbloxPreview_Data\\globalgamemanagers")); + using var sr = new StreamReader(fs); + char[] data = new char[512]; + while(!sr.EndOfStream) + { + Array.Copy(data, 256, data, 0, 256); + int read = sr.ReadBlock(data, 256, 256); + for (int i = 0; i < data.Length - 11; i++) + { + if (data[i] == '2') + { + string date = new string(data, i, 11); + if (date.StartsWith("202") && DateTime.TryParse(date, out var ret)) + return ret; + } + } + } + + return default; } } } diff --git a/GCMM/ModInfo.cs b/GCMM/ModInfo.cs index cd31934..d1d8625 100644 --- a/GCMM/ModInfo.cs +++ b/GCMM/ModInfo.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace GCMM +namespace TBMM { public class ModInfo { diff --git a/GCMM/Program.cs b/GCMM/Program.cs index 9437a54..e2578f6 100644 --- a/GCMM/Program.cs +++ b/GCMM/Program.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; -namespace GCMM +namespace TBMM { static class Program { diff --git a/GCMM/SettingsForm.Designer.cs b/GCMM/SettingsForm.Designer.cs index c11354f..9641a14 100644 --- a/GCMM/SettingsForm.Designer.cs +++ b/GCMM/SettingsForm.Designer.cs @@ -1,4 +1,4 @@ -namespace GCMM +namespace TBMM { partial class SettingsForm { diff --git a/GCMM/SettingsForm.cs b/GCMM/SettingsForm.cs index ee72e6d..f3d68fc 100644 --- a/GCMM/SettingsForm.cs +++ b/GCMM/SettingsForm.cs @@ -1,7 +1,7 @@ using System; using System.Windows.Forms; -namespace GCMM +namespace TBMM { public partial class SettingsForm : Form { diff --git a/GCMM/ZipArchiveExtensions.cs b/GCMM/ZipArchiveExtensions.cs index e6f943a..f1bc376 100644 --- a/GCMM/ZipArchiveExtensions.cs +++ b/GCMM/ZipArchiveExtensions.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace GCMM +namespace TBMM { public static class ZipArchiveExtensions { //https://stackoverflow.com/a/14795752/2703239