fix: fixed config saving interacting poorly with alignToNormal, pause menu button should now hide on debug false

This commit is contained in:
FreezeDriedMangoes 2022-05-22 08:55:34 -04:00
parent d3f9a35cba
commit e7168e4d74
3 changed files with 20 additions and 5 deletions

View File

@ -73,6 +73,7 @@ namespace NewHorizons
Debug = config.GetSettingsValue<bool>("Debug");
DebugReload.UpdateReloadButton();
DebugMenu.UpdatePauseMenuButton();
Logger.UpdateLogLevel(Debug ? Logger.LogType.Log : Logger.LogType.Error);
_defaultSystemOverride = config.GetSettingsValue<string>("Default System Override");

View File

@ -1,6 +1,7 @@
using NewHorizons.External;
using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.Handlers;
using Newtonsoft.Json;
using OWML.Common;
using OWML.Common.Menus;
@ -43,7 +44,6 @@ namespace NewHorizons.Utility.DebugUtilities
public static readonly char separatorCharacter = '☧'; // since no chars are illegal in game object names, I picked one that's extremely unlikely to be used to be a separator
private static readonly string favoritePropsPlayerPrefKey = "FavoriteProps";
//private string workingModName = "";
private static IModBehaviour loadedMod = null;
private Dictionary<string, PlanetConfig> loadedConfigFiles = new Dictionary<string, PlanetConfig>();
private bool saveButtonUnlocked = false;
@ -65,7 +65,6 @@ namespace NewHorizons.Utility.DebugUtilities
private void Start()
{
if (!Main.Debug) return;
if (!staticInitialized)
{
staticInitialized = true;
@ -91,9 +90,17 @@ namespace NewHorizons.Utility.DebugUtilities
private void PauseMenuInitHook()
{
pauseMenuButton = Main.Instance.ModHelper.Menus.PauseMenu.OptionsButton.Duplicate("Toggle Prop Placer Menu".ToUpper());
pauseMenuButton = Main.Instance.ModHelper.Menus.PauseMenu.OptionsButton.Duplicate(TranslationHandler.GetTranslation("Toggle Prop Placer Menu", TranslationHandler.TextType.UI).ToUpper());
InitMenu();
}
public static void UpdatePauseMenuButton()
{
if (pauseMenuButton != null)
{
if (Main.Debug) pauseMenuButton.Show();
else pauseMenuButton.Hide();
}
}
private void RestoreMenuOpennessState() { menuOpen = openMenuOnPause; }
private void ToggleMenu() { menuOpen = !menuOpen; openMenuOnPause = !openMenuOnPause; }
@ -324,6 +331,8 @@ namespace NewHorizons.Utility.DebugUtilities
{
if (_editorMenuStyle != null) return;
UpdatePauseMenuButton();
// TODO: figure out how to clear this event list so that we don't pile up useless instances of the DebugMenu that can't get garbage collected
pauseMenuButton.OnClick += ToggleMenu;

View File

@ -12,6 +12,10 @@ using static NewHorizons.External.Modules.PropModule;
namespace NewHorizons.Utility.DebugUtilities
{
//
// The prop placer. Doesn't interact with any files, just places and tracks props.
//
[RequireComponent(typeof(DebugRaycaster))]
class DebugPropPlacer : MonoBehaviour
{
@ -23,9 +27,10 @@ namespace NewHorizons.Utility.DebugUtilities
public DetailInfo detailInfo;
}
// VASE
public static readonly string DEFAULT_OBJECT = "BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District1/Props_HangingCity_District1/OtherComponentsGroup/Props_HangingCity_Building_10/Prefab_NOM_VaseThin";
public string currentObject { get; private set; }
public string currentObject { get; private set; } // path of the prop to be placed
private bool hasAddedCurrentObjectToRecentsList = false;
private List<PropPlacementData> props = new List<PropPlacementData>();
private List<PropPlacementData> deletedProps = new List<PropPlacementData>();
@ -230,8 +235,8 @@ namespace NewHorizons.Utility.DebugUtilities
for(int i = 0; i < bodyProps.Count; i++)
{
bodyProps[i].detailInfo.position = bodyProps[i].gameObject.transform.localPosition;
bodyProps[i].detailInfo.rotation = bodyProps[i].gameObject.transform.localEulerAngles;
bodyProps[i].detailInfo.scale = bodyProps[i].gameObject.transform.localScale.x;
if (!bodyProps[i].detailInfo.alignToNormal) bodyProps[i].detailInfo.rotation = bodyProps[i].gameObject.transform.localEulerAngles;
infoArray[i] = bodyProps[i].detailInfo;
}