Skip to content

Commit

Permalink
Merge pull request #181 from RedBrumbler/feat/extra-icons
Browse files Browse the repository at this point in the history
Add extra icons and display them in the avatar nametag
  • Loading branch information
Goobwabber authored Aug 17, 2023
2 parents ff60230 + afeacf4 commit aaee636
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
Binary file added MultiplayerExtensions/Assets/IconMeta64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MultiplayerExtensions/Assets/IconToaster64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions MultiplayerExtensions/Environment/MpexAvatarNameTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,23 @@ private void HandleMpexData(IConnectedPlayer player, MpexPlayerData data)

private void SetPlatformData(MpPlayerData data)
{
Sprite icon = null;
switch (data.Platform)
{
case Platform.Steam:
SetIcon(PlayerIconSlot.Platform, _spriteManager.IconSteam64);
icon = _spriteManager.IconSteam64;
break;
case Platform.OculusQuest:
icon = _spriteManager.IconMeta64;
break;
case Platform.OculusPC:
SetIcon(PlayerIconSlot.Platform, _spriteManager.IconOculus64);
icon = _spriteManager.IconOculus64;
break;
default:
icon = _spriteManager.IconToaster64;
break;
}
SetIcon(PlayerIconSlot.Platform, icon);
}

private void SetIcon(PlayerIconSlot slot, Sprite sprite)
Expand Down
7 changes: 4 additions & 3 deletions MultiplayerExtensions/MultiplayerExtensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Assets\IconMeta64.png" />
<EmbeddedResource Include="Assets\IconToaster64.png" />
<EmbeddedResource Include="manifest.json" />
<None Remove="Assets\IconMeta64.png" />
<None Remove="Assets\IconSteam64.png" />
<None Remove="Assets\IconToaster64.png" />
<None Remove="UI\MpexEnvironmentViewController.bsml" />
<None Remove="UI\MpexGameplaySetup.bsml" />
<None Remove="UI\MpexMiscViewController.bsml" />
Expand All @@ -209,9 +213,6 @@
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Assets" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="BeforeBuild" Condition="'$(NCRUNCH)' != '1'">
<Error Text="The BeatSaberModdingTools.Tasks nuget package doesn't seem to be installed." Condition="'$(BSMTTaskAssembly)' == ''" />
<GetCommitInfo ProjectDir="$(ProjectDir)">
Expand Down
19 changes: 18 additions & 1 deletion MultiplayerExtensions/Utilities/SpriteManager.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using SiraUtil.Logging;
using System;
using System.Reflection;
using System.Security.Policy;
using UnityEngine;
using Zenject;

namespace MultiplayerExtensions.Utilities
{
public class SpriteManager : IInitializable
public class SpriteManager : IInitializable, IDisposable
{
public Sprite IconOculus64 { get; private set; } = null!;
public Sprite IconSteam64 { get; private set; } = null!;
public Sprite IconMeta64 { get; private set; } = null!;
public Sprite IconToaster64 { get; private set; } = null!;

private readonly SiraLog _logger;

Expand All @@ -23,6 +26,20 @@ public void Initialize()
{
IconOculus64 = GetSpriteFromResources("MultiplayerExtensions.Assets.IconOculus64.png");
IconSteam64 = GetSpriteFromResources("MultiplayerExtensions.Assets.IconSteam64.png");
IconMeta64 = GetSpriteFromResources("MultiplayerExtensions.Assets.IconMeta64.png");
IconToaster64 = GetSpriteFromResources("MultiplayerExtensions.Assets.IconToaster64.png");
}

public void Dispose()
{
if (IconOculus64 != null) Sprite.Destroy(IconOculus64);
IconOculus64 = null;
if (IconSteam64 != null) Sprite.Destroy(IconSteam64);
IconSteam64 = null;
if (IconMeta64 != null) Sprite.Destroy(IconMeta64);
IconMeta64 = null;
if (IconToaster64 != null) Sprite.Destroy(IconToaster64);
IconToaster64 = null;
}

private Sprite GetSpriteFromResources(string resourcePath, float pixelsPerUnit = 10.0f)
Expand Down

0 comments on commit aaee636

Please sign in to comment.