mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Prop placer life support (#455)
<!-- Some improvement that requires no action on the part of add-on creators i.e., improved star graphics --> ## Improvements - The Dev Tools menu now has a "print changes" button, an alternative to the terrifying and buggy "save changes" button
This commit is contained in:
commit
19a4cedb7d
@ -37,8 +37,8 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
// Submenus
|
||||
private List<DebugSubmenu> submenus;
|
||||
private int activeSubmenu = 0;
|
||||
|
||||
private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings
|
||||
|
||||
internal static JsonSerializerSettings jsonSettings = new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore,
|
||||
@ -158,6 +158,12 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
}
|
||||
GUI.enabled = true;
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (GUILayout.Button("Print config changes for your mod"))
|
||||
{
|
||||
PrintLoadedConfigChangesForRecentSystem();
|
||||
saveButtonUnlocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(20);
|
||||
@ -267,6 +273,14 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
}
|
||||
}
|
||||
|
||||
private void PrintLoadedConfigChangesForRecentSystem()
|
||||
{
|
||||
foreach(DebugSubmenu menu in submenus)
|
||||
{
|
||||
menu.PrintNewConfigSection(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitMenu()
|
||||
{
|
||||
if (_editorMenuStyle != null) return;
|
||||
|
||||
@ -521,5 +521,43 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
// metadata.spiral.zRotation = metadata.spiral.zRotation;
|
||||
//});
|
||||
}
|
||||
|
||||
internal override void PrintNewConfigSection(DebugMenu menu)
|
||||
{
|
||||
var conversationsJSON = conversations
|
||||
.GroupBy(conversation => conversation.planetConfig.name)
|
||||
.Select(allConversationsOnBody =>
|
||||
allConversationsOnBody.Key +
|
||||
"\n[" +
|
||||
allConversationsOnBody.Select(conversation =>
|
||||
"\t{\n" +
|
||||
$"\t\t\"position\": {conversation.conversation.position},\n" +
|
||||
$"\t\t\"normal\": {conversation.conversation.normal},\n" +
|
||||
(conversation.conversation.parentPath == default ? "" : $"\t\t\"parentPath\": \"{conversation.conversation.parentPath}\",\n") +
|
||||
(conversation.conversation.location == NomaiTextInfo.NomaiTextLocation.UNSPECIFIED ? "" : $"\t\t\"location\": {conversation.conversation.location},\n") +
|
||||
(conversation.conversation.rotation == default ? "" : $"\t\t\"rotation\": {conversation.conversation.rotation},\n") +
|
||||
(conversation.conversation.rename == default ? "" : $"\t\t\"rename\": \"{conversation.conversation.rename}\",\n") +
|
||||
(conversation.conversation.seed == default ? "" : $"\t\t\"seed\": {conversation.conversation.seed},\n") +
|
||||
(conversation.conversation.type == NomaiTextInfo.NomaiTextType.Wall ? "" : $"\t\t\"type\": \"{conversation.conversation.type}\",\n") +
|
||||
$"\t\t\"xmlFile\": \"{conversation.conversation.xmlFile}\",\n" +
|
||||
"\t\t\"arcInfo\": [\n" +
|
||||
string.Join(",\n", conversation.spirals.Select(spiral =>
|
||||
"\t\t\t{" +
|
||||
$"\"position\": {spiral.spiral.position}, " +
|
||||
$"\"zRotation\": {spiral.spiral.zRotation}, " +
|
||||
(spiral.spiral.mirror == default ? "" : $"\"mirror\": {spiral.spiral.mirror}, ") +
|
||||
(spiral.spiral.type == NomaiTextArcInfo.NomaiTextArcType.Adult ? "" : $"\"type\": \"{spiral.spiral.type}\", ") +
|
||||
(spiral.spiral.variation == -1 ? "" : $"\"variation\": {spiral.spiral.variation}") +
|
||||
"}"
|
||||
)) +
|
||||
"\t\t]"
|
||||
)
|
||||
);
|
||||
|
||||
foreach(string json in conversationsJSON)
|
||||
{
|
||||
Logger.Log(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility.DebugUtilities;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -384,5 +385,14 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
menu.loadedConfigFiles[filepath] = config;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void PrintNewConfigSection(DebugMenu menu)
|
||||
{
|
||||
foreach(var body in _dpp.GetPropsConfigByBody())
|
||||
{
|
||||
var json = string.Join(",\n", body.Value.Select(detail => "\t"+ JsonConvert.SerializeObject(detail, DebugMenu.jsonSettings)));
|
||||
Logger.Log($"{body.Key.name} ({body.Value.Length})\n[\n{json}\n]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,19 +35,22 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
{
|
||||
}
|
||||
|
||||
private string GetEntryPositionsJSON()
|
||||
{
|
||||
return string.Join(",\n",
|
||||
Resources
|
||||
.FindObjectsOfTypeAll<ShipLogEntryCard>()
|
||||
.Select(go =>
|
||||
"{ \"id\": \"" +go.name+ "\", \"position\": {\"x\": "+go.transform.localPosition.x+", \"y\": "+go.transform.localPosition.y+" } "
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
internal override void OnGUI(DebugMenu menu)
|
||||
{
|
||||
if (GUILayout.Button("Print Ship Log Positions"))
|
||||
{
|
||||
entryPositionsText = String.Join("\n",
|
||||
Resources
|
||||
.FindObjectsOfTypeAll<ShipLogEntryCard>()
|
||||
.ToList()
|
||||
.Select(go =>
|
||||
("{ \"id\": \"" +go.name+ "\", \"position\": {\"x\": "+go.transform.localPosition.x+", \"y\": "+go.transform.localPosition.y+" } ")
|
||||
)
|
||||
.ToList()
|
||||
);
|
||||
entryPositionsText = GetEntryPositionsJSON();
|
||||
}
|
||||
|
||||
GUILayout.TextArea(entryPositionsText);
|
||||
@ -67,5 +70,10 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
{
|
||||
return "Ship Log";
|
||||
}
|
||||
|
||||
internal override void PrintNewConfigSection(DebugMenu menu)
|
||||
{
|
||||
Logger.Log(GetEntryPositionsJSON());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
{
|
||||
internal abstract void OnAwake(DebugMenu menu);
|
||||
internal abstract void OnGUI(DebugMenu menu);
|
||||
internal abstract void PrintNewConfigSection(DebugMenu menu);
|
||||
internal abstract void PreSave(DebugMenu menu);
|
||||
internal abstract void OnInit(DebugMenu menu);
|
||||
internal abstract void LoadConfigFile(DebugMenu menu, PlanetConfig config);
|
||||
@ -21,6 +22,5 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
internal abstract void GainActive();
|
||||
internal abstract void LoseActive();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,6 +108,9 @@ namespace NewHorizons.Utility.DebugUtilities
|
||||
DebugRaycastData data = _rc.Raycast();
|
||||
PlaceObject(data);
|
||||
|
||||
//TODO: use DropItem logic to make props not clip through the ground when placed
|
||||
//public virtual void DropItem(Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget)
|
||||
|
||||
if (!hasAddedCurrentObjectToRecentsList)
|
||||
{
|
||||
hasAddedCurrentObjectToRecentsList = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user