Skip to content

Commit

Permalink
Merge pull request #158 from MacTee/dev
Browse files Browse the repository at this point in the history
Dev merge - Version 2.3.0.7
- Fixes for issues #151 & #153
  • Loading branch information
MacTee authored Jul 31, 2017
2 parents c4554e2 + 21b4095 commit a6a587b
Show file tree
Hide file tree
Showing 91 changed files with 4,544 additions and 104 deletions.
10 changes: 8 additions & 2 deletions KSPModAdmin.Core/Controller/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,10 @@ protected static void LoadPlugins()
/// </summary>
protected static void AsyncTaskDone(object sender)
{
View.cbKSPPath.Enabled = true;
View.InvokeIfRequired(() =>
{
View.cbKSPPath.Enabled = true;
});
}

/// <summary>
Expand All @@ -663,7 +666,10 @@ protected static void AsyncTaskDone(object sender)
/// </summary>
protected static void AsyncTaskStarted(object sender)
{
View.cbKSPPath.Enabled = false;
View.InvokeIfRequired(() =>
{
View.cbKSPPath.Enabled = false;
});
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions KSPModAdmin.Core/Controller/ModSelectionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,10 +1499,10 @@ public static void OpenExportImportDialog()
public static void CreateZip(List<ModNode> nodes)
{
// get path for the zip
if (!Directory.Exists(OptionsController.DownloadPath))
if (!OptionsController.HasValidDownloadPath)
OptionsController.SelectNewDownloadPath();

if (!Directory.Exists(OptionsController.DownloadPath))
if (!OptionsController.HasValidDownloadPath)
{
Messenger.AddInfo(Messages.MSG_ERROR_NO_DOWNLOAD_FOLDER_SELECTED);
Messenger.AddInfo(Messages.MSG_ZIP_CREATION_ABORTED);
Expand Down
17 changes: 13 additions & 4 deletions KSPModAdmin.Core/Controller/OptionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ public static int SearchDepth
set { if (View != null) View.SearchDepth = value; }
}

public static bool HasValidDownloadPath
{
get
{
return !string.IsNullOrEmpty(DownloadPath) && Directory.Exists(DownloadPath);
}
}

#endregion

#region Misc
Expand Down Expand Up @@ -504,6 +512,7 @@ public static string SelectedLanguage
/// </summary>
private OptionsController()
{
OtherAppOptions = new Dictionary<string, string>();
}

/// <summary>
Expand Down Expand Up @@ -701,10 +710,10 @@ private static string GetDownloadMSG(Dictionary<string, string> parameter)
private static void DownloadNewAdminVersion()
{
// get valid download path.
if (string.IsNullOrEmpty(DownloadPath) || !Directory.Exists(DownloadPath))
if (!OptionsController.HasValidDownloadPath)
SelectNewDownloadPath();

if (!string.IsNullOrEmpty(DownloadPath) && Directory.Exists(DownloadPath))
if (OptionsController.HasValidDownloadPath)
{
string filename = View.llblAdminDownload.Text;
string url = string.Empty;
Expand Down Expand Up @@ -964,7 +973,7 @@ public static void OpenKSPRoot()
/// </summary>
public static void OpenDownloadFolder()
{
if (string.IsNullOrEmpty(DownloadPath))
if (!OptionsController.HasValidDownloadPath)
{
MessageBox.Show(View.ParentForm, string.Format(Messages.MSG_SELECT_0_FOLDER_FIRST, DOWNLOAD));
return;
Expand Down Expand Up @@ -1008,7 +1017,7 @@ public static string SelectNewDownloadPath()

string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string pathDownload = Path.Combine(pathUser, DOWNLOADS);
if (!string.IsNullOrEmpty(DownloadPath))
if (OptionsController.HasValidDownloadPath)
pathDownload = DownloadPath;

FolderSelectDialog dlg = new FolderSelectDialog();
Expand Down
13 changes: 11 additions & 2 deletions KSPModAdmin.Core/KSPModAdmin.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -96,6 +98,15 @@
<Compile Include="Config\KSPConfig.cs" />
<Compile Include="Messages.cs" />
<Compile Include="Model\ICopyModInfo.cs" />
<Compile Include="Utils\CKAN\CkanArchive.cs" />
<Compile Include="Utils\CKAN\CkanMod.cs" />
<Compile Include="Utils\CKAN\CkanRepoManager.cs" />
<Compile Include="Utils\CKAN\Json\CkanInstallInfo.cs" />
<Compile Include="Utils\CKAN\Json\CkanModInfo.cs" />
<Compile Include="Utils\CKAN\Json\CkanRelation.cs" />
<Compile Include="Utils\CKAN\Json\CkanRepository.cs" />
<Compile Include="Utils\CKAN\Json\CkanResource.cs" />
<Compile Include="Utils\CKAN\Json\JsonSingleOrArrayConverter.cs" />
<Compile Include="Utils\Controls\TabControlEx.cs">
<SubType>Component</SubType>
</Compile>
Expand Down Expand Up @@ -705,7 +716,6 @@
<None Include="Resources\folder_add.png" />
<None Include="Resources\page.png" />
<None Include="Resources\page_add.png" />
<None Include="Settings.StyleCop" />
<None Include="Utils\Controls\TreeViewAdv\NodeControls\ClassDiagram.cd" />
<None Include="Utils\SiteHandler\xPathConfigs\CurseForgeXPaths.cfg" />
</ItemGroup>
Expand Down Expand Up @@ -780,7 +790,6 @@
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets" Condition="Exists('..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets')" />
<!-- 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.
<Target Name="BeforeBuild">
Expand Down
1 change: 0 additions & 1 deletion KSPModAdmin.Core/Settings.StyleCop

This file was deleted.

33 changes: 33 additions & 0 deletions KSPModAdmin.Core/Utils/CKAN/CkanArchive.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Collections.Generic;

namespace KSPMODAdmin.Core.Utils.Ckan
{
/// <summary>
/// Class that contains all information from a Ckan Repository archive.
/// </summary>
public class CkanArchive
{
/// <summary>
/// The CKAN Repository information from which this Archive comes from.
/// </summary>
public CkanRepository Repository { get; set; }

/// <summary>
/// The full path to the CKAN Repository archive.
/// </summary>
public string FullPath { get; set; }

/// <summary>
/// A List of all Mods that this CKAN Repository Archive contains.
/// </summary>
public Dictionary<string, CkanMod> Mods { get; set; }

/// <summary>
/// Creates a instance of the class CkanArchive.
/// </summary>
public CkanArchive()
{
Mods = new Dictionary<string, CkanMod>();
}
}
}
33 changes: 33 additions & 0 deletions KSPModAdmin.Core/Utils/CKAN/CkanMod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Collections.Generic;

namespace KSPMODAdmin.Core.Utils.Ckan
{
/// <summary>
/// Class that represents a mod entry in a CKAN Repository archive.
/// </summary>
public class CkanMod
{
/// <summary>
/// Name of the mod.
/// </summary>
public string Name { get; set; }

/// <summary>
/// The all known CKAN ModInfos for this mod.
/// </summary>
public List<CkanModInfo> ModInfos { get; set; }

/// <summary>
/// Path to the CKAN Repository archive.
/// </summary>
public string ArchivePath { get; set; }

/// <summary>
/// Creates a new instance of the class CkanMod.
/// </summary>
public CkanMod()
{
ModInfos = new List<CkanModInfo>();
}
}
}
Loading

0 comments on commit a6a587b

Please sign in to comment.