Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vletroye committed Sep 17, 2023
1 parent 79ce7ac commit 60fdc43
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 81 deletions.
7 changes: 5 additions & 2 deletions Mods/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
<setting name="Packages" serializeAs="String">
<value />
</setting>
<setting name="PackageRoot" serializeAs="String">
<setting name="PackageRootDSM6x" serializeAs="String">
<value />
</setting>
<setting name="SourceImages" serializeAs="String">
<setting name="PackageRootDSM7x" serializeAs="String">
<value />
</setting>
<setting name="SourceImages" serializeAs="String">
<value />
</setting>
<setting name="UpgradeRequired" serializeAs="String">
Expand Down
7 changes: 6 additions & 1 deletion Mods/Data/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Package(string targetFolder, string spk, bool forceDeflate)
else
{
//Check if a package is to be deflated
if (PackageHelper.DeflatePackageIfRequired(forceDeflate, ref dirInfo, fileInfo) == DialogResult.Cancel)
if (PackageHelper.DeflatePackageIfRequired(forceDeflate, ref dirInfo, ref fileInfo) == DialogResult.Cancel)
IsLoaded = false;
else
{
Expand All @@ -46,11 +46,16 @@ public Package(string targetFolder, string spk, bool forceDeflate)
IsLoaded = false;
}
}
if (dirInfo != null) this.Folder = dirInfo.FullName;
if (fileInfo != null) this.SPK = fileInfo.FullName;
}
}

public Package(string targetFolder, string spk) : this(targetFolder, spk, false) { }

public string Folder { get; set; }
public string SPK { get; set; }

public bool IsLoaded { get; set; }

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions Mods/Data/PackageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal static bool SeemsDeflated(DirectoryInfo packageFolder)
/// No if a Deflation was not done.
/// If the spk is deflated into a temporary folder, this one is returned into targetFolder.
/// </returns>
internal static DialogResult DeflatePackageIfRequired(bool forceDeflate, ref DirectoryInfo targetFolder, FileInfo spk)
internal static DialogResult DeflatePackageIfRequired(bool forceDeflate, ref DirectoryInfo targetFolder, ref FileInfo spk)
{
DialogResult answer = DialogResult.No;
bool spkToBeDeflated = true;
Expand All @@ -80,7 +80,7 @@ internal static DialogResult DeflatePackageIfRequired(bool forceDeflate, ref Dir
else if (!spk.Exists)
throw new ArgumentException(String.Format("Application Error: The SPK {0} does not exist.", spk.FullName));

// If not target folder to deflate, use the folder of the SPK
// If no target folder provided to deflate, use the folder of the SPK
if (targetFolder == null || !targetFolder.Exists)
if (SeemsDeflated(spk.Directory))
{
Expand Down Expand Up @@ -316,6 +316,7 @@ internal static bool DeflatePackage(FileInfo spk)

internal static void CopyPackagingBinaries(string path)
{

if (File.Exists(Path.Combine(path, "7z.exe")))
File.Delete(Path.Combine(path, "7z.exe"));
File.Copy(Path.Combine(Helper.ResourcesDirectory, "7z.exe"), Path.Combine(path, "7z.exe"));
Expand Down
20 changes: 14 additions & 6 deletions Mods/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ private void FillInfoScreen()
if (groupBoxPackage.BackColor != Color.Salmon)
{
groupBoxPackage.BackColor = Color.Salmon;
HelperNew.PublishWarning("This package has has been opened from a temporary folder. Possibly move it into a target folder using the menu Package > Move.");
HelperNew.PublishWarning("This package has been opened from a temporary folder. Possibly move it into a target folder using the menu Package > Move.");
}
}
else
Expand Down Expand Up @@ -3640,7 +3640,7 @@ private void buttonAdvanced_Click(object sender, EventArgs e)
ScriptInfo config = null;
if (!string.IsNullOrWhiteSpace(CurrentPackage.INFO.DsmUiDir))
{
configName = CurrentPackage.Folder_UI;
configName = CurrentPackage.Path_Config;
if (File.Exists(configName))
{
content = File.ReadAllText(configName);
Expand Down Expand Up @@ -3680,10 +3680,15 @@ private void menuOpenPackageFolder_Click(object sender, EventArgs e)
}
Process.Start(path);
}
else if (!(string.IsNullOrEmpty(Properties.Settings.Default.PackageRoot)) && Directory.Exists(Properties.Settings.Default.PackageRoot))
else
{
var path = Properties.Settings.Default.PackageRoot;
Process.Start(path);

// TODO: check here if creating a package DSM <= 6.x or >= 7.x
if (!(string.IsNullOrEmpty(Properties.Settings.Default.PackageRootDSM6x)) && Directory.Exists(Properties.Settings.Default.PackageRootDSM6x))
{
var path = Properties.Settings.Default.PackageRootDSM6x;
Process.Start(path);
}
}
}

Expand Down Expand Up @@ -3994,7 +3999,10 @@ private bool PromptToMovePackage(string path = null)
{
folderBrowserDialog4Mods.Title = "Pick a target Root folder to move the Package currently opened.";
if (Properties.Settings.Default.DefaultPackageRoot)
folderBrowserDialog4Mods.InitialDirectory = Properties.Settings.Default.PackageRoot;
{
// TODO: check here if creating a package DSM <= 6.x or >= 7.x
folderBrowserDialog4Mods.InitialDirectory = Properties.Settings.Default.PackageRootDSM6x;
}
else
folderBrowserDialog4Mods.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

Expand Down
Loading

0 comments on commit 60fdc43

Please sign in to comment.