From 4839c44c9a2db24d829ec55043cddfd12934bed4 Mon Sep 17 00:00:00 2001 From: Kirefel Date: Sun, 19 Mar 2023 18:07:42 +1100 Subject: [PATCH] Open seed directory from menu --- README.md | 4 +- Randomiser/GenerateRandomiserSeedAction.cs | 11 ++--- Randomiser/RandomiserSaveSlotsUI.cs | 41 +++++++++++++++++++ .../World Changes/RandomiserBootstrap.cs | 21 +++++++--- Randomiser/strings/English.txt | 2 + 5 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 Randomiser/RandomiserSaveSlotsUI.cs diff --git a/README.md b/README.md index 9e90ffa..dea006c 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ Upcoming: ### Where is the spoiler/seed file? -In the mod's install location (default `%APPDATA%\ori-bf-mod-manager\mods\RandoBeta\seeds`). The folders are named by date. These will be deleted whenever the mod is updated so be sure to save a copy of any you want to keep. The seed is also stored in the save file of the game itself so it won't be affected if the `randomizer0.dat` file is deleted. +Go to the save file in the main menu and press the indicated button (default `Tab`/`Back`) -This will become more easily accessible later. +These files are lost when updating the mod or overwriting a save slot, so be sure to make a copy of any you want to keep. ### Sein text is back! diff --git a/Randomiser/GenerateRandomiserSeedAction.cs b/Randomiser/GenerateRandomiserSeedAction.cs index 0c3b2a0..2f0aaed 100644 --- a/Randomiser/GenerateRandomiserSeedAction.cs +++ b/Randomiser/GenerateRandomiserSeedAction.cs @@ -19,21 +19,18 @@ public override void Perform(IContext context) isRunning = true; - Thread thread = new Thread(GenerateSeed); // idk how long this takes, just assumed it might take a few seconds during which we don't want to be frozen - // Might not need the thread + Thread thread = new Thread(GenerateSeed); thread.Start(); } - public override void Stop() - { - - } + public override void Stop() { } private void GenerateSeed() { var assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - var outputPath = Path.GetFullPath(Path.Combine(assemblyDir, Path.Combine("seeds", DateTime.Now.ToString("yyyyMMddHHmmss")))); + int saveSlotIndex = SaveSlotsUI.Instance.CurrentSlotIndex; + var outputPath = Path.GetFullPath(Path.Combine(assemblyDir, Path.Combine("seeds", (saveSlotIndex + 1).ToString()))); Directory.CreateDirectory(outputPath); string seedgenPath = Path.Combine( diff --git a/Randomiser/RandomiserSaveSlotsUI.cs b/Randomiser/RandomiserSaveSlotsUI.cs new file mode 100644 index 0000000..ddc4378 --- /dev/null +++ b/Randomiser/RandomiserSaveSlotsUI.cs @@ -0,0 +1,41 @@ +using System.Diagnostics; +using System.IO; +using System.Reflection; +using UnityEngine; + +namespace Randomiser +{ + public class RandomiserSaveSlotsUI : MonoBehaviour, ISuspendable + { + public bool IsSuspended { get; set; } + + private SaveSlotsUI saveSlotsUI; + + void Awake() + { + SuspensionManager.Register(this); + saveSlotsUI = GetComponent(); + } + + void FixedUpdate() + { + if (IsSuspended || !GameController.IsFocused || !saveSlotsUI.IsVisible || saveSlotsUI.PromptIsOpen || !saveSlotsUI.Active || saveSlotsUI.SelectingDifficulty || saveSlotsUI.IsCopying) + return; + + if (Core.Input.Select.OnPressed && !Core.Input.Select.Used && saveSlotsUI.CurrentSaveSlot && saveSlotsUI.CurrentSaveSlot.HasSave) + { + Core.Input.Select.Used = true; + + var assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + int saveSlotIndex = saveSlotsUI.CurrentSlotIndex; + var outputPath = Path.GetFullPath(Path.Combine(assemblyDir, Path.Combine("seeds", (saveSlotIndex + 1).ToString()))); + + if (Directory.Exists(outputPath)) + Process.Start(outputPath); + else + Randomiser.Message("Seed directory not found"); + } + } + } +} diff --git a/Randomiser/World Changes/RandomiserBootstrap.cs b/Randomiser/World Changes/RandomiserBootstrap.cs index 49d08a6..ca5317a 100644 --- a/Randomiser/World Changes/RandomiserBootstrap.cs +++ b/Randomiser/World Changes/RandomiserBootstrap.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Reflection; +using BaseModLib; using OriDeModLoader; using UnityEngine; @@ -57,13 +58,13 @@ private static void BootstrapCreditsScreen(SceneRoot sceneRoot) var messageBox = creditsTextMods.GetComponent(); messageBox.OverrideText = "TODO"; -// messageBox.OverrideText = @"*Mods*# + // messageBox.OverrideText = @"*Mods*# -//#Author/s ^Mod Loader^# + //#Author/s ^Mod Loader^# -//#Name 1 ^Mod 1^ -//Name 2 ^Mod 2^ -//Name n ^Mod n^#"; + //#Name 1 ^Mod 1^ + //Name 2 ^Mod 2^ + //Name n ^Mod n^#"; } private static void BootstrapTitleScreenSwallowsNest(SceneRoot sceneRoot) @@ -139,6 +140,16 @@ private static void BootstrapTitleScreenSwallowsNest(SceneRoot sceneRoot) ActionSequence.Rename(startGameSequence.Actions); } + + // Open folder in explorer/copy seed + { + sceneRoot.transform.Find("ui/group/6. saveSlots/saveSlotUI").gameObject.AddComponent(); + var backLabel = sceneRoot.transform.Find("ui/group/6. saveSlots/legend/back").GetComponent(); + //backLabel.SetMessage(new MessageDescriptor(Strings.Get("UI_VIEW_SEED"))); + var provider = ScriptableObject.CreateInstance(); + provider.SetMessage(Strings.Get("UI_VIEW_SEED")); + backLabel.SetMessageProvider(provider); + } } private static Texture2D LoadTextureFromFile(string path, int width, int height) diff --git a/Randomiser/strings/English.txt b/Randomiser/strings/English.txt index b9cbdbe..8a60cc9 100644 --- a/Randomiser/strings/English.txt +++ b/Randomiser/strings/English.txt @@ -93,3 +93,5 @@ ABILITY_DESC_AttackPowerUpgrade=Enhances the strength of Spirit Flame ABILITY_FIND_TO_UNLOCK=@Find this in the world to unlock@ ABILITY_OWNED_COUNT=$Number obtained: {0}$ + +UI_VIEW_SEED=[Map] View Seed \ No newline at end of file