Skip to content

Commit

Permalink
Fixed templates not working
Browse files Browse the repository at this point in the history
  • Loading branch information
FragileDeviations committed Mar 16, 2024
1 parent c7d201b commit da0ac0f
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Links/
Scripts/Lists/TheBeeMovie.cs
.idea/
*.dll
*.zip

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
3 changes: 3 additions & 0 deletions BoneMenu/BoneMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ public static void Setup()
Preferences.OwnCategory.SaveToFile(false);
TextManager.SetText();
});
#if DEBUG
subCat.CreateFunctionElement("Reroll", Color.white, TextManager.SetText);
#endif
}
}
21 changes: 20 additions & 1 deletion Main.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using HarmonyLib;
using SLZ.Marrow.SceneStreaming;
using SLZ.Marrow.Warehouse;
using SLZ.SaveData;

namespace WeatherElectric.SplashText;

Expand All @@ -9,15 +11,19 @@ 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()
{
ModConsole.Setup(LoggerInstance);
Preferences.Setup();
BoneMenu.Setup();
UserData.Setup();

SaveData = DataManager.Instance._activeSave;
}

[HarmonyPatch(typeof(Player_Health), "MakeVignette")]
Expand All @@ -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
}
}
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* [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
37 changes: 31 additions & 6 deletions Scripts/Helpers/EntryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
40 changes: 35 additions & 5 deletions Scripts/Lists/BonelabSplashes.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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/";
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions SplashText.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>CS0121</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -52,6 +53,9 @@
<Reference Include="MelonLoader">
<HintPath>Links\MelonLoader\MelonLoader.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\..\Steam\steamapps\common\BONELAB\MelonLoader\Dependencies\Il2CppAssemblyGenerator\Cpp2IL\cpp2il_out\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SLZ.Marrow">
<HintPath>Links\MelonLoader\Managed\SLZ.Marrow.dll</HintPath>
</Reference>
Expand Down
4 changes: 4 additions & 0 deletions Staging/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
**v1.1.0**
* Fixed templates not working
* Added [Height], [RandomFavoriteAvatar] and [RandomFavoriteSpawnable] templates

**v1.0.0**
* Initial release
9 changes: 6 additions & 3 deletions Staging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* [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
2 changes: 1 addition & 1 deletion Staging/manifest.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down

0 comments on commit da0ac0f

Please sign in to comment.