- Loc updates

- Add access URL to webinterface panel
This commit is contained in:
Infi
2024-08-28 14:31:25 +02:00
parent 2ababa82b0
commit 8d6f59f9fa
5 changed files with 59 additions and 26 deletions
+2 -16
View File
@@ -417,7 +417,7 @@ public sealed class PayloadHandler {
GameFunctions.GameFunctions.OpenPartyFinder(); GameFunctions.GameFunctions.OpenPartyFinder();
break; break;
case UriPayload uri: case UriPayload uri:
TryOpenURI(uri.Uri); WrapperUtil.TryOpenURI(uri.Uri);
break; break;
default: default:
RightClickPayload(chunk, payload); RightClickPayload(chunk, payload);
@@ -671,7 +671,7 @@ public sealed class PayloadHandler {
ImGui.Separator(); ImGui.Separator();
if (ImGui.Selectable(Language.Context_OpenInBrowser)) if (ImGui.Selectable(Language.Context_OpenInBrowser))
TryOpenURI(uri.Uri); WrapperUtil.TryOpenURI(uri.Uri);
if (ImGui.Selectable(Language.Context_CopyLink)) if (ImGui.Selectable(Language.Context_CopyLink))
{ {
@@ -679,18 +679,4 @@ public sealed class PayloadHandler {
WrapperUtil.AddNotification(Language.Context_CopyLinkNotification, NotificationType.Info); WrapperUtil.AddNotification(Language.Context_CopyLinkNotification, NotificationType.Info);
} }
} }
private void TryOpenURI(Uri uri)
{
try
{
Plugin.Log.Debug($"Opening URI {uri} in default browser");
Dalamud.Utility.Util.OpenLink(uri.ToString());
}
catch (Exception ex)
{
Plugin.Log.Error($"Error opening URI: {ex}");
WrapperUtil.AddNotification(Language.Context_OpenInBrowserError, NotificationType.Error);
}
}
} }
+10 -1
View File
@@ -3606,7 +3606,7 @@ namespace ChatTwo.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Controls:. /// Looks up a localized string similar to Control Panel:.
/// </summary> /// </summary>
internal static string Webinterface_Controls { internal static string Webinterface_Controls {
get { get {
@@ -3623,6 +3623,15 @@ namespace ChatTwo.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to URL:.
/// </summary>
internal static string Webinterface_Controls_Url {
get {
return ResourceManager.GetString("Webinterface_Controls_Url", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Authcode:. /// Looks up a localized string similar to Authcode:.
/// </summary> /// </summary>
+4 -1
View File
@@ -581,11 +581,14 @@
<value>Reset your password and invalidate all session tokens.</value> <value>Reset your password and invalidate all session tokens.</value>
</data> </data>
<data name="Webinterface_Controls"> <data name="Webinterface_Controls">
<value>Controls:</value> <value>Control Panel:</value>
</data> </data>
<data name="Webinterface_Controls_Active"> <data name="Webinterface_Controls_Active">
<value>Active:</value> <value>Active:</value>
</data> </data>
<data name="Webinterface_Controls_Url">
<value>URL:</value>
</data>
<data name="Keybind_None"> <data name="Keybind_None">
<value>none set</value> <value>none set</value>
</data> </data>
+27 -7
View File
@@ -16,9 +16,7 @@ internal sealed class Webinterface(Plugin plugin, Configuration mutable) : ISett
public void Draw(bool changed) 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."); ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudWhite, "After checking 'Enabled' and clicking 'Start' this will 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(); 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!"); 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!");
@@ -29,7 +27,7 @@ internal sealed class Webinterface(Plugin plugin, Configuration mutable) : ISett
{ {
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudViolet, "- Forward the port used (9000)"); ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudViolet, "- Forward the port used (9000)");
ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudViolet, "- Share your authentication code with anyone else"); 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)"); ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudViolet, "- Expect multi-boxing to work with this (only first client works)");
} }
ImGui.Spacing(); 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."); ImGuiUtil.WrappedTextWithColor(ImGuiColors.DalamudOrange, "No support will be provided if any of the 'Do Not' clauses aren't respected and adhered to appropriately.");
@@ -43,8 +41,6 @@ internal sealed class Webinterface(Plugin plugin, Configuration mutable) : ISett
if (!Mutable.WebinterfaceEnabled) if (!Mutable.WebinterfaceEnabled)
return; return;
ImGui.Separator();
ImGui.Spacing(); ImGui.Spacing();
ImGuiUtil.OptionCheckbox(ref Mutable.WebinterfaceAutoStart, Language.Options_WebinterfaceAutoStart_Name, Language.Options_WebinterfaceAutoStart_Description); ImGuiUtil.OptionCheckbox(ref Mutable.WebinterfaceAutoStart, Language.Options_WebinterfaceAutoStart_Name, Language.Options_WebinterfaceAutoStart_Description);
@@ -63,7 +59,7 @@ internal sealed class Webinterface(Plugin plugin, Configuration mutable) : ISett
Plugin.ServerCore.InvalidateSessions(); Plugin.ServerCore.InvalidateSessions();
} }
ImGuiUtil.WrappedTextWithColor(ImGuiColors.HealerGreen, Language.Webinterface_Controls); ImGui.TextUnformatted(Language.Webinterface_Controls);
using (ImRaii.PushIndent(10.0f)) using (ImRaii.PushIndent(10.0f))
{ {
ImGui.TextUnformatted(Language.Webinterface_Controls_Active); ImGui.TextUnformatted(Language.Webinterface_Controls_Active);
@@ -76,6 +72,27 @@ internal sealed class Webinterface(Plugin plugin, Configuration mutable) : ISett
ImGui.TextUnformatted(isActive ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString()); ImGui.TextUnformatted(isActive ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString());
} }
Uri? uri;
try {
uri = new Uri($"http://{System.Net.Dns.GetHostName()}:{Mutable.WebinterfacePort}/");
}
catch(Exception)
{
uri = null;
}
ImGui.TextUnformatted(Language.Webinterface_Controls_Url);
ImGui.SameLine();
if (uri is not null)
{
if (ImGui.Selectable(uri.AbsoluteUri))
WrapperUtil.TryOpenURI(uri);
}
else
{
ImGui.TextUnformatted("Unable to resolve hostname.");
}
using (ImRaii.Disabled(isActive || Plugin.ServerCore.IsStopping())) using (ImRaii.Disabled(isActive || Plugin.ServerCore.IsStopping()))
{ {
if (ImGui.Button(Language.Webinterface_Button_Start)) if (ImGui.Button(Language.Webinterface_Button_Start))
@@ -113,6 +130,9 @@ internal sealed class Webinterface(Plugin plugin, Configuration mutable) : ISett
} }
} }
} }
ImGui.Spacing(); ImGui.Spacing();
ImGui.Spacing();
ImGuiUtil.WrappedTextWithColor(ImGuiColors.HealerGreen, "Note: This will require at least a semi-modern browser in order to function correctly.");
} }
} }
+16 -1
View File
@@ -1,4 +1,5 @@
using Dalamud.Interface.ImGuiNotification; using ChatTwo.Resources;
using Dalamud.Interface.ImGuiNotification;
namespace ChatTwo.Util; namespace ChatTwo.Util;
@@ -9,6 +10,20 @@ public static class WrapperUtil
Plugin.Notification.AddNotification(new Notification { Content = content, Type = type, Minimized = minimized }); Plugin.Notification.AddNotification(new Notification { Content = content, Type = type, Minimized = minimized });
} }
public static void TryOpenURI(Uri uri)
{
try
{
Plugin.Log.Debug($"Opening URI {uri} in default browser");
Dalamud.Utility.Util.OpenLink(uri.ToString());
}
catch (Exception ex)
{
Plugin.Log.Error($"Error opening URI: {ex}");
AddNotification(Language.Context_OpenInBrowserError, NotificationType.Error);
}
}
public static IEnumerable<(T Value, int Index)> WithIndex<T>(this IEnumerable<T> list) public static IEnumerable<(T Value, int Index)> WithIndex<T>(this IEnumerable<T> list)
=> list.Select((x, i) => (x, i)); => list.Select((x, i) => (x, i));
} }