feat: add new settings ui
Also add window display options.
This commit is contained in:
Executable
+34
@@ -0,0 +1,34 @@
|
||||
using ChatTwo.Code;
|
||||
using ChatTwo.Util;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class ChatColours : ISettingsTab {
|
||||
private Configuration Mutable { get; }
|
||||
|
||||
public string Name => "Chat colours";
|
||||
|
||||
internal ChatColours(Configuration mutable) {
|
||||
this.Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw() {
|
||||
foreach (var type in Enum.GetValues<ChatType>()) {
|
||||
if (ImGui.Button($"Default##{type}")) {
|
||||
this.Mutable.ChatColours.Remove(type);
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
var vec = this.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);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.TreePop();
|
||||
}
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class Display : ISettingsTab {
|
||||
private Configuration Mutable { get; }
|
||||
|
||||
public string Name => "Display";
|
||||
|
||||
internal Display(Configuration mutable) {
|
||||
this.Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw() {
|
||||
ImGui.Checkbox("Hide chat", ref this.Mutable.HideChat);
|
||||
ImGui.Checkbox("Show native item tooltips", ref this.Mutable.NativeItemTooltips);
|
||||
ImGui.Checkbox("Show tabs in a sidebar", ref this.Mutable.SidebarTabView);
|
||||
ImGui.Checkbox("Use modern timestamp layout", ref this.Mutable.PrettierTimestamps);
|
||||
|
||||
if (this.Mutable.PrettierTimestamps) {
|
||||
ImGui.Checkbox("More compact modern layout", ref this.Mutable.MoreCompactPretty);
|
||||
}
|
||||
|
||||
ImGui.DragFloat("Font size", ref this.Mutable.FontSize, .0125f, 12f, 36f, "%.1f");
|
||||
ImGui.Checkbox("Allow moving main window", ref this.Mutable.CanMove);
|
||||
ImGui.Checkbox("Allow resizing main window", ref this.Mutable.CanResize);
|
||||
ImGui.Checkbox("Show title bar for main window", ref this.Mutable.ShowTitleBar);
|
||||
}
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal interface ISettingsTab {
|
||||
string Name { get; }
|
||||
void Draw();
|
||||
}
|
||||
Executable
+105
@@ -0,0 +1,105 @@
|
||||
using ChatTwo.Code;
|
||||
using ChatTwo.Util;
|
||||
using Dalamud.Interface;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class Tabs : ISettingsTab {
|
||||
private Configuration Mutable { get; }
|
||||
|
||||
public string Name => "Tabs";
|
||||
|
||||
internal Tabs(Configuration mutable) {
|
||||
this.Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw() {
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.Plus, tooltip: "Add")) {
|
||||
this.Mutable.Tabs.Add(new Tab());
|
||||
}
|
||||
|
||||
var toRemove = -1;
|
||||
for (var i = 0; i < this.Mutable.Tabs.Count; i++) {
|
||||
var tab = this.Mutable.Tabs[i];
|
||||
|
||||
if (ImGui.TreeNodeEx($"{tab.Name}###tab-{i}")) {
|
||||
ImGui.PushID($"tab-{i}");
|
||||
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: "Delete")) {
|
||||
toRemove = i;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowUp, tooltip: "Move up") && i > 0) {
|
||||
(this.Mutable.Tabs[i - 1], this.Mutable.Tabs[i]) = (this.Mutable.Tabs[i], this.Mutable.Tabs[i - 1]);
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: "Move down") && i < this.Mutable.Tabs.Count - 1) {
|
||||
(this.Mutable.Tabs[i + 1], this.Mutable.Tabs[i]) = (this.Mutable.Tabs[i], this.Mutable.Tabs[i + 1]);
|
||||
}
|
||||
|
||||
ImGui.InputText("Name", ref tab.Name, 512, ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
ImGui.Checkbox("Show unread count", ref tab.DisplayUnread);
|
||||
ImGui.Checkbox("Show timestamps", ref tab.DisplayTimestamp);
|
||||
|
||||
var input = tab.Channel?.ToChatType().Name() ?? "<None>";
|
||||
if (ImGui.BeginCombo("Input channel", input)) {
|
||||
if (ImGui.Selectable("<None>", tab.Channel == null)) {
|
||||
tab.Channel = null;
|
||||
}
|
||||
|
||||
foreach (var channel in Enum.GetValues<InputChannel>()) {
|
||||
if (ImGui.Selectable(channel.ToChatType().Name(), tab.Channel == channel)) {
|
||||
tab.Channel = channel;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
if (ImGui.TreeNodeEx("Channels")) {
|
||||
foreach (var type in Enum.GetValues<ChatType>()) {
|
||||
var enabled = tab.ChatCodes.ContainsKey(type);
|
||||
if (ImGui.Checkbox($"##{type.Name()}-{i}", ref enabled)) {
|
||||
if (enabled) {
|
||||
tab.ChatCodes[type] = ChatSourceExt.All;
|
||||
} else {
|
||||
tab.ChatCodes.Remove(type);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGui.TreeNodeEx($"{type.Name()}##{i}")) {
|
||||
tab.ChatCodes.TryGetValue(type, out var sourcesEnum);
|
||||
var sources = (uint) sourcesEnum;
|
||||
|
||||
foreach (var source in Enum.GetValues<ChatSource>()) {
|
||||
if (ImGui.CheckboxFlags(source.ToString(), ref sources, (uint) source)) {
|
||||
tab.ChatCodes[type] = (ChatSource) sources;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ImGui.TreePop();
|
||||
}
|
||||
|
||||
ImGui.TreePop();
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
}
|
||||
|
||||
if (toRemove > -1) {
|
||||
this.Mutable.Tabs.RemoveAt(toRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user