Skip to content

Commit

Permalink
Merge branch 'release/1.6.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Farmith committed Nov 19, 2021
2 parents 93d66a6 + c66dd78 commit 98f996c
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 32 deletions.
42 changes: 21 additions & 21 deletions MultiInstanceManager/AccountConfigurator.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions MultiInstanceManager/AccountConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;
using MultiInstanceManager.Helpers;
Expand Down Expand Up @@ -34,6 +35,7 @@ public AccountConfiguration()
hotKeyKey.KeyUp += hotKeyKey_KeyUp;

saveConfig.Click += SaveConfiguration;
browseForInstallationButton.Click += browseForInstallationButton_Click;
}
public void OnShown(object sender, EventArgs e)
{
Expand Down Expand Up @@ -343,5 +345,26 @@ private void selectedRegion_SelectedIndexChanged(object sender, EventArgs e)
{

}
private void browseForInstallationButton_Click(object sender, EventArgs e)
{
int size = -1;
System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
openFileDialog1.InitialDirectory = (string)Registry.GetValue(Constants.gameInstallRegKey[0], Constants.gameInstallRegKey[1], "");
openFileDialog1.Filter = "Executables (*.exe)|*.exe";
openFileDialog1.FilterIndex = 1;
openFileDialog1.RestoreDirectory = true;
DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string filepath = openFileDialog1.FileName;
string path = Path.GetDirectoryName(filepath);
string file = Path.GetFileNameWithoutExtension(filepath);

installationPath.Text = path;
gameExecutableName.Text = file;
}
Console.WriteLine(size); // <-- Shows file size in debugging mode.
Console.WriteLine(result); // <-- For debugging use.
}
}
}
62 changes: 62 additions & 0 deletions MultiInstanceManager/Helpers/CMDLineHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MultiInstanceManager.Helpers
{
public static class CMDLineHelper
{
public static Dictionary<String,List<String>> parseArguments(string[] input)
{
Log.Debug("Parsing arguments..");
Dictionary<String, List<String>> commands = new Dictionary<String, List<String>>();

string command = String.Empty;
List<String> parameters = new List<String>();
bool variablemode = false;
for(var i = 0; i < input.Length; i++)
{
if(variablemode && input[i].Substring(0, 2).CompareTo("--")!=0)
{
Log.Debug("Adding parameter: " + input[i]);
parameters.Add(input[i]);
}
if(input[i].Substring(0,2).CompareTo("--")==0)
{
Log.Debug("Adding command...");
// Check if we have a previous command to save away first:
if(variablemode && command != String.Empty)
{
Log.Debug("Adding Command: " + command);
commands.Add(command, parameters);
parameters = new List<String>(); // Reset the parameters for good measure.
command = String.Empty; // Reset the command for good measure.
variablemode = false; // Doesn't really do anything, but it's for good measure.
}
// This is a "command" of sorts, new entry:
command = input[i].Substring(2, input[i].Length-2);
variablemode = true;
}
}
// Lastly, save the last command:
if (variablemode && command != String.Empty)
{
Log.Debug("Adding Command: " + command);
commands.Add(command, parameters);
parameters = new List<String>(); // Reset the parameters for good measure.
command = String.Empty; // Reset the command for good measure.
variablemode = false; // Doesn't really do anything, but it's for good measure.
}
return commands;
}
public static Dictionary<String, List<String>> GetArguments()
{
Log.Debug("Loading command-line arguments");
var CommandLineArguments = parseArguments(Environment.GetCommandLineArgs());
return CommandLineArguments;

}
}
}
80 changes: 77 additions & 3 deletions MultiInstanceManager/MultiInstanceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
using MultiInstanceManager.Helpers;
using MultiInstanceManager.Modules;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Deployment.Application;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Linq;
using static Dfust.Hotkeys.Enums;
using System.Threading;

namespace MultiInstanceManager
{
Expand All @@ -21,6 +24,10 @@ public partial class MultiInstanceManager : Form
public MultiInstanceManager()
{
InitializeComponent();

// Fetch the commandline arguments first and foremost:
var CommandLineArguments = CMDLineHelper.GetArguments();

addAccountButton.Click += new EventHandler(addAccountButton_Click);
launchButton.Click += new EventHandler(launchButton_Click);
removeButton.Click += new EventHandler(removeButton_Click);
Expand All @@ -32,7 +39,10 @@ public MultiInstanceManager()
saveAccounInfo.Checked = ConfigurationManager.AppSettings.Get("saveCredentials")?.ToString() == "true" ? true : false;
saveAccounInfo.CheckedChanged += new EventHandler(saveAccounInfo_Changed);
// Reset log once per start of application
Log.Empty();
if(!CommandLineArguments.TryGetValue("keeplogs",out List<String> parm))
{
Log.Empty();
}
/*
* Clean any pre-1.6.2 version profiles to use a new name
*/
Expand Down Expand Up @@ -92,8 +102,71 @@ public MultiInstanceManager()
MH.SwapFocus(a);
});
}
}
// Auto-launch features:
bool launchWhenAllRefreshed = false;
if (CommandLineArguments.TryGetValue("relaunch", out List<String> laf))
{
Log.Debug("Auto-starting all profiles we refresh, after last refresh");
launchWhenAllRefreshed = true;
}
if (CommandLineArguments.TryGetValue("autorefresh", out List<String> profs))
{
Log.Debug("Refreshing: " + profs.Count + " profiles on start due to cmd-line request");
RefreshProfiles(profs,launchWhenAllRefreshed);
}
if (CommandLineArguments.TryGetValue("autostart", out List<String> autostarts) && !launchWhenAllRefreshed)
{
Log.Debug("Auto-starting: " + autostarts.Count + " profiles on start due to cmd-line request");
LaunchProfiles(autostarts);
}

}
public async Task LaunchProfiles(List<String> profiles)
{
foreach (var profile in profiles)
{
try
{
DisableButtons();
Log.Debug("Launching profile: " + profile);
var task = Task.Factory.StartNew(() => MH.LaunchWithAccount(profile.Trim(' ')));
var result = await task;
EnableButtons();
}
catch (Exception e)
{
Log.Debug("Could not start profile: " + profile + " error: ");
Log.Debug(e.ToString());
}
}
Log.Debug("All profiles should be launched");
}
public async Task RefreshProfiles(List<String> profiles,bool launchWhenAllRefreshed)
{
foreach (var profile in profiles)
{
try
{
DisableButtons();
var task = Task.Factory.StartNew(() => MH.Setup(profile.Trim(' '), true));
var result = await task;
EnableButtons();
}
catch (Exception e)
{
Log.Debug("Could not refresh: " + profile + " error: ");
Log.Debug(e.ToString());
}
}
if(launchWhenAllRefreshed)
{
Log.Debug("Restarting all previous profiles due to commandline request");
Log.Debug("Waiting a moment for refreshed client to completely die");
Thread.Sleep(2000);
var task = Task.Factory.StartNew(() => LaunchProfiles(profiles));
var result = await task;
}
}
public static void AddOrUpdateAppSettings(string key, string value)
{
try
Expand Down Expand Up @@ -175,7 +248,6 @@ private async void launchButton_Click(object sender, EventArgs e)
}
private void removeButton_Click(object sender, System.EventArgs e)
{
// TODO: This feature should also try to clear the Windows Credential Store of credentials.
if (accountList.CheckedItems.Count > 0)
{
for (var x = 0; x < accountList.CheckedItems.Count; x++)
Expand All @@ -191,6 +263,8 @@ private void removeButton_Click(object sender, System.EventArgs e)
}
catch (Exception ex)
{
Log.Debug("Something went wrong while removing profiles:");
Log.Debug(ex.ToString());
Debug.WriteLine(ex);
// Something went terribly wrong..
}
Expand Down
5 changes: 3 additions & 2 deletions MultiInstanceManager/MultiInstanceManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
<DependentUpon>AccountConfigurator.cs</DependentUpon>
</Compile>
<Compile Include="Helpers\AutomationHelper.cs" />
<Compile Include="Helpers\CMDLineHelper.cs" />
<Compile Include="Helpers\CredentialHelper.cs" />
<Compile Include="Helpers\FileHelper.cs" />
<Compile Include="Helpers\Log.cs" />
Expand Down Expand Up @@ -223,15 +224,15 @@
<Output TaskParameter="Assemblies" ItemName="Targets" />
</GetAssemblyIdentity>
<ItemGroup>
<VersionNumber Include="$([System.Text.RegularExpressions.Regex]::Replace(&quot;%(Targets.Version)&quot;, &quot;^([^\.]+)\.([^\.]+).([^\.]+)(.*)$&quot;, &quot;$1.$2.$3&quot;))" />
<VersionNumber Include="$([System.Text.RegularExpressions.Regex]::Replace(&quot;%(Targets.Version)&quot;, &quot;^([^\.]+)\.([^\.]+).([^\.]+)(.*)$&quot;, &quot;$1.$2.$3&quot;))" />
<!-- <VersionNumber Include="@(Targets->'%(Version)')"/> -->
</ItemGroup>
</Target>
<PropertyGroup>
<PostBuildEventDependsOn>
$(PostBuildEventDependsOn);
PostBuildMacros;
</PostBuildEventDependsOn>
</PostBuildEventDependsOn>
<PostBuildEvent>copy /Y "$(SolutionDir)\\README.*" "$(TargetDir)"
if exist D2RMIM-Release-@(VersionNumber).zip ( Del D2RMIM-Release-@(VersionNumber).zip )
powershell.exe -command Compress-Archive -Path *.dll,README.*,MultiInstanceManager.exe,MultiInstanceManager.exe.config -DestinationPath D2RMIM-Release-@(VersionNumber).zip</PostBuildEvent>
Expand Down
4 changes: 2 additions & 2 deletions MultiInstanceManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.3.3")]
[assembly: AssemblyFileVersion("1.6.3.3")]
[assembly: AssemblyVersion("1.6.4.0")]
[assembly: AssemblyFileVersion("1.6.4.0")]
[assembly: NeutralResourcesLanguage("en")]
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ FAQ:
- * Fixed bug with Y coordinate not saving properly (used X instead due to an oversight)
- * Cleaned up reusable into function.

* 1.6.4 **Minor release**
- New features:
- * Browse for game executable button now activated
- * Command-line arguments now implemented, usage:
- * Auto-refresh profile(s): MultiInstanceManager.exe --autorefresh <profile> <profile2> <profileN>
- * Auto-restart after refresh: MultiInstanceManager.exe --autorefresh <profile1> --relaunch
- * Disable clearing of logs: MultiInstanceManager.exe --keeplogs
- * Everything: MultiInstanceManager.exe --autorefresh <profile1> --relaunch --keeplogs

* 1.6.3 **Bugfix Release**

- Bugfixes:
- * Fixed bug with special characters in passwords
- * Fixed bug with Y coordinate not saving properly (used X instead due to an oversight)
- * Cleaned up reusable into function.

* 1.6.2 **Minor release 1.6.2***

- Bugfixes:
Expand Down Expand Up @@ -193,7 +209,3 @@ The closing of bnet + client is to allow multiple accounts to be setup easily wi

Note: There is a "Dump RegKey" button still on the gui in this release, this is mostly for debug-purposes tho so don't worry about it, all it does is dump the web-keys for D2R into "dump.bin", nothing more nothing less.

## TODO:

* Add more configuration options
* Find a faster way to "refresh" accounts

0 comments on commit 98f996c

Please sign in to comment.