diff --git a/RotationSolver/SpeechHelper.cs b/RotationSolver/SpeechHelper.cs index dedf7c937..34f873a53 100644 --- a/RotationSolver/SpeechHelper.cs +++ b/RotationSolver/SpeechHelper.cs @@ -16,12 +16,12 @@ internal static void Speak(string text) { try { - VoiceNames ??= _speech.GetInstalledVoices().Select(v => v.VoiceInfo.Name).ToArray(); _speech ??= new SpeechSynthesizer(); _speech.Volume = Service.Config.VoiceVolume; _speech.SelectVoice(Service.Config.VoiceName); + VoiceNames ??= _speech.GetInstalledVoices().Select(v => v.VoiceInfo.Name).ToArray(); } - catch(Exception ex) + catch (Exception ex) { if (!_errored) { diff --git a/RotationSolver/Updaters/RotationUpdater.cs b/RotationSolver/Updaters/RotationUpdater.cs index 07b2e7519..1f772e495 100644 --- a/RotationSolver/Updaters/RotationUpdater.cs +++ b/RotationSolver/Updaters/RotationUpdater.cs @@ -19,6 +19,9 @@ public static async void GetAllCustomRotations() var relayFolder = Service.Interface.ConfigDirectory.FullName; if (!Directory.Exists(relayFolder)) Directory.CreateDirectory(relayFolder); + LoadRotationsFromLocal(relayFolder); + + bool hasDownload = false; using (var client = new HttpClient()) { IEnumerable libs = Service.Config.OtherLibs; @@ -59,6 +62,7 @@ await response.Content.CopyToAsync(new FileStream(filePath, File.Exists(filePath ? FileMode.Open : FileMode.CreateNew)); } + hasDownload = true; PluginLog.Log($"Successfully download the {filePath}"); } catch (Exception ex) @@ -68,10 +72,15 @@ await response.Content.CopyToAsync(new FileStream(filePath, File.Exists(filePath } } + if (hasDownload) LoadRotationsFromLocal(relayFolder); + } + + private static void LoadRotationsFromLocal(string relayFolder) + { var directories = Service.Config.OtherLibs - .Where(Directory.Exists) - .Append(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ICustomRotation)).Location)) - .Append(relayFolder); + .Where(Directory.Exists) + .Append(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ICustomRotation)).Location)) + .Append(relayFolder); var assemblies = from dir in directories where Directory.Exists(dir)