Skip to content

Commit

Permalink
v2.2
Browse files Browse the repository at this point in the history
- Fixed compatibility with older versions of RimWorld 1.3
  • Loading branch information
Jaxe-Dev committed Jun 24, 2022
1 parent 880ed7c commit dd905a1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Interaction Bubbles

![Mod Version](https://img.shields.io/badge/Mod_Version-2.1-blue)
![Mod Version](https://img.shields.io/badge/Mod_Version-2.2-blue)
![RimWorld Version](https://img.shields.io/badge/Built_for_RimWorld-1.3-blue)
![Harmony Version](https://img.shields.io/badge/Powered_by_Harmony-2.2-blue)\
[![Steam Subscribers](https://img.shields.io/steam/downloads/1516158345?color=blue&label=Steam%20Downloads&logo=Steam)](https://steamcommunity.com/sharedfiles/filedetails/?id=1516158345)
Expand Down Expand Up @@ -33,7 +33,6 @@ The following base methods are patched with Harmony:
```
Postfix : RimWorld.PlaySettings.DoPlaySettingsGlobalControls
Postfix : RimWorld.MapInterface.MapInterfaceOnGUI_BeforeMainTabs
Postfix : Verse.BattleLog.Add
Postfix : Verse.PlayLog.Add
Prefix : Verse.Profile.MemoryUtility.ClearAllMapsAndWorld
```
Expand Down
1 change: 0 additions & 1 deletion source/-/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ The following base methods are patched with Harmony:
```
Postfix : RimWorld.PlaySettings.DoPlaySettingsGlobalControls
Postfix : RimWorld.MapInterface.MapInterfaceOnGUI_BeforeMainTabs
Postfix : Verse.BattleLog.Add
Postfix : Verse.PlayLog.Add
Prefix : Verse.Profile.MemoryUtility.ClearAllMapsAndWorld
```
Expand Down
6 changes: 2 additions & 4 deletions source/Core/Bubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ private static void DrawAtlas(Rect rect, Texture2D atlas)

var scale = Mathf.RoundToInt(Mathf.Min(atlas.width * 0.25f, rect.height / 4f, rect.width / 4f));

if (Compatibility.HasSteamDeckUpdate) { Widgets.BeginGroup(rect); }
else { GUI.BeginGroup(rect); }
Compatibility.BeginGroupHandler(null, rect);

Widgets.DrawTexturePart(new Rect(0.0f, 0.0f, scale, scale), new Rect(0.0f, 0.0f, 0.25f, 0.25f), atlas);
Widgets.DrawTexturePart(new Rect(rect.width - scale, 0.0f, scale, scale), new Rect(0.75f, 0.0f, 0.25f, 0.25f), atlas);
Expand All @@ -130,8 +129,7 @@ private static void DrawAtlas(Rect rect, Texture2D atlas)
Widgets.DrawTexturePart(new Rect(0.0f, scale, scale, rect.height - (scale * 2f)), new Rect(0.0f, 0.25f, 0.25f, 0.5f), atlas);
Widgets.DrawTexturePart(new Rect(rect.width - scale, scale, scale, rect.height - (scale * 2f)), new Rect(0.75f, 0.25f, 0.25f, 0.5f), atlas);

if (Compatibility.HasSteamDeckUpdate) { Widgets.EndGroup(); }
else { GUI.EndGroup(); }
Compatibility.EndGroupHandler(null);
}

public void Rebuild() => _text = null;
Expand Down
12 changes: 4 additions & 8 deletions source/Core/Compatibility.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection;
using System;
using HarmonyLib;
using UnityEngine;
using Verse;

namespace Bubbles.Core
Expand All @@ -8,7 +9,8 @@ internal static class Compatibility
{
private static readonly bool CameraPlusLoaded = ModsConfig.IsActive("brrainz.cameraplus");

public static readonly bool HasSteamDeckUpdate = CheckHasSteamDeckUpdate();
public static readonly FastInvokeHandler BeginGroupHandler = MethodInvoker.GetHandler(typeof(Widgets).GetMethod("BeginGroup", new[] { typeof(Rect) }) ?? typeof(GUI).GetMethod(nameof(GUI.BeginGroup), new[] { typeof(Rect) }));
public static readonly FastInvokeHandler EndGroupHandler = MethodInvoker.GetHandler(typeof(Widgets).GetMethod("EndGroup", new Type[] { }) ?? typeof(GUI).GetMethod(nameof(GUI.EndGroup), new Type[] { }));

private static FastInvokeHandler _cameraPlusLerpRootSize;

Expand All @@ -22,11 +24,5 @@ private static void ApplyCameraPlus(ref float scale)

scale = (float) _cameraPlusLerpRootSize(null, scale);
}

private static bool CheckHasSteamDeckUpdate()
{
try { return typeof(Widgets).GetMethod("BeginGroup") != null && typeof(Widgets).GetMethod("EndGroup") != null; }
catch (AmbiguousMatchException) { return true; }
}
}
}
2 changes: 1 addition & 1 deletion source/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Mod : Verse.Mod
{
public const string Id = "Bubbles";
public const string Name = "Interaction Bubbles";
public const string Version = "2.1";
public const string Version = "2.2";

public static Mod Instance;

Expand Down

0 comments on commit dd905a1

Please sign in to comment.