Skip to content

Commit d487f91

Browse files
committed
add custom lobby map rendering + make dash count methods public (will require update to dashcountmod)
1 parent 1f955f8 commit d487f91

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

UI/JournalHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Celeste.Mod.CollabUtils2.UI {
88
public static class JournalHelper {
9-
private static Dictionary<string, Action<OuiJournal, string, bool>> JournalEditors = new Dictionary<string, Action<OuiJournal, string, bool>>();
9+
private static readonly Dictionary<string, Action<OuiJournal, string, bool>> JournalEditors = new Dictionary<string, Action<OuiJournal, string, bool>>();
1010

1111
internal static bool VanillaJournal = true; // default to vanilla journal
1212
internal static bool ShowOnlyDiscovered = false;
@@ -70,7 +70,6 @@ private static void OnJournalEnter(OuiJournal journal, Oui from) {
7070
}
7171

7272
// ModInterop exports
73-
7473
[ModExportName("CollabUtils2.JournalHelper")]
7574
private static class ModExports {
7675
public static void AddJournalEditor(string collabID, Action<OuiJournal, string, bool> editor) {

UI/LobbyMapUI.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Xna.Framework;
44
using Microsoft.Xna.Framework.Graphics;
55
using Monocle;
6+
using MonoMod.ModInterop;
67
using System;
78
using System.Collections;
89
using System.Collections.Generic;
@@ -81,6 +82,19 @@ public class LobbyMapUI : Entity {
8182
private int lastSelectedWarpIndex = -1;
8283
private float scaleMultiplier = 1f;
8384
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+
}
8498

8599
private Rectangle windowBounds;
86100
private Rectangle mapBounds;
@@ -701,6 +715,9 @@ public override void Render() {
701715
if (CollabModule.Instance.SaveData.ShowVisitedPoints) {
702716
drawVisitedPoints();
703717
}
718+
719+
if (CustomRenderActions.TryGetValue(LobbyHelper.GetCollabNameForSID(lobbyMapInfo.LevelSet), out Action<Entity, List<Component>> customRenderAction))
720+
customRenderAction(this, markerComponents);
704721

705722
drawForeground();
706723
}
@@ -1204,5 +1221,20 @@ public LobbySelection(EntityData data, MapData map) {
12041221
}
12051222

12061223
#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
12071239
}
12081240
}

UI/OuiJournalCollabProgressDashCountMod.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ namespace Celeste.Mod.CollabUtils2.UI {
88
/// </summary>
99
public static class OuiJournalCollabProgressDashCountMod {
1010
[MethodImpl(MethodImplOptions.NoInlining)]
11-
internal static bool IsDashCountEnabled() {
11+
public static bool IsDashCountEnabled() {
1212
return false;
1313
}
1414

1515
// those depend on Dash Count Mod settings / save data, and will be implemented by Dash Count Mod itself.
1616

1717
[MethodImpl(MethodImplOptions.NoInlining)]
18-
internal static bool DisplaysTotalDashes() {
18+
public static bool DisplaysTotalDashes() {
1919
return false;
2020
}
2121

2222
[MethodImpl(MethodImplOptions.NoInlining)]
23-
internal static int GetLevelDashesForJournalProgress(AreaStats stats) {
23+
public static int GetLevelDashesForJournalProgress(AreaStats stats) {
2424
return stats.BestTotalDashes;
2525
}
2626
}

0 commit comments

Comments
 (0)