Skip to content

Commit

Permalink
Preserve compatibility with SpaceWarp 1.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Falki-git committed May 26, 2023
1 parent c0f6293 commit 1d468cc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
19 changes: 10 additions & 9 deletions MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ public class MicroEngineerMod : BaseSpaceWarpPlugin
public override void OnInitialized()
{
Instance = this;

GUID = Info.Metadata.GUID;

BackwardCompatibilityInitializations();

Styles.Initialize();

MessageManager.Instance.SubscribeToMessages();

BackwardCompatibilityInitializations();

// Register Flight and OAB buttons
Appbar.RegisterAppButton(
"Micro Engineer",
Expand All @@ -47,22 +48,22 @@ public override void OnInitialized()
{
UI.Instance.ShowGuiOAB = isOpen;
Manager.Instance.Windows.FindAll(w => w is EntryWindow).Cast<EntryWindow>().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive = isOpen;
GameObject.Find("BTN - MicroEngineerOAB")?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(isOpen);
GameObject.Find("BTN-MicroEngineerOAB")?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(isOpen);
});
}

private void BackwardCompatibilityInitializations()
{
// Preserve backward compatibility with SpaceWarp 1.0.1
if (Utility.IsModOlderThan("SpaceWarp", 1, 1, 0))
// Preserve backward compatibility with SpaceWarp 1.1.x
if (Utility.IsModOlderThan("SpaceWarp", 1, 2, 0))
{
Logger.LogInfo("Space Warp older version detected. Loading old Styles.");
Styles.SetStylesForOldSpaceWarpSkin();
Logger.LogInfo("Older Space Warp version detected. Setting mod GUID to \"micro_engineer\".");
GUID = "micro_engineer";
}
else
Logger.LogInfo("Space Warp new version detected. Loading new Styles.");
Logger.LogInfo("New Space Warp version detected. No backward compatibility needed.");
}

public void Update()
{
Manager.Instance.Update();
Expand Down
2 changes: 1 addition & 1 deletion MicroEngineerProject/MicroEngineer/Utilities/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ internal static (int major, int minor, int patch)? GetModVersion(string modId)
if (versionNumbers.Length == 3)
int.TryParse(versionNumbers[2], out patchVersion);

Logger.LogInfo($"Space Warp version {majorVersion}.{minorVersion}.{patchVersion} detected.");
Logger.LogInfo($"{modId} version {majorVersion}.{minorVersion}.{patchVersion} detected.");

return (majorVersion, minorVersion, patchVersion);
}
Expand Down
5 changes: 3 additions & 2 deletions Staging/BepInEx/plugins/micro_engineer/swinfo.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"spec": "1.2",
"mod_id": "micro_engineer",
"author": "Micrologist, Falki",
"name": "Micro Engineer",
"description": "Get in-flight and VAB information about your current vessel",
"source": "https://github.com/Micrologist/MicroEngineer",
"version": "1.0.3",
"version": "1.1.0",
"version_check": "https://raw.githubusercontent.com/Micrologist/MicroEngineer/main/Staging/BepInEx/plugins/micro_engineer/swinfo.json",
"dependencies": [
{
"id": "SpaceWarp",
"version": {
"min": "1.0.1",
"min": "1.1.0",
"max": "*"
}
}
Expand Down

0 comments on commit 1d468cc

Please sign in to comment.