Skip to content

Commit

Permalink
Create a typedef to simplify code.
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLake committed Jun 22, 2015
1 parent d196dc5 commit 9f59baf
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions GUI/MainInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace CKAN
{
using ModChanges = List<KeyValuePair<GUIMod, GUIModChangeType>>;
public partial class Main
{
private BackgroundWorker m_InstallWorker;
Expand All @@ -27,7 +28,7 @@ private void InstallMods(object sender, DoWorkEventArgs e) // this probably need
ClearLog();

var opts =
(KeyValuePair<List<KeyValuePair<GUIMod, GUIModChangeType>>, RelationshipResolverOptions>) e.Argument;
(KeyValuePair<ModChanges, RelationshipResolverOptions>) e.Argument;

ModuleInstaller installer = ModuleInstaller.GetInstance(CurrentInstance, GUI.user);
// setup progress callback
Expand Down Expand Up @@ -184,7 +185,7 @@ private void InstallMods(object sender, DoWorkEventArgs e) // this probably need
{
m_TabController.HideTab("WaitTabPage");
m_TabController.ShowTab("ManageModsTabPage");
e.Result = new KeyValuePair<bool, List<KeyValuePair<GUIMod, GUIModChangeType>>>(false, opts.Key);
e.Result = new KeyValuePair<bool, ModChanges>(false, opts.Key);
return;
}

Expand All @@ -203,7 +204,7 @@ private void InstallMods(object sender, DoWorkEventArgs e) // this probably need
};

//Set the result to false/failed in case we return
e.Result = new KeyValuePair<bool, List<KeyValuePair<GUIMod, GUIModChangeType>>>(false, opts.Key);
e.Result = new KeyValuePair<bool, ModChanges>(false, opts.Key);
SetDescription("Uninstalling selected mods");
if (!WasSuccessful(() => installer.UninstallList(toUninstall)))
return;
Expand All @@ -224,22 +225,20 @@ private void InstallMods(object sender, DoWorkEventArgs e) // this probably need
{
if (installCanceled)
{
e.Result = new KeyValuePair<bool, List<KeyValuePair<GUIMod, GUIModChangeType>>>(false,
opts.Key);
e.Result = new KeyValuePair<bool, ModChanges>(false,opts.Key);
return;
}
var ret = InstallList(toInstall, opts.Value, downloader);
if (!ret)
{
// install failed for some reason, error message is already displayed to the user
e.Result = new KeyValuePair<bool, List<KeyValuePair<GUIMod, GUIModChangeType>>>(false,
opts.Key);
e.Result = new KeyValuePair<bool, ModChanges>(false,opts.Key);
return;
}
resolvedAllProvidedMods = true;
}

e.Result = new KeyValuePair<bool, List<KeyValuePair<GUIMod, GUIModChangeType>>>(true, opts.Key);
e.Result = new KeyValuePair<bool, ModChanges>(true, opts.Key);
}

/// <summary>
Expand Down Expand Up @@ -355,7 +354,7 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e)
UpdateModsList();
m_TabController.SetTabLock(false);

var result = (KeyValuePair<bool, List<KeyValuePair<GUIMod, GUIModChangeType>>>) e.Result;
var result = (KeyValuePair<bool, ModChanges>) e.Result;

if (result.Key)
{
Expand Down

0 comments on commit 9f59baf

Please sign in to comment.