Changed syncshell profiles a bit.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -32,6 +32,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
private readonly LightlessProfileManager _lightlessProfileManager;
|
private readonly LightlessProfileManager _lightlessProfileManager;
|
||||||
private readonly FileDialogManager _fileDialogManager;
|
private readonly FileDialogManager _fileDialogManager;
|
||||||
private readonly UiSharedService _uiSharedService;
|
private readonly UiSharedService _uiSharedService;
|
||||||
|
private LightlessGroupProfileData _profileData = null;
|
||||||
private List<BannedGroupUserDto> _bannedUsers = [];
|
private List<BannedGroupUserDto> _bannedUsers = [];
|
||||||
private bool _adjustedForScollBarsLocalProfile = false;
|
private bool _adjustedForScollBarsLocalProfile = false;
|
||||||
private bool _adjustedForScollBarsOnlineProfile = false;
|
private bool _adjustedForScollBarsOnlineProfile = false;
|
||||||
@@ -80,7 +81,6 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
GroupFullInfo = _pairManager.Groups[GroupFullInfo.Group];
|
GroupFullInfo = _pairManager.Groups[GroupFullInfo.Group];
|
||||||
|
|
||||||
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())
|
||||||
_uiSharedService.UnderlinedBigText(GroupFullInfo.GroupAliasOrGID + " Administrative Panel", UIColors.Get("LightlessBlue"));
|
_uiSharedService.UnderlinedBigText(GroupFullInfo.GroupAliasOrGID + " Administrative Panel", UIColors.Get("LightlessBlue"));
|
||||||
|
|
||||||
@@ -199,152 +199,159 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
private void DrawProfile()
|
private void DrawProfile()
|
||||||
{
|
{
|
||||||
var profile = _lightlessProfileManager.GetLightlessGroupProfile(new GroupData(GroupFullInfo.Group.GID));
|
|
||||||
var profileTab = ImRaii.TabItem("Profile");
|
var profileTab = ImRaii.TabItem("Profile");
|
||||||
|
|
||||||
if (profileTab)
|
if (profileTab)
|
||||||
{
|
{
|
||||||
_uiSharedService.MediumText("Current Profile (as saved on server)", UIColors.Get("LightlessPurple"));
|
if (_uiSharedService.MediumTreeNode("Current Profile", UIColors.Get("LightlessPurple")))
|
||||||
ImGui.Dummy(new Vector2(5));
|
|
||||||
|
|
||||||
if (!_profileImage.SequenceEqual(profile.ImageData.Value))
|
|
||||||
{
|
{
|
||||||
_profileImage = profile.ImageData.Value;
|
_logger.LogInformation(GroupFullInfo.Group.GID);
|
||||||
_pfpTextureWrap?.Dispose();
|
_profileData = _lightlessProfileManager.GetLightlessGroupProfile(GroupFullInfo.Group);
|
||||||
_pfpTextureWrap = _uiSharedService.LoadImage(_profileImage);
|
if (_profileData != null)
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.Equals(_profileDescription, profile.Description, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
_profileDescription = profile.Description;
|
|
||||||
_descriptionText = _profileDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_pfpTextureWrap != null)
|
|
||||||
{
|
|
||||||
ImGui.Image(_pfpTextureWrap.Handle, ImGuiHelpers.ScaledVector2(_pfpTextureWrap.Width, _pfpTextureWrap.Height));
|
|
||||||
}
|
|
||||||
|
|
||||||
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
|
||||||
ImGuiHelpers.ScaledRelativeSameLine(256, spacing);
|
|
||||||
using (_uiSharedService.GameFont.Push())
|
|
||||||
{
|
|
||||||
var descriptionTextSize = ImGui.CalcTextSize(profile.Description, wrapWidth: 256f);
|
|
||||||
var childFrame = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 256);
|
|
||||||
if (descriptionTextSize.Y > childFrame.Y)
|
|
||||||
{
|
{
|
||||||
_adjustedForScollBarsOnlineProfile = true;
|
ImGui.Dummy(new Vector2(5));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_adjustedForScollBarsOnlineProfile = false;
|
|
||||||
}
|
|
||||||
childFrame = childFrame with
|
|
||||||
{
|
|
||||||
X = childFrame.X + (_adjustedForScollBarsOnlineProfile ? ImGui.GetStyle().ScrollbarSize : 0),
|
|
||||||
};
|
|
||||||
if (ImGui.BeginChildFrame(101, childFrame))
|
|
||||||
{
|
|
||||||
UiSharedService.TextWrapped(profile.Description);
|
|
||||||
}
|
|
||||||
ImGui.EndChildFrame();
|
|
||||||
}
|
|
||||||
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
|
|
||||||
ImGui.EndTabItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.BeginTabItem("Profile Settings"))
|
if (!_profileImage.SequenceEqual(_profileData.ImageData.Value))
|
||||||
{
|
|
||||||
_uiSharedService.MediumText("Profile Settings", UIColors.Get("LightlessPurple"));
|
|
||||||
ImGui.Dummy(new Vector2(5));
|
|
||||||
|
|
||||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
|
|
||||||
{
|
|
||||||
_fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) =>
|
|
||||||
{
|
|
||||||
if (!success) return;
|
|
||||||
_ = Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
var fileContent = File.ReadAllBytes(file);
|
_profileImage = _profileData.ImageData.Value;
|
||||||
using MemoryStream ms = new(fileContent);
|
_pfpTextureWrap?.Dispose();
|
||||||
var format = await Image.DetectFormatAsync(ms).ConfigureAwait(false);
|
_pfpTextureWrap = _uiSharedService.LoadImage(_profileImage);
|
||||||
if (!format.FileExtensions.Contains("png", StringComparer.OrdinalIgnoreCase))
|
}
|
||||||
{
|
|
||||||
_showFileDialogError = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
using var image = Image.Load<Rgba32>(fileContent);
|
|
||||||
|
|
||||||
if (image.Width > 256 || image.Height > 256 || (fileContent.Length > 250 * 1024))
|
if (!string.Equals(_profileDescription, _profileData.Description, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
_showFileDialogError = true;
|
_profileDescription = _profileData.Description;
|
||||||
return;
|
_descriptionText = _profileDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
_showFileDialogError = false;
|
if (_pfpTextureWrap != null)
|
||||||
await _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: null, Tags: null, Convert.ToBase64String(fileContent)))
|
{
|
||||||
.ConfigureAwait(false);
|
ImGui.Image(_pfpTextureWrap.Handle, ImGuiHelpers.ScaledVector2(_pfpTextureWrap.Width, _pfpTextureWrap.Height));
|
||||||
|
}
|
||||||
|
|
||||||
|
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
||||||
|
ImGuiHelpers.ScaledRelativeSameLine(256, spacing);
|
||||||
|
using (_uiSharedService.GameFont.Push())
|
||||||
|
{
|
||||||
|
var descriptionTextSize = ImGui.CalcTextSize(_profileData.Description, wrapWidth: 256f);
|
||||||
|
var childFrame = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 256);
|
||||||
|
if (descriptionTextSize.Y > childFrame.Y)
|
||||||
|
{
|
||||||
|
_adjustedForScollBarsOnlineProfile = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_adjustedForScollBarsOnlineProfile = false;
|
||||||
|
}
|
||||||
|
childFrame = childFrame with
|
||||||
|
{
|
||||||
|
X = childFrame.X + (_adjustedForScollBarsOnlineProfile ? ImGui.GetStyle().ScrollbarSize : 0),
|
||||||
|
};
|
||||||
|
if (ImGui.BeginChildFrame(101, childFrame))
|
||||||
|
{
|
||||||
|
UiSharedService.TextWrapped(_profileData.Description);
|
||||||
|
}
|
||||||
|
ImGui.EndChildFrame();
|
||||||
|
ImGui.TreePop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.Separator();
|
||||||
|
|
||||||
|
if (_uiSharedService.MediumTreeNode("Profile Settings", UIColors.Get("LightlessPurple")))
|
||||||
|
{
|
||||||
|
ImGui.Dummy(new Vector2(5));
|
||||||
|
|
||||||
|
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
|
||||||
|
{
|
||||||
|
_fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) =>
|
||||||
|
{
|
||||||
|
if (!success) return;
|
||||||
|
_ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
var fileContent = File.ReadAllBytes(file);
|
||||||
|
using MemoryStream ms = new(fileContent);
|
||||||
|
var format = await Image.DetectFormatAsync(ms).ConfigureAwait(false);
|
||||||
|
if (!format.FileExtensions.Contains("png", StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
_showFileDialogError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using var image = Image.Load<Rgba32>(fileContent);
|
||||||
|
|
||||||
|
if (image.Width > 256 || image.Height > 256 || (fileContent.Length > 250 * 1024))
|
||||||
|
{
|
||||||
|
_showFileDialogError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_showFileDialogError = false;
|
||||||
|
await _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: null, Tags: null, Convert.ToBase64String(fileContent)))
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
UiSharedService.AttachToolTip("Select and upload a new profile picture");
|
|
||||||
ImGui.SameLine();
|
|
||||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear uploaded profile picture"))
|
|
||||||
{
|
|
||||||
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: null, Tags: null, PictureBase64: null));
|
|
||||||
}
|
|
||||||
UiSharedService.AttachToolTip("Clear your currently uploaded profile picture");
|
|
||||||
if (_showFileDialogError)
|
|
||||||
{
|
|
||||||
UiSharedService.ColorTextWrapped("The profile picture must be a PNG file with a maximum height and width of 256px and 250KiB size", ImGuiColors.DalamudRed);
|
|
||||||
}
|
|
||||||
|
|
||||||
_uiSharedService.DrawHelpText("If your profile description or image can be considered NSFW, toggle this to ON");
|
|
||||||
var widthTextBox = 400;
|
|
||||||
var posX = ImGui.GetCursorPosX();
|
|
||||||
ImGui.TextUnformatted($"Description {_descriptionText.Length}/1500");
|
|
||||||
ImGui.SetCursorPosX(posX);
|
|
||||||
ImGuiHelpers.ScaledRelativeSameLine(widthTextBox, ImGui.GetStyle().ItemSpacing.X);
|
|
||||||
ImGui.TextUnformatted("Preview (approximate)");
|
|
||||||
using (_uiSharedService.GameFont.Push())
|
|
||||||
ImGui.InputTextMultiline("##description", ref _descriptionText, 1500, ImGuiHelpers.ScaledVector2(widthTextBox, 200));
|
|
||||||
|
|
||||||
ImGui.SameLine();
|
|
||||||
|
|
||||||
using (_uiSharedService.GameFont.Push())
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
_adjustedForScollBarsLocalProfile = true;
|
|
||||||
}
|
}
|
||||||
else
|
UiSharedService.AttachToolTip("Select and upload a new profile picture");
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear uploaded profile picture"))
|
||||||
{
|
{
|
||||||
_adjustedForScollBarsLocalProfile = false;
|
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: null, Tags: null, PictureBase64: null));
|
||||||
}
|
}
|
||||||
childFrameLocal = childFrameLocal with
|
UiSharedService.AttachToolTip("Clear your currently uploaded profile picture");
|
||||||
|
if (_showFileDialogError)
|
||||||
{
|
{
|
||||||
X = childFrameLocal.X + (_adjustedForScollBarsLocalProfile ? ImGui.GetStyle().ScrollbarSize : 0),
|
UiSharedService.ColorTextWrapped("The profile picture must be a PNG file with a maximum height and width of 256px and 250KiB size", ImGuiColors.DalamudRed);
|
||||||
};
|
|
||||||
if (ImGui.BeginChildFrame(102, childFrameLocal))
|
|
||||||
{
|
|
||||||
UiSharedService.TextWrapped(_descriptionText);
|
|
||||||
}
|
}
|
||||||
ImGui.EndChildFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Description"))
|
_uiSharedService.DrawHelpText("If your profile description or image can be considered NSFW, toggle this to ON");
|
||||||
{
|
var widthTextBox = 400;
|
||||||
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: _descriptionText, Tags: null, PictureBase64: null));
|
var posX = ImGui.GetCursorPosX();
|
||||||
|
ImGui.TextUnformatted($"Description {_descriptionText.Length}/1500");
|
||||||
|
ImGui.SetCursorPosX(posX);
|
||||||
|
ImGuiHelpers.ScaledRelativeSameLine(widthTextBox, ImGui.GetStyle().ItemSpacing.X);
|
||||||
|
ImGui.TextUnformatted("Preview (approximate)");
|
||||||
|
using (_uiSharedService.GameFont.Push())
|
||||||
|
ImGui.InputTextMultiline("##description", ref _descriptionText, 1500, ImGuiHelpers.ScaledVector2(widthTextBox, 200));
|
||||||
|
|
||||||
|
ImGui.SameLine();
|
||||||
|
|
||||||
|
using (_uiSharedService.GameFont.Push())
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
_adjustedForScollBarsLocalProfile = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_adjustedForScollBarsLocalProfile = false;
|
||||||
|
}
|
||||||
|
childFrameLocal = childFrameLocal with
|
||||||
|
{
|
||||||
|
X = childFrameLocal.X + (_adjustedForScollBarsLocalProfile ? ImGui.GetStyle().ScrollbarSize : 0),
|
||||||
|
};
|
||||||
|
if (ImGui.BeginChildFrame(102, childFrameLocal))
|
||||||
|
{
|
||||||
|
UiSharedService.TextWrapped(_descriptionText);
|
||||||
|
}
|
||||||
|
ImGui.EndChildFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Description"))
|
||||||
|
{
|
||||||
|
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: _descriptionText, Tags: null, PictureBase64: null));
|
||||||
|
}
|
||||||
|
UiSharedService.AttachToolTip("Sets your profile description text");
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear Description"))
|
||||||
|
{
|
||||||
|
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: null, Tags: null, PictureBase64: null));
|
||||||
|
}
|
||||||
|
UiSharedService.AttachToolTip("Clears your profile description text");
|
||||||
|
ImGui.TreePop();
|
||||||
}
|
}
|
||||||
UiSharedService.AttachToolTip("Sets your profile description text");
|
|
||||||
ImGui.SameLine();
|
|
||||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear Description"))
|
|
||||||
{
|
|
||||||
_ = _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: null, Tags: null, PictureBase64: null));
|
|
||||||
}
|
|
||||||
UiSharedService.AttachToolTip("Clears your profile description text");
|
|
||||||
}
|
}
|
||||||
profileTab.Dispose();
|
profileTab.Dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user