Skip to content

Commit

Permalink
v3.1.3 adds exception handling in menus
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Nov 18, 2020
1 parent 0e863d6 commit 92b2ab4
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 5 deletions.
Binary file modified 1.1/Assemblies/AchtungMod.dll
Binary file not shown.
Binary file modified 1.2/Assemblies/AchtungMod.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>net.pardeike.rimworld.mod.achtung</identifier>
<version>3.1.2.0</version>
<version>3.1.3.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
2 changes: 1 addition & 1 deletion About/ModSync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ModSyncNinjaData>
<ID>be673269-db56-463b-8c36-e074881e0d77</ID>
<ModName>Achtung!</ModName>
<Version>3.1.2.0</Version>
<Version>3.1.3.0</Version>
<SaveBreaking>False</SaveBreaking>
<Host name="Github">
<Owner>pardeike</Owner>
Expand Down
2 changes: 1 addition & 1 deletion Source/JobDriver_CleanRoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ private Room RoomAt(IntVec3 cell)
return RegionAndRoomQuery.RoomAt(cell, pawn.Map);
}
}
}
}
18 changes: 18 additions & 0 deletions Source/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,32 @@ public static void Postfix(Pawn __instance, ref string __result)
[HarmonyPatch(typeof(FloatMenuMakerMap))]
[HarmonyPatch(nameof(FloatMenuMakerMap.ChoicesAtFor))]
[HarmonyPatch(new[] { typeof(Vector3), typeof(Pawn) })]
[StaticConstructorOnStartup]
static class FloatMenuMakerMap_ChoicesAtFor_Patch
{
static readonly Texture2D AttentionIcon = ContentFinder<Texture2D>.Get("AttentionIcon", true);

public static void Postfix(List<FloatMenuOption> __result, Vector3 clickPos, Pawn pawn)
{
if (pawn?.Map != null && pawn.Drafted == false)
if (WorldRendererUtility.WorldRenderedNow == false)
__result.AddRange(Controller.AchtungChoicesAtFor(clickPos, pawn));
}

public static Exception Finalizer(Exception __exception, List<FloatMenuOption> __result)
{
if (__exception != null)
{
var exceptionString = __exception.ToString();
__result.Add(new FloatMenuOption("Achtung caught and prevented some mod exception. Select this to copy the stacktrace to your clipboard", () =>
{
var te = new TextEditor { text = exceptionString };
te.SelectAll();
te.Copy();
}, AttentionIcon, Color.yellow, MenuOptionPriority.VeryLow));
}
return null;
}
}

// custom context menu
Expand Down
Binary file added Source/Originals/AttentionIcon.afphoto
Binary file not shown.
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

[assembly: Guid("8bd5a28f-96c4-43b4-907f-600aa0162f84")]

[assembly: AssemblyVersion("3.1.2.0")]
[assembly: AssemblyFileVersion("3.1.2.0")]
[assembly: AssemblyVersion("3.1.3.0")]
[assembly: AssemblyFileVersion("3.1.3.0")]
Binary file added Textures/AttentionIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 92b2ab4

Please sign in to comment.