/// <summary> /// Called on the initial loading of Lol Enhancement Suite. /// </summary> private void MainGrid_Loaded(object sender, RoutedEventArgs e) { LeagueVersionLabel.Content = INTENDED_VERSION; //Create the debug log. Delete it if it already exists. if (File.Exists("debug.log")) { File.Delete("debug.log"); } File.Create("debug.log").Dispose(); //Set the events for the worker when the patching starts. _worker.DoWork += worker_DoWork; _worker.RunWorkerCompleted += worker_RunWorkerCompleted; //Set the events for the Garena version removing mechanism worker. GarenaBackupWorker.DoWork += GarenaWorker_DoWork; GarenaBackupWorker.RunWorkerCompleted += GarenaWorker_WorkCompleted; //Enable exception logging if the debugger ISNT attached. if (!Debugger.IsAttached) { AppDomain.CurrentDomain.FirstChanceException += OnFirstChanceException; } //try to find the mods in the base directory of the solution when the debugger is attached if (Debugger.IsAttached && !Directory.Exists(_modsDirectory) && Directory.Exists("../../../mods")) { _modsDirectory = "../../../mods"; } //Make sure that the mods exist in the directory. Warn the user if they dont. if (!Directory.Exists(_modsDirectory)) { MessageBox.Show("Missing mods directory. Ensure that all files were extracted properly.", "Missing files"); } var modList = Directory.GetDirectories(_modsDirectory); //Add each mod to the mod list. foreach (string mod in modList) { string modJsonFile = Path.Combine(mod, "mod.json"); if (File.Exists(modJsonFile)) { JavaScriptSerializer s = new JavaScriptSerializer(); LessMod lessMod = s.Deserialize <LessMod>(File.ReadAllText(modJsonFile)); lessMod.Directory = mod; CheckBox Check = new CheckBox(); Check.IsChecked = !lessMod.DisabledByDefault; Check.Content = lessMod.Name; ModsListBox.Items.Add(Check); _lessMods.Add(Check, lessMod); } } }
private void LoadMods() { ModsListBox.Items.Clear(); _lessMods.Clear(); //Get all mods within the mod directory var modList = Directory.GetDirectories(_modsDirectory); //Add each mod to the mod list. foreach (string mod in modList) { string modJsonFile = Path.Combine(mod, "mod.json"); if (File.Exists(modJsonFile)) { LessMod lessMod = serializer.Deserialize <LessMod>(File.ReadAllText(modJsonFile)); lessMod.Directory = mod; CheckBox ModCheckBox = new CheckBox() { IsChecked = !lessMod.DisabledByDefault && !lessMod.PermaDisable, //Don't automatically check disabled by default mods IsEnabled = !lessMod.PermaDisable, Content = lessMod.Name }; ModsListBox.Items.Add(ModCheckBox); _lessMods.Add(ModCheckBox, lessMod); } } }
/// <summary> /// Change the label & description when the mod is hovered over. /// </summary> private void ModsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { CheckBox box = (CheckBox)ModsListBox.SelectedItem; if (box == null) { return; } LessMod lessMod = _lessMods[box]; ModNameLabel.Content = lessMod.Name; ModDescriptionBox.Text = lessMod.Description; //see if our mod has an author and display it if (!string.IsNullOrEmpty(lessMod.Author)) { ModAuthorLabel.Content = "Author: " + lessMod.Author; } else { ModAuthorLabel.Content = "Author: Dark Voodoo Magicks"; } }