Merge branch 'main' into dean/extrachat-input-channels

This commit is contained in:
Infi
2024-04-10 19:13:02 +02:00
committed by GitHub
43 changed files with 1529 additions and 479 deletions
+3 -3
View File
@@ -6,8 +6,8 @@ internal class AutoCompleteInfo {
internal int EndPos { get; }
internal AutoCompleteInfo(string toComplete, int startPos, int endPos) {
this.ToComplete = toComplete;
this.StartPos = startPos;
this.EndPos = endPos;
ToComplete = toComplete;
StartPos = startPos;
EndPos = endPos;
}
}
+33 -18
View File
@@ -13,6 +13,7 @@ using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Style;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing;
using Dalamud.Memory;
@@ -75,12 +76,8 @@ public sealed class ChatLogWindow : Window, IUiComponent {
Plugin = plugin;
Salt = new Random().Next().ToString();
Size = new Vector2(500, 250);
SizeCondition = ImGuiCond.FirstUseEver;
SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(500, 250),
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
};
PayloadHandler = new PayloadHandler(this);
HandlerLender = new Lender<PayloadHandler>(() => new PayloadHandler(this));
@@ -100,6 +97,24 @@ public sealed class ChatLogWindow : Window, IUiComponent {
Plugin.AddonLifecycle.RegisterListener(AddonEvent.PostRequestedUpdate, "ItemDetail", PayloadHandler.MoveTooltip);
}
public override void PreDraw()
{
if (Plugin.Config.OverrideStyle)
{
var styles = StyleModel.GetConfiguredStyles();
styles?.First(style => style.Name.Equals(Plugin.Config.ChosenStyle)).Push();
}
}
public override void PostDraw()
{
if (Plugin.Config.OverrideStyle)
{
var styles = StyleModel.GetConfiguredStyles();
styles?.First(style => style.Name.Equals(Plugin.Config.ChosenStyle)).Pop();
}
}
public void Dispose() {
Plugin.AddonLifecycle.UnregisterListener(AddonEvent.PostRequestedUpdate, "ItemDetail", PayloadHandler.MoveTooltip);
Plugin.ClientState.Logout -= Logout;
@@ -1292,10 +1307,8 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|| cmd.Alias.RawString == command
|| cmd.ShortCommand.RawString == command
|| cmd.ShortAlias.RawString == command);
if (cmd != null) {
if (cmd != null)
Plugin.CommandHelpWindow.UpdateContent(cmd);
Plugin.CommandHelpWindow.IsOpen = true;
}
}
if (data->EventFlag != ImGuiInputTextFlags.CallbackHistory) {
@@ -1367,18 +1380,20 @@ public sealed class ChatLogWindow : Window, IUiComponent {
private void DrawChunk(Chunk chunk, bool wrap = true, PayloadHandler? handler = null, float lineWidth = 0f) {
if (chunk is IconChunk icon && _fontIcon != null) {
var bounds = IconUtil.GetBounds((byte) icon.Icon);
if (bounds != null) {
var texSize = new Vector2(_fontIcon.Width, _fontIcon.Height);
var bounds = IconUtil.GfdFileView.TryGetEntry((uint) icon.Icon, out var entry);
if (!bounds)
return;
var sizeRatio = Plugin.Config.FontSize / bounds.Value.W;
var size = new Vector2(bounds.Value.Z, bounds.Value.W) * sizeRatio * ImGuiHelpers.GlobalScale;
var texSize = new Vector2(_fontIcon.Width, _fontIcon.Height);
var uv0 = new Vector2(bounds.Value.X, bounds.Value.Y - 2) / texSize;
var uv1 = new Vector2(bounds.Value.X + bounds.Value.Z, bounds.Value.Y - 2 + bounds.Value.W) / texSize;
ImGui.Image(_fontIcon.ImGuiHandle, size, uv0, uv1);
ImGuiUtil.PostPayload(chunk, handler);
}
var sizeRatio = Plugin.Config.FontSize / entry.Height;
var size = new Vector2(entry.Width, entry.Height) * sizeRatio * ImGuiHelpers.GlobalScale;
var uv0 = new Vector2(entry.Left, entry.Top + 170) * 2 / texSize;
var uv1 = new Vector2(entry.Left + entry.Width, entry.Top + entry.Height + 170) * 2 / texSize;
ImGui.Image(_fontIcon.ImGuiHandle, size, uv0, uv1);
ImGuiUtil.PostPayload(chunk, handler);
return;
}
+4
View File
@@ -20,6 +20,7 @@ public class CommandHelpWindow : Window {
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.AlwaysAutoResize;
}
// Sets IsOpen to true if it should be drawn
public void UpdateContent(TextCommand command)
{
Command = command;
@@ -36,6 +37,7 @@ public class CommandHelpWindow : Window {
break;
case CommandHelpSide.None:
default:
IsOpen = false;
return;
}
@@ -45,6 +47,8 @@ public class CommandHelpWindow : Window {
MinimumSize = new Vector2(width, 0),
MaximumSize = LogWindow.LastWindowSize with { X = width }
};
IsOpen = true;
}
public override void Draw()
+6 -6
View File
@@ -169,7 +169,7 @@ internal sealed class FaceData {
internal byte[] Data { get; }
internal FaceData(byte[] data) {
this.Data = data;
Data = data;
}
}
@@ -178,8 +178,8 @@ internal sealed class FontData {
internal FaceData? Italic { get; }
internal FontData(FaceData regular, FaceData? italic) {
this.Regular = regular;
this.Italic = italic;
Regular = regular;
Italic = italic;
}
}
@@ -189,8 +189,8 @@ internal sealed class Font {
internal string ResourcePathItalic { get; }
internal Font(string name, string resourcePath, string resourcePathItalic) {
this.Name = name;
this.ResourcePath = resourcePath;
this.ResourcePathItalic = resourcePathItalic;
Name = name;
ResourcePath = resourcePath;
ResourcePathItalic = resourcePathItalic;
}
}
+14 -6
View File
@@ -1,4 +1,5 @@
using System.Numerics;
using Dalamud.Interface.Style;
using Dalamud.Interface.Windowing;
using ImGuiNET;
@@ -16,16 +17,17 @@ internal class Popout : Window
Tab = tab;
Idx = idx;
Size = new Vector2(350, 350);
SizeCondition = ImGuiCond.FirstUseEver;
SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(350, 350),
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
};
}
public override void PreDraw()
{
if (ChatLogWindow.Plugin.Config.OverrideStyle)
{
var styles = StyleModel.GetConfiguredStyles();
styles?.First(style => style.Name.Equals(ChatLogWindow.Plugin.Config.ChosenStyle)).Push();
}
Flags = ImGuiWindowFlags.None;
if (!ChatLogWindow.Plugin.Config.ShowPopOutTitleBar)
Flags |= ImGuiWindowFlags.NoTitleBar;
@@ -53,7 +55,13 @@ internal class Popout : Window
public override void PostDraw()
{
ChatLogWindow.PopOutDocked[Idx] = ImGui.IsWindowDocked();
if (ChatLogWindow.Plugin.Config.OverrideStyle)
{
var styles = StyleModel.GetConfiguredStyles();
styles?.First(style => style.Name.Equals(ChatLogWindow.Plugin.Config.ChosenStyle)).Pop();
}
}
public override void OnClose()
@@ -64,4 +72,4 @@ internal class Popout : Window
Tab.PopOut = false;
ChatLogWindow.Plugin.SaveConfig();
}
}
}
+323
View File
@@ -0,0 +1,323 @@
using System.Numerics;
using System.Text;
using ChatTwo.Util;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using DalamudPartyFinderPayload = Dalamud.Game.Text.SeStringHandling.Payloads.PartyFinderPayload;
namespace ChatTwo.Ui;
public class SeStringDebugger : Window
{
private readonly Plugin Plugin;
public SeStringDebugger(Plugin plugin) : base($"SeString Debugger###chat2-sestringdebugger")
{
Plugin = plugin;
SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(475, 600),
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
};
#if DEBUG
Plugin.Commands.Register("/chat2Debugger").Execute += Toggle;
#endif
}
public void Dispose()
{
#if DEBUG
Plugin.Commands.Register("/chat2Debugger").Execute -= Toggle;
#endif
}
private void Toggle(string _, string __) => Toggle();
public override void Draw()
{
ImGui.TextUnformatted("SeString Content");
ImGui.Spacing();
if (Plugin.Store.LastMessage.Message == null)
{
ImGui.TextUnformatted("Nothing to show");
return;
}
// TODO: Make SeString freely selectable through chat
foreach (var payload in Plugin.Store.LastMessage.Message.Payloads)
{
switch (payload)
{
case UIForegroundPayload color:
{
RenderMetadataDictionary("Link ForegroundColor", new Dictionary<string, string?>
{
{ "Enabled?", color.IsEnabled.ToString() },
{ "ColorKey", color.IsEnabled ? color.ColorKey.ToString() : "Color Ended" },
});
break;
}
case MapLinkPayload map:
{
RenderMetadataDictionary("Link MapLinkPayload", new Dictionary<string, string?>
{
{ "Map.RowId", map.Map?.RowId.ToString() },
{ "Map.PlaceName", map.Map?.PlaceName.Value?.Name.ToString() },
{ "Map.PlaceNameRegion", map.Map?.PlaceNameRegion.Value?.Name.ToString() },
{ "Map.PlaceNameSub", map.Map?.PlaceNameSub.Value?.Name.ToString() },
{ "TerritoryType.RowId", map.TerritoryType?.RowId.ToString() },
{ "RawX", map.RawX.ToString() },
{ "RawY", map.RawY.ToString() },
{ "XCoord", map.XCoord.ToString() },
{ "YCoord", map.YCoord.ToString() },
{ "CoordinateString", map.CoordinateString },
{ "DataString", map.DataString },
});
break;
}
case QuestPayload quest:
{
RenderMetadataDictionary("Link QuestPayload", new Dictionary<string, string?>
{
{ "Quest.RowId", quest.Quest?.RowId.ToString() },
{ "Quest.Name", quest.Quest?.Name.ToString() },
});
break;
}
case DalamudLinkPayload link:
{
RenderMetadataDictionary("Link DalamudLinkPayload", new Dictionary<string, string?>
{
{ "CommandId", link.CommandId.ToString() },
{ "Plugin", link.Plugin },
});
break;
}
case DalamudPartyFinderPayload pf:
{
RenderMetadataDictionary("Link PartyFinderPayload", new Dictionary<string, string?>
{
{ "ListingId", pf.ListingId.ToString() },
{ "LinkType", EnumName(pf.LinkType) },
});
break;
}
case PlayerPayload player:
{
RenderMetadataDictionary("Link PlayerPayload", new Dictionary<string, string?>
{
{ "Real", player.DisplayedName },
{ "PlayerName", player.PlayerName },
{ "World.Name", player.World.Name },
});
break;
}
case ItemPayload item:
{
RenderMetadataDictionary("Link ItemPayload", new Dictionary<string, string?>
{
{ "ItemId", item.ItemId.ToString() },
{ "RawItemId", item.RawItemId.ToString() },
{ "Kind", EnumName(item.Kind) },
{ "IsHQ", item.IsHQ.ToString() },
{ "Item.Name", item.Item?.Name.ToString() },
});
break;
}
case AutoTranslatePayload at:
{
RenderMetadataDictionary("Link AutoTranslatePayload", new Dictionary<string, string?>
{
{ "Text", at.Text },
});
break;
}
case IconPayload icon:
{
var found = IconUtil.GfdFileView.TryGetEntry((uint) icon.Icon, out var entry);
RenderMetadataDictionary("Link IconPayload", new Dictionary<string, string?>
{
{ "Found", found.ToString() },
{ "Icon ID", ((uint) icon.Icon).ToString() },
});
break;
}
case RawPayload raw:
{
var colorPayload = ColorPayload.From(raw.Data);
if (colorPayload != null)
{
var push = colorPayload.Enabled && colorPayload.Color != 0;
// if (push) ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(colorPayload.U));
RenderMetadataDictionary("Link ColorPayload", new Dictionary<string, string?>
{
{ "Unshifted", colorPayload.UnshiftedColor.ToString("X8") },
{ "Color", colorPayload.Color.ToString("X8") },
{ "Enabled?", colorPayload.Enabled.ToString() },
});
// if (push) ImGui.PopStyleColor();
}
else
{
RenderMetadataDictionary("Link RawPayload", new Dictionary<string, string?>
{
{ "Data", string.Join(" ", raw.Data.Select(b => b.ToString("X2"))) },
{ "Type", EnumName(raw.Type) },
});
}
break;
}
case StatusPayload status:
{
RenderMetadataDictionary("Link StatusPayload", new Dictionary<string, string?>
{
{ "Status.RowId", status.Status.RowId.ToString() },
{ "Status.Name", status.Status.Name },
{ "Status.Icon", status.Status.Icon.ToString() }
});
break;
}
case Util.PartyFinderPayload pf:
{
RenderMetadataDictionary("Link PartyFinderPayload", new Dictionary<string, string?>
{
{ "Id", pf.Id.ToString() }
});
break;
}
case AchievementPayload achievement:
{
RenderMetadataDictionary("Link AchievementPayload", new Dictionary<string, string?>
{
{ "Id", achievement.Id.ToString() }
});
break;
}
default:
var payloadData = payload.Encode();
var initialByte = payloadData.First();
if (initialByte != 0x02)
{
RenderMetadataDictionary("Text Payload", new Dictionary<string, string?>
{
{ "Content", Encoding.UTF8.GetString(payloadData) },
});
}
else
{
var unknown = new RawPayload(payloadData);
RenderMetadataDictionary("Link Unknown", new Dictionary<string, string?>
{
{ "Unknown", string.Join(" ", unknown.Data.Select(b => b.ToString("X2"))) },
});
}
break;
}
}
}
private static string? EnumName<T>(T? value) where T : Enum
{
if (value == null)
{
return null;
}
var rawValue = Convert.ChangeType(value, value.GetTypeCode());
return (Enum.GetName(value.GetType(), value) ?? "Unknown") + $" ({rawValue})";
}
private static void RenderMetadataDictionary(string name, Dictionary<string, string?> metadata)
{
var style = ImGui.GetStyle();
ImGui.Text($"{name}:");
ImGui.Indent(style.IndentSpacing);
if (!ImGui.BeginTable($"##chat3-{name}", 2, 0))
{
ImGui.EndTable();
ImGui.Unindent(style.IndentSpacing);
return;
}
ImGui.TableSetupColumn($"##chat3-{name}-key", 0, 0.4f);
ImGui.TableSetupColumn($"##chat3-{name}-value");
for (var i = 0; i < metadata.Count; i++)
{
var (key, value) = metadata.ElementAt(i);
ImGui.PushID(i);
ImGui.TableNextColumn();
ImGui.Text(key);
ImGui.TableNextColumn();
ImGuiTextVisibleWhitespace(value);
ImGui.PopID();
}
ImGui.EndTable();
ImGui.Unindent(style.IndentSpacing);
ImGui.NewLine();
}
// ImGuiTextVisibleWhitespace replaces leading and trailing whitespace with
// visible characters. The extra characters are rendered with a muted font.
private static void ImGuiTextVisibleWhitespace(string? original, bool wrap = true)
{
if (string.IsNullOrEmpty(original))
{
var str = original == null ? "(null)" : "(empty)";
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
ImGui.TextUnformatted(str);
ImGui.PopStyleColor();
return;
}
var text = original;
var start = 0;
var end = text.Length;
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
void WriteText(string text)
{
if (wrap)
{
ImGui.TextWrapped(text);
}
else
{
ImGui.TextUnformatted(text);
}
}
while (start < end && char.IsWhiteSpace(text[start]))
{
start++;
}
if (start > 0)
{
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
WriteText(new string('_', start));
ImGui.PopStyleColor();
ImGui.SameLine();
}
while (end > start && char.IsWhiteSpace(text[end - 1]))
{
end--;
}
WriteText(text[start..end]);
if (end < text.Length)
{
ImGui.SameLine();
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
WriteText(new string('_', text.Length - end));
ImGui.PopStyleColor();
}
ImGui.PopStyleVar();
}
}
+30 -12
View File
@@ -2,6 +2,8 @@ using System.Numerics;
using ChatTwo.Resources;
using ChatTwo.Util;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using ImGuiNET;
namespace ChatTwo.Ui.SettingsTabs;
@@ -31,23 +33,40 @@ internal sealed class About : ISettingsTab {
ImGui.TextUnformatted(string.Format(Language.Options_About_Opening, Plugin.PluginName));
ImGuiHelpers.ScaledDummy(10.0f);
ImGui.TextUnformatted(Language.Options_About_Authors);
ImGui.SameLine();
ImGui.TextColored(ImGuiColors.ParsedGold, Plugin.Authors);
ImGui.TextUnformatted(Language.Options_About_Discord);
ImGui.SameLine();
ImGui.TextColored(ImGuiColors.ParsedGold, "@infi");
ImGui.TextUnformatted(Language.Options_About_Version);
ImGui.SameLine();
ImGui.TextColored(ImGuiColors.ParsedOrange, Plugin.Version);
ImGuiHelpers.ScaledDummy(10.0f);
ImGui.TextUnformatted(Language.Options_About_Discord_Thread);
ImGui.SameLine();
if (ImGuiUtil.IconButton(FontAwesomeIcon.ExternalLinkAlt, "discordThread"))
Dalamud.Utility.Util.OpenLink("https://canary.discord.com/channels/581875019861328007/1224865018789761126");
ImGui.Spacing();
if (ImGuiUtil.IconButton(FontAwesomeIcon.ExternalLinkAlt, "clickup"))
{
Dalamud.Utility.Util.OpenLink("https://sharing.clickup.com/b/h/6-122378074-2/1047d21a39a4140");
}
ImGui.TextUnformatted(Language.Options_About_Github_Issues);
ImGui.SameLine();
ImGui.TextUnformatted(Language.Options_About_ClickUp);
if (ImGuiUtil.IconButton(FontAwesomeIcon.ExternalLinkAlt, "githubIssues"))
Dalamud.Utility.Util.OpenLink("https://github.com/Infiziert90/ChatTwo/issues");
ImGuiHelpers.ScaledDummy(10.0f);
ImGui.TextUnformatted(Language.Options_About_CrowdIn);
ImGui.SameLine();
if (ImGuiUtil.IconButton(FontAwesomeIcon.ExternalLinkAlt, "crowdin"))
{
Dalamud.Utility.Util.OpenLink("https://crowdin.com/project/chattwo");
}
ImGui.SameLine();
ImGui.TextUnformatted(string.Format(Language.Options_About_CrowdIn, Plugin.PluginName));
ImGui.Spacing();
@@ -68,7 +87,6 @@ internal sealed class About : ISettingsTab {
ImGui.EndChild();
}
ImGuiUtil.HelpText($"{Plugin.PluginName} v{GetType().Assembly.GetName().Version?.ToString(3)}");
ImGui.PopTextWrapPos();
}
}
+7 -7
View File
@@ -13,8 +13,8 @@ internal sealed class ChatColours : ISettingsTab {
public string Name => Language.Options_ChatColours_Tab + "###tabs-chat-colours";
internal ChatColours(Configuration mutable, Plugin plugin) {
this.Mutable = mutable;
this.Plugin = plugin;
Mutable = mutable;
Plugin = plugin;
#if DEBUG
var sortable = ChatTypeExt.SortOrder
@@ -36,23 +36,23 @@ internal sealed class ChatColours : ISettingsTab {
foreach (var (_, types) in ChatTypeExt.SortOrder) {
foreach (var type in types) {
if (ImGuiUtil.IconButton(FontAwesomeIcon.UndoAlt, $"{type}", Language.Options_ChatColours_Reset)) {
this.Mutable.ChatColours.Remove(type);
Mutable.ChatColours.Remove(type);
}
ImGui.SameLine();
if (ImGuiUtil.IconButton(FontAwesomeIcon.LongArrowAltDown, $"{type}", Language.Options_ChatColours_Import)) {
var gameColour = this.Plugin.Functions.Chat.GetChannelColour(type);
this.Mutable.ChatColours[type] = gameColour ?? type.DefaultColour() ?? 0;
var gameColour = Plugin.Functions.Chat.GetChannelColour(type);
Mutable.ChatColours[type] = gameColour ?? type.DefaultColour() ?? 0;
}
ImGui.SameLine();
var vec = this.Mutable.ChatColours.TryGetValue(type, out var colour)
var vec = Mutable.ChatColours.TryGetValue(type, out var colour)
? ColourUtil.RgbaToVector3(colour)
: ColourUtil.RgbaToVector3(type.DefaultColour() ?? 0);
if (ImGui.ColorEdit3(type.Name(), ref vec, ImGuiColorEditFlags.NoInputs)) {
this.Mutable.ChatColours[type] = ColourUtil.Vector3ToRgba(vec);
Mutable.ChatColours[type] = ColourUtil.Vector3ToRgba(vec);
}
}
}
+14 -14
View File
@@ -11,36 +11,36 @@ internal sealed class Database : ISettingsTab {
public string Name => Language.Options_Database_Tab + "###tabs-database";
internal Database(Configuration mutable, Store store) {
this.Store = store;
this.Mutable = mutable;
Store = store;
Mutable = mutable;
}
private bool _showAdvanced;
public void Draw(bool changed) {
if (changed) {
this._showAdvanced = ImGui.GetIO().KeyShift;
_showAdvanced = ImGui.GetIO().KeyShift;
}
ImGuiUtil.OptionCheckbox(ref this.Mutable.DatabaseBattleMessages, Language.Options_DatabaseBattleMessages_Name, Language.Options_DatabaseBattleMessages_Description);
ImGuiUtil.OptionCheckbox(ref Mutable.DatabaseBattleMessages, Language.Options_DatabaseBattleMessages_Name, Language.Options_DatabaseBattleMessages_Description);
ImGui.Spacing();
if (ImGuiUtil.OptionCheckbox(ref this.Mutable.LoadPreviousSession, Language.Options_LoadPreviousSession_Name, Language.Options_LoadPreviousSession_Description)) {
if (this.Mutable.LoadPreviousSession) {
this.Mutable.FilterIncludePreviousSessions = true;
if (ImGuiUtil.OptionCheckbox(ref Mutable.LoadPreviousSession, Language.Options_LoadPreviousSession_Name, Language.Options_LoadPreviousSession_Description)) {
if (Mutable.LoadPreviousSession) {
Mutable.FilterIncludePreviousSessions = true;
}
}
ImGui.Spacing();
if (ImGuiUtil.OptionCheckbox(ref this.Mutable.FilterIncludePreviousSessions, Language.Options_FilterIncludePreviousSessions_Name, Language.Options_FilterIncludePreviousSessions_Description)) {
if (!this.Mutable.FilterIncludePreviousSessions) {
this.Mutable.LoadPreviousSession = false;
if (ImGuiUtil.OptionCheckbox(ref Mutable.FilterIncludePreviousSessions, Language.Options_FilterIncludePreviousSessions_Name, Language.Options_FilterIncludePreviousSessions_Description)) {
if (!Mutable.FilterIncludePreviousSessions) {
Mutable.LoadPreviousSession = false;
}
}
ImGuiUtil.OptionCheckbox(
ref this.Mutable.SharedMode,
ref Mutable.SharedMode,
Language.Options_SharedMode_Name,
string.Format(Language.Options_SharedMode_Description, Plugin.PluginName)
);
@@ -48,16 +48,16 @@ internal sealed class Database : ISettingsTab {
ImGui.Spacing();
if (this._showAdvanced && ImGui.TreeNodeEx(Language.Options_Database_Advanced)) {
if (_showAdvanced && ImGui.TreeNodeEx(Language.Options_Database_Advanced)) {
ImGui.PushTextWrapPos();
ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);
if (ImGui.Button("Checkpoint")) {
this.Store.Database.Checkpoint();
Store.Database.Checkpoint();
}
if (ImGui.Button("Rebuild")) {
this.Store.Database.Rebuild();
Store.Database.Rebuild();
}
ImGui.PopTextWrapPos();
+25
View File
@@ -1,5 +1,6 @@
using ChatTwo.Resources;
using ChatTwo.Util;
using Dalamud.Interface.Style;
using ImGuiNET;
namespace ChatTwo.Ui.SettingsTabs;
@@ -40,6 +41,12 @@ internal sealed class Display : ISettingsTab {
);
ImGui.Spacing();
ImGuiUtil.OptionCheckbox(
ref Mutable.HideInLoadingScreens,
Language.Options_HideInLoadingScreens_Name,
string.Format(Language.Options_HideInLoadingScreens_Description, Plugin.PluginName));
ImGui.Spacing();
ImGuiUtil.OptionCheckbox(
ref Mutable.NativeItemTooltips,
Language.Options_NativeItemTooltips_Name,
@@ -89,6 +96,24 @@ internal sealed class Display : ISettingsTab {
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();
if (Mutable.OverrideStyle)
{
var currentStyle = Mutable.ChosenStyle.Equals("") ? StyleModel.GetConfiguredStyle().Name : Mutable.ChosenStyle;
if (ImGui.BeginCombo(Language.Options_OverrideStyleDropdown_Name, currentStyle)) {
foreach (var style in StyleModel.GetConfiguredStyles()) {
if (ImGui.Selectable(style.Name, Mutable.ChosenStyle == style.Name)) {
Mutable.ChosenStyle = style.Name;
}
}
ImGui.EndCombo();
}
}
ImGui.Spacing();
ImGui.PopTextWrapPos();
}
}
+28 -28
View File
@@ -12,45 +12,45 @@ public class Fonts : ISettingsTab {
private List<string> JpFonts { get; set; } = new();
internal Fonts(Configuration mutable) {
this.Mutable = mutable;
this.UpdateFonts();
Mutable = mutable;
UpdateFonts();
}
private void UpdateFonts() {
this.GlobalFonts = Ui.Fonts.GetFonts();
this.JpFonts = Ui.Fonts.GetJpFonts();
GlobalFonts = Ui.Fonts.GetFonts();
JpFonts = Ui.Fonts.GetJpFonts();
}
public void Draw(bool changed) {
if (changed) {
this.UpdateFonts();
UpdateFonts();
}
ImGui.PushTextWrapPos();
ImGui.Checkbox(Language.Options_FontsEnabled, ref this.Mutable.FontsEnabled);
ImGui.Checkbox(Language.Options_FontsEnabled, ref Mutable.FontsEnabled);
ImGui.Spacing();
if (this.Mutable.FontsEnabled) {
if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, this.Mutable.GlobalFont)) {
if (Mutable.FontsEnabled) {
if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, Mutable.GlobalFont)) {
foreach (var font in Ui.Fonts.GlobalFonts) {
if (ImGui.Selectable(font.Name, this.Mutable.GlobalFont == font.Name)) {
this.Mutable.GlobalFont = font.Name;
if (ImGui.Selectable(font.Name, Mutable.GlobalFont == font.Name)) {
Mutable.GlobalFont = font.Name;
}
if (ImGui.IsWindowAppearing() && this.Mutable.GlobalFont == font.Name) {
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == font.Name) {
ImGui.SetScrollHereY(0.5f);
}
}
ImGui.Separator();
foreach (var name in this.GlobalFonts) {
if (ImGui.Selectable(name, this.Mutable.GlobalFont == name)) {
this.Mutable.GlobalFont = name;
foreach (var name in GlobalFonts) {
if (ImGui.Selectable(name, Mutable.GlobalFont == name)) {
Mutable.GlobalFont = name;
}
if (ImGui.IsWindowAppearing() && this.Mutable.GlobalFont == name) {
if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == name) {
ImGui.SetScrollHereY(0.5f);
}
}
@@ -62,25 +62,25 @@ public class Fonts : ISettingsTab {
ImGuiUtil.WarningText(Language.Options_Font_Warning);
ImGui.Spacing();
if (ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, this.Mutable.JapaneseFont)) {
if (ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, Mutable.JapaneseFont)) {
foreach (var (name, _) in Ui.Fonts.JapaneseFonts) {
if (ImGui.Selectable(name, this.Mutable.JapaneseFont == name)) {
this.Mutable.JapaneseFont = name;
if (ImGui.Selectable(name, Mutable.JapaneseFont == name)) {
Mutable.JapaneseFont = name;
}
if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == name) {
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name) {
ImGui.SetScrollHereY(0.5f);
}
}
ImGui.Separator();
foreach (var family in this.JpFonts) {
if (ImGui.Selectable(family, this.Mutable.JapaneseFont == family)) {
this.Mutable.JapaneseFont = family;
foreach (var family in JpFonts) {
if (ImGui.Selectable(family, Mutable.JapaneseFont == family)) {
Mutable.JapaneseFont = family;
}
if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == family) {
if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == family) {
ImGui.SetScrollHereY(0.5f);
}
}
@@ -94,12 +94,12 @@ public class Fonts : ISettingsTab {
if (ImGui.CollapsingHeader(Language.Options_ExtraGlyphs_Name)) {
ImGuiUtil.HelpText(string.Format(Language.Options_ExtraGlyphs_Description, Plugin.PluginName));
var range = (int) this.Mutable.ExtraGlyphRanges;
var range = (int) Mutable.ExtraGlyphRanges;
foreach (var extra in Enum.GetValues<ExtraGlyphRanges>()) {
ImGui.CheckboxFlags(extra.Name(), ref range, (int) extra);
}
this.Mutable.ExtraGlyphRanges = (ExtraGlyphRanges) range;
Mutable.ExtraGlyphRanges = (ExtraGlyphRanges) range;
}
ImGui.Spacing();
@@ -108,9 +108,9 @@ public class Fonts : ISettingsTab {
const float speed = .0125f;
const float min = 8f;
const float max = 36f;
ImGuiUtil.DragFloatVertical(Language.Options_FontSize_Name, ref this.Mutable.FontSize, speed, min, max, $"{this.Mutable.FontSize:N1}");
ImGuiUtil.DragFloatVertical(Language.Options_JapaneseFontSize_Name, ref this.Mutable.JapaneseFontSize, speed, min, max, $"{this.Mutable.JapaneseFontSize:N1}");
ImGuiUtil.DragFloatVertical(Language.Options_SymbolsFontSize_Name, ref this.Mutable.SymbolsFontSize, speed, min, max, $"{this.Mutable.SymbolsFontSize:N1}");
ImGuiUtil.DragFloatVertical(Language.Options_FontSize_Name, ref Mutable.FontSize, speed, min, max, $"{Mutable.FontSize:N1}");
ImGuiUtil.DragFloatVertical(Language.Options_JapaneseFontSize_Name, ref Mutable.JapaneseFontSize, speed, min, max, $"{Mutable.JapaneseFontSize:N1}");
ImGuiUtil.DragFloatVertical(Language.Options_SymbolsFontSize_Name, ref Mutable.SymbolsFontSize, speed, min, max, $"{Mutable.SymbolsFontSize:N1}");
ImGuiUtil.HelpText(Language.Options_SymbolsFontSize_Description);
ImGui.PopTextWrapPos();
+10 -10
View File
@@ -10,14 +10,14 @@ internal sealed class Miscellaneous : ISettingsTab {
public string Name => Language.Options_Miscellaneous_Tab + "###tabs-miscellaneous";
public Miscellaneous(Configuration mutable) {
this.Mutable = mutable;
Mutable = mutable;
}
public void Draw(bool changed) {
if (ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, this.Mutable.LanguageOverride.Name())) {
if (ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, Mutable.LanguageOverride.Name())) {
foreach (var language in Enum.GetValues<LanguageOverride>()) {
if (ImGui.Selectable(language.Name())) {
this.Mutable.LanguageOverride = language;
Mutable.LanguageOverride = language;
}
}
@@ -27,10 +27,10 @@ internal sealed class Miscellaneous : ISettingsTab {
ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName));
ImGui.Spacing();
if (ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, this.Mutable.CommandHelpSide.Name())) {
if (ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, Mutable.CommandHelpSide.Name())) {
foreach (var side in Enum.GetValues<CommandHelpSide>()) {
if (ImGui.Selectable(side.Name(), this.Mutable.CommandHelpSide == side)) {
this.Mutable.CommandHelpSide = side;
if (ImGui.Selectable(side.Name(), Mutable.CommandHelpSide == side)) {
Mutable.CommandHelpSide = side;
}
}
@@ -40,10 +40,10 @@ internal sealed class Miscellaneous : ISettingsTab {
ImGuiUtil.HelpText(string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName));
ImGui.Spacing();
if (ImGuiUtil.BeginComboVertical(Language.Options_KeybindMode_Name, this.Mutable.KeybindMode.Name())) {
if (ImGuiUtil.BeginComboVertical(Language.Options_KeybindMode_Name, Mutable.KeybindMode.Name())) {
foreach (var mode in Enum.GetValues<KeybindMode>()) {
if (ImGui.Selectable(mode.Name(), this.Mutable.KeybindMode == mode)) {
this.Mutable.KeybindMode = mode;
if (ImGui.Selectable(mode.Name(), Mutable.KeybindMode == mode)) {
Mutable.KeybindMode = mode;
}
if (ImGui.IsItemHovered()) {
@@ -59,7 +59,7 @@ internal sealed class Miscellaneous : ISettingsTab {
ImGuiUtil.HelpText(string.Format(Language.Options_KeybindMode_Description, Plugin.PluginName));
ImGui.Spacing();
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref this.Mutable.SortAutoTranslate);
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
ImGuiUtil.HelpText(Language.Options_SortAutoTranslate_Description);
ImGui.Spacing();
}
+19 -19
View File
@@ -15,8 +15,8 @@ internal sealed class Tabs : ISettingsTab {
private int _toOpen = -2;
internal Tabs(Plugin plugin, Configuration mutable) {
this.Plugin = plugin;
this.Mutable = mutable;
Plugin = plugin;
Mutable = mutable;
}
public void Draw(bool changed) {
@@ -28,29 +28,29 @@ internal sealed class Tabs : ISettingsTab {
if (ImGui.BeginPopup(addTabPopup)) {
if (ImGui.Selectable(Language.Options_Tabs_NewTab)) {
this.Mutable.Tabs.Add(new Tab());
Mutable.Tabs.Add(new Tab());
}
ImGui.Separator();
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_General))) {
this.Mutable.Tabs.Add(TabsUtil.VanillaGeneral);
Mutable.Tabs.Add(TabsUtil.VanillaGeneral);
}
if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_Event))) {
this.Mutable.Tabs.Add(TabsUtil.VanillaEvent);
Mutable.Tabs.Add(TabsUtil.VanillaEvent);
}
ImGui.EndPopup();
}
var toRemove = -1;
var doOpens = this._toOpen > -2;
for (var i = 0; i < this.Mutable.Tabs.Count; i++) {
var tab = this.Mutable.Tabs[i];
var doOpens = _toOpen > -2;
for (var i = 0; i < Mutable.Tabs.Count; i++) {
var tab = Mutable.Tabs[i];
if (doOpens) {
ImGui.SetNextItemOpen(i == this._toOpen);
ImGui.SetNextItemOpen(i == _toOpen);
}
if (ImGui.TreeNodeEx($"{tab.Name}###tab-{i}")) {
@@ -58,21 +58,21 @@ internal sealed class Tabs : ISettingsTab {
if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: Language.Options_Tabs_Delete)) {
toRemove = i;
this._toOpen = -1;
_toOpen = -1;
}
ImGui.SameLine();
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowUp, tooltip: Language.Options_Tabs_MoveUp) && i > 0) {
(this.Mutable.Tabs[i - 1], this.Mutable.Tabs[i]) = (this.Mutable.Tabs[i], this.Mutable.Tabs[i - 1]);
this._toOpen = i - 1;
(Mutable.Tabs[i - 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i - 1]);
_toOpen = i - 1;
}
ImGui.SameLine();
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: Language.Options_Tabs_MoveDown) && i < this.Mutable.Tabs.Count - 1) {
(this.Mutable.Tabs[i + 1], this.Mutable.Tabs[i]) = (this.Mutable.Tabs[i], this.Mutable.Tabs[i + 1]);
this._toOpen = i + 1;
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: Language.Options_Tabs_MoveDown) && i < Mutable.Tabs.Count - 1) {
(Mutable.Tabs[i + 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i + 1]);
_toOpen = i + 1;
}
ImGui.InputText(Language.Options_Tabs_Name, ref tab.Name, 512, ImGuiInputTextFlags.EnterReturnsTrue);
@@ -160,7 +160,7 @@ internal sealed class Tabs : ISettingsTab {
ImGui.TreePop();
}
if (this.Plugin.ExtraChat.ChannelNames.Count > 0 && ImGui.TreeNodeEx(Language.Options_Tabs_ExtraChatChannels)) {
if (Plugin.ExtraChat.ChannelNames.Count > 0 && ImGui.TreeNodeEx(Language.Options_Tabs_ExtraChatChannels)) {
ImGui.Checkbox(Language.Options_Tabs_ExtraChatAll, ref tab.ExtraChatAll);
ImGui.Separator();
@@ -169,7 +169,7 @@ internal sealed class Tabs : ISettingsTab {
ImGui.BeginDisabled();
}
foreach (var (id, name) in this.Plugin.ExtraChat.ChannelNames) {
foreach (var (id, name) in Plugin.ExtraChat.ChannelNames) {
var enabled = tab.ExtraChatChannels.Contains(id);
if (!ImGui.Checkbox($"{name}##ec-{id}", ref enabled)) {
continue;
@@ -196,11 +196,11 @@ internal sealed class Tabs : ISettingsTab {
}
if (toRemove > -1) {
this.Mutable.Tabs.RemoveAt(toRemove);
Mutable.Tabs.RemoveAt(toRemove);
}
if (doOpens) {
this._toOpen = -2;
_toOpen = -2;
}
}
}