()
| 227 | } |
| 228 | |
| 229 | private void SetupStyle() |
| 230 | { |
| 231 | var themeOptions = Options.Theme; |
| 232 | |
| 233 | // If a non-default style was chosen, switch to that style |
| 234 | string styleName = themeOptions.SelectedStyle; |
| 235 | if (styleName != ThemeOptions.DefaultName && styleName != ThemeOptions.LightDefault && themeOptions.Styles.TryGetValue(styleName, out var style) && style != null) |
| 236 | { |
| 237 | // Setup defaults for newly added components that might be missing |
| 238 | if (style.Selection == Color.Transparent && style.SelectionBorder == Color.Transparent) |
| 239 | { |
| 240 | // [Deprecated on 6.03.2024, expires on 6.03.2026] |
| 241 | style.Selection = Color.Orange * 0.4f; |
| 242 | style.SelectionBorder = Color.Orange; |
| 243 | } |
| 244 | |
| 245 | Style.Current = style; |
| 246 | } |
| 247 | else |
| 248 | { |
| 249 | if (styleName == ThemeOptions.LightDefault) |
| 250 | { |
| 251 | Style.Current = CreateLightStyle(); |
| 252 | } |
| 253 | else |
| 254 | { |
| 255 | Style.Current = CreateDefaultStyle(); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | // Ensure custom fonts are valid, reset if not |
| 260 | var defaultInterfaceOptions = new InterfaceOptions(); |
| 261 | if (Style.Current.FontTitle == null) |
| 262 | Style.Current.FontTitle = defaultInterfaceOptions.TitleFont.GetFont(); |
| 263 | if (Style.Current.FontSmall == null) |
| 264 | Style.Current.FontSmall = defaultInterfaceOptions.SmallFont.GetFont(); |
| 265 | if (Style.Current.FontMedium == null) |
| 266 | Style.Current.FontMedium = defaultInterfaceOptions.MediumFont.GetFont(); |
| 267 | if (Style.Current.FontLarge == null) |
| 268 | Style.Current.FontLarge = defaultInterfaceOptions.LargeFont.GetFont(); |
| 269 | |
| 270 | // Set fallback fonts |
| 271 | var fallbackFonts = Options.Interface.FallbackFonts; |
| 272 | if (fallbackFonts == null || fallbackFonts.Length == 0 || fallbackFonts.All(x => x == null)) |
| 273 | fallbackFonts = GameSettings.Load<GraphicsSettings>().FallbackFonts; |
| 274 | Font.FallbackFonts = fallbackFonts; |
| 275 | } |
| 276 | |
| 277 | /// <summary> |
| 278 | /// Creates the default style. |
nothing calls this directly
no test coverage detected