diff --git a/MareSynchronos/MareConfiguration/Configurations/ServerConfig.cs b/MareSynchronos/MareConfiguration/Configurations/ServerConfig.cs index 116c33b..373aab4 100644 --- a/MareSynchronos/MareConfiguration/Configurations/ServerConfig.cs +++ b/MareSynchronos/MareConfiguration/Configurations/ServerConfig.cs @@ -13,7 +13,7 @@ public class ServerConfig : IMareConfiguration { 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 int Version { get; set; } = 1; diff --git a/MareSynchronos/UI/Components/Popup/BanUserPopupHandler.cs b/MareSynchronos/UI/Components/Popup/BanUserPopupHandler.cs index 8a2f69f..1803e78 100644 --- a/MareSynchronos/UI/Components/Popup/BanUserPopupHandler.cs +++ b/MareSynchronos/UI/Components/Popup/BanUserPopupHandler.cs @@ -22,6 +22,8 @@ public class BanUserPopupHandler : IPopupHandler public Vector2 PopupSize => new(500, 250); + public bool ShowClose => true; + public void DrawContent() { 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."); } - public void OnClose() - { - } - public void Open(OpenBanUserPopupMessage message) { _reportedPair = message.PairToBan; diff --git a/MareSynchronos/UI/Components/Popup/CensusPopupHandler.cs b/MareSynchronos/UI/Components/Popup/CensusPopupHandler.cs index de95e33..8befc4b 100644 --- a/MareSynchronos/UI/Components/Popup/CensusPopupHandler.cs +++ b/MareSynchronos/UI/Components/Popup/CensusPopupHandler.cs @@ -17,13 +17,20 @@ public class CensusPopupHandler : IPopupHandler _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() { + var start = 0f; 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."); ImGui.Separator(); 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 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("To consent to collecting census data press the appropriate button 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)) + var width = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X; + 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(); } - } - - public void OnClose() - { - _serverConfigurationManager.ShownCensusPopup = true; + ImGuiHelpers.ScaledDummy(1f); + if (ImGui.Button("I do not consent to send my census data", new Vector2(width, buttonSize.Y))) + { + _serverConfigurationManager.SendCensusData = false; + _serverConfigurationManager.ShownCensusPopup = true; + ImGui.CloseCurrentPopup(); + } + var height = ImGui.GetCursorPosY() - start; + _size = _size with { Y = height }; } } diff --git a/MareSynchronos/UI/Components/Popup/IPopupHandler.cs b/MareSynchronos/UI/Components/Popup/IPopupHandler.cs index aa649b4..21b99f9 100644 --- a/MareSynchronos/UI/Components/Popup/IPopupHandler.cs +++ b/MareSynchronos/UI/Components/Popup/IPopupHandler.cs @@ -5,8 +5,7 @@ namespace MareSynchronos.UI.Components.Popup; public interface IPopupHandler { Vector2 PopupSize { get; } + bool ShowClose { get; } void DrawContent(); - - void OnClose(); } \ No newline at end of file diff --git a/MareSynchronos/UI/Components/Popup/PopupHandler.cs b/MareSynchronos/UI/Components/Popup/PopupHandler.cs index 055ee91..484659b 100644 --- a/MareSynchronos/UI/Components/Popup/PopupHandler.cs +++ b/MareSynchronos/UI/Components/Popup/PopupHandler.cs @@ -69,17 +69,13 @@ public class PopupHandler : WindowMediatorSubscriberBase using var popup = ImRaii.Popup(WindowName, ImGuiWindowFlags.Modal); if (!popup) return; _currentHandler.DrawContent(); - ImGui.Separator(); - if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close")) + if (_currentHandler.ShowClose) { - ImGui.CloseCurrentPopup(); - _currentHandler.OnClose(); + ImGui.Separator(); + if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close")) + { + ImGui.CloseCurrentPopup(); + } } } - - public override void OnClose() - { - base.OnClose(); - _currentHandler?.OnClose(); - } } \ No newline at end of file diff --git a/MareSynchronos/UI/Components/Popup/ReportPopupHandler.cs b/MareSynchronos/UI/Components/Popup/ReportPopupHandler.cs index 3f58dd2..a93bfd9 100644 --- a/MareSynchronos/UI/Components/Popup/ReportPopupHandler.cs +++ b/MareSynchronos/UI/Components/Popup/ReportPopupHandler.cs @@ -24,6 +24,8 @@ internal class ReportPopupHandler : IPopupHandler public Vector2 PopupSize => new(500, 500); + public bool ShowClose => true; + public void DrawContent() { using (ImRaii.PushFont(_uiSharedService.UidFont)) @@ -49,10 +51,6 @@ internal class ReportPopupHandler : IPopupHandler } } - public void OnClose() - { - } - public void Open(OpenReportPopupMessage msg) { _reportedPair = msg.PairToReport;