fix: add way to show classifier window

This commit is contained in:
Anna 2021-03-05 23:00:52 -05:00
parent 20530c6290
commit 993a6ccca4
3 changed files with 9 additions and 9 deletions

View File

@ -52,7 +52,7 @@ namespace NoSoliciting.Interface {
this.Plugin.Config.Save();
if (this.Plugin.Config.UseMachineLearning) {
this.Plugin.InitialiseMachineLearning();
this.Plugin.InitialiseMachineLearning(false);
}
}
@ -129,7 +129,7 @@ namespace NoSoliciting.Interface {
this.Plugin.MlFilter?.Dispose();
this.Plugin.MlFilter = null;
this.Plugin.MlStatus = MlFilterStatus.Uninitialised;
this.Plugin.InitialiseMachineLearning();
this.Plugin.InitialiseMachineLearning(ImGui.GetIO().KeyAlt);
}
}

View File

@ -50,7 +50,7 @@ namespace NoSoliciting.Ml {
return MessageCategory.Normal;
}
public static async Task<MlFilter?> Load(Plugin plugin) {
public static async Task<MlFilter?> Load(Plugin plugin, bool showWindow) {
plugin.MlStatus = MlFilterStatus.DownloadingManifest;
var manifest = await DownloadManifest();
@ -93,7 +93,7 @@ namespace NoSoliciting.Ml {
var pipeId = Guid.NewGuid();
var process = StartClassifier(exePath, pipeId);
var process = StartClassifier(exePath, pipeId, showWindow);
var client = await CreateClassifierClient(pipeId, data);
return new MlFilter(
@ -119,11 +119,11 @@ namespace NoSoliciting.Ml {
return client;
}
private static Process StartClassifier(string exePath, Guid pipeId) {
private static Process StartClassifier(string exePath, Guid pipeId, bool showWindow) {
var game = Process.GetCurrentProcess();
var startInfo = new ProcessStartInfo(exePath) {
CreateNoWindow = true,
CreateNoWindow = !showWindow,
UseShellExecute = false,
Arguments = $"\"{game.Id}\" \"{game.ProcessName}\" \"{pipeId}\"",
};

View File

@ -52,7 +52,7 @@ namespace NoSoliciting {
this.Filter = new Filter(this);
if (this.Config.UseMachineLearning) {
this.InitialiseMachineLearning();
this.InitialiseMachineLearning(false);
}
// pre-compute the max ilvl to prevent stutter
@ -74,12 +74,12 @@ namespace NoSoliciting {
this._disposedValue = true;
}
internal void InitialiseMachineLearning() {
internal void InitialiseMachineLearning(bool showWindow) {
if (this.MlFilter != null) {
return;
}
Task.Run(async () => this.MlFilter = await MlFilter.Load(this))
Task.Run(async () => this.MlFilter = await MlFilter.Load(this, showWindow))
.ContinueWith(e => {
if (e.IsFaulted) {
this.MlStatus = MlFilterStatus.Uninitialised;