Use ImRaii in ImGuiUtil
This commit is contained in:
@@ -36,58 +36,60 @@ public class Fonts : ISettingsTab
|
||||
|
||||
if (Mutable.FontsEnabled)
|
||||
{
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, Mutable.GlobalFont))
|
||||
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, Mutable.GlobalFont))
|
||||
{
|
||||
foreach (var font in Ui.Fonts.GlobalFonts)
|
||||
if (combo)
|
||||
{
|
||||
if (ImGui.Selectable(font.Name, Mutable.GlobalFont == font.Name))
|
||||
Mutable.GlobalFont = font.Name;
|
||||
foreach (var font in Ui.Fonts.GlobalFonts)
|
||||
{
|
||||
if (ImGui.Selectable(font.Name, Mutable.GlobalFont == font.Name))
|
||||
Mutable.GlobalFont = font.Name;
|
||||
|
||||
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == font.Name)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == font.Name)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
foreach (var name in GlobalFonts)
|
||||
{
|
||||
if (ImGui.Selectable(name, Mutable.GlobalFont == name))
|
||||
Mutable.GlobalFont = name;
|
||||
|
||||
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == name)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
foreach (var name in GlobalFonts)
|
||||
{
|
||||
if (ImGui.Selectable(name, Mutable.GlobalFont == name))
|
||||
Mutable.GlobalFont = name;
|
||||
|
||||
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == name)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Font_Description, Plugin.PluginName));
|
||||
ImGuiUtil.WarningText(Language.Options_Font_Warning);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, Mutable.JapaneseFont))
|
||||
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, Mutable.JapaneseFont))
|
||||
{
|
||||
foreach (var (name, _) in Ui.Fonts.JapaneseFonts)
|
||||
if (combo)
|
||||
{
|
||||
if (ImGui.Selectable(name, Mutable.JapaneseFont == name))
|
||||
Mutable.JapaneseFont = name;
|
||||
foreach (var (name, _) in Ui.Fonts.JapaneseFonts)
|
||||
{
|
||||
if (ImGui.Selectable(name, Mutable.JapaneseFont == name))
|
||||
Mutable.JapaneseFont = name;
|
||||
|
||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
foreach (var family in JpFonts)
|
||||
{
|
||||
if (ImGui.Selectable(family, Mutable.JapaneseFont == family))
|
||||
Mutable.JapaneseFont = family;
|
||||
|
||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == family)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
foreach (var family in JpFonts)
|
||||
{
|
||||
if (ImGui.Selectable(family, Mutable.JapaneseFont == family))
|
||||
Mutable.JapaneseFont = family;
|
||||
|
||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == family)
|
||||
ImGui.SetScrollHereY(0.5f);
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName));
|
||||
|
||||
@@ -11,42 +11,45 @@ internal sealed class Miscellaneous(Configuration mutable) : ISettingsTab
|
||||
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, Mutable.LanguageOverride.Name()))
|
||||
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, Mutable.LanguageOverride.Name()))
|
||||
{
|
||||
foreach (var language in Enum.GetValues<LanguageOverride>())
|
||||
if (ImGui.Selectable(language.Name()))
|
||||
Mutable.LanguageOverride = language;
|
||||
|
||||
ImGui.EndCombo();
|
||||
if (combo)
|
||||
{
|
||||
foreach (var language in Enum.GetValues<LanguageOverride>())
|
||||
if (ImGui.Selectable(language.Name()))
|
||||
Mutable.LanguageOverride = language;
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, Mutable.CommandHelpSide.Name()))
|
||||
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, Mutable.CommandHelpSide.Name()))
|
||||
{
|
||||
foreach (var side in Enum.GetValues<CommandHelpSide>())
|
||||
if (ImGui.Selectable(side.Name(), Mutable.CommandHelpSide == side))
|
||||
Mutable.CommandHelpSide = side;
|
||||
|
||||
ImGui.EndCombo();
|
||||
if (combo)
|
||||
{
|
||||
foreach (var side in Enum.GetValues<CommandHelpSide>())
|
||||
if (ImGui.Selectable(side.Name(), Mutable.CommandHelpSide == side))
|
||||
Mutable.CommandHelpSide = side;
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName));
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_KeybindMode_Name, Mutable.KeybindMode.Name()))
|
||||
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_KeybindMode_Name, Mutable.KeybindMode.Name()))
|
||||
{
|
||||
foreach (var mode in Enum.GetValues<KeybindMode>())
|
||||
if (combo)
|
||||
{
|
||||
if (ImGui.Selectable(mode.Name(), Mutable.KeybindMode == mode))
|
||||
Mutable.KeybindMode = mode;
|
||||
foreach (var mode in Enum.GetValues<KeybindMode>())
|
||||
{
|
||||
if (ImGui.Selectable(mode.Name(), Mutable.KeybindMode == mode))
|
||||
Mutable.KeybindMode = mode;
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(mode.Tooltip());
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(mode.Tooltip());
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGuiUtil.HelpText(string.Format(Language.Options_KeybindMode_Description, Plugin.PluginName));
|
||||
|
||||
@@ -93,31 +93,33 @@ internal sealed class Tabs : ISettingsTab
|
||||
ImGuiUtil.DragFloatVertical(Language.Options_Tabs_Opacity, ref tab.Opacity, 0.25f, 0f, 100f, $"{tab.Opacity:N2}%%", ImGuiSliderFlags.AlwaysClamp);
|
||||
}
|
||||
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Tabs_UnreadMode, tab.UnreadMode.Name()))
|
||||
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Tabs_UnreadMode, tab.UnreadMode.Name()))
|
||||
{
|
||||
foreach (var mode in Enum.GetValues<UnreadMode>())
|
||||
if (combo)
|
||||
{
|
||||
if (ImGui.Selectable(mode.Name(), tab.UnreadMode == mode))
|
||||
tab.UnreadMode = mode;
|
||||
foreach (var mode in Enum.GetValues<UnreadMode>())
|
||||
{
|
||||
if (ImGui.Selectable(mode.Name(), tab.UnreadMode == mode))
|
||||
tab.UnreadMode = mode;
|
||||
|
||||
if (mode.Tooltip() is { } tooltip && ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(tooltip);
|
||||
if (mode.Tooltip() is { } tooltip && ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
var input = tab.Channel?.ToChatType().Name() ?? Language.Options_Tabs_NoInputChannel;
|
||||
if (ImGuiUtil.BeginComboVertical(Language.Options_Tabs_InputChannel, input))
|
||||
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Tabs_InputChannel, input))
|
||||
{
|
||||
if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null))
|
||||
tab.Channel = null;
|
||||
if (combo)
|
||||
{
|
||||
if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null))
|
||||
tab.Channel = null;
|
||||
|
||||
foreach (var channel in Enum.GetValues<InputChannel>())
|
||||
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel))
|
||||
tab.Channel = channel;
|
||||
|
||||
ImGui.EndCombo();
|
||||
foreach (var channel in Enum.GetValues<InputChannel>())
|
||||
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel))
|
||||
tab.Channel = channel;
|
||||
}
|
||||
}
|
||||
|
||||
using (var channelNode = ImRaii.TreeNode(Language.Options_Tabs_Channels))
|
||||
|
||||
Reference in New Issue
Block a user