Skip to content

Commit

Permalink
Replace map% indicator with goal on pause screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirefel committed Mar 29, 2023
1 parent f60f876 commit f19754d
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 83 deletions.
70 changes: 1 addition & 69 deletions Randomiser/Core/Randomiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static void Grant(Location location)
if (location.type == Location.LocationType.Skill && location.name != "Sein")
{
if (TreesFoundExceptSein % 3 == 0)
Message(BuildProgressString());
Message(DynamicText.BuildProgressString());
}
}

Expand Down Expand Up @@ -128,73 +128,5 @@ private static bool IsGoalMet(GoalMode mode)
}
return false;
}

public static string BuildProgressString()
{
StringBuilder sb = new StringBuilder();

int trees = TreesFoundExceptSein;
int maps = MapstonesRepaired;

if (Seed.GoalMode == GoalMode.WorldTour)
{
int relics = RelicsFound;
sb.Append(Strings.Get("RANDO_PROGRESS_WORLDTOUR",
trees >= 10 ? "$" : "",
trees,
maps >= 9 ? "$" : "",
maps,
TotalPickupsFound,
relics >= Seed.RelicsRequired ? "$" : "",
relics,
Seed.RelicsRequired
));
}
else
{
sb.Append(Strings.Get("RANDO_PROGRESS_0",
trees == 10 ? "$" : "",
trees,
maps == 9 ? "$" : "",
maps,
TotalPickupsFound
));
}

if (Seed.KeyMode == KeyMode.Clues)
{
Clues.Clue wv = Seed.Clues.WaterVein;
Clues.Clue gs = Seed.Clues.GumonSeal;
Clues.Clue ss = Seed.Clues.Sunstone;

sb.AppendLine();
sb.Append(Strings.Get("RANDO_PROGRESS_CLUES",
wv.owned ? "*" : "",
wv.revealed ? Strings.Get("AREA_SHORT_" + wv.area) : "????",
gs.owned ? "#" : "",
gs.revealed ? Strings.Get("AREA_SHORT_" + gs.area) : "????",
ss.owned ? "@" : "",
ss.revealed ? Strings.Get("AREA_SHORT_" + ss.area) : "????"
));
}

if (Seed.KeyMode == KeyMode.Shards)
{
int max = Seed.ShardsRequiredForKey;

sb.AppendLine();
sb.Append(Strings.Get("RANDO_PROGRESS_SHARDS",
Inventory.waterVeinShards == max ? "*" : "",
Inventory.waterVeinShards,
Inventory.gumonSealShards == max ? "#" : "",
Inventory.gumonSealShards,
Inventory.sunstoneShards == max ? "@" : "",
Inventory.sunstoneShards,
max
));
}

return sb.ToString();
}
}
}
18 changes: 5 additions & 13 deletions Randomiser/Core/RandomiserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void Update()

if (UnityEngine.Input.GetKeyDown(KeyCode.P))
{
Randomiser.Message(Randomiser.BuildProgressString());
Randomiser.Message(DynamicText.BuildProgressString());
}
}

Expand All @@ -100,19 +100,11 @@ private void Update()
Randomiser.Message(Randomiser.Inventory.lastPickup);
}

if (Randomiser.Seed.GoalMode == GoalMode.WorldTour && UnityEngine.Input.GetKeyDown(KeyCode.Alpha5))
if (UnityEngine.Input.GetKeyDown(KeyCode.Alpha5))
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(Strings.Get("OBJECTIVE_RELICS_FOUND_TEXT"));
foreach (var relicLocation in Randomiser.Seed.RelicLocations.OrderBy(l => (int)l.worldArea))
{
bool found = relicLocation.HasBeenObtained();
if (found) sb.Append("$");
sb.Append(Strings.Get("AREA_SHORT_" + relicLocation.worldArea.ToString()));
if (found) sb.Append("$");
sb.Append(" ");
}
Randomiser.Message(sb.ToString());
string text = DynamicText.BuildDetailedGoalString();
if (!string.IsNullOrEmpty(text))
Randomiser.Message(text);
}
}
}
Expand Down
109 changes: 109 additions & 0 deletions Randomiser/DynamicText.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System.Linq;
using System.Text;
using OriDeModLoader;

namespace Randomiser
{
public static class DynamicText
{
public static string BuildProgressString()
{
StringBuilder sb = new StringBuilder();

int trees = Randomiser.TreesFoundExceptSein;
int maps = Randomiser.MapstonesRepaired;

if (Randomiser.Seed.GoalMode == GoalMode.WorldTour)
{
int relics = Randomiser.RelicsFound;
sb.Append(Strings.Get("RANDO_PROGRESS_WORLDTOUR",
trees >= 10 ? "$" : "",
trees,
maps >= 9 ? "$" : "",
maps,
Randomiser.TotalPickupsFound,
relics >= Randomiser.Seed.RelicsRequired ? "$" : "",
relics,
Randomiser.Seed.RelicsRequired
));
}
else
{
sb.Append(Strings.Get("RANDO_PROGRESS_0",
trees == 10 ? "$" : "",
trees,
maps == 9 ? "$" : "",
maps,
Randomiser.TotalPickupsFound
));
}

if (Randomiser.Seed.KeyMode == KeyMode.Clues)
{
Clues.Clue wv = Randomiser.Seed.Clues.WaterVein;
Clues.Clue gs = Randomiser.Seed.Clues.GumonSeal;
Clues.Clue ss = Randomiser.Seed.Clues.Sunstone;

sb.AppendLine();
sb.Append(Strings.Get("RANDO_PROGRESS_CLUES",
wv.owned ? "*" : "",
wv.revealed ? Strings.Get("AREA_SHORT_" + wv.area) : "????",
gs.owned ? "#" : "",
gs.revealed ? Strings.Get("AREA_SHORT_" + gs.area) : "????",
ss.owned ? "@" : "",
ss.revealed ? Strings.Get("AREA_SHORT_" + ss.area) : "????"
));
}

if (Randomiser.Seed.KeyMode == KeyMode.Shards)
{
int max = Randomiser.Seed.ShardsRequiredForKey;

sb.AppendLine();
sb.Append(Strings.Get("RANDO_PROGRESS_SHARDS",
Randomiser.Inventory.waterVeinShards == max ? "*" : "",
Randomiser.Inventory.waterVeinShards,
Randomiser.Inventory.gumonSealShards == max ? "#" : "",
Randomiser.Inventory.gumonSealShards,
Randomiser.Inventory.sunstoneShards == max ? "@" : "",
Randomiser.Inventory.sunstoneShards,
max
));
}

return sb.ToString();
}

public static string BuildDetailedGoalString()
{
StringBuilder sb = new StringBuilder();

if (Randomiser.Seed.GoalMode == GoalMode.WorldTour)
{
sb.AppendLine(Strings.Get("OBJECTIVE_RELICS_FOUND_TEXT"));
foreach (var relicLocation in Randomiser.Seed.RelicLocations.OrderBy(l => (int)l.worldArea))
{
bool found = relicLocation.HasBeenObtained();
if (found) sb.Append("$");
sb.Append(Strings.Get("AREA_SHORT_" + relicLocation.worldArea.ToString()));
if (found) sb.Append("$");
sb.Append(" ");
}
}
else if (Randomiser.Seed.GoalMode == GoalMode.ForceTrees)
{
sb.AppendLine(Strings.Get("OBJECTIVE_TREES_FOUND_TEXT"));
foreach (var treeLocation in Randomiser.Locations.Cache.skillsExceptSein.OrderBy(l => l.saveIndex))
{
bool found = treeLocation.HasBeenObtained();
if (found) sb.Append("$");
sb.Append(Strings.Get("LOCATION_" + treeLocation.name));
if (found) sb.Append("$");
sb.Append(" ");
}
}

return sb.ToString();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using HarmonyLib;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HarmonyLib;
using OriDeModLoader;
using Sein.World;
using UnityEngine;
Expand All @@ -23,6 +26,8 @@ private static void Postfix(InventoryManager __instance)
sunstoneClueText = Object.Instantiate(__instance.EnergyUpgradesText);
sunstoneClueText.transform.position = __instance.MountHoruKey.transform.position + Vector3.down * 0.55f;
sunstoneClueText.transform.SetParent(__instance.MountHoruKey.transform);

__instance.CompletionText.transform.parent.GetComponentInChildren<InventoryItemHelpText>().HelpMessage = ScriptableObject.CreateInstance<CompletionDescriptionMessageProvider>();
}
}

Expand All @@ -34,6 +39,8 @@ private static void Postfix()
InventoryManagerKeyHintsAwake.waterVeinClueText.SetMessage(new MessageDescriptor(GetKeyLabel(Keys.GinsoTree, 0, Randomiser.Inventory.waterVeinShards)));
InventoryManagerKeyHintsAwake.gumonSealClueText.SetMessage(new MessageDescriptor(GetKeyLabel(Keys.ForlornRuins, 1, Randomiser.Inventory.gumonSealShards)));
InventoryManagerKeyHintsAwake.sunstoneClueText.SetMessage(new MessageDescriptor(GetKeyLabel(Keys.MountHoru, 2, Randomiser.Inventory.sunstoneShards)));

InventoryManager.Instance.CompletionText.SetMessage(new MessageDescriptor(GetCompletionText()));
}

private static string GetKeyLabel(bool ownsKey, int key, int shardCount)
Expand Down Expand Up @@ -70,5 +77,26 @@ private static Clues.Clue ClueForKey(int key)
default: return default;
}
}

private static string GetCompletionText()
{
switch (Randomiser.Seed.GoalMode)
{
case GoalMode.ForceTrees:
return $"{Randomiser.TreesFound}/10";
case GoalMode.WorldTour:
return $"{Randomiser.RelicsFound}/{Randomiser.Seed.RelicsRequired}";
}

return "";
}
}

public class CompletionDescriptionMessageProvider : MessageProvider
{
public override IEnumerable<MessageDescriptor> GetMessages()
{
return new MessageDescriptor[] { new MessageDescriptor(DynamicText.BuildDetailedGoalString()) };
}
}
}
12 changes: 12 additions & 0 deletions Randomiser/strings/English.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ AREA_SHORT_Glades=Glades
AREA_SHORT_Swamp=Swamp
AREA_SHORT_Valley=Valley

LOCATION_WallJumpSkillTree=Wall Jump
LOCATION_ChargeFlameSkillTree=Charge Flame
LOCATION_DashSkillTree=Dash
LOCATION_GrenadeSkillTree=Grenade
LOCATION_DoubleJumpSkillTree=Double Jump
LOCATION_BashSkillTree=Bash
LOCATION_StompSkillTree=Stomp
LOCATION_GlideSkillFeather=Glide
LOCATION_ChargeJumpSkillTree=Charge Jump
LOCATION_ClimbSkillTree=Climb

# Rando strings
RANDO_PROGRESS_1={0}Trees ({1}/10){0} {2}Maps ({3}/9){2} Total ({4}/256)
RANDO_PROGRESS_WORLDTOUR={0}Trees ({1}/10){0} {2}Maps ({3}/9){2} Total ({4}/256) {5}Relics ({6}/{7}){5}
Expand All @@ -84,6 +95,7 @@ OBJECTIVE_FORCE_MAPS=Restore all 9 #Mapstones#
OBJECTIVE_WARMTH_FRAGS=Find all {0} #Warmth Fragments# hidden throughout Nibel
OBJECTIVE_FALLBACK=Continue to search for #Skills# and #Resources#
OBJECTIVE_RELICS_FOUND_TEXT=Relics found:
OBJECTIVE_TREES_FOUND_TEXT=Trees found:

ABILITY_ExtraDoubleJump=Extra Jump
ABILITY_DESC_ExtraDoubleJump=Allows Ori to jump more times in the air
Expand Down

0 comments on commit f19754d

Please sign in to comment.