adjust initial dialog to opt in/out into census with buttons

This commit is contained in:
rootdarkarchon
2023-11-21 14:59:43 +01:00
parent a32aef8ee8
commit 1dfdab4fef
6 changed files with 39 additions and 33 deletions

View File

@@ -13,7 +13,7 @@ public class ServerConfig : IMareConfiguration
{ new ServerStorage() { ServerName = ApiController.MainServer, ServerUri = ApiController.MainServiceUri } }, { new ServerStorage() { ServerName = ApiController.MainServer, ServerUri = ApiController.MainServiceUri } },
}; };
public bool SendCensusData { get; set; } = true; public bool SendCensusData { get; set; } = false;
public bool ShownCensusPopup { get; set; } = false; public bool ShownCensusPopup { get; set; } = false;
public int Version { get; set; } = 1; public int Version { get; set; } = 1;

View File

@@ -22,6 +22,8 @@ public class BanUserPopupHandler : IPopupHandler
public Vector2 PopupSize => new(500, 250); public Vector2 PopupSize => new(500, 250);
public bool ShowClose => true;
public void DrawContent() public void DrawContent()
{ {
UiSharedService.TextWrapped("User " + (_reportedPair.UserData.AliasOrUID) + " will be banned and removed from this Syncshell."); UiSharedService.TextWrapped("User " + (_reportedPair.UserData.AliasOrUID) + " will be banned and removed from this Syncshell.");
@@ -37,10 +39,6 @@ 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;

View File

@@ -17,13 +17,20 @@ public class CensusPopupHandler : IPopupHandler
_uiSharedService = uiSharedService; _uiSharedService = uiSharedService;
} }
public Vector2 PopupSize => new(600, 350); private Vector2 _size = new(600, 450);
public Vector2 PopupSize => _size;
public bool ShowClose => false;
public void DrawContent() public void DrawContent()
{ {
var start = 0f;
using (ImRaii.PushFont(_uiSharedService.UidFont)) using (ImRaii.PushFont(_uiSharedService.UidFont))
UiSharedService.TextWrapped("Mare Census Opt-Out"); {
ImGuiHelpers.ScaledDummy(5, 5); start = ImGui.GetCursorPosY() - ImGui.CalcTextSize("Mare Census Data").Y;
UiSharedService.TextWrapped("Mare Census Participation");
}
ImGuiHelpers.ScaledDummy(5f);
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."); 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(); ImGui.Separator();
UiSharedService.TextWrapped("Mare Census is a data collecting service that can be used for statistical purposes. " + UiSharedService.TextWrapped("Mare Census is a data collecting service that can be used for statistical purposes. " +
@@ -34,17 +41,25 @@ public class CensusPopupHandler : IPopupHandler
+ "- Current Gender (reflecting Glamourer changes)" + Environment.NewLine + "- Current Gender (reflecting Glamourer changes)" + Environment.NewLine
+ "- Current Race (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)"); + "- 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("To consent to collecting census data press the appropriate button below.");
UiSharedService.TextWrapped("This setting can be changed anytime in the Mare Settings."); UiSharedService.TextWrapped("This setting can be changed anytime in the Mare Settings.");
var sendCensus = _serverConfigurationManager.SendCensusData; var width = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
if (ImGui.Checkbox("Allow sending census data", ref sendCensus)) var buttonSize = ImGuiHelpers.GetButtonSize("I consent to send my census data");
ImGuiHelpers.ScaledDummy(5f);
if (ImGui.Button("I consent to send my census data", new Vector2(width, buttonSize.Y * 2.5f)))
{ {
_serverConfigurationManager.SendCensusData = sendCensus; _serverConfigurationManager.SendCensusData = true;
_serverConfigurationManager.ShownCensusPopup = true;
ImGui.CloseCurrentPopup();
} }
} ImGuiHelpers.ScaledDummy(1f);
if (ImGui.Button("I do not consent to send my census data", new Vector2(width, buttonSize.Y)))
public void OnClose() {
{ _serverConfigurationManager.SendCensusData = false;
_serverConfigurationManager.ShownCensusPopup = true; _serverConfigurationManager.ShownCensusPopup = true;
ImGui.CloseCurrentPopup();
}
var height = ImGui.GetCursorPosY() - start;
_size = _size with { Y = height };
} }
} }

View File

@@ -5,8 +5,7 @@ namespace MareSynchronos.UI.Components.Popup;
public interface IPopupHandler public interface IPopupHandler
{ {
Vector2 PopupSize { get; } Vector2 PopupSize { get; }
bool ShowClose { get; }
void DrawContent(); void DrawContent();
void OnClose();
} }

View File

@@ -69,17 +69,13 @@ public class PopupHandler : WindowMediatorSubscriberBase
using var popup = ImRaii.Popup(WindowName, ImGuiWindowFlags.Modal); using var popup = ImRaii.Popup(WindowName, ImGuiWindowFlags.Modal);
if (!popup) return; if (!popup) return;
_currentHandler.DrawContent(); _currentHandler.DrawContent();
ImGui.Separator(); if (_currentHandler.ShowClose)
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close"))
{ {
ImGui.CloseCurrentPopup(); ImGui.Separator();
_currentHandler.OnClose(); if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close"))
{
ImGui.CloseCurrentPopup();
}
} }
} }
public override void OnClose()
{
base.OnClose();
_currentHandler?.OnClose();
}
} }

View File

@@ -24,6 +24,8 @@ internal class ReportPopupHandler : IPopupHandler
public Vector2 PopupSize => new(500, 500); public Vector2 PopupSize => new(500, 500);
public bool ShowClose => true;
public void DrawContent() public void DrawContent()
{ {
using (ImRaii.PushFont(_uiSharedService.UidFont)) using (ImRaii.PushFont(_uiSharedService.UidFont))
@@ -49,10 +51,6 @@ internal class ReportPopupHandler : IPopupHandler
} }
} }
public void OnClose()
{
}
public void Open(OpenReportPopupMessage msg) public void Open(OpenReportPopupMessage msg)
{ {
_reportedPair = msg.PairToReport; _reportedPair = msg.PairToReport;