This repository has been archived by the owner on Nov 19, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,763 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using UnhollowerBaseLib.Attributes; | ||
using UnityEngine; | ||
|
||
namespace PlayerList.Components | ||
{ | ||
class EnableDisableListener : MonoBehaviour | ||
{ | ||
[method: HideFromIl2Cpp] | ||
public event Action OnEnableEvent; | ||
[method: HideFromIl2Cpp] | ||
public event Action OnDisableEvent; | ||
public EnableDisableListener(IntPtr obj0) : base(obj0) { } | ||
|
||
public void OnEnable() => OnEnableEvent?.Invoke(); | ||
public void OnDisable() => OnDisableEvent?.Invoke(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using MelonLoader; | ||
using UnityEngine; | ||
|
||
namespace PlayerList | ||
{ | ||
class Config | ||
{ | ||
// TODO: Make is so the vector 2 acutlaly uses the custom mapper when it gets fixed | ||
public static readonly string categoryIdentifier = "PlayerList Config"; | ||
public static MelonPreferences_Category category = MelonPreferences.CreateCategory(categoryIdentifier); | ||
|
||
public static MelonPreferences_Entry<bool> enabledOnStart; | ||
public static MelonPreferences_Entry<bool> condensedText; | ||
public static MelonPreferences_Entry<int> fontSize; | ||
public static MelonPreferences_Entry<int> snapToGridSize; | ||
|
||
public static MelonPreferences_Entry<bool> pingToggle; | ||
public static MelonPreferences_Entry<bool> fpsToggle; | ||
public static MelonPreferences_Entry<bool> platformToggle; | ||
public static MelonPreferences_Entry<bool> perfToggle; | ||
public static MelonPreferences_Entry<bool> displayNameToggle; | ||
public static bool HasSomethingOff | ||
{ | ||
get | ||
{ | ||
if (!pingToggle.Value || !fpsToggle.Value || !platformToggle.Value || !perfToggle.Value || !displayNameToggle.Value) | ||
return true; | ||
return false; | ||
} | ||
} | ||
|
||
public static MelonPreferences_Entry<int> playerListMenuButtonPosition; | ||
|
||
private static MelonPreferences_Entry<float> _playerListPositionX; | ||
private static MelonPreferences_Entry<float> _playerListPositionY; | ||
public static Vector2 PlayerListPosition | ||
{ | ||
get { return Utilities.Converters.ConvertToUnityUnits(new Vector2(_playerListPositionX.Value, _playerListPositionY.Value)); } | ||
set | ||
{ | ||
Vector2 convertedVector = Utilities.Converters.ConvertToMenuUnits(value); | ||
_playerListPositionX.Value = convertedVector.x; | ||
_playerListPositionY.Value = convertedVector.y; | ||
} | ||
} | ||
|
||
public static void RegisterSettings() | ||
{ | ||
enabledOnStart = (MelonPreferences_Entry<bool>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(enabledOnStart), true, is_hidden: true); | ||
condensedText = (MelonPreferences_Entry<bool>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(condensedText), false, is_hidden: true); | ||
fontSize = (MelonPreferences_Entry<int>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(fontSize), 35, is_hidden: true); | ||
snapToGridSize = (MelonPreferences_Entry<int>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(snapToGridSize), 420, is_hidden: true); | ||
|
||
pingToggle = (MelonPreferences_Entry<bool>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(pingToggle), true, is_hidden: true); | ||
fpsToggle = (MelonPreferences_Entry<bool>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(fpsToggle), true, is_hidden: true); | ||
platformToggle = (MelonPreferences_Entry<bool>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(platformToggle), true, is_hidden: true); | ||
perfToggle = (MelonPreferences_Entry<bool>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(perfToggle), true, is_hidden: true); | ||
displayNameToggle = (MelonPreferences_Entry<bool>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(displayNameToggle), true, is_hidden: true); | ||
|
||
playerListMenuButtonPosition = (MelonPreferences_Entry<int>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(playerListMenuButtonPosition), 1, is_hidden: true); | ||
|
||
_playerListPositionX = (MelonPreferences_Entry<float>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(_playerListPositionX), 7.5f, is_hidden: true); | ||
_playerListPositionY = (MelonPreferences_Entry<float>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(_playerListPositionY), 3.5f, is_hidden: true); | ||
// playerListPosition = (MelonPreferences_Entry<Vector2>)MelonPreferences.CreateEntry(categoryIdentifier, nameof(playerListPosition), (Vector2)Utilities.Converters.ConvertToUnityUnits(new Vector3(7.5f, 3.5f)), is_hidden: true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using VRC; | ||
|
||
namespace PlayerList.Entries | ||
{ | ||
class CoordinatePositionEntry : EntryBase | ||
{ | ||
public override string Name { get { return "Coordinate Position"; } } | ||
public override void ProcessText(object[] parameters = null) | ||
{ | ||
ChangeEntry("x", Math.Round(Player.prop_Player_0.gameObject.transform.position.x, 1)); | ||
ChangeEntry("y", Math.Round(Player.prop_Player_0.gameObject.transform.position.y, 1)); | ||
ChangeEntry("z", Math.Round(Player.prop_Player_0.gameObject.transform.position.z, 1)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using MelonLoader; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace PlayerList.Entries | ||
{ | ||
public class EntryBase | ||
{ | ||
public virtual string Name { get; } | ||
|
||
public MelonPreferences_Entry<bool> prefEntry; | ||
|
||
private string _originalText; | ||
public string OriginalText | ||
{ | ||
get { return _originalText; } | ||
} | ||
|
||
public GameObject gameObject; | ||
public Text textComponent; | ||
|
||
private int _identifier; | ||
public int Identifier | ||
{ | ||
get { return _identifier; } | ||
} | ||
|
||
public virtual void Init(object[] parameters = null) | ||
{ | ||
|
||
} | ||
|
||
public void Refresh(object[] parameters = null) | ||
{ | ||
textComponent.text = _originalText; | ||
ProcessText(parameters); | ||
} | ||
|
||
public virtual void ProcessText(object[] parameters = null) | ||
{ | ||
} | ||
|
||
public static T CreateInstance<T>(GameObject gameObject, object[] parameters = null, bool includeConfig = false) where T : EntryBase, new() | ||
{ | ||
EntryBase entry = new T(); | ||
|
||
entry._identifier = gameObject.GetInstanceID(); | ||
entry.gameObject = gameObject; | ||
entry.textComponent = gameObject.GetComponent<Text>(); | ||
entry._originalText = entry.textComponent.text; | ||
if (includeConfig) | ||
{ | ||
entry.prefEntry = (MelonPreferences_Entry<bool>)MelonPreferences.CreateEntry(Config.categoryIdentifier, entry.Name.Replace(" ", ""), true, is_hidden: true); | ||
entry.gameObject.SetActive(entry.prefEntry.Value); | ||
} | ||
entry.Init(parameters); | ||
|
||
return (T)entry; | ||
} | ||
public void ChangeEntry(string identifier, string value) => textComponent.text = textComponent.text.Replace($"{{{identifier}}}", value); | ||
public void ChangeEntry(string identifier, object value) => textComponent.text = textComponent.text.Replace($"{{{identifier}}}", value.ToString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
namespace PlayerList.Entries | ||
{ | ||
class GameVersionEntry : EntryBase | ||
{ | ||
public override string Name { get { return "Game Version"; } } | ||
|
||
public static int buildNumber = Resources.FindObjectsOfTypeAll<VRCApplicationSetup>().First().field_Public_Int32_0; | ||
|
||
public override void ProcessText(object[] parameters = null) => ChangeEntry("gameversion", buildNumber); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using VRC.Core; | ||
|
||
namespace PlayerList.Entries | ||
{ | ||
class InstanceCreatorEntry : EntryBase | ||
{ | ||
public override string Name { get { return "Instance Creator"; } } | ||
|
||
public string creatorTag; | ||
public string lastUserDisplayName; | ||
public override void ProcessText(object[] parameters = null) | ||
{ | ||
if (RoomManager.field_Internal_Static_ApiWorldInstance_0 != null) | ||
{ | ||
Il2CppSystem.Collections.Generic.List<ApiWorldInstance.InstanceTag> tags = RoomManager.field_Internal_Static_ApiWorldInstance_0.ParseTags(RoomManager.field_Internal_Static_ApiWorldInstance_0.idWithTags); | ||
foreach (ApiWorldInstance.InstanceTag tag in tags) | ||
{ | ||
if (tag.name == "private" || tag.name == "friend" || tag.name == "hidden") | ||
{ | ||
if (creatorTag == tag.data) | ||
{ | ||
ChangeEntry("instancecreator", lastUserDisplayName); | ||
return; | ||
} | ||
|
||
if (tag.data == APIUser.CurrentUser.id) | ||
{ | ||
ChangeEntry("instancecreator", APIUser.CurrentUser.displayName); | ||
lastUserDisplayName = APIUser.CurrentUser.displayName; | ||
} | ||
else | ||
{ | ||
APIUser.FetchUser(tag.data, new Action<APIUser>(OnIdReceived), null); | ||
ChangeEntry("instancecreator", "Loading..."); | ||
} | ||
|
||
creatorTag = tag.data; | ||
return; | ||
} | ||
} | ||
} | ||
|
||
ChangeEntry("instancecreator", "No Instance Creator"); | ||
creatorTag = null; | ||
} | ||
public void OnIdReceived(APIUser user) | ||
{ | ||
lastUserDisplayName = user.displayName; | ||
MelonLoader.MelonLogger.Msg("User fetched"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using VRC; | ||
|
||
namespace PlayerList.Entries | ||
{ | ||
class InstanceMasterEntry : EntryBase | ||
{ | ||
public override string Name { get { return "Instance Master"; } } | ||
|
||
public override void ProcessText(object[] parameters = null) | ||
{ | ||
if (PlayerManager.field_Private_Static_PlayerManager_0 == null) return; | ||
|
||
foreach (Player player in PlayerManager.field_Private_Static_PlayerManager_0.field_Private_List_1_Player_0) | ||
{ | ||
if (player.prop_VRCPlayerApi_0 == null) return; | ||
|
||
if (player.prop_VRCPlayerApi_0.isMaster) | ||
{ | ||
if (player.field_Private_APIUser_0 == null) return; | ||
ChangeEntry("instancemaster", player.field_Private_APIUser_0.displayName); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using UnityEngine; | ||
using VRC; | ||
using VRC.Core; | ||
|
||
namespace PlayerList.Entries | ||
{ | ||
class LocalPlayerEntry : EntryBase | ||
{ | ||
public override string Name { get { return "Local Player"; } } | ||
|
||
public TMPro.TextMeshProUGUI perfText; | ||
|
||
public override void Init(object[] parameters) | ||
{ | ||
gameObject.GetComponent<UnityEngine.UI.Button>().onClick.AddListener(new System.Action(() => PlayerEntry.OpenPlayerInQuickMenu(Player.prop_Player_0))); | ||
perfText = Player.prop_Player_0.transform.Find("Player Nameplate/Canvas/Nameplate/Contents/Quick Stats/Performance Text").GetComponent<TMPro.TextMeshProUGUI>(); | ||
} | ||
public override void ProcessText(object[] parameters) | ||
{ | ||
if (Config.condensedText.Value && !Config.HasSomethingOff) | ||
textComponent.text = textComponent.text.Replace(" ", ""); | ||
|
||
// Convert to byte as that's what's sent over network so if you spoof your ping you'll see what's actually sent over the network | ||
if (Config.pingToggle.Value) | ||
{ | ||
ChangeEntry("pingcolor", PlayerEntry.GetPingColor((short)Photon.Pun.PhotonNetwork.field_Public_Static_LoadBalancingClient_0.prop_LoadBalancingPeer_0.RoundTripTime)); | ||
ChangeEntry("ping", ((short)Photon.Pun.PhotonNetwork.field_Public_Static_LoadBalancingClient_0.prop_LoadBalancingPeer_0.RoundTripTime).ToString().PadRight(4)); | ||
} | ||
|
||
// I STG if I have to remove fps because skids start walking up to people saying poeple's fps im gonna murder someone | ||
if (Config.fpsToggle.Value) | ||
{ | ||
ChangeEntry("fpscolor", PlayerEntry.GetFpsColor((int)(1f / Time.deltaTime))); | ||
ChangeEntry("fps", ((int)(1f / Time.deltaTime)).ToString().PadRight(3)); | ||
} | ||
|
||
if (Config.platformToggle.Value) | ||
ChangeEntry("platform", PlayerEntry.ParsePlatform(Player.prop_Player_0).PadRight(5)); | ||
|
||
if (Config.perfToggle.Value) | ||
{ | ||
if (perfText != null) | ||
{ | ||
ChangeEntry("perfcolor", "#" + ColorUtility.ToHtmlStringRGB(perfText.color)); | ||
ChangeEntry("perf", PlayerEntry.ParsePerformanceText(perfText.text).PadRight(5)); | ||
} | ||
else | ||
{ | ||
perfText = Player.prop_Player_0.transform.Find("Player Nameplate/Canvas/Nameplate/Contents/Quick Stats/Performance Text").GetComponent<TMPro.TextMeshProUGUI>(); | ||
ChangeEntry("perfcolor", "#ff00000"); | ||
ChangeEntry("perf", "???"); | ||
} | ||
} | ||
|
||
if (Config.displayNameToggle.Value) | ||
{ | ||
ChangeEntry("rankcolor", "#" + ColorUtility.ToHtmlStringRGB(VRCPlayer.Method_Public_Static_Color_APIUser_0(APIUser.CurrentUser))); | ||
ChangeEntry("displayname", APIUser.CurrentUser.displayName); | ||
} | ||
|
||
if (Config.HasSomethingOff) | ||
textComponent.text = " - " + PlayerEntry.RemoveOffToggles(textComponent.text.Substring(3)); | ||
} | ||
} | ||
} |
Oops, something went wrong.