Compare commits
5 Commits
c306b5b5de
...
828d85a521
Author | SHA1 | Date | |
---|---|---|---|
828d85a521 | |||
5a9bbc71fc | |||
7330298277 | |||
1f03d10a22 | |||
879aeef05c |
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>1.1.0</Version>
|
||||
<Version>1.2.0</Version>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
@ -9,6 +9,7 @@ internal class Configuration : IPluginConfiguration {
|
||||
|
||||
public bool HideChat = true;
|
||||
public bool NativeItemTooltips = true;
|
||||
public bool PrettierTimestamps = true;
|
||||
public bool SidebarTabView;
|
||||
public float FontSize = 17f;
|
||||
public Dictionary<ChatType, uint> ChatColours = new();
|
||||
|
@ -213,7 +213,13 @@ internal sealed unsafe class Chat : IDisposable {
|
||||
|
||||
target.StringPtr = tellTargetPtr == null ? zero : tellTargetPtr;
|
||||
target.StringLength = bytes.Length;
|
||||
this._changeChatChannel(RaptureShellModule.Instance, (int) (channel + 1), channel.LinkshellIndex(), &target, 1);
|
||||
|
||||
var idx = channel.LinkshellIndex();
|
||||
if (idx == uint.MaxValue) {
|
||||
idx = 0;
|
||||
}
|
||||
|
||||
this._changeChatChannel(RaptureShellModule.Instance, (int) channel, idx, &target, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ internal sealed class ChatLog : IUiComponent {
|
||||
}
|
||||
|
||||
Tab? activeTab = null;
|
||||
if (currentTab > -1) {
|
||||
if (currentTab > -1 && currentTab < this.Ui.Plugin.Config.Tabs.Count - 1) {
|
||||
activeTab = this.Ui.Plugin.Config.Tabs[currentTab];
|
||||
}
|
||||
|
||||
@ -172,6 +172,16 @@ internal sealed class ChatLog : IUiComponent {
|
||||
private void DrawMessageLog(Tab tab, float childHeight, bool switchedTab) {
|
||||
if (ImGui.BeginChild("##chat2-messages", new Vector2(-1, childHeight))) {
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
||||
var table = tab.DisplayTimestamp && this.Ui.Plugin.Config.PrettierTimestamps;
|
||||
|
||||
if (table) {
|
||||
if (!ImGui.BeginTable("timestamp-table", 2, ImGuiTableFlags.PreciseWidths)) {
|
||||
goto EndChild;
|
||||
}
|
||||
|
||||
ImGui.TableSetupColumn("timestamps", ImGuiTableColumnFlags.WidthFixed);
|
||||
ImGui.TableSetupColumn("messages", ImGuiTableColumnFlags.WidthStretch);
|
||||
}
|
||||
|
||||
// var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
|
||||
// int numMessages;
|
||||
@ -184,10 +194,19 @@ internal sealed class ChatLog : IUiComponent {
|
||||
|
||||
if (tab.DisplayTimestamp) {
|
||||
var timestamp = message.Date.ToLocalTime().ToString("t");
|
||||
this.DrawChunk(new TextChunk(null, null, $"[{timestamp}]") {
|
||||
Foreground = 0xFFFFFFFF,
|
||||
});
|
||||
ImGui.SameLine();
|
||||
if (table) {
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(timestamp);
|
||||
} else {
|
||||
this.DrawChunk(new TextChunk(null, null, $"[{timestamp}]") {
|
||||
Foreground = 0xFFFFFFFF,
|
||||
});
|
||||
ImGui.SameLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (table) {
|
||||
ImGui.TableNextColumn();
|
||||
}
|
||||
|
||||
if (message.Sender.Count > 0) {
|
||||
@ -220,10 +239,15 @@ internal sealed class ChatLog : IUiComponent {
|
||||
// ImGui.SetScrollFromPosY(itemPosY - ImGui.GetWindowPos().Y);
|
||||
ImGui.SetScrollHereY(1f);
|
||||
}
|
||||
|
||||
this.PayloadHandler.Draw();
|
||||
|
||||
if (table) {
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
this.PayloadHandler.Draw();
|
||||
|
||||
EndChild:
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
||||
@ -238,7 +262,10 @@ internal sealed class ChatLog : IUiComponent {
|
||||
var tab = this.Ui.Plugin.Config.Tabs[tabI];
|
||||
|
||||
var unread = tabI == this._lastTab || !tab.DisplayUnread || tab.Unread == 0 ? "" : $" ({tab.Unread})";
|
||||
if (!ImGui.BeginTabItem($"{tab.Name}{unread}###log-tab-{tabI}")) {
|
||||
var draw = ImGui.BeginTabItem($"{tab.Name}{unread}###log-tab-{tabI}");
|
||||
this.DrawTabContextMenu(tab, tabI);
|
||||
|
||||
if (!draw) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -260,7 +287,14 @@ internal sealed class ChatLog : IUiComponent {
|
||||
private int DrawTabSidebar() {
|
||||
var currentTab = -1;
|
||||
|
||||
ImGui.Columns(2);
|
||||
if (!ImGui.BeginTable("tabs-table", 2, ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.Resizable)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ImGui.TableSetupColumn("tabs", ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn("chat", ImGuiTableColumnFlags.None, 4);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
|
||||
var switchedTab = false;
|
||||
var childHeight = GetRemainingHeightForMessageLog();
|
||||
@ -269,7 +303,10 @@ internal sealed class ChatLog : IUiComponent {
|
||||
var tab = this.Ui.Plugin.Config.Tabs[tabI];
|
||||
|
||||
var unread = tabI == this._lastTab || !tab.DisplayUnread || tab.Unread == 0 ? "" : $" ({tab.Unread})";
|
||||
if (!ImGui.Selectable($"{tab.Name}{unread}###log-tab-{tabI}", this._lastTab == tabI)) {
|
||||
var clicked = ImGui.Selectable($"{tab.Name}{unread}###log-tab-{tabI}", this._lastTab == tabI);
|
||||
this.DrawTabContextMenu(tab, tabI);
|
||||
|
||||
if (!clicked) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -281,7 +318,7 @@ internal sealed class ChatLog : IUiComponent {
|
||||
|
||||
ImGui.EndChild();
|
||||
|
||||
ImGui.NextColumn();
|
||||
ImGui.TableNextColumn();
|
||||
|
||||
if (currentTab == -1 && this._lastTab < this.Ui.Plugin.Config.Tabs.Count) {
|
||||
currentTab = this._lastTab;
|
||||
@ -292,11 +329,61 @@ internal sealed class ChatLog : IUiComponent {
|
||||
this.DrawMessageLog(this.Ui.Plugin.Config.Tabs[currentTab], childHeight, switchedTab);
|
||||
}
|
||||
|
||||
ImGui.Columns();
|
||||
ImGui.EndTable();
|
||||
|
||||
return currentTab;
|
||||
}
|
||||
|
||||
private void DrawTabContextMenu(Tab tab, int i) {
|
||||
if (!ImGui.BeginPopupContextItem()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var tabs = this.Ui.Plugin.Config.Tabs;
|
||||
var anyChanged = false;
|
||||
|
||||
ImGui.PushID($"tab-context-menu-{i}");
|
||||
|
||||
ImGui.SetNextItemWidth(250f);
|
||||
if (ImGui.InputText("##tab-name", ref tab.Name, 128)) {
|
||||
anyChanged = true;
|
||||
}
|
||||
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: "Delete tab")) {
|
||||
tabs.RemoveAt(i);
|
||||
anyChanged = true;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
var (leftIcon, leftTooltip) = this.Ui.Plugin.Config.SidebarTabView
|
||||
? (FontAwesomeIcon.ArrowUp, "Move up")
|
||||
: ((FontAwesomeIcon) 61536, "Move left");
|
||||
if (ImGuiUtil.IconButton(leftIcon, tooltip: leftTooltip) && i > 0) {
|
||||
(tabs[i - 1], tabs[i]) = (tabs[i], tabs[i - 1]);
|
||||
ImGui.CloseCurrentPopup();
|
||||
anyChanged = true;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
var (rightIcon, rightTooltip) = this.Ui.Plugin.Config.SidebarTabView
|
||||
? (FontAwesomeIcon.ArrowDown, "Move down")
|
||||
: (FontAwesomeIcon.ArrowRight, "Move right");
|
||||
if (ImGuiUtil.IconButton(rightIcon, tooltip: rightTooltip) && i < tabs.Count - 1) {
|
||||
(tabs[i + 1], tabs[i]) = (tabs[i], tabs[i + 1]);
|
||||
ImGui.CloseCurrentPopup();
|
||||
anyChanged = true;
|
||||
}
|
||||
|
||||
if (anyChanged) {
|
||||
this.Ui.Plugin.SaveConfig();
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
private unsafe int Callback(ImGuiInputTextCallbackData* data) {
|
||||
var ptr = new ImGuiInputTextCallbackDataPtr(data);
|
||||
|
||||
@ -358,6 +445,10 @@ internal sealed class ChatLog : IUiComponent {
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
||||
try {
|
||||
for (var i = 0; i < chunks.Count; i++) {
|
||||
if (chunks[i] is TextChunk text && string.IsNullOrEmpty(text.Content)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.DrawChunk(chunks[i], wrap, handler);
|
||||
|
||||
if (i < chunks.Count - 1) {
|
||||
|
@ -13,6 +13,7 @@ internal sealed class Settings : IUiComponent {
|
||||
private bool _hideChat;
|
||||
private bool _nativeItemTooltips;
|
||||
private bool _sidebarTabView;
|
||||
private bool _prettierTimestamps;
|
||||
private float _fontSize;
|
||||
private Dictionary<ChatType, uint> _chatColours = new();
|
||||
private List<Tab> _tabs = new();
|
||||
@ -37,6 +38,7 @@ internal sealed class Settings : IUiComponent {
|
||||
this._hideChat = config.HideChat;
|
||||
this._nativeItemTooltips = config.NativeItemTooltips;
|
||||
this._sidebarTabView = config.SidebarTabView;
|
||||
this._prettierTimestamps = config.PrettierTimestamps;
|
||||
this._fontSize = config.FontSize;
|
||||
this._chatColours = config.ChatColours.ToDictionary(entry => entry.Key, entry => entry.Value);
|
||||
this._tabs = config.Tabs.Select(tab => tab.Clone()).ToList();
|
||||
@ -65,7 +67,8 @@ internal sealed class Settings : IUiComponent {
|
||||
ImGui.Checkbox("Hide chat", ref this._hideChat);
|
||||
ImGui.Checkbox("Show native item tooltips", ref this._nativeItemTooltips);
|
||||
ImGui.Checkbox("Show tabs in a sidebar", ref this._sidebarTabView);
|
||||
ImGui.DragFloat("Font size", ref this._fontSize, .5f, 12f, 36f);
|
||||
ImGui.Checkbox("Use modern timestamp layout", ref this._prettierTimestamps);
|
||||
ImGui.DragFloat("Font size", ref this._fontSize, .0125f, 12f, 36f, "%.1f");
|
||||
|
||||
if (ImGui.TreeNodeEx("Chat colours")) {
|
||||
foreach (var type in Enum.GetValues<ChatType>()) {
|
||||
@ -206,6 +209,7 @@ internal sealed class Settings : IUiComponent {
|
||||
config.HideChat = this._hideChat;
|
||||
config.NativeItemTooltips = this._nativeItemTooltips;
|
||||
config.SidebarTabView = this._sidebarTabView;
|
||||
config.PrettierTimestamps = this._prettierTimestamps;
|
||||
config.FontSize = this._fontSize;
|
||||
config.ChatColours = this._chatColours;
|
||||
config.Tabs = this._tabs;
|
||||
|
Loading…
Reference in New Issue
Block a user