public void Reload() { Logger.log.Notice("Reloading TwitchFX config"); Command.ResetCommands(); LoadConfig(); ColorPreset.ResetColorPresets(); CustomLightshowData.ResetLightshows(); LoadColorPresets(UnityGame.UserDataPath + "\\TwitchFX\\ColorPresets"); LoadLightshows(UnityGame.UserDataPath + "\\TwitchFX\\Lightshows"); }
private void LoadLightshows(string lightshowFolderPath) { if (!Directory.Exists(lightshowFolderPath)) { Directory.CreateDirectory(lightshowFolderPath); } string[] lightshowFilePaths = Directory.GetFiles(lightshowFolderPath); foreach (string lightshowFilePath in lightshowFilePaths) { string name = Path.GetFileName(lightshowFilePath); if (!name.EndsWith(".json")) { continue; } name = name.Substring(0, name.Length - 5); string json = File.ReadAllText(lightshowFilePath); JSONNode rootJSON; try { rootJSON = JSON.Parse(json); } catch (Exception e) { Logger.log.Error("Failed loading lightshow: " + name); Logger.log.Error("\t" + e.Message); continue; } CustomLightshowData lightshow; try { lightshow = CustomLightshowData.LoadLightshowDataFromJSON(rootJSON, name); } catch (InvalidJSONException e) { Logger.log.Error("Failed loading lightshow: " + name); Logger.log.Error("\tInvalid JSON data: " + e.errorMessage); continue; } CustomLightshowData.SetLightshowData(name, lightshow); } Logger.log.Info(CustomLightshowData.GetLightshowDataCount() + " lightshows loaded from " + lightshowFolderPath); }