- Support locked channels
- Implement render limit for webinterface [default 1000]
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Version>1.29.0</Version>
|
||||
<Version>1.29.1</Version>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@@ -75,7 +75,7 @@ internal class Configuration : IPluginConfiguration
|
||||
public bool CollapseDuplicateMessages;
|
||||
public bool PlaySounds = true;
|
||||
public bool KeepInputFocus = true;
|
||||
public int MaxLinesToRender = 10_000;
|
||||
public int MaxLinesToRender = 10_000; // 1-10000
|
||||
public bool Use24HourClock;
|
||||
|
||||
public bool ShowEmotes = true;
|
||||
@@ -96,7 +96,7 @@ internal class Configuration : IPluginConfiguration
|
||||
FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansJpMedium),
|
||||
SizePt = 12.75f,
|
||||
};
|
||||
public bool ItalicEnabled = false;
|
||||
public bool ItalicEnabled;
|
||||
public SingleFontSpec ItalicFontV2 = new()
|
||||
{
|
||||
FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansKrRegular),
|
||||
@@ -120,6 +120,7 @@ internal class Configuration : IPluginConfiguration
|
||||
public string WebinterfacePassword = WebinterfaceUtil.GenerateSimpleAuthCode();
|
||||
public int WebinterfacePort = 9000;
|
||||
public ConcurrentDictionary<string, bool> SessionTokens = [];
|
||||
public int WebinterfaceMaxLinesToSend = 1000; // 1-10000
|
||||
|
||||
internal void UpdateFrom(Configuration other, bool backToOriginal)
|
||||
{
|
||||
@@ -188,6 +189,7 @@ internal class Configuration : IPluginConfiguration
|
||||
WebinterfaceAutoStart = other.WebinterfaceAutoStart;
|
||||
WebinterfacePassword = other.WebinterfacePassword;
|
||||
WebinterfacePort = other.WebinterfacePort;
|
||||
WebinterfaceMaxLinesToSend = other.WebinterfaceMaxLinesToSend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ namespace ChatTwo.Http.MessageProtocol;
|
||||
/// <summary>
|
||||
/// Contains the current channel name
|
||||
/// </summary>
|
||||
public struct SwitchChannel(MessageTemplate[] channelName)
|
||||
public struct SwitchChannel((MessageTemplate[] ChannelName, bool Locked) channel)
|
||||
{
|
||||
[JsonProperty("channelName")] public MessageTemplate[] ChannelName = channelName;
|
||||
[JsonProperty("channelName")] public MessageTemplate[] ChannelName = channel.ChannelName;
|
||||
[JsonProperty("channelLocked")] public bool Locked = channel.Locked;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,15 +15,16 @@ public class Processing
|
||||
Plugin = plugin;
|
||||
}
|
||||
|
||||
internal MessageTemplate[] ReadChannelName(Chunk[] channelName)
|
||||
internal (MessageTemplate[] ChannelName, bool Locked) ReadChannelName(Chunk[] channelName)
|
||||
{
|
||||
return channelName.Select(ProcessChunk).ToArray();
|
||||
var locked = Plugin.ChatLogWindow.CurrentTab is not { Channel: null };
|
||||
return (channelName.Select(ProcessChunk).ToArray(), locked);
|
||||
}
|
||||
|
||||
internal async Task<MessageResponse[]> ReadMessageList()
|
||||
{
|
||||
var tabMessages = await Plugin.ChatLogWindow.CurrentTab!.Messages.GetCopy();
|
||||
return tabMessages.Select(ReadMessageContent).ToArray();
|
||||
return tabMessages.TakeLast(Plugin.Config.WebinterfaceMaxLinesToSend).Select(ReadMessageContent).ToArray();
|
||||
}
|
||||
|
||||
internal MessageResponse ReadMessageContent(Message message)
|
||||
@@ -44,11 +45,11 @@ public class Processing
|
||||
{
|
||||
var messages = await WebserverUtil.FrameworkWrapper(ReadMessageList);
|
||||
var channels = await Plugin.Framework.RunOnTick(Plugin.ChatLogWindow.GetAvailableChannels);
|
||||
var channelName = await Plugin.Framework.RunOnTick(() => ReadChannelName(Plugin.ChatLogWindow.PreviousChannel));
|
||||
var channel = await Plugin.Framework.RunOnTick(() => ReadChannelName(Plugin.ChatLogWindow.PreviousChannel));
|
||||
|
||||
// Using the bulk message event to clear everything on the client side that may still exist
|
||||
sse.OutboundQueue.Enqueue(new BulkMessagesEvent(new Messages(messages)));
|
||||
sse.OutboundQueue.Enqueue(new SwitchChannelEvent(new SwitchChannel(channelName)));
|
||||
sse.OutboundQueue.Enqueue(new SwitchChannelEvent(new SwitchChannel(channel)));
|
||||
sse.OutboundQueue.Enqueue(new ChannelListEvent(new ChannelList(channels.ToDictionary(pair => pair.Key, pair => (uint)pair.Value))));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
};
|
||||
this.maxTimestampWidth = 0;
|
||||
this.scrolledToBottom = true;
|
||||
this.channelLocked = false;
|
||||
|
||||
|
||||
// channel selector
|
||||
@@ -72,9 +73,21 @@
|
||||
});
|
||||
}
|
||||
|
||||
updateChannelHint(templates) {
|
||||
updateChannelHint(channel) {
|
||||
this.elements.channelHint.innerHTML = '';
|
||||
this.elements.channelHint.appendChild(this.processTemplate(templates));
|
||||
|
||||
const channelElement = this.processTemplate(channel.channelName);
|
||||
|
||||
// Makes the channel selector unclickable if the channel is fixed
|
||||
this.channelLocked = channel.channelLocked;
|
||||
if (this.channelLocked) {
|
||||
channelElement.firstChild.innerText = `(Locked) ${channelElement.firstChild.innerText}`;
|
||||
this.elements.channelSelect.style.pointerEvents = 'none';
|
||||
} else {
|
||||
this.elements.channelSelect.style.pointerEvents = 'auto';
|
||||
}
|
||||
|
||||
this.elements.channelHint.appendChild(channelElement);
|
||||
}
|
||||
|
||||
updateChannels(channels) {
|
||||
@@ -228,7 +241,7 @@
|
||||
|
||||
this.sse.addEventListener('switch-channel', (event) => {
|
||||
try {
|
||||
this.updateChannelHint(JSON.parse(event.data).channelName);
|
||||
this.updateChannelHint(JSON.parse(event.data));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
Generated
+18
@@ -3533,6 +3533,24 @@ namespace ChatTwo.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Limits the amount of log lines to show in the webinterface. This will improve loading performance..
|
||||
/// </summary>
|
||||
internal static string Options_WebinterfaceMaxLinesToSend_Description {
|
||||
get {
|
||||
return ResourceManager.GetString("Options_WebinterfaceMaxLinesToSend_Description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Log line limit for the webinterface.
|
||||
/// </summary>
|
||||
internal static string Options_WebinterfaceMaxLinesToSend_Name {
|
||||
get {
|
||||
return ResourceManager.GetString("Options_WebinterfaceMaxLinesToSend_Name", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Window opacity.
|
||||
/// </summary>
|
||||
|
||||
@@ -1087,6 +1087,12 @@
|
||||
<data name="Options_MaxLinesToShow_Description" xml:space="preserve">
|
||||
<value>Limits the amount of log lines to show in the chat window. This may slightly improve performance.</value>
|
||||
</data>
|
||||
<data name="Options_WebinterfaceMaxLinesToSend_Name" xml:space="preserve">
|
||||
<value>Log line limit for the webinterface</value>
|
||||
</data>
|
||||
<data name="Options_WebinterfaceMaxLinesToSend_Description" xml:space="preserve">
|
||||
<value>Limits the amount of log lines to show in the webinterface. This will improve loading performance.</value>
|
||||
</data>
|
||||
<data name="LoadMessages_Error" xml:space="preserve">
|
||||
<value>An error occurred while loading chat history. Please see plugin logs for more information to report this issue.</value>
|
||||
</data>
|
||||
|
||||
@@ -50,7 +50,8 @@ internal sealed class ChatLog : ISettingsTab
|
||||
ImGuiUtil.DragFloatVertical(Language.Options_WindowOpacity_Name, ref Mutable.WindowAlpha, .25f, 0f, 100f, $"{Mutable.WindowAlpha:N2}%%", ImGuiSliderFlags.AlwaysClamp);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGuiUtil.InputIntVertical(Language.Options_MaxLinesToShow_Name, Language.Options_MaxLinesToShow_Description, ref Mutable.MaxLinesToRender)) Mutable.MaxLinesToRender = Math.Clamp(Mutable.MaxLinesToRender, 1, 10_000);
|
||||
if (ImGuiUtil.InputIntVertical(Language.Options_MaxLinesToShow_Name, Language.Options_MaxLinesToShow_Description, ref Mutable.MaxLinesToRender))
|
||||
Mutable.MaxLinesToRender = Math.Clamp(Mutable.MaxLinesToRender, 1, 10_000);
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.CanMove, Language.Options_CanMove_Name);
|
||||
|
||||
@@ -54,6 +54,10 @@ internal sealed class Webinterface(Plugin plugin, Configuration mutable) : ISett
|
||||
Mutable.WebinterfacePort = Math.Clamp(Mutable.WebinterfacePort, 1024, 49151);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGuiUtil.InputIntVertical(Language.Options_WebinterfaceMaxLinesToSend_Name, Language.Options_WebinterfaceMaxLinesToSend_Description, ref Mutable.WebinterfaceMaxLinesToSend))
|
||||
Mutable.WebinterfaceMaxLinesToSend = Math.Clamp(Mutable.WebinterfaceMaxLinesToSend, 1, 10_000);
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudOrange, Language.Webinterface_CurrentPassword);
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted(Mutable.WebinterfacePassword);
|
||||
|
||||
Reference in New Issue
Block a user