up to date with 2.0.3
This commit is contained in:
@@ -6,12 +6,12 @@ using Dalamud.Utility;
|
||||
using LightlessSync.FileCache;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
using LightlessSync.LightlessConfiguration.Models;
|
||||
using LightlessSync.Localization;
|
||||
using LightlessSync.Services;
|
||||
using LightlessSync.Services.Mediator;
|
||||
using LightlessSync.Services.ServerConfiguration;
|
||||
using LightlessSync.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -21,7 +21,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
private readonly LightlessConfigService _configService;
|
||||
private readonly CacheMonitor _cacheMonitor;
|
||||
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
|
||||
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" }, { "中文", "zh"} };
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly DalamudUtilService _dalamudUtilService;
|
||||
private readonly UiSharedService _uiShared;
|
||||
@@ -31,7 +31,6 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
private string _secretKey = string.Empty;
|
||||
private string _timeoutLabel = string.Empty;
|
||||
private Task? _timeoutTask;
|
||||
private string[]? _tosParagraphs;
|
||||
private bool _useLegacyLogin = false;
|
||||
|
||||
public IntroUi(ILogger<IntroUi> logger, UiSharedService uiShared, LightlessConfigService configService,
|
||||
@@ -50,8 +49,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
WindowBuilder.For(this)
|
||||
.SetSizeConstraints(new Vector2(600, 400), new Vector2(600, 2000))
|
||||
.Apply();
|
||||
|
||||
GetToSLocalization();
|
||||
|
||||
|
||||
Mediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = false);
|
||||
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) =>
|
||||
@@ -88,7 +86,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
for (int i = 60; i > 0; i--)
|
||||
{
|
||||
_timeoutLabel = $"{Strings.ToS.ButtonWillBeAvailableIn} {i}s";
|
||||
_timeoutLabel = $"{Resources.Resources.ToSStrings_ButtonWillBeAvailableIn} {i}s";
|
||||
await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
@@ -102,44 +100,46 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
Vector2 textSize;
|
||||
using (_uiShared.UidFont.Push())
|
||||
{
|
||||
textSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
|
||||
ImGui.TextUnformatted(Strings.ToS.AgreementLabel);
|
||||
textSize = ImGui.CalcTextSize(Resources.Resources.ToSStrings_LanguageLabel);
|
||||
ImGui.TextUnformatted(Resources.Resources.ToSStrings_AgreementLabel);
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
var languageSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
|
||||
var languageSize = ImGui.CalcTextSize(Resources.Resources.ToSStrings_LanguageLabel);
|
||||
ImGui.SetCursorPosX(ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - languageSize.X - 80);
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - languageSize.Y / 2);
|
||||
|
||||
ImGui.TextUnformatted(Strings.ToS.LanguageLabel);
|
||||
ImGui.TextUnformatted(Resources.Resources.ToSStrings_LanguageLabel);
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - (languageSize.Y + ImGui.GetStyle().FramePadding.Y) / 2);
|
||||
ImGui.SetNextItemWidth(80);
|
||||
if (ImGui.Combo("", ref _currentLanguage, _languages.Keys.ToArray(), _languages.Count))
|
||||
{
|
||||
GetToSLocalization(_currentLanguage);
|
||||
var culture = new CultureInfo(_languages.Values.ToArray()[_currentLanguage]);
|
||||
CultureInfo.DefaultThreadCurrentCulture = culture;
|
||||
CultureInfo.DefaultThreadCurrentUICulture = culture;
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.SetWindowFontScale(1.5f);
|
||||
string readThis = Strings.ToS.ReadLabel;
|
||||
string readThis = Resources.Resources.ToSStrings_ReadLabel;
|
||||
textSize = ImGui.CalcTextSize(readThis);
|
||||
ImGui.SetCursorPosX(ImGui.GetWindowSize().X / 2 - textSize.X / 2);
|
||||
UiSharedService.ColorText(readThis, ImGuiColors.DalamudRed);
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
ImGui.Separator();
|
||||
|
||||
UiSharedService.TextWrapped(_tosParagraphs![0]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![1]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![2]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![3]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![4]);
|
||||
UiSharedService.TextWrapped(_tosParagraphs![5]);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph1);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph2);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph3);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph4);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph5);
|
||||
UiSharedService.TextWrapped(Resources.Resources.ToSStrings_Paragraph6);
|
||||
|
||||
ImGui.Separator();
|
||||
if (_timeoutTask?.IsCompleted ?? true)
|
||||
{
|
||||
if (ImGui.Button(Strings.ToS.AgreeLabel + "##toSetup"))
|
||||
if (ImGui.Button(Resources.Resources.ToSStrings_AgreeLabel + "##toSetup"))
|
||||
{
|
||||
_configService.Current.AcceptedAgreement = true;
|
||||
_configService.Save();
|
||||
@@ -349,16 +349,6 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
private void GetToSLocalization(int changeLanguageTo = -1)
|
||||
{
|
||||
if (changeLanguageTo != -1)
|
||||
{
|
||||
_uiShared.LoadLocalization(_languages.ElementAt(changeLanguageTo).Value);
|
||||
}
|
||||
|
||||
_tosParagraphs = [Strings.ToS.Paragraph1, Strings.ToS.Paragraph2, Strings.ToS.Paragraph3, Strings.ToS.Paragraph4, Strings.ToS.Paragraph5, Strings.ToS.Paragraph6];
|
||||
}
|
||||
|
||||
[GeneratedRegex("^[A-F0-9]{64}$", RegexOptions.Compiled | RegexOptions.CultureInvariant)]
|
||||
private static partial Regex SecretRegex();
|
||||
}
|
||||
@@ -497,7 +497,7 @@ public class LightFinderUI : WindowMediatorSubscriberBase
|
||||
|
||||
var cardData = new List<(GroupJoinDto Shell, string BroadcasterName, bool IsOwnBroadcast)>();
|
||||
|
||||
foreach (var shell in _nearbySyncshells)
|
||||
foreach (var shell in _nearbySyncshells.ToArray())
|
||||
{
|
||||
if (shell?.Group == null || string.IsNullOrEmpty(shell.Group.GID))
|
||||
continue;
|
||||
@@ -759,29 +759,22 @@ public class LightFinderUI : WindowMediatorSubscriberBase
|
||||
|
||||
var scale = ImGuiHelpers.GlobalScale;
|
||||
|
||||
// if not already open
|
||||
if (!ImGui.IsPopupOpen("JoinSyncshellModal"))
|
||||
ImGui.OpenPopup("JoinSyncshellModal");
|
||||
|
||||
Vector2 windowPos = ImGui.GetWindowPos();
|
||||
Vector2 windowSize = ImGui.GetWindowSize();
|
||||
float modalWidth = Math.Min(420f * scale, windowSize.X - 40f * scale);
|
||||
float modalHeight = 295f * scale;
|
||||
ImGui.SetNextWindowPos(new Vector2(
|
||||
windowPos.X + (windowSize.X - modalWidth) * 0.5f,
|
||||
windowPos.Y + (windowSize.Y - modalHeight) * 0.5f
|
||||
), ImGuiCond.Always);
|
||||
ImGui.SetNextWindowSize(new Vector2(modalWidth, modalHeight));
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 6f * ImGuiHelpers.GlobalScale);
|
||||
ImGui.PushStyleColor(ImGuiCol.Border, Vector4.Zero);
|
||||
Vector2 childPos = new Vector2(
|
||||
(windowSize.X - modalWidth) * 0.5f,
|
||||
(windowSize.Y - modalHeight) * 0.5f
|
||||
);
|
||||
ImGui.SetCursorPos(childPos);
|
||||
|
||||
using ImRaii.Color modalBorder = ImRaii.PushColor(ImGuiCol.Border, UIColors.Get("LightlessPurple").WithAlpha(0.5f));
|
||||
using ImRaii.Style rounding = ImRaii.PushStyle(ImGuiStyleVar.WindowRounding, 8f * scale);
|
||||
using ImRaii.Style borderSize = ImRaii.PushStyle(ImGuiStyleVar.WindowBorderSize, 2f * scale);
|
||||
using ImRaii.Style padding = ImRaii.PushStyle(ImGuiStyleVar.WindowPadding, new Vector2(16f * scale, 16f * scale));
|
||||
using var modalBorder = ImRaii.PushColor(ImGuiCol.Border, UIColors.Get("LightlessPurple").WithAlpha(0.5f));
|
||||
using var childBg = ImRaii.PushColor(ImGuiCol.ChildBg, ImGui.GetStyle().Colors[(int)ImGuiCol.WindowBg]);
|
||||
using var rounding = ImRaii.PushStyle(ImGuiStyleVar.ChildRounding, 8f * scale);
|
||||
using var borderSize = ImRaii.PushStyle(ImGuiStyleVar.ChildBorderSize, 2f * scale);
|
||||
using var padding = ImRaii.PushStyle(ImGuiStyleVar.WindowPadding, new Vector2(16f * scale, 16f * scale));
|
||||
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar;
|
||||
if (ImGui.BeginPopupModal("JoinSyncshellModal", ref _joinModalOpen, flags))
|
||||
if (ImGui.BeginChild("JoinSyncshellOverlay", new Vector2(modalWidth, modalHeight), true, ImGuiWindowFlags.NoScrollbar))
|
||||
{
|
||||
float contentWidth = ImGui.GetContentRegionAvail().X;
|
||||
|
||||
@@ -843,7 +836,7 @@ public class LightFinderUI : WindowMediatorSubscriberBase
|
||||
|
||||
_joinDto = null;
|
||||
_joinInfo = null;
|
||||
ImGui.CloseCurrentPopup();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,20 +851,13 @@ public class LightFinderUI : WindowMediatorSubscriberBase
|
||||
{
|
||||
_joinDto = null;
|
||||
_joinInfo = null;
|
||||
ImGui.CloseCurrentPopup();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle modal close via the bool ref
|
||||
if (!_joinModalOpen)
|
||||
{
|
||||
_joinDto = null;
|
||||
_joinInfo = null;
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
||||
private void DrawPermissionToggleRow(string label, FontAwesomeIcon icon, bool suggested, bool current, Action<bool> apply, float contentWidth)
|
||||
@@ -1580,11 +1566,20 @@ public class LightFinderUI : WindowMediatorSubscriberBase
|
||||
|
||||
if (previousGid != null)
|
||||
{
|
||||
var newIndex = _nearbySyncshells.FindIndex(s => string.Equals(s.Group.GID, previousGid, StringComparison.Ordinal));
|
||||
if (newIndex >= 0)
|
||||
try
|
||||
{
|
||||
_selectedNearbyIndex = newIndex;
|
||||
return;
|
||||
var nearbySyncshellsSnapshot = _nearbySyncshells.ToArray();
|
||||
var newIndex = Array.FindIndex(nearbySyncshellsSnapshot,
|
||||
s => string.Equals(s.Group.GID, previousGid, StringComparison.Ordinal));
|
||||
if (newIndex >= 0)
|
||||
{
|
||||
_selectedNearbyIndex = newIndex;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
ClearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1626,9 +1621,18 @@ public class LightFinderUI : WindowMediatorSubscriberBase
|
||||
|
||||
private string? GetSelectedGid()
|
||||
{
|
||||
if (_selectedNearbyIndex < 0 || _selectedNearbyIndex >= _nearbySyncshells.Count)
|
||||
try
|
||||
{
|
||||
var index = _selectedNearbyIndex;
|
||||
var list = _nearbySyncshells.ToArray();
|
||||
if (index < 0 || index >= list.Length)
|
||||
return null;
|
||||
return list[index].Group.GID;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
return _nearbySyncshells[_selectedNearbyIndex].Group.GID;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -3279,16 +3279,16 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
|
||||
var labels = new[]
|
||||
{
|
||||
"Unsafe",
|
||||
"Safe (Race)",
|
||||
"Safest (Race + Bones)",
|
||||
"Unsafe (Off)",
|
||||
"Safe (Race Check)",
|
||||
"Safest (Race + Bones Check)",
|
||||
};
|
||||
|
||||
var tooltips = new[]
|
||||
{
|
||||
"No validation. Fastest, but may allow incompatible animations (riskier).",
|
||||
"Validates skeleton race + modded skeleton check (recommended).",
|
||||
"Requires matching skeleton race + bone compatibility (strictest).",
|
||||
"No validation. Fastest, but may allow incompatible animations.",
|
||||
"Validates skeleton race + modded skeleton check. Will be safer to use but will block some animations",
|
||||
"Requires matching skeleton race + bone compatibility. Will block alot, not recommended.",
|
||||
};
|
||||
|
||||
|
||||
@@ -4630,7 +4630,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
ImGui.TextColored(UIColors.Get("LightlessBlue"),
|
||||
_apiController.OnlineUsers.ToString(CultureInfo.InvariantCulture));
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted("Users Online");
|
||||
ImGui.TextUnformatted(Resources.Resources.Users_Online);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(")");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ using LightlessSync.Interop.Ipc;
|
||||
using LightlessSync.Interop.Ipc.Framework;
|
||||
using LightlessSync.LightlessConfiguration;
|
||||
using LightlessSync.LightlessConfiguration.Models;
|
||||
using LightlessSync.Localization;
|
||||
using LightlessSync.PlayerData.Pairs;
|
||||
using LightlessSync.Services;
|
||||
using LightlessSync.Services.Mediator;
|
||||
@@ -1468,12 +1467,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
return false;
|
||||
}
|
||||
|
||||
public void LoadLocalization(string languageCode)
|
||||
{
|
||||
_localization.SetupWithLangCode(languageCode);
|
||||
Strings.ToS = new Strings.ToSStrings();
|
||||
}
|
||||
|
||||
internal static void DistanceSeparator()
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
||||
Reference in New Issue
Block a user