Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. using System;
  2. using Verse;
  3. using Harmony;
  4. using System.Xml;
  5. using System.IO;
  6.  
  7. namespace DebugActions
  8. {
  9. class DebugActions : Mod
  10. {
  11. public DebugActions(ModContentPack content) : base(content)
  12. {
  13. HarmonyInstance.Create("rimworld.debugactions").PatchAll();
  14. }
  15. }
  16.  
  17. [HarmonyPatch (typeof(LoadedModManager), "CombineIntoUnifiedXML")]
  18. internal static class SaveXML
  19. {
  20. public static XmlDocument instance;
  21.  
  22. static void Postfix(XmlDocument __result)
  23. {
  24. if (instance == null) instance = __result;
  25. }
  26. }
  27.  
  28. [HarmonyPatch (typeof(Dialog_DebugActionsMenu), "DoListingItems_Entry")]
  29. static class AddDebugActions
  30. {
  31. static void Prefix(Dialog_DebugActionsMenu __instance)
  32. {
  33. var menu = __instance;
  34.  
  35. menu.DoLabel("XML");
  36. menu.DebugAction("Dump", delegate {
  37. StringWriter sw = new StringWriter();
  38. SaveXML.instance.Save(sw);
  39. string formattedXml = sw.ToString();
  40.  
  41. Log.Message(formattedXml);
  42. });
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement