Browse Source

Read game version from the game, begin renaming to TBMM everywhere

tags/v1.5.0
NorbiPeti 3 years ago
parent
commit
43db83717f
18 changed files with 62 additions and 46 deletions
  1. +1
    -1
      GCMM/AutoPatchingState.cs
  2. +1
    -1
      GCMM/Configuration.cs
  3. +1
    -1
      GCMM/CustomMessageBox.Designer.cs
  4. +1
    -1
      GCMM/CustomMessageBox.cs
  5. +1
    -1
      GCMM/DialogUtils.cs
  6. +1
    -4
      GCMM/GCMM.csproj
  7. +2
    -2
      GCMM/Localization.Designer.cs
  8. +1
    -1
      GCMM/MainForm.Designer.cs
  9. +7
    -9
      GCMM/MainForm.cs
  10. +1
    -1
      GCMM/MainModInstaller.cs
  11. +14
    -11
      GCMM/MainModList.cs
  12. +2
    -2
      GCMM/MainPatcher.cs
  13. +24
    -6
      GCMM/MainUtils.cs
  14. +1
    -1
      GCMM/ModInfo.cs
  15. +1
    -1
      GCMM/Program.cs
  16. +1
    -1
      GCMM/SettingsForm.Designer.cs
  17. +1
    -1
      GCMM/SettingsForm.cs
  18. +1
    -1
      GCMM/ZipArchiveExtensions.cs

+ 1
- 1
GCMM/AutoPatchingState.cs View File

@@ -1,4 +1,4 @@
namespace GCMM
namespace TBMM
{
public enum AutoPatchingState
{


+ 1
- 1
GCMM/Configuration.cs View File

@@ -1,7 +1,7 @@
using System.IO;
using Newtonsoft.Json;

namespace GCMM
namespace TBMM
{
public class Configuration
{


+ 1
- 1
GCMM/CustomMessageBox.Designer.cs View File

@@ -1,4 +1,4 @@
namespace GCMM
namespace TBMM
{
partial class CustomMessageBox
{


+ 1
- 1
GCMM/CustomMessageBox.cs View File

@@ -1,6 +1,6 @@
using System.Windows.Forms;

namespace GCMM
namespace TBMM
{
public partial class CustomMessageBox : Form
{


+ 1
- 1
GCMM/DialogUtils.cs View File

@@ -1,6 +1,6 @@
using System.Windows.Forms;

namespace GCMM
namespace TBMM
{
public static class DialogUtils
{


+ 1
- 4
GCMM/GCMM.csproj View File

@@ -6,7 +6,7 @@
<UseWindowsForms>true</UseWindowsForms>
<SignAssembly>false</SignAssembly>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<Version>1.4.0</Version>
<Version>1.5.0</Version>
<Authors>NorbiPeti</Authors>
<Company>ExMods</Company>
<Description>A mod manager for Techblox. It automatically downloads and runs GCIPA and allows the user to install mods.</Description>
@@ -33,9 +33,6 @@
<ItemGroup>
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>


+ 2
- 2
GCMM/Localization.Designer.cs View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------

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;


+ 1
- 1
GCMM/MainForm.Designer.cs View File

@@ -1,4 +1,4 @@
namespace GCMM
namespace TBMM
{
partial class MainForm
{


+ 7
- 9
GCMM/MainForm.cs View File

@@ -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<string, ModInfo> mods = new Dictionary<string, ModInfo>();
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));
}


+ 1
- 1
GCMM/MainModInstaller.cs View File

@@ -7,7 +7,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GCMM
namespace TBMM
{
partial class MainForm
{


+ 14
- 11
GCMM/MainModList.cs View File

@@ -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;
}


+ 2
- 2
GCMM/MainPatcher.cs View File

@@ -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())


+ 24
- 6
GCMM/MainUtils.cs View File

@@ -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;
}
}
}

+ 1
- 1
GCMM/ModInfo.cs View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GCMM
namespace TBMM
{
public class ModInfo
{


+ 1
- 1
GCMM/Program.cs View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GCMM
namespace TBMM
{
static class Program
{


+ 1
- 1
GCMM/SettingsForm.Designer.cs View File

@@ -1,4 +1,4 @@
namespace GCMM
namespace TBMM
{
partial class SettingsForm
{


+ 1
- 1
GCMM/SettingsForm.cs View File

@@ -1,7 +1,7 @@
using System;
using System.Windows.Forms;

namespace GCMM
namespace TBMM
{
public partial class SettingsForm : Form
{


+ 1
- 1
GCMM/ZipArchiveExtensions.cs View File

@@ -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


Loading…
Cancel
Save