/// <summary> /// Retrieves the Mod Loader configuration file struct. /// </summary> /// <param name="gameConfigDirectory">The directory containing the configuration file for the game. e.g. $LOADERPATH\\Reloaded-Mods\\Games\\Sonic-Heroes</param> /// <returns></returns> public static GameConfig ParseConfig(string gameConfigDirectory) { // Sets the configuration file location for the game. string configFile = gameConfigDirectory + $"\\{Strings.Parsers.ConfigFile}"; // Try parsing the config file, else backup to default one. GameConfig config; try { config = File.Exists(configFile) ? JsonConvert.DeserializeObject <GameConfig>(File.ReadAllText(configFile)) : new GameConfig(); } catch { config = new GameConfig(); } // Set the directory of this config. config.ConfigLocation = configFile; // Override names if default config. if (gameConfigDirectory == LoaderPaths.GetGlobalGameConfigDirectory()) { config = GameConfig.SetGlobalConfigProperties(config); } // Return the config file. return(config); }
/// <summary> /// Allows for the selection of a mod folder for storing mods for the current game. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SelectModFolder(object sender, EventArgs e) { // Dialog for launching executables. CommonOpenFileDialog folderDialog = new CommonOpenFileDialog(); folderDialog.Title = "Select the folder for storing current game's mods."; folderDialog.Multiselect = false; folderDialog.IsFolderPicker = true; folderDialog.InitialDirectory = LoaderPaths.GetModLoaderModDirectory(); // Open dialog. if (folderDialog.ShowDialog() == CommonFileDialogResult.Ok) { if (folderDialog.FileName.Contains(LoaderPaths.GetModLoaderModDirectory())) { // Check if a folder was selected. if (folderDialog.FileName.Length < LoaderPaths.GetModLoaderModDirectory().Length + 1) { MessageBox.Show("You should probably select a folder."); folderDialog.Dispose(); return; } // Get relative path. borderless_GameModDirectory.Text = folderDialog.FileName.Substring(LoaderPaths.GetModLoaderModDirectory().Length + 1); } else { MessageBox.Show("Your chosen directory should be a subdirectory of Reloaded-Mods (" + LoaderPaths.GetModLoaderModDirectory() + ")"); } } // Dispose dialog. folderDialog.Dispose(); }
/// <summary> /// Creates a new mod loader config from scratch. /// </summary> /// <param name="configLocation">The location of the config file to be written.</param> public void CreateConfig(string configLocation) { // Create category _iniData.Sections.Add(new SectionData("Mod Loader Configuration")); // Create fields _iniData.Sections["Mod Loader Configuration"].AddKey("Current_Theme"); _iniData.Sections["Mod Loader Configuration"].AddKey("Controller_Config_Type"); // Get default theme (first alphabetical theme) string[] directories = Directory.GetDirectories((LoaderPaths.GetModLoaderThemeDirectory())); // Set default theme if exists. if (directories.Length > 0) { _iniData["Mod Loader Configuration"]["Current_Theme"] = Path.GetFileNameWithoutExtension(directories[0]); } else { _iniData["Mod Loader Configuration"]["Current_Theme"] = "!Reloaded"; } // Set defaults _iniData["Mod Loader Configuration"]["Controller_Config_Type"] = Remapper.DirectInputConfigType.ProductGUID.ToString(); // Write file _iniParser.WriteFile(configLocation, _iniData); }
/// <summary> /// Retrieves the Mod Loader configuration file struct. /// </summary> /// <param name="gameConfigDirectory">The directory containing the configuration file for the game. e.g. $LOADERPATH\\Reloaded-Mods\\Games\\Sonic-Heroes</param> /// <returns></returns> public static GameConfig ParseConfig(string gameConfigDirectory) { // Sets the configuration file location for the game. string configFile = gameConfigDirectory + $"\\{Strings.Parsers.ConfigFile}"; // Try parsing the config file, else backup to default one. GameConfig config; try { config = File.Exists(configFile) ? JsonConvert.DeserializeObject <GameConfig>(File.ReadAllText(configFile)) : new GameConfig(); } catch { config = new GameConfig(); } // Set the directory of this config. config.ConfigLocation = configFile; // Override names if default config. if (gameConfigDirectory == LoaderPaths.GetGlobalGameConfigDirectory()) // Function call gemerates !Global if it does not exist. { config = GameConfig.SetGlobalConfigProperties(config); } // Create mod directory if nonexistant. if (!Directory.Exists(LoaderPaths.GetModLoaderModDirectory() + $"\\{config.ModDirectory}")) { Directory.CreateDirectory(LoaderPaths.GetModLoaderModDirectory() + $"\\{config.ModDirectory}"); } // Return the config file. return(config); }
/// <summary> /// Retrieves the configuration file location for the individual controller. /// If using an XInput controller, pass null. /// </summary> private void GetConfigLocation(DInputController dInputController) { // Get Configuration Details LoaderConfigParser.Config config = LoaderConfigParser.ParseConfig(); // Set the device type ConfigType = config.DirectInputConfigType; // If XInput/DInput if (DeviceType == InputDeviceType.DirectInput) { // If InstanceGUID or ProductGUID. if (ConfigType == DirectInputConfigType.InstanceGUID) { ConfigurationFileLocation = LoaderPaths.GetModLoaderConfigDirectory() + "/Controllers/Instances/" + dInputController.Information.InstanceGuid + ".json"; } else if (ConfigType == DirectInputConfigType.ProductGUID) { ConfigurationFileLocation = LoaderPaths.GetModLoaderConfigDirectory() + "/Controllers/" + PathSanitizer.ForceValidFilePath(dInputController.Information.ProductName) + ".json"; } } else if (DeviceType == InputDeviceType.XInput) { ConfigurationFileLocation = LoaderPaths.GetModLoaderConfigDirectory() + "/Controllers/XInput/" + "Controller_" + XInputPort + ".json"; } }
/// <summary> /// Retrieves the list of games from their configurations. /// </summary> private void LoadGames() { // Save current game config GameConfigParser.GameConfig currentConfig = Global.CurrentGameConfig; // Clear the current listview. box_GameList.Rows.Clear(); // Retrieve current game list the into Global. Global.GameConfigurations = Global.ConfigurationManager.GetAllGameConfigs(); // For each config, append it. foreach (GameConfigParser.GameConfig gameConfig in Global.GameConfigurations) { // Stores the path of the mod for display. string modPath = LoaderPaths.GetModLoaderModDirectory() + "\\" + gameConfig.ModDirectory; // Retrieves the relative path for presentation. string relativeModPath = LoaderPaths.GetModLoaderRelativePath(modPath); // Add the relative path. box_GameList.Rows.Add(gameConfig.GameName, relativeModPath); } // Re-select the currently selected game. ReselectCurrentGame(currentConfig); }
/// <summary> /// Adds a new game onto the current game list. /// </summary> private void AddNewGame(object sender, EventArgs e) { // Select new location for game configuration. CommonOpenFileDialog folderDialog = new CommonOpenFileDialog { Title = "Select the folder for the new game configuration.", Multiselect = false, IsFolderPicker = true, InitialDirectory = LoaderPaths.GetModLoaderGamesDirectory() }; // Open dialog. if (folderDialog.ShowDialog() == CommonFileDialogResult.Ok) { if (folderDialog.FileName.Contains(LoaderPaths.GetModLoaderGamesDirectory()) && folderDialog.FileName.Length > LoaderPaths.GetModLoaderGamesDirectory().Length) { CreateNewGameConfig(folderDialog.FileName); } else { MessageBox.Show($"Your chosen directory should be a subdirectory of {LoaderPaths.GetModLoaderGamesDirectory()} "); } } // Dispose dialog. folderDialog.Dispose(); }
/// <summary> /// Generates dummy templates for the individual different configurations of project types. /// </summary> private static void GenerateConfigTemplates() { // Get path to our folder containing the template set of configs. string templateDirectory = LoaderPaths.GetTemplatesDirectory() + "\\Config"; Directory.CreateDirectory(templateDirectory); // Write all configs. ModConfig.WriteConfig(new ModConfig() { ModLocation = $"{templateDirectory}\\Mod-Config.json" }); GameConfig.WriteConfig(new GameConfig() { ConfigLocation = $"{templateDirectory}\\Game-Config.json" }); ThemeConfig.WriteConfig(new ThemeConfig() { ThemeLocation = $"{templateDirectory}\\Theme-Config.json" }); PluginConfig.WriteConfig(new PluginConfig() { PluginConfigLocation = $"{templateDirectory}\\Plugin-Config.json" }); }
/// <summary> /// Writes out the Config file to the Config file location. /// </summary> /// <param name="config">The Config file to write to disk.</param> public static void WriteConfig(LoaderConfig config) { // Convert structure to JSON string json = JsonConvert.SerializeObject(config, Formatting.Indented); // Write to disk File.WriteAllText(LoaderPaths.GetModLoaderConfig(), json); }
/// <summary> /// Writes out the config file to the config file location/ /// </summary> /// <param name="config">The config file to write to disk.</param> public static void WriteConfig(Config config) { // Convert structure to JSON string json = JsonConvert.SerializeObject(config, Strings.Parsers.SerializerSettings); // Write to disk File.WriteAllText(LoaderPaths.GetModLoaderConfig(), json); }
/// <summary> /// Writes out the config file to an .ini file. /// </summary> /// <param name="config"></param> public void WriteConfig(Config config) { // Change the values of the current fields. _iniData["Mod Loader Configuration"]["Current_Theme"] = config.CurrentTheme; _iniData["Mod Loader Configuration"]["Controller_Config_Type"] = Enum.GetName(typeof(Remapper.DirectInputConfigType), config.DirectInputConfigType); // Write the file out to disk _iniParser.WriteFile(LoaderPaths.GetModLoaderConfig(), _iniData); }
/// <summary> /// Update the application when the user presses the update button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void item_Update_Click(object sender, EventArgs e) { try { // Cast the button & ignore if currently downloading. Button testButton = (Button)sender; if (_isCurrentlyDownloading) { return; } // If the progressbar is max, we are done here. if (borderless_UpdateProgressBar.Value == borderless_UpdateProgressBar.MAX_VALUE) { this.Close(); } // Set flags & GUI testButton.Text = "Downloading"; _isCurrentlyDownloading = true; // Get the current game configuration & file paths. GameConfig gameConfig = _gameConfigs[borderless_SelectGame.SelectedIndex]; string gameModDirectory = $"{LoaderPaths.GetModLoaderModDirectory()}\\{gameConfig.ModDirectory}"; CallUpdateSourcesOnDownloadLink(gameModDirectory); // May change modification URL download link. string fileName = "Temp.tmp"; string downloadLocation = $"{gameModDirectory}\\{fileName}"; // Start the modification download. byte[] remoteFile = await FileDownloader.DownloadFile ( new Uri(_modificationUrl), downloadProgressChanged : ClientOnDownloadProgressChanged ); // Start unpacking testButton.Text = "Unpacking"; testButton.Refresh(); using (Stream stream = new MemoryStream(remoteFile)) using (ArchiveFile archiveFile = new ArchiveFile(stream)) { archiveFile.Extract($"{gameModDirectory}\\"); CallUpdateSourcesOnExtractLink(archiveFile); } // Cleanup File.Delete(downloadLocation); _isCurrentlyDownloading = false; borderless_UpdateProgressBar.Value = borderless_UpdateProgressBar.MAX_VALUE; testButton.Text = "Close"; } catch (Exception exception) { MessageBox.Show(exception.Message); _isCurrentlyDownloading = false; } }
/// <summary> /// Retrieves the Mod Loader configuration file struct. /// </summary> /// <returns>Parses a Mod Loader configuration file.</returns> public static LoaderConfig ParseConfig() { // Try parsing the Config file, else return default one. try { return(File.Exists(LoaderPaths.GetModLoaderConfig()) ? JsonConvert.DeserializeObject <LoaderConfig>(File.ReadAllText(LoaderPaths.GetModLoaderConfig())) : new LoaderConfig()); } catch { return(new LoaderConfig()); } }
/// <summary> /// Applies a set of global configuration properties to the supplied configuration. /// all configuration which is used to load mods for all games. /// </summary> /// <returns>The global configuration properties</returns> public static GameConfig SetGlobalConfigProperties(GameConfig gameConfig) { gameConfig.ExecutableLocation = "All Executables"; gameConfig.ModDirectory = Strings.Common.GlobalModFolder; gameConfig.ConfigLocation = LoaderPaths.GetGlobalGameConfigDirectory() + $"\\{Strings.Parsers.ConfigFile}"; gameConfig.GameName = Strings.Common.GlobalModName; gameConfig.GameVersion = "Reloaded"; gameConfig.GameDirectory = "Between Time and Space"; return(gameConfig); }
public static List <PluginConfig> GetAllConfigs() { // Retrieves the name of all directories in the 'Themes' folder. string[] directories = Directory.GetDirectories(LoaderPaths.GetPluginsDirectory()); List <PluginConfig> pluginConfigs = new List <PluginConfig>(directories.Length); foreach (var directory in directories) { pluginConfigs.Add(ParseConfig(directory)); } return(pluginConfigs); }
/// <summary> /// Retrieves the Mod Loader configuration file struct. /// </summary> /// <returns></returns> public Config ParseConfig() { // Instantiate a new configuration struct. Config config = new Config(); // Read the mod loader configuration. _iniData = _iniParser.ReadFile(LoaderPaths.GetModLoaderConfig()); // Parse the mod loader configuration. config.CurrentTheme = _iniData["Mod Loader Configuration"]["Current_Theme"]; config.DirectInputConfigType = (Remapper.DirectInputConfigType)Enum.Parse(typeof(Remapper.DirectInputConfigType), _iniData["Mod Loader Configuration"]["Controller_Config_Type"]); // Return the config file. return(config); }
/// <summary> /// Removes Zone Information from dynamic link libraries downloaded from the internet such /// that certain users of Microsoft Windows would not be denied loading of our own arbitrary code. /// </summary> /// <remarks> /// Only affects files downloaded via very specific certain outdated programs such as /// Internet Explorer /// </remarks> public static void UnblockDlls() { // Print Info Message about Unlocking DLLs LoaderConsole.PrintFormattedMessage("Removing Zone Identifiers from Files (DLL Unlocking)", LoaderConsole.PrintInfoMessage); // Search all DLLs under loader directories. // Normally I'd restrict this to mod directories, but the loader's own libraries might also be worth checking. string[] dllFiles = Directory.GetFiles(LoaderPaths.GetModLoaderDirectory(), "*.dll", SearchOption.AllDirectories); // Unblock new file. foreach (string dllFile in dllFiles) { FileUnblocker.Unblock(dllFile); } }
/// <summary> /// Retrieves all currently enabled global modifications, executed regardless of /// the individual mod configuration. /// </summary> /// <returns>A list of currently globally enabled mods.</returns> public static List <ModConfig> GetEnabledGlobalMods() { // Get global mod configuration. GameConfig globalModConfig = GameConfig.ParseConfig(LoaderPaths.GetGlobalGameConfigDirectory()); // Get all mods for the global configuration. List <ModConfig> modConfigurations = ConfigManager.GetAllModsForGame(globalModConfig); // Filter out the enabled mods. modConfigurations = modConfigurations.Where(x => // Get folder name containing the mod = Path.GetFileName(Path.GetDirectoryName(x.ModLocation)) // Check if it's contained in the enabled mods list globalModConfig.EnabledMods.Contains(Path.GetFileName(Path.GetDirectoryName(x.ModLocation)))).ToList(); return(modConfigurations); }
/// <summary> /// Retrieves the properties of the special "global" configuration, a master above /// all configuration which is used to load mods for all games. /// </summary> /// <returns>The global configuration properties</returns> public static GameConfig GetGlobalConfigProperties() { // Creates the global mod directory if it does not exist. // This is just to ensure safe usage of the global config. LoaderPaths.GetGlobalModDirectory(); return(new GameConfig() { ExecutableLocation = "All Executables", ModDirectory = Strings.Common.GlobalModFolder, ConfigLocation = LoaderPaths.GetGlobalGameConfigDirectory() + $"\\{Strings.Parsers.ConfigFile}", GameDirectory = "Between Time and Space", GameName = Strings.Common.GlobalModName, GameVersion = "Reloaded" }); }
/// <summary> /// Re-selects the currently selected game upon entering the Main Menu. /// </summary> /// <param name="gameConfiguration">The game configuration to try and re-select.</param> private void ReselectCurrentGame(GameConfigParser.GameConfig gameConfiguration) { // Find and select the last highlighted game. string currentGameName = gameConfiguration?.GameName; string currentRelativeModDirectory = LoaderPaths.GetModLoaderRelativePath(LoaderPaths.GetModLoaderModDirectory() + "\\" + gameConfiguration?.ModDirectory); foreach (DataGridViewRow row in box_GameList.Rows) { // Cells[0] = Game Name // Cells[1] = Mod Location if ((string)row.Cells[0].Value == currentGameName && (string)row.Cells[1].Value == currentRelativeModDirectory) { row.Selected = true; } } }
/// <summary> /// Deletes a game configuration from the known configurations. /// </summary> private void DeleteGame(object sender, EventArgs e) { // Get current selected game. GameComboBoxDetails comboBoxDetails = GetSelectedGame(); // If there is no game (null), return. if (comboBoxDetails == null) { return; } // Find and remove first by details. for (int x = 0; x < Global.GameConfigurations.Count; x++) { // Find the first match to game name, executable and version. if (Global.GameConfigurations[x].GameName == comboBoxDetails.GameName && Global.GameConfigurations[x].ExecutableLocation == comboBoxDetails.ExecutableRelativeLocation && Global.GameConfigurations[x].GameVersion == comboBoxDetails.GameVersion) { // Check if global config. if (Global.GameConfigurations[x].ConfigLocation == LoaderPaths.GetGlobalGameConfigDirectory()) { MessageBox.Show($"It's no use {Environment.UserName}, give up."); return; } // Maintain currently open banners. try { Global.BaseForm.ChildrenForms.MainMenu.item_GameBanner.BackgroundImage.Dispose(); } catch { } try { box_GameBanner.BackgroundImage.Dispose(); } catch { } // Remove game from list & Switch game. borderless_CurrentGame.Items.RemoveAt(x); try { borderless_CurrentGame.SelectedIndex = borderless_CurrentGame.Items.Count - 1; } catch { } // Garbage collect old possible image references. GC.Collect(); GC.WaitForPendingFinalizers(); // Remove game config & physical location. try { Directory.Delete(Global.GameConfigurations[x].ConfigLocation, true); } catch { } Global.GameConfigurations.RemoveAt(x); break; } } }
/// <summary> /// Generates a Reloaded Steam shim for the currently selected game. /// </summary> public static void GenerateShim() { // Get file names and paths. string shimExecutableName = Path.GetFileName(Global.CurrentGameConfig.ExecutableLocation); string shimOutputLocation = Path.GetTempPath() + "\\Reloaded-Temp-Steam-Shim"; // Check if exe name is correct. if (shimExecutableName == "") { MessageBox.Show("Failed to generate Steam Shim\n" + "Your executable name may be empty or profile not saved."); return; } // Generate instructions. string instructions = $"Using the pseudo-launcher as a game's basic launcher replacement (for some games that can only be launched via launcher):\r\n" + $"1. Rename the pseudo-launcher executable name \"{shimExecutableName}\" to the name of the game's default launcher (e.g. SteamLauncher.exe)\r\n" + $"2. Replace the game's launcher executable with the shim executable.\r\n" + $"3. Create (if you haven't already), individual game profiles for individual executables the default launcher would launch e.g. Shenmue.exe, Shenmue2.exe\r\n" + "Result: If done correctly, when launching the game, you will get a prompt asking\r\n" + "which game to launch via Reloaded if there is more than 1 game. Else the only game will be launched directly.\r\n\r\n" + $"-----------------------------------------------------------------------------------------\r\n\r\n" + $"Using the pseudo-launcher to trick Steam API:\r\n" + $"1. Rename {Global.CurrentGameConfig.ExecutableLocation} to a different name e.g. {Global.CurrentGameConfig.ExecutableLocation.Replace(".exe", "-Reloaded.exe")}\r\n" + $"2. Set the new executable path for the game to the changed path, e.g. {Global.CurrentGameConfig.ExecutableLocation.Replace(".exe", "-Reloaded.exe")} in Reloaded-Launcher.\r\n" + $"3. Copy Reloaded's Pseudo-launcher \"{shimExecutableName}\" to the place of the old executable {Global.CurrentGameConfig.ExecutableLocation}\r\n" + $"Result: You can now launch games directly through Steam and Reloaded mods still are applied.\r\n\r\n" + "With Steam games, note that after Steam updates, or verifying game files you may have to redo this process.\r\n" + "For more information refer to Reloaded's Github readme pages/wiki.\r\n" + "You should delete this folder when you are done."; // Output everything to disc. Directory.CreateDirectory(shimOutputLocation); File.WriteAllText($"{shimOutputLocation}\\Instructions.txt", instructions); RelativePaths.CopyByRelativePath($"{LoaderPaths.GetTemplatesDirectory()}\\Steam-Shim", shimOutputLocation, RelativePaths.FileCopyMethod.Copy, true); if (File.Exists($"{shimOutputLocation}\\{shimExecutableName}")) { File.Delete($"{shimOutputLocation}\\{shimExecutableName}"); } File.Move($"{shimOutputLocation}\\Reloaded-Steam-Shim.exe", $"{shimOutputLocation}\\{shimExecutableName}"); // Open directory in explorer. Process.Start($"{shimOutputLocation}"); }
/// <summary> /// Retrieves all of the game individual mod configurations for the currently selected game. /// </summary> public List <ModConfigParser.ModConfig> GetAllMods(GameConfigParser.GameConfig gameConfiguration) { // Retrieves the name of all directories in the 'Mods' folder for the game. string[] modDirectories = Directory.GetDirectories(LoaderPaths.GetModLoaderModDirectory() + "\\" + gameConfiguration.ModDirectory); // Retrieve the game configurations List <ModConfigParser.ModConfig> modConfigurations = new List <ModConfigParser.ModConfig>(modDirectories.Length); // Read each game configuration foreach (string directory in modDirectories) { try { modConfigurations.Add(ModConfigParser.ParseConfig(directory)); } catch (Exception ex) { MessageBox.Show("One of your mod configurations is missing or corrupt: " + ex.Message); } } // Return. return(modConfigurations); }
/// <summary> /// Retrieves all of the game individual game configurations, including the global /// game configuration containing global mods. /// </summary> public List <GameConfigParser.GameConfig> GetAllGameConfigs() { // Retrieves the name of all directories in the 'Games' folder. string[] directories = Directory.GetDirectories(LoaderPaths.GetModLoaderGamesDirectory()); // Retrieve the game configurations List <GameConfigParser.GameConfig> gameConfigurations = new List <GameConfigParser.GameConfig>(directories.Length); // Read each game configuration foreach (string directory in directories) { try { gameConfigurations.Add(GameConfigParser.ParseConfig(directory)); } catch (Exception ex) { MessageBox.Show("One of your game configurations is missing or corrupt: " + ex.Message); } } // Return. return(gameConfigurations); }
/// <summary> /// Retrieves the Mod Loader Colour Configuration File. /// </summary> /// <param name="themeDirectory">The relative directory of the individual theme to Reloaded-Config/Themes. e.g. Default</param> public static Theme ParseConfig(string themeDirectory) { // Specifies the location of the current theme property file. string themeLocation = LoaderPaths.GetModLoaderThemeDirectory() + "/" + themeDirectory + $"/{Strings.Parsers.ThemeFile}"; // Try parsing the config file, else return default one. Theme theme; try { theme = File.Exists(themeLocation) ? JsonConvert.DeserializeObject <Theme>(File.ReadAllText(themeLocation)) : Theme.GetDefaultThemeConfig(); } catch { theme = Theme.GetDefaultThemeConfig(); } theme.ThemePropertyLocation = themeLocation; return(theme); }
/// <summary> /// Retrieves all currently enabled mods for the current specified game configuration, /// including the global modifications not covered by <see cref="ConfigManager"/>. /// Note: This list is not topologically sorted and ignores the dependency order, consider passing the result to <see cref="TopologicallySortConfigurations"/> /// in order to obtain a list of mods where the dependencies of mods are loaded first. /// </summary> /// <param name="gameConfiguration">The game configuration to obtain the enabled mods for, including globals.</param> /// <returns>A list of all currently enabled mods for the game, including globals.</returns> public static List <ModConfig> GetAllEnabledMods(GameConfig gameConfiguration) { // Retrieve the game configurations List <ModConfig> modConfigurations = new List <ModConfig>(gameConfiguration.EnabledMods.Count); // Read each game configuration foreach (string directory in gameConfiguration.EnabledMods) { string configPath = Path.Combine(LoaderPaths.GetModLoaderModDirectory(), gameConfiguration.ModDirectory, directory); try { modConfigurations.Add(ModConfig.ParseConfig(configPath, gameConfiguration)); } catch (Exception ex) { MessageBox.Show("One of your mod configurations is missing or corrupt: " + ex.Message); } } // Append global mods and return. modConfigurations.AddRange(GetEnabledGlobalMods()); return(modConfigurations); }
/// <summary> /// Saves the current game configuration. /// </summary> private void SaveCurrentGame() { // Get current selected game. GameComboBoxDetails comboBoxDetails = GetSelectedGame(); // Find and remove first by details. foreach (GameConfig gameConfig in Global.GameConfigurations) { // Find the first match to game name, executable and version. if (gameConfig.GameName == comboBoxDetails.GameName && gameConfig.ExecutableLocation == comboBoxDetails.ExecutableRelativeLocation && gameConfig.GameVersion == comboBoxDetails.GameVersion) { // Check if global config. if (gameConfig.ConfigLocation == LoaderPaths.GetGlobalGameConfigDirectory()) { MessageBox.Show($"I'm sorry {Environment.UserName}, I'm afraid I can't let you do that."); return; } // Set the new game details. gameConfig.GameName = borderless_GameName.Text; gameConfig.GameVersion = borderless_GameVersion.Text; gameConfig.GameDirectory = borderless_GameDirectory.Text; gameConfig.ExecutableLocation = borderless_GameExecutableDirectory.Text; gameConfig.ModDirectory = borderless_GameModDirectory.Text; gameConfig.CommandLineArgs = borderless_CommandLineArguments.Text; // Change the current item name to reflect new changes. borderless_CurrentGame.Items[borderless_CurrentGame.SelectedIndex] = borderless_GameName.Text + " " + Theme.ThemeProperties.TitleProperties.LoaderTitleDelimiter + " " + borderless_GameExecutableDirectory.Text + " " + Theme.ThemeProperties.TitleProperties.LoaderTitleDelimiter + " " + borderless_GameVersion.Text; break; } } }
public TestRunnerOptions(TestRunnerOptions copyFrom) { if (copyFrom == null) { return; } IgnoreFocus = copyFrom.IgnoreFocus; FixturePaths.AddAll(copyFrom.FixturePaths); LoaderPaths.AddAll(copyFrom.LoaderPaths); LoadAssemblyFromPath = copyFrom.LoadAssemblyFromPath; RandomSeed = copyFrom.RandomSeed; _flags = copyFrom._flags; ContextLines = copyFrom.ContextLines; SelfTest = copyFrom.SelfTest; PackageReferences.AddAll(copyFrom.PackageReferences); PlanFilter.CopyFrom(copyFrom.PlanFilter); TestTimeout = copyFrom.TestTimeout; PlanTimeout = copyFrom.PlanTimeout; SlowTestThreshold = copyFrom.SlowTestThreshold; AssertionMessageFormatMode = copyFrom.AssertionMessageFormatMode; PreviousRun = copyFrom.PreviousRun; }
/// <summary> /// Copies the default Mod Loader configuration and theme files upon first launch. /// </summary> private void CopyDefaultFiles() { // Copy without replacement. // Source directory = App Directory string sourceDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Files"; string targetDirectory = LoaderPaths.GetModLoaderDirectory(); // Copy without replacement. // Source directory = App Directory string sourceDirectoryDefaultMods = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Default-Mods"; string targetDirectoryDefaultMods = LoaderPaths.GetGlobalModDirectory(); try { RelativePaths.CopyByRelativePath(sourceDirectory, targetDirectory, RelativePaths.FileCopyMethod.Copy, false); RelativePaths.CopyByRelativePath(sourceDirectoryDefaultMods, targetDirectoryDefaultMods, RelativePaths.FileCopyMethod.Copy, true); // Nuke remaining files. Directory.Delete(sourceDirectory, true); Directory.Delete(sourceDirectoryDefaultMods, true); } catch (Exception) { /* ¯\_(ツ)_/¯ */ } }
static void Main(string[] args) { SetDefault(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Copy Reloaded Default Theme if missing. string themeFolderPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\Theme"; if (IsDirectoryEmpty(LoaderPaths.GetModLoaderThemeDirectory())) { DirectoryCopy(themeFolderPath, LoaderPaths.GetModLoaderThemeDirectory(), true); } // Boot if (args.Length > 0) { Application.Run(new MainWindow(args[0])); } else { Application.Run(new MainWindow()); } }