internal static Menu PrepareMenu(ModToggleDelegates toggleDelegates)
        {
            return(new Menu("Custom Knight", new Element[] {
                Blueprints.CreateToggle(toggleDelegates, "Custom Skins", "", "Enabled", "Disabled"),
                new HorizontalOption(
                    "Swapper", "Apply skin to bosses, enemies & areas",
                    new string[] { "Disabled", "Enabled" },
                    (setting) => { CustomKnight.toggleSwap(setting == 1); },
                    () => CustomKnight.swapManager.enabled ? 1 : 0,
                    Id: "SwapperEnabled"),
                new HorizontalOption(
                    "Select Skin", "The skin will be used for current save and any new saves.",
                    getSkinNameArray(),
                    (setting) => { selectedSkin = setting; },
                    () => selectedSkin,
                    Id: "SelectSkinOption"),
                new MenuButton("PreloadButton", "Will Preload objects for modifying events", (_) => TogglePreloads(), Id: "PreloadButton"),
                new MenuRow(
                    new List <Element> {
                    Blueprints.NavigateToMenu("Skin List", "Opens a list of Skins", () => SkinsList.GetMenu(MenuRef.menuScreen)),
                    new MenuButton("Apply Skin", "Apply The currently selected skin.", (_) => ApplySkin()),
                },
                    Id: "ApplyButtonGroup"
                    )
                {
                    XDelta = 400f
                },

                new TextPanel("To Add more skins, copy the skins into your Skins folder."),
                new MenuRow(
                    new List <Element> {
                    new MenuButton("Open Folder", "Open skins folder", (_) => OpenSkins()),
                    new MenuButton("Fix / Reload", "Fix skin structure and reload", (_) => FixSkins()),
                    new MenuButton("Need Help?", "Join the HK Modding Discord", (_) => OpenLink("https://discord.gg/J4SV6NFxAA")),
                },
                    Id: "HelpButtonGroup"
                    )
                {
                    XDelta = 425f
                },
                new MenuRow(
                    new List <Element> {
                    new MenuButton("Dump", "Dumps the sprites that Swapper supports (Expect lag)", (_) => ToggleDumping(), Id: "DumpButton"),
                    //new MenuButton("Generate Cache","Generates Cache for Everything (Can take hours)",(_)=>DumpAll(),Id:"DumpAllButton"),
                    //new MenuButton("Need Help?","Join the HK Modding Discord",(_)=>OpenLink("https://discord.gg/J4SV6NFxAA")),
                },
                    Id: "AdditonalButtonGroup"
                    )
                {
                    XDelta = 425f
                },
            }));
        }
 // Due to the lifecycle of the UIManager object, The `EditMenus` event has to be used to create custom menus.
 // This event is called every time a UIManager is created,
 // and will also call the added action if the UIManager has already started.
 internal void InitMenuCreation()
 {
     Patch.UIManager.BeforeHideDynamicMenu += ToggleMods;
     Patch.UIManager.EditMenus             += () =>
     {
         ModScreens = new Dictionary <IMod, MenuScreen>();
         var builder = new MenuBuilder("ModListMenu");
         this.screen = builder.Screen;
         builder.CreateTitle("Mods", MenuTitleStyle.vanillaStyle)
         .SetDefaultNavGraph(new ChainedNavGraph())
         .CreateContentPane(RectTransformData.FromSizeAndPos(
                                new RelVector2(new Vector2(1920f, 903f)),
                                new AnchoredPosition(
                                    new Vector2(0.5f, 0.5f),
                                    new Vector2(0.5f, 0.5f),
                                    new Vector2(0f, -60f)
                                    )
                                ))
         .CreateControlPane(RectTransformData.FromSizeAndPos(
                                new RelVector2(new Vector2(1920f, 259f)),
                                new AnchoredPosition(
                                    new Vector2(0.5f, 0.5f),
                                    new Vector2(0.5f, 0.5f),
                                    new Vector2(0f, -502f)
                                    )
                                ))
         .AddContent(
             new NullContentLayout(),
             c => c.AddScrollPaneContent(
                 new ScrollbarConfig
         {
             CancelAction = _ => this.ApplyChanges(),
             Navigation   = new Navigation {
                 mode = Navigation.Mode.Explicit
             },
             Position = new AnchoredPosition
             {
                 ChildAnchor  = new Vector2(0f, 1f),
                 ParentAnchor = new Vector2(1f, 1f),
                 Offset       = new Vector2(-310f, 0f)
             },
             SelectionPadding = _ => (-60, 0)
         },
                 new RelLength(0f),
                 RegularGridLayout.CreateVerticalLayout(105f),
                 c =>
         {
             foreach (var modInst in ModLoader.ModInstances)
             {
                 if (modInst.Error != null)
                 {
                     continue;
                 }
                 ModToggleDelegates?toggleDels = null;
                 if (modInst.Mod is ITogglableMod itmod)
                 {
                     try
                     {
                         if (
                             modInst.Mod is not(
                                 IMenuMod {
                             ToggleButtonInsideMenu: true
                         } or
                                 ICustomMenuMod {
                             ToggleButtonInsideMenu: true
                         }
                                 )
                             )
                         {
                             var rt       = c.ContentObject.GetComponent <RectTransform>();
                             rt.sizeDelta = new Vector2(0f, rt.sizeDelta.y + 105f);
                             c.AddHorizontalOption(
                                 modInst.Name,
                                 new HorizontalOptionConfig
                             {
                                 ApplySetting = (self, ind) =>
                                 {
                                     changedMods[modInst] = ind == 1;
                                 },
                                 CancelAction = _ => this.ApplyChanges(),
                                 Label        = modInst.Name,
                                 Options      = new string[] {
                                     Lang.Get("MOH_OFF", "MainMenu"),
                                     Lang.Get("MOH_ON", "MainMenu")
                                 },
                                 RefreshSetting = (self, apply) => self.optionList.SetOptionTo(
                                     modInst.Enabled ? 1 : 0
                                     ),
                                 Style       = HorizontalOptionStyle.VanillaStyle,
                                 Description = new DescriptionInfo
                                 {
                                     Text = $"v{modInst.Mod.GetVersion()}"
                                 }
                             },
                                 out var opt
                                 );
                             opt.menuSetting.RefreshValueFromGameSettings();
                         }
                         else
                         {
                             toggleDels = new ModToggleDelegates
                             {
                                 SetModEnabled = enabled =>
                                 {
                                     changedMods[modInst] = enabled;
                                 },
                                 GetModEnabled = () => modInst.Enabled,
                                             #pragma warning disable CS0618
                                 // Kept for backwards compatability.
                                 ApplyChange = () => {  }
                                             #pragma warning restore CS0618
                             };
                         }
                     }
                     catch (Exception e)
                     {
                         Logger.APILogger.LogError(e);
                     }
                 }
Esempio n. 3
0
        public static MenuScreen GetMenuScreen(MenuScreen returnScreen, ModToggleDelegates dels)
        {
            MenuBuilder builder = MenuUtils.CreateMenuBuilderWithBackButton("QoL", returnScreen, out _);

            void Return(MenuSelectable _) => UIManager.instance.UIGoToDynamicMenu(returnScreen);