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

I have made it that each Instance has its own login info #65

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MultiMC/GTKGUI/GTKGUIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,9 @@ public ITextInputDialog TextInputDialog(string message, string text = "")
{
return new TextInputDialog(message,text,mainWindow);
}
public IImportLoginInfoDialog ImportLoginInfoDialog()
{
throw new NotImplementedException();
}
}
}
10 changes: 10 additions & 0 deletions MultiMC/GTKGUI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ void OnCheckUpdatesClicked(object sender, EventArgs e)
CheckUpdatesClicked(this, EventArgs.Empty);
}

void OnImportInstLoginInfoClicked(object sender, EventArgs e)
{
if (ImportInstLoginInfoClicked != null)
ImportInstLoginInfoClicked(this, EventArgs.Empty);
}

void OnHelpClicked(object sender, EventArgs e)
{
Expand Down Expand Up @@ -325,6 +330,7 @@ void OnViewInstFolderClicked(object sender, EventArgs e)
ViewInstFolderClicked(this, new InstActionEventArgs(SelectedInst));
}


void OnDeleteClicked(object sender, EventArgs e)
{
if (DeleteInstClicked != null)
Expand Down Expand Up @@ -422,6 +428,8 @@ public IList<Instance> InstanceList

public event EventHandler CheckUpdatesClicked;

public event EventHandler ImportInstLoginInfoClicked;

public event EventHandler HelpClicked;

public event EventHandler AboutClicked;
Expand All @@ -438,6 +446,8 @@ public IList<Instance> InstanceList

public event EventHandler<InstActionEventArgs> ViewInstFolderClicked;



public event EventHandler<InstActionEventArgs> DeleteInstClicked;

public event EventHandler<InstActionEventArgs> RemoveOpenALClicked;
Expand Down
2 changes: 2 additions & 0 deletions MultiMC/GUI/IGUIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public interface IGUIManager

IEditModsDialog EditModsDialog(Instance inst);

IImportLoginInfoDialog ImportLoginInfoDialog();

ILoginDialog LoginDialog(string errMsg = null);

IDialog DeleteDialog();
Expand Down
12 changes: 12 additions & 0 deletions MultiMC/GUI/IImportLoginInfoDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MultiMC.GUI
{
public interface IImportLoginInfoDialog : IDialog
{

}
}
5 changes: 3 additions & 2 deletions MultiMC/GUI/IMainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public interface IMainWindow : IWindow

event EventHandler HelpClicked;
event EventHandler AboutClicked;



event EventHandler ImportInstLoginInfoClicked;

event EventHandler<InstActionEventArgs> InstanceLaunched;

event EventHandler<InstActionEventArgs> ChangeIconClicked;
Expand Down
27 changes: 27 additions & 0 deletions MultiMC/Instance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ public static Instance[] LoadInstances(string instDir)
}
return (Instance[])instList.ToArray(typeof(Instance));
}
public static String[] LoadInstancesNames(string instDir)
{
if (!Directory.Exists(instDir))
{
return new String[0];
}

ArrayList instList = new ArrayList();
foreach (string dir in Directory.GetDirectories(instDir))
{
Console.WriteLine("Loading instance from " + dir + "...");
Instance inst = null;
try
{
inst = LoadInstance(dir);
}
catch (InvalidInstanceException e)
{
Console.WriteLine(e.Message);
}

if (inst != null)
instList.Add(inst.Name);
}
return (string[])instList.ToArray(typeof(string));
}

/// <summary>
/// Loads the instance from the specified directory.
Expand Down Expand Up @@ -376,6 +402,7 @@ public string RootDir
}
}


/// <summary>
/// The directory where mods will be stored
/// </summary>
Expand Down
48 changes: 36 additions & 12 deletions MultiMC/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Main()

MainWindow.SettingsClicked += SettingsClicked;
MainWindow.CheckUpdatesClicked += UpdateClicked;

MainWindow.ImportInstLoginInfoClicked += ImportInstLoginInfoClicked;
MainWindow.AboutClicked += AboutClicked;

// Instance context menu
Expand All @@ -79,7 +79,7 @@ public Main()
MainWindow.EditModsClicked += EditModsClicked;
MainWindow.RebuildJarClicked += RebuildClicked;
MainWindow.ViewInstFolderClicked += ViewInstFolderClicked;

MainWindow.DeleteInstClicked += DeleteInstClicked;
// on linux, provide the possiblity to nuke OpenAL libs
if(OSUtils.OS == OSEnum.Linux)
Expand Down Expand Up @@ -348,8 +348,8 @@ void ViewFolderClicked(object sender, EventArgs e)
{
string instDir = Path.GetFullPath(AppSettings.Main.InstanceDir);

if (!Directory.Exists(instDir))
Directory.CreateDirectory(instDir);
if (!Directory.Exists(instDir))
Directory.CreateDirectory(instDir);
Process.Start(instDir);
}

Expand Down Expand Up @@ -378,7 +378,26 @@ void SettingsClicked(object sender, EventArgs e)
{
DownloadNewVersion();
}

}

void ImportInstLoginInfoClicked(object sender, EventArgs e)
{
IImportLoginInfoDialog importLoginInfoDlg = GUIManager.Main.ImportLoginInfoDialog();
importLoginInfoDlg.ShowInTaskbar = false;

importLoginInfoDlg.Response += (o, args) =>
{
if (args.Response == DialogResponse.OK)
importLoginInfoDlg.Close();
if (args.Response == DialogResponse.Cancel)
importLoginInfoDlg.Close();
};

importLoginInfoDlg.Parent = MainWindow;
importLoginInfoDlg.DefaultPosition = DefWindowPosition.CenterParent;
importLoginInfoDlg.Run();
}
#endregion

#region Instance Menu
Expand Down Expand Up @@ -512,7 +531,10 @@ void ViewInstFolderClicked(object sender, InstActionEventArgs e)
Process.Start(SelectedInst.RootDir);
}

void DeleteInstClicked(object sender, InstActionEventArgs e)



void DeleteInstClicked(object sender, InstActionEventArgs e)
{
IDialog deleteDialog = GUIManager.Main.DeleteDialog();
deleteDialog.ShowInTaskbar = false;
Expand Down Expand Up @@ -1093,12 +1115,12 @@ private void ReadUserInfo(out string username, out string password)
{
try
{
if (!File.Exists(Properties.Resources.LastLoginFileName))
{
username = password = "";
return;
}

if (!File.Exists(Path.Combine(SelectedInst.RootDir, Properties.Resources.LastLoginFileName)))
{
username = password = "";
return;
}
using (SHA384 sha = SHA384.Create())
{
byte[] hash = sha.ComputeHash(
Expand All @@ -1117,7 +1139,7 @@ private void ReadUserInfo(out string username, out string password)

ICryptoTransform decryptor = rijAlg.CreateDecryptor(key, IV);

using (FileStream fsDecrypt = File.OpenRead(Properties.Resources.LastLoginFileName))
using (FileStream fsDecrypt = File.OpenRead(Path.Combine(SelectedInst.RootDir, Properties.Resources.LastLoginFileName)))
{
CryptoStream csDecrypt =
new CryptoStream(fsDecrypt, decryptor, CryptoStreamMode.Read);
Expand Down Expand Up @@ -1173,7 +1195,9 @@ private void WriteUserInfo(string username, string password)

try
{
using (FileStream fsEncrypt = File.Open(Properties.Resources.LastLoginFileName,


using (FileStream fsEncrypt = File.Open(Path.Combine(SelectedInst.RootDir, Properties.Resources.LastLoginFileName),
FileMode.Create))
{
using (CryptoStream csEncrypt =
Expand Down
18 changes: 15 additions & 3 deletions MultiMC/MultiMC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<RootNamespace>MultiMC</RootNamespace>
<AssemblyName>MultiMC</AssemblyName>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -23,7 +24,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down Expand Up @@ -147,6 +147,7 @@
<Compile Include="GUI\IGUIManager.cs" />
<Compile Include="GUI\IImageList.cs" />
<Compile Include="GUI\ILoginDialog.cs" />
<Compile Include="GUI\IImportLoginInfoDialog.cs" />
<Compile Include="GUI\INotesDialog.cs" />
<Compile Include="GUI\IRestoreBackupDialog.cs" />
<Compile Include="GUI\ISaveManagerDialog.cs" />
Expand Down Expand Up @@ -179,6 +180,7 @@
<Compile Include="ConfigFile.cs" />
<Compile Include="Tasks\Downloader.cs" />
<Compile Include="Tasks\DirCopyTask.cs" />
<Compile Include="Tasks\LoginCopyTask.cs" />
<Compile Include="Tasks\Modder.cs" />
<Compile Include="Tasks\RestoreTask.cs" />
<Compile Include="Tasks\SimpleTask.cs" />
Expand Down Expand Up @@ -208,6 +210,12 @@
<Compile Include="WinGUI\ConsoleForm.Designer.cs">
<DependentUpon>ConsoleForm.cs</DependentUpon>
</Compile>
<Compile Include="WinGUI\ImportLoginInfoForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="WinGUI\ImportLoginInfoForm.Designer.cs">
<DependentUpon>ImportLoginInfoForm.cs</DependentUpon>
</Compile>
<Compile Include="WinGUI\TextInputDialog.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -320,6 +328,9 @@
<EmbeddedResource Include="WinGUI\ConsoleForm.resx">
<DependentUpon>ConsoleForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="WinGUI\ImportLoginInfoForm.resx">
<DependentUpon>ImportLoginInfoForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="WinGUI\TextInputDialog.resx">
<DependentUpon>TextInputDialog.cs</DependentUpon>
</EmbeddedResource>
Expand Down Expand Up @@ -443,6 +454,7 @@
<Content Include="WinGUI\ToolbarIcons\AboutIcon.png" />
<Content Include="WinGUI\ToolbarIcons\CheckUpdateIcon.png" />
<Content Include="WinGUI\ToolbarIcons\HelpIcon.png" />
<None Include="WinGUI\ToolbarIcons\importexporticon.png" />
<Content Include="WinGUI\ToolbarIcons\NewInstIcon.png" />
<Content Include="WinGUI\ToolbarIcons\RefreshInstIcon.png" />
<Content Include="WinGUI\ToolbarIcons\RenameIcon.png" />
Expand All @@ -452,10 +464,10 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>"C:\Program Files\Java\jdk1.6.0_27\bin\javac" -d $(ProjectDir)Launcher $(ProjectDir)Launcher\MultiMCLauncher.java</PreBuildEvent>
<PreBuildEvent>"C:\Program Files\Java\jdk1.6.0_24\bin\javac" -d $(ProjectDir)Launcher $(ProjectDir)Launcher\MultiMCLauncher.java</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>copy $(TargetPath) C:\Users\Andrew\Dropbox\Public\MultiMC.exe</PostBuildEvent>
<PostBuildEvent>copy $(TargetPath) C:\visualstudio10\MultiMC.exe</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
9 changes: 8 additions & 1 deletion MultiMC/Properties/Resources.Designer.cs

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

3 changes: 3 additions & 0 deletions MultiMC/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,7 @@
<data name="enderman" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\enderman.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="importexporticon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\WinGUI\ToolbarIcons\importexporticon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Loading