Created
September 7, 2019 19:29
-
-
Save notfood/9492d87e4c6ac0cb51875122ba87897e to your computer and use it in GitHub Desktop.
Adds a button to the debug panel to dump the resulting xml into console.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Verse; | |
using Harmony; | |
using System.Xml; | |
using System.IO; | |
namespace DebugActions | |
{ | |
class DebugActions : Mod | |
{ | |
public DebugActions(ModContentPack content) : base(content) | |
{ | |
HarmonyInstance.Create("rimworld.debugactions").PatchAll(); | |
} | |
} | |
[HarmonyPatch (typeof(LoadedModManager), "CombineIntoUnifiedXML")] | |
internal static class SaveXML | |
{ | |
public static XmlDocument instance; | |
static void Postfix(XmlDocument __result) | |
{ | |
if (instance == null) instance = __result; | |
} | |
} | |
[HarmonyPatch (typeof(Dialog_DebugActionsMenu), "DoListingItems_Entry")] | |
static class AddDebugActions | |
{ | |
static void Prefix(Dialog_DebugActionsMenu __instance) | |
{ | |
var menu = __instance; | |
menu.DoLabel("XML"); | |
menu.DebugAction("Dump", delegate { | |
StringWriter sw = new StringWriter(); | |
SaveXML.instance.Save(sw); | |
string formattedXml = sw.ToString(); | |
Log.Message(formattedXml); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment