feat: add channel switcher, settings button, better tooltips
This commit is contained in:
+44
-2
@@ -1,12 +1,16 @@
|
||||
using System.Numerics;
|
||||
using ChatTwo.Code;
|
||||
using ChatTwo.Util;
|
||||
using Dalamud.Interface;
|
||||
using ImGuiNET;
|
||||
using ImGuiScene;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace ChatTwo.Ui;
|
||||
|
||||
internal sealed class ChatLog : IUiComponent {
|
||||
private const string ChatChannelPicker = "chat-channel-picker";
|
||||
|
||||
private PluginUi Ui { get; }
|
||||
|
||||
internal bool Activate;
|
||||
@@ -143,7 +147,39 @@ internal sealed class ChatLog : IUiComponent {
|
||||
ImGui.SetKeyboardFocusHere();
|
||||
}
|
||||
|
||||
ImGui.TextUnformatted(this.Ui.Plugin.Functions.ChatChannel.name);
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
||||
try {
|
||||
this.DrawChunks(this.Ui.Plugin.Functions.ChatChannel.name);
|
||||
} finally {
|
||||
ImGui.PopStyleVar();
|
||||
}
|
||||
|
||||
var beforeIcon = ImGui.GetCursorPos();
|
||||
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.Comment)) {
|
||||
ImGui.OpenPopup(ChatChannelPicker);
|
||||
}
|
||||
|
||||
if (ImGui.BeginPopup(ChatChannelPicker)) {
|
||||
foreach (var channel in Enum.GetValues<InputChannel>()) {
|
||||
var name = this.Ui.Plugin.DataManager.GetExcelSheet<LogFilter>()!
|
||||
.FirstOrDefault(row => row.LogKind == (byte) channel.ToChatType())
|
||||
?.Name
|
||||
?.RawString ?? channel.ToString();
|
||||
|
||||
if (ImGui.Selectable(name)) {
|
||||
this.Ui.Plugin.Functions.SetChatChannel(channel);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
var afterIcon = ImGui.GetCursorPos();
|
||||
|
||||
var buttonWidth = afterIcon.X - beforeIcon.X;
|
||||
var inputWidth = ImGui.GetContentRegionAvail().X - buttonWidth;
|
||||
|
||||
var inputType = this.Ui.Plugin.Functions.ChatChannel.channel.ToChatType();
|
||||
var inputColour = this.Ui.Plugin.Config.ChatColours.TryGetValue(inputType, out var inputCol)
|
||||
@@ -154,7 +190,7 @@ internal sealed class ChatLog : IUiComponent {
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(inputColour.Value));
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
ImGui.SetNextItemWidth(inputWidth);
|
||||
const ImGuiInputTextFlags inputFlags = ImGuiInputTextFlags.EnterReturnsTrue
|
||||
| ImGuiInputTextFlags.CallbackAlways
|
||||
| ImGuiInputTextFlags.CallbackHistory;
|
||||
@@ -174,6 +210,12 @@ internal sealed class ChatLog : IUiComponent {
|
||||
ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.Cog)) {
|
||||
this.Ui.SettingsVisible ^= true;
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ namespace ChatTwo.Ui;
|
||||
internal sealed class Settings : IUiComponent {
|
||||
private PluginUi Ui { get; }
|
||||
|
||||
private bool _visible;
|
||||
|
||||
private bool _hideChat;
|
||||
private bool _nativeItemTooltips;
|
||||
private float _fontSize;
|
||||
@@ -29,7 +27,7 @@ internal sealed class Settings : IUiComponent {
|
||||
}
|
||||
|
||||
private void Command(string command, string args) {
|
||||
this._visible ^= true;
|
||||
this.Ui.SettingsVisible ^= true;
|
||||
}
|
||||
|
||||
private void Initialise() {
|
||||
@@ -42,11 +40,11 @@ internal sealed class Settings : IUiComponent {
|
||||
}
|
||||
|
||||
public void Draw() {
|
||||
if (!this._visible) {
|
||||
if (!this.Ui.SettingsVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ImGui.Begin($"{this.Ui.Plugin.Name} settings", ref this._visible)) {
|
||||
if (!ImGui.Begin($"{this.Ui.Plugin.Name} settings", ref this.Ui.SettingsVisible)) {
|
||||
ImGui.End();
|
||||
return;
|
||||
}
|
||||
@@ -148,13 +146,13 @@ internal sealed class Settings : IUiComponent {
|
||||
|
||||
if (ImGui.Button("Save and close")) {
|
||||
save = true;
|
||||
this._visible = false;
|
||||
this.Ui.SettingsVisible = false;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGui.Button("Discard")) {
|
||||
this._visible = false;
|
||||
this.Ui.SettingsVisible = false;
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
|
||||
Reference in New Issue
Block a user