Example #1
0
        /// <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}");
        }
Example #2
0
        /// <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)
            { /* ¯\_(ツ)_/¯ */ }
        }
        /// <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) + $"\\{Strings.Launcher.CopyOnLaunchFolders.DefaultConfigFolder}";
            string targetDirectory = LoaderPaths.GetModLoaderDirectory();

            // Copy without replacement.
            // Source directory = App Directory
            string sourceDirectoryDefaultPlugins = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + $"\\{Strings.Launcher.CopyOnLaunchFolders.DefaultPluginsFolder}";
            string targetDirectoryDefaultPlugins = LoaderPaths.GetPluginsDirectory();

            string sourceDirectoryDefaultMods = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + $"\\{Strings.Launcher.CopyOnLaunchFolders.DefaultModsFolder}";
            string targetDirectoryDefaultMods = LoaderPaths.GetGlobalModDirectory();

            string sourceDirectoryDefaultTemplates = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + $"\\{Strings.Launcher.CopyOnLaunchFolders.DefaultTemplatesFolder}";
            string targetDirectoryDefaultTemplates = LoaderPaths.GetTemplatesDirectory();

            // Files
            try
            {
                RelativePaths.CopyByRelativePath(sourceDirectory, targetDirectory, RelativePaths.FileCopyMethod.Copy, false, true);
                Directory.Delete(sourceDirectory, true);
            }
            catch (Exception)
            { /* ¯\_(ツ)_/¯ */ }

            // Mods
            try
            {
                RelativePaths.CopyByRelativePath(sourceDirectoryDefaultMods, targetDirectoryDefaultMods, RelativePaths.FileCopyMethod.Copy, true, true);

                // We want to avoid deleting symbols.
                #if DEBUG
                // Do nothing.
                #else
                // Delete default mods directory.
                Directory.Delete(sourceDirectoryDefaultMods, true);
                #endif
            }
            catch (Exception)
            { /* ¯\_(ツ)_/¯ */ }

            // Plugins
            try
            {
                RelativePaths.CopyByRelativePath(sourceDirectoryDefaultPlugins, targetDirectoryDefaultPlugins, RelativePaths.FileCopyMethod.Copy, true, true);

                #if DEBUG
                // Do nothing.
                #else
                // Delete default plugins directory.
                Directory.Delete(sourceDirectoryDefaultPlugins, true);
                #endif
            }
            catch (Exception)
            { /* ¯\_(ツ)_/¯ */ }

            // Templates
            try
            {
                RelativePaths.CopyByRelativePath(sourceDirectoryDefaultTemplates, targetDirectoryDefaultTemplates, RelativePaths.FileCopyMethod.Copy, true, true);

                #if DEBUG
                // Do nothing.
                #else
                // Delete default plugins directory.
                Directory.Delete(sourceDirectoryDefaultPlugins, true);
                #endif
            }
            catch (Exception)
            { /* ¯\_(ツ)_/¯ */ }
        }