Skip to content

Commit

Permalink
Fixed a slight oversight in remote splash handling
Browse files Browse the repository at this point in the history
  • Loading branch information
FragileDeviations committed Mar 16, 2024
1 parent da0ac0f commit a150aec
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
1 change: 1 addition & 0 deletions GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
global using WeatherElectric.SplashText.Melon;
global using BoneLib.BoneMenu;
global using BoneLib.BoneMenu.Elements;
global using SLZ.Marrow.Warehouse;
global using UnityEngine;
global using WeatherElectric.SplashText.Menu;
global using WeatherElectric.SplashText.Scripts;
Expand Down
3 changes: 1 addition & 2 deletions Main.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using HarmonyLib;
using SLZ.Marrow.SceneStreaming;
using SLZ.Marrow.Warehouse;
using SLZ.SaveData;

namespace WeatherElectric.SplashText;
Expand All @@ -11,7 +10,7 @@ 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.1.0";
internal const string Version = "1.1.1";
internal const string DownloadLink = "https://bonelab.thunderstore.io/package/SoulWithMae/SplashText/";

public static Save SaveData;
Expand Down
4 changes: 1 addition & 3 deletions Scripts/Helpers/EntryHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using SLZ.Marrow.Warehouse;

namespace WeatherElectric.SplashText.Scripts.Helpers;
namespace WeatherElectric.SplashText.Scripts.Helpers;

internal static class EntryHelper
{
Expand Down
47 changes: 41 additions & 6 deletions Scripts/Lists/BonelabSplashes.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
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 @@ -80,9 +77,47 @@ private static IEnumerator FetchText(FetchTextCallback callback)

if (request.result == UnityWebRequest.Result.Success)
{
string randomText = request.downloadHandler.text;
ModConsole.Msg($"Text recieved: {randomText}", 1);
callback(randomText);
var rnd = new System.Random();
string randomSplash = request.downloadHandler.text;

ModConsole.Msg($"Text recieved: {randomSplash}", 1);

if (randomSplash.Contains("[PalletCount]"))
{
randomSplash = randomSplash.Replace("[PalletCount]", AssetWarehouse.Instance.GetPallets().Count.ToString());
}

if (randomSplash.Contains("[CurrentAvatar]"))
{
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);
}

callback(randomSplash);
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions Staging/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**v1.1.1**
* Fixed oversight in remote splash text handling

**v1.1.0**
* Fixed templates not working
* Added [Height], [RandomFavoriteAvatar] and [RandomFavoriteSpawnable] templates
Expand Down
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.1.0",
"version_number": "1.1.1",
"website_url": "https://github.com/WeatherElectric/SplashText",
"description": "Adds splash text to Void G114's menu.",
"dependencies": [
Expand Down

0 comments on commit a150aec

Please sign in to comment.