mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Use Custom Ship Log Modes utility mod (#411)
## Improvements - Use the new [Custom Ship Log Modes](https://github.com/dgarroDC/CustomShipLogModes) utility mod to add the Interstellar Mode for better compatibility and functionality with other mods adding modes. ## Bug fixes - Fixed Interstellar Mode not selectable when Rumor Mode was disabled by the user The mod isn't in the database yet (https://github.com/ow-mods/ow-mod-db/pull/445) so don't merge this PR yet!
This commit is contained in:
commit
6210f2e594
@ -21,10 +21,8 @@ namespace NewHorizons.Components.ShipLog
|
||||
private Vector2 _panRootPos = Vector2.zero;
|
||||
private Vector2 _startPanPos;
|
||||
|
||||
private ScreenPromptList _upperRightPromptList;
|
||||
private ScreenPromptList _centerPromptList;
|
||||
|
||||
private ScreenPrompt _detectiveModePrompt;
|
||||
private ScreenPrompt _targetSystemPrompt;
|
||||
private ScreenPrompt _warpPrompt = new ScreenPrompt(InputLibrary.autopilot, "<CMD> Warp to system");
|
||||
|
||||
@ -45,9 +43,7 @@ namespace NewHorizons.Components.ShipLog
|
||||
_oneShotSource = oneShotSource;
|
||||
|
||||
_centerPromptList = centerPromptList;
|
||||
_upperRightPromptList = upperRightPromptList;
|
||||
|
||||
_detectiveModePrompt = new ScreenPrompt(InputLibrary.swapShipLogMode, UITextLibrary.GetString(UITextType.LogRumorModePrompt), 0, ScreenPrompt.DisplayState.Normal, false);
|
||||
_targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, TranslationHandler.GetTranslation("LOCK_AUTOPILOT_WARP", TranslationHandler.TextType.UI), 0, ScreenPrompt.DisplayState.Normal, false);
|
||||
|
||||
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
||||
@ -166,7 +162,7 @@ namespace NewHorizons.Components.ShipLog
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
||||
Locator.GetPromptManager().AddScreenPrompt(_detectiveModePrompt, _upperRightPromptList, TextAnchor.MiddleRight, -1, true);
|
||||
_oneShotSource.PlayOneShot(AudioType.ShipLogEnterMapMode);
|
||||
Locator.GetPromptManager().AddScreenPrompt(_targetSystemPrompt, _centerPromptList, TextAnchor.MiddleCenter, -1, true);
|
||||
}
|
||||
|
||||
@ -174,7 +170,6 @@ namespace NewHorizons.Components.ShipLog
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
|
||||
Locator.GetPromptManager().RemoveScreenPrompt(_detectiveModePrompt);
|
||||
Locator.GetPromptManager().RemoveScreenPrompt(_targetSystemPrompt);
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using NewHorizons.Components.ShipLog;
|
||||
using NewHorizons.Utility;
|
||||
using System.Collections.Generic;
|
||||
using NewHorizons.OtherMods.CustomShipLogModes;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
namespace NewHorizons.Handlers
|
||||
@ -45,14 +46,7 @@ namespace NewHorizons.Handlers
|
||||
panRoot.transform.localPosition = Vector3.zero;
|
||||
panRoot.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||
|
||||
var centerPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_Center")?.GetComponent<ScreenPromptList>();
|
||||
var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent<ScreenPromptList>();
|
||||
var oneShotSource = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>();
|
||||
|
||||
ShipLogStarChartMode.Initialize(
|
||||
centerPromptList,
|
||||
upperRightPromptList,
|
||||
oneShotSource);
|
||||
CustomShipLogModesHandler.AddInterstellarMode();
|
||||
}
|
||||
|
||||
_starSystemToFactID = new Dictionary<string, string>();
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
using NewHorizons.Handlers;
|
||||
|
||||
namespace NewHorizons.OtherMods.CustomShipLogModes;
|
||||
|
||||
public static class CustomShipLogModesHandler
|
||||
{
|
||||
private static readonly ICustomShipLogModesAPI API;
|
||||
|
||||
static CustomShipLogModesHandler()
|
||||
{
|
||||
API = Main.Instance.ModHelper.Interaction.TryGetModApi<ICustomShipLogModesAPI>("dgarro.CustomShipLogModes");
|
||||
}
|
||||
|
||||
public static void AddInterstellarMode()
|
||||
{
|
||||
API.AddMode(StarChartHandler.ShipLogStarChartMode,
|
||||
() => Main.HasWarpDrive,
|
||||
() => TranslationHandler.GetTranslation("INTERSTELLAR_MODE", TranslationHandler.TextType.UI));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace NewHorizons.OtherMods.CustomShipLogModes;
|
||||
|
||||
public interface ICustomShipLogModesAPI
|
||||
{
|
||||
public void AddMode(ShipLogMode mode, Func<bool> isEnabledSupplier, Func<string> nameSupplier);
|
||||
}
|
||||
@ -7,18 +7,6 @@ namespace NewHorizons.Patches
|
||||
[HarmonyPatch]
|
||||
public static class WarpDrivePatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ShipLogMapMode), nameof(ShipLogMapMode.EnterMode))]
|
||||
public static void ShipLogMapMode_EnterMode(ShipLogMapMode __instance)
|
||||
{
|
||||
if (!Main.HasWarpDrive) return;
|
||||
|
||||
var newPrompt = TranslationHandler.GetTranslation("INTERSTELLAR_MODE", TranslationHandler.TextType.UI);
|
||||
__instance._detectiveModePrompt.SetText(newPrompt);
|
||||
var text = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/ScreenPromptListScaleRoot/ScreenPromptList_UpperRight/ScreenPrompt/Text").GetComponent<UnityEngine.UI.Text>();
|
||||
text.text = newPrompt;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ShipCockpitController), nameof(ShipCockpitController.Update))]
|
||||
public static bool ShipCockpitController_Update(ShipCockpitController __instance)
|
||||
@ -37,42 +25,5 @@ namespace NewHorizons.Patches
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ShipLogController), nameof(ShipLogController.Update))]
|
||||
public static bool ShipLogController_Update(ShipLogController __instance)
|
||||
{
|
||||
if (!Main.HasWarpDrive) return true;
|
||||
|
||||
if (__instance._exiting
|
||||
|| OWInput.GetInputMode() != InputMode.ShipComputer
|
||||
|| __instance._currentMode.AllowCancelInput() && OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.All)
|
||||
|| StarChartHandler.ShipLogStarChartMode == null)
|
||||
return true;
|
||||
|
||||
// Mostly copied from the base method but we're trying to fit in our new mode
|
||||
__instance._exitPrompt.SetVisibility(__instance._currentMode.AllowCancelInput());
|
||||
__instance._currentMode.UpdateMode();
|
||||
if (__instance._currentMode.AllowModeSwap() && OWInput.IsNewlyPressed(InputLibrary.swapShipLogMode, InputMode.All))
|
||||
{
|
||||
ShipLogMode currentMode = __instance._currentMode;
|
||||
string focusedEntryID = currentMode.GetFocusedEntryID();
|
||||
if (!focusedEntryID.Equals("")) return true;
|
||||
bool flag = currentMode.Equals(__instance._mapMode);
|
||||
__instance._currentMode = (flag ? __instance._detectiveMode : __instance._mapMode);
|
||||
|
||||
if (currentMode.Equals(__instance._mapMode))
|
||||
__instance._currentMode = StarChartHandler.ShipLogStarChartMode;
|
||||
else if (currentMode.Equals(StarChartHandler.ShipLogStarChartMode))
|
||||
__instance._currentMode = __instance._detectiveMode;
|
||||
else
|
||||
__instance._currentMode = __instance._mapMode;
|
||||
|
||||
currentMode.ExitMode();
|
||||
__instance._currentMode.EnterMode(focusedEntryID, null);
|
||||
__instance._oneShotSource.PlayOneShot(flag ? global::AudioType.ShipLogEnterDetectiveMode : global::AudioType.ShipLogEnterMapMode, 1f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
"uniqueName": "xen.NewHorizons",
|
||||
"version": "1.6.2",
|
||||
"owmlVersion": "2.7.2",
|
||||
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility" ],
|
||||
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
|
||||
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ],
|
||||
"pathsToPreserve": [ "planets", "systems", "translations" ]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user