Skip to content

Commit

Permalink
Merge pull request #563 from PixiEditor/1.2-hotfixes
Browse files Browse the repository at this point in the history
1.2 hotfixes
  • Loading branch information
flabbet authored Jul 4, 2023
2 parents ae5ccbd + d70ec75 commit 9ccf967
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 16 deletions.
5 changes: 4 additions & 1 deletion src/PixiEditor/Data/Localization/Languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,5 +586,8 @@
"ADD_PRIMARY_COLOR_TO_PALETTE": "Add primary color to palette",
"ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "Add primary color to current palette",

"COPY_COLOR": "Copy color"
"COPY_COLOR": "Copy color",

"FAILED_DOWNLOADING_TITLE": "Downloading update failed",
"FAILED_DOWNLOADING": "Failed downloading the update, you might not have enough space on the disk"
}
1 change: 1 addition & 0 deletions src/PixiEditor/Extensions/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
All the extensions goes in this folder.
10 changes: 1 addition & 9 deletions src/PixiEditor/Models/AppExtensions/ExtensionLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ internal class ExtensionLoader

public ExtensionLoader()
{
ValidateExtensionFolder();
_officialExtensionsKeys.Add("pixieditor.supporterpack", new OfficialExtensionData("supporter-pack.snk", AdditionalContentProduct.SupporterPack));
}

public void LoadExtensions()
{
if (!Directory.Exists(Paths.ExtensionsFullPath)) return;
var directories = Directory.GetDirectories(Paths.ExtensionsFullPath);
foreach (var directory in directories)
{
Expand Down Expand Up @@ -208,14 +208,6 @@ private Extension LoadExtensionEntry(Assembly entryAssembly, Type extensionType,
extensionType = null;
return null;
}

private void ValidateExtensionFolder()
{
if (!Directory.Exists(Paths.ExtensionsFullPath))
{
Directory.CreateDirectory(Paths.ExtensionsFullPath);
}
}
}

internal struct OfficialExtensionData
Expand Down
3 changes: 2 additions & 1 deletion src/PixiEditor/Models/IO/Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ internal class Importer : NotifyableObject
/// <param name="path">Path of the image.</param>
/// <param name="size">New size of the image.</param>
/// <returns>WriteableBitmap of imported image.</returns>
public static Surface ImportImage(string path, VecI size)
public static Surface? ImportImage(string path, VecI size)
{
if (!Path.Exists(path)) return null;
Surface original = Surface.Load(path);
if (original.Size == size || size == VecI.NegativeOne)
{
Expand Down
3 changes: 3 additions & 0 deletions src/PixiEditor/PixiEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@
<EmbeddedResource Include="OfficialExtensions\supporter-pack.snk" />
<None Remove="Styles\AvalonDock\Images\**" />
<Page Remove="Styles\AvalonDock\Images\**" />
<None Update="Extensions\readme.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/PixiEditor/ViewModels/SubViewModels/Main/FileViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ private void OpenRegularImage(string path, bool associatePath)
{
var image = Importer.ImportImage(path, VecI.NegativeOne);

if (image == null) return;

var doc = NewDocument(b => b
.WithSize(image.Size)
.WithLayer(l => l
Expand Down
23 changes: 18 additions & 5 deletions src/PixiEditor/ViewModels/SubViewModels/Main/UpdateViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,29 @@ public async Task<bool> CheckForUpdate()
{
UpdateReadyToInstall = false;
VersionText = new LocalizedString("DOWNLOADING_UPDATE");
if (updateCompatible)
try
{
if (updateCompatible)
{
await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo);
}
else
{
await UpdateDownloader.DownloadInstaller(UpdateChecker.LatestReleaseInfo);
}

UpdateReadyToInstall = true;
}
catch (IOException ex)
{
await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo);
NoticeDialog.Show("FAILED_DOWNLOADING_TITLE", "FAILED_DOWNLOADING");
return false;
}
else
catch(TaskCanceledException ex)
{
await UpdateDownloader.DownloadInstaller(UpdateChecker.LatestReleaseInfo);
return false;
}

UpdateReadyToInstall = true;
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private async void ImportPalette_OnClick(object sender, RoutedEventArgs e)
private async Task ImportPalette(string fileName)
{
var parser = PaletteProvider.AvailableParsers.FirstOrDefault(x => x.SupportedFileExtensions.Contains(Path.GetExtension(fileName)));
if (parser == null) return;
var data = await parser.Parse(fileName);
if (data.IsCorrupted || data.Colors.Length == 0) return;
Colors.Clear();
Expand Down

0 comments on commit 9ccf967

Please sign in to comment.