Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
<AvaloniaVersion>11.3.11</AvaloniaVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="ActiproSoftware.Controls.Avalonia" Version="25.2.2" />
<PackageVersion Include="AvalonEdit" Version="6.3.1.120" />
<PackageVersion Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageVersion Include="BCnEncoder.Net" Version="2.2.1" />
<PackageVersion Include="CommunityToolkit.Diagnostics" Version="8.4.0" />
<PackageVersion Include="ConsoleAppFramework" Version="5.2.4" />
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.2" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="ObjectListView.Official" Version="2.9.1" />
<PackageVersion Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
<PackageVersion Include="SharpGLTF.Toolkit" Version="1.0.0-alpha0023" />
<PackageVersion Include="SixLabors.ImageSharp" Version="2.1.13" />
<PackageVersion Include="System.IO.Packaging" Version="10.0.1" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.1" />
<PackageVersion Include="System.IO.Packaging" Version="10.0.2" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.2" />
<PackageVersion Include="ZLogger" Version="2.5.10" />
<PackageVersion Include="ZstdSharp.Port" Version="0.7.2" />
</ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions EgoEngineLibrary.slnx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Solution>
<Configurations>
<Platform Name="Any CPU" />
</Configurations>
<Folder Name="/Solution Items/">
<File Path=".editorconfig" />
<File Path=".gitattributes" />
Expand All @@ -14,6 +11,8 @@
<Folder Name="/src/">
<Project Path="src/EgoCtfEditor/EgoCtfEditor.csproj" />
<Project Path="src/EgoDatabaseEditor/EgoDatabaseEditor.csproj" />
<Project Path="src/EgoEngineLibrary.Frontend.Avalonia/EgoEngineLibrary.Frontend.Avalonia.csproj" />
<Project Path="src/EgoEngineLibrary.Frontend/EgoEngineLibrary.Frontend.csproj" />
<Project Path="src/EgoEngineLibrary/EgoEngineLibrary.csproj" />
<Project Path="src/EgoErpArchiver/EgoErpArchiver.csproj" />
<Project Path="src/EgoErpArchiverConsole/EgoErpArchiverConsole.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Platform.Storage;

using CommunityToolkit.Mvvm.Messaging;

namespace EgoEngineLibrary.Frontend.Dialogs.File;

public static class FileDialogAvalonia
{
public static void Register(Visual recipient)
{
FileDialog.Messenger.Register<Visual, FileOpenMessage>(recipient, FileOpenHandler);
FileDialog.Messenger.Register<Visual, FileSaveMessage>(recipient, FileSaveHandler);
}

public static void Unregister(Visual recipient)
{
FileDialog.Messenger.Unregister<FileOpenMessage>(recipient);
FileDialog.Messenger.Unregister<FileSaveMessage>(recipient);
}

private static void FileOpenHandler(Visual recipient, FileOpenMessage message)
{
message.Reply(FileOpen(recipient, message));
}

private static async Task<IReadOnlyList<string>> FileOpen(Visual recipient, FileOpenMessage message)
{
// Get a reference to our TopLevel (in our case the parent Window)
var topLevel = TopLevel.GetTopLevel(recipient);
if (topLevel is null)
{
return [];
}

var openOptions = message.Options;
var options = new FilePickerOpenOptions
{
Title = openOptions.Title,
FileTypeFilter = openOptions.FileTypeChoices?.Select(x => x.ToFilePickerType()).ToArray(),
SuggestedFileType = openOptions.SuggestedFileType?.ToFilePickerType(),
AllowMultiple = openOptions.AllowMultiple,
SuggestedFileName = openOptions.FileName,
SuggestedStartLocation = openOptions.InitialDirectory is null
? null
: await topLevel.StorageProvider.TryGetFolderFromPathAsync(openOptions.InitialDirectory),
};

var storageFiles = await topLevel.StorageProvider.OpenFilePickerAsync(options);
return storageFiles.Select(x => x.Path.LocalPath).ToArray();
}

private static void FileSaveHandler(Visual recipient, FileSaveMessage message)
{
message.Reply(FileSave(recipient, message));
}

private static async Task<string?> FileSave(Visual recipient, FileSaveMessage message)
{
// Get a reference to our TopLevel (in our case the parent Window)
var topLevel = TopLevel.GetTopLevel(recipient);
if (topLevel is null)
{
return null;
}

var saveOptions = message.Options;
var options = new FilePickerSaveOptions
{
Title = saveOptions.Title,
FileTypeChoices = saveOptions.FileTypeChoices?.Select(x => x.ToFilePickerType()).ToArray(),
SuggestedFileType = saveOptions.SuggestedFileType?.ToFilePickerType(),
DefaultExtension = saveOptions.DefaultExtension,
ShowOverwritePrompt = saveOptions.ShowOverwritePrompt,
SuggestedFileName = saveOptions.FileName,
SuggestedStartLocation = saveOptions.InitialDirectory is null
? null
: await topLevel.StorageProvider.TryGetFolderFromPathAsync(saveOptions.InitialDirectory),
};

var storageFiles = await topLevel.StorageProvider.SaveFilePickerAsync(options);
return storageFiles?.Path.LocalPath;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Avalonia.Platform.Storage;

namespace EgoEngineLibrary.Frontend.Dialogs.File;

public static class FilePickerTypes
{
private static readonly FilePickerFileType Pssg = new("PSSG files")
{
Patterns = ["*.pssg"],
MimeTypes = ["application/octet-stream"],
AppleUniformTypeIdentifiers = ["public.data"]
};

private static readonly FilePickerFileType Dds = new("DDS files")
{
Patterns = ["*.dds"],
MimeTypes = ["application/octet-stream"],
AppleUniformTypeIdentifiers = ["public.image"]
};

private static readonly FilePickerFileType Gltf = new("Gltf files")
{
Patterns = ["*.glb", "*.gltf"],
MimeTypes = ["model/gltf-binary", "model/gltf+json"],
AppleUniformTypeIdentifiers = ["public.3d-content"]
};

private static readonly FilePickerFileType Bin = new("Bin files")
{
Patterns = ["*.bin"],
MimeTypes = ["application/octet-stream"],
AppleUniformTypeIdentifiers = ["public.data"]
};

public static FilePickerFileType ToFilePickerType(this FilePickerType type)
{
return type switch
{
FilePickerType.All => FilePickerFileTypes.All,
FilePickerType.Bin => Bin,
FilePickerType.Dds => Dds,
FilePickerType.Gltf => Gltf,
FilePickerType.Pssg => Pssg,
FilePickerType.Xml => FilePickerFileTypes.Xml,
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Avalonia.Controls;

using CommunityToolkit.Mvvm.Messaging;

namespace EgoEngineLibrary.Frontend.Dialogs.MessageBox;

public static class MessageBoxAvalonia
{
public static void Register(Window recipient)
{
MessageBox.Messenger.Register<Window, MessageBoxShowMessage>(recipient, MessageBoxShowHandler);
}

public static void Unregister(Window recipient)
{
MessageBox.Messenger.Unregister<MessageBoxShowMessage>(recipient);
}

private static void MessageBoxShowHandler(Window recipient, MessageBoxShowMessage message)
{
message.Reply(Show(recipient, message.MessageBoxText, message.Caption, message.Button, message.Icon,
message.DefaultResult));
}

private static Task<MessageBoxResult> Show(
Window owner,
string messageBoxText,
string caption,
MessageBoxButton button = MessageBoxButton.OK,
MessageBoxImage icon = MessageBoxImage.None,
MessageBoxResult defaultResult = MessageBoxResult.None)
{
ArgumentNullException.ThrowIfNull(owner);

MessageBoxWindow box = new()
{
MinWidth = 114,
MinHeight = 94,
MaxWidth = owner.Width,
MaxHeight = owner.Height,
Title = caption,
Message = messageBoxText,
Buttons = button,
ImageIcon = icon,
DefaultResult = defaultResult
};
return box.ShowDialog<MessageBoxResult>(owner);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Window 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"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
x:Class="EgoEngineLibrary.Frontend.Dialogs.MessageBox.MessageBoxWindow"
Title="MessageBoxWindow" CanResize="False" CanMinimize="False" ShowInTaskbar="false"
SizeToContent="WidthAndHeight" Padding="10" WindowStartupLocation="CenterOwner">
<Window.Resources>
<StreamGeometry x:Key="ErrorCircleRegular">M12,2 C17.523,2 22,6.478 22,12 C22,17.522 17.523,22 12,22 C6.477,22 2,17.522 2,12 C2,6.478 6.477,2 12,2 Z M12,3.667 C7.405,3.667 3.667,7.405 3.667,12 C3.667,16.595 7.405,20.333 12,20.333 C16.595,20.333 20.333,16.595 20.333,12 C20.333,7.405 16.595,3.667 12,3.667 Z M11.9986626,14.5022358 C12.5502088,14.5022358 12.9973253,14.9493523 12.9973253,15.5008984 C12.9973253,16.0524446 12.5502088,16.4995611 11.9986626,16.4995611 C11.4471165,16.4995611 11,16.0524446 11,15.5008984 C11,14.9493523 11.4471165,14.5022358 11.9986626,14.5022358 Z M11.9944624,7 C12.3741581,6.99969679 12.6881788,7.28159963 12.7381342,7.64763535 L12.745062,7.7494004 L12.7486629,12.2509944 C12.7489937,12.6652079 12.4134759,13.0012627 11.9992625,13.0015945 C11.6195668,13.0018977 11.3055461,12.7199949 11.2555909,12.3539592 L11.2486629,12.2521941 L11.245062,7.7506001 C11.2447312,7.33638667 11.580249,7.00033178 11.9944624,7 Z</StreamGeometry>
<StreamGeometry x:Key="InfoRegular">M14,2 C20.6274,2 26,7.37258 26,14 C26,20.6274 20.6274,26 14,26 C7.37258,26 2,20.6274 2,14 C2,7.37258 7.37258,2 14,2 Z M14,3.5 C8.20101,3.5 3.5,8.20101 3.5,14 C3.5,19.799 8.20101,24.5 14,24.5 C19.799,24.5 24.5,19.799 24.5,14 C24.5,8.20101 19.799,3.5 14,3.5 Z M14,11 C14.3796833,11 14.6934889,11.2821653 14.7431531,11.6482323 L14.75,11.75 L14.75,19.25 C14.75,19.6642 14.4142,20 14,20 C13.6203167,20 13.3065111,19.7178347 13.2568469,19.3517677 L13.25,19.25 L13.25,11.75 C13.25,11.3358 13.5858,11 14,11 Z M14,7 C14.5523,7 15,7.44772 15,8 C15,8.55228 14.5523,9 14,9 C13.4477,9 13,8.55228 13,8 C13,7.44772 13.4477,7 14,7 Z</StreamGeometry>
<StreamGeometry x:Key="QuestionCircleRegular">M24 4C35.0457 4 44 12.9543 44 24C44 35.0457 35.0457 44 24 44C12.9543 44 4 35.0457 4 24C4 12.9543 12.9543 4 24 4ZM24 6.5C14.335 6.5 6.5 14.335 6.5 24C6.5 33.665 14.335 41.5 24 41.5C33.665 41.5 41.5 33.665 41.5 24C41.5 14.335 33.665 6.5 24 6.5ZM24.25 32C25.0784 32 25.75 32.6716 25.75 33.5C25.75 34.3284 25.0784 35 24.25 35C23.4216 35 22.75 34.3284 22.75 33.5C22.75 32.6716 23.4216 32 24.25 32ZM24.25 13C27.6147 13 30.5 15.8821 30.5 19.2488C30.502 21.3691 29.7314 22.7192 27.8216 24.7772L26.8066 25.8638C25.7842 27.0028 25.3794 27.7252 25.3409 28.5793L25.3379 28.7411L25.3323 28.8689L25.3143 28.9932C25.2018 29.5636 24.7009 29.9957 24.0968 30.0001C23.4065 30.0049 22.8428 29.4493 22.8379 28.7589C22.8251 26.9703 23.5147 25.7467 25.1461 23.9739L26.1734 22.8762C27.5312 21.3837 28.0012 20.503 28 19.25C28 17.2634 26.2346 15.5 24.25 15.5C22.3307 15.5 20.6142 17.1536 20.5055 19.0587L20.4935 19.3778C20.4295 20.0081 19.8972 20.5 19.25 20.5C18.5596 20.5 18 19.9404 18 19.25C18 15.8846 20.8864 13 24.25 13Z</StreamGeometry>
<StreamGeometry x:Key="WarningRegular">M10.9093922,2.78216375 C11.9491636,2.20625071 13.2471955,2.54089334 13.8850247,3.52240345 L13.9678229,3.66023048 L21.7267791,17.6684928 C21.9115773,18.0021332 22.0085303,18.3772743 22.0085303,18.7586748 C22.0085303,19.9495388 21.0833687,20.9243197 19.9125791,21.003484 L19.7585303,21.0086748 L4.24277801,21.0086748 C3.86146742,21.0086748 3.48641186,20.9117674 3.15282824,20.7270522 C2.11298886,20.1512618 1.7079483,18.8734454 2.20150311,17.8120352 L2.27440063,17.668725 L10.0311968,3.66046274 C10.2357246,3.291099 10.5400526,2.98673515 10.9093922,2.78216375 Z M20.4146132,18.3952808 L12.6556571,4.3870185 C12.4549601,4.02467391 11.9985248,3.89363262 11.6361802,4.09432959 C11.5438453,4.14547244 11.4637001,4.21532637 11.4006367,4.29899869 L11.3434484,4.38709592 L3.58665221,18.3953582 C3.385998,18.7577265 3.51709315,19.2141464 3.87946142,19.4148006 C3.96285732,19.4609794 4.05402922,19.4906942 4.14802472,19.5026655 L4.24277801,19.5086748 L19.7585303,19.5086748 C20.1727439,19.5086748 20.5085303,19.1728883 20.5085303,18.7586748 C20.5085303,18.6633247 20.4903516,18.5691482 20.455275,18.4811011 L20.4146132,18.3952808 L12.6556571,4.3870185 L20.4146132,18.3952808 Z M12.0004478,16.0017852 C12.5519939,16.0017852 12.9991104,16.4489016 12.9991104,17.0004478 C12.9991104,17.5519939 12.5519939,17.9991104 12.0004478,17.9991104 C11.4489016,17.9991104 11.0017852,17.5519939 11.0017852,17.0004478 C11.0017852,16.4489016 11.4489016,16.0017852 12.0004478,16.0017852 Z M11.9962476,8.49954934 C12.3759432,8.49924613 12.689964,8.78114897 12.7399193,9.14718469 L12.7468472,9.24894974 L12.750448,13.7505438 C12.7507788,14.1647572 12.4152611,14.5008121 12.0010476,14.5011439 C11.621352,14.5014471 11.3073312,14.2195442 11.257376,13.8535085 L11.250448,13.7517435 L11.2468472,9.25014944 C11.2465164,8.83593601 11.5820341,8.49988112 11.9962476,8.49954934 Z</StreamGeometry>
</Window.Resources>
<Grid RowDefinitions="*,Auto" ColumnDefinitions="Auto,*">
<PathIcon Name="Image" Grid.Column="0" Grid.Row="0" Width="48" Height="48" Margin="0, 0, 5, 0"></PathIcon>
<ScrollViewer Grid.Column="1" Grid.Row="0" VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<TextBlock Name="MessageTextBlock" Text="The quick brown fox jumped over the lazy dog."></TextBlock>
</ScrollViewer>
<UniformGrid Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Rows="1" HorizontalAlignment="Center"
ColumnSpacing="5" Margin="0 5 0 0">
<Button Name="FirstButton" Click="FirstButton_OnClick">A</Button>
<Button Name="SecondButton" Click="SecondButton_OnClick">B</Button>
<Button Name="ThirdButton" Click="ThirdButton_OnClick">C</Button>
</UniformGrid>
</Grid>
</Window>
Loading