diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs
index de6e017..7fbe619 100755
--- a/ChatTwo/Configuration.cs
+++ b/ChatTwo/Configuration.cs
@@ -25,6 +25,7 @@ internal class Configuration : IPluginConfiguration
public bool HideSameTimestamps;
public bool ShowNoviceNetwork;
public bool SidebarTabView;
+ public PreviewPosition PreviewPosition = PreviewPosition.Inside;
public CommandHelpSide CommandHelpSide = CommandHelpSide.None;
public KeybindMode KeybindMode = KeybindMode.Strict;
public LanguageOverride LanguageOverride = LanguageOverride.None;
@@ -78,6 +79,7 @@ internal class Configuration : IPluginConfiguration
HideSameTimestamps = other.HideSameTimestamps;
ShowNoviceNetwork = other.ShowNoviceNetwork;
SidebarTabView = other.SidebarTabView;
+ PreviewPosition = other.PreviewPosition;
CommandHelpSide = other.CommandHelpSide;
KeybindMode = other.KeybindMode;
LanguageOverride = other.LanguageOverride;
@@ -238,6 +240,27 @@ internal class Tab
}
}
+[Serializable]
+internal enum PreviewPosition
+{
+ None,
+ Inside,
+ Top,
+ Bottom,
+}
+
+internal static class PreviewPositionExt
+{
+ internal static string Name(this PreviewPosition position) => position switch
+ {
+ PreviewPosition.None => Language.Options_Preview_None,
+ PreviewPosition.Inside => Language.Options_Preview_Inside,
+ PreviewPosition.Top => Language.Options_Preview_Top,
+ PreviewPosition.Bottom => Language.Options_Preview_Bottom,
+ _ => throw new ArgumentOutOfRangeException(nameof(position), position, null),
+ };
+}
+
[Serializable]
internal enum CommandHelpSide
{
diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs
index 85d8b8a..95f9f51 100755
--- a/ChatTwo/Resources/Language.Designer.cs
+++ b/ChatTwo/Resources/Language.Designer.cs
@@ -2390,6 +2390,69 @@ namespace ChatTwo.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Bottom.
+ ///
+ internal static string Options_Preview_Bottom {
+ get {
+ return ResourceManager.GetString("Options_Preview_Bottom", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to A preview wih all emote, auto-translate encoded as they appear in chat.
+ ///
+ internal static string Options_Preview_Description {
+ get {
+ return ResourceManager.GetString("Options_Preview_Description", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Text Preview:.
+ ///
+ internal static string Options_Preview_Header {
+ get {
+ return ResourceManager.GetString("Options_Preview_Header", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Inside.
+ ///
+ internal static string Options_Preview_Inside {
+ get {
+ return ResourceManager.GetString("Options_Preview_Inside", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Input preview.
+ ///
+ internal static string Options_Preview_Name {
+ get {
+ return ResourceManager.GetString("Options_Preview_Name", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to None.
+ ///
+ internal static string Options_Preview_None {
+ get {
+ return ResourceManager.GetString("Options_Preview_None", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Top.
+ ///
+ internal static string Options_Preview_Top {
+ get {
+ return ResourceManager.GetString("Options_Preview_Top", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Replaces words with their emote version, currently supports BetterTTV.
///
diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx
index ec4994a..f3e7052 100644
--- a/ChatTwo/Resources/Language.resx
+++ b/ChatTwo/Resources/Language.resx
@@ -1051,4 +1051,25 @@
Emotes available:
+
+ A preview wih all emote, auto-translate encoded as they appear in chat
+
+
+ Input preview
+
+
+ None
+
+
+ Inside
+
+
+ Top
+
+
+ Bottom
+
+
+ Text Preview:
+
diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs
index 09fc872..5d2815b 100644
--- a/ChatTwo/Ui/ChatLogWindow.cs
+++ b/ChatTwo/Ui/ChatLogWindow.cs
@@ -521,7 +521,7 @@ public sealed class ChatLogWindow : Window
// TODO: I hate this predraw thing
PreviewHeight = 0;
Message? predrawnMessage = null;
- if (!string.IsNullOrEmpty(Chat))
+ if (Plugin.Config.PreviewPosition is PreviewPosition.Inside && !string.IsNullOrEmpty(Chat))
{
var bytes = Encoding.UTF8.GetBytes(Chat.Trim());
AutoTranslate.ReplaceWithPayload(Plugin.DataManager, ref bytes);
@@ -534,7 +534,7 @@ public sealed class ChatLogWindow : Window
var before = ImGui.GetCursorPosY();
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero))
{
- ImGui.TextUnformatted("Text Preview:");
+ ImGui.TextUnformatted(Language.Options_Preview_Header);
DrawChunks(predrawnMessage.Content);
}
var after = ImGui.GetCursorPosY();
diff --git a/ChatTwo/Ui/InputPreview.cs b/ChatTwo/Ui/InputPreview.cs
index 82ce60e..ca274b3 100644
--- a/ChatTwo/Ui/InputPreview.cs
+++ b/ChatTwo/Ui/InputPreview.cs
@@ -1,4 +1,3 @@
-using System.Numerics;
using System.Text;
using ChatTwo.Code;
using ChatTwo.Util;
@@ -14,7 +13,6 @@ public class InputPreview : Window
private ChatLogWindow LogWindow { get; }
private float Height;
- private float AppliedHeight;
internal InputPreview(ChatLogWindow logWindow) : base("##chat2-inputpreview")
{
@@ -31,25 +29,25 @@ public class InputPreview : Window
public override void PreDraw()
{
- // ReSharper disable once CompareOfFloatsByEqualityOperator
- // Sizes don't use much precision
- if (AppliedHeight == Height)
- return;
-
- AppliedHeight = Height;
-
- var width = LogWindow.LastWindowSize.X;
var pos = LogWindow.LastWindowPos;
+ var size = LogWindow.LastWindowSize;
- Size = new Vector2(width, Height);
+ Size = size with { Y = Height };
- Position = pos with { Y = pos.Y - Height };
+ var y = Plugin.Config.PreviewPosition switch
+ {
+ PreviewPosition.Top => pos.Y - Height,
+ PreviewPosition.Bottom => pos.Y + size.Y,
+ _ => throw new ArgumentOutOfRangeException(nameof(Plugin.Config.PreviewPosition), Plugin.Config.PreviewPosition, null)
+ };
+
+ Position = pos with { Y = y };
PositionCondition = ImGuiCond.Always;
}
public override bool DrawConditions()
{
- return !string.IsNullOrEmpty(LogWindow.Chat);
+ return Plugin.Config.PreviewPosition is PreviewPosition.Top or PreviewPosition.Bottom && !string.IsNullOrEmpty(LogWindow.Chat);
}
public override void Draw()
diff --git a/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs b/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs
index 2fee8d6..03944f3 100755
--- a/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs
+++ b/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs
@@ -24,6 +24,19 @@ internal sealed class Miscellaneous(Configuration mutable) : ISettingsTab
ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName));
ImGui.Spacing();
+ using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Preview_Name, Mutable.PreviewPosition.Name()))
+ {
+ if (combo)
+ {
+ foreach (var position in Enum.GetValues())
+ if (ImGui.Selectable(position.Name(), Mutable.PreviewPosition == position))
+ Mutable.PreviewPosition = position;
+ }
+ }
+
+ ImGuiUtil.HelpText(Language.Options_Preview_Description);
+ ImGui.Spacing();
+
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, Mutable.CommandHelpSide.Name()))
{
if (combo)