Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

Commit 4e5d0dd

Browse files
committed
Added files.
1 parent 31195c1 commit 4e5d0dd

33 files changed

+2754
-0
lines changed

BinaryGZipSerializer.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.IO;
2+
using System.Runtime.Serialization.Formatters.Binary;
3+
using MelonLoader.ICSharpCode.SharpZipLib.GZip;
4+
5+
namespace ReMod.Core
6+
{
7+
public static class BinaryGZipSerializer
8+
{
9+
public static void Serialize(object value, string path)
10+
{
11+
var formatter = new BinaryFormatter();
12+
13+
using (var fStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
14+
{
15+
using (var gzipStream = new GZipOutputStream(fStream))
16+
{
17+
formatter.Serialize(gzipStream, value);
18+
}
19+
}
20+
}
21+
22+
public static object Deserialize(string path)
23+
{
24+
var formatter = new BinaryFormatter();
25+
26+
using (Stream fStream = File.OpenRead(path))
27+
{
28+
using (var gzipStream = new GZipInputStream(fStream))
29+
{
30+
return formatter.Deserialize(gzipStream);
31+
}
32+
}
33+
}
34+
}
35+
}

ConfigValue.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Linq;
3+
using MelonLoader;
4+
5+
namespace ReMod.Core
6+
{
7+
public class ConfigValue<T>
8+
{
9+
public event Action OnValueChanged;
10+
11+
private readonly MelonPreferences_Entry<T> _entry;
12+
13+
public T Value => _entry.Value;
14+
15+
public ConfigValue(string name, T defaultValue, string displayName = null, string description = null, bool isHidden = false)
16+
{
17+
var category = MelonPreferences.CreateCategory("ReMod");
18+
19+
var entryName = string.Concat(name.Where(c => char.IsLetter(c) || char.IsNumber(c)));
20+
_entry = category.GetEntry<T>(entryName) ?? category.CreateEntry(entryName, defaultValue, displayName, description, isHidden);
21+
_entry.OnValueChangedUntyped += () => OnValueChanged?.Invoke();
22+
}
23+
24+
public static implicit operator T(ConfigValue<T> conf)
25+
{
26+
return conf._entry.Value;
27+
}
28+
29+
public void SetValue(T value)
30+
{
31+
_entry.Value = value;
32+
MelonPreferences.Save();
33+
}
34+
35+
public override string ToString()
36+
{
37+
return _entry.Value.ToString();
38+
}
39+
}
40+
}

Managers/ResourceManager.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Reflection;
5+
using UnityEngine;
6+
7+
namespace ReMod.Core.Managers
8+
{
9+
public class ResourceManager
10+
{
11+
private readonly Dictionary<string, Texture2D> _textures = new Dictionary<string, Texture2D>();
12+
private readonly Dictionary<string, Sprite> _sprites = new Dictionary<string, Sprite>();
13+
14+
private readonly Assembly _ourAssembly;
15+
16+
private readonly string _resourcePath;
17+
18+
public static ResourceManager Instance { get; private set; }
19+
public ResourceManager(Assembly ourAssembly, string resourcePath)
20+
{
21+
if (Instance != null)
22+
{
23+
throw new Exception("ResourceManager already exists.");
24+
}
25+
Instance = this;
26+
27+
_ourAssembly = ourAssembly;
28+
_resourcePath = resourcePath;
29+
}
30+
31+
public Texture2D GetTexture(string resourceName)
32+
{
33+
if (_textures.ContainsKey(resourceName))
34+
{
35+
return _textures[resourceName];
36+
}
37+
38+
var resourcePath = $"{_resourcePath}.{resourceName}.png";
39+
var stream = _ourAssembly.GetManifestResourceStream(resourcePath);
40+
if (stream == null)
41+
{
42+
throw new ArgumentException($"Resource \"{resourcePath}\" doesn't exist", nameof(resourceName));
43+
}
44+
45+
using var ms = new MemoryStream();
46+
stream.CopyTo(ms);
47+
48+
var texture = new Texture2D(1, 1);
49+
ImageConversion.LoadImage(texture, ms.ToArray());
50+
texture.hideFlags |= HideFlags.DontUnloadUnusedAsset;
51+
texture.wrapMode = TextureWrapMode.Clamp;
52+
53+
_textures.Add(resourceName, texture);
54+
55+
return texture;
56+
}
57+
58+
public Sprite GetSprite(string resourceName)
59+
{
60+
if (_sprites.ContainsKey(resourceName))
61+
{
62+
return _sprites[resourceName];
63+
}
64+
65+
var texture = GetTexture(resourceName);
66+
67+
var rect = new Rect(0.0f, 0.0f, texture.width, texture.height);
68+
var pivot = new Vector2(0.5f, 0.5f);
69+
var border = Vector4.zero;
70+
var sprite = Sprite.CreateSprite_Injected(texture, ref rect, ref pivot, 100.0f, 0, SpriteMeshType.Tight, ref border, false);
71+
sprite.hideFlags |= HideFlags.DontUnloadUnusedAsset;
72+
73+
_sprites.Add(resourceName, sprite);
74+
75+
return sprite;
76+
}
77+
}
78+
}

Managers/UiManager.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System;
2+
using ReMod.Core.UI;
3+
using ReMod.Core.VRChat;
4+
using UnityEngine;
5+
using UnityEngine.UI;
6+
using VRC.UI.Elements;
7+
8+
namespace ReMod.Core.Managers
9+
{
10+
public class UiManager
11+
{
12+
public ReMenuPage MainMenu { get; }
13+
public ReMenuCategory TargetMenu { get; }
14+
15+
private static UiManager _instance;
16+
public UiManager(string menuName, Sprite menuSprite)
17+
{
18+
if (_instance != null)
19+
{
20+
throw new Exception("UiManager already exists.");
21+
}
22+
_instance = this;
23+
24+
FixLaunchpadScrolling();
25+
26+
var resourceManager = ResourceManager.Instance;
27+
MainMenu = new ReMenuPage(menuName, true);
28+
ReTabButton.Create(menuName, $"Open the {menuName} menu.", menuName, menuSprite);
29+
30+
MainMenu.AddCategoryPage("Movement", sprite: resourceManager.GetSprite("running"));
31+
32+
var visualCatPage = MainMenu.AddCategoryPage("Visuals", sprite: resourceManager.GetSprite("eye"));
33+
34+
visualCatPage.AddCategory("ESP/Highlights");
35+
visualCatPage.AddCategory("Flashlight");
36+
visualCatPage.AddCategory("Wireframe");
37+
visualCatPage.AddCategory("Bone ESP");
38+
visualCatPage.AddCategory("Nametags");
39+
40+
MainMenu.AddMenuPage("Dynamic Bones", sprite: resourceManager.GetSprite("bone"));
41+
MainMenu.AddMenuPage("Avatars", sprite: resourceManager.GetSprite("hanger"));
42+
43+
var utilCatPage = MainMenu.AddCategoryPage("Utility", sprite: resourceManager.GetSprite("tools"));
44+
45+
utilCatPage.AddCategory("Quality of Life");
46+
utilCatPage.AddCategory("Local Clone");
47+
utilCatPage.AddCategory("Objects");
48+
utilCatPage.AddCategory("Spoofing");
49+
utilCatPage.AddCategory("Protection");
50+
utilCatPage.AddCategory("Emojis");
51+
utilCatPage.AddCategory("Media Controls");
52+
utilCatPage.AddCategory("Staff Alerts");
53+
utilCatPage.AddCategory("Near Clipping Plane");
54+
utilCatPage.AddCategory("Application");
55+
56+
MainMenu.AddMenuPage("Logging", sprite: resourceManager.GetSprite("log"));
57+
MainMenu.AddMenuPage("FBT", sprite: resourceManager.GetSprite("arms-up"));
58+
MainMenu.AddMenuPage("Hotkeys", sprite: resourceManager.GetSprite("keyboard"));
59+
60+
TargetMenu = new ReMenuCategory($"{menuName}", ExtendedQuickMenu.Instance.field_Private_UIPage_1.transform.Find("ScrollRect").GetComponent<ScrollRect>().content);
61+
}
62+
63+
private void FixLaunchpadScrolling()
64+
{
65+
var dashboard = ExtendedQuickMenu.Instance.field_Public_Transform_0.Find("Window/QMParent/Menu_Dashboard").GetComponent<UIPage>();
66+
var scrollRect = dashboard.GetComponentInChildren<ScrollRect>();
67+
var dashboardScrollbar = scrollRect.transform.Find("Scrollbar").GetComponent<Scrollbar>();
68+
69+
var dashboardContent = scrollRect.content;
70+
dashboardContent.GetComponent<VerticalLayoutGroup>().childControlHeight = true;
71+
dashboardContent.Find("Carousel_Banners").gameObject.SetActive(false);
72+
73+
scrollRect.enabled = true;
74+
scrollRect.verticalScrollbar = dashboardScrollbar;
75+
scrollRect.viewport.GetComponent<RectMask2D>().enabled = true;
76+
}
77+
}
78+
}

ModComponent.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using ExitGames.Client.Photon;
2+
using HarmonyLib;
3+
using MelonLoader;
4+
using Photon.Pun;
5+
using Photon.Realtime;
6+
using ReMod.Core.Managers;
7+
using System;
8+
using System.Reflection;
9+
using VRC.Core;
10+
using VRC.DataModel;
11+
using VRC.SDKBase;
12+
using Player = VRC.Player;
13+
14+
namespace ReMod.Core
15+
{
16+
public class ComponentDisabled : Attribute
17+
{
18+
}
19+
20+
public class ComponentPriority : Attribute
21+
{
22+
public int Priority;
23+
public ComponentPriority(int priority = 0) => Priority = priority;
24+
}
25+
26+
public class ModComponent
27+
{
28+
public virtual void OnUiManagerInitEarly(){}
29+
public virtual void OnUiManagerInit(UiManager uiManager){}
30+
public virtual void OnFixedUpdate(){}
31+
public virtual void OnUpdate(){}
32+
public virtual void OnLateUpdate(){}
33+
public virtual void OnGUI(){}
34+
public virtual void OnSceneWasLoaded(int buildIndex, string sceneName){}
35+
public virtual void OnSceneWasInitialized(int buildIndex, string sceneName){}
36+
public virtual void OnApplicationQuit(){}
37+
public virtual void OnPreferencesSaved(){}
38+
public virtual void OnPreferencesLoaded(){ }
39+
public virtual void OnPhotonPlayerJoined(Il2CppSystem.Collections.Hashtable propertiesTable) { }
40+
public virtual void OnPhotonPlayerLeft(Photon.Realtime.Player player) { }
41+
public virtual void OnPlayerJoined(Player player){}
42+
public virtual void OnPlayerLeft(Player player){}
43+
public virtual void OnAvatarIsReady(VRCPlayer player){}
44+
public virtual void OnEnterWorld(ApiWorld world, ApiWorldInstance instance){}
45+
public virtual void OnSelectUser(IUser user, bool isRemote){ }
46+
47+
// return value determines whether it found something malicious and should block the original function
48+
public virtual bool ExecuteEvent(Player player, VRC_EventHandler.VrcEvent evt, VRC_EventHandler.VrcBroadcastType broadcastType, int instagatorId, float fastForward) { return false; }
49+
public virtual bool OnPhotonEvent(LoadBalancingClient loadBalancingClient, ref EventData eventData) { return false; }
50+
public virtual bool VRCNetworkingClientOnPhotonEvent(EventData eventData) { return false; }
51+
public virtual bool VRC_EventLogOnPhotonEvent(EventData eventData) { return false; }
52+
public virtual bool OnDownloadAvatar(ApiAvatar apiAvatar) { return false; }
53+
public virtual bool OnRaiseEvent(byte eventCode, ref Il2CppSystem.Object content, RaiseEventOptions raiseEventOptions, SendOptions sendOptions) { return false; }
54+
55+
public virtual void OnOwnershipTransfered(Photon.Realtime.Player player, PhotonView photonView, bool isMaster, bool isRequest){}
56+
public virtual void OnBlockStateChange(Photon.Realtime.Player instigator, bool blocked){ }
57+
public virtual void OnMuteStateChange(Photon.Realtime.Player instigator, bool muted) { }
58+
public virtual void OnModUserListUpdated() { }
59+
public virtual void OnRenderObject() { }
60+
public virtual void OnOperationResponse(LoadBalancingClient loadBalancingClient, OperationResponse operationResponse) { }
61+
public virtual void OnJoinedRoom() { }
62+
public virtual void OnLeftRoom() { }
63+
64+
protected HarmonyMethod GetLocalPatch(string methodName)
65+
{
66+
return GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static).ToNewHarmonyMethod();
67+
}
68+
}
69+
}

Properties/AssemblyInfo.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
// General Information about an assembly is controlled through the following
5+
// set of attributes. Change these attribute values to modify the information
6+
// associated with an assembly.
7+
[assembly: AssemblyTitle("ReMod.Core")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("ReMod.Core")]
12+
[assembly: AssemblyCopyright("Copyright © 2021")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// Setting ComVisible to false makes the types in this assembly not visible
17+
// to COM components. If you need to access a type in this assembly from
18+
// COM, set the ComVisible attribute to true on that type.
19+
[assembly: ComVisible(false)]
20+
21+
// The following GUID is for the ID of the typelib if this project is exposed to COM
22+
[assembly: Guid("c87fe758-acb9-4fa2-af6f-10aa9aa0023c")]
23+
24+
// Version information for an assembly consists of the following four values:
25+
//
26+
// Major Version
27+
// Minor Version
28+
// Build Number
29+
// Revision
30+
//
31+
// You can specify all the values or you can default the Build and Revision Numbers
32+
// by using the '*' as shown below:
33+
// [assembly: AssemblyVersion("1.0.*")]
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)