-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install from .ckan file option for ConsoleUI
- Loading branch information
Showing
10 changed files
with
123 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.IO; | ||
|
||
using CKAN.ConsoleUI.Toolkit; | ||
using System.Linq; | ||
|
||
namespace CKAN.ConsoleUI { | ||
|
||
/// <summary> | ||
/// A popup to let the user import manually downloaded zip files into the mod cache. | ||
/// </summary> | ||
public static class InstallFromCkanDialog { | ||
|
||
/// <summary> | ||
/// Let the user choose some zip files, then import them to the mod cache. | ||
/// </summary> | ||
/// <param name="theme">The visual theme to use to draw the dialog</param> | ||
/// <param name="gameInst">Game instance to import into</param> | ||
public static CkanModule[] ChooseCkanFiles(ConsoleTheme theme, | ||
GameInstance gameInst) | ||
{ | ||
var cfmsd = new ConsoleFileMultiSelectDialog( | ||
Properties.Resources.CkanFileSelectTitle, | ||
FindDownloadsPath(gameInst), | ||
"*.ckan", | ||
Properties.Resources.CkanFileSelectHeader, | ||
Properties.Resources.CkanFileSelectHeader); | ||
return cfmsd.Run(theme) | ||
.Select(f => CkanModule.FromFile(f.FullName)) | ||
.ToArray(); | ||
} | ||
|
||
private static readonly string[] downloadPaths = new string[] { | ||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads"), | ||
Environment.GetFolderPath(Environment.SpecialFolder.Desktop) | ||
}; | ||
|
||
private static string FindDownloadsPath(GameInstance gameInst) | ||
{ | ||
foreach (string p in downloadPaths) { | ||
if (!string.IsNullOrEmpty(p) && Directory.Exists(p)) { | ||
return p; | ||
} | ||
} | ||
return gameInst.GameDir(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters