Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.19.0 #795

Merged
merged 26 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ccd3e29
Keys are now much more forgiving (ignores whitespace casing why not)
xen-42 Mar 8, 2024
9191dc2
Update TranslationHandler.cs
xen-42 Mar 8, 2024
057554a
Translation fixes for Astral Codec (#794)
xen-42 Mar 8, 2024
641084a
Add shipLogStartingPlanetID to star system config
Bwc9876 Mar 9, 2024
a5a068d
fix compile error
JohnCorby Mar 9, 2024
8946ce3
Updated Schemas
Bwc9876 Mar 9, 2024
9f69964
Add shipLogStartingPlanetID to Star System Config (#798)
JohnCorby Mar 9, 2024
159ffbb
Add secret page docs
Bwc9876 Mar 9, 2024
e3ecb55
RigidbodyPatches - Don't run when QSB is installed
misternebula Mar 10, 2024
0036028
Don't run rigidbody patches when QSB is installed. (#800)
JohnCorby Mar 10, 2024
e8b0bf4
Check for null refs inside streaming warp volume then destroy it
xen-42 Mar 11, 2024
c21fd90
Fix ocean fog
xen-42 Mar 12, 2024
1c11c49
Destroy whole game object
xen-42 Mar 12, 2024
717047b
Fix ocean fog (#803)
xen-42 Mar 12, 2024
13b28fa
Dont add timeloopcontroller to base system
xen-42 Mar 12, 2024
b5ec327
Track new fog warp volumes and only patch those
xen-42 Mar 12, 2024
7bfe3d2
Remove unused volume
xen-42 Mar 12, 2024
b1b7f43
Fix bramble seeds being the wrong size
xen-42 Mar 12, 2024
c615902
Subtitles can now be larger, added subtitle to api (outsider compat)
xen-42 Mar 12, 2024
90c3b9b
Fix subtitle breaking when theres only one
xen-42 Mar 12, 2024
b00aaa6
Dont add timeloopcontroller to base system (#804)
xen-42 Mar 12, 2024
80e9e34
Check for null refs inside streaming warp volume then destroy it (#802)
xen-42 Mar 12, 2024
4997b91
Just return true
xen-42 Mar 12, 2024
61a3717
Fixes for Outsider (#805)
xen-42 Mar 13, 2024
00b3965
Update manifest.json
xen-42 Mar 13, 2024
b0e9437
Merge branch 'dev' of https://github.com/Outer-Wilds-New-Horizons/new…
xen-42 Mar 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NewHorizons/Builder/Body/WaterBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigid
var fogGO = Object.Instantiate(_oceanFog, waterGO.transform);
fogGO.name = "OceanFog";
fogGO.transform.localPosition = Vector3.zero;
fogGO.transform.localScale = Vector3.one;
// In base game GD ocean fog is 550 while the water volume is 500
fogGO.transform.localScale = Vector3.one * 550f / 500f;
fogGO.SetActive(true);

if (module.tint != null)
Expand Down
17 changes: 17 additions & 0 deletions NewHorizons/Builder/Props/BrambleNodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ public static class BrambleNodeBuilder
private static GameObject _brambleSeedPrefab;
private static GameObject _brambleNodePrefab;

private static HashSet<FogWarpVolume> _nhFogWarpVolumes = new();

public static bool IsNHFogWarpVolume(FogWarpVolume volume) => _nhFogWarpVolumes.Contains(volume);

public static void Init(PlanetConfig[] dimensionConfigs)
{
_unpairedNodes.Clear();
_propagatedSignals.Clear();
namedNodes.Clear();
builtBrambleNodes.Clear();
_nhFogWarpVolumes.Clear();

PropagateSignals(dimensionConfigs);
}
Expand Down Expand Up @@ -190,6 +195,12 @@ public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo conf
collider.enabled = true;
}

// We track all the fog warp volumes that NH created so we can only effect those in patches, this way we leave base game stuff alone.
foreach (var fogWarpVolume in brambleNode.GetComponentsInChildren<FogWarpVolume>(true).Append(brambleNode.GetComponent<FogWarpVolume>()))
{
_nhFogWarpVolumes.Add(fogWarpVolume);
}

var innerFogWarpVolume = brambleNode.GetComponent<InnerFogWarpVolume>();
var outerFogWarpVolume = GetOuterFogWarpVolumeFromAstroObject(go);
var fogLight = brambleNode.GetComponent<FogLight>();
Expand Down Expand Up @@ -239,6 +250,12 @@ public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo conf
foreach(Transform child in brambleNode.transform)
{
child.localScale = Vector3.one * config.scale;

// The fog on bramble seeds has a specific scale we need to copy over
if (child.name == "VolumetricFogSphere (2)")
{
child.localScale *= 6.3809f;
}
}
innerFogWarpVolume._warpRadius *= config.scale;
innerFogWarpVolume._exitRadius *= config.scale;
Expand Down
3 changes: 3 additions & 0 deletions NewHorizons/Components/TimeLoopController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public void Start()

public void Update()
{
// So that mods can turn the time loop on/off using the TimLoop.SetTimeLoopEnabled method
if (!TimeLoop._timeLoopEnabled) return;

// Stock gives like 33 seconds after the sun collapses
if (_supernovaHappened && Time.time > _supernovaTime + 50f)
{
Expand Down
8 changes: 0 additions & 8 deletions NewHorizons/Components/Volumes/NHInnerFogWarpVolume.cs

This file was deleted.

18 changes: 18 additions & 0 deletions NewHorizons/Components/Volumes/StreamingWarpVolume.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using NewHorizons.Utility.OWML;
using UnityEngine;

namespace NewHorizons.Components.Volumes
Expand All @@ -23,6 +24,23 @@ public void Start()

public void FixedUpdate()
{
// Bug report on Astral Codec mod page - Huge lag inside streaming warp volume, possible NRE?
if (_probe == null)
{
_probe = Locator.GetProbe();
if (_probe == null)
{
NHLogger.LogError($"How is your scout probe null? Destroying {nameof(StreamingWarpVolume)}");
GameObject.DestroyImmediate(gameObject);
}
}

if (streamingGroup == null)
{
NHLogger.LogError($"{nameof(StreamingWarpVolume)} has no streaming group. Destroying {nameof(StreamingWarpVolume)}");
GameObject.DestroyImmediate(gameObject);
}

bool probeActive = _probe.IsLaunched() && !_probe.IsAnchored();

bool shouldBeLoadingRequiredAssets = _playerInVolume || (_probeInVolume && probeActive);
Expand Down
5 changes: 5 additions & 0 deletions NewHorizons/External/Configs/StarSystemConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public class StarSystemConfig
/// </summary>
public string[] initialReveal;

/// <summary>
/// The planet to focus on when entering the ship log for the first time in a loop. If not set this will be the planet at navtigation position (1, 0)
/// </summary>
public string shipLogStartingPlanetID;

/// <summary>
/// List colors of curiosity entries
/// </summary>
Expand Down
77 changes: 57 additions & 20 deletions NewHorizons/Handlers/SubtitlesHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class SubtitlesHandler : MonoBehaviour
public static int SUBTITLE_HEIGHT = 97;
public static int SUBTITLE_WIDTH = 669; // nice

public Graphic graphic;
public Image image;

public float fadeSpeed = 0.005f;
public float fade = 1;
public bool fadingAway = true;
Expand All @@ -29,32 +26,53 @@ class SubtitlesHandler : MonoBehaviour
public static readonly int PAUSE_TIMER_MAX = 50;
public int pauseTimer = PAUSE_TIMER_MAX;

private Image _subtitleDisplay;
private Graphic _graphic;

private static List<(IModBehaviour mod, string filePath)> _additionalSubtitles = new();

public static void RegisterAdditionalSubtitle(IModBehaviour mod, string filePath)
{
_additionalSubtitles.Add((mod, filePath));
}

public void CheckForEOTE()
{
if (!eoteSubtitleHasBeenInserted)
{
if (Main.HasDLC)
{
if (eoteSprite != null) possibleSubtitles.Insert(0, eoteSprite); // ensure that the Echoes of the Eye subtitle always appears first
if (eoteSprite != null)
{
// Don't make it appear first actually because we have mods to display!
possibleSubtitles.Add(eoteSprite);
}
eoteSubtitleHasBeenInserted = true;
}
}
}

public void Start()
{
// We preserve the current image to add it to our custom subtitle
// We also need this element to preserve its size
GetComponent<CanvasGroup>().alpha = 1;
graphic = GetComponent<Graphic>();
image = GetComponent<UnityEngine.UI.Image>();

graphic.enabled = true;
image.enabled = true;

var image = GetComponent<Image>();
eoteSprite = image.sprite;
image.sprite = null;
image.enabled = false;
var layout = GetComponent<LayoutElement>();
layout.minHeight = SUBTITLE_HEIGHT;

CheckForEOTE();

image.sprite = null; // Just in case. I don't know how not having the dlc changes the subtitle game object
// We add our subtitles as a child object so that their sizing doesnt shift the layout of the main menu
_subtitleDisplay = new GameObject().AddComponent<Image>();
_subtitleDisplay.transform.parent = transform;
_subtitleDisplay.transform.localPosition = new Vector3(0, 0, 0);
_subtitleDisplay.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
_graphic = _subtitleDisplay.gameObject.GetAddComponent<Graphic>();
_subtitleDisplay.gameObject.GetAddComponent<LayoutElement>().minWidth = SUBTITLE_WIDTH;

AddSubtitles();
}
Expand All @@ -73,6 +91,10 @@ private void AddSubtitles()
AddSubtitle(mod, "subtitle.png");
}
}
foreach (var pair in _additionalSubtitles)
{
AddSubtitle(pair.mod, pair.filePath);
}
}

public void AddSubtitle(IModBehaviour mod, string filepath)
Expand All @@ -82,7 +104,7 @@ public void AddSubtitle(IModBehaviour mod, string filepath)
var tex = ImageUtilities.GetTexture(mod, filepath, false);
if (tex == null) return;

var sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, SUBTITLE_HEIGHT), new Vector2(0.5f, 0.5f), 100.0f);
var sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, Mathf.Max(SUBTITLE_HEIGHT, tex.height)), new Vector2(0.5f, 0.5f), 100.0f);
AddSubtitle(sprite);
}

Expand All @@ -95,12 +117,25 @@ public void FixedUpdate()
{
CheckForEOTE();

if (possibleSubtitles.Count == 0) return;
if (possibleSubtitles.Count == 0)
{
return;
}

_subtitleDisplay.transform.localPosition = new Vector3(0, -36, 0);

if (image.sprite == null) image.sprite = possibleSubtitles[0];
if (_subtitleDisplay.sprite == null)
{
_subtitleDisplay.sprite = possibleSubtitles[0];
// Always call this in case we stop changing subtitles after
ChangeSubtitle();
}

// don't fade transition subtitles if there's only one subtitle
if (possibleSubtitles.Count <= 1) return;
if (possibleSubtitles.Count <= 1)
{
return;
}

if (pauseTimer > 0)
{
Expand All @@ -111,7 +146,7 @@ public void FixedUpdate()
if (fadingAway)
{
fade -= fadeSpeed;

if (fade <= 0)
{
fade = 0;
Expand All @@ -122,7 +157,7 @@ public void FixedUpdate()
else
{
fade += fadeSpeed;

if (fade >= 1)
{
fade = 1;
Expand All @@ -131,14 +166,16 @@ public void FixedUpdate()
}
}

graphic.color = new Color(1, 1, 1, fade);
_graphic.color = new Color(1, 1, 1, fade);
}

public void ChangeSubtitle()
{
subtitleIndex = (subtitleIndex + 1) % possibleSubtitles.Count;

image.sprite = possibleSubtitles[subtitleIndex];

_subtitleDisplay.sprite = possibleSubtitles[subtitleIndex];
var ratio = SUBTITLE_WIDTH / _subtitleDisplay.sprite.texture.width;
_subtitleDisplay.rectTransform.sizeDelta = new Vector2(_subtitleDisplay.sprite.texture.width, _subtitleDisplay.sprite.texture.height) * ratio;
}
}
}
3 changes: 2 additions & 1 deletion NewHorizons/Handlers/SystemCreationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public static void LoadSystem(NewHorizonsSystem system)
if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") return;

// Small mod compat change for StopTime - do nothing if it's enabled
if (system.Config.enableTimeLoop && !OtherModUtil.IsEnabled("_nebula.StopTime"))
// Do not add our custom time loop controller in the base game system: It will handle itself
if (Main.Instance.CurrentStarSystem != "SolarSystem" && system.Config.enableTimeLoop && !OtherModUtil.IsEnabled("_nebula.StopTime"))
{
var timeLoopController = new GameObject("TimeLoopController");
timeLoopController.AddComponent<TimeLoopController>();
Expand Down
18 changes: 16 additions & 2 deletions NewHorizons/Handlers/TranslationHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using NewHorizons.External.Configs;
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace NewHorizons.Handlers
{
Expand Down Expand Up @@ -49,8 +51,17 @@ public static string GetTranslation(string text, TextType type, bool warn)

// Get the translated text
if (dictionary.TryGetValue(language, out var table))
{
if (table.TryGetValue(text, out var translatedText))
{
return translatedText;
}
// Try without whitespace if its missing
else if (table.TryGetValue(text.TruncateWhitespace(), out translatedText))
{
return translatedText;
}
}

if (warn) NHLogger.LogVerbose($"Defaulting to english for {text}");

Expand Down Expand Up @@ -85,8 +96,11 @@ public static void RegisterTranslation(TextTranslation.Language language, Transl
if (!_dialogueTranslationDictionary.ContainsKey(language)) _dialogueTranslationDictionary.Add(language, new Dictionary<string, string>());
foreach (var originalKey in config.DialogueDictionary.Keys)
{
var key = originalKey.Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
var value = config.DialogueDictionary[originalKey].Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
// Fix new lines in dialogue translations, remove whitespace from keys else if the dialogue has weird whitespace and line breaks it gets really annoying
// to write translation keys for (can't just copy paste out of xml, have to start adding \\n and \\r and stuff
// If any of these issues become relevant to other dictionaries we can bring this code over, but for now why fix what isnt broke
var key = originalKey.Replace("\\n", "\n").TruncateWhitespace().Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
var value = config.DialogueDictionary[originalKey].Replace("\\n", "\n").Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");

if (!_dialogueTranslationDictionary[language].ContainsKey(key)) _dialogueTranslationDictionary[language].Add(key, value);
else _dialogueTranslationDictionary[language][key] = value;
Expand Down
8 changes: 8 additions & 0 deletions NewHorizons/INewHorizons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,13 @@ AudioSignal SpawnSignal(IModBehaviour mod, GameObject root, string audio, string
/// <returns></returns>
string GetTranslationForOtherText(string text);
#endregion

/// <summary>
/// Registers a subtitle for the main menu.
/// Call this once before the main menu finishes loading
/// </summary>
/// <param name="mod"></param>
/// <param name="filePath"></param>
void AddSubtitle(IModBehaviour mod, string filePath);
}
}
2 changes: 2 additions & 0 deletions NewHorizons/NewHorizonsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,7 @@ public void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, st
public string GetTranslationForUI(string text) => TranslationHandler.GetTranslation(text, TranslationHandler.TextType.UI);

public string GetTranslationForOtherText(string text) => TranslationHandler.GetTranslation(text, TranslationHandler.TextType.OTHER);

public void AddSubtitle(IModBehaviour mod, string filePath) => SubtitlesHandler.RegisterAdditionalSubtitle(mod, filePath);
}
}
Loading
Loading