private static IEnumerator applyAndGoBack() { //update menu ui MenuRef.Find("helptext").isVisible = false; MenuRef.Find("applying").isVisible = true; setSkinButtonVisibility(false); yield return(new WaitForSecondsRealtime(0.2f)); BetterMenu.MenuRef?.Find("SelectSkinOption")?.updateAfter(_ => { try { BetterMenu.ApplySkin(); } catch (Exception e) { CustomKnight.Instance.Log(e.ToString()); } } ); yield return(new WaitForSecondsRealtime(0.2f)); UIManager.instance.UIGoToDynamicMenu(lastMenu); yield return(new WaitForSecondsRealtime(0.2f)); //menu ui initial state MenuRef.Find("helptext").isVisible = true; MenuRef.Find("applying").isVisible = false; setSkinButtonVisibility(true); }
/// <summary> /// Add a skin to the skin list provided by an external mod. /// </summary> /// <param name="NewSkin">an <c>ISelectableSkin</c> that represents the skin</param> /// <returns>true if the skin is added</returns> public static bool AddSkin(ISelectableSkin NewSkin) { var Exists = SkinManager.ProvidedSkins.Exists(skin => skin.GetId() == NewSkin.GetId()); if (!Exists) { SkinManager.ProvidedSkins.Add(NewSkin); BetterMenu.UpdateSkinList(); } return(!Exists); }
internal static MenuScreen GetMenu(MenuScreen lastMenu, ModToggleDelegates?toggleDelegates) { if (MenuRef == null) { MenuRef = PrepareMenu((ModToggleDelegates)toggleDelegates); } MenuRef.OnBuilt += (_, Element) => { SetPreloadButton(); SetDumpButton(); if (SkinManager.CurrentSkin != null) { BetterMenu.SelectedSkin(SkinManager.CurrentSkin.GetId()); } }; return(MenuRef.GetMenuScreen(lastMenu)); }
/// <summary> /// Change the current skin, to the one whose id is provided. /// </summary> /// <param name="id">a <c>string</c> that uniquely identifies the skin</param> public static void SetSkinById(string id) { var Skin = GetSkinById(id); CustomKnight.Instance.Log("Trying to apply skin :" + Skin.GetId()); if (CurrentSkin != null && CurrentSkin.GetId() == Skin.GetId()) { return; } CurrentSkin = Skin; BetterMenu.SelectedSkin(SkinManager.CurrentSkin.GetId()); // use this when saving so you save to the right settings if (GameManager.instance.IsNonGameplayScene()) { CustomKnight.GlobalSettings.DefaultSkin = CurrentSkin.GetId(); } else { CustomKnight.GlobalSettings.DefaultSkin = CurrentSkin.GetId(); CustomKnight.SaveSettings.DefaultSkin = CurrentSkin.GetId(); }; RefreshSkin(false); OnSetSkin?.Invoke(CustomKnight.Instance, new EventArgs()); }