Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
- #111 thumb.jpg in existing scripts not recognized in blueprint manager
Browse files Browse the repository at this point in the history
- #124 [PRE] [VS2019] Error when attempting to create a new Project
- #125 [PRE] [VS2019] New projects default to C# 7 or higher.
- #130 Suggestion: Refreshing whitelist runs SE; Add -skipintro to not show intro video
  • Loading branch information
Malware committed Apr 20, 2019
1 parent 03aa2db commit 8e781e9
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 63 deletions.
7 changes: 4 additions & 3 deletions Source/IngameScriptTemplate/IngameScript.vstemplate
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<Icon>IngameScript.ico</Icon>
<AppliesTo>CSharp</AppliesTo>
<ProjectType>CSharp</ProjectType>
<RequiredFrameworkVersion>4.6</RequiredFrameworkVersion>
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
<RequiredFrameworkVersion>4.6.1</RequiredFrameworkVersion>
<MaxFrameworkVersion>4.6.1</MaxFrameworkVersion>
<NumberOfParentCategoriesToRollUp>2</NumberOfParentCategoriesToRollUp>
<SortOrder>1000</SortOrder>
<TemplateID>e8dc9f0e-c9d8-400b-b23d-b61e738f2a72</TemplateID>
<CreateNewFolder>true</CreateNewFolder>
Expand All @@ -27,7 +28,7 @@
</Project>
</TemplateContent>
<WizardExtension>
<Assembly>MDK, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=ed62e9cc24aaaa2b</Assembly>
<Assembly>MDK, Version=1.2.0.0, Culture=Neutral, PublicKeyToken=ed62e9cc24aaaa2b</Assembly>
<FullClassName>MDK.Services.IngameScriptWizard</FullClassName>
</WizardExtension>
</VSTemplate>
1 change: 0 additions & 1 deletion Source/MDK/MDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
<DependentUpon>ProjectHealthDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProjectHealth\ProjectHealthDialogModel.cs" />
<Compile Include="Views\ProjectHealth\ProjectOptionsRequestedEventArgs.cs" />
<Compile Include="Views\ProjectHealth\Fixes\UpgradeFrom_1_1.cs" />
<Compile Include="Views\ToBooleanConverter.cs" />
<Compile Include="Views\DialogClosingEventArgs.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Source/MDK/MDKPackage.GeneratedInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class MDKPackage
/// <summary>
/// The current package version
/// </summary>
public static readonly Version Version = new Version("1.2.2");
public static readonly Version Version = new Version("1.2.6");

/// <summary>
/// The required IDE version
Expand Down
13 changes: 7 additions & 6 deletions Source/MDK/MDKPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ namespace MDK
/// <summary>
/// The MDK Visual Studio Extension
/// </summary>
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[InstalledProductRegistration("#110", "#112", "1.2", IconResourceID = 400)] // Info on this package for Help/About
[ProvideMenuResource("Menus.ctmenu", 1)]
[Guid(PackageGuidString)]
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
[ProvideOptionPage(typeof(MDKOptions), "MDK/SE", "Options", 0, 0, true)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionOpening_string)]
[ProvideAutoLoad(VSConstants.UICONTEXT.ShellInitialized_string)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionOpening_string, PackageAutoLoadFlags.BackgroundLoad)]
[ProvideAutoLoad(VSConstants.UICONTEXT.ShellInitialized_string, PackageAutoLoadFlags.BackgroundLoad)]
public sealed partial class MDKPackage : ExtendedPackage
{
/// <summary>
Expand Down Expand Up @@ -105,8 +105,9 @@ protected override void Dispose(bool disposing)
/// Initialization of the package; this method is called right after the package is sited, so this is the place
/// where you can put all the initialization code that rely on services provided by VisualStudio.
/// </summary>
protected override System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
_solutionManager = new SolutionManager(this);
_solutionManager.BeginRecording();
_solutionManager.ProjectLoaded += OnProjectLoaded;
Expand All @@ -129,7 +130,7 @@ protected override System.Threading.Tasks.Task InitializeAsync(CancellationToken

KnownUIContexts.ShellInitializedContext.WhenActivated(OnShellActivated);

return base.InitializeAsync(cancellationToken, progress);
await base.InitializeAsync(cancellationToken, progress);
}

void OnUpdateDetected(Version detectedVersion)
Expand Down
1 change: 1 addition & 0 deletions Source/MDK/Services/WhitelistCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void Refresh(string installPath)
$"-applaunch {appId}",
$"-plugin \"{pluginPath}\"",
"-nosplash",
"-skipintro",
"-whitelistcaches",
$"\"{whitelistTarget}\"",
"-terminalcaches",
Expand Down
7 changes: 5 additions & 2 deletions Source/MDK/Views/BlueprintManager/BlueprintManagerModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
Expand All @@ -16,6 +17,8 @@ namespace MDK.Views.BlueprintManager
/// </summary>
public class BlueprintManagerDialogModel : DialogViewModel
{
static readonly string[] ThumbFileNames = {"thumb.png", "thumb.jpg", "thumb.jpeg"};

string _blueprintPath;
BlueprintModel _selectedBlueprint;
HashSet<string> _significantBlueprints;
Expand Down Expand Up @@ -205,8 +208,8 @@ void LoadBlueprints()
continue;

BitmapImage icon = null;
var thumbFileName = Path.Combine(folder.FullName, "thumb.png");
if (File.Exists(thumbFileName))
var thumbFileName = ThumbFileNames.Select(name => Path.Combine(folder.FullName, name)).FirstOrDefault(File.Exists);
if (thumbFileName != null)
{
icon = new BitmapImage();
icon.BeginInit();
Expand Down
75 changes: 74 additions & 1 deletion Source/MDK/Views/ProjectHealth/Fixes/BackupFix.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
using Malware.MDKServices;

namespace MDK.Views.ProjectHealth.Fixes
Expand All @@ -13,15 +14,87 @@ public override void Apply(HealthAnalysis analysis, FixStatus status)
{
status.Description = "Creating a backup in the parent folder...";
var directory = Path.GetDirectoryName(analysis.FileName) ?? ".\\";
if (!directory.EndsWith("\\"))
directory += "\\";
var zipFileName = $"{Path.GetFileNameWithoutExtension(analysis.FileName)}_Backup_{DateTime.Now:yyyy-MM-dd-HHmmssfff}.zip";
var tmpZipName = Path.Combine(Path.GetTempPath(), zipFileName);
ZipFile.CreateFromDirectory(directory, tmpZipName, CompressionLevel.Fastest, false);
ZipHelper.CreateFromDirectory(directory, tmpZipName, CompressionLevel.Fastest, false, path => OnlyInterestingFiles(directory, path));
var backupDirectory = new DirectoryInfo(Path.Combine(directory, "..\\"));
File.Copy(tmpZipName, Path.Combine(backupDirectory.FullName, zipFileName));
File.Delete(tmpZipName);
status.Description = "Backup created";
}

bool OnlyInterestingFiles(string baseDirectory, string path)
{
path = path.Substring(baseDirectory.Length);
if (path.Equals(".vs", StringComparison.CurrentCultureIgnoreCase) || path.StartsWith(".vs\\", StringComparison.CurrentCultureIgnoreCase))
return false;
if (path.Equals("bin", StringComparison.CurrentCultureIgnoreCase) || path.StartsWith("bin\\", StringComparison.CurrentCultureIgnoreCase))
return false;
if (path.Equals("obj", StringComparison.CurrentCultureIgnoreCase) || path.StartsWith("obj\\", StringComparison.CurrentCultureIgnoreCase))
return false;
return true;
}

public static class ZipHelper
{
public static void CreateFromDirectory(
string sourceDirectoryName,
string destinationArchiveFileName,
CompressionLevel compressionLevel,
bool includeBaseDirectory,
Predicate<string> filter
)
{
if (string.IsNullOrEmpty(sourceDirectoryName))
{
throw new ArgumentNullException(nameof(sourceDirectoryName));
}
if (string.IsNullOrEmpty(destinationArchiveFileName))
{
throw new ArgumentNullException(nameof(destinationArchiveFileName));
}
var filesToAdd = Directory.GetFiles(sourceDirectoryName, "*", SearchOption.AllDirectories);
var entryNames = GetEntryNames(filesToAdd, sourceDirectoryName, includeBaseDirectory);
using (var zipFileStream = new FileStream(destinationArchiveFileName, FileMode.Create))
{
using (var archive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
{
for (int i = 0; i < filesToAdd.Length; i++)
{
// Add the following condition to do filtering:
if (!filter(filesToAdd[i]))
{
continue;
}
archive.CreateEntryFromFile(filesToAdd[i], entryNames[i], compressionLevel);
}
}
}
}
}

private static string[] GetEntryNames(string[] names, string sourceFolder, bool includeBaseName)
{
if (names == null || names.Length == 0)
return new string[0];

if (includeBaseName)
sourceFolder = Path.GetDirectoryName(sourceFolder);

int length = string.IsNullOrEmpty(sourceFolder) ? 0 : sourceFolder.Length;
if (length > 0 && sourceFolder != null && sourceFolder[length - 1] != Path.DirectorySeparatorChar && sourceFolder[length - 1] != Path.AltDirectorySeparatorChar)
length++;

var result = new string[names.Length];
for (int i = 0; i < names.Length; i++)
{
result[i] = names[i].Substring(length);
}

return result;
}
public override bool IsApplicableTo(HealthAnalysis project) => true;
}
}
3 changes: 0 additions & 3 deletions Source/MDK/Views/ProjectHealth/ProjectHealthDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,17 @@ public partial class ProjectHealthDialog : DialogWindow
/// </summary>
public ProjectHealthDialog() { InitializeComponent(); }

void OnUpgradeCompleted(object sender, EventArgs e) { MessageBox.Show(this, Text.ProjectHealthDialog_OnUpgradeCompleted_BackupsStoredMessage, "Projects Upgraded/Repaired", MessageBoxButton.OK, MessageBoxImage.Information); }

void SetModel(ProjectHealthDialogModel viewModel)
{
Host.DataContext = viewModel;
viewModel.Closing += OnModelClosing;
viewModel.UpgradeCompleted += OnUpgradeCompleted;
}

void OnModelClosing(object sender, DialogClosingEventArgs e)
{
var viewModel = ((ProjectHealthDialogModel)Host.DataContext);
viewModel.Closing -= OnModelClosing;
viewModel.UpgradeCompleted -= OnUpgradeCompleted;
DialogResult = e.State;
Close();
}
Expand Down
5 changes: 0 additions & 5 deletions Source/MDK/Views/ProjectHealth/ProjectHealthDialogModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ public ProjectHealthDialogModel([NotNull] MDKPackage package, [NotNull] HealthAn
FixStatuses = new ReadOnlyObservableCollection<FixStatus>(_fixStatuses);
}

/// <summary>
/// Informs the view that the upgrade process is complete.
/// </summary>
public event EventHandler UpgradeCompleted;

/// <summary>
/// A list of projects and their problems
/// </summary>
Expand Down
37 changes: 0 additions & 37 deletions Source/MDK/Views/ProjectHealth/ProjectOptionsRequestedEventArgs.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Source/MDK/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="MDK.Morten Aune Lyrstad.e02b602e-3099-44a5-88c6-cb30cab978f6" Version="1.2.2" Language="en-US" Publisher="Morten Aune Lyrstad" />
<Identity Id="MDK.Morten Aune Lyrstad.e02b602e-3099-44a5-88c6-cb30cab978f6" Version="1.2.6" Language="en-US" Publisher="Morten Aune Lyrstad" />
<DisplayName>MDK/SE</DisplayName>
<Description xml:space="preserve">A toolkit to help with ingame script (programmable block) development for Keen Software House's space sandbox Space Engineers.

Expand Down
3 changes: 3 additions & 0 deletions Source/MDKServices/HealthAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ static HealthAnalysis Analyze(Project project, HealthAnalysisOptions options)
/// </summary>
public MDKProjectProperties Properties { get; }

/// <summary>
/// Contains the options used when running this analysis
/// </summary>
public HealthAnalysisOptions AnalysisOptions { get; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ partial class MDKProjectProperties
/// <summary>
/// The current package version this utility assembly targets
/// </summary>
public static readonly Version TargetPackageVersion = new Version("1.2.2");
public static readonly Version TargetPackageVersion = new Version("1.2.6");
}
}
5 changes: 3 additions & 2 deletions Source/MixinProjectTemplate/MixinProjectTemplate.vstemplate
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<Icon>MixinProjectTemplate.ico</Icon>
<AppliesTo>CSharp</AppliesTo>
<ProjectType>CSharp</ProjectType>
<RequiredFrameworkVersion>4.6</RequiredFrameworkVersion>
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
<RequiredFrameworkVersion>4.6.1</RequiredFrameworkVersion>
<MaxFrameworkVersion>4.6.1</MaxFrameworkVersion>
<NumberOfParentCategoriesToRollUp>2</NumberOfParentCategoriesToRollUp>
<SortOrder>1100</SortOrder>
<TemplateID>e8dc9f0e-c9d8-400b-b23d-b61e738f2a72</TemplateID>
<CreateNewFolder>true</CreateNewFolder>
Expand Down

0 comments on commit 8e781e9

Please sign in to comment.