-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Add the option to disable codescan #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ public CodeScanConfigService(HttpClient httpClient, IPreferencesService preferen | |
| } | ||
|
|
||
| string pathBase = _preferencesService.GetPreferences().InstallationPath; | ||
| string folderName = GetFolderName(version); | ||
| string folderName = GetFolderName(version, _environmentService); | ||
| string versionPath = Path.Combine(pathBase, "nonbuild", version, folderName); | ||
|
|
||
| if (Directory.Exists(versionPath) == false) | ||
|
|
@@ -194,9 +194,9 @@ private string GetZipFolderName() | |
| } | ||
| } | ||
|
|
||
| private string GetFolderName(string version) | ||
| public static string GetFolderName(string version, IEnvironmentService environmentService) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think almost all pages use |
||
| { | ||
| CurrentEnvironment os = _environmentService.GetCurrentEnvironment(); | ||
| CurrentEnvironment os = environmentService.GetCurrentEnvironment(); | ||
| switch (os) | ||
| { | ||
| case CurrentEnvironment.WindowsStandalone: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,11 +48,20 @@ public bool? TTSEnabled | |
| get => _TTSEnabled; | ||
| set => this.RaiseAndSetIfChanged(ref _TTSEnabled, value); | ||
| } | ||
|
|
||
| private bool? _allowCodeScan = true; | ||
|
|
||
| public bool? AllowCodeScan | ||
| { | ||
| get => _allowCodeScan; | ||
| set => this.RaiseAndSetIfChanged(ref _allowCodeScan, value); | ||
| } | ||
|
|
||
| private readonly IPreferencesService _preferencesService; | ||
| private readonly IInstallationService _installationService; | ||
| private readonly IEnvironmentService _environmentService; | ||
| private readonly ITTSService _ttsService; | ||
|
|
||
|
|
||
| public PreferencesPanelViewModel( | ||
| IPreferencesService preferencesService, | ||
|
|
@@ -69,6 +78,7 @@ public PreferencesPanelViewModel( | |
| _installationPath = preferences.InstallationPath; | ||
| _autoRemove = preferences.AutoRemove; | ||
| _TTSEnabled = preferences.TTSEnabled; | ||
| _allowCodeScan = preferences.AllowCodeScan; | ||
| this.WhenAnyValue(p => p.AutoRemove) | ||
| .Select(_ => Observable.FromAsync(OnAutoRemoveChangedAsync)) | ||
| .Concat() | ||
|
|
@@ -78,6 +88,11 @@ public PreferencesPanelViewModel( | |
| .Select(_ => Observable.FromAsync(OnTTSChangedAsync)) | ||
| .Concat() | ||
| .Subscribe(); | ||
|
|
||
| this.WhenAnyValue(p => p.AllowCodeScan) | ||
| .Select(_ => Observable.FromAsync(OnAllowCodeScanChangedAsync)) | ||
| .Concat() | ||
| .Subscribe(); | ||
| } | ||
|
|
||
| public async Task OnAutoRemoveChangedAsync() | ||
|
|
@@ -160,6 +175,26 @@ await MessageBoxBuilder.CreateMessageBox(MessageBoxButtons.Ok, "Error moving ins | |
| await MessageBoxBuilder.CreateMessageBox(MessageBoxButtons.Ok, "Invalid installation path", invalidReason).ShowAsync(); | ||
| } | ||
| } | ||
|
|
||
| public async Task OnAllowCodeScanChangedAsync() | ||
| { | ||
| if (AllowCodeScan == false) | ||
| { | ||
| IMsBox<string> msgBox = MessageBoxBuilder.CreateMessageBox( | ||
| MessageBoxButtons.YesNo, | ||
| "Warning", | ||
| "For security reasons, we recommend you never disable the codescan feature unless you're trying to play on older servers that are no longer supported.\n Are you sure you want to proceed?" | ||
|
||
| ); | ||
|
|
||
| string response = await msgBox.ShowAsync(); | ||
| if (response.Equals(MessageBoxResults.No)) | ||
| { | ||
| AllowCodeScan = true; // Revert the change | ||
| } | ||
| } | ||
|
|
||
| _preferencesService.GetPreferences().AllowCodeScan = AllowCodeScan; | ||
| } | ||
|
|
||
| public override void Refresh() | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.