Compare commits

..

No commits in common. "828d85a521cbea3359ce023002b346c2e6f9b6e5" and "c306b5b5de2ea8866bd3401742e71b207ee35476" have entirely different histories.

5 changed files with 15 additions and 117 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.2.0</Version>
<Version>1.1.0</Version>
<TargetFramework>net5.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

View File

@ -9,7 +9,6 @@ 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();

View File

@ -213,13 +213,7 @@ internal sealed unsafe class Chat : IDisposable {
target.StringPtr = tellTargetPtr == null ? zero : tellTargetPtr;
target.StringLength = bytes.Length;
var idx = channel.LinkshellIndex();
if (idx == uint.MaxValue) {
idx = 0;
}
this._changeChatChannel(RaptureShellModule.Instance, (int) channel, idx, &target, 1);
this._changeChatChannel(RaptureShellModule.Instance, (int) (channel + 1), channel.LinkshellIndex(), &target, 1);
}
}
}

View File

@ -79,7 +79,7 @@ internal sealed class ChatLog : IUiComponent {
}
Tab? activeTab = null;
if (currentTab > -1 && currentTab < this.Ui.Plugin.Config.Tabs.Count - 1) {
if (currentTab > -1) {
activeTab = this.Ui.Plugin.Config.Tabs[currentTab];
}
@ -172,16 +172,6 @@ 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;
@ -194,20 +184,11 @@ internal sealed class ChatLog : IUiComponent {
if (tab.DisplayTimestamp) {
var timestamp = message.Date.ToLocalTime().ToString("t");
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) {
this.DrawChunks(message.Sender, true, this.PayloadHandler);
@ -239,15 +220,10 @@ internal sealed class ChatLog : IUiComponent {
// ImGui.SetScrollFromPosY(itemPosY - ImGui.GetWindowPos().Y);
ImGui.SetScrollHereY(1f);
}
}
this.PayloadHandler.Draw();
if (table) {
ImGui.EndTable();
}
}
EndChild:
ImGui.EndChild();
}
@ -262,10 +238,7 @@ 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})";
var draw = ImGui.BeginTabItem($"{tab.Name}{unread}###log-tab-{tabI}");
this.DrawTabContextMenu(tab, tabI);
if (!draw) {
if (!ImGui.BeginTabItem($"{tab.Name}{unread}###log-tab-{tabI}")) {
continue;
}
@ -287,14 +260,7 @@ internal sealed class ChatLog : IUiComponent {
private int DrawTabSidebar() {
var currentTab = -1;
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();
ImGui.Columns(2);
var switchedTab = false;
var childHeight = GetRemainingHeightForMessageLog();
@ -303,10 +269,7 @@ 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})";
var clicked = ImGui.Selectable($"{tab.Name}{unread}###log-tab-{tabI}", this._lastTab == tabI);
this.DrawTabContextMenu(tab, tabI);
if (!clicked) {
if (!ImGui.Selectable($"{tab.Name}{unread}###log-tab-{tabI}", this._lastTab == tabI)) {
continue;
}
@ -318,7 +281,7 @@ internal sealed class ChatLog : IUiComponent {
ImGui.EndChild();
ImGui.TableNextColumn();
ImGui.NextColumn();
if (currentTab == -1 && this._lastTab < this.Ui.Plugin.Config.Tabs.Count) {
currentTab = this._lastTab;
@ -329,61 +292,11 @@ internal sealed class ChatLog : IUiComponent {
this.DrawMessageLog(this.Ui.Plugin.Config.Tabs[currentTab], childHeight, switchedTab);
}
ImGui.EndTable();
ImGui.Columns();
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);
@ -445,10 +358,6 @@ 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) {

View File

@ -13,7 +13,6 @@ 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();
@ -38,7 +37,6 @@ 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();
@ -67,8 +65,7 @@ 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.Checkbox("Use modern timestamp layout", ref this._prettierTimestamps);
ImGui.DragFloat("Font size", ref this._fontSize, .0125f, 12f, 36f, "%.1f");
ImGui.DragFloat("Font size", ref this._fontSize, .5f, 12f, 36f);
if (ImGui.TreeNodeEx("Chat colours")) {
foreach (var type in Enum.GetValues<ChatType>()) {
@ -209,7 +206,6 @@ 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;