Skip to content

Commit

Permalink
Open seed directory from menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirefel committed Mar 19, 2023
1 parent a7a05be commit 4839c44
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
11 changes: 4 additions & 7 deletions Randomiser/GenerateRandomiserSeedAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
41 changes: 41 additions & 0 deletions Randomiser/RandomiserSaveSlotsUI.cs
Original file line number Diff line number Diff line change
@@ -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<SaveSlotsUI>();
}

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");
}
}
}
}
21 changes: 16 additions & 5 deletions Randomiser/World Changes/RandomiserBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using BaseModLib;
using OriDeModLoader;
using UnityEngine;

Expand Down Expand Up @@ -57,13 +58,13 @@ private static void BootstrapCreditsScreen(SceneRoot sceneRoot)

var messageBox = creditsTextMods.GetComponent<MessageBox>();
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)
Expand Down Expand Up @@ -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<RandomiserSaveSlotsUI>();
var backLabel = sceneRoot.transform.Find("ui/group/6. saveSlots/legend/back").GetComponent<MessageBox>();
//backLabel.SetMessage(new MessageDescriptor(Strings.Get("UI_VIEW_SEED")));
var provider = ScriptableObject.CreateInstance<BasicMessageProvider>();
provider.SetMessage(Strings.Get("UI_VIEW_SEED"));
backLabel.SetMessageProvider(provider);
}
}

private static Texture2D LoadTextureFromFile(string path, int width, int height)
Expand Down
2 changes: 2 additions & 0 deletions Randomiser/strings/English.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4839c44

Please sign in to comment.