diff --git a/AdvancedSafety/AdvancedSafetyMod.cs b/AdvancedSafety/AdvancedSafetyMod.cs index 10a683a..c05299a 100644 --- a/AdvancedSafety/AdvancedSafetyMod.cs +++ b/AdvancedSafety/AdvancedSafetyMod.cs @@ -26,6 +26,8 @@ namespace AdvancedSafety { internal partial class AdvancedSafetyMod : MelonMod { + public static MelonLogger.Instance Logger; + internal static bool CanReadAudioMixers = true; internal static bool CanReadBadFloats = true; @@ -35,6 +37,8 @@ internal partial class AdvancedSafetyMod : MelonMod public override void OnApplicationStart() { if (!CheckWasSuccessful || !MustStayTrue || MustStayFalse) return; + + Logger = LoggerInstance; AdvancedSafetySettings.RegisterSettings(); ClassInjector.RegisterTypeInIl2Cpp(); @@ -45,7 +49,7 @@ public override void OnApplicationStart() } catch (Exception ex) { - MelonLogger.Error($"Error initializing Bundle Verifier: {ex}"); + Logger.Error($"Error initializing Bundle Verifier: {ex}"); } var matchingMethods = typeof(AssetManagement) @@ -251,7 +255,7 @@ void Bfs(GameObjectWithPriorityData objWithPriority) go.AddComponent(); if (MelonDebug.IsEnabled() || destroyedObjects > 100) - MelonLogger.Msg($"Cleaned avatar ({avatarManager.field_Private_ApiAvatar_0?.name}) used by \"{vrcPlayer.prop_VRCPlayerApi_0?.displayName}\" in {start.ElapsedMilliseconds}ms, scanned {scannedObjects} things, destroyed {destroyedObjects} things"); + Logger.Msg($"Cleaned avatar ({avatarManager.field_Private_ApiAvatar_0?.name}) used by \"{vrcPlayer.prop_VRCPlayerApi_0?.displayName}\" in {start.ElapsedMilliseconds}ms, scanned {scannedObjects} things, destroyed {destroyedObjects} things"); } private static IEnumerator CheckSpawnSounds(GameObject go, List audioSourcesList) @@ -303,7 +307,7 @@ private static IntPtr ObjectInstantiatePatch(IntPtr assetPtr, Vector3 pos, Quate } catch (Exception ex) { - MelonLogger.Error($"Exception when cleaning avatar: {ex}"); + Logger.Error($"Exception when cleaning avatar: {ex}"); } return result; diff --git a/AdvancedSafety/AvatarHiding.cs b/AdvancedSafety/AvatarHiding.cs index 82d2a85..9479867 100644 --- a/AdvancedSafety/AvatarHiding.cs +++ b/AdvancedSafety/AvatarHiding.cs @@ -101,7 +101,7 @@ private static void CanUseCustomAvatarPostfix(ref bool __result) if (ourBlockedAvatarAuthors.ContainsKey(apiAvatar.authorId) || ourBlockedAvatars.ContainsKey(apiAvatar.id)) { - MelonLogger.Msg( + AdvancedSafetyMod.Logger.Msg( $"Hiding avatar on {apiUser.displayName} because it or its author is hidden"); // denyReason = 3; __result = false; @@ -109,7 +109,7 @@ private static void CanUseCustomAvatarPostfix(ref bool __result) } catch (Exception ex) { - MelonLogger.Error($"Exception in CanUseCustomAvatarPatch: {ex}"); + AdvancedSafetyMod.Logger.Error($"Exception in CanUseCustomAvatarPatch: {ex}"); } } diff --git a/AdvancedSafety/BundleVerifier/BundleDlContext.cs b/AdvancedSafety/BundleVerifier/BundleDlContext.cs index 196c1ba..57b8c3c 100644 --- a/AdvancedSafety/BundleVerifier/BundleDlContext.cs +++ b/AdvancedSafety/BundleVerifier/BundleDlContext.cs @@ -48,7 +48,7 @@ internal bool PreProcessBytes() } catch (Exception ex) { - MelonLogger.Error($"Error while initializing verifier internals: {ex}"); + AdvancedSafetyMod.Logger.Error($"Error while initializing verifier internals: {ex}"); return false; } @@ -63,8 +63,8 @@ internal int ProcessBytes(byte[] bytes, int offset, int length) } catch (IOException ex) { - MelonLogger.Error($"Received more bytes than declared for bundle URL {Url} (declared: {BundleDlInterceptor.GetTotalSize(OriginalBundleDownload)})"); - MelonLogger.Error(ex.ToString()); + AdvancedSafetyMod.Logger.Error($"Received more bytes than declared for bundle URL {Url} (declared: {BundleDlInterceptor.GetTotalSize(OriginalBundleDownload)})"); + AdvancedSafetyMod.Logger.Error(ex.ToString()); DoBackSpew(); unsafe { @@ -100,7 +100,7 @@ internal void CompleteDownload() if (exitCode != 0) { var cleanedUrl = BundleVerifierMod.SanitizeUrl(Url); - MelonLogger.Msg($"Verifier process failed with exit code {exitCode} ({VerifierExitCodes.GetExitCodeDescription(exitCode)}) for bundle uid={cleanedUrl.Item1}+{cleanedUrl.Item2}"); + AdvancedSafetyMod.Logger.Msg($"Verifier process failed with exit code {exitCode} ({VerifierExitCodes.GetExitCodeDescription(exitCode)}) for bundle uid={cleanedUrl.Item1}+{cleanedUrl.Item2}"); BundleVerifierMod.BadBundleCache.Add(Url); MelonDebug.Msg("Reporting completion without data"); // feed some garbage into it, otherwise it dies diff --git a/AdvancedSafety/BundleVerifier/BundleDlInterceptor.cs b/AdvancedSafety/BundleVerifier/BundleDlInterceptor.cs index b1ffd03..b7bd716 100644 --- a/AdvancedSafety/BundleVerifier/BundleDlInterceptor.cs +++ b/AdvancedSafety/BundleVerifier/BundleDlInterceptor.cs @@ -37,7 +37,7 @@ internal static int PreparePatch(IntPtr thisPtr) if (ourInterceptedContext.TryGetValue(thisPtr, out var context) && context.IsBadUrl) { var cleanedUrl = BundleVerifierMod.SanitizeUrl(context.Url); - MelonLogger.Msg($"Bundle for ptr {thisPtr} uid={cleanedUrl.Item1}+{cleanedUrl.Item2} is pre-marked as bad, faking failed download"); + AdvancedSafetyMod.Logger.Msg($"Bundle for ptr {thisPtr} uid={cleanedUrl.Item1}+{cleanedUrl.Item2} is pre-marked as bad, faking failed download"); // indicate that it should use the DL stream Marshal.WriteInt32(thisPtr + 0x90, 1); // and then indicate the downloader that we don't want the download diff --git a/AdvancedSafety/BundleVerifier/BundleDownloadMethods.cs b/AdvancedSafety/BundleVerifier/BundleDownloadMethods.cs index 62d99c3..b600c07 100644 --- a/AdvancedSafety/BundleVerifier/BundleDownloadMethods.cs +++ b/AdvancedSafety/BundleVerifier/BundleDownloadMethods.cs @@ -43,8 +43,8 @@ internal static bool Init() if (!ourBundleDownloadOffsets.TryGetValue(unityPlayerHash, out var offsets)) { - MelonLogger.Error($"Unknown UnityPlayer hash: {unityPlayerHash}"); - MelonLogger.Error("Bundle verifier will not work"); + AdvancedSafetyMod.Logger.Error($"Unknown UnityPlayer hash: {unityPlayerHash}"); + AdvancedSafetyMod.Logger.Error("Bundle verifier will not work"); return false; } @@ -91,7 +91,7 @@ private static IntPtr CreateCachedPatch(IntPtr scriptingObjectPtr, NativePatchUt } catch (Exception ex) { - MelonLogger.Error($"Exception in CreateCached patch: {ex}"); + AdvancedSafetyMod.Logger.Error($"Exception in CreateCached patch: {ex}"); } return result; } diff --git a/AdvancedSafety/BundleVerifier/BundleHashCache.cs b/AdvancedSafety/BundleVerifier/BundleHashCache.cs index 420889e..1ca1b0e 100644 --- a/AdvancedSafety/BundleVerifier/BundleHashCache.cs +++ b/AdvancedSafety/BundleVerifier/BundleHashCache.cs @@ -29,7 +29,7 @@ public BundleHashCache(string? cacheFile) var readBytes = myHashWriterStream.Read(transferArray, 0, transferArray.Length); if (readBytes != transferArray.Length) { - MelonLogger.Error($"Failure to read {transferArray.Length} bytes from cached bad URL file"); + AdvancedSafetyMod.Logger.Error($"Failure to read {transferArray.Length} bytes from cached bad URL file"); myHashWriterStream.Position = 0; break; } diff --git a/AdvancedSafety/BundleVerifier/BundleVerifierMod.cs b/AdvancedSafety/BundleVerifier/BundleVerifierMod.cs index abc82c7..2539094 100644 --- a/AdvancedSafety/BundleVerifier/BundleVerifierMod.cs +++ b/AdvancedSafety/BundleVerifier/BundleVerifierMod.cs @@ -47,8 +47,8 @@ public static void OnApplicationStart(HarmonyLib.Harmony harmonyInstance) } catch (IOException ex) { - MelonLogger.Error("Unable to extract bundle verifier app, the mod will not work"); - MelonLogger.Error(ex.ToString()); + AdvancedSafetyMod.Logger.Error("Unable to extract bundle verifier app, the mod will not work"); + AdvancedSafetyMod.Logger.Error(ex.ToString()); return; } @@ -84,7 +84,7 @@ private static IEnumerator CheckInstanceType() if (!EnabledSetting.Value) { BundleDlInterceptor.ShouldIntercept = false; - MelonLogger.Msg($"Bundle intercept disabled in settings"); + AdvancedSafetyMod.Logger.Msg($"Bundle intercept disabled in settings"); yield break; } diff --git a/AdvancedSafety/PortalHiding.cs b/AdvancedSafety/PortalHiding.cs index 2f3efce..d3fc2b2 100644 --- a/AdvancedSafety/PortalHiding.cs +++ b/AdvancedSafety/PortalHiding.cs @@ -45,7 +45,7 @@ private static void InstantiateObjectPatch(IntPtr thisPtr, IntPtr objectNamePtr, if (APIUser.CurrentUser?.id == apiUser.id) return; if (MelonDebug.IsEnabled()) - MelonLogger.Msg($"User {apiUser.displayName} dropped a portal"); + AdvancedSafetyMod.Logger.Msg($"User {apiUser.displayName} dropped a portal"); string denyReason = null; if (AdvancedSafetySettings.HidePortalsFromBlockedUsers.Value && IsBlockedEitherWay(apiUser.id)) @@ -62,13 +62,13 @@ private static void InstantiateObjectPatch(IntPtr thisPtr, IntPtr objectNamePtr, if (dict.ContainsKey(networkId)) { var someStruct = dict[networkId]; - MelonLogger.Msg(denyReason); + AdvancedSafetyMod.Logger.Msg(denyReason); MelonCoroutines.Start(HideGameObjectAfterDelay(someStruct.field_Public_GameObject_0)); } } catch (Exception ex) { - MelonLogger.Error($"Exception in portal hider patch: {ex}"); + AdvancedSafetyMod.Logger.Error($"Exception in portal hider patch: {ex}"); } } diff --git a/AdvancedSafety/ReaderPatches.cs b/AdvancedSafety/ReaderPatches.cs index 54fa507..6f5fb0e 100644 --- a/AdvancedSafety/ReaderPatches.cs +++ b/AdvancedSafety/ReaderPatches.cs @@ -48,8 +48,8 @@ internal static void ApplyPatches() if (!ourOffsets.TryGetValue(unityPlayerHash, out var offsets)) { - MelonLogger.Error($"Unknown UnityPlayer hash: {unityPlayerHash}"); - MelonLogger.Error("Some features will not work"); + AdvancedSafetyMod.Logger.Error($"Unknown UnityPlayer hash: {unityPlayerHash}"); + AdvancedSafetyMod.Logger.Error("Some features will not work"); return; } @@ -238,7 +238,7 @@ private static unsafe long CountNodesDeepThunk(NodeContainer* thisPtr) } catch (Exception ex) { - MelonLogger.Error($"Exception in CountNodes patch: {ex}"); + AdvancedSafetyMod.Logger.Error($"Exception in CountNodes patch: {ex}"); return 1; } } diff --git a/Directory.Build.props b/Directory.Build.props index 90cb8fe..1c58845 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -89,6 +89,11 @@ false false $(MsBuildThisFileDirectory)Libs\MelonLoader.dll + + + false + false + $(MsBuildThisFileDirectory)Libs\0Harmony.dll false diff --git a/FavCat/CustomLists/CustomPickerList.cs b/FavCat/CustomLists/CustomPickerList.cs index 4bdab2f..f4fb719 100644 --- a/FavCat/CustomLists/CustomPickerList.cs +++ b/FavCat/CustomLists/CustomPickerList.cs @@ -147,7 +147,7 @@ public void Awake() } catch (Exception ex) { - MelonLogger.Error(ex.ToString()); + FavCatMod.Logger.Error(ex.ToString()); } } diff --git a/FavCat/Database/DatabaseImageHandler.cs b/FavCat/Database/DatabaseImageHandler.cs index 3c7f111..1e6232f 100644 --- a/FavCat/Database/DatabaseImageHandler.cs +++ b/FavCat/Database/DatabaseImageHandler.cs @@ -72,12 +72,12 @@ public Task TrimCache(long maxSize) await TaskUtilities.YieldToMainThread(); - MelonLogger.Msg($"Removed {cutoffPoint} images from cache"); + FavCatMod.Logger.Msg($"Removed {cutoffPoint} images from cache"); }).ContinueWith(task => { if (!task.IsFaulted) return; - MelonLogger.Warning("Image cache trim failed; assuming cache corrupted, clearing collections. Exception: " + task.Exception); + FavCatMod.Logger.Warning("Image cache trim failed; assuming cache corrupted, clearing collections. Exception: " + task.Exception); myFileDatabase.GetCollection>("_files").DeleteAll(); myFileDatabase.GetCollection("_chunks").DeleteAll(); }); @@ -109,13 +109,13 @@ public async Task LoadImageAsync(string url, Action onDone) } catch (Exception ex) { - MelonLogger.Error($"Exception in onDone callback: {ex}"); + FavCatMod.Logger.Error($"Exception in onDone callback: {ex}"); } } catch (Exception ex) { if (MelonDebug.IsEnabled()) - MelonLogger.Warning($"Exception in image load, will delete offending image: {ex}"); + FavCatMod.Logger.Warning($"Exception in image load, will delete offending image: {ex}"); myFileDatabase.FileStorage.Delete(url); myImageInfos.Delete(url); onDone(AssetsHandler.PreviewLoading.texture); @@ -158,7 +158,7 @@ public Task StoreImageAsync(string url, Il2CppStructArray data) catch (LiteException ex) { if (MelonDebug.IsEnabled()) - MelonLogger.Warning($"Database exception in image store handler: {ex}"); + FavCatMod.Logger.Warning($"Database exception in image store handler: {ex}"); } }); } diff --git a/FavCat/Database/LocalStoreDatabase.Avatar.cs b/FavCat/Database/LocalStoreDatabase.Avatar.cs index d8a1cf7..832a088 100644 --- a/FavCat/Database/LocalStoreDatabase.Avatar.cs +++ b/FavCat/Database/LocalStoreDatabase.Avatar.cs @@ -13,7 +13,7 @@ public partial class LocalStoreDatabase { internal void RunBackgroundAvatarSearch(string text, Action> callback) { - MelonLogger.Msg($"Running local avatar search for text {text}"); + FavCatMod.Logger.Msg($"Running local avatar search for text {text}"); var ownerId = APIUser.CurrentUser.id; Task.Run(() => { var searchText = text.ToLowerInvariant(); @@ -31,7 +31,7 @@ internal void RunBackgroundAvatarSearch(string text, Action> callback) { - MelonLogger.Msg($"Running local avatar search for user {userId}"); + FavCatMod.Logger.Msg($"Running local avatar search for user {userId}"); var ownerId = APIUser.CurrentUser.id; Task.Run(() => { var list = myStoredAvatars.Find(stored => diff --git a/FavCat/Database/LocalStoreDatabase.Player.cs b/FavCat/Database/LocalStoreDatabase.Player.cs index 3cf5632..a48e33e 100644 --- a/FavCat/Database/LocalStoreDatabase.Player.cs +++ b/FavCat/Database/LocalStoreDatabase.Player.cs @@ -31,7 +31,7 @@ public void UpdateStoredPlayer(APIUser player) internal void RunBackgroundPlayerSearch(string text, Action> callback) { - MelonLogger.Msg($"Running local player search for text {text}"); + FavCatMod.Logger.Msg($"Running local player search for text {text}"); Task.Run(() => { var searchText = text.ToLowerInvariant(); var list = myStoredPlayers.Find(stored => stored.Name.Contains(searchText)).ToList(); diff --git a/FavCat/Database/LocalStoreDatabase.World.cs b/FavCat/Database/LocalStoreDatabase.World.cs index 58e3ecb..f5b02ef 100644 --- a/FavCat/Database/LocalStoreDatabase.World.cs +++ b/FavCat/Database/LocalStoreDatabase.World.cs @@ -13,7 +13,7 @@ public partial class LocalStoreDatabase { internal void RunBackgroundWorldSearch(string text, Action> callback) { - MelonLogger.Msg($"Running local world search for text {text}"); + FavCatMod.Logger.Msg($"Running local world search for text {text}"); Task.Run(() => { var searchText = text.ToLowerInvariant(); var list = myStoredWorlds.Find(stored => diff --git a/FavCat/Database/LocalStoreDatabase.cs b/FavCat/Database/LocalStoreDatabase.cs index 159c6f4..57f4d08 100644 --- a/FavCat/Database/LocalStoreDatabase.cs +++ b/FavCat/Database/LocalStoreDatabase.cs @@ -42,7 +42,7 @@ public LocalStoreDatabase(string databasePath, string imageCachePath) } catch (Exception ex) { - MelonLogger.Warning("Exception when creating image cache; assuming it's corrupted and deleting it. Exception: " + ex); + FavCatMod.Logger.Warning("Exception when creating image cache; assuming it's corrupted and deleting it. Exception: " + ex); File.Delete(imageDbPath); myImageDatabase = new LiteDatabase(new ConnectionString { Filename = imageDbPath, Connection = connectionType }); } @@ -79,7 +79,7 @@ private void UpdateThreadMain() } catch (Exception ex) { - MelonLogger.Error($"Exception in DB update thread: {ex}"); + FavCatMod.Logger.Error($"Exception in DB update thread: {ex}"); } } else Thread.Sleep(100); diff --git a/FavCat/FavCatMod.cs b/FavCat/FavCatMod.cs index b7f06fe..95f8e78 100644 --- a/FavCat/FavCatMod.cs +++ b/FavCat/FavCatMod.cs @@ -26,17 +26,20 @@ namespace FavCat internal partial class FavCatMod : MelonMod { public static LocalStoreDatabase? Database; + public static MelonLogger.Instance Logger; + internal static FavCatMod Instance; internal AvatarModule? AvatarModule; internal WorldsModule? WorldsModule; internal PlayersModule? PlayerModule; - + internal static PageUserInfo PageUserInfo; public override void OnApplicationStart() { Instance = this; + Logger = LoggerInstance; if (!CheckWasSuccessful || !MustStayTrue || MustStayFalse) return; Directory.CreateDirectory("./UserData/FavCatImport"); @@ -48,7 +51,7 @@ public override void OnApplicationStart() FavCatSettings.RegisterSettings(); - MelonLogger.Msg("Creating database"); + Logger.Msg("Creating database"); Database = new LocalStoreDatabase(FavCatSettings.DatabasePath.Value, FavCatSettings.ImageCachePath.Value); Database.ImageHandler.TrimCache(FavCatSettings.MaxCacheSizeBytes).NoAwait(); @@ -96,7 +99,7 @@ public void OnUiManagerInit() } catch (Exception ex) { - MelonLogger.Error($"Exception in avatar module init: {ex}"); + Logger.Error($"Exception in avatar module init: {ex}"); } try @@ -106,7 +109,7 @@ public void OnUiManagerInit() } catch (Exception ex) { - MelonLogger.Error($"Exception in world module init: {ex}"); + Logger.Error($"Exception in world module init: {ex}"); } try @@ -116,11 +119,11 @@ public void OnUiManagerInit() } catch (Exception ex) { - MelonLogger.Error($"Exception in player module init: {ex}"); + Logger.Error($"Exception in player module init: {ex}"); } PageUserInfo = GameObject.Find("UserInterface/MenuContent/Screens/UserInfo").GetComponent(); - MelonLogger.Msg("Initialized!"); + Logger.Msg("Initialized!"); } public override void OnUpdate() @@ -202,7 +205,7 @@ public static void ImageSnifferPatch(IntPtr instancePtr, IntPtr asyncOperationPt } catch (Exception ex) { - MelonLogger.Error($"Exception in image downloader patch: {ex}"); + FavCatMod.Logger.Error($"Exception in image downloader patch: {ex}"); } } @@ -238,7 +241,7 @@ private static void ApiSnifferBody(IntPtr @this) } catch (Exception ex) { - MelonLogger.Error($"Exception in API sniffer patch: {ex}"); + FavCatMod.Logger.Error($"Exception in API sniffer patch: {ex}"); } } } diff --git a/FavCat/GlobalImageCache.cs b/FavCat/GlobalImageCache.cs index 6977610..830d3e6 100644 --- a/FavCat/GlobalImageCache.cs +++ b/FavCat/GlobalImageCache.cs @@ -82,7 +82,7 @@ private static void RunRequest(string url) ourNextAllowedUpdate = Time.time + RequestDelay; - MelonLogger.Msg($"Performing image request to {url}"); + FavCatMod.Logger.Msg($"Performing image request to {url}"); ImageDownloader.DownloadImage(url, 256, new Action(tex => { if (!Textures.TryGetValue(url, out var oldTex) || !oldTex) diff --git a/FavCat/ImportFolderProcessor.cs b/FavCat/ImportFolderProcessor.cs index 2239e2d..fe70b46 100644 --- a/FavCat/ImportFolderProcessor.cs +++ b/FavCat/ImportFolderProcessor.cs @@ -47,7 +47,7 @@ public static async Task ProcessImportsFolder() } catch (Exception ex) { - MelonLogger.Msg($"Import of {file} failed: {ex}"); + FavCatMod.Logger.Msg($"Import of {file} failed: {ex}"); } } @@ -62,7 +62,7 @@ public static async Task ProcessImportsFolder() } catch (Exception ex) { - MelonLogger.Msg($"Import of {file} failed: {ex}"); + FavCatMod.Logger.Msg($"Import of {file} failed: {ex}"); } } @@ -78,12 +78,12 @@ internal static async Task ProcessTextFile(string filePath) var database = FavCatMod.Database; if (database == null) { - MelonLogger.Msg("Database does not exist, can't import"); + FavCatMod.Logger.Msg("Database does not exist, can't import"); return; } var fileName = Path.GetFileName(filePath); - MelonLogger.Msg($"Started avatar import process for file {fileName}"); + FavCatMod.Logger.Msg($"Started avatar import process for file {fileName}"); var toAddUsers = new List(); var toAddWorlds = new List(); @@ -158,7 +158,7 @@ void DoAddCategories(List ids, DatabaseFavoriteHandler favs, Exten DoAddCategories(toAddWorlds, database.WorldFavorites, FavCatMod.Instance.WorldsModule, database.myStoredWorlds); DoAddCategories(toAddUsers, database.PlayerFavorites, FavCatMod.Instance.PlayerModule, database.myStoredPlayers); - MelonLogger.Msg($"Done importing {fileName}"); + FavCatMod.Logger.Msg($"Done importing {fileName}"); File.Delete(filePath); } @@ -169,12 +169,12 @@ internal static Task MergeInForeignStore(string foreignStorePath) var database = FavCatMod.Database; if (database == null) { - MelonLogger.Msg("Database does not exist, can't merge"); + FavCatMod.Logger.Msg("Database does not exist, can't merge"); return; } var fileName = Path.GetFileName(foreignStorePath); - MelonLogger.Msg($"Started merging database with {fileName}"); + FavCatMod.Logger.Msg($"Started merging database with {fileName}"); using var storeDatabase = new LiteDatabase(new ConnectionString {Filename = foreignStorePath, ReadOnly = true, Connection = ConnectionType.Direct}); var storedAvatars = storeDatabase.GetCollection("avatars"); @@ -205,7 +205,7 @@ internal static Task MergeInForeignStore(string foreignStorePath) database.myStoredWorlds.Upsert(storedWorld); } - MelonLogger.Msg($"Done merging database with {fileName}"); + FavCatMod.Logger.Msg($"Done merging database with {fileName}"); }); } } diff --git a/FavCat/Modules/AvatarModule.cs b/FavCat/Modules/AvatarModule.cs index 89aaac0..a8c461a 100644 --- a/FavCat/Modules/AvatarModule.cs +++ b/FavCat/Modules/AvatarModule.cs @@ -31,7 +31,7 @@ public AvatarModule() : base(ExpandedMenu.AvatarMenu, FavCatMod.Database.AvatarF { myCurrentAnnoyingMessage = CanPerformAdditiveActions ? "WillBeObsolete" : (CanShowExistingLists ? "CantAddWithCanny" : "NoFavorites"); - MelonLogger.Msg("Adding button to UI - Looking up for Change Button"); + FavCatMod.Logger.Msg("Adding button to UI - Looking up for Change Button"); var foundAvatarPage = Resources.FindObjectsOfTypeAll()?.FirstOrDefault(p => p.transform.Find("Change Button") != null); if (foundAvatarPage == null) throw new ApplicationException("No avatar page, can't initialize extended favorites"); diff --git a/FavCat/Modules/ExtendedFavoritesModuleBase.cs b/FavCat/Modules/ExtendedFavoritesModuleBase.cs index 7c62343..ce04ceb 100644 --- a/FavCat/Modules/ExtendedFavoritesModuleBase.cs +++ b/FavCat/Modules/ExtendedFavoritesModuleBase.cs @@ -257,7 +257,7 @@ internal void ReorderLists() foreach (var list in GatherLists(true)) { if (MelonDebug.IsEnabled() && knownLists.ContainsKey(list.ListName)) - MelonLogger.Msg($"List {list.ListName} is duplicated"); + FavCatMod.Logger.Msg($"List {list.ListName} is duplicated"); knownLists[list.ListName] = list; } @@ -582,7 +582,7 @@ protected void ProcessSearchResults() mySearchResult = null; if (results == null) return; - MelonLogger.Msg("Local search done, {0} results", results.Count); + FavCatMod.Logger.Msg("Local search done, {0} results", results.Count); SortModelList(SearchList.Category.SortType, SearchCategoryName, results); SearchList.SetList(results.Select(it => WrapModel(null, it.it)), true); diff --git a/Finitizer/FinitizerMod.cs b/Finitizer/FinitizerMod.cs index 5d9ca65..2bf4077 100644 --- a/Finitizer/FinitizerMod.cs +++ b/Finitizer/FinitizerMod.cs @@ -19,12 +19,16 @@ internal partial class FinitizerMod : MelonMod // Why these numbers? Check wrld_b9f80349-74af-4840-8ce9-a1b783436590 for how *horribly* things break even on 10^6. Nothing belongs outside these bounds. The significand is that of MaxValue. private const float MaxAllowedValueTop = 3.402823E+7f; private const float MaxAllowedValueBottom = -3.402823E+7f; + + private static MelonLogger.Instance Logger; private bool myArePatchesApplied; private bool myWasEnabled; public override void OnApplicationStart() { + Logger = LoggerInstance; + var category = MelonPreferences.CreateCategory(SettingsCategory, SettingsCategory); var entry = category.CreateEntry(EnabledSetting, true, "FP fix enabled"); entry.OnValueChanged += (_, value) => @@ -45,7 +49,7 @@ private void OnModSettingsApplied(bool isEnabled) else UnpatchAll(); - MelonLogger.Msg($"Finitizer is now {(isEnabled ? "enabled" : "disabled")}"); + Logger.Msg($"Finitizer is now {(isEnabled ? "enabled" : "disabled")}"); myWasEnabled = isEnabled; } @@ -67,7 +71,7 @@ private unsafe void ApplyPatches() PatchICall("UnityEngine.Object::" + nameof(Object.Internal_InstantiateSingleWithParent_Injected), out ourOriginalInstantiateWithParent, InstantiateWithParentPatch); myArePatchesApplied = true; - MelonLogger.Msg("Things patching complete"); + Logger.Msg("Things patching complete"); } [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -102,7 +106,7 @@ private static void PatchICall(string name, out T original, T target) where T var originalPointer = IL2CPP.il2cpp_resolve_icall(name); if (originalPointer == IntPtr.Zero) { - MelonLogger.Warning($"ICall {name} was not found, not patching"); + Logger.Warning($"ICall {name} was not found, not patching"); original = null; return; } @@ -117,7 +121,7 @@ private void UnpatchAll() NativePatchUtils.UnpatchAll(); myArePatchesApplied = false; - MelonLogger.Msg("Things unpatching complete"); + Logger.Msg("Things unpatching complete"); } public static unsafe bool IsInvalid(float f) => (*(int*) &f & int.MaxValue) >= 2139095040; diff --git a/FriendsPlusHome/FriendsPlusHomeMod.cs b/FriendsPlusHome/FriendsPlusHomeMod.cs index 35581b0..8468c99 100644 --- a/FriendsPlusHome/FriendsPlusHomeMod.cs +++ b/FriendsPlusHome/FriendsPlusHomeMod.cs @@ -25,9 +25,12 @@ internal partial class FriendsPlusHomeMod : MelonMod private static MelonPreferences_Entry StartupName; private static MelonPreferences_Entry ButtonName; + private static MelonLogger.Instance Logger; public override void OnApplicationStart() { + Logger = LoggerInstance; + var category = MelonPreferences.CreateCategory(SettingsCategory, "Friends+ Home"); StartupName = category.CreateEntry(SettingStartupName, nameof(InstanceAccessType.FriendsOfGuests), "Startup instance type"); ButtonName = category.CreateEntry(SettingButtonName, nameof(InstanceAccessType.FriendsOfGuests), "\"Go Home\" instance type"); @@ -43,7 +46,7 @@ public override void OnApplicationStart() if (!XrefScanner.XrefScan(methodInfo).Any(it => it.Type == XrefType.Global && it.ReadAsObject()?.ToString() == "Going to Home Location: ")) continue; - MelonLogger.Msg($"Patched {methodInfo.Name}"); + Logger.Msg($"Patched {methodInfo.Name}"); HarmonyInstance.Patch(methodInfo, postfix: new HarmonyMethod(AccessTools.Method(typeof(FriendsPlusHomeMod), nameof(GoHomePatch)))); } @@ -78,7 +81,7 @@ private static void GoHomePatch(VRCFlowManagerVRC __instance) private static void StartEnforcingInstanceType(VRCFlowManager flowManager, bool isButton) { var targetType = Enum.TryParse(isButton ? ButtonName.Value : StartupName.Value, out var type) ? type : InstanceAccessType.FriendsOfGuests; - MelonLogger.Msg($"Enforcing home instance type: {targetType}"); + Logger.Msg($"Enforcing home instance type: {targetType}"); flowManager.field_Protected_InstanceAccessType_0 = targetType; MelonCoroutines.Start(EnforceTargetInstanceType(flowManager, targetType, isButton ? 10 : 30)); diff --git a/IKTweaks/IKTweaksMod.cs b/IKTweaks/IKTweaksMod.cs index 5c3fbb9..e41e6d5 100644 --- a/IKTweaks/IKTweaksMod.cs +++ b/IKTweaks/IKTweaksMod.cs @@ -18,9 +18,13 @@ namespace IKTweaks { internal partial class IKTweaksMod : MelonMod { + public static MelonLogger.Instance Logger; + public override void OnApplicationStart() { if (!CheckWasSuccessful || !MustStayTrue || MustStayFalse) return; + + Logger = LoggerInstance; IkTweaksSettings.RegisterSettings(); diff --git a/IKTweaks/VrIkHandling.cs b/IKTweaks/VrIkHandling.cs index 7d17747..fed8ae8 100644 --- a/IKTweaks/VrIkHandling.cs +++ b/IKTweaks/VrIkHandling.cs @@ -64,7 +64,7 @@ private static void SolverUpdatePatchImpl(IntPtr thisPtr, IntPtr methodPtr, Void } catch (Exception ex) { - MelonLogger.Error($"Exception in IK solver: {ex}"); + IKTweaksMod.Logger.Error($"Exception in IK solver: {ex}"); } } @@ -122,7 +122,7 @@ private static void SolvePelvisPatch(IntPtr thisPtr, IntPtr methodPtr) } catch (Exception ex) { - MelonLogger.Error($"Exception in IK spine solver: {ex}"); + IKTweaksMod.Logger.Error($"Exception in IK spine solver: {ex}"); } } diff --git a/JoinNotifier/JoinNotifierMod.cs b/JoinNotifier/JoinNotifierMod.cs index 1f747a7..f3f321a 100644 --- a/JoinNotifier/JoinNotifierMod.cs +++ b/JoinNotifier/JoinNotifierMod.cs @@ -49,7 +49,7 @@ internal partial class JoinNotifierMod : MelonMod public override void OnApplicationStart() { if (!CheckWasSuccessful || !MustStayTrue || MustStayFalse) return; - + JoinNotifierSettings.RegisterSettings(); MelonCoroutines.Start(InitThings()); @@ -89,7 +89,7 @@ public IEnumerator InitThings() if (File.Exists(CustomJoinSoundFileName)) { - MelonLogger.Msg("Loading custom join sound"); + LoggerInstance.Msg("Loading custom join sound"); var uwr = UnityWebRequest.Get($"file://{Path.Combine(Environment.CurrentDirectory, CustomJoinSoundFileName)}"); uwr.SendWebRequest(); @@ -105,7 +105,7 @@ public IEnumerator InitThings() if (File.Exists(CustomLeaveSoundFileName)) { - MelonLogger.Msg("Loading custom leave sound"); + LoggerInstance.Msg("Loading custom leave sound"); var uwr = UnityWebRequest.Get($"file://{Path.Combine(Environment.CurrentDirectory, CustomLeaveSoundFileName)}"); uwr.SendWebRequest(); @@ -216,7 +216,7 @@ private void CreateGameObjects() var hudRoot = GameObject.Find("UserInterface/UnscaledUI/HudContent_Old/Hud"); if (hudRoot == null) { - MelonLogger.Msg("Not creating gameobjects - no hud root"); + LoggerInstance.Msg("Not creating gameobjects - no hud root"); return; } @@ -267,7 +267,7 @@ public void OnPlayerJoined(Player player) if (JoinNotifierSettings.ShouldShowNames(true)) MelonCoroutines.Start(ShowName(myJoinText, myJoinNames, playerName, true, isFriendsWith)); if (JoinNotifierSettings.LogToConsole.Value) - MelonLogger.Msg(isFriendsWith && JoinNotifierSettings.ShowFriendsInDifferentColor.Value + LoggerInstance.Msg(isFriendsWith && JoinNotifierSettings.ShowFriendsInDifferentColor.Value ? ConsoleColor.DarkYellow : ConsoleColor.DarkCyan, $"{(isFriendsWith ? "Friend " : "")}{playerName} joined"); } @@ -295,7 +295,7 @@ public void OnPlayerLeft(Player player) if (JoinNotifierSettings.ShouldShowNames(false)) MelonCoroutines.Start(ShowName(myLeaveText, myLeaveNames, playerName, false, isFriendsWith)); if (JoinNotifierSettings.LogToConsole.Value) - MelonLogger.Msg(isFriendsWith && JoinNotifierSettings.ShowFriendsInDifferentColor.Value + LoggerInstance.Msg(isFriendsWith && JoinNotifierSettings.ShowFriendsInDifferentColor.Value ? ConsoleColor.DarkYellow : ConsoleColor.DarkMagenta, $"{(isFriendsWith ? "Friend " : "")}{playerName} left"); } diff --git a/LagFreeScreenshots/AwaitProvider.cs b/LagFreeScreenshots/AwaitProvider.cs index fcfbbd3..885d293 100644 --- a/LagFreeScreenshots/AwaitProvider.cs +++ b/LagFreeScreenshots/AwaitProvider.cs @@ -31,7 +31,7 @@ public void Flush() } catch (Exception ex) { - MelonLogger.Warning($"Exception in task: {ex}"); + LagFreeScreenshotsMod.Logger.Warning($"Exception in task: {ex}"); } } } diff --git a/LagFreeScreenshots/LagFreeScreenshotsMod.cs b/LagFreeScreenshots/LagFreeScreenshotsMod.cs index 71aa466..470142c 100644 --- a/LagFreeScreenshots/LagFreeScreenshotsMod.cs +++ b/LagFreeScreenshots/LagFreeScreenshotsMod.cs @@ -36,6 +36,8 @@ namespace LagFreeScreenshots { internal partial class LagFreeScreenshotsMod : MelonMod { + public static MelonLogger.Instance Logger; + private const string SettingsCategory = "LagFreeScreenshots"; private const string SettingEnableMod = "Enabled"; private const string SettingScreenshotResolution = "ScreenshotResolution"; @@ -61,6 +63,8 @@ internal partial class LagFreeScreenshotsMod : MelonMod public override void OnApplicationStart() { + Logger = LoggerInstance; + var category = MelonPreferences.CreateCategory(SettingsCategory, "Lag Free Screenshots"); ourEnabled = category.CreateEntry(SettingEnableMod, true, "Enabled"); ourResolution = category.CreateEntry( SettingScreenshotResolution, PresetScreenshotSizes.Default, "Screenshot resolution override"); @@ -74,7 +78,7 @@ public override void OnApplicationStart() if (!MelonHandler.Mods.Any(it => it.Info.Name == "UI Expansion Kit" && it.Assembly.GetName().Version >= new Version(0, 2, 6))) { - MelonLogger.Error("UI Expansion Kit is not found. Lag Free Screenshots will not work."); + Logger.Error("UI Expansion Kit is not found. Lag Free Screenshots will not work."); return; } @@ -165,7 +169,7 @@ public static bool MoveNextPatchAsyncReadback(ref bool __result, CameraTakePhoto resY, hasAlpha).ContinueWith(t => { if (t.IsFaulted) - MelonLogger.Warning($"Free-floating task failed with exception: {t.Exception}"); + Logger.Warning($"Free-floating task failed with exception: {t.Exception}"); }); return false; } @@ -203,7 +207,7 @@ private static int MaxMsaaCount(int w, int h) if (maxMsaa != ourLastUsedMsaaLevel) { - MelonLogger.Msg($"Using MSAA x{maxMsaa} for screenshots (FB size {(colorSizePerLevel * maxMsaa + colorSizePerLevel / 2) / 1024 / 1024}MB)"); + Logger.Msg($"Using MSAA x{maxMsaa} for screenshots (FB size {(colorSizePerLevel * maxMsaa + colorSizePerLevel / 2) / 1024 / 1024}MB)"); ourLastUsedMsaaLevel = (int) maxMsaa; } @@ -247,7 +251,7 @@ public static async Task TakeScreenshot(Camera camera, int w, int h, bool hasAlp var request = AsyncGPUReadback.Request(renderTexture, 0, hasAlpha ? TextureFormat.ARGB32 : TextureFormat.RGB24, new Action(r => { if (r.hasError) - MelonLogger.Warning("Readback request finished with error (w)"); + Logger.Warning("Readback request finished with error (w)"); data = ToBytes(r.GetDataRaw(0), r.GetLayerDataSize()); MelonDebug.Msg($"Bytes readback took total {stopwatch.ElapsedMilliseconds}"); @@ -257,7 +261,7 @@ public static async Task TakeScreenshot(Camera camera, int w, int h, bool hasAlp await TaskUtilities.YieldToMainThread(); if (request.hasError) - MelonLogger.Warning("Readback request finished with error"); + Logger.Warning("Readback request finished with error"); if (data.Item1 == IntPtr.Zero) { @@ -269,7 +273,7 @@ public static async Task TakeScreenshot(Camera camera, int w, int h, bool hasAlp { unsafe { - MelonLogger.Msg("Does not support readback, using fallback texture read method"); + Logger.Msg("Does not support readback, using fallback texture read method"); RenderTexture.active = renderTexture; var newTexture = new Texture2D(w, h, hasAlpha ? TextureFormat.ARGB32 : TextureFormat.RGB24, false); @@ -385,7 +389,7 @@ private static async Task EncodeAndSavePicture(string filePath, (IntPtr, int Len await Task.Delay(1).ConfigureAwait(false); if (Thread.CurrentThread == ourMainThread) - MelonLogger.Error("Image encode is executed on main thread - it's a bug!"); + Logger.Error("Image encode is executed on main thread - it's a bug!"); var step = hasAlpha ? 4 : 3; @@ -492,7 +496,7 @@ private static async Task EncodeAndSavePicture(string filePath, (IntPtr, int Len await TaskUtilities.YieldToMainThread(); - MelonLogger.Msg($"Image saved to {filePath}"); + Logger.Msg($"Image saved to {filePath}"); // compatibility with log-reading tools UnityEngine.Debug.Log($"Took screenshot to: {filePath}"); diff --git a/MirrorResolutionUnlimiter/MirrorResolutionUnlimiterMod.cs b/MirrorResolutionUnlimiter/MirrorResolutionUnlimiterMod.cs index b06c1ea..61e0d33 100644 --- a/MirrorResolutionUnlimiter/MirrorResolutionUnlimiterMod.cs +++ b/MirrorResolutionUnlimiter/MirrorResolutionUnlimiterMod.cs @@ -27,6 +27,7 @@ internal partial class MirrorResolutionUnlimiterMod : MelonMod private static bool ourAllMirrorsAuto = false; private static int ourMirrorMsaa = 0; private static MelonPreferences_Entry ourMsaaIsUpperLimit; + private static MelonLogger.Instance ourLogger; internal static MelonPreferences_Entry UiInMirrors; private MelonPreferences_Entry myPixelLightsSetting; @@ -35,6 +36,8 @@ public override void OnApplicationStart() { ClassInjector.RegisterTypeInIl2Cpp(); + ourLogger = LoggerInstance; + var category = MelonPreferences.CreateCategory(ModCategory, "Mirror Resolution"); var maxTextureRes = category.CreateEntry(MaxResPref, 4096, "Max eye texture size"); maxTextureRes.OnValueChanged += (_, v) => ourMaxEyeResolution = v; @@ -68,7 +71,7 @@ public override void OnApplicationStart() if (MelonHandler.Mods.Any(it => it.Info.Name == "UI Expansion Kit")) { - MelonLogger.Msg("Adding UIExpansionKit buttons"); + ourLogger.Msg("Adding UIExpansionKit buttons"); UiExtensionsAddon.Init(); } } @@ -169,7 +172,7 @@ private static bool GetReflectionData(VRC_MirrorReflection __instance, Camera __ } catch (Exception ex) { - MelonLogger.Error("Exception happened in GetReflectionData override" + ex); + ourLogger.Error("Exception happened in GetReflectionData override" + ex); } return true; } diff --git a/ScaleGoesBrr/ScaleGoesBrrMod.cs b/ScaleGoesBrr/ScaleGoesBrrMod.cs index 84ee21d..b1d6afb 100644 --- a/ScaleGoesBrr/ScaleGoesBrrMod.cs +++ b/ScaleGoesBrr/ScaleGoesBrrMod.cs @@ -22,6 +22,7 @@ public partial class ScaleGoesBrrMod : MelonMod private static VRCVrCameraSteam ourSteamCamera; private static Transform ourCameraTransform; + private static MelonLogger.Instance ourLogger; public static event Action OnAvatarScaleChanged; @@ -34,6 +35,8 @@ public override void OnApplicationStart() { ClassInjector.RegisterTypeInIl2Cpp(); + ourLogger = LoggerInstance; + var category = MelonPreferences.CreateCategory("ScaleGoesBrr", "Scale Goes Brr"); ourIsEnabled = category.CreateEntry("Enabled", true, "Enable avatar scaling support"); FixPlayspaceCenterBias = category.CreateEntry("FixPlayspaceCenterBias", true, "Scale towards avatar root (not playspace center)"); @@ -119,7 +122,7 @@ private static IEnumerator OnLocalPlayerAvatarCreatedCoro(Vector3 originalScale, var originalTrackingRootScale = trackingRoot.localScale; - MelonLogger.Msg($"Initialized scaling support for current avatar: avatar initial scale {originalScale.y}, tracking initial scale {originalTrackingRootScale.y}"); + ourLogger.Msg($"Initialized scaling support for current avatar: avatar initial scale {originalScale.y}, tracking initial scale {originalTrackingRootScale.y}"); var comp = go.AddComponent(); comp.source = go.transform; @@ -173,7 +176,7 @@ private static void OnLocalPlayerAvatarCreatedImpl(GameObject go, VRC_AvatarDesc if (descriptor == null || descriptor.TryCast() != null) { - MelonLogger.Msg("Current avatar is SDK2, ignoring rescaling support"); + ourLogger.Msg("Current avatar is SDK2, ignoring rescaling support"); return; } diff --git a/Styletor/ExtraHandlers/ActionMenuHandler.cs b/Styletor/ExtraHandlers/ActionMenuHandler.cs index ea26c38..35f3573 100644 --- a/Styletor/ExtraHandlers/ActionMenuHandler.cs +++ b/Styletor/ExtraHandlers/ActionMenuHandler.cs @@ -139,7 +139,7 @@ private void EncacheTexture(Texture2D? texture) var name = texture.name; if (myTexturesByName.TryGetValue(name, out var previous) && previous != texture) - MelonLogger.Msg($"Object named {name} as a texture different from previous one: {previous.name} != {texture.name}"); + StyletorMod.Instance.Logger.Msg($"Object named {name} as a texture different from previous one: {previous.name} != {texture.name}"); myTexturesByName[name] = texture; } @@ -175,7 +175,7 @@ private void EncacheSprite(Sprite? texture) var name = texture.name; if (mySpritesByName.TryGetValue(name, out var previous) && previous != texture) - MelonLogger.Msg($"Object named {name} as a texture different from previous one: {previous.name} != {texture.name}"); + StyletorMod.Instance.Logger.Msg($"Object named {name} as a texture different from previous one: {previous.name} != {texture.name}"); mySpritesByName[name] = texture; } @@ -189,11 +189,11 @@ private void ProcessObjectForSave(Transform t, string parentName) if (graphics.Count > 0) { if (graphics.Count > 1) - MelonLogger.Msg($"AM object {fullName} (in {t.parent.gameObject.name}) has more than one Graphic!"); + StyletorMod.Instance.Logger.Msg($"AM object {fullName} (in {t.parent.gameObject.name}) has more than one Graphic!"); var color = graphics[0].color; if (myOriginalGraphicColorsByObjectName.TryGetValue(fullName, out var oldColor) && oldColor != color) - MelonLogger.Msg($"Object named {fullName} was seen with two different colors: {oldColor.ToString()} vs {color.ToString()}"); + StyletorMod.Instance.Logger.Msg($"Object named {fullName} was seen with two different colors: {oldColor.ToString()} vs {color.ToString()}"); myOriginalGraphicColorsByObjectName[fullName] = color; diff --git a/Styletor/StyleEngineWrapper.cs b/Styletor/StyleEngineWrapper.cs index 33b5862..c92f676 100644 --- a/Styletor/StyleEngineWrapper.cs +++ b/Styletor/StyleEngineWrapper.cs @@ -161,7 +161,7 @@ internal void BackupDefaultStyle() myOriginalSpritesByLowercaseFullKey[keyValuePair.Key.Item1] = keyValuePair.Value.Cast(); } - MelonLogger.Msg($"Stored default style: {myOriginalStylesBackup.Count} styles, {myOriginalSprites.Count} sprites"); + StyletorMod.Instance.Logger.Msg($"Stored default style: {myOriginalStylesBackup.Count} styles, {myOriginalSprites.Count} sprites"); } public string? GetSpriteFullNameByOriginalSprite(Sprite? originalSprite) diff --git a/Styletor/Styles/BuiltinStyleExporter.cs b/Styletor/Styles/BuiltinStyleExporter.cs index 2d7dcdf..c069aac 100644 --- a/Styletor/Styles/BuiltinStyleExporter.cs +++ b/Styletor/Styles/BuiltinStyleExporter.cs @@ -19,7 +19,7 @@ public static void ExportDefaultStyle(string baseDir, StyleEngine styleEngine) var spriteType = Il2CppType.Of(); var audioClipType = Il2CppType.Of(); - MelonLogger.Msg($"Exporting default VRC skin to {baseDir}"); + StyletorMod.Instance.Logger.Msg($"Exporting default VRC skin to {baseDir}"); foreach (var keyValuePair in styleEngine.field_Private_Dictionary_2_Tuple_2_String_Type_Object_0) { var basePath = Path.Combine(baseDir, keyValuePair.Key.Item1); @@ -42,7 +42,7 @@ public static void ExportDefaultStyle(string baseDir, StyleEngine styleEngine) WriteWaveFile(basePath + ".wav", audioClip); } } - MelonLogger.Msg($"Export finished"); + StyletorMod.Instance.Logger.Msg($"Export finished"); } private static void WriteWaveFile(string filePath, AudioClip clip) diff --git a/Styletor/Styles/OverrideStyle.cs b/Styletor/Styles/OverrideStyle.cs index 6348078..f251768 100644 --- a/Styletor/Styles/OverrideStyle.cs +++ b/Styletor/Styles/OverrideStyle.cs @@ -92,7 +92,7 @@ public static OverrideStyle LoadFromStreams(StyleEngineWrapper styleEngine, Dict var loadedTexture = Utils.Utils.LoadTexture(keyValuePair.Value); if (loadedTexture == null) { - MelonLogger.Msg($"Failed to load a texture from {keyValuePair.Key}"); + StyletorMod.Instance.Logger.Msg($"Failed to load a texture from {keyValuePair.Key}"); continue; } diff --git a/Styletor/Styles/OverridesStyleSheet.cs b/Styletor/Styles/OverridesStyleSheet.cs index 02ef185..ad42f3b 100644 --- a/Styletor/Styles/OverridesStyleSheet.cs +++ b/Styletor/Styles/OverridesStyleSheet.cs @@ -127,7 +127,7 @@ public void ApplyOverrides(ColorizerManager colorizer) var targetNormalizedSelector = keyValuePair.Value.SelectorTo.ToStringNormalized(); if (baseStyles == null || baseStyles.Count == 0) { - MelonLogger.Msg($"Selector {keyValuePair.Value.SelectorFrom} not found in default style to copy into {targetNormalizedSelector}"); + StyletorMod.Instance.Logger.Msg($"Selector {keyValuePair.Value.SelectorFrom} not found in default style to copy into {targetNormalizedSelector}"); continue; } @@ -165,7 +165,7 @@ public void ApplyOverrides(ColorizerManager colorizer) var baseStyles = myStyleEngine.TryGetBySelector(keyValuePair.Key); if (baseStyles == null && !keyValuePair.Value.IsNew) { - MelonLogger.Msg($"Selector {keyValuePair.Key} overrides nothing in default style and is not marked as new (see README)"); + StyletorMod.Instance.Logger.Msg($"Selector {keyValuePair.Key} overrides nothing in default style and is not marked as new (see README)"); continue; } @@ -185,7 +185,7 @@ public void ApplyOverrides(ColorizerManager colorizer) } } - MelonLogger.Msg($"Applied {myStyleOverrides.Count} overrides from {Name}"); + StyletorMod.Instance.Logger.Msg($"Applied {myStyleOverrides.Count} overrides from {Name}"); } private static Selector ParseSelector(string selectorText) => Selector.Method_Public_Static_Selector_String_0(selectorText.Trim()); @@ -199,13 +199,13 @@ private void ParseOverride(string lastSelectorText, bool isNew, string bodyText) var selectorNormalized = selector.ToStringNormalized(); if (myStyleOverrides.ContainsKey(selectorNormalized)) - MelonLogger.Warning($"Style sheet override {Name} contains duplicate selector {selectorNormalized}"); + StyletorMod.Instance.Logger.Warning($"Style sheet override {Name} contains duplicate selector {selectorNormalized}"); myStyleOverrides[selectorNormalized] = (isNew, bodyText); } catch (Exception ex) { - MelonLogger.Warning($"Error while parsing override style {Name}: {ex}"); + StyletorMod.Instance.Logger.Warning($"Error while parsing override style {Name}: {ex}"); } } } diff --git a/Styletor/Styles/StylesLoader.cs b/Styletor/Styles/StylesLoader.cs index d8ba4a5..81b3eaf 100644 --- a/Styletor/Styles/StylesLoader.cs +++ b/Styletor/Styles/StylesLoader.cs @@ -80,7 +80,7 @@ private void DoLoadStyle(string styleRawName, Func loadDelegate) } catch (Exception ex) { - MelonLogger.Warning($"Can't load style {styleRawName}: {ex}"); + StyletorMod.Instance.Logger.Warning($"Can't load style {styleRawName}: {ex}"); } } @@ -140,11 +140,11 @@ internal void ApplyStyle(string styleName) if (myStyles.TryGetValue(styleName, out var style)) { - MelonLogger.Msg($"Applying style {styleName}"); + StyletorMod.Instance.Logger.Msg($"Applying style {styleName}"); style.ApplyOverrides(myColorizer); } else - MelonLogger.Msg($"Style {styleName} not found"); + StyletorMod.Instance.Logger.Msg($"Style {styleName} not found"); foreach (var overrideStyle in mixinsToUse.Where(it => it.Metadata.MixinPriority >= 0)) overrideStyle.ApplyOverrides(myColorizer); @@ -175,14 +175,14 @@ internal void ApplyStyle(string styleName) if (spriteThisWouldReplace == null || originalSpriteFullKey == null) { - MelonLogger.Msg($"Image {normalizedName} in StyletorStyles would replace nothing; it will be ignored"); + StyletorMod.Instance.Logger.Msg($"Image {normalizedName} in StyletorStyles would replace nothing; it will be ignored"); continue; } var texture = Utils.Utils.LoadTexture(imagePath); if (texture == null) { - MelonLogger.Msg($"Could not load texture from image {normalizedName} in StyletorStyles"); + StyletorMod.Instance.Logger.Msg($"Could not load texture from image {normalizedName} in StyletorStyles"); continue; } diff --git a/Styletor/StyletorMod.cs b/Styletor/StyletorMod.cs index 1c3eaf6..8fea83e 100644 --- a/Styletor/StyletorMod.cs +++ b/Styletor/StyletorMod.cs @@ -34,10 +34,12 @@ public partial class StyletorMod : MelonMod private ActionMenuHandler myActionMenuHandler; public SettingsHolder Settings => mySettings; + public MelonLogger.Instance Logger; public override void OnApplicationStart() { Instance = this; + Logger = LoggerInstance; Directory.CreateDirectory(Path.Combine(MelonUtils.UserDataDirectory, StylesLoader.StylesSubDir)); @@ -136,7 +138,7 @@ private IEnumerator WaitForStyleInit() var initMethod = initMethods.Count == 1 ? initMethods[0] : null; if (initMethod == null) - MelonLogger.Warning("No Init method on StyleEngine, will wait for natural init"); + Logger.Warning("No Init method on StyleEngine, will wait for natural init"); else initMethod.Invoke(myStyleEngine.StyleEngine, Array.Empty());*/ @@ -153,7 +155,7 @@ private IEnumerator WaitForStyleInit() } catch (Exception ex) { - MelonLogger.Error($"UI Laser recoloring handler failed to initialize: {ex}"); + Logger.Error($"UI Laser recoloring handler failed to initialize: {ex}"); } try @@ -162,7 +164,7 @@ private IEnumerator WaitForStyleInit() } catch (Exception ex) { - MelonLogger.Error($"Action Menu recoloring handler failed to initialize: {ex}"); + Logger.Error($"Action Menu recoloring handler failed to initialize: {ex}"); } } diff --git a/TrueShaderAntiCrash/TrueShaderAntiCrashMod.cs b/TrueShaderAntiCrash/TrueShaderAntiCrashMod.cs index 0a5e8be..65f0740 100644 --- a/TrueShaderAntiCrash/TrueShaderAntiCrashMod.cs +++ b/TrueShaderAntiCrash/TrueShaderAntiCrashMod.cs @@ -43,8 +43,8 @@ public override void OnApplicationStart() if (!ourOffsets.TryGetValue(unityPlayerHash, out var offset)) { - MelonLogger.Error($"Unknown UnityPlayer hash: {unityPlayerHash}"); - MelonLogger.Error("The mod will not work"); + LoggerInstance.Error($"Unknown UnityPlayer hash: {unityPlayerHash}"); + LoggerInstance.Error("The mod will not work"); return; } @@ -63,7 +63,7 @@ public override void OnApplicationStart() } catch (IOException ex) { - MelonLogger.Warning("Failed to write native unity plugin; will attempt loading it anyway. This is normal if you're running multiple instances of VRChat"); + LoggerInstance.Warning("Failed to write native unity plugin; will attempt loading it anyway. This is normal if you're running multiple instances of VRChat"); MelonDebug.Msg(ex.ToString()); } @@ -81,7 +81,7 @@ public override void OnApplicationStart() if (loaded == IntPtr.Zero) { - MelonLogger.Error("Module load failed"); + LoggerInstance.Error("Module load failed"); return; } diff --git a/Turbones/JigglySolverApi.cs b/Turbones/JigglySolverApi.cs index 7855362..cff3f88 100644 --- a/Turbones/JigglySolverApi.cs +++ b/Turbones/JigglySolverApi.cs @@ -104,7 +104,7 @@ internal static bool Initialize(string dllName) var lib = LoadLibraryA(dllName); if (lib == IntPtr.Zero) { - MelonLogger.Error("Native library load failed, mod won't work"); + TurbonesMod.Logger.Error("Native library load failed, mod won't work"); return false; } @@ -145,7 +145,7 @@ internal static bool Initialize(string dllName) private static T GetPointer(IntPtr lib, string name) where T : MulticastDelegate { var result = Marshal.GetDelegateForFunctionPointer(GetProcAddress(lib, name)); - if (result == null) MelonLogger.Error($"Delegate for {name} not found! Bug?"); + if (result == null) TurbonesMod.Logger.Error($"Delegate for {name} not found! Bug?"); return result; } diff --git a/Turbones/Offsets.cs b/Turbones/Offsets.cs index 79a0e1c..83d7d0f 100644 --- a/Turbones/Offsets.cs +++ b/Turbones/Offsets.cs @@ -12,7 +12,7 @@ public static class Offsets public static IntPtr GetICall(string name) { var result = IL2CPP.il2cpp_resolve_icall(name); - if (result == IntPtr.Zero) MelonLogger.Error($"ICall {name} not found, crash will likely follow"); + if (result == IntPtr.Zero) TurbonesMod.Logger.Error($"ICall {name} not found, crash will likely follow"); MelonDebug.Msg($"ICall pointer for {name} is {result}"); return result; @@ -23,7 +23,7 @@ public static uint GetFieldOffset(string fieldName) var classPtr = Il2CppClassPointerStore.NativeClassPtr; if (classPtr == IntPtr.Zero) { - MelonLogger.Error($"{typeof(T)} class pointer is null"); + TurbonesMod.Logger.Error($"{typeof(T)} class pointer is null"); return 0; } @@ -33,21 +33,21 @@ public static uint GetFieldOffset(string fieldName) var managedField = typeof(T).GetField("NativeFieldInfoPtr_" + fieldName, BindingFlags.Static | BindingFlags.NonPublic); if (managedField == null) { - MelonLogger.Error($"Field {fieldName} is not found on type {typeof(T)} (managed)"); + TurbonesMod.Logger.Error($"Field {fieldName} is not found on type {typeof(T)} (managed)"); return 0; } fieldPtr = (IntPtr) managedField.GetValue(null); if (fieldPtr == IntPtr.Zero) { - MelonLogger.Error($"Field {fieldName} is not found on type {typeof(T)} (ptr)"); + TurbonesMod.Logger.Error($"Field {fieldName} is not found on type {typeof(T)} (ptr)"); return 0; } } var fieldOffset = IL2CPP.il2cpp_field_get_offset(fieldPtr); if (fieldOffset <= 0) - MelonLogger.Error($"Field offset for field {typeof(T)}.{fieldName} is {fieldOffset}"); + TurbonesMod.Logger.Error($"Field offset for field {typeof(T)}.{fieldName} is {fieldOffset}"); MelonDebug.Msg($"Field offset for field {typeof(T)}.{fieldName} is {fieldOffset}"); @@ -59,7 +59,7 @@ private static IntPtr GetProcAddressSafe(IntPtr module, string name) if (module == IntPtr.Zero) return IntPtr.Zero; var result = JigglySolverApi.GetProcAddress(module, name); if (result == IntPtr.Zero) - MelonLogger.Error($"No entry point for {name}"); + TurbonesMod.Logger.Error($"No entry point for {name}"); else MelonDebug.Msg($"Entry point for {name} is {result}"); @@ -72,7 +72,7 @@ public static void SetOffsets() if (ga == IntPtr.Zero) { - MelonLogger.Error("GameAssembly was not found, crash will likely follow"); + TurbonesMod.Logger.Error("GameAssembly was not found, crash will likely follow"); } var icalls = new ICallOffsets diff --git a/Turbones/TurbonesMod.cs b/Turbones/TurbonesMod.cs index 9ee188f..c2e7431 100644 --- a/Turbones/TurbonesMod.cs +++ b/Turbones/TurbonesMod.cs @@ -17,6 +17,8 @@ namespace Turbones { internal partial class TurbonesMod : MelonMod { + public static MelonLogger.Instance Logger; + private static IntPtr ourDynBoneCollideEntryPoint; private static IntPtr ourDynBoneUpdateEntryPoint; private static IntPtr ourLastPatchPointer; @@ -24,6 +26,8 @@ internal partial class TurbonesMod : MelonMod public override void OnApplicationStart() { ClassInjector.RegisterTypeInIl2Cpp(); + + Logger = LoggerInstance; var category = MelonPreferences.CreateCategory("Turbones"); var enableCollisionChecks = category.CreateEntry("OptimizedCollisionChecks", true, "Enable optimized collision checks"); @@ -43,13 +47,13 @@ public override void OnApplicationStart() } catch (IOException ex) { - MelonLogger.Warning("Failed to write native dll; will attempt loading it anyway. This is normal if you're running multiple instances of VRChat"); + Logger.Warning("Failed to write native dll; will attempt loading it anyway. This is normal if you're running multiple instances of VRChat"); MelonDebug.Msg(ex.ToString()); } if (!JigglySolverApi.Initialize("VRChat_Data/Plugins/" + dllName)) { - MelonLogger.Error("Error initializing native library; mod won't work"); + Logger.Error("Error initializing native library; mod won't work"); return; } @@ -71,7 +75,7 @@ unsafe void PatchCollide() fixed(IntPtr* a = &ourDynBoneCollideEntryPoint) MelonUtils.NativeHookAttach((IntPtr)a, JigglySolverApi.LibDynBoneCollideEntryPoint); - MelonLogger.Msg("Patched DynamicBone Collide"); + Logger.Msg("Patched DynamicBone Collide"); isCollidePatched = true; } @@ -82,7 +86,7 @@ unsafe void UnpatchCollide() fixed(IntPtr* a = &ourDynBoneCollideEntryPoint) MelonUtils.NativeHookDetach((IntPtr)a, JigglySolverApi.LibDynBoneCollideEntryPoint); - MelonLogger.Msg("Unpatched DynamicBone Collide"); + Logger.Msg("Unpatched DynamicBone Collide"); isCollidePatched = false; } @@ -96,7 +100,7 @@ unsafe void RepatchUpdate(bool useFast, bool useMt) fixed(IntPtr* a = &ourDynBoneUpdateEntryPoint) MelonUtils.NativeHookDetach((IntPtr)a, ourLastPatchPointer); - MelonLogger.Msg("Unpatched DynamicBone Update"); + Logger.Msg("Unpatched DynamicBone Update"); ourLastPatchPointer = IntPtr.Zero; } @@ -109,7 +113,7 @@ unsafe void RepatchUpdate(bool useFast, bool useMt) fixed(IntPtr* a = &ourDynBoneUpdateEntryPoint) MelonUtils.NativeHookAttach((IntPtr)a, ourLastPatchPointer); - MelonLogger.Msg($"Patched DynamicBone Update (multithreaded: {useMt})"); + Logger.Msg($"Patched DynamicBone Update (multithreaded: {useMt})"); } else { @@ -120,7 +124,7 @@ unsafe void RepatchUpdate(bool useFast, bool useMt) JigglySolverApi.SetOriginalBoneUpdateDelegate(ourDynBoneUpdateEntryPoint); - MelonLogger.Msg($"Patched DynamicBone Update (notify)"); + Logger.Msg($"Patched DynamicBone Update (notify)"); } } diff --git a/UIExpansionKit/API/Classes/AwaitProvider.cs b/UIExpansionKit/API/Classes/AwaitProvider.cs index 5c34fcd..0f51f6b 100644 --- a/UIExpansionKit/API/Classes/AwaitProvider.cs +++ b/UIExpansionKit/API/Classes/AwaitProvider.cs @@ -50,7 +50,7 @@ public void Flush() } catch (Exception ex) { - MelonLogger.Warning($"Exception in delegate queue {QueueName}: {ex}"); + UiExpansionKitMod.Instance.Logger.Warning($"Exception in delegate queue {QueueName}: {ex}"); } } } diff --git a/UIExpansionKit/API/ExpansionKitApi.cs b/UIExpansionKit/API/ExpansionKitApi.cs index 097634f..3d168d0 100644 --- a/UIExpansionKit/API/ExpansionKitApi.cs +++ b/UIExpansionKit/API/ExpansionKitApi.cs @@ -85,7 +85,7 @@ public static void RegisterCustomSettingsCategory(string categoryName, GameObjec { if (CustomCategoryUIs.ContainsKey(categoryName)) { - MelonLogger.Error($"Custom UI for category {categoryName} is already registered"); + UiExpansionKitMod.Instance.Logger.Error($"Custom UI for category {categoryName} is already registered"); return; } diff --git a/UIExpansionKit/API/TaskUtilities.cs b/UIExpansionKit/API/TaskUtilities.cs index e3f3082..873e6d8 100644 --- a/UIExpansionKit/API/TaskUtilities.cs +++ b/UIExpansionKit/API/TaskUtilities.cs @@ -40,7 +40,7 @@ public static void NoAwait(this Task task, string taskInfo = "Task") task.ContinueWith(tsk => { if (tsk.IsFaulted) - MelonLogger.Error($"Free-floating {taskInfo} failed with exception: {tsk.Exception}"); + UiExpansionKitMod.Instance.Logger.Error($"Free-floating {taskInfo} failed with exception: {tsk.Exception}"); }); } } diff --git a/UIExpansionKit/ButtonFactory.cs b/UIExpansionKit/ButtonFactory.cs index a13ac21..263b612 100644 --- a/UIExpansionKit/ButtonFactory.cs +++ b/UIExpansionKit/ButtonFactory.cs @@ -18,7 +18,7 @@ internal static void CreateButtonForRegistration(ExpansionKitApi.ButtonRegistrat } catch (Exception ex) { - MelonLogger.Error($"Exception when creating a button for registration of {registration}: {ex}"); + UiExpansionKitMod.Instance.Logger.Error($"Exception when creating a button for registration of {registration}: {ex}"); } } diff --git a/UIExpansionKit/FieldInject/InjectedField.cs b/UIExpansionKit/FieldInject/InjectedField.cs index 6aa300d..539342e 100644 --- a/UIExpansionKit/FieldInject/InjectedField.cs +++ b/UIExpansionKit/FieldInject/InjectedField.cs @@ -31,7 +31,7 @@ protected InjectedField(string name) var ownerClass = (Il2CppClass_24_2*) classPointer; myOffset = (int)ownerClass->instance_size - IntPtr.Size; - MelonLogger.Msg($"Injecting field: current size {ownerClass->instance_size} added size {addedSize} offset {myOffset}"); + UiExpansionKitMod.Instance.Logger.Msg($"Injecting field: current size {ownerClass->instance_size} added size {addedSize} offset {myOffset}"); var fieldType = (Il2CppType_16_0*)Marshal.AllocHGlobal(Marshal.SizeOf()); *fieldType = ((Il2CppClass_24_2*)fieldTypePointer)->byval_arg; diff --git a/UIExpansionKit/ModSettingsHandler.cs b/UIExpansionKit/ModSettingsHandler.cs index 7e4d99b..c1fe347 100644 --- a/UIExpansionKit/ModSettingsHandler.cs +++ b/UIExpansionKit/ModSettingsHandler.cs @@ -348,7 +348,7 @@ void RefreshOptions() break; } if (MelonDebug.IsEnabled()) - MelonLogger.Msg($"Unknown mod pref type {pref.GetType()}"); + UiExpansionKitMod.Instance.Logger.Msg($"Unknown mod pref type {pref.GetType()}"); break; } } diff --git a/UIExpansionKit/StylingHelper.cs b/UIExpansionKit/StylingHelper.cs index 3b1904f..199def4 100644 --- a/UIExpansionKit/StylingHelper.cs +++ b/UIExpansionKit/StylingHelper.cs @@ -84,13 +84,13 @@ public static void ApplyStyling(StyleElementWrapper wrapper) var requestedStyle = SewElementTypeIdField.Get(wrapper); if (string.IsNullOrEmpty(requestedStyle)) { - MelonLogger.Error("Empty requested style on SEW"); + UiExpansionKitMod.Instance.Logger.Error("Empty requested style on SEW"); return; } if (!ourDefaultStyleMap.TryGetValue(requestedStyle, out var className)) { - MelonLogger.Error($"Unknown requested style: {requestedStyle}"); + UiExpansionKitMod.Instance.Logger.Error($"Unknown requested style: {requestedStyle}"); return; } diff --git a/UIExpansionKit/UiExpansionKitMod.cs b/UIExpansionKit/UiExpansionKitMod.cs index 4d7b892..a7b2dcd 100644 --- a/UIExpansionKit/UiExpansionKitMod.cs +++ b/UIExpansionKit/UiExpansionKitMod.cs @@ -40,6 +40,8 @@ internal partial class UiExpansionKitMod : MelonMod internal Transform myCameraExpandoRoot; internal Transform myQmExpandosRoot; + public MelonLogger.Instance Logger; + private static readonly List<(ExpandedMenu, string, bool isFullMenu)> GameObjectToCategoryList = new List<(ExpandedMenu, string, bool)> { (ExpandedMenu.AvatarMenu, "UserInterface/MenuContent/Screens/Avatar", true), @@ -77,6 +79,7 @@ internal partial class UiExpansionKitMod : MelonMod public override void OnApplicationStart() { Instance = this; + Logger = LoggerInstance; ClassInjector.RegisterTypeInIl2Cpp(); ClassInjector.RegisterTypeInIl2Cpp(); ClassInjector.RegisterTypeInIl2Cpp(); @@ -165,7 +168,7 @@ private IEnumerator InitThings() } catch (Exception ex) { - MelonLogger.Error($"Error while invoking UI-manager-init delegate {action.GetType().FullName}: {ex}"); + Logger.Error($"Error while invoking UI-manager-init delegate {action.GetType().FullName}: {ex}"); } } @@ -182,7 +185,7 @@ private IEnumerator InitThings() } catch (Exception ex) { - MelonLogger.Error($"Error while waiting for init of coroutine with type {coroutine.GetType().FullName}: {ex}"); + Logger.Error($"Error while waiting for init of coroutine with type {coroutine.GetType().FullName}: {ex}"); break; } yield return coroutine.Current; @@ -217,7 +220,7 @@ private IEnumerator InitThings() private void DecorateMenuPages() { - MelonLogger.Msg("Decorating menus"); + Logger.Msg("Decorating menus"); var quickMenuExpandoPrefab = myStuffBundle.QuickMenuExpando; var quickMenuRoot = GetQuickMenu().transform.Find("Container").gameObject; @@ -244,7 +247,7 @@ private void DecorateMenuPages() var gameObject = UnityUtils.FindInactiveObjectInActiveRoot(gameObjectPath); if (gameObject == null) { - MelonLogger.Error($"GameObject at path {gameObjectPath} for category {categoryEnum} was not found, not decorating"); + Logger.Error($"GameObject at path {gameObjectPath} for category {categoryEnum} was not found, not decorating"); continue; } @@ -352,7 +355,7 @@ private void DecorateCamera() var cameraController = UserCameraController.field_Internal_Static_UserCameraController_0; if (cameraController == null) { - MelonLogger.Warning("Camera controller not found, not decorating the camera"); + Logger.Warning("Camera controller not found, not decorating the camera"); return; } diff --git a/ViewPointTweaker/ViewPointTweakerMod.cs b/ViewPointTweaker/ViewPointTweakerMod.cs index f7e78d3..9a0949e 100644 --- a/ViewPointTweaker/ViewPointTweakerMod.cs +++ b/ViewPointTweaker/ViewPointTweakerMod.cs @@ -63,7 +63,7 @@ private void OnUiManagerInit() return; } - MelonLogger.Error("Steam tracking not found, things will break"); + LoggerInstance.Error("Steam tracking not found, things will break"); } private void SaveViewpoints() @@ -78,7 +78,7 @@ private void LoadViewpoints() var json = File.ReadAllText(ViewPointsFilePath); JSON.MakeInto(JSON.Load(json), out ourSavedViewpoints); - MelonLogger.Msg($"Loaded {ourSavedViewpoints.Count} saved viewpoints"); + LoggerInstance.Msg($"Loaded {ourSavedViewpoints.Count} saved viewpoints"); } private static void HeadAlignmentInitPatch(IKHeadAlignment __instance)