Changes some calls
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -47,6 +47,7 @@ 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;
|
||||||
|
|
||||||
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)
|
||||||
@@ -87,6 +88,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
if (!_isModerator && !_isOwner) return;
|
if (!_isModerator && !_isOwner) return;
|
||||||
|
|
||||||
GroupFullInfo = _pairManager.Groups[GroupFullInfo.Group];
|
GroupFullInfo = _pairManager.Groups[GroupFullInfo.Group];
|
||||||
|
_profileData = _lightlessProfileManager.GetLightlessGroupProfile(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())
|
||||||
@@ -213,55 +215,50 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
{
|
{
|
||||||
if (_uiSharedService.MediumTreeNode("Current Profile", UIColors.Get("LightlessPurple")))
|
if (_uiSharedService.MediumTreeNode("Current Profile", UIColors.Get("LightlessPurple")))
|
||||||
{
|
{
|
||||||
_logger.LogInformation(GroupFullInfo.Group.GID);
|
ImGui.Dummy(new Vector2(5));
|
||||||
_profileData = _lightlessProfileManager.GetLightlessGroupProfile(GroupFullInfo.Group);
|
|
||||||
if (_profileData != null)
|
if (!_profileImage.SequenceEqual(_profileData.ImageData.Value))
|
||||||
{
|
{
|
||||||
ImGui.Dummy(new Vector2(5));
|
_profileImage = _profileData.ImageData.Value;
|
||||||
|
_pfpTextureWrap?.Dispose();
|
||||||
|
_pfpTextureWrap = _uiSharedService.LoadImage(_profileImage);
|
||||||
|
}
|
||||||
|
|
||||||
if (!_profileImage.SequenceEqual(_profileData.ImageData.Value))
|
if (!string.Equals(_profileDescription, _profileData.Description, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
_profileImage = _profileData.ImageData.Value;
|
_profileDescription = _profileData.Description;
|
||||||
_pfpTextureWrap?.Dispose();
|
_descriptionText = _profileDescription;
|
||||||
_pfpTextureWrap = _uiSharedService.LoadImage(_profileImage);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.Equals(_profileDescription, _profileData.Description, StringComparison.OrdinalIgnoreCase))
|
if (_pfpTextureWrap != null)
|
||||||
{
|
{
|
||||||
_profileDescription = _profileData.Description;
|
ImGui.Image(_pfpTextureWrap.Handle, ImGuiHelpers.ScaledVector2(_pfpTextureWrap.Width, _pfpTextureWrap.Height));
|
||||||
_descriptionText = _profileDescription;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (_pfpTextureWrap != null)
|
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)
|
||||||
{
|
{
|
||||||
ImGui.Image(_pfpTextureWrap.Handle, ImGuiHelpers.ScaledVector2(_pfpTextureWrap.Width, _pfpTextureWrap.Height));
|
_adjustedForScollBarsOnlineProfile = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
|
||||||
ImGuiHelpers.ScaledRelativeSameLine(256, spacing);
|
|
||||||
using (_uiSharedService.GameFont.Push())
|
|
||||||
{
|
{
|
||||||
var descriptionTextSize = ImGui.CalcTextSize(_profileData.Description, wrapWidth: 256f);
|
_adjustedForScollBarsOnlineProfile = false;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
childFrame = childFrame with
|
||||||
|
{
|
||||||
|
X = childFrame.X + (_adjustedForScollBarsOnlineProfile ? ImGui.GetStyle().ScrollbarSize : 0),
|
||||||
|
};
|
||||||
|
if (ImGui.BeginChildFrame(101, childFrame))
|
||||||
|
{
|
||||||
|
UiSharedService.TextWrapped(_profileData.Description);
|
||||||
|
}
|
||||||
|
ImGui.EndChildFrame();
|
||||||
|
ImGui.TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,25 +275,28 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
if (!success) return;
|
if (!success) return;
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var fileContent = File.ReadAllBytes(file);
|
var fileContent = await File.ReadAllBytesAsync(file).ConfigureAwait(false);
|
||||||
using MemoryStream ms = new(fileContent);
|
MemoryStream ms = new(fileContent);
|
||||||
var format = await Image.DetectFormatAsync(ms).ConfigureAwait(false);
|
await using (ms.ConfigureAwait(false))
|
||||||
if (!format.FileExtensions.Contains("png", StringComparer.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
_showFileDialogError = true;
|
var format = await Image.DetectFormatAsync(ms).ConfigureAwait(false);
|
||||||
return;
|
if (!format.FileExtensions.Contains("png", StringComparer.OrdinalIgnoreCase))
|
||||||
}
|
{
|
||||||
using var image = Image.Load<Rgba32>(fileContent);
|
_showFileDialogError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using var image = Image.Load<Rgba32>(fileContent);
|
||||||
|
|
||||||
if (image.Width > 256 || image.Height > 256 || (fileContent.Length > 250 * 1024))
|
if (image.Width > 256 || image.Height > 256 || (fileContent.Length > 250 * 1024))
|
||||||
{
|
{
|
||||||
_showFileDialogError = true;
|
_showFileDialogError = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_showFileDialogError = false;
|
_showFileDialogError = false;
|
||||||
await _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: null, Tags: null, Convert.ToBase64String(fileContent)))
|
await _apiController.GroupSetProfile(new GroupProfileDto(new GroupData(GroupFullInfo.Group.GID), Description: null, Tags: null, Convert.ToBase64String(fileContent)))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -711,5 +711,6 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
|||||||
public override void OnClose()
|
public override void OnClose()
|
||||||
{
|
{
|
||||||
Mediator.Publish(new RemoveWindowMessage(this));
|
Mediator.Publish(new RemoveWindowMessage(this));
|
||||||
|
_pfpTextureWrap?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user