Use ImRaii in ImGuiUtil
This commit is contained in:
+23
-2
@@ -33,11 +33,17 @@ dotnet_naming_rule.private_instance_fields_rule.resharper_guid=4a98fdf6-7d98-4f5
|
|||||||
dotnet_naming_rule.private_instance_fields_rule.severity=warning
|
dotnet_naming_rule.private_instance_fields_rule.severity=warning
|
||||||
dotnet_naming_rule.private_instance_fields_rule.style=upper_camel_case_style
|
dotnet_naming_rule.private_instance_fields_rule.style=upper_camel_case_style
|
||||||
dotnet_naming_rule.private_instance_fields_rule.symbols=private_instance_fields_symbols
|
dotnet_naming_rule.private_instance_fields_rule.symbols=private_instance_fields_symbols
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule_1.import_to_resharper=True
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule_1.resharper_description=Instance fields (private)
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule_1.resharper_guid=4a98fdf6-7d98-4f5a-afeb-ea44ad98c70c
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule_1.severity=warning
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule_1.style=upper_camel_case_style
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule_1.symbols=private_instance_fields_symbols_1
|
||||||
dotnet_naming_rule.private_static_fields_rule.import_to_resharper=True
|
dotnet_naming_rule.private_static_fields_rule.import_to_resharper=True
|
||||||
dotnet_naming_rule.private_static_fields_rule.resharper_description=Static fields (private)
|
dotnet_naming_rule.private_static_fields_rule.resharper_description=Static fields (private)
|
||||||
dotnet_naming_rule.private_static_fields_rule.resharper_guid=f9fce829-e6f4-4cb2-80f1-5497c44f51df
|
dotnet_naming_rule.private_static_fields_rule.resharper_guid=f9fce829-e6f4-4cb2-80f1-5497c44f51df
|
||||||
dotnet_naming_rule.private_static_fields_rule.severity=warning
|
dotnet_naming_rule.private_static_fields_rule.severity=warning
|
||||||
dotnet_naming_rule.private_static_fields_rule.style=lower_camel_case_style
|
dotnet_naming_rule.private_static_fields_rule.style=upper_camel_case_style
|
||||||
dotnet_naming_rule.private_static_fields_rule.symbols=private_static_fields_symbols
|
dotnet_naming_rule.private_static_fields_rule.symbols=private_static_fields_symbols
|
||||||
dotnet_naming_rule.private_static_readonly_rule.import_to_resharper=True
|
dotnet_naming_rule.private_static_readonly_rule.import_to_resharper=True
|
||||||
dotnet_naming_rule.private_static_readonly_rule.resharper_description=Static readonly fields (private)
|
dotnet_naming_rule.private_static_readonly_rule.resharper_description=Static readonly fields (private)
|
||||||
@@ -51,6 +57,12 @@ dotnet_naming_rule.unity_serialized_field_rule.resharper_guid=5f0fdb63-c892-4d2c
|
|||||||
dotnet_naming_rule.unity_serialized_field_rule.severity=warning
|
dotnet_naming_rule.unity_serialized_field_rule.severity=warning
|
||||||
dotnet_naming_rule.unity_serialized_field_rule.style=lower_camel_case_style_1
|
dotnet_naming_rule.unity_serialized_field_rule.style=lower_camel_case_style_1
|
||||||
dotnet_naming_rule.unity_serialized_field_rule.symbols=unity_serialized_field_symbols
|
dotnet_naming_rule.unity_serialized_field_rule.symbols=unity_serialized_field_symbols
|
||||||
|
dotnet_naming_rule.unity_serialized_field_rule_1.import_to_resharper=True
|
||||||
|
dotnet_naming_rule.unity_serialized_field_rule_1.resharper_description=Unity serialized field
|
||||||
|
dotnet_naming_rule.unity_serialized_field_rule_1.resharper_guid=5f0fdb63-c892-4d2c-9324-15c80b22a7ef
|
||||||
|
dotnet_naming_rule.unity_serialized_field_rule_1.severity=warning
|
||||||
|
dotnet_naming_rule.unity_serialized_field_rule_1.style=lower_camel_case_style_1
|
||||||
|
dotnet_naming_rule.unity_serialized_field_rule_1.symbols=unity_serialized_field_symbols_1
|
||||||
dotnet_naming_style.lower_camel_case_style.capitalization=camel_case
|
dotnet_naming_style.lower_camel_case_style.capitalization=camel_case
|
||||||
dotnet_naming_style.lower_camel_case_style.required_prefix=_
|
dotnet_naming_style.lower_camel_case_style.required_prefix=_
|
||||||
dotnet_naming_style.lower_camel_case_style_1.capitalization=camel_case
|
dotnet_naming_style.lower_camel_case_style_1.capitalization=camel_case
|
||||||
@@ -64,6 +76,10 @@ dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities
|
|||||||
dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds=field
|
dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds=field
|
||||||
dotnet_naming_symbols.private_instance_fields_symbols.resharper_applicable_kinds=field,readonly_field
|
dotnet_naming_symbols.private_instance_fields_symbols.resharper_applicable_kinds=field,readonly_field
|
||||||
dotnet_naming_symbols.private_instance_fields_symbols.resharper_required_modifiers=instance
|
dotnet_naming_symbols.private_instance_fields_symbols.resharper_required_modifiers=instance
|
||||||
|
dotnet_naming_symbols.private_instance_fields_symbols_1.applicable_accessibilities=private
|
||||||
|
dotnet_naming_symbols.private_instance_fields_symbols_1.applicable_kinds=field
|
||||||
|
dotnet_naming_symbols.private_instance_fields_symbols_1.resharper_applicable_kinds=field,readonly_field
|
||||||
|
dotnet_naming_symbols.private_instance_fields_symbols_1.resharper_required_modifiers=instance
|
||||||
dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities=private
|
dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities=private
|
||||||
dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds=field
|
dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds=field
|
||||||
dotnet_naming_symbols.private_static_fields_symbols.required_modifiers=static
|
dotnet_naming_symbols.private_static_fields_symbols.required_modifiers=static
|
||||||
@@ -78,6 +94,10 @@ dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities=
|
|||||||
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds=
|
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds=
|
||||||
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds=unity_serialised_field
|
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds=unity_serialised_field
|
||||||
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers=instance
|
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers=instance
|
||||||
|
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_accessibilities=*
|
||||||
|
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds=
|
||||||
|
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_applicable_kinds=unity_serialised_field
|
||||||
|
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_required_modifiers=instance
|
||||||
dotnet_style_parentheses_in_arithmetic_binary_operators=never_if_unnecessary:none
|
dotnet_style_parentheses_in_arithmetic_binary_operators=never_if_unnecessary:none
|
||||||
dotnet_style_parentheses_in_other_binary_operators=always_for_clarity:none
|
dotnet_style_parentheses_in_other_binary_operators=always_for_clarity:none
|
||||||
dotnet_style_parentheses_in_relational_binary_operators=never_if_unnecessary:none
|
dotnet_style_parentheses_in_relational_binary_operators=never_if_unnecessary:none
|
||||||
@@ -91,6 +111,7 @@ dotnet_style_require_accessibility_modifiers=for_non_interface_members:suggestio
|
|||||||
|
|
||||||
# ReSharper properties
|
# ReSharper properties
|
||||||
resharper_autodetect_indent_settings=true
|
resharper_autodetect_indent_settings=true
|
||||||
|
resharper_cpp_insert_final_newline=true
|
||||||
resharper_csharp_insert_final_newline=false
|
resharper_csharp_insert_final_newline=false
|
||||||
resharper_formatter_off_tag=@formatter:off
|
resharper_formatter_off_tag=@formatter:off
|
||||||
resharper_formatter_on_tag=@formatter:on
|
resharper_formatter_on_tag=@formatter:on
|
||||||
@@ -99,7 +120,7 @@ resharper_fsharp_insert_final_newline=false
|
|||||||
resharper_html_insert_final_newline=false
|
resharper_html_insert_final_newline=false
|
||||||
resharper_resx_insert_final_newline=false
|
resharper_resx_insert_final_newline=false
|
||||||
resharper_shaderlab_insert_final_newline=false
|
resharper_shaderlab_insert_final_newline=false
|
||||||
resharper_T4_insert_final_newline=false
|
resharper_t4_insert_final_newline=false
|
||||||
resharper_use_indent_from_vs=false
|
resharper_use_indent_from_vs=false
|
||||||
resharper_vb_insert_final_newline=false
|
resharper_vb_insert_final_newline=false
|
||||||
resharper_xmldoc_insert_final_newline=false
|
resharper_xmldoc_insert_final_newline=false
|
||||||
|
|||||||
@@ -36,58 +36,60 @@ public class Fonts : ISettingsTab
|
|||||||
|
|
||||||
if (Mutable.FontsEnabled)
|
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))
|
foreach (var font in Ui.Fonts.GlobalFonts)
|
||||||
Mutable.GlobalFont = font.Name;
|
{
|
||||||
|
if (ImGui.Selectable(font.Name, Mutable.GlobalFont == font.Name))
|
||||||
|
Mutable.GlobalFont = font.Name;
|
||||||
|
|
||||||
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == font.Name)
|
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == font.Name)
|
||||||
ImGui.SetScrollHereY(0.5f);
|
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.HelpText(string.Format(Language.Options_Font_Description, Plugin.PluginName));
|
||||||
ImGuiUtil.WarningText(Language.Options_Font_Warning);
|
ImGuiUtil.WarningText(Language.Options_Font_Warning);
|
||||||
ImGui.Spacing();
|
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))
|
foreach (var (name, _) in Ui.Fonts.JapaneseFonts)
|
||||||
Mutable.JapaneseFont = name;
|
{
|
||||||
|
if (ImGui.Selectable(name, Mutable.JapaneseFont == name))
|
||||||
|
Mutable.JapaneseFont = name;
|
||||||
|
|
||||||
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name)
|
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name)
|
||||||
ImGui.SetScrollHereY(0.5f);
|
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));
|
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)
|
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 (combo)
|
||||||
if (ImGui.Selectable(language.Name()))
|
{
|
||||||
Mutable.LanguageOverride = language;
|
foreach (var language in Enum.GetValues<LanguageOverride>())
|
||||||
|
if (ImGui.Selectable(language.Name()))
|
||||||
ImGui.EndCombo();
|
Mutable.LanguageOverride = language;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName));
|
ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName));
|
||||||
ImGui.Spacing();
|
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 (combo)
|
||||||
if (ImGui.Selectable(side.Name(), Mutable.CommandHelpSide == side))
|
{
|
||||||
Mutable.CommandHelpSide = side;
|
foreach (var side in Enum.GetValues<CommandHelpSide>())
|
||||||
|
if (ImGui.Selectable(side.Name(), Mutable.CommandHelpSide == side))
|
||||||
ImGui.EndCombo();
|
Mutable.CommandHelpSide = side;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiUtil.HelpText(string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName));
|
ImGuiUtil.HelpText(string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName));
|
||||||
ImGui.Spacing();
|
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))
|
foreach (var mode in Enum.GetValues<KeybindMode>())
|
||||||
Mutable.KeybindMode = mode;
|
{
|
||||||
|
if (ImGui.Selectable(mode.Name(), Mutable.KeybindMode == mode))
|
||||||
|
Mutable.KeybindMode = mode;
|
||||||
|
|
||||||
if (ImGui.IsItemHovered())
|
if (ImGui.IsItemHovered())
|
||||||
ImGui.SetTooltip(mode.Tooltip());
|
ImGui.SetTooltip(mode.Tooltip());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndCombo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiUtil.HelpText(string.Format(Language.Options_KeybindMode_Description, Plugin.PluginName));
|
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);
|
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))
|
foreach (var mode in Enum.GetValues<UnreadMode>())
|
||||||
tab.UnreadMode = mode;
|
{
|
||||||
|
if (ImGui.Selectable(mode.Name(), tab.UnreadMode == mode))
|
||||||
|
tab.UnreadMode = mode;
|
||||||
|
|
||||||
if (mode.Tooltip() is { } tooltip && ImGui.IsItemHovered())
|
if (mode.Tooltip() is { } tooltip && ImGui.IsItemHovered())
|
||||||
ImGui.SetTooltip(tooltip);
|
ImGui.SetTooltip(tooltip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndCombo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var input = tab.Channel?.ToChatType().Name() ?? Language.Options_Tabs_NoInputChannel;
|
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))
|
if (combo)
|
||||||
tab.Channel = null;
|
{
|
||||||
|
if (ImGui.Selectable(Language.Options_Tabs_NoInputChannel, tab.Channel == null))
|
||||||
|
tab.Channel = null;
|
||||||
|
|
||||||
foreach (var channel in Enum.GetValues<InputChannel>())
|
foreach (var channel in Enum.GetValues<InputChannel>())
|
||||||
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel))
|
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel))
|
||||||
tab.Channel = channel;
|
tab.Channel = channel;
|
||||||
|
}
|
||||||
ImGui.EndCombo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var channelNode = ImRaii.TreeNode(Language.Options_Tabs_Channels))
|
using (var channelNode = ImRaii.TreeNode(Language.Options_Tabs_Channels))
|
||||||
|
|||||||
+30
-35
@@ -12,7 +12,7 @@ namespace ChatTwo.Util;
|
|||||||
|
|
||||||
internal static class ImGuiUtil
|
internal static class ImGuiUtil
|
||||||
{
|
{
|
||||||
private static Plugin Plugin;
|
private static Plugin Plugin = null!;
|
||||||
|
|
||||||
public static void Initialize(Plugin plugin)
|
public static void Initialize(Plugin plugin)
|
||||||
{
|
{
|
||||||
@@ -26,22 +26,22 @@ internal static class ImGuiUtil
|
|||||||
ImGuiMouseButton.Right
|
ImGuiMouseButton.Right
|
||||||
];
|
];
|
||||||
|
|
||||||
private static Payload? _hovered;
|
private static Payload? Hovered;
|
||||||
private static Payload? _lastLink;
|
private static Payload? LastLink;
|
||||||
private static readonly List<(Vector2, Vector2)> PayloadBounds = new();
|
private static readonly List<(Vector2, Vector2)> PayloadBounds = [];
|
||||||
|
|
||||||
internal static void PostPayload(Chunk chunk, PayloadHandler? handler)
|
internal static void PostPayload(Chunk chunk, PayloadHandler? handler)
|
||||||
{
|
{
|
||||||
var payload = chunk.Link;
|
var payload = chunk.Link;
|
||||||
if (payload != null && ImGui.IsItemHovered())
|
if (payload != null && ImGui.IsItemHovered())
|
||||||
{
|
{
|
||||||
_hovered = payload;
|
Hovered = payload;
|
||||||
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||||
handler?.Hover(payload);
|
handler?.Hover(payload);
|
||||||
}
|
}
|
||||||
else if (!ReferenceEquals(_hovered, payload))
|
else if (!ReferenceEquals(Hovered, payload))
|
||||||
{
|
{
|
||||||
_hovered = null;
|
Hovered = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler == null)
|
if (handler == null)
|
||||||
@@ -61,12 +61,12 @@ internal static class ImGuiUtil
|
|||||||
ImGuiNative.igTextUnformatted(text, textEnd);
|
ImGuiNative.igTextUnformatted(text, textEnd);
|
||||||
PostPayload(chunk, handler);
|
PostPayload(chunk, handler);
|
||||||
|
|
||||||
if (!ReferenceEquals(_lastLink, chunk.Link))
|
if (!ReferenceEquals(LastLink, chunk.Link))
|
||||||
PayloadBounds.Clear();
|
PayloadBounds.Clear();
|
||||||
|
|
||||||
_lastLink = chunk.Link;
|
LastLink = chunk.Link;
|
||||||
|
|
||||||
if (_hovered != null && ReferenceEquals(_hovered, chunk.Link))
|
if (Hovered != null && ReferenceEquals(Hovered, chunk.Link))
|
||||||
{
|
{
|
||||||
defaultText.W = 0.25f;
|
defaultText.W = 0.25f;
|
||||||
var actualCol = ColourUtil.Vector4ToAbgr(defaultText);
|
var actualCol = ColourUtil.Vector4ToAbgr(defaultText);
|
||||||
@@ -78,14 +78,14 @@ internal static class ImGuiUtil
|
|||||||
PayloadBounds.Clear();
|
PayloadBounds.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_hovered == null && chunk.Link != null)
|
if (Hovered == null && chunk.Link != null)
|
||||||
PayloadBounds.Add((oldPos, ImGui.GetItemRectSize()));
|
PayloadBounds.Add((oldPos, ImGui.GetItemRectSize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (csText.Length == 0)
|
if (csText.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var part in csText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
|
foreach (var part in csText.Split(["\r\n", "\r", "\n"], StringSplitOptions.None))
|
||||||
{
|
{
|
||||||
var bytes = Encoding.UTF8.GetBytes(part);
|
var bytes = Encoding.UTF8.GetBytes(part);
|
||||||
fixed (byte* rawText = bytes)
|
fixed (byte* rawText = bytes)
|
||||||
@@ -199,17 +199,11 @@ internal static class ImGuiUtil
|
|||||||
internal static void HelpText(string text)
|
internal static void HelpText(string text)
|
||||||
{
|
{
|
||||||
var colour = ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled];
|
var colour = ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled];
|
||||||
ImGui.PushStyleColor(ImGuiCol.Text, colour);
|
using (ImRaii.PushColor(ImGuiCol.Text, colour))
|
||||||
ImGui.PushTextWrapPos();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
|
ImGui.PushTextWrapPos();
|
||||||
ImGui.TextUnformatted(text);
|
ImGui.TextUnformatted(text);
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
ImGui.PopTextWrapPos();
|
ImGui.PopTextWrapPos();
|
||||||
ImGui.PopStyleColor();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,22 +211,26 @@ internal static class ImGuiUtil
|
|||||||
{
|
{
|
||||||
var style = StyleModel.GetConfiguredStyle() ?? StyleModel.GetFromCurrent();
|
var style = StyleModel.GetConfiguredStyle() ?? StyleModel.GetFromCurrent();
|
||||||
var dalamudOrange = style.BuiltInColors?.DalamudOrange;
|
var dalamudOrange = style.BuiltInColors?.DalamudOrange;
|
||||||
if (dalamudOrange != null)
|
|
||||||
ImGui.PushStyleColor(ImGuiCol.Text, dalamudOrange.Value);
|
|
||||||
|
|
||||||
if (wrap) ImGui.PushTextWrapPos();
|
var push = dalamudOrange != null;
|
||||||
ImGui.TextUnformatted(text);
|
var color = dalamudOrange ?? Vector4.Zero;
|
||||||
if (wrap) ImGui.PopTextWrapPos();
|
using (ImRaii.PushColor(ImGuiCol.Text, color, push))
|
||||||
|
{
|
||||||
|
if (wrap)
|
||||||
|
ImGui.PushTextWrapPos();
|
||||||
|
|
||||||
if (dalamudOrange != null)
|
ImGui.TextUnformatted(text);
|
||||||
ImGui.PopStyleColor();
|
|
||||||
|
if (wrap)
|
||||||
|
ImGui.PopTextWrapPos();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool BeginComboVertical(string label, string previewValue, ImGuiComboFlags flags = ImGuiComboFlags.None)
|
internal static ImRaii.IEndObject BeginComboVertical(string label, string previewValue, ImGuiComboFlags flags = ImGuiComboFlags.None)
|
||||||
{
|
{
|
||||||
ImGui.TextUnformatted(label);
|
ImGui.TextUnformatted(label);
|
||||||
ImGui.SetNextItemWidth(-1);
|
ImGui.SetNextItemWidth(-1);
|
||||||
return ImGui.BeginCombo($"##{label}", previewValue, flags);
|
return ImRaii.Combo($"##{label}", previewValue, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool DragFloatVertical(string label, ref float value, float vSpeed = 1.0f, float vMin = float.MinValue, float vMax = float.MaxValue, string? format = null, ImGuiSliderFlags flags = ImGuiSliderFlags.None)
|
internal static bool DragFloatVertical(string label, ref float value, float vSpeed = 1.0f, float vMin = float.MinValue, float vMax = float.MaxValue, string? format = null, ImGuiSliderFlags flags = ImGuiSliderFlags.None)
|
||||||
@@ -265,13 +263,10 @@ internal static class ImGuiUtil
|
|||||||
internal static bool CtrlShiftButton(string label, string tooltip = "")
|
internal static bool CtrlShiftButton(string label, string tooltip = "")
|
||||||
{
|
{
|
||||||
var ctrlShiftHeld = ImGui.GetIO() is { KeyCtrl: true, KeyShift: true };
|
var ctrlShiftHeld = ImGui.GetIO() is { KeyCtrl: true, KeyShift: true };
|
||||||
if (!ctrlShiftHeld)
|
|
||||||
ImGui.BeginDisabled();
|
|
||||||
|
|
||||||
var ret = ImGui.Button(label) && ctrlShiftHeld;
|
bool ret;
|
||||||
|
using (ImRaii.Disabled(!ctrlShiftHeld))
|
||||||
if (!ctrlShiftHeld)
|
ret = ImGui.Button(label) && ctrlShiftHeld;
|
||||||
ImGui.EndDisabled();
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(tooltip) && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
if (!string.IsNullOrEmpty(tooltip) && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
||||||
ImGui.SetTooltip(tooltip);
|
ImGui.SetTooltip(tooltip);
|
||||||
|
|||||||
Reference in New Issue
Block a user