diff --git a/src/PoeLurker.Core/Models/Collaboration.cs b/src/PoeLurker.Core/Models/Collaboration.cs index 15a7251e..3be8baea 100644 --- a/src/PoeLurker.Core/Models/Collaboration.cs +++ b/src/PoeLurker.Core/Models/Collaboration.cs @@ -7,7 +7,7 @@ namespace PoeLurker.Core.Models; using System; -using System.Diagnostics; +using PoeLurker.Core.Extensions; /// /// Represents a collaboration. @@ -51,7 +51,7 @@ public bool IsExpired() /// public void Open() { - Process.Start(Url.ToString()); + ProcessExtensions.OpenUrl(Url.ToString()); } #endregion diff --git a/src/PoeLurker.Core/Models/Settings.cs b/src/PoeLurker.Core/Models/Settings.cs index 01de961f..33863553 100644 --- a/src/PoeLurker.Core/Models/Settings.cs +++ b/src/PoeLurker.Core/Models/Settings.cs @@ -25,6 +25,26 @@ public Settings() SoldMessage = DefaultSoldMessage; BusyMessage = DefaultBusyMessage; ThankYouMessage = DefaultThankYouMessage; + + ShowWelcome = true; + IncomingTradeEnabled = true; + OutgoingTradeEnabled = true; + ToolTipEnabled = true; + ClipboardEnabled = true; + AutoKickEnabled = true; + HideInBackground = true; + HideoutEnabled = true; + BuildAutoClose = true; + ShowReleaseNote = true; + ShowStartupAnimation = true; + SoldDetection = true; + OutgoingDelayToClose = 100; + JoinHideoutVolume = 1; + AlertVolume = 1; + ItemAlertVolume = 0.5f; + TradebarScaling = 1; + LifeForeground = "#FFFFFFFF"; + ToolTipDelay = 1000; } #region Properties @@ -32,7 +52,6 @@ public Settings() /// /// Gets or sets a value indicating whether the welcome screen should be shown. /// - [DefaultValue(true)] public bool ShowWelcome { get; set; } /// @@ -68,13 +87,11 @@ public Settings() /// /// Gets or sets a value indicating whether [incoming trade enabled]. /// - [DefaultValue(true)] public bool IncomingTradeEnabled { get; set; } /// /// Gets or sets a value indicating whether [outgoing trade enabled]. /// - [DefaultValue(true)] public bool OutgoingTradeEnabled { get; set; } /// @@ -110,37 +127,31 @@ public Settings() /// /// Gets or sets the alert volume. /// - [DefaultValue(1)] public float AlertVolume { get; set; } /// /// Gets or sets the alert volume. /// - [DefaultValue(0.5f)] public float ItemAlertVolume { get; set; } /// /// Gets or sets the join hideout volume. /// - [DefaultValue(1)] public float JoinHideoutVolume { get; set; } /// /// Gets or sets a value indicating whether [tool tip enabled]. /// - [DefaultValue(true)] public bool ToolTipEnabled { get; set; } /// /// Gets or sets a value indicating whether [clipboard enabled]. /// - [DefaultValue(true)] public bool ClipboardEnabled { get; set; } /// /// Gets or sets a value indicating whether [automatic kick]. /// - [DefaultValue(true)] public bool AutoKickEnabled { get; set; } /// @@ -161,13 +172,11 @@ public Settings() /// /// Gets or sets the tooltip delay. /// - [DefaultValue(1000)] public int ToolTipDelay { get; set; } /// /// Gets or sets a value indicating whether [hide in background]. /// - [DefaultValue(true)] public bool HideInBackground { get; set; } /// @@ -178,19 +187,16 @@ public Settings() /// /// Gets or sets the life foreground. /// - [DefaultValue("#FFFFFFFF")] public string LifeForeground { get; set; } /// /// Gets or sets the trade bar scaling. /// - [DefaultValue(1)] public double TradebarScaling { get; set; } /// /// Gets or sets a value indicating whether [show startup animation]. /// - [DefaultValue(true)] public bool ShowStartupAnimation { get; set; } /// @@ -206,13 +212,11 @@ public Settings() /// /// Gets or sets a value indicating whether [sold detection]. /// - [DefaultValue(true)] public bool SoldDetection { get; set; } /// /// Gets or sets a value indicating whether [show release note]. /// - [DefaultValue(true)] public bool ShowReleaseNote { get; set; } /// @@ -223,7 +227,6 @@ public Settings() /// /// Gets or sets a value indicating whether [build automatic close]. /// - [DefaultValue(true)] public bool BuildAutoClose { get; set; } /// @@ -234,13 +237,11 @@ public Settings() /// /// Gets or sets a value indicating whether [synchronize build]. /// - [DefaultValue(true)] public bool SyncBuild { get; set; } /// /// Gets or sets a value indicating whether [hideout enabled]. /// - [DefaultValue(true)] public bool HideoutEnabled { get; set; } /// @@ -261,8 +262,12 @@ public Settings() /// /// Gets or sets a value indicating the delay to close outgoing trades. /// - [DefaultValue(100)] public double OutgoingDelayToClose { get; set; } + /// + /// Gets or sets a value indicating if the user tried to connect with patreon. + /// + public bool ConnectedToPatreon { get; set; } + #endregion } \ No newline at end of file diff --git a/src/PoeLurker.Core/PoeLurker.Core.csproj b/src/PoeLurker.Core/PoeLurker.Core.csproj index bca1ef86..c9bd222b 100644 --- a/src/PoeLurker.Core/PoeLurker.Core.csproj +++ b/src/PoeLurker.Core/PoeLurker.Core.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/PoeLurker.Core/Services/SettingsService.cs b/src/PoeLurker.Core/Services/SettingsService.cs index e73c07af..8de69461 100644 --- a/src/PoeLurker.Core/Services/SettingsService.cs +++ b/src/PoeLurker.Core/Services/SettingsService.cs @@ -487,6 +487,19 @@ public bool ShowStartupAnimation } } + public bool ConnectedToPatreon + { + get + { + return _settings.Entity.ConnectedToPatreon; + } + + set + { + _settings.Entity.ConnectedToPatreon = value; + } + } + /// /// Gets or sets a value indicating whether [vulkan renderer]. /// diff --git a/src/PoeLurker.UI/PoeLurker.UI.csproj b/src/PoeLurker.UI/PoeLurker.UI.csproj index 390e65cf..09d9ce47 100644 --- a/src/PoeLurker.UI/PoeLurker.UI.csproj +++ b/src/PoeLurker.UI/PoeLurker.UI.csproj @@ -151,7 +151,7 @@ - + diff --git a/src/PoeLurker.UI/ViewModels/BuildViewModel.cs b/src/PoeLurker.UI/ViewModels/BuildViewModel.cs index 0f76b23b..59c8acd5 100644 --- a/src/PoeLurker.UI/ViewModels/BuildViewModel.cs +++ b/src/PoeLurker.UI/ViewModels/BuildViewModel.cs @@ -8,12 +8,12 @@ namespace PoeLurker.UI.ViewModels; using System; using System.Collections.ObjectModel; -using System.Diagnostics; using System.Linq; using System.Net.Http; using System.Threading.Tasks; using Caliburn.Micro; using PoeLurker.Core; +using PoeLurker.Core.Extensions; using PoeLurker.Core.Helpers; using PoeLurker.Core.Models; using PoeLurker.Core.Services; @@ -491,7 +491,7 @@ public void OpenSelectedTree() { if (SelectedSkillTreeInformation != null && !string.IsNullOrEmpty(SelectedSkillTreeInformation.Url)) { - Process.Start(SelectedSkillTreeInformation.Url); + ProcessExtensions.OpenUrl(SelectedSkillTreeInformation.Url); } } diff --git a/src/PoeLurker.UI/ViewModels/PushoverViewModel.cs b/src/PoeLurker.UI/ViewModels/PushoverViewModel.cs index a9b41439..b58c0120 100644 --- a/src/PoeLurker.UI/ViewModels/PushoverViewModel.cs +++ b/src/PoeLurker.UI/ViewModels/PushoverViewModel.cs @@ -6,7 +6,7 @@ namespace PoeLurker.UI.ViewModels; -using System.Diagnostics; +using PoeLurker.Core.Extensions; using PoeLurker.Patreon.Services; /// @@ -121,7 +121,7 @@ public async void Test() /// public void NewAccount() { - Process.Start("https://pushover.net/signup"); + ProcessExtensions.OpenUrl("https://pushover.net/signup"); } /// @@ -129,7 +129,7 @@ public void NewAccount() /// public void Info() { - Process.Start("https://github.com/C1rdec/Poe-Lurker/blob/main/assets/Pushover.md"); + ProcessExtensions.OpenUrl("https://github.com/C1rdec/Poe-Lurker/blob/main/assets/Pushover.md"); } #endregion diff --git a/src/PoeLurker.UI/ViewModels/SettingsViewModel.cs b/src/PoeLurker.UI/ViewModels/SettingsViewModel.cs index bf96cae9..4a03faae 100644 --- a/src/PoeLurker.UI/ViewModels/SettingsViewModel.cs +++ b/src/PoeLurker.UI/ViewModels/SettingsViewModel.cs @@ -437,14 +437,14 @@ public bool NotConnected { get { - return !new TokenService().Connected; + return !_settingService.ConnectedToPatreon; } } /// /// Gets the patreon identifier. /// - public string PatreonId => new TokenService().PatreonId; + public string PatreonId => _currentPatreonService.PatreonId; /// /// Gets or sets a value indicating whether this is pledging. @@ -1049,7 +1049,7 @@ public void OpenLogs() if (Directory.Exists(folderName)) { - Process.Start(folderName); + ProcessExtensions.OpenUrl(folderName); } } @@ -1308,6 +1308,9 @@ public async Task LoginToPatreon() SearchEnabled = true; MapEnabled = true; DashboardEnabled = true; + _settingService.ConnectedToPatreon = true; + SaveSettings(); + NotifyOfPropertyChange(() => NotConnected); } } @@ -1383,28 +1386,36 @@ protected override async Task OnActivateAsync(CancellationToken token) { HasCustomTradeSound = _soundService.HasCustomTradeAlert(); HasCustomItemSound = _soundService.HasCustomItemAlert(); + AlertVolume = (int)(_settingService.AlertVolume * 100); + ItemAlertVolume = (int)(_settingService.ItemAlertVolume * 100); + JoinHideoutVolume = (int)(_settingService.JoinHideoutVolume * 100); + CheckForUpdate(); - _ = _currentPatreonService.CheckPledgeStatus().ContinueWith(t => + if (_settingService.ConnectedToPatreon) { - Pledging = _currentPatreonService.Pledging; - if (Pledging) - { - BlessingText = "A blessing I can’t deny"; - } - else + _ = _currentPatreonService.CheckPledgeStatus().ContinueWith(t => { - SearchEnabled = false; - DashboardEnabled = false; - MapEnabled = false; - } + Pledging = _currentPatreonService.Pledging; + if (Pledging) + { + BlessingText = "A blessing I can’t deny"; + } + else + { + SearchEnabled = false; + DashboardEnabled = false; + MapEnabled = false; + _settingService.ConnectedToPatreon = false; + _settingService.Save(); + } + _activated = true; + }); + } + else + { _activated = true; - }); - - AlertVolume = (int)(_settingService.AlertVolume * 100); - ItemAlertVolume = (int)(_settingService.ItemAlertVolume * 100); - JoinHideoutVolume = (int)(_settingService.JoinHideoutVolume * 100); - CheckForUpdate(); + } await base.OnActivateAsync(token); } diff --git a/src/PoeLurker.UI/ViewModels/ShellViewModel.cs b/src/PoeLurker.UI/ViewModels/ShellViewModel.cs index 984445d7..10ef236e 100644 --- a/src/PoeLurker.UI/ViewModels/ShellViewModel.cs +++ b/src/PoeLurker.UI/ViewModels/ShellViewModel.cs @@ -17,6 +17,7 @@ namespace PoeLurker.UI.ViewModels; using System.Windows; using Caliburn.Micro; using PoeLurker.Core; +using PoeLurker.Core.Extensions; using PoeLurker.Core.Helpers; using PoeLurker.Core.Models; using PoeLurker.Core.Services; @@ -127,7 +128,7 @@ public ShellViewModel( if (settingsService.ShowReleaseNote) { - Process.Start("https://github.com/C1rdec/Poe-Lurker/releases/latest"); + ProcessExtensions.OpenUrl("https://github.com/C1rdec/Poe-Lurker/releases/latest"); } } diff --git a/src/PoeLurker.UI/ViewModels/WelcomeViewModel.cs b/src/PoeLurker.UI/ViewModels/WelcomeViewModel.cs index 19d9990f..5e50c848 100644 --- a/src/PoeLurker.UI/ViewModels/WelcomeViewModel.cs +++ b/src/PoeLurker.UI/ViewModels/WelcomeViewModel.cs @@ -6,8 +6,8 @@ namespace PoeLurker.UI.ViewModels; -using System.Diagnostics; using Caliburn.Micro; +using PoeLurker.Core.Extensions; /// /// Represents the welcome screen. @@ -21,7 +21,7 @@ public class WelcomeViewModel : Screen /// public void OpenDiscord() { - Process.Start("https://discord.com/invite/hQERv7K"); + ProcessExtensions.OpenUrl("https://discord.com/invite/hQERv7K"); } /// @@ -29,7 +29,7 @@ public void OpenDiscord() /// public void OpenPatreon() { - Process.Start("https://www.patreon.com/poelurker"); + ProcessExtensions.OpenUrl("https://www.patreon.com/poelurker"); } /// @@ -37,7 +37,7 @@ public void OpenPatreon() /// public void OpenUserGuide() { - Process.Start(@"https://docs.google.com/presentation/d/1XhaSSNAFGxzouc5amzAW8c_6ifToNjnsQq5UmNgLXoo/present?slide=id.p"); + ProcessExtensions.OpenUrl(@"https://docs.google.com/presentation/d/1XhaSSNAFGxzouc5amzAW8c_6ifToNjnsQq5UmNgLXoo/present?slide=id.p"); } /// @@ -45,7 +45,7 @@ public void OpenUserGuide() /// public void OpenCheatSheet() { - Process.Start(@"https://github.com/C1rdec/Poe-Lurker/blob/main/assets/CheatSheet.md"); + ProcessExtensions.OpenUrl(@"https://github.com/C1rdec/Poe-Lurker/blob/main/assets/CheatSheet.md"); } ///