From fc90197eef917898185edfdd121c2d1a99443ae0 Mon Sep 17 00:00:00 2001 From: Sunskimmer82 <92886026+Sunskimmer822@users.noreply.github.com> Date: Tue, 22 Apr 2025 22:32:27 -0500 Subject: [PATCH] songs load into the arcade list now! the maps don't work though --- Core.cs | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/Core.cs b/Core.cs index ee48cc2..03ce741 100644 --- a/Core.cs +++ b/Core.cs @@ -13,6 +13,7 @@ using Arcade.UI.SongSelect; using static Arcade.UI.SongSelect.ArcadeSongDatabase; using UnityEngine.UIElements; using System.Xml.Linq; +using static Dreamteck.Splines.SplineSampleModifier; [assembly: MelonInfo(typeof(UnbeatableSongHack.Core), "SUnbeatable-Loader", "1.0.0", "Serena Sunskimmer82", null)] [assembly: MelonGame("D-CELL GAMES", "UNBEATABLE [DEMO]")] @@ -287,7 +288,7 @@ namespace UnbeatableSongHack LoggerInstance.Msg("Adding song to list: " + beatmapItem.Path); // This whole part would be needed for AddSongList() - beatmapItem.Beatmap = new Beatmap(); + beatmapItem.Beatmap = ScriptableObject.CreateInstance(); beatmapItem.Beatmap.metadata.title = "Custom " + name; beatmapItem.Beatmap.metadata.titleUnicode = "Custom " + name; beatmapItem.Beatmap.metadata.artist = "Not You"; @@ -412,7 +413,7 @@ namespace UnbeatableSongHack } } - if (GUI.Button(new Rect(10,120,100,25), "Add Empty Songs To Arcade")) + if (GUI.Button(new Rect(10,120,100,25), "Add Custom Songs To Arcade")) { var db = Arcade.UI.SongSelect.ArcadeSongDatabase.Instance; @@ -437,12 +438,12 @@ namespace UnbeatableSongHack LoggerInstance.Msg($"{beatmapName} has difficulty {difficulty}"); BeatmapItem item = new BeatmapItem(); - item.Path = "__CUSTOM" + songFile+"/"+difficulty.ToUpper(); + item.Path = "__CUSTOM" + songFile; item.Song = new Song(beatmapName); TextAsset asset = new TextAsset(beatmapContent); asset.name = beatmapName; item.BeatmapInfo = new BeatmapInfo(asset,difficulty); - item.Beatmap = new Beatmap(); + item.Beatmap = ScriptableObject.CreateInstance(); item.Beatmap.name = beatmapName; item.Beatmap.metadata.title = beatmapName; item.Beatmap.metadata.titleUnicode = beatmapName; @@ -637,6 +638,79 @@ namespace UnbeatableSongHack } + [HarmonyPatch(typeof(ArcadeSongDatabase), "Awake")] + public class ArcadeSongDatabasePatch + { + public static void Postfix(ref ArcadeSongDatabase __instance) + { + var LoggerInstance = Core.GetLogger(); + LoggerInstance.Msg("HAIIIIIIII"); + + Traverse traverse = Traverse.Create(__instance); + BeatmapIndex beatmapIndex = traverse.Field("_beatmapIndex").GetValue(); + Dictionary songDatabase = traverse.Field("_songDatabase").GetValue>(); + List songList = traverse.Field("_songList").GetValue>(); + + string beatmapPath = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\UNBEATABLE Demo\\SUnbeatable-Loader\\Songs\\Empty Diary (Custom)\\beatmap.dat"; + + //test song - Empty Diaryaaa + string beatmap = File.ReadAllText(beatmapPath); + + string songName = ""; + using (var songNameReader = new StringReader(beatmap.Substring(beatmap.IndexOf("Title:") + 6).Trim())) + { + songName = songNameReader.ReadLine(); + } + LoggerInstance.Msg(songName); + + string difficulty = beatmap.Substring(beatmap.IndexOf("Version:") + 8 /* adding 8, the length of the string "Version:" */ , beatmap.IndexOf(" ", beatmap.IndexOf("Version:")) - (beatmap.IndexOf("Version:") + 8)); + LoggerInstance.Msg(difficulty); + + string path = "__CUSTOM"+beatmapPath; + BeatmapIndex.Song mapSong = new Song(songName); + mapSong.stageScene = "TrainStationRhythm"; + TextAsset asset = new TextAsset(); + BeatmapInfo info = new BeatmapInfo(asset,difficulty); + Beatmap map = ScriptableObject.CreateInstance(); + map.metadata.title = songName; + map.metadata.titleUnicode = songName; + map.metadata.artist = "Not You"; + map.metadata.artistUnicode = "Not You"; + map.metadata.tagData.Level = 10; + + BeatmapItem item = new BeatmapItem(); + item.Path = path; + item.BeatmapInfo = info; + item.Beatmap = map; + item.Highscore = new HighScoreItem(path, 0, 0f, 0, cleared: false, new Dictionary(), Modifiers.None); + item.Unlocked = true; + + songList.Add(item); + songDatabase.TryAdd(songName, item); + + + /*public string Path; + + public BeatmapIndex.Song Song; + + public BeatmapInfo BeatmapInfo; + + public Beatmap Beatmap; + + public HighScoreItem Highscore; + + public bool Unlocked; + + public override string ToString() + { + return Path; + }*/ + + + } + + } +