|
3 | 3 | using Microsoft.Xna.Framework; |
4 | 4 | using Microsoft.Xna.Framework.Graphics; |
5 | 5 | using Monocle; |
| 6 | +using MonoMod.ModInterop; |
6 | 7 | using System; |
7 | 8 | using System.Collections; |
8 | 9 | using System.Collections.Generic; |
@@ -81,6 +82,19 @@ public class LobbyMapUI : Entity { |
81 | 82 | private int lastSelectedWarpIndex = -1; |
82 | 83 | private float scaleMultiplier = 1f; |
83 | 84 | private float finalScale => actualScale * scaleMultiplier; |
| 85 | + |
| 86 | + // mod interop |
| 87 | + private static readonly Dictionary<string, Action<Entity, List<Component>>> CustomRenderActions = new Dictionary<string, Action<Entity, List<Component>>>(); |
| 88 | + public static void AddCustomRenderAction(string collabID, Action<Entity, List<Component>> action) { |
| 89 | + if (CustomRenderActions.TryGetValue(collabID, out _)) |
| 90 | + CustomRenderActions[collabID] = action; |
| 91 | + else |
| 92 | + CustomRenderActions.Add(collabID, action); |
| 93 | + } |
| 94 | + public static void RemoveCustomRenderAction(string collabID) { |
| 95 | + if (CustomRenderActions.TryGetValue(collabID, out _)) |
| 96 | + CustomRenderActions.Remove(collabID); |
| 97 | + } |
84 | 98 |
|
85 | 99 | private Rectangle windowBounds; |
86 | 100 | private Rectangle mapBounds; |
@@ -701,6 +715,9 @@ public override void Render() { |
701 | 715 | if (CollabModule.Instance.SaveData.ShowVisitedPoints) { |
702 | 716 | drawVisitedPoints(); |
703 | 717 | } |
| 718 | + |
| 719 | + if (CustomRenderActions.TryGetValue(LobbyHelper.GetCollabNameForSID(lobbyMapInfo.LevelSet), out Action<Entity, List<Component>> customRenderAction)) |
| 720 | + customRenderAction(this, markerComponents); |
704 | 721 |
|
705 | 722 | drawForeground(); |
706 | 723 | } |
@@ -1204,5 +1221,20 @@ public LobbySelection(EntityData data, MapData map) { |
1204 | 1221 | } |
1205 | 1222 |
|
1206 | 1223 | #endregion |
| 1224 | + |
| 1225 | + #region ModInterop |
| 1226 | + |
| 1227 | + // ModInterop exports |
| 1228 | + [ModExportName("CollabUtils2.JournalHelper")] |
| 1229 | + private static class ModExports { |
| 1230 | + public static void AddCustomRenderAction(string collabID, Action<Entity, List<Component>> editor) { |
| 1231 | + LobbyMapUI.AddCustomRenderAction(collabID, editor); |
| 1232 | + } |
| 1233 | + public static void RemoveCustomRenderAction(string collabID) { |
| 1234 | + LobbyMapUI.RemoveCustomRenderAction(collabID); |
| 1235 | + } |
| 1236 | + } |
| 1237 | + |
| 1238 | + #endregion |
1207 | 1239 | } |
1208 | 1240 | } |
0 commit comments