Just null check the styles
This commit is contained in:
@@ -101,34 +101,14 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
||||
|
||||
public override void PreDraw()
|
||||
{
|
||||
if (Plugin.Config.OverrideStyle && Plugin.Config.ChosenStyle != "")
|
||||
{
|
||||
var styles = StyleModel.GetConfiguredStyles();
|
||||
try
|
||||
{
|
||||
styles?.First(style => style.Name.Equals(Plugin.Config.ChosenStyle)).Push();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
// Swallow the error - User does not have a valid style set
|
||||
}
|
||||
}
|
||||
if (Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
||||
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == Plugin.Config.ChosenStyle)?.Push();
|
||||
}
|
||||
|
||||
public override void PostDraw()
|
||||
{
|
||||
if (Plugin.Config.OverrideStyle && Plugin.Config.ChosenStyle != "")
|
||||
{
|
||||
var styles = StyleModel.GetConfiguredStyles();
|
||||
try
|
||||
{
|
||||
styles?.First(style => style.Name.Equals(Plugin.Config.ChosenStyle)).Pop();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
// Swallow the error - User does not have a valid style set
|
||||
}
|
||||
}
|
||||
if (Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
||||
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == Plugin.Config.ChosenStyle)?.Pop();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
|
||||
+6
-24
@@ -25,18 +25,9 @@ internal class Popout : Window
|
||||
|
||||
public override void PreDraw()
|
||||
{
|
||||
if (ChatLogWindow.Plugin.Config.OverrideStyle && ChatLogWindow.Plugin.Config.ChosenStyle != "")
|
||||
{
|
||||
var styles = StyleModel.GetConfiguredStyles();
|
||||
try
|
||||
{
|
||||
styles?.First(style => style.Name.Equals(ChatLogWindow.Plugin.Config.ChosenStyle)).Push();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
// Swallow the error - User does not have a valid style set
|
||||
}
|
||||
}
|
||||
if (ChatLogWindow.Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
||||
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == ChatLogWindow.Plugin.Config.ChosenStyle)?.Push();
|
||||
|
||||
Flags = ImGuiWindowFlags.None;
|
||||
if (!ChatLogWindow.Plugin.Config.ShowPopOutTitleBar)
|
||||
Flags |= ImGuiWindowFlags.NoTitleBar;
|
||||
@@ -66,18 +57,9 @@ internal class Popout : Window
|
||||
{
|
||||
|
||||
ChatLogWindow.PopOutDocked[Idx] = ImGui.IsWindowDocked();
|
||||
if (ChatLogWindow.Plugin.Config.OverrideStyle && ChatLogWindow.Plugin.Config.ChosenStyle != "")
|
||||
{
|
||||
var styles = StyleModel.GetConfiguredStyles();
|
||||
try
|
||||
{
|
||||
styles?.First(style => style.Name.Equals(ChatLogWindow.Plugin.Config.ChosenStyle)).Pop();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
// Swallow the error - User does not have a valid style set
|
||||
}
|
||||
}
|
||||
|
||||
if (ChatLogWindow.Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
||||
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == ChatLogWindow.Plugin.Config.ChosenStyle)?.Pop();
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
|
||||
@@ -87,6 +87,7 @@ internal sealed class About : ISettingsTab {
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,5 +60,7 @@ internal sealed class ChatColours : ISettingsTab {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,5 +126,7 @@ internal sealed class Database : ISettingsTab
|
||||
ImGui.PopTextWrapPos();
|
||||
ImGui.TreePop();
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,19 +101,26 @@ internal sealed class Display : ISettingsTab {
|
||||
|
||||
if (Mutable.OverrideStyle)
|
||||
{
|
||||
var currentStyle = Mutable.ChosenStyle.Equals("") ? StyleModel.GetConfiguredStyle().Name : Mutable.ChosenStyle;
|
||||
if (ImGui.BeginCombo(Language.Options_OverrideStyleDropdown_Name, currentStyle)) {
|
||||
foreach (var style in StyleModel.GetConfiguredStyles()) {
|
||||
if (ImGui.Selectable(style.Name, Mutable.ChosenStyle == style.Name)) {
|
||||
Mutable.ChosenStyle = style.Name;
|
||||
}
|
||||
}
|
||||
var styles = StyleModel.GetConfiguredStyles();
|
||||
if (styles != null)
|
||||
{
|
||||
var currentStyle = Mutable.ChosenStyle ?? Language.Options_OverrideStyle_NotSelected;
|
||||
if (ImGui.BeginCombo(Language.Options_OverrideStyleDropdown_Name, currentStyle))
|
||||
{
|
||||
foreach (var style in styles)
|
||||
if (ImGui.Selectable(style.Name, Mutable.ChosenStyle == style.Name))
|
||||
Mutable.ChosenStyle = style.Name;
|
||||
|
||||
ImGui.EndCombo();
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted(Language.Options_OverrideStyle_NotAvailable);
|
||||
}
|
||||
}
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ public class Fonts : ISettingsTab {
|
||||
ImGuiUtil.DragFloatVertical(Language.Options_SymbolsFontSize_Name, ref Mutable.SymbolsFontSize, speed, min, max, $"{Mutable.SymbolsFontSize:N1}");
|
||||
ImGuiUtil.HelpText(Language.Options_SymbolsFontSize_Description);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ internal sealed class Miscellaneous : ISettingsTab {
|
||||
|
||||
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
|
||||
ImGuiUtil.HelpText(Language.Options_SortAutoTranslate_Description);
|
||||
|
||||
ImGui.Spacing();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user