add census popup on connection
This commit is contained in:
@@ -14,6 +14,7 @@ public class ServerConfig : IMareConfiguration
|
|||||||
};
|
};
|
||||||
|
|
||||||
public bool SendCensusData { get; set; } = true;
|
public bool SendCensusData { get; set; } = true;
|
||||||
|
public bool ShownCensusPopup { get; set; } = false;
|
||||||
|
|
||||||
public int Version { get; set; } = 1;
|
public int Version { get; set; } = 1;
|
||||||
}
|
}
|
||||||
@@ -111,6 +111,7 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
collection.AddScoped<WindowMediatorSubscriberBase, PopupHandler>();
|
collection.AddScoped<WindowMediatorSubscriberBase, PopupHandler>();
|
||||||
collection.AddScoped<IPopupHandler, ReportPopupHandler>();
|
collection.AddScoped<IPopupHandler, ReportPopupHandler>();
|
||||||
collection.AddScoped<IPopupHandler, BanUserPopupHandler>();
|
collection.AddScoped<IPopupHandler, BanUserPopupHandler>();
|
||||||
|
collection.AddScoped<IPopupHandler, CensusPopupHandler>();
|
||||||
collection.AddScoped<CacheCreationService>();
|
collection.AddScoped<CacheCreationService>();
|
||||||
collection.AddScoped<TransientResourceManager>();
|
collection.AddScoped<TransientResourceManager>();
|
||||||
collection.AddScoped<PlayerDataFactory>();
|
collection.AddScoped<PlayerDataFactory>();
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public record PairHandlerVisibleMessage(PairHandler Player) : MessageBase;
|
|||||||
public record RefreshUiMessage : MessageBase;
|
public record RefreshUiMessage : MessageBase;
|
||||||
public record OpenReportPopupMessage(Pair PairToReport) : MessageBase;
|
public record OpenReportPopupMessage(Pair PairToReport) : MessageBase;
|
||||||
public record OpenBanUserPopupMessage(Pair PairToBan, GroupFullInfoDto GroupFullInfoDto) : MessageBase;
|
public record OpenBanUserPopupMessage(Pair PairToBan, GroupFullInfoDto GroupFullInfoDto) : MessageBase;
|
||||||
|
public record OpenCensusPopupMessage() : MessageBase;
|
||||||
public record OpenSyncshellAdminPanel(GroupFullInfoDto GroupInfo) : MessageBase;
|
public record OpenSyncshellAdminPanel(GroupFullInfoDto GroupInfo) : MessageBase;
|
||||||
public record OpenPermissionWindow(Pair Pair) : MessageBase;
|
public record OpenPermissionWindow(Pair Pair) : MessageBase;
|
||||||
public record DownloadLimitChangedMessage() : SameThreadMessage;
|
public record DownloadLimitChangedMessage() : SameThreadMessage;
|
||||||
|
|||||||
@@ -44,6 +44,19 @@ public class ServerConfigurationManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShownCensusPopup
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _configService.Current.ShownCensusPopup;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_configService.Current.ShownCensusPopup = value;
|
||||||
|
_configService.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int CurrentServerIndex
|
public int CurrentServerIndex
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ public class BanUserPopupHandler : IPopupHandler
|
|||||||
UiSharedService.TextWrapped("The reason will be displayed in the banlist. The current server-side alias if present (Vanity ID) will automatically be attached to the reason.");
|
UiSharedService.TextWrapped("The reason will be displayed in the banlist. The current server-side alias if present (Vanity ID) will automatically be attached to the reason.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnClose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void Open(OpenBanUserPopupMessage message)
|
public void Open(OpenBanUserPopupMessage message)
|
||||||
{
|
{
|
||||||
_reportedPair = message.PairToBan;
|
_reportedPair = message.PairToBan;
|
||||||
|
|||||||
50
MareSynchronos/UI/Components/Popup/CensusPopupHandler.cs
Normal file
50
MareSynchronos/UI/Components/Popup/CensusPopupHandler.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using Dalamud.Interface.Utility;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
|
using ImGuiNET;
|
||||||
|
using MareSynchronos.Services.ServerConfiguration;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
|
namespace MareSynchronos.UI.Components.Popup;
|
||||||
|
|
||||||
|
public class CensusPopupHandler : IPopupHandler
|
||||||
|
{
|
||||||
|
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||||
|
private readonly UiSharedService _uiSharedService;
|
||||||
|
|
||||||
|
public CensusPopupHandler(ServerConfigurationManager serverConfigurationManager, UiSharedService uiSharedService)
|
||||||
|
{
|
||||||
|
_serverConfigurationManager = serverConfigurationManager;
|
||||||
|
_uiSharedService = uiSharedService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2 PopupSize => new(600, 350);
|
||||||
|
|
||||||
|
public void DrawContent()
|
||||||
|
{
|
||||||
|
using (ImRaii.PushFont(_uiSharedService.UidFont))
|
||||||
|
UiSharedService.TextWrapped("Mare Census Opt-Out");
|
||||||
|
ImGuiHelpers.ScaledDummy(5, 5);
|
||||||
|
UiSharedService.TextWrapped("If you are seeing this popup you are updating from a Mare version that did not collect census data. Please read the following carefully.");
|
||||||
|
ImGui.Separator();
|
||||||
|
UiSharedService.TextWrapped("Mare Census is a data collecting service that can be used for statistical purposes. " +
|
||||||
|
"All data collected through Mare Census is temporary and will be stored associated with your UID on the connected service as long as you are connected. " +
|
||||||
|
"The data cannot be used for long term tracking of individuals.");
|
||||||
|
UiSharedService.TextWrapped("If enabled, Mare Census will collect following data:" + Environment.NewLine
|
||||||
|
+ "- Currently connected World" + Environment.NewLine
|
||||||
|
+ "- Current Gender (reflecting Glamourer changes)" + Environment.NewLine
|
||||||
|
+ "- Current Race (reflecting Glamourer changes)" + Environment.NewLine
|
||||||
|
+ "- Current Clan (i.e. Seeker of the Sun, Keeper of the Moon, etc., reflecting Glamourer changes)");
|
||||||
|
UiSharedService.TextWrapped("If you do not consent to the data mentioned above being sent, untick the checkbox below.");
|
||||||
|
UiSharedService.TextWrapped("This setting can be changed anytime in the Mare Settings.");
|
||||||
|
var sendCensus = _serverConfigurationManager.SendCensusData;
|
||||||
|
if (ImGui.Checkbox("Allow sending census data", ref sendCensus))
|
||||||
|
{
|
||||||
|
_serverConfigurationManager.SendCensusData = sendCensus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnClose()
|
||||||
|
{
|
||||||
|
_serverConfigurationManager.ShownCensusPopup = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,4 +7,6 @@ public interface IPopupHandler
|
|||||||
Vector2 PopupSize { get; }
|
Vector2 PopupSize { get; }
|
||||||
|
|
||||||
void DrawContent();
|
void DrawContent();
|
||||||
|
|
||||||
|
void OnClose();
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,13 @@ public class PopupHandler : WindowMediatorSubscriberBase
|
|||||||
((BanUserPopupHandler)_currentHandler).Open(msg);
|
((BanUserPopupHandler)_currentHandler).Open(msg);
|
||||||
IsOpen = true;
|
IsOpen = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Mediator.Subscribe<OpenCensusPopupMessage>(this, (msg) =>
|
||||||
|
{
|
||||||
|
_openPopup = true;
|
||||||
|
_currentHandler = _handlers.OfType<CensusPopupHandler>().Single();
|
||||||
|
IsOpen = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
@@ -66,6 +73,13 @@ public class PopupHandler : WindowMediatorSubscriberBase
|
|||||||
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close"))
|
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close"))
|
||||||
{
|
{
|
||||||
ImGui.CloseCurrentPopup();
|
ImGui.CloseCurrentPopup();
|
||||||
|
_currentHandler.OnClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnClose()
|
||||||
|
{
|
||||||
|
base.OnClose();
|
||||||
|
_currentHandler?.OnClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,10 @@ internal class ReportPopupHandler : IPopupHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnClose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void Open(OpenReportPopupMessage msg)
|
public void Open(OpenReportPopupMessage msg)
|
||||||
{
|
{
|
||||||
_reportedPair = msg.PairToReport;
|
_reportedPair = msg.PairToReport;
|
||||||
|
|||||||
@@ -102,6 +102,15 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
|
|||||||
|
|
||||||
public async Task CreateConnections()
|
public async Task CreateConnections()
|
||||||
{
|
{
|
||||||
|
if (!_serverManager.ShownCensusPopup)
|
||||||
|
{
|
||||||
|
Mediator.Publish(new OpenCensusPopupMessage());
|
||||||
|
while (!_serverManager.ShownCensusPopup)
|
||||||
|
{
|
||||||
|
await Task.Delay(500).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Logger.LogDebug("CreateConnections called");
|
Logger.LogDebug("CreateConnections called");
|
||||||
|
|
||||||
if (_serverManager.CurrentServer?.FullPause ?? true)
|
if (_serverManager.CurrentServer?.FullPause ?? true)
|
||||||
|
|||||||
Reference in New Issue
Block a user