|
|
|
|
@@ -4,14 +4,17 @@ using Dalamud.Interface.Colors;
|
|
|
|
|
using Dalamud.Interface.ImGuiFileDialog;
|
|
|
|
|
using Dalamud.Interface.Textures.TextureWraps;
|
|
|
|
|
using Dalamud.Interface.Utility;
|
|
|
|
|
using Dalamud.Interface.Utility.Raii;
|
|
|
|
|
using LightlessSync.API.Data;
|
|
|
|
|
using LightlessSync.API.Dto.User;
|
|
|
|
|
using LightlessSync.Services;
|
|
|
|
|
using LightlessSync.Services.Mediator;
|
|
|
|
|
using LightlessSync.Utils;
|
|
|
|
|
using LightlessSync.WebAPI;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using SixLabors.ImageSharp;
|
|
|
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
|
|
|
using System.Numerics;
|
|
|
|
|
|
|
|
|
|
namespace LightlessSync.UI;
|
|
|
|
|
|
|
|
|
|
@@ -30,6 +33,15 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
|
|
|
|
private bool _showFileDialogError = false;
|
|
|
|
|
private bool _wasOpen;
|
|
|
|
|
|
|
|
|
|
private bool vanityInitialized; // useless for now
|
|
|
|
|
private bool textEnabled;
|
|
|
|
|
private bool glowEnabled;
|
|
|
|
|
private Vector4 textColor;
|
|
|
|
|
private Vector4 glowColor;
|
|
|
|
|
|
|
|
|
|
private record VanityState(bool TextEnabled, bool GlowEnabled, Vector4 TextColor, Vector4 GlowColor);
|
|
|
|
|
private VanityState _savedVanity;
|
|
|
|
|
|
|
|
|
|
public EditProfileUi(ILogger<EditProfileUi> logger, LightlessMediator mediator,
|
|
|
|
|
ApiController apiController, UiSharedService uiSharedService, FileDialogManager fileDialogManager,
|
|
|
|
|
LightlessProfileManager lightlessProfileManager, PerformanceCollectorService performanceCollectorService)
|
|
|
|
|
@@ -38,8 +50,8 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
|
|
|
|
IsOpen = false;
|
|
|
|
|
this.SizeConstraints = new()
|
|
|
|
|
{
|
|
|
|
|
MinimumSize = new(768, 512),
|
|
|
|
|
MaximumSize = new(768, 2000)
|
|
|
|
|
MinimumSize = new(850, 640),
|
|
|
|
|
MaximumSize = new(850, 700)
|
|
|
|
|
};
|
|
|
|
|
_apiController = apiController;
|
|
|
|
|
_uiSharedService = uiSharedService;
|
|
|
|
|
@@ -57,14 +69,61 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
|
|
|
|
_pfpTextureWrap = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Mediator.Subscribe<ConnectedMessage>(this, msg =>
|
|
|
|
|
{
|
|
|
|
|
LoadVanity();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawNoteLine(string icon, Vector4 color, string text)
|
|
|
|
|
{
|
|
|
|
|
_uiSharedService.MediumText(icon, color);
|
|
|
|
|
ImGui.SameLine();
|
|
|
|
|
|
|
|
|
|
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3);
|
|
|
|
|
ImGui.TextWrapped(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadVanity()
|
|
|
|
|
{
|
|
|
|
|
textEnabled = !string.IsNullOrEmpty(_apiController.TextColorHex);
|
|
|
|
|
glowEnabled = !string.IsNullOrEmpty(_apiController.TextGlowColorHex);
|
|
|
|
|
|
|
|
|
|
textColor = textEnabled ? UIColors.HexToRgba(_apiController.TextColorHex!) : Vector4.One;
|
|
|
|
|
glowColor = glowEnabled ? UIColors.HexToRgba(_apiController.TextGlowColorHex!) : Vector4.Zero;
|
|
|
|
|
|
|
|
|
|
_savedVanity = new VanityState(textEnabled, glowEnabled, textColor, glowColor);
|
|
|
|
|
vanityInitialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void DrawInternal()
|
|
|
|
|
{
|
|
|
|
|
_uiSharedService.BigText("Current Profile (as saved on server)");
|
|
|
|
|
_uiSharedService.UnderlinedBigText("Notes and Rules for Profiles", UIColors.Get("LightlessYellow"));
|
|
|
|
|
ImGui.Dummy(new Vector2(5));
|
|
|
|
|
|
|
|
|
|
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(2, 2));
|
|
|
|
|
|
|
|
|
|
DrawNoteLine("# ", UIColors.Get("LightlessBlue"), "All users that are paired and unpaused with you will be able to see your profile picture and description.");
|
|
|
|
|
DrawNoteLine("! ", UIColors.Get("LightlessYellow"), "Other users have the possibility to report your profile for breaking the rules.");
|
|
|
|
|
DrawNoteLine("!!! ", UIColors.Get("DimRed"), "AVOID: Anything as profile image that can be considered highly illegal or obscene (bestiality, anything that could be considered a sexual act with a minor (that includes Lalafells), etc.)");
|
|
|
|
|
DrawNoteLine("!!! ", UIColors.Get("DimRed"), "AVOID: Slurs of any kind in the description that can be considered highly offensive");
|
|
|
|
|
DrawNoteLine("! ", UIColors.Get("LightlessYellow"), "In case of valid reports from other users this can lead to disabling your profile forever or terminating your Lightless account indefinitely.");
|
|
|
|
|
DrawNoteLine("! ", UIColors.Get("LightlessYellow"), "Judgement of your profile validity from reports through staff is not up to debate and the decisions to disable your profile/account permanent.");
|
|
|
|
|
DrawNoteLine("! ", UIColors.Get("LightlessBlue"), "If your profile picture or profile description could be considered NSFW, enable the toggle in profile settings.");
|
|
|
|
|
|
|
|
|
|
ImGui.PopStyleVar();
|
|
|
|
|
|
|
|
|
|
ImGui.Dummy(new Vector2(3));
|
|
|
|
|
|
|
|
|
|
var profile = _lightlessProfileManager.GetLightlessProfile(new UserData(_apiController.UID));
|
|
|
|
|
|
|
|
|
|
if (ImGui.BeginTabBar("##EditProfileTabs"))
|
|
|
|
|
{
|
|
|
|
|
if (ImGui.BeginTabItem("Current Profile"))
|
|
|
|
|
{
|
|
|
|
|
_uiSharedService.MediumText("Current Profile (as saved on server)", UIColors.Get("LightlessPurple"));
|
|
|
|
|
ImGui.Dummy(new Vector2(5));
|
|
|
|
|
|
|
|
|
|
if (profile.IsFlagged)
|
|
|
|
|
{
|
|
|
|
|
UiSharedService.ColorTextWrapped(profile.Description, ImGuiColors.DalamudRed);
|
|
|
|
|
@@ -119,18 +178,14 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
|
|
|
|
ImGui.Checkbox("Is NSFW", ref nsfw);
|
|
|
|
|
ImGui.EndDisabled();
|
|
|
|
|
|
|
|
|
|
ImGui.Separator();
|
|
|
|
|
_uiSharedService.BigText("Notes and Rules for Profiles");
|
|
|
|
|
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
|
|
|
|
|
ImGui.EndTabItem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui.TextWrapped($"- All users that are paired and unpaused with you will be able to see your profile picture and description.{Environment.NewLine}" +
|
|
|
|
|
$"- Other users have the possibility to report your profile for breaking the rules.{Environment.NewLine}" +
|
|
|
|
|
$"- !!! AVOID: anything as profile image that can be considered highly illegal or obscene (bestiality, anything that could be considered a sexual act with a minor (that includes Lalafells), etc.){Environment.NewLine}" +
|
|
|
|
|
$"- !!! AVOID: slurs of any kind in the description that can be considered highly offensive{Environment.NewLine}" +
|
|
|
|
|
$"- In case of valid reports from other users this can lead to disabling your profile forever or terminating your Lightless account indefinitely.{Environment.NewLine}" +
|
|
|
|
|
$"- Judgement of your profile validity from reports through staff is not up to debate and the decisions to disable your profile/account permanent.{Environment.NewLine}" +
|
|
|
|
|
$"- If your profile picture or profile description could be considered NSFW, enable the toggle below.");
|
|
|
|
|
ImGui.Separator();
|
|
|
|
|
_uiSharedService.BigText("Profile Settings");
|
|
|
|
|
if (ImGui.BeginTabItem("Profile Settings"))
|
|
|
|
|
{
|
|
|
|
|
_uiSharedService.MediumText("Profile Settings", UIColors.Get("LightlessPurple"));
|
|
|
|
|
ImGui.Dummy(new Vector2(5));
|
|
|
|
|
|
|
|
|
|
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
|
|
|
|
|
{
|
|
|
|
|
@@ -223,6 +278,105 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
|
|
|
|
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, ProfilePictureBase64: null, ""));
|
|
|
|
|
}
|
|
|
|
|
UiSharedService.AttachToolTip("Clears your profile description text");
|
|
|
|
|
|
|
|
|
|
ImGui.EndTabItem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui.BeginTabItem("Vanity Settings"))
|
|
|
|
|
{
|
|
|
|
|
_uiSharedService.MediumText("Supporter Vanity Settings", UIColors.Get("LightlessPurple"));
|
|
|
|
|
ImGui.Dummy(new Vector2(4));
|
|
|
|
|
DrawNoteLine("# ", UIColors.Get("LightlessPurple"), "Must be a supporter through Patreon/Ko-fi to access these settings.");
|
|
|
|
|
|
|
|
|
|
var hasVanity = _apiController.HasVanity;
|
|
|
|
|
|
|
|
|
|
if (!hasVanity)
|
|
|
|
|
{
|
|
|
|
|
UiSharedService.ColorTextWrapped("You do not currently have vanity access. Become a supporter to unlock these features.", UIColors.Get("DimRed"));
|
|
|
|
|
ImGui.Dummy(new Vector2(8));
|
|
|
|
|
ImGui.BeginDisabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
|
|
|
|
|
_uiSharedService.MediumText("Colored UID", UIColors.Get("LightlessPurple"));
|
|
|
|
|
ImGui.Dummy(new Vector2(5));
|
|
|
|
|
|
|
|
|
|
var font = UiBuilder.MonoFont;
|
|
|
|
|
var playerUID = _apiController.UID;
|
|
|
|
|
var playerDisplay = _apiController.DisplayName;
|
|
|
|
|
|
|
|
|
|
var previewTextColor = textEnabled ? textColor : Vector4.One;
|
|
|
|
|
var previewGlowColor = glowEnabled ? glowColor : Vector4.Zero;
|
|
|
|
|
|
|
|
|
|
var seString = SeStringUtils.BuildFormattedPlayerName(playerDisplay, previewTextColor, previewGlowColor);
|
|
|
|
|
|
|
|
|
|
using (ImRaii.PushFont(font))
|
|
|
|
|
{
|
|
|
|
|
var offsetX = 10f;
|
|
|
|
|
var pos = ImGui.GetCursorScreenPos() + new Vector2(offsetX, 0);
|
|
|
|
|
var size = ImGui.CalcTextSize(seString.TextValue);
|
|
|
|
|
|
|
|
|
|
var padding = new Vector2(6, 3);
|
|
|
|
|
var rectMin = pos - padding;
|
|
|
|
|
var rectMax = pos + size + padding;
|
|
|
|
|
|
|
|
|
|
var bgColor = new Vector4(0.15f, 0.15f, 0.15f, 1f);
|
|
|
|
|
var borderColor = UIColors.Get("LightlessPurple");
|
|
|
|
|
|
|
|
|
|
var drawList = ImGui.GetWindowDrawList();
|
|
|
|
|
drawList.AddRectFilled(rectMin, rectMax, ImGui.GetColorU32(bgColor), 6.0f);
|
|
|
|
|
drawList.AddRect(rectMin, rectMax, ImGui.GetColorU32(borderColor), 6.0f, ImDrawFlags.None, 1.5f);
|
|
|
|
|
|
|
|
|
|
SeStringUtils.RenderSeStringWithHitbox(seString, pos, font);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float colorPickAlign = 90f;
|
|
|
|
|
|
|
|
|
|
DrawNoteLine("- ", UIColors.Get("LightlessPurple"), "Text Color");
|
|
|
|
|
ImGui.SameLine(colorPickAlign);
|
|
|
|
|
ImGui.Checkbox("##toggleTextColor", ref textEnabled);
|
|
|
|
|
ImGui.SameLine();
|
|
|
|
|
ImGui.BeginDisabled(!textEnabled);
|
|
|
|
|
ImGui.ColorEdit4($"##color_text", ref textColor, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.AlphaPreviewHalf);
|
|
|
|
|
ImGui.EndDisabled();
|
|
|
|
|
|
|
|
|
|
DrawNoteLine("- ", UIColors.Get("LightlessPurple"), "Glow Color");
|
|
|
|
|
ImGui.SameLine(colorPickAlign);
|
|
|
|
|
ImGui.Checkbox("##toggleGlowColor", ref glowEnabled);
|
|
|
|
|
ImGui.SameLine();
|
|
|
|
|
ImGui.BeginDisabled(!glowEnabled);
|
|
|
|
|
ImGui.ColorEdit4($"##color_glow", ref glowColor, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.AlphaPreviewHalf);
|
|
|
|
|
ImGui.EndDisabled();
|
|
|
|
|
|
|
|
|
|
bool changed = !Equals(_savedVanity, new VanityState(textEnabled, glowEnabled, textColor, glowColor));
|
|
|
|
|
|
|
|
|
|
if (!changed)
|
|
|
|
|
ImGui.BeginDisabled();
|
|
|
|
|
|
|
|
|
|
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Changes"))
|
|
|
|
|
{
|
|
|
|
|
string? newText = textEnabled ? UIColors.RgbaToHex(textColor) : string.Empty;
|
|
|
|
|
string? newGlow = glowEnabled ? UIColors.RgbaToHex(glowColor) : string.Empty;
|
|
|
|
|
|
|
|
|
|
_ = _apiController.UserUpdateVanityColors(new UserVanityColorsDto(newText, newGlow));
|
|
|
|
|
|
|
|
|
|
_savedVanity = new VanityState(textEnabled, glowEnabled, textColor, glowColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!changed)
|
|
|
|
|
ImGui.EndDisabled();
|
|
|
|
|
|
|
|
|
|
ImGui.Dummy(new Vector2(5));
|
|
|
|
|
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
|
|
|
|
|
|
|
|
|
|
if (!hasVanity)
|
|
|
|
|
ImGui.EndDisabled();
|
|
|
|
|
|
|
|
|
|
ImGui.EndTabItem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui.EndTabBar();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
|