Add pre-testing version of the webinterface
This commit is contained in:
+103
-81
@@ -58,7 +58,7 @@ public sealed class ChatLogWindow : Window
|
||||
private int InputBacklogIdx = -1;
|
||||
private int LastTab { get; set; }
|
||||
private InputChannel? TempChannel;
|
||||
private TellTarget? TellTarget;
|
||||
internal TellTarget? TellTarget;
|
||||
public bool TellSpecial;
|
||||
private readonly Stopwatch LastResize = new();
|
||||
private AutoCompleteInfo? AutoCompleteInfo;
|
||||
@@ -555,84 +555,7 @@ public sealed class ChatLogWindow : Window
|
||||
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero))
|
||||
{
|
||||
if (TellTarget != null)
|
||||
{
|
||||
var playerName = TellTarget.Name;
|
||||
if (ScreenshotMode)
|
||||
// Note: don't use HidePlayerInString here because
|
||||
// abbreviation settings do not affect this.
|
||||
playerName = HashPlayer(TellTarget.Name, TellTarget.World);
|
||||
var world = WorldSheet.GetRow(TellTarget.World)?.Name?.RawString ?? "???";
|
||||
|
||||
DrawChunks(new Chunk[]
|
||||
{
|
||||
new TextChunk(ChunkSource.None, null, "Tell "),
|
||||
new TextChunk(ChunkSource.None, null, playerName),
|
||||
new IconChunk(ChunkSource.None, null, BitmapFontIcon.CrossWorld),
|
||||
new TextChunk(ChunkSource.None, null, world),
|
||||
});
|
||||
}
|
||||
else if (TempChannel != null)
|
||||
{
|
||||
if (TempChannel.Value.IsLinkshell())
|
||||
{
|
||||
var idx = (uint) TempChannel.Value - (uint) InputChannel.Linkshell1;
|
||||
var lsName = Plugin.Functions.Chat.GetLinkshellName(idx);
|
||||
ImGui.TextUnformatted($"LS #{idx + 1}: {lsName}");
|
||||
}
|
||||
else if (TempChannel.Value.IsCrossLinkshell())
|
||||
{
|
||||
var idx = (uint) TempChannel.Value - (uint) InputChannel.CrossLinkshell1;
|
||||
var cwlsName = Plugin.Functions.Chat.GetCrossLinkshellName(idx);
|
||||
ImGui.TextUnformatted($"CWLS [{idx + 1}]: {cwlsName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted(TempChannel.Value.ToChatType().Name());
|
||||
}
|
||||
}
|
||||
else if (activeTab is { Channel: { } channel })
|
||||
{
|
||||
// We cannot lookup ExtraChat channel names from index over
|
||||
// IPC so we just don't show the name if it's the tabs
|
||||
// channel.
|
||||
//
|
||||
// We don't call channel.ToChatType().Name() as it has the
|
||||
// long name as used in the settings window.
|
||||
ImGui.TextUnformatted(channel.IsExtraChatLinkshell() ? $"ECLS [{channel.LinkshellIndex() + 1}]" : channel.ToChatType().Name());
|
||||
}
|
||||
else if (Plugin.ExtraChat.ChannelOverride is var (overrideName, _))
|
||||
{
|
||||
ImGui.TextUnformatted(overrideName);
|
||||
}
|
||||
else if (ScreenshotMode && Plugin.Functions.Chat.Channel is (InputChannel.Tell, _, var tellPlayerName, var tellWorldId))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(tellPlayerName) && tellWorldId != 0)
|
||||
{
|
||||
// Note: don't use HidePlayerInString here because
|
||||
// abbreviation settings do not affect this.
|
||||
var playerName = HashPlayer(tellPlayerName, tellWorldId);
|
||||
var world = WorldSheet.GetRow(tellWorldId)?.Name?.RawString ?? "???";
|
||||
|
||||
DrawChunks(new Chunk[]
|
||||
{
|
||||
new TextChunk(ChunkSource.None, null, "Tell "),
|
||||
new TextChunk(ChunkSource.None, null, playerName),
|
||||
new IconChunk(ChunkSource.None, null, BitmapFontIcon.CrossWorld),
|
||||
new TextChunk(ChunkSource.None, null, world),
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// We still need to censor the name if we couldn't read
|
||||
// valid data.
|
||||
ImGui.TextUnformatted("Tell");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawChunks(Plugin.Functions.Chat.Channel.Name);
|
||||
}
|
||||
DrawChannelName(activeTab);
|
||||
}
|
||||
|
||||
var beforeIcon = ImGui.GetCursorPos();
|
||||
@@ -826,6 +749,105 @@ public sealed class ChatLogWindow : Window
|
||||
GameFunctions.GameFunctions.ClickNoviceNetworkButton();
|
||||
}
|
||||
|
||||
private void DrawChannelName(Tab? activeTab)
|
||||
{
|
||||
DrawChunks(ReadChannelName(activeTab));
|
||||
}
|
||||
|
||||
internal Chunk[] ReadChannelName(Tab? activeTab)
|
||||
{
|
||||
Chunk[] channelNameChunks;
|
||||
if (TellTarget != null)
|
||||
{
|
||||
var playerName = TellTarget.Name;
|
||||
if (ScreenshotMode)
|
||||
// Note: don't use HidePlayerInString here because
|
||||
// abbreviation settings do not affect this.
|
||||
playerName = HashPlayer(TellTarget.Name, TellTarget.World);
|
||||
var world = WorldSheet.GetRow(TellTarget.World)?.Name?.RawString ?? "???";
|
||||
|
||||
channelNameChunks = new Chunk[]
|
||||
{
|
||||
new TextChunk(ChunkSource.None, null, "Tell "),
|
||||
new TextChunk(ChunkSource.None, null, playerName),
|
||||
new IconChunk(ChunkSource.None, null, BitmapFontIcon.CrossWorld),
|
||||
new TextChunk(ChunkSource.None, null, world),
|
||||
};
|
||||
}
|
||||
else if (TempChannel != null)
|
||||
{
|
||||
string name;
|
||||
if (TempChannel.Value.IsLinkshell())
|
||||
{
|
||||
var idx = (uint) TempChannel.Value - (uint) InputChannel.Linkshell1;
|
||||
var lsName = Plugin.Functions.Chat.GetLinkshellName(idx);
|
||||
name = $"LS #{idx + 1}: {lsName}";
|
||||
}
|
||||
else if (TempChannel.Value.IsCrossLinkshell())
|
||||
{
|
||||
var idx = (uint) TempChannel.Value - (uint) InputChannel.CrossLinkshell1;
|
||||
var cwlsName = Plugin.Functions.Chat.GetCrossLinkshellName(idx);
|
||||
name = $"CWLS [{idx + 1}]: {cwlsName}";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = TempChannel.Value.ToChatType().Name();
|
||||
}
|
||||
|
||||
channelNameChunks = [new TextChunk(ChunkSource.None, null, name)];
|
||||
}
|
||||
else if (activeTab is { Channel: { } channel })
|
||||
{
|
||||
// We cannot lookup ExtraChat channel names from index over
|
||||
// IPC so we just don't show the name if it's the tabs
|
||||
// channel.
|
||||
//
|
||||
// We don't call channel.ToChatType().Name() as it has the
|
||||
// long name as used in the settings window.
|
||||
channelNameChunks = new Chunk[]
|
||||
{
|
||||
new TextChunk(ChunkSource.None, null, channel.IsExtraChatLinkshell() ? $"ECLS [{channel.LinkshellIndex() + 1}]" : channel.ToChatType().Name())
|
||||
};
|
||||
}
|
||||
else if (Plugin.ExtraChat.ChannelOverride is var (overrideName, _))
|
||||
{
|
||||
channelNameChunks = new Chunk[]
|
||||
{
|
||||
new TextChunk(ChunkSource.None, null, overrideName)
|
||||
};
|
||||
}
|
||||
else if (ScreenshotMode && Plugin.Functions.Chat.Channel is (InputChannel.Tell, _, var tellPlayerName, var tellWorldId))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(tellPlayerName) && tellWorldId != 0)
|
||||
{
|
||||
// Note: don't use HidePlayerInString here because
|
||||
// abbreviation settings do not affect this.
|
||||
var playerName = HashPlayer(tellPlayerName, tellWorldId);
|
||||
var world = WorldSheet.GetRow(tellWorldId)?.Name?.RawString ?? "???";
|
||||
|
||||
channelNameChunks = new Chunk[]
|
||||
{
|
||||
new TextChunk(ChunkSource.None, null, "Tell "),
|
||||
new TextChunk(ChunkSource.None, null, playerName),
|
||||
new IconChunk(ChunkSource.None, null, BitmapFontIcon.CrossWorld),
|
||||
new TextChunk(ChunkSource.None, null, world),
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// We still need to censor the name if we couldn't read
|
||||
// valid data.
|
||||
channelNameChunks = [new TextChunk(ChunkSource.None, null, "Tell")];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
channelNameChunks = Plugin.Functions.Chat.Channel.Name.ToArray();
|
||||
}
|
||||
|
||||
return channelNameChunks;
|
||||
}
|
||||
|
||||
internal void SetChannel(InputChannel? channel)
|
||||
{
|
||||
channel ??= InputChannel.Say;
|
||||
@@ -852,7 +874,7 @@ public sealed class ChatLogWindow : Window
|
||||
GameFunctions.Chat.SetChannel(channel.Value);
|
||||
}
|
||||
|
||||
private void SendChatBox(Tab? activeTab)
|
||||
internal void SendChatBox(Tab? activeTab)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(Chat))
|
||||
{
|
||||
@@ -1727,7 +1749,7 @@ public sealed class ChatLogWindow : Window
|
||||
|
||||
}
|
||||
|
||||
private string HidePlayerInString(string str, string playerName, uint worldId)
|
||||
internal string HidePlayerInString(string str, string playerName, uint worldId)
|
||||
{
|
||||
var expected = Plugin.Functions.Chat.AbbreviatePlayerName(playerName);
|
||||
var hash = HashPlayer(playerName, worldId);
|
||||
|
||||
@@ -37,10 +37,11 @@ public sealed class SettingsWindow : Window
|
||||
new ChatLog(Plugin, Mutable),
|
||||
new Emote(Plugin, Mutable),
|
||||
new Preview(Plugin, Mutable),
|
||||
new Ui.SettingsTabs.Fonts(Mutable),
|
||||
new Fonts(Mutable),
|
||||
new ChatColours(Plugin, Mutable),
|
||||
new Tabs(Plugin, Mutable),
|
||||
new Database(Plugin, Mutable),
|
||||
new Webinterface(Plugin, Mutable),
|
||||
new Miscellaneous(Mutable),
|
||||
new Changelog(Mutable),
|
||||
new About(),
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using ChatTwo.Resources;
|
||||
using ChatTwo.Util;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ChatTwo.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class Webinterface(Plugin plugin, Configuration mutable) : ISettingsTab
|
||||
{
|
||||
private Plugin Plugin { get; } = plugin;
|
||||
private Configuration Mutable { get; } = mutable;
|
||||
public string Name => Language.Options_Webinterface_Tab + "###tabs-Webinterface";
|
||||
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudWhite, "On checking 'Enabled' this will enable and load up Chat2's built-in web interface, which will allow devices on your network to access in-game chat. This feature may be used to allow a phone or another computer to see Chat2 activity, switch channels, and send messages as though you were typing in FFXIV itself.");
|
||||
ImGui.Spacing();
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.HealerGreen, "Note: This will require at least a semi-modern browser in order to function correctly.");
|
||||
ImGui.Spacing();
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudOrange, "For reasons of account security, this feature is not intended for use outside of your local network, you have been warned!");
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Spacing();
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudViolet, "Do Not:");
|
||||
using (ImRaii.PushIndent(15.0f))
|
||||
{
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudViolet, "- Forward the ports used (9000 and 9001)");
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudViolet, "- Share your authentication code with anyone else");
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudViolet, "- Expect multi-boxing to work with this (only first client is tracked and utilised)");
|
||||
}
|
||||
ImGui.Spacing();
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudOrange, "No support will be provided if any of the 'Do Not' clauses aren't respected and adhered to appropriately.");
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.Checkbox(Language.Options_WebinterfaceEnable_Name, ref Mutable.WebinterfaceEnabled);
|
||||
ImGuiUtil.HelpText(Language.Options_WebinterfaceEnable_Description);
|
||||
ImGui.Spacing();
|
||||
|
||||
if (!Mutable.WebinterfaceEnabled)
|
||||
return;
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudOrange, Language.Webinterface_CurrentPassword);
|
||||
ImGui.TextUnformatted(Mutable.WebinterfacePassword);
|
||||
ImGui.SameLine();
|
||||
if (ImGuiUtil.IconButton(FontAwesomeIcon.Recycle, tooltip: Language.Webinterface_PasswordReset_Tooltip))
|
||||
Mutable.WebinterfacePassword = WebinterfaceUtil.GenerateSimpleAuthCode();
|
||||
|
||||
ImGuiUtil.WrappedTextWithColor(ImGuiColors.HealerGreen, Language.Webinterface_Status);
|
||||
using (ImRaii.PushIndent(10.0f))
|
||||
{
|
||||
ImGui.TextUnformatted(Language.Webinterface_Status_Active);
|
||||
ImGui.SameLine();
|
||||
|
||||
var isActive = Plugin.ServerCore.GetStats();
|
||||
using (Plugin.FontManager.FontAwesome.Push())
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, isActive ? ImGuiColors.HealerGreen : ImGuiColors.DalamudOrange))
|
||||
{
|
||||
ImGui.TextUnformatted($"{(isActive ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Cross.ToIconString())}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user