Skip to content

Commit

Permalink
Merge pull request #1 from pjf/im_in_ur_pr83_changin_ur_files
Browse files Browse the repository at this point in the history
Fixups for PR #83
  • Loading branch information
AlexanderDzhoganov committed Oct 18, 2014
2 parents 8e4666d + b72b5dc commit 0c31303
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CKAN/*/bin
CKAN/*/obj
test-results
*.userprefs
*.csproj.user
TestResult.xml
StyleCop.Cache
ckan.exe
Expand Down
6 changes: 3 additions & 3 deletions CKAN/CKAN/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,12 @@ void InstallComponent (dynamic stanza, ZipFile zipfile, Dictionary<string, Insta
else if (stanza.install_to == "Tutorial")
{
installDir = Path.Combine(Path.Combine(KSP.GameDir(), "saves"), "training");
makeDirs = false;
makeDirs = true;
}
else if (stanza.install_to == "GameRoot")
{
installDir = KSP.GameDir();
makeDirs = true;
makeDirs = false;
} else {
// What is the best exception to use here??
throw new Exception("Unknown install location: " + stanza.install_to);
Expand Down Expand Up @@ -514,4 +514,4 @@ public ModuleNotFoundException (string mod, string ver = null) {
version = ver;
}
}
}
}
5 changes: 2 additions & 3 deletions CKAN/CKAN/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ public CkanModule LatestAvailable(string module, KSPVersion ksp_version = null)
return available_modules[module].Latest(ksp_version);
}
catch (KeyNotFoundException) {
return null;
// throw new ModuleNotFoundException(module);
throw new ModuleNotFoundException(module);
}
}

Expand Down Expand Up @@ -252,4 +251,4 @@ public bool IsInstalled(string modName) {
return true;
}
}
}
}
16 changes: 16 additions & 0 deletions CKAN/CKAN/RelationshipResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public struct RelationshipResolverOptions {
public bool with_all_suggests;
}

// Alas, it appears that structs cannot have defaults. Try
// DefaultOpts() to get friendly defaults.

public class RelationshipResolver {

// A list of all the mods we're going to install.
Expand Down Expand Up @@ -49,6 +52,19 @@ public RelationshipResolver (List<string> modules, RelationshipResolverOptions o

}

/// <summary>
/// Returns the default options for relationship resolution.
/// </summary>
public static RelationshipResolverOptions DefaultOpts()
{
var opts = new RelationshipResolverOptions ();
opts.with_recommends = true;
opts.with_suggests = false;
opts.with_all_suggests = false;

return opts;
}

// Resolve all relationships for a module.
// May recurse to ResolveStanza.
private void Resolve(CkanModule module, RelationshipResolverOptions options) {
Expand Down
4 changes: 2 additions & 2 deletions CKAN/CKAN/Types/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ struct Comparison {
public string remainder1;
public string remainder2;
}

public Version (string version_string) {
orig_string = version_string;
orig_string = version_string;

// TODO: Can we get rid of $1 here? Does C# support (?:syntax)?
Match match = Regex.Match (version_string, "^(([0-9]+):)?(.*)$");
Expand Down
6 changes: 0 additions & 6 deletions CKAN/CmdLine/CmdLine.csproj.user

This file was deleted.

2 changes: 1 addition & 1 deletion CKAN/CmdLine/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static int Upgrade(UpgradeOptions options)
if (options.modules.Count == 0)
{
// What? No files specified?
User.WriteLine("Usage: ckan install [--with-suggests] [--with-all-suggests] [--no-recommends] Mod [Mod2, ...]");
User.WriteLine("Usage: ckan upgrade [--with-suggests] [--with-all-suggests] [--no-recommends] Mod [Mod2, ...]");
return EXIT_BADOPT;
}

Expand Down
5 changes: 1 addition & 4 deletions CKAN/GUI/ApplyChangesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ private void CancelButton_Click(object sender, EventArgs e)

private void ConfirmButton_Click(object sender, EventArgs e)
{
var install_ops = new RelationshipResolverOptions();
install_ops.with_all_suggests = false;
install_ops.with_suggests = false;
install_ops.with_recommends = false;
RelationshipResolverOptions install_ops = RelationshipResolver.DefaultOpts();

m_InstallWorker.RunWorkerAsync(new KeyValuePair<List<KeyValuePair<CkanModule, GUIModChangeType>>, RelationshipResolverOptions>(m_Changeset, install_ops));
m_InstallWorker = null;
Expand Down
7 changes: 0 additions & 7 deletions CKAN/GUI/CKAN-GUI.csproj.user

This file was deleted.

5 changes: 1 addition & 4 deletions CKAN/GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ private List<KeyValuePair<CkanModule, GUIModChangeType>> ComputeChangeSetFromMod
}
}

RelationshipResolverOptions options = new RelationshipResolverOptions();
options.with_all_suggests = false;
options.with_recommends = false;
options.with_suggests = false;
RelationshipResolverOptions options = RelationshipResolver.DefaultOpts();

RelationshipResolver resolver = null;
try
Expand Down
2 changes: 1 addition & 1 deletion Spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ mandatory directives:
Valid values for this entry are `GameData`, `Ships`, `Tutorial`,
and `GameRoot` (which should be used sparingly, if at all).
Paths will be preserved, but directories will *only*
be created when installing to `GameData`.
be created when installing to `GameData` or `Tutorial`.

An install directive may also include the following optional fields:

Expand Down

0 comments on commit 0c31303

Please sign in to comment.