Replace all PushTextWrapPos with using version
This commit is contained in:
@@ -33,7 +33,7 @@ internal sealed class About : ISettingsTab
|
|||||||
|
|
||||||
public void Draw(bool changed)
|
public void Draw(bool changed)
|
||||||
{
|
{
|
||||||
ImGui.PushTextWrapPos();
|
using var wrap = ImGuiUtil.TextWrapPos();
|
||||||
|
|
||||||
ImGui.TextUnformatted(string.Format(Language.Options_About_Opening, Plugin.PluginName));
|
ImGui.TextUnformatted(string.Format(Language.Options_About_Opening, Plugin.PluginName));
|
||||||
|
|
||||||
@@ -93,8 +93,6 @@ internal sealed class About : ISettingsTab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
ImGui.PopTextWrapPos();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,63 +21,63 @@ internal sealed class ChatLog : ISettingsTab
|
|||||||
|
|
||||||
public void Draw(bool changed)
|
public void Draw(bool changed)
|
||||||
{
|
{
|
||||||
ImGui.PushTextWrapPos();
|
using (ImGuiUtil.TextWrapPos())
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.KeepInputFocus, Language.Options_KeepInputFocus_Name, Language.Options_KeepInputFocus_Description);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.PlaySounds, Language.Options_PlaySounds_Name, Language.Options_PlaySounds_Description);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.SidebarTabView, Language.Options_SidebarTabView_Name, string.Format(Language.Options_SidebarTabView_Description, Plugin.PluginName));
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.NativeItemTooltips, Language.Options_NativeItemTooltips_Name, string.Format(Language.Options_NativeItemTooltips_Description, Plugin.PluginName));
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
if (Mutable.NativeItemTooltips)
|
|
||||||
{
|
{
|
||||||
ImGuiUtil.DragFloatVertical(Language.Options_TooltipOffset_Name, Language.Options_TooltipOffset_Desc, ref Mutable.TooltipOffset, 1, 0f, 400f, $"{Mutable.TooltipOffset:N0}px", ImGuiSliderFlags.AlwaysClamp);
|
ImGuiUtil.OptionCheckbox(ref Mutable.KeepInputFocus, Language.Options_KeepInputFocus_Name, Language.Options_KeepInputFocus_Description);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGuiUtil.OptionCheckbox(ref Mutable.PlaySounds, Language.Options_PlaySounds_Name, Language.Options_PlaySounds_Description);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGuiUtil.OptionCheckbox(ref Mutable.SidebarTabView, Language.Options_SidebarTabView_Name, string.Format(Language.Options_SidebarTabView_Description, Plugin.PluginName));
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGuiUtil.OptionCheckbox(ref Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGuiUtil.OptionCheckbox(ref Mutable.NativeItemTooltips, Language.Options_NativeItemTooltips_Name, string.Format(Language.Options_NativeItemTooltips_Description, Plugin.PluginName));
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
if (Mutable.NativeItemTooltips)
|
||||||
|
{
|
||||||
|
ImGuiUtil.DragFloatVertical(Language.Options_TooltipOffset_Name, Language.Options_TooltipOffset_Desc, ref Mutable.TooltipOffset, 1, 0f, 400f, $"{Mutable.TooltipOffset:N0}px", ImGuiSliderFlags.AlwaysClamp);
|
||||||
|
ImGui.Spacing();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGuiUtil.DragFloatVertical(Language.Options_WindowOpacity_Name, ref Mutable.WindowAlpha, .25f, 0f, 100f, $"{Mutable.WindowAlpha:N2}%%", ImGuiSliderFlags.AlwaysClamp);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
if (ImGuiUtil.InputIntVertical(Language.Options_MaxLinesToShow_Name, Language.Options_MaxLinesToShow_Description, ref Mutable.MaxLinesToRender)) Mutable.MaxLinesToRender = Math.Clamp(Mutable.MaxLinesToRender, 1, 10_000);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGuiUtil.OptionCheckbox(ref Mutable.CanMove, Language.Options_CanMove_Name);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGuiUtil.OptionCheckbox(ref Mutable.CanResize, Language.Options_CanResize_Name);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGuiUtil.OptionCheckbox(ref Mutable.ShowTitleBar, Language.Options_ShowTitleBar_Name);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGuiUtil.OptionCheckbox(ref Mutable.ShowPopOutTitleBar, Language.Options_ShowPopOutTitleBar_Name);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGuiUtil.OptionCheckbox(ref Mutable.OverrideStyle, Language.Options_OverrideStyle_Name, Language.Options_OverrideStyle_Name_Desc);
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
|
ImGui.Separator();
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGui.TextUnformatted(Language.Options_AdjustPosition_Name);
|
||||||
|
var pos = Plugin.ChatLogWindow.LastWindowPos;
|
||||||
|
ImGui.SetNextItemWidth(-1);
|
||||||
|
if (ImGui.DragFloat2($"##{Language.Options_AdjustPosition_Name}", ref pos, 1, 0, float.MaxValue, "%.0fpx"))
|
||||||
|
Plugin.ChatLogWindow.Position = pos;
|
||||||
|
ImGuiUtil.WarningText(Language.Options_AdjustPosition_Warning);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiUtil.DragFloatVertical(Language.Options_WindowOpacity_Name, ref Mutable.WindowAlpha, .25f, 0f, 100f, $"{Mutable.WindowAlpha:N2}%%", ImGuiSliderFlags.AlwaysClamp);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
if (ImGuiUtil.InputIntVertical(Language.Options_MaxLinesToShow_Name, Language.Options_MaxLinesToShow_Description, ref Mutable.MaxLinesToRender)) Mutable.MaxLinesToRender = Math.Clamp(Mutable.MaxLinesToRender, 1, 10_000);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.CanMove, Language.Options_CanMove_Name);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.CanResize, Language.Options_CanResize_Name);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.ShowTitleBar, Language.Options_ShowTitleBar_Name);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.ShowPopOutTitleBar, Language.Options_ShowPopOutTitleBar_Name);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.OverrideStyle, Language.Options_OverrideStyle_Name, Language.Options_OverrideStyle_Name_Desc);
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGui.Spacing();
|
|
||||||
ImGui.Separator();
|
|
||||||
ImGui.Spacing();
|
|
||||||
|
|
||||||
ImGui.TextUnformatted(Language.Options_AdjustPosition_Name);
|
|
||||||
var pos = Plugin.ChatLogWindow.LastWindowPos;
|
|
||||||
ImGui.SetNextItemWidth(-1);
|
|
||||||
if (ImGui.DragFloat2($"##{Language.Options_AdjustPosition_Name}", ref pos, 1, 0, float.MaxValue, "%.0fpx"))
|
|
||||||
Plugin.ChatLogWindow.Position = pos;
|
|
||||||
ImGuiUtil.WarningText(Language.Options_AdjustPosition_Warning);
|
|
||||||
ImGui.Spacing();
|
|
||||||
ImGui.PopTextWrapPos();
|
|
||||||
|
|
||||||
if (!Mutable.OverrideStyle)
|
if (!Mutable.OverrideStyle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -147,9 +147,9 @@ internal sealed class Database : ISettingsTab
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
using var treeNode = ImRaii.TreeNode(Language.Options_Database_Advanced);
|
using var treeNode = ImRaii.TreeNode(Language.Options_Database_Advanced);
|
||||||
ImGui.PushTextWrapPos();
|
using var wrap = ImGuiUtil.TextWrapPos();
|
||||||
ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);
|
|
||||||
|
|
||||||
|
ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);
|
||||||
if (ImGuiUtil.CtrlShiftButton("Perform maintenance", "Ctrl+Shift: MessageManager.Store.PerformMaintenance()"))
|
if (ImGuiUtil.CtrlShiftButton("Perform maintenance", "Ctrl+Shift: MessageManager.Store.PerformMaintenance()"))
|
||||||
Plugin.MessageManager.Store.PerformMaintenance();
|
Plugin.MessageManager.Store.PerformMaintenance();
|
||||||
|
|
||||||
@@ -161,8 +161,6 @@ internal sealed class Database : ISettingsTab
|
|||||||
|
|
||||||
if (ImGuiUtil.CtrlShiftButton("Inject 10,000 messages", "Ctrl+Shift: creates 10,000 unique messages (async)"))
|
if (ImGuiUtil.CtrlShiftButton("Inject 10,000 messages", "Ctrl+Shift: creates 10,000 unique messages (async)"))
|
||||||
new Thread(() => InsertMessages(10_000)).Start();
|
new Thread(() => InsertMessages(10_000)).Start();
|
||||||
|
|
||||||
ImGui.PopTextWrapPos();
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ internal sealed class Display : ISettingsTab
|
|||||||
|
|
||||||
public void Draw(bool changed)
|
public void Draw(bool changed)
|
||||||
{
|
{
|
||||||
ImGui.PushTextWrapPos();
|
using var wrap = ImGuiUtil.TextWrapPos();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.HideChat, Language.Options_HideChat_Name, Language.Options_HideChat_Description);
|
ImGuiUtil.OptionCheckbox(ref Mutable.HideChat, Language.Options_HideChat_Name, Language.Options_HideChat_Description);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
@@ -52,7 +52,5 @@ internal sealed class Display : ISettingsTab
|
|||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.CollapseDuplicateMessages, Language.Options_CollapseDuplicateMessages_Name, Language.Options_CollapseDuplicateMessages_Description);
|
ImGuiUtil.OptionCheckbox(ref Mutable.CollapseDuplicateMessages, Language.Options_CollapseDuplicateMessages_Name, Language.Options_CollapseDuplicateMessages_Description);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
ImGui.PopTextWrapPos();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ internal sealed class Emote : ISettingsTab
|
|||||||
|
|
||||||
public void Draw(bool changed)
|
public void Draw(bool changed)
|
||||||
{
|
{
|
||||||
ImGui.PushTextWrapPos();
|
using var wrap = ImGuiUtil.TextWrapPos();
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref Mutable.ShowEmotes, Language.Options_ShowEmotes_Name, Language.Options_ShowEmotes_Desc);
|
ImGuiUtil.OptionCheckbox(ref Mutable.ShowEmotes, Language.Options_ShowEmotes_Name, Language.Options_ShowEmotes_Desc);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
@@ -109,7 +109,5 @@ internal sealed class Emote : ISettingsTab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.PopTextWrapPos();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class Fonts : ISettingsTab
|
|||||||
if (changed)
|
if (changed)
|
||||||
UpdateFonts();
|
UpdateFonts();
|
||||||
|
|
||||||
ImGui.PushTextWrapPos();
|
using var wrap = ImGuiUtil.TextWrapPos();
|
||||||
|
|
||||||
ImGui.Checkbox(Language.Options_FontsEnabled, ref Mutable.FontsEnabled);
|
ImGui.Checkbox(Language.Options_FontsEnabled, ref Mutable.FontsEnabled);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
@@ -118,6 +118,5 @@ public class Fonts : ISettingsTab
|
|||||||
ImGuiUtil.HelpText(Language.Options_SymbolsFontSize_Description);
|
ImGuiUtil.HelpText(Language.Options_SymbolsFontSize_Description);
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
ImGui.PopTextWrapPos();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-10
@@ -200,11 +200,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];
|
||||||
|
|
||||||
|
using (TextWrapPos())
|
||||||
using (ImRaii.PushColor(ImGuiCol.Text, colour))
|
using (ImRaii.PushColor(ImGuiCol.Text, colour))
|
||||||
{
|
{
|
||||||
ImGui.PushTextWrapPos();
|
|
||||||
ImGui.TextUnformatted(text);
|
ImGui.TextUnformatted(text);
|
||||||
ImGui.PopTextWrapPos();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,15 +215,11 @@ internal static class ImGuiUtil
|
|||||||
|
|
||||||
var push = dalamudOrange != null;
|
var push = dalamudOrange != null;
|
||||||
var color = dalamudOrange ?? Vector4.Zero;
|
var color = dalamudOrange ?? Vector4.Zero;
|
||||||
|
|
||||||
|
using (TextWrapPos(wrap))
|
||||||
using (ImRaii.PushColor(ImGuiCol.Text, color, push))
|
using (ImRaii.PushColor(ImGuiCol.Text, color, push))
|
||||||
{
|
{
|
||||||
if (wrap)
|
|
||||||
ImGui.PushTextWrapPos();
|
|
||||||
|
|
||||||
ImGui.TextUnformatted(text);
|
ImGui.TextUnformatted(text);
|
||||||
|
|
||||||
if (wrap)
|
|
||||||
ImGui.PopTextWrapPos();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,9 +438,15 @@ internal static class ImGuiUtil
|
|||||||
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
|
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImRaii.IEndObject TextWrapPos(float wrapLocalPosX)
|
public static ImRaii.IEndObject TextWrapPos(bool condition)
|
||||||
{
|
{
|
||||||
ImGui.PushTextWrapPos(wrapLocalPosX);
|
if (!condition)
|
||||||
|
return new EndUnconditionally(Nop, false);
|
||||||
|
|
||||||
|
ImGui.PushTextWrapPos();
|
||||||
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
|
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used to avoid pops if condition is false for Push.
|
||||||
|
private static void Nop() { }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user