Just null check the styles
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>1.20.3</Version>
|
<Version>1.20.4</Version>
|
||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ internal class Configuration : IPluginConfiguration {
|
|||||||
public Dictionary<ChatType, uint> ChatColours = new();
|
public Dictionary<ChatType, uint> ChatColours = new();
|
||||||
public List<Tab> Tabs = new();
|
public List<Tab> Tabs = new();
|
||||||
|
|
||||||
public bool OverrideStyle = false;
|
public bool OverrideStyle;
|
||||||
public string ChosenStyle = "";
|
public string? ChosenStyle;
|
||||||
|
|
||||||
public uint DatabaseMigration = LatestDbVersion;
|
public uint DatabaseMigration = LatestDbVersion;
|
||||||
|
|
||||||
|
|||||||
Generated
+18
@@ -2156,6 +2156,24 @@ namespace ChatTwo.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to No dalamud styles available.
|
||||||
|
/// </summary>
|
||||||
|
internal static string Options_OverrideStyle_NotAvailable {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Options_OverrideStyle_NotAvailable", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Not selected.
|
||||||
|
/// </summary>
|
||||||
|
internal static string Options_OverrideStyle_NotSelected {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Options_OverrideStyle_NotSelected", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Styles.
|
/// Looks up a localized string similar to Styles.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -982,4 +982,10 @@
|
|||||||
<data name="Options_Database_Metadata_Size">
|
<data name="Options_Database_Metadata_Size">
|
||||||
<value>Size: {0}</value>
|
<value>Size: {0}</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Options_OverrideStyle_NotSelected" xml:space="preserve">
|
||||||
|
<value>Not selected</value>
|
||||||
|
</data>
|
||||||
|
<data name="Options_OverrideStyle_NotAvailable" xml:space="preserve">
|
||||||
|
<value>No dalamud styles available</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|||||||
@@ -101,34 +101,14 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
|||||||
|
|
||||||
public override void PreDraw()
|
public override void PreDraw()
|
||||||
{
|
{
|
||||||
if (Plugin.Config.OverrideStyle && Plugin.Config.ChosenStyle != "")
|
if (Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
||||||
{
|
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == Plugin.Config.ChosenStyle)?.Push();
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PostDraw()
|
public override void PostDraw()
|
||||||
{
|
{
|
||||||
if (Plugin.Config.OverrideStyle && Plugin.Config.ChosenStyle != "")
|
if (Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
||||||
{
|
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == Plugin.Config.ChosenStyle)?.Pop();
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
|||||||
+6
-24
@@ -25,18 +25,9 @@ internal class Popout : Window
|
|||||||
|
|
||||||
public override void PreDraw()
|
public override void PreDraw()
|
||||||
{
|
{
|
||||||
if (ChatLogWindow.Plugin.Config.OverrideStyle && ChatLogWindow.Plugin.Config.ChosenStyle != "")
|
if (ChatLogWindow.Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
||||||
{
|
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == ChatLogWindow.Plugin.Config.ChosenStyle)?.Push();
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Flags = ImGuiWindowFlags.None;
|
Flags = ImGuiWindowFlags.None;
|
||||||
if (!ChatLogWindow.Plugin.Config.ShowPopOutTitleBar)
|
if (!ChatLogWindow.Plugin.Config.ShowPopOutTitleBar)
|
||||||
Flags |= ImGuiWindowFlags.NoTitleBar;
|
Flags |= ImGuiWindowFlags.NoTitleBar;
|
||||||
@@ -66,18 +57,9 @@ internal class Popout : Window
|
|||||||
{
|
{
|
||||||
|
|
||||||
ChatLogWindow.PopOutDocked[Idx] = ImGui.IsWindowDocked();
|
ChatLogWindow.PopOutDocked[Idx] = ImGui.IsWindowDocked();
|
||||||
if (ChatLogWindow.Plugin.Config.OverrideStyle && ChatLogWindow.Plugin.Config.ChosenStyle != "")
|
|
||||||
{
|
if (ChatLogWindow.Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
|
||||||
var styles = StyleModel.GetConfiguredStyles();
|
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == ChatLogWindow.Plugin.Config.ChosenStyle)?.Pop();
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnClose()
|
public override void OnClose()
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ internal sealed class About : ISettingsTab {
|
|||||||
ImGui.EndChild();
|
ImGui.EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
ImGui.PopTextWrapPos();
|
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.PopTextWrapPos();
|
||||||
ImGui.TreePop();
|
ImGui.TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,19 +101,26 @@ internal sealed class Display : ISettingsTab {
|
|||||||
|
|
||||||
if (Mutable.OverrideStyle)
|
if (Mutable.OverrideStyle)
|
||||||
{
|
{
|
||||||
var currentStyle = Mutable.ChosenStyle.Equals("") ? StyleModel.GetConfiguredStyle().Name : Mutable.ChosenStyle;
|
var styles = StyleModel.GetConfiguredStyles();
|
||||||
if (ImGui.BeginCombo(Language.Options_OverrideStyleDropdown_Name, currentStyle)) {
|
if (styles != null)
|
||||||
foreach (var style in StyleModel.GetConfiguredStyles()) {
|
{
|
||||||
if (ImGui.Selectable(style.Name, Mutable.ChosenStyle == style.Name)) {
|
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;
|
Mutable.ChosenStyle = style.Name;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui.Spacing();
|
else
|
||||||
|
{
|
||||||
|
ImGui.TextUnformatted(Language.Options_OverrideStyle_NotAvailable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
ImGui.PopTextWrapPos();
|
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.DragFloatVertical(Language.Options_SymbolsFontSize_Name, ref Mutable.SymbolsFontSize, speed, min, max, $"{Mutable.SymbolsFontSize:N1}");
|
||||||
ImGuiUtil.HelpText(Language.Options_SymbolsFontSize_Description);
|
ImGuiUtil.HelpText(Language.Options_SymbolsFontSize_Description);
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
ImGui.PopTextWrapPos();
|
ImGui.PopTextWrapPos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ internal sealed class Miscellaneous : ISettingsTab {
|
|||||||
|
|
||||||
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
|
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
|
||||||
ImGuiUtil.HelpText(Language.Options_SortAutoTranslate_Description);
|
ImGuiUtil.HelpText(Language.Options_SortAutoTranslate_Description);
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user