Skip to content

Commit

Permalink
Merge pull request #1 from EIA485/master
Browse files Browse the repository at this point in the history
add option to default delegate views open
  • Loading branch information
art0007i authored Sep 30, 2022
2 parents 15fa000 + 53e139c commit 8ea60b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ShowDelegates/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
28 changes: 16 additions & 12 deletions ShowDelegates/ShowDelegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,28 @@

namespace ShowDelegates
{
public class ShowDelegates : NeosMod
{
public override string Name => "ShowDelegates";
public override string Author => "art0007i";
public override string Version => "1.1.0";
public override string Link => "https://github.com/art0007i/ShowDelegates/";
public class ShowDelegates : NeosMod
{
public override string Name => "ShowDelegates";
public override string Author => "art0007i";
public override string Version => "1.1.1";
public override string Link => "https://github.com/art0007i/ShowDelegates/";

[AutoRegisterConfigKey]
private static readonly ModConfigurationKey<bool> KEY_DEFAULT_OPEN = new ModConfigurationKey<bool>("default_open", "If true delegates will be expanded by default", () => false);
[AutoRegisterConfigKey]
private static readonly ModConfigurationKey<bool> KEY_SHOW_DELEGATES = new ModConfigurationKey<bool>("show_deleages", "If false delegates will not be shown", () => true);
[AutoRegisterConfigKey]
private static readonly ModConfigurationKey<bool> KEY_SHOW_HIDDEN = new ModConfigurationKey<bool>("show_hidden", "If false items with the hidden HideInInspector attribute will not be shown", ()=>true);
private static ModConfiguration config;

public override void OnEngineInit()
{
Harmony harmony = new Harmony("me.art0007i.ShowDelegates");
harmony.PatchAll();
{
Harmony harmony = new Harmony("me.art0007i.ShowDelegates");
harmony.PatchAll();
config = GetConfiguration();

}
}
private static void GenerateDelegateProxy<T>(UIBuilder ui, string name, T target) where T : class
{
LocaleString localeString = name + ":";
Expand Down Expand Up @@ -73,7 +75,7 @@ private static string funName(string prefix, MethodInfo info)
[HarmonyPatch(typeof(WorkerInspector))]
[HarmonyPatch("BuildInspectorUI")]
class WorkerInspector_BuildInspectorUI_Patch
{
{
private static void Postfix(WorkerInspector __instance, Worker worker, UIBuilder ui, Predicate<ISyncMember> memberFilter = null)
{
if(config.GetValue(KEY_SHOW_HIDDEN))
Expand All @@ -98,7 +100,9 @@ where m.GetParameters().Length <= 3 && m.GetCustomAttributes(typeof(SyncMethod),
var delegates = ui.VerticalLayout();
delegates.Slot.ActiveSelf = false;
delegates.Slot.RemoveComponent(delegates.Slot.GetComponent<LayoutElement>());
myTxt.Slot.AttachComponent<Expander>().SectionRoot.Target = delegates.Slot;
var expander = myTxt.Slot.AttachComponent<Expander>();
expander.SectionRoot.Target = delegates.Slot;
expander.IsExpanded = config.GetValue(KEY_DEFAULT_OPEN);
var colorDriver = myTxt.Slot.AttachComponent<Button>().ColorDrivers.Add();
colorDriver.ColorDrive.Target = myTxt.Color;
colorDriver.NormalColor.Value = color.Black;
Expand Down

0 comments on commit 8ea60b7

Please sign in to comment.