From da0ac0f3ea9865f64ece6afcc003d08c14a4d5d1 Mon Sep 17 00:00:00 2001 From: Mae Date: Sat, 16 Mar 2024 13:08:04 -0700 Subject: [PATCH] Fixed templates not working --- .gitignore | 1 + BoneMenu/BoneMenu.cs | 3 +++ Main.cs | 21 ++++++++++++++++- README.md | 9 ++++--- Scripts/Helpers/EntryHelper.cs | 37 ++++++++++++++++++++++++----- Scripts/Lists/BonelabSplashes.cs | 40 ++++++++++++++++++++++++++++---- SplashText.csproj | 4 ++++ Staging/CHANGELOG.md | 4 ++++ Staging/README.md | 9 ++++--- Staging/manifest.json | 2 +- 10 files changed, 111 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 3406618..469edd6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ Links/ Scripts/Lists/TheBeeMovie.cs .idea/ *.dll +*.zip # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs diff --git a/BoneMenu/BoneMenu.cs b/BoneMenu/BoneMenu.cs index fc36e77..c19853a 100644 --- a/BoneMenu/BoneMenu.cs +++ b/BoneMenu/BoneMenu.cs @@ -12,5 +12,8 @@ public static void Setup() Preferences.OwnCategory.SaveToFile(false); TextManager.SetText(); }); +#if DEBUG + subCat.CreateFunctionElement("Reroll", Color.white, TextManager.SetText); +#endif } } \ No newline at end of file diff --git a/Main.cs b/Main.cs index d46d14f..b04673b 100644 --- a/Main.cs +++ b/Main.cs @@ -1,5 +1,7 @@ using HarmonyLib; using SLZ.Marrow.SceneStreaming; +using SLZ.Marrow.Warehouse; +using SLZ.SaveData; namespace WeatherElectric.SplashText; @@ -9,8 +11,10 @@ public class Main : MelonMod internal const string Description = "Adds splash text to Void G114's menu."; internal const string Author = "SoulWithMae"; internal const string Company = "Weather Electric"; - internal const string Version = "1.0.0"; + internal const string Version = "1.1.0"; internal const string DownloadLink = "https://bonelab.thunderstore.io/package/SoulWithMae/SplashText/"; + + public static Save SaveData; public override void OnInitializeMelon() { @@ -18,6 +22,8 @@ public override void OnInitializeMelon() Preferences.Setup(); BoneMenu.Setup(); UserData.Setup(); + + SaveData = DataManager.Instance._activeSave; } [HarmonyPatch(typeof(Player_Health), "MakeVignette")] @@ -31,6 +37,19 @@ public static void Postfix(Player_Health __instance) if (SceneStreamer.Session.Level.Barcode != CommonBarcodes.Maps.VoidG114) return; ModConsole.Msg("Void G114 loaded, creating splash text host", 1); TextManager.Start(); + +#if DEBUG + var testText1 = "[UserName] exists"; + var testText2 = "[PalletCount] pallets"; + var testText3 = "[CurrentAvatar] is your current avatar"; + testText1 = testText1.Replace("[UserName]", Environment.UserName); + testText2 = testText2.Replace("[PalletCount]", AssetWarehouse.Instance.GetPallets().Count.ToString()); + var crateRef = new AvatarCrateReference(SaveData.PlayerSettings.CurrentAvatar); + testText3 = testText3.Replace("[CurrentAvatar]", crateRef.Crate.Title); + ModConsole.Msg($"Test text 1: {testText1}", 1); + ModConsole.Msg($"Test text 2: {testText2}", 1); + ModConsole.Msg($"Test text 3: {testText3}", 1); +#endif } } } \ No newline at end of file diff --git a/README.md b/README.md index 9199bf7..01ab50b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ There are a few templates for use in entries. These templates get replaced with what their value is. -* {CurrentAvatar} - What avatar you are -* {UserName} = Your windows username -* {PalletCount} = How many SDK mods you have installed \ No newline at end of file +* [CurrentAvatar] - What avatar you are +* [UserName] = Your windows username +* [PalletCount] = How many SDK mods you have installed +* [Height] = Your height +* [RandomFavoriteAvatar] = A random favorite avatar +* [RandomFavoriteSpawnable] = A random favorite spawnable \ No newline at end of file diff --git a/Scripts/Helpers/EntryHelper.cs b/Scripts/Helpers/EntryHelper.cs index 1a5712d..19a3094 100644 --- a/Scripts/Helpers/EntryHelper.cs +++ b/Scripts/Helpers/EntryHelper.cs @@ -11,19 +11,44 @@ public static string GetRandomEntry() var r = rnd.Next(lines.Length); var randomSplash = lines[r]; - if (randomSplash.Contains("{UserName}")) + if (randomSplash.Contains("[UserName]")) { - randomSplash = randomSplash.Replace("{UserName}", Environment.UserName); + randomSplash = randomSplash.Replace("[UserName]", Environment.UserName); } - if (randomSplash.Contains("{PalletCount}")) + if (randomSplash.Contains("[PalletCount]")) { - randomSplash = randomSplash.Replace("{PalletCount}", AssetWarehouse.Instance.GetPallets().Count.ToString()); + randomSplash = randomSplash.Replace("[PalletCount]", AssetWarehouse.Instance.GetPallets().Count.ToString()); } - if (randomSplash.Contains("{CurrentAvatar}")) + if (randomSplash.Contains("[CurrentAvatar]")) { - randomSplash = randomSplash.Replace("{CurrentAvatar}", Player.rigManager.AvatarCrate.Crate.Title); + var crateRef = new AvatarCrateReference(Main.SaveData.PlayerSettings.CurrentAvatar); + randomSplash = randomSplash.Replace("[CurrentAvatar]", crateRef.Crate.Title); + } + + if (randomSplash.Contains("[Height")) + { + var height = Main.SaveData.PlayerSettings.PlayerHeight; + int feet = (int)height; + float inches = height - feet; + randomSplash = randomSplash.Replace("[Height]", $"{feet}'{inches}\""); + } + + // It's gonna say this has errors: it does not. it builds fine, il2cpp just sucks + if (randomSplash.Contains("[RandomFavoriteSpawnable]")) + { + var spawnable = Main.SaveData.PlayerSettings.FavoriteSpawnables[rnd.Next(Main.SaveData.PlayerSettings.FavoriteSpawnables.Count)]; + var crateRef = new SpawnableCrateReference(spawnable); + randomSplash = randomSplash.Replace("[RandomFavoriteSpawnable]", crateRef.Crate.Title); + } + + if (randomSplash.Contains("[RandomFavoriteAvatar]")) + { + + var avatar = Main.SaveData.PlayerSettings.FavoriteAvatars[rnd.Next(Main.SaveData.PlayerSettings.FavoriteAvatars.Count)]; + var crateRef = new AvatarCrateReference(avatar); + randomSplash = randomSplash.Replace("[RandomFavoriteAvatar]", crateRef.Crate.Title); } return randomSplash; diff --git a/Scripts/Lists/BonelabSplashes.cs b/Scripts/Lists/BonelabSplashes.cs index c087c54..5bf9d19 100644 --- a/Scripts/Lists/BonelabSplashes.cs +++ b/Scripts/Lists/BonelabSplashes.cs @@ -1,5 +1,7 @@ using System.Collections; +using Newtonsoft.Json; using SLZ.Marrow.Warehouse; +using SLZ.SaveData; using UnityEngine.Networking; namespace WeatherElectric.SplashText.Scripts.Lists; @@ -51,7 +53,10 @@ public static class BonelabSplashes "i'm gonna put 9 realtime lights in the scene, suffer", "Only {PalletCount} mods installed? smh", "{CurrentAvatar}? what a lame avatar", - "oh cool, {CurrentAvatar}, thats a good avatar" + "oh cool, {CurrentAvatar}, thats a good avatar", + "lol [Height]", + "you really use [RandomFavoriteSpawnable]?", + "you liked [RandomFavoriteAvatar] enough to put it in your BODYLOG?" }; private const string SplashAPI = "https://splashtext.weatherelectric.xyz/"; @@ -96,14 +101,39 @@ public static string GetRandomOfflineSplash() var rnd = new System.Random(); var randomSplash = Splashes[rnd.Next(Splashes.Length)]; - if (randomSplash.Contains("{PalletCount}")) + if (randomSplash.Contains("[PalletCount]")) { - randomSplash = randomSplash.Replace("{PalletCount}", AssetWarehouse.Instance.GetPallets().Count.ToString()); + randomSplash = randomSplash.Replace("[PalletCount]", AssetWarehouse.Instance.GetPallets().Count.ToString()); } - if (randomSplash.Contains("{CurrentAvatar}")) + if (randomSplash.Contains("[CurrentAvatar]")) { - randomSplash = randomSplash.Replace("{CurrentAvatar}", Player.rigManager.AvatarCrate.Crate.Title); + var crateRef = new AvatarCrateReference(Main.SaveData.PlayerSettings.CurrentAvatar); + randomSplash = randomSplash.Replace("[CurrentAvatar]", crateRef.Crate.Title); + } + + if (randomSplash.Contains("[Height")) + { + var height = Main.SaveData.PlayerSettings.PlayerHeight; + int feet = (int)height; + float inches = height - feet; + randomSplash = randomSplash.Replace("[Height]", $"{feet}'{inches}\""); + } + + // It's gonna say this has errors: it does not. it builds fine, il2cpp just sucks + if (randomSplash.Contains("[RandomFavoriteSpawnable]")) + { + var spawnable = Main.SaveData.PlayerSettings.FavoriteSpawnables[rnd.Next(Main.SaveData.PlayerSettings.FavoriteSpawnables.Count)]; + var crateRef = new SpawnableCrateReference(spawnable); + randomSplash = randomSplash.Replace("[RandomFavoriteSpawnable]", crateRef.Crate.Title); + } + + if (randomSplash.Contains("[RandomFavoriteAvatar]")) + { + + var avatar = Main.SaveData.PlayerSettings.FavoriteAvatars[rnd.Next(Main.SaveData.PlayerSettings.FavoriteAvatars.Count)]; + var crateRef = new AvatarCrateReference(avatar); + randomSplash = randomSplash.Replace("[RandomFavoriteAvatar]", crateRef.Crate.Title); } return randomSplash; diff --git a/SplashText.csproj b/SplashText.csproj index 8aa71ae..0ff1225 100644 --- a/SplashText.csproj +++ b/SplashText.csproj @@ -23,6 +23,7 @@ DEBUG;TRACE prompt 4 + CS0121 AnyCPU @@ -52,6 +53,9 @@ Links\MelonLoader\MelonLoader.dll + + ..\..\..\..\Steam\steamapps\common\BONELAB\MelonLoader\Dependencies\Il2CppAssemblyGenerator\Cpp2IL\cpp2il_out\Newtonsoft.Json.dll + Links\MelonLoader\Managed\SLZ.Marrow.dll diff --git a/Staging/CHANGELOG.md b/Staging/CHANGELOG.md index 9656226..6c49f1b 100644 --- a/Staging/CHANGELOG.md +++ b/Staging/CHANGELOG.md @@ -1,2 +1,6 @@ +**v1.1.0** +* Fixed templates not working +* Added [Height], [RandomFavoriteAvatar] and [RandomFavoriteSpawnable] templates + **v1.0.0** * Initial release \ No newline at end of file diff --git a/Staging/README.md b/Staging/README.md index 9199bf7..01ab50b 100644 --- a/Staging/README.md +++ b/Staging/README.md @@ -14,6 +14,9 @@ There are a few templates for use in entries. These templates get replaced with what their value is. -* {CurrentAvatar} - What avatar you are -* {UserName} = Your windows username -* {PalletCount} = How many SDK mods you have installed \ No newline at end of file +* [CurrentAvatar] - What avatar you are +* [UserName] = Your windows username +* [PalletCount] = How many SDK mods you have installed +* [Height] = Your height +* [RandomFavoriteAvatar] = A random favorite avatar +* [RandomFavoriteSpawnable] = A random favorite spawnable \ No newline at end of file diff --git a/Staging/manifest.json b/Staging/manifest.json index 6df521a..0c832f0 100644 --- a/Staging/manifest.json +++ b/Staging/manifest.json @@ -1,6 +1,6 @@ { "name": "SplashText", - "version_number": "1.0.0", + "version_number": "1.1.0", "website_url": "https://github.com/WeatherElectric/SplashText", "description": "Adds splash text to Void G114's menu.", "dependencies": [