Skip to content

Commit

Permalink
Merge branch 'main' into features/config-indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsTheSky authored Jan 24, 2024
2 parents 0554cb3 + 6da2221 commit a15cbc6
Show file tree
Hide file tree
Showing 33 changed files with 725 additions and 294 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ jobs:
run: |
cd SkEditor
dotnet restore
dotnet publish -c Release -r osx-arm64 -p:PublishSingleFile=true --no-self-contained /p:DebugType=None /p:DebugSymbols=false
dotnet publish -c Release -r osx-x64 -p:PublishSingleFile=true --no-self-contained /p:DebugType=None /p:DebugSymbols=false
- name: Create .app structure
run: |
mkdir -p "SkEditor.app/Contents/MacOS"
mkdir -p "SkEditor.app/Contents/Resources"
cp -r SkEditor/bin/Release/net8.0/osx-arm64/publish/* "SkEditor.app/Contents/MacOS/"
cp -r SkEditor/bin/Release/net8.0/osx-x64/publish/* "SkEditor.app/Contents/MacOS/"
cp SkEditor/Info.plist "SkEditor.app/Contents/"
cp SkEditor/SkEditor.icns "SkEditor.app/Contents/Resources/"
Expand Down
3 changes: 3 additions & 0 deletions Installer/LanguagesComponents.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<Component>
<File Source="..\SkEditor\bin\Release\net8.0\win-x64\publish\Languages\Spanish.xaml" />
</Component>
<Component>
<File Source="..\SkEditor\bin\Release\net8.0\win-x64\publish\Languages\Hungarian.xaml" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
2 changes: 1 addition & 1 deletion Installer/Package.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<Package Name="SkEditor" Manufacturer="Notro" Version="2.1.0" UpgradeCode="14564974-da58-4917-8a0d-590043f589c2">
<Package Name="SkEditor" Manufacturer="Notro" Version="2.1.2" UpgradeCode="14564974-da58-4917-8a0d-590043f589c2">
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
<MediaTemplate EmbedCab="yes" />

Expand Down
51 changes: 37 additions & 14 deletions SkEditor/API/AddonLoader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Avalonia.Controls;
using Serilog;
using Serilog;
using SkEditor.Utilities;
using System;
using System.Collections.Generic;
Expand All @@ -12,25 +11,23 @@ namespace SkEditor.API;
public class AddonLoader
{
public static List<IAddon> Addons { get; } = [];
public static HashSet<string> DllNames { get; } = [];

public static void Load()
{
var addonFolder = Path.Combine(AppConfig.AppDataFolderPath, "Addons");

Directory.CreateDirectory(addonFolder);

IEnumerable<string> addonFolders = Directory.EnumerateDirectories(addonFolder, "*", SearchOption.TopDirectoryOnly);
IEnumerable<string> updatedFolderAddons = Directory.EnumerateFiles(addonFolder, "*.zip", SearchOption.TopDirectoryOnly);
UpdateAddons(addonFolder);
DeleteDisableAddons(addonFolder);

foreach (string updatedAddon in updatedFolderAddons)
{
string nameWithoutPrefix = Path.GetFileName(updatedAddon)["updated-".Length..];
string folderWithoutPrefixPath = Path.Combine(addonFolder, Path.GetFileNameWithoutExtension(nameWithoutPrefix));
Directory.Delete(folderWithoutPrefixPath, true);
ZipFile.ExtractToDirectory(updatedAddon, addonFolder);
File.Delete(updatedAddon);
}
LoadAddonsFromFolder(addonFolder);
EnableAddons();
}

private static void DeleteDisableAddons(string addonFolder)
{
IEnumerable<string> addonFolders = Directory.EnumerateDirectories(addonFolder, "*", SearchOption.TopDirectoryOnly);
foreach (string folder in addonFolders)
{
if (ApiVault.Get().GetAppConfig().AddonsToDelete.Contains(Path.GetFileName(folder)))
Expand All @@ -49,9 +46,31 @@ public static void Load()
}
LoadAddonsFromFolder(folder);
}
}

LoadAddonsFromFolder(addonFolder);
private static void UpdateAddons(string addonFolder)
{
IEnumerable<string> updatedFolderAddons = Directory.EnumerateFiles(addonFolder, "*.zip", SearchOption.TopDirectoryOnly);

foreach (string updatedAddon in updatedFolderAddons)
{
string nameWithoutPrefix = Path.GetFileName(updatedAddon)["updated-".Length..];
string folderWithoutPrefixPath = Path.Combine(addonFolder, Path.GetFileNameWithoutExtension(nameWithoutPrefix));
if (!Directory.Exists(folderWithoutPrefixPath))
{
Log.Warning($"Found \"{updatedAddon}\" in addons folder, but its folder \"{folderWithoutPrefixPath}\" doesn't exist. Deleting it.");
File.Delete(updatedAddon);
continue;
}

Directory.Delete(folderWithoutPrefixPath, true);
ZipFile.ExtractToDirectory(updatedAddon, addonFolder);
File.Delete(updatedAddon);
}
}

private static void EnableAddons()
{
try
{
AppDomain.CurrentDomain.GetAssemblies()
Expand All @@ -64,6 +83,9 @@ public static void Load()
Addons.Add(addon);
addon.OnEnable();
});

ApiVault.Get().GetAppConfig().AddonsToDelete.Clear();
ApiVault.Get().GetAppConfig().AddonsToUpdate.Clear();
}
catch (Exception ex)
{
Expand Down Expand Up @@ -101,6 +123,7 @@ public static List<Assembly> LoadAddonsFromFolder(string folder)
if (AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == Path.GetFileNameWithoutExtension(dllFile))) continue;

assemblies.Add(Assembly.LoadFrom(dllFile));
DllNames.Add(fileName);
}

return assemblies;
Expand Down
5 changes: 5 additions & 0 deletions SkEditor/Controls/MainMenuControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<ui:SymbolIcon Symbol="OpenFile"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Open folder" Name="MenuItemOpenFolder" IsVisible="False" HotKey="Ctrl+Shift+O" InputGesture="Ctrl+Shift+O">
<MenuItem.Icon>
<ui:SymbolIcon Symbol="Folder"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{DynamicResource MenuHeaderSave}" Name="MenuItemSave" HotKey="Ctrl+S" InputGesture="Ctrl+S">
<MenuItem.Icon>
<ui:SymbolIcon Symbol="Save"/>
Expand Down
4 changes: 3 additions & 1 deletion SkEditor/Controls/MainMenuControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using SkEditor.API;
using SkEditor.Utilities.Editor;
using SkEditor.Utilities.Files;
using SkEditor.Utilities.Projects;
using SkEditor.Utilities.Syntax;
using SkEditor.Views;
using SkEditor.Views.Generators;
Expand All @@ -24,6 +25,7 @@ private void AssignCommands()
{
MenuItemNew.Command = new RelayCommand(FileHandler.NewFile);
MenuItemOpen.Command = new RelayCommand(FileHandler.OpenFile);
MenuItemOpenFolder.Command = new RelayCommand(ProjectOpener.OpenProject);
MenuItemSave.Command = new RelayCommand(async () =>
{
(bool, Exception) success = await FileHandler.SaveFile();
Expand All @@ -47,7 +49,7 @@ private void AssignCommands()
MenuItemDuplicate.Command = new RelayCommand(() => CustomCommandsHandler.OnDuplicateCommandExecuted(ApiVault.Get().GetTextEditor().TextArea));
MenuItemComment.Command = new RelayCommand(() => CustomCommandsHandler.OnCommentCommandExecuted(ApiVault.Get().GetTextEditor().TextArea));

MenuItemRefreshSyntax.Command = new RelayCommand(() => SyntaxLoader.RefreshSyntax());
MenuItemRefreshSyntax.Command = new RelayCommand(async () => await SyntaxLoader.RefreshSyntaxAsync());

MenuItemSettings.Command = new RelayCommand(() => new SettingsWindow().ShowDialog(ApiVault.Get().GetMainWindow()));
MenuItemGenerateGui.Command = new RelayCommand(() => new GuiGenerator().ShowDialog(ApiVault.Get().GetMainWindow()));
Expand Down
49 changes: 49 additions & 0 deletions SkEditor/Controls/SideBarControl.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:FluentAvalonia.UI.Controls"
x:Class="SkEditor.Controls.SideBarControl">

<UserControl.Styles>
<Style Selector="Button.barButton">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="0"/>
</Style>
<Style Selector="Separator">
<Setter Property="Margin" Value="0,1"/>
</Style>
<Style Selector="TreeViewItem">
<Setter Property="FontWeight" Value="Regular"/>
</Style>
</UserControl.Styles>

<Grid ColumnDefinitions="auto,auto" RowDefinitions="*">
<Border Grid.Column="0" Width="36" Background="{DynamicResource SkEditorBorderBackground}" CornerRadius="7">
<StackPanel Spacing="10" HorizontalAlignment="Center">
<Button Name="ProjectsButton" Height="36" Width="36" Classes="barButton">
<Button.Content>
<ui:SymbolIcon Symbol="Folder" FontSize="24" Foreground="#bfffffff" />
</Button.Content>
</Button>
</StackPanel>
</Border>

<Border Name="ExtendedSideBar" Grid.Column="1" Width="0" Background="{DynamicResource SkEditorBorderBackground}" CornerRadius="7" Margin="10,0,0,0">
<Border.Transitions>
<Transitions>
<DoubleTransition Property="Width" Duration="0:0:0.05" Easing="QuadraticEaseIn"/>
</Transitions>
</Border.Transitions>

<Grid RowDefinitions="auto,auto,*">
<TextBlock Grid.Row="0" Text="Explorer" FontWeight="DemiBold" Margin="20,10,20,10"/>
<Separator Grid.Row="1" Margin="0,0,0,10"/>
<TreeView Grid.Row="2" Name="FileTreeView">

</TreeView>
</Grid>
</Border>
</Grid>
</UserControl>
23 changes: 23 additions & 0 deletions SkEditor/Controls/SideBarControl.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Avalonia.Controls;
using CommunityToolkit.Mvvm.Input;

namespace SkEditor.Controls;
public partial class SideBarControl : UserControl
{
public SideBarControl()
{
InitializeComponent();

AssignCommands();
}

private void AssignCommands()
{
ProjectsButton.Command = new RelayCommand(() =>
{
ScrollViewer.SetHorizontalScrollBarVisibility(FileTreeView, Avalonia.Controls.Primitives.ScrollBarVisibility.Disabled);
ScrollViewer.SetVerticalScrollBarVisibility(FileTreeView, Avalonia.Controls.Primitives.ScrollBarVisibility.Auto);
ExtendedSideBar.Width = ExtendedSideBar.Width == 0 ? 250 : 0;
});
}
}
3 changes: 0 additions & 3 deletions SkEditor/Languages/English.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@
<system:String x:Key="SettingsPersonalizationSyntax">Syntax highlighting</system:String>
<system:String x:Key="SettingsPersonalizationFont">Font</system:String>
<system:String x:Key="SettingsPersonalizationFontDescription">Current font: {0}</system:String>

<!-- File Syntaxes -->
<system:String x:Key="SettingsSyntaxesTitle">Syntax Highlighting</system:String>

<!-- Theme Settings -->
<system:String x:Key="SettingsThemeTitle">Theme</system:String>
Expand Down
Loading

0 comments on commit a15cbc6

Please sign in to comment.