Created
August 1, 2021 01:02
-
-
Save krypt-lynx/a90241189203d9771aad7486caf13e6a to your computer and use it in GitHub Desktop.
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 HarmonyLib; | |
using RimWorld; | |
using RWLayout.alpha2; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using UnityEngine; | |
using Verse; | |
namespace UnifiedXmlExport | |
{ | |
static class MainMenuDrawerPatches | |
{ | |
static CGuiRoot guiHost; | |
static MainMenuDrawerPatches() | |
{ | |
guiHost = new CGuiRoot(); | |
var notification = guiHost.AddElement(new NotificationView()); | |
guiHost.AddConstraints(guiHost.top ^ notification.top); | |
guiHost.AddConstraints(guiHost.left ^ notification.left); | |
guiHost.AddConstraints(guiHost.right ^ notification.right); | |
} | |
internal static void Patch(Harmony harmony) | |
{ | |
harmony.Patch(AccessTools.Method(typeof(MainMenuDrawer), nameof(MainMenuDrawer.DoMainMenuControls)), | |
prefix: new HarmonyMethod(typeof(MainMenuDrawerPatches), nameof(DoMainMenuControls_prefix))); | |
} | |
private static void DoMainMenuControls_prefix(Rect rect) | |
{ | |
guiHost.InRect = Rect.MinMaxRect(rect.xMin - 520, rect.yMin, rect.xMin - 20, rect.yMax); | |
guiHost.UpdateLayoutIfNeeded(); | |
guiHost.DoElementContent(); | |
} | |
} | |
class CWindowBox : CElement | |
{ | |
private static readonly Color WindowBGBorderColor = new ColorInt(97, 108, 122).ToColor; | |
public override void DoContent() | |
{ | |
base.DoContent(); | |
GuiTools.PushColor(Widgets.WindowBGFillColor); | |
GUI.DrawTexture(BoundsRounded, BaseContent.WhiteTex); | |
GuiTools.PopColor(); | |
GuiTools.PushColor(WindowBGBorderColor); | |
Widgets.DrawBox(BoundsRounded, 1, null); | |
GuiTools.PopColor(); | |
GUI.color = Color.white; | |
} | |
} | |
class NotificationView : CWindowBox | |
{ | |
public NotificationView() : base() | |
{ | |
this.StackTop(StackOptions.Create(intrinsicIfNotSet: true, insets: new EdgeInsets(8, 10, 8, 10)), | |
this.AddElement(new CLabel | |
{ | |
Title = @"Unified Xml Export", | |
Font = Verse.GameFont.Medium | |
}), | |
10, | |
this.AddElement(new CLabel | |
{ | |
Title = | |
@"For whatever reason you have this mod active | |
If you are know why exactly - thank you for using this tool and have luck developing your mods. | |
But in case if you don't, or even have no idea what ""Unified Xml Export"" is, there are two opotions: | |
- It was added by RimPy to create marged mod | |
- The author of modpack you are using halfassing their work. | |
In first case you need to remove ""Unified Xml Export"" from active mods (and maybe RWLayout, unless you have other mods requaring it to work) | |
In second case you should poke modpack author until they fixes the damn thing | |
Have a nice day!", | |
WordWrap = true | |
}) | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment