mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add screen prompts for debug mode (#352)
This commit is contained in:
commit
073892c008
@ -16,7 +16,12 @@
|
|||||||
"RICH_PRESENCE_EXPLORING": "Exploring {0}.",
|
"RICH_PRESENCE_EXPLORING": "Exploring {0}.",
|
||||||
"RICH_PRESENCE_WARPING": "Warping to {0}.",
|
"RICH_PRESENCE_WARPING": "Warping to {0}.",
|
||||||
"OUTDATED_VERSION_WARNING": "WARNING\n\nNew Horizons only works on version {0} or higher. You're on version {1}.\n\nPlease update your game or uninstall NH.",
|
"OUTDATED_VERSION_WARNING": "WARNING\n\nNew Horizons only works on version {0} or higher. You're on version {1}.\n\nPlease update your game or uninstall NH.",
|
||||||
"JSON_FAILED_TO_LOAD": "Invalid file(s): {0}"
|
"JSON_FAILED_TO_LOAD": "Invalid file(s): {0}",
|
||||||
|
"DEBUG_RAYCAST": "Raycast",
|
||||||
|
"DEBUG_PLACE": "Place Object",
|
||||||
|
"DEBUG_PLACE_TEXT": "Place Nomai Text",
|
||||||
|
"DEBUG_UNDO": "Undo",
|
||||||
|
"DEBUG_REDO": "Redo"
|
||||||
},
|
},
|
||||||
"AchievementTranslations": {
|
"AchievementTranslations": {
|
||||||
"NH_EATEN_OUTSIDE_BRAMBLE": {
|
"NH_EATEN_OUTSIDE_BRAMBLE": {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using NewHorizons.Handlers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -15,13 +16,24 @@ namespace NewHorizons.Utility.DebugUtilities
|
|||||||
|
|
||||||
private DebugRaycaster _rc;
|
private DebugRaycaster _rc;
|
||||||
|
|
||||||
|
private ScreenPrompt _placePrompt;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_rc = this.GetComponent<DebugRaycaster>();
|
_rc = this.GetComponent<DebugRaycaster>();
|
||||||
|
|
||||||
|
_placePrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_PLACE_TEXT", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.G));
|
||||||
|
Locator.GetPromptManager().AddScreenPrompt(_placePrompt, PromptPosition.UpperRight, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
|
Locator.GetPromptManager()?.RemoveScreenPrompt(_placePrompt, PromptPosition.UpperRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
UpdatePromptVisibility();
|
||||||
if (!Main.Debug) return;
|
if (!Main.Debug) return;
|
||||||
if (!active) return;
|
if (!active) return;
|
||||||
|
|
||||||
@ -31,5 +43,10 @@ namespace NewHorizons.Utility.DebugUtilities
|
|||||||
if (onRaycast != null) onRaycast.Invoke(data);
|
if (onRaycast != null) onRaycast.Invoke(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdatePromptVisibility()
|
||||||
|
{
|
||||||
|
_placePrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug && active);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using NewHorizons.Builder.Props;
|
using NewHorizons.Builder.Props;
|
||||||
using NewHorizons.External.Configs;
|
using NewHorizons.External.Configs;
|
||||||
using NewHorizons.External.Modules;
|
using NewHorizons.External.Modules;
|
||||||
|
using NewHorizons.Handlers;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -39,14 +40,36 @@ namespace NewHorizons.Utility.DebugUtilities
|
|||||||
public GameObject mostRecentlyPlacedPropGO { get { return props.Count() <= 0 ? null : props[props.Count() - 1].gameObject; } }
|
public GameObject mostRecentlyPlacedPropGO { get { return props.Count() <= 0 ? null : props[props.Count() - 1].gameObject; } }
|
||||||
public string mostRecentlyPlacedPropPath { get { return props.Count() <= 0 ? "" : props[props.Count() - 1].detailInfo.path; } }
|
public string mostRecentlyPlacedPropPath { get { return props.Count() <= 0 ? "" : props[props.Count() - 1].detailInfo.path; } }
|
||||||
|
|
||||||
|
private ScreenPrompt _placePrompt;
|
||||||
|
private ScreenPrompt _undoPrompt;
|
||||||
|
private ScreenPrompt _redoPrompt;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_rc = this.GetRequiredComponent<DebugRaycaster>();
|
_rc = this.GetRequiredComponent<DebugRaycaster>();
|
||||||
currentObject = DEFAULT_OBJECT;
|
currentObject = DEFAULT_OBJECT;
|
||||||
|
|
||||||
|
_placePrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_PLACE", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.G));
|
||||||
|
_undoPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_UNDO", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.Minus));
|
||||||
|
_redoPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_REDO", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.Equals));
|
||||||
|
|
||||||
|
Locator.GetPromptManager().AddScreenPrompt(_placePrompt, PromptPosition.UpperRight, false);
|
||||||
|
Locator.GetPromptManager().AddScreenPrompt(_undoPrompt, PromptPosition.UpperRight, false);
|
||||||
|
Locator.GetPromptManager().AddScreenPrompt(_redoPrompt, PromptPosition.UpperRight, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
var promptManager = Locator.GetPromptManager();
|
||||||
|
if (promptManager == null) return;
|
||||||
|
promptManager.RemoveScreenPrompt(_placePrompt, PromptPosition.UpperRight);
|
||||||
|
promptManager.RemoveScreenPrompt(_undoPrompt, PromptPosition.UpperRight);
|
||||||
|
promptManager.RemoveScreenPrompt(_redoPrompt, PromptPosition.UpperRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
|
UpdatePromptVisibility();
|
||||||
if (!Main.Debug) return;
|
if (!Main.Debug) return;
|
||||||
if (!active) return;
|
if (!active) return;
|
||||||
|
|
||||||
@ -66,6 +89,14 @@ namespace NewHorizons.Utility.DebugUtilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdatePromptVisibility()
|
||||||
|
{
|
||||||
|
var visible = !OWTime.IsPaused() && Main.Debug && active;
|
||||||
|
_placePrompt.SetVisibility(visible);
|
||||||
|
_undoPrompt.SetVisibility(visible && props.Count > 0);
|
||||||
|
_redoPrompt.SetVisibility(visible && deletedProps.Count > 0);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetCurrentObject(string s)
|
public void SetCurrentObject(string s)
|
||||||
{
|
{
|
||||||
currentObject = s;
|
currentObject = s;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using NewHorizons.Components.Orbital;
|
using NewHorizons.Handlers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
@ -17,15 +17,25 @@ namespace NewHorizons.Utility.DebugUtilities
|
|||||||
private GameObject _planeDownRightSphere;
|
private GameObject _planeDownRightSphere;
|
||||||
private GameObject _planeDownLeftSphere;
|
private GameObject _planeDownLeftSphere;
|
||||||
|
|
||||||
|
private ScreenPrompt _raycastPrompt;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_rb = this.GetRequiredComponent<OWRigidbody>();
|
_rb = this.GetRequiredComponent<OWRigidbody>();
|
||||||
|
|
||||||
|
_raycastPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_RAYCAST", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.P));
|
||||||
|
|
||||||
|
Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
Locator.GetPromptManager()?.RemoveScreenPrompt(_raycastPrompt, PromptPosition.UpperRight);
|
||||||
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
|
UpdatePromptVisibility();
|
||||||
if (!Main.Debug) return;
|
if (!Main.Debug) return;
|
||||||
if (Keyboard.current == null) return;
|
if (Keyboard.current == null) return;
|
||||||
|
|
||||||
@ -36,6 +46,11 @@ namespace NewHorizons.Utility.DebugUtilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void UpdatePromptVisibility()
|
||||||
|
{
|
||||||
|
_raycastPrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
internal void PrintRaycast()
|
internal void PrintRaycast()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -352,6 +352,15 @@ namespace NewHorizons.Utility
|
|||||||
return newTexture;
|
return newTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Sprite GetButtonSprite(JoystickButton button) => GetButtonSprite(ButtonPromptLibrary.SharedInstance.GetButtonTexture(button));
|
||||||
|
public static Sprite GetButtonSprite(KeyCode key) => GetButtonSprite(ButtonPromptLibrary.SharedInstance.GetButtonTexture(key));
|
||||||
|
private static Sprite GetButtonSprite(Texture2D texture)
|
||||||
|
{
|
||||||
|
var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100, 0, SpriteMeshType.FullRect, Vector4.zero, false);
|
||||||
|
sprite.name = texture.name;
|
||||||
|
return sprite;
|
||||||
|
}
|
||||||
|
|
||||||
// Modified from https://stackoverflow.com/a/69141085/9643841
|
// Modified from https://stackoverflow.com/a/69141085/9643841
|
||||||
public class AsyncImageLoader : MonoBehaviour
|
public class AsyncImageLoader : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user