Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full launcher and installer #200

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

masesk
Copy link
Contributor

@masesk masesk commented Nov 15, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

  • All new classes have class-level documentation comments, if there are any at all
  • Tests for the changes have been added (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation update
  • Other... Please describe:

What is the current behaviour?

Adding an installer and a launcher to the mod. Installer contains all the necessary dlls and auto-detects where Mount and Blade is installed. Creates a shortcut if needed.

Launcher runs mount and blade with /server or /client (with the necessary submodules) depending on the selection from UI.
There is potential to add more launch options to this.

What is the new behaviour?

Other information

source/BannerlordCoopInstaller/Installer.cs Outdated Show resolved Hide resolved
string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
{
foreach (string subkey_name in key.GetSubKeyNames())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit unnecessary. Can we use LINQ to find the subkey we're looking for? Do we only expect a few subkeys in each key? Probably fine since it's just during install...

source/BannerlordCoopInstaller/Installer.cs Outdated Show resolved Hide resolved
source/BannerlordCoopInstaller/Installer.cs Outdated Show resolved Hide resolved
private void PathBrowse_Click(object sender, EventArgs e)
{
FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the cancel button work? Is that inherit functionality from forms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality of the dialog box is inherited from the second parameter: MessageBoxButtons.YesNo in the declaration.

/// Check if MB is installed (through the registry) - Only works in x64.
/// </summary>
/// <returns>Full path where MB is installed</returns>
private string GetBannerLordInstalledPath()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is copy pasta, lets pull this out into some status util for both classes to use. If for some reason this changes in future releases, we don't want to have to change it twice

}
return null;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also some white space to clean

process.StartInfo.FileName = "\"" + mbPath + @"\bin\Win64_Shipping_Client\Bannerlord.exe" + "\"";
process.StartInfo.Arguments = "/singleplayer /server _MODULES_*Native*SandBoxCore*CustomBattle*SandBox*StoryMode*Coop*_MODULES_";
process.Start();
process.Close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we close it? I assume this works I just don't know what it does haha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spawns a process to run MB, once it's done, the process is dead, it just needs to be closed so the resources can be freed up.

source/Launcher/Launcher.cs Outdated Show resolved Hide resolved
source/Launcher/Launcher.cs Show resolved Hide resolved
Copy link

@MetehanAydemir MetehanAydemir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants