Skip to content

Commit

Permalink
CelesteNet: display the lobby icon instead of the map icon in the pla…
Browse files Browse the repository at this point in the history
…yer list when playing a collab
  • Loading branch information
maddie480 committed Jan 10, 2022
1 parent 2976f96 commit b615fca
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CollabUtils2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<Reference Include="CelesteNet.Client">
<HintPath>lib-stripped\CelesteNet.Client.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="CelesteNet.Shared">
<HintPath>lib-stripped\CelesteNet.Shared.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>

<Choose>
<When Condition="Exists('..\..\Celeste.exe')">
<ItemGroup>
Expand Down
18 changes: 18 additions & 0 deletions LobbyHelper.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Celeste.Mod.CelesteNet.Client.Components;
using Celeste.Mod.CollabUtils2.UI;
using Celeste.Mod.UI;
using Mono.Cecil;
Expand Down Expand Up @@ -35,6 +36,10 @@ internal static void OnInitialize() {
) {
LoadCollabIDFile(asset);
}

if (Everest.Loader.DependencyLoaded(new EverestModuleMetadata() { Name = "CelesteNet.Client", Version = new Version(2, 0, 0) })) {
adjustCollabIcon();
}
}

public static void LoadCollabIDFile(ModAsset asset) {
Expand Down Expand Up @@ -169,6 +174,19 @@ internal static void Unload() {
hookOnOuiFileSelectSlotRender?.Dispose();
}

private static void adjustCollabIcon() {
CelesteNetPlayerListComponent.OnGetState += (blob, state) => {
// if we are in a collab map, change the icon displayed in the CelesteNet player list to the lobby icon.
AreaData data = AreaData.Get(state.SID);
if (data != null) {
string lobbySID = GetLobbyForLevelSet(data.LevelSet);
if (lobbySID != null) {
blob.Location.Icon = AreaData.Get(lobbySID)?.Icon ?? blob.Location.Icon;
}
}
};
}

public static void OnSessionCreated() {
Session session = SaveData.Instance.CurrentSession_Safe;
string levelSet = GetLobbyLevelSet(session.Area.GetSID());
Expand Down
2 changes: 1 addition & 1 deletion everest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- Name: CollabUtils2
Version: 1.6.1
Version: 1.6.2
DLL: bin/Debug/net452/CollabUtils2.dll
Dependencies:
- Name: Everest
Expand Down
Binary file added lib-stripped/CelesteNet.Client.dll
Binary file not shown.
Binary file added lib-stripped/CelesteNet.Shared.dll
Binary file not shown.

0 comments on commit b615fca

Please sign in to comment.