Changed the layout a bit, added nsfw
This commit is contained in:
@@ -13,11 +13,13 @@ using LightlessSync.API.Dto.User;
|
|||||||
using LightlessSync.PlayerData.Pairs;
|
using LightlessSync.PlayerData.Pairs;
|
||||||
using LightlessSync.Services;
|
using LightlessSync.Services;
|
||||||
using LightlessSync.Services.Mediator;
|
using LightlessSync.Services.Mediator;
|
||||||
|
using LightlessSync.UI.Handlers;
|
||||||
using LightlessSync.WebAPI;
|
using LightlessSync.WebAPI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
namespace LightlessSync.UI;
|
namespace LightlessSync.UI;
|
||||||
@@ -34,7 +36,6 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
private readonly UiSharedService _uiSharedService;
|
private readonly UiSharedService _uiSharedService;
|
||||||
private List<BannedGroupUserDto> _bannedUsers = [];
|
private List<BannedGroupUserDto> _bannedUsers = [];
|
||||||
private LightlessGroupProfileData? _profileData = null;
|
private LightlessGroupProfileData? _profileData = null;
|
||||||
private GroupData? _lastProfileGroup = null;
|
|
||||||
private bool _adjustedForScollBarsLocalProfile = false;
|
private bool _adjustedForScollBarsLocalProfile = false;
|
||||||
private bool _adjustedForScollBarsOnlineProfile = false;
|
private bool _adjustedForScollBarsOnlineProfile = false;
|
||||||
private string _descriptionText = string.Empty;
|
private string _descriptionText = string.Empty;
|
||||||
@@ -48,7 +49,8 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
private Task<int>? _pruneTestTask;
|
private Task<int>? _pruneTestTask;
|
||||||
private Task<int>? _pruneTask;
|
private Task<int>? _pruneTask;
|
||||||
private int _pruneDays = 14;
|
private int _pruneDays = 14;
|
||||||
private bool renewProfile;
|
private readonly List<string> _allowedTags = ["Apex", "Predator", "Tavern", "NSFW", "SFW"];
|
||||||
|
private List<string> _selectedTags = [];
|
||||||
|
|
||||||
public SyncshellAdminUI(ILogger<SyncshellAdminUI> logger, LightlessMediator mediator, ApiController apiController,
|
public SyncshellAdminUI(ILogger<SyncshellAdminUI> logger, LightlessMediator mediator, ApiController apiController,
|
||||||
UiSharedService uiSharedService, PairManager pairManager, GroupFullInfoDto groupFullInfo, PerformanceCollectorService performanceCollectorService, LightlessProfileManager lightlessProfileManager, FileDialogManager fileDialogManager)
|
UiSharedService uiSharedService, PairManager pairManager, GroupFullInfoDto groupFullInfo, PerformanceCollectorService performanceCollectorService, LightlessProfileManager lightlessProfileManager, FileDialogManager fileDialogManager)
|
||||||
@@ -92,6 +94,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
GroupFullInfo = _pairManager.Groups[GroupFullInfo.Group];
|
GroupFullInfo = _pairManager.Groups[GroupFullInfo.Group];
|
||||||
|
|
||||||
_profileData = _lightlessProfileManager.GetLightlessGroupProfile(GroupFullInfo.Group);
|
_profileData = _lightlessProfileManager.GetLightlessGroupProfile(GroupFullInfo.Group);
|
||||||
|
GetTagsFromProfile();
|
||||||
|
|
||||||
using var id = ImRaii.PushId("syncshell_admin_" + GroupFullInfo.GID);
|
using var id = ImRaii.PushId("syncshell_admin_" + GroupFullInfo.GID);
|
||||||
using (_uiSharedService.UidFont.Push())
|
using (_uiSharedService.UidFont.Push())
|
||||||
@@ -109,7 +112,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
DrawManagement();
|
DrawManagement();
|
||||||
|
|
||||||
DrawPermission(perm);
|
DrawPermission(perm);
|
||||||
|
|
||||||
DrawProfile();
|
DrawProfile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,7 +273,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
if (_uiSharedService.MediumTreeNode("Profile Settings", UIColors.Get("LightlessPurple")))
|
if (_uiSharedService.MediumTreeNode("Profile Settings", UIColors.Get("LightlessPurple")))
|
||||||
{
|
{
|
||||||
ImGui.Dummy(new Vector2(5));
|
ImGui.Dummy(new Vector2(5));
|
||||||
|
ImGui.TextUnformatted($"Profile Picture:");
|
||||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
|
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
|
||||||
{
|
{
|
||||||
_fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) =>
|
_fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) =>
|
||||||
@@ -314,8 +317,15 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
{
|
{
|
||||||
UiSharedService.ColorTextWrapped("The profile picture must be a PNG file with a maximum height and width of 256px and 250KiB size", ImGuiColors.DalamudRed);
|
UiSharedService.ColorTextWrapped("The profile picture must be a PNG file with a maximum height and width of 256px and 250KiB size", ImGuiColors.DalamudRed);
|
||||||
}
|
}
|
||||||
|
ImGui.Separator();
|
||||||
|
ImGui.TextUnformatted($"Tags:");
|
||||||
|
var childFrameLocal = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 200);
|
||||||
|
|
||||||
_uiSharedService.DrawHelpText("If your profile description or image can be considered NSFW, toggle this to ON");
|
foreach (string tag in _allowedTags)
|
||||||
|
{
|
||||||
|
using (ImRaii.PushId($"tag-{tag}")) DrawTag(tag);
|
||||||
|
}
|
||||||
|
ImGui.Separator();
|
||||||
var widthTextBox = 400;
|
var widthTextBox = 400;
|
||||||
var posX = ImGui.GetCursorPosX();
|
var posX = ImGui.GetCursorPosX();
|
||||||
ImGui.TextUnformatted($"Description {_descriptionText.Length}/1500");
|
ImGui.TextUnformatted($"Description {_descriptionText.Length}/1500");
|
||||||
@@ -330,7 +340,6 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
using (_uiSharedService.GameFont.Push())
|
using (_uiSharedService.GameFont.Push())
|
||||||
{
|
{
|
||||||
var descriptionTextSizeLocal = ImGui.CalcTextSize(_descriptionText, wrapWidth: 256f);
|
var descriptionTextSizeLocal = ImGui.CalcTextSize(_descriptionText, wrapWidth: 256f);
|
||||||
var childFrameLocal = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 200);
|
|
||||||
if (descriptionTextSizeLocal.Y > childFrameLocal.Y)
|
if (descriptionTextSizeLocal.Y > childFrameLocal.Y)
|
||||||
{
|
{
|
||||||
_adjustedForScollBarsLocalProfile = true;
|
_adjustedForScollBarsLocalProfile = true;
|
||||||
@@ -361,6 +370,14 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: null, PictureBase64: null));
|
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: null, PictureBase64: null));
|
||||||
}
|
}
|
||||||
UiSharedService.AttachToolTip("Clears your profile description text");
|
UiSharedService.AttachToolTip("Clears your profile description text");
|
||||||
|
ImGui.Separator();
|
||||||
|
ImGui.TextUnformatted($"Profile Options:");
|
||||||
|
var isNsfw = false;
|
||||||
|
if (ImGui.Checkbox("Profile is NSFW", ref isNsfw))
|
||||||
|
{
|
||||||
|
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, isNsfw, ProfilePictureBase64: null, Description: null));
|
||||||
|
}
|
||||||
|
_uiSharedService.DrawHelpText("If your profile description or image can be considered NSFW, toggle this to ON");
|
||||||
ImGui.TreePop();
|
ImGui.TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -710,6 +727,52 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
inviteTab.Dispose();
|
inviteTab.Dispose();
|
||||||
}
|
}
|
||||||
|
private void DrawTag(string tag)
|
||||||
|
{
|
||||||
|
var HasTag = _selectedTags.Contains(tag, StringComparer.Ordinal);
|
||||||
|
if (ImGui.Checkbox(tag, ref HasTag))
|
||||||
|
{
|
||||||
|
if (HasTag)
|
||||||
|
{
|
||||||
|
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: ListToString(_selectedTags, ","), PictureBase64: null));
|
||||||
|
|
||||||
|
_selectedTags.Add(tag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ = _selectedTags.Count > 0
|
||||||
|
? _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: ListToString(_selectedTags, ","), PictureBase64: null))
|
||||||
|
: _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.AliasOrGID), Description: null, Tags: string.Empty, PictureBase64: null));
|
||||||
|
|
||||||
|
_selectedTags.Remove(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetTagsFromProfile()
|
||||||
|
{
|
||||||
|
_selectedTags = [];
|
||||||
|
if (_profileData != null)
|
||||||
|
{
|
||||||
|
_selectedTags = StringToList(_profileData.Tags, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ListToString(List<string> list, string delimiter)
|
||||||
|
{
|
||||||
|
if (list == null || list.Count == 0)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
return string.Join(delimiter, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<string> StringToList(string input, string delimiter)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(input))
|
||||||
|
return [];
|
||||||
|
|
||||||
|
return [.. input.Split([delimiter], StringSplitOptions.None)];
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnClose()
|
public override void OnClose()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user