internal static void AddBossBarStyle(ModBossBarStyle bossBarStyle) { lock (bossBarStyles) { bossBarStyles.Add(bossBarStyle); ModTypeLookup <ModBossBarStyle> .Register(bossBarStyle); } }
/// <summary> /// Inserts the boss bar style select option into the main and ingame menu under the "Interface" category /// </summary> internal static string InsertMenu(out Action onClick) { string styleText = null; ModBossBarStyle pendingBossBarStyle = null; foreach (ModBossBarStyle bossBarStyle in bossBarStyles) { if (bossBarStyle == CurrentStyle) { styleText = bossBarStyle.DisplayName; break; } pendingBossBarStyle = bossBarStyle; } if (pendingBossBarStyle == null) { pendingBossBarStyle = bossBarStyles.Last(); } if (styleText == null || bossBarStyles.Count == 1) { styleText = Language.GetTextValue("tModLoader.BossBarStyleNoOptions"); } onClick = () => SwitchBossBarStyle(pendingBossBarStyle); return(Language.GetTextValue("tModLoader.BossBarStyle", styleText)); }
/// <summary> /// Sets the saved style that should be switched to, handles possibly unloaded/invalid ones and defaults to the vanilla style /// </summary> internal static void GotoSavedStyle() { switchToStyle = vanillaStyle; if (ModContent.TryFind(lastSelectedStyle, out ModBossBarStyle value)) { switchToStyle = value; } styleLoading = false; }
/// <summary> /// Checks if the style was changed and applies it, saves the config if required /// </summary> internal static void HandleStyle() { if (switchToStyle != null && switchToStyle != CurrentStyle) { CurrentStyle.OnDeselected(); CurrentStyle = switchToStyle; CurrentStyle.OnSelected(); } switchToStyle = null; if (!styleLoading && CurrentStyle.FullName != lastSelectedStyle) { lastSelectedStyle = CurrentStyle.FullName; Main.SaveSettings(); } }
/// <summary> /// Sets the pending style that should be switched to /// </summary> /// <param name="bossBarStyle">Pending boss bar style</param> internal static void SwitchBossBarStyle(ModBossBarStyle bossBarStyle) => switchToStyle = bossBarStyle;