Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite with AvaloniaUI #40

Merged
merged 60 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b517217
try avalonia ui
LeftofZen Mar 1, 2024
9256afa
add veldrid/imgui and maui experiments as well
LeftofZen Mar 3, 2024
d4300f2
ava progress
LeftofZen Mar 11, 2024
7e5d50c
Merge branch 'master' into avagui
LeftofZen Mar 11, 2024
0950285
make veldridgui compile
LeftofZen Mar 11, 2024
6ccdbb5
progress
LeftofZen Mar 19, 2024
b79251d
Merge branch 'master' into avagui
LeftofZen Mar 22, 2024
3986ade
actually a partial working ui...
LeftofZen Mar 22, 2024
271f257
remove old ui experiments, get avagui working
LeftofZen Mar 22, 2024
49c135e
add treeview
LeftofZen Mar 23, 2024
823845f
get treeview showing icons
LeftofZen Mar 23, 2024
7aa4ec7
add vehicle icons, polish
LeftofZen Mar 23, 2024
01b5fc6
working view-per-object
LeftofZen Mar 25, 2024
9bcc4e2
try using propertygrid
LeftofZen Mar 25, 2024
4342ece
some kind of bastardized stringtable viewing
LeftofZen Mar 30, 2024
86892f4
dictioanry experimenting
LeftofZen Apr 17, 2024
28b99fa
add yet another avalonia experiment with datagrids. this one actually…
LeftofZen Apr 17, 2024
534a5a4
update packages
LeftofZen Apr 23, 2024
3f67bf3
working string table
LeftofZen Apr 23, 2024
214f4e3
progress
LeftofZen May 23, 2024
9404afc
also try maui again
LeftofZen May 24, 2024
bb63b77
working maui, avagui file viewer additions
LeftofZen May 28, 2024
f8a6c81
start menuing
LeftofZen May 28, 2024
14c1b0f
attempt to get menus working
LeftofZen May 30, 2024
a48afc2
add logging viewer
LeftofZen May 30, 2024
09b710f
fix menu bug
LeftofZen May 30, 2024
7289eab
Merge branch 'master' into avaguiexperimental
LeftofZen May 31, 2024
529bda5
fix old gui after merge
LeftofZen May 31, 2024
8a57c39
working avalonia image table
LeftofZen May 31, 2024
d61db15
Merge branch 'master' into avaguiexperimental
LeftofZen Jun 1, 2024
578a389
misc fixes, stop initialisation of null image table
LeftofZen Jun 1, 2024
a8eb71f
code warnings fixes
LeftofZen Jun 1, 2024
916ee08
Merge branch 'master' into avaguiexperimental
LeftofZen Jun 3, 2024
0eabcdc
remove outdated projects
LeftofZen Jun 3, 2024
026c0dd
at least display strings
LeftofZen Jun 3, 2024
99c329d
add support for displaying and loading object/data directories
LeftofZen Jun 23, 2024
30d3bbc
start work on new object format
LeftofZen Jun 23, 2024
77f93fd
start adding sc5/sv5 file support
LeftofZen Jun 23, 2024
bba9419
add gamestate object and work towards a workinf implementation
LeftofZen Jun 24, 2024
2daeb2a
more attributes
LeftofZen Jun 25, 2024
261daee
split sc/v file structs, undo uint index changes
LeftofZen Jun 25, 2024
6f72670
add working scv5 loading
LeftofZen Jun 25, 2024
17b6e25
sc/v5 parsing mostly works now
LeftofZen Jun 26, 2024
d88acc7
start using data templates for the object views
LeftofZen Jun 27, 2024
97938d9
cleanup repo
LeftofZen Jun 27, 2024
6a64dfb
add missing png assets to the repo
LeftofZen Jun 27, 2024
fdad5b6
re-enable images previously disabled
LeftofZen Jun 27, 2024
c53111f
add validate method to s5header
LeftofZen Jun 29, 2024
d128e86
working file->load dir
LeftofZen Jul 1, 2024
4cbbd47
add 'open settings folder' button', allow adding of new obj dirs
LeftofZen Jul 11, 2024
29d1f3f
add version checking
LeftofZen Jul 11, 2024
437581b
attempt to add delete objdir functionality but avalonia prevents it
LeftofZen Jul 11, 2024
7ccfa7a
small ui cleanups
LeftofZen Jul 11, 2024
f34bbd1
remove old avaguistringtable project
LeftofZen Jul 11, 2024
56dd6e4
add some UI tweaks
LeftofZen Jul 11, 2024
7db7e71
add object reload functionality, and pencil in save functionality
LeftofZen Jul 11, 2024
1294452
use expander for logs tab
LeftofZen Jul 16, 2024
061eda9
add image export and import
LeftofZen Jul 16, 2024
881ebe1
update some objects from openloco updates
LeftofZen Jul 18, 2024
f339249
fix bug in industry save
LeftofZen Jul 18, 2024
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
16 changes: 3 additions & 13 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ charset = utf-8
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_namespace_match_folder = true:suggestion

# C# files
[*.csproj]
Expand Down Expand Up @@ -421,18 +423,6 @@ dotnet_diagnostic.SA1602.severity = none
dotnet_diagnostic.SA1649.severity = none
dotnet_diagnostic.SA1633.severity = none

dotnet_diagnostic.WTG1001.severity = warning
dotnet_diagnostic.WTG1002.severity = warning
dotnet_diagnostic.WTG1011.severity = warning
dotnet_diagnostic.WTG1009.severity = none
dotnet_diagnostic.WTG1012.severity = warning
dotnet_diagnostic.WTG1013.severity = none
dotnet_diagnostic.WTG3001.severity = warning
dotnet_diagnostic.WTG3002.severity = warning
dotnet_diagnostic.WTG3003.severity = warning
dotnet_diagnostic.WTG3005.severity = warning
dotnet_diagnostic.WTG3006.severity = warning
dotnet_diagnostic.WTG3008.severity = warning
dotnet_diagnostic.WTG3011.severity = warning
dotnet_diagnostic.RCS1217.severity = none

dotnet_diagnostic.RS0030.severity = error
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,3 @@ MigrationBackup/

# MonoGame
*.xnb
*.png
17 changes: 17 additions & 0 deletions AvaGui/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AvaGui.App"
xmlns:local="using:AvaGui"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
</Application.Styles>

</Application>
29 changes: 29 additions & 0 deletions AvaGui/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using AvaGui.ViewModels;
using AvaGui.Views;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace AvaGui
{
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}

base.OnFrameworkInitializationCompleted();
}
}
}
Binary file added AvaGui/Assets/loco_icon.ico
Binary file not shown.
Binary file added AvaGui/Assets/loco_object_types_combined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AvaGui/Assets/loco_vehicle_types_combined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AvaGui/Assets/palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AvaGui/Assets/vanilla.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions AvaGui/AvaGui.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<StartupObject>AvaGui.Program</StartupObject>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>

<ItemGroup>
<None Remove="version.txt" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="version.txt" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.11" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.11" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.11" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.11" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.11" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.11" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.11" />
<PackageReference Include="bodong.Avalonia.PropertyGrid" Version="11.0.10.1" />
<PackageReference Include="bodong.PropertyModels" Version="11.0.10.1" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="ReactiveUI.Validation" Version="4.0.9" />
<PackageReference Include="Zenith.Core" Version="1.0.20" />
</ItemGroup>


<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>


<ItemGroup>
<Compile Update="Views\VehicleView.axaml.cs">
<DependentUpon>VehicleView.axaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions AvaGui/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ReactiveUI />
</Weavers>
26 changes: 26 additions & 0 deletions AvaGui/FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ReactiveUI" minOccurs="0" maxOccurs="1" type="xs:anyType" />
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
21 changes: 21 additions & 0 deletions AvaGui/Models/FileSystemItemGroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Avalonia;
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.Objects;
using System.Collections.ObjectModel;

namespace AvaGui.Models
{
public abstract record FileSystemItemBase(string Path, string Name, ObservableCollection<FileSystemItemBase>? SubNodes = null, PixelRect? SourceRect = null)
{
public string NameComputed
=> $"{Name}{(SubNodes == null ? string.Empty : $" ({SubNodes.Count})")}"; // nested interpolated string...what have i become
}

public record FileSystemItem(string Path, string Name, SourceGame SourceGame) : FileSystemItemBase(Path, Name, null, new PixelRect((int)SourceGame * 16, 0, 16, 16));

public record FileSystemItemGroup(string Path, ObjectType ObjectType, ObservableCollection<FileSystemItemBase> SubNodes, int SpriteOffsetIndex)
: FileSystemItemBase(Path, ObjectType.ToString(), SubNodes, new PixelRect(32 * SpriteOffsetIndex, 0, 32, 32));

public record FileSystemVehicleGroup(string Path, VehicleType VehicleType, ObservableCollection<FileSystemItemBase> SubNodes, int SpriteOffsetIndex)
: FileSystemItemBase(Path, VehicleType.ToString(), SubNodes, new PixelRect(32 * SpriteOffsetIndex, 0, 32, 32));
}
7 changes: 7 additions & 0 deletions AvaGui/Models/IUiObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System.ComponentModel;

namespace AvaGui.Models
{
[TypeConverter(typeof(ExpandableObjectConverter))]
public interface IUiObject { }
}
12 changes: 12 additions & 0 deletions AvaGui/Models/IUiObjectWithGraphics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using OpenLoco.ObjectEditor.Headers;
using System.Collections.Generic;
using System.ComponentModel;

namespace AvaGui.Models
{
[TypeConverter(typeof(TypeListConverter))]
public interface IUiObjectWithGraphics
{
public List<G1Element32> G1Elements { get; set; }
}
}
8 changes: 8 additions & 0 deletions AvaGui/Models/IndexObjectHeader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.Objects;
using System;

namespace AvaGui.Models
{
public record IndexObjectHeader(string Name, ObjectType ObjectType, SourceGame SourceGame, UInt32 Checksum, VehicleType? VehicleType);
}
29 changes: 29 additions & 0 deletions AvaGui/Models/LanguageTranslation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using OpenLoco.ObjectEditor.Data;
using ReactiveUI;

namespace AvaGui.Models
{
public class LanguageTranslation : ReactiveObject
{
public LanguageTranslation(LanguageId language, string translation)
{
_language = language;
_translation = translation;
}

private LanguageId _language;
public LanguageId Language
{
get => _language;
set => _ = this.RaiseAndSetIfChanged(ref _language, value);
}

private string _translation;

public string Translation
{
get => _translation;
set => _ = this.RaiseAndSetIfChanged(ref _translation, value);
}
}
}
33 changes: 33 additions & 0 deletions AvaGui/Models/NewObjectFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.Headers;
using OpenLoco.ObjectEditor.Types;
using System;
using System.Collections.Generic;

namespace AvaGui.Models
{
// no encoding - just zip the whole object if necessary
// no checksum - its now a json object, not binary
public class NewObjectFormat<T>
{
public string Name { get; set; }
public string Author { get; set; } // new
public string Version { get; set; } // author-specified version
public DateTimeOffset LastEdit { get; set; } // last-edited UTC date is an implicit version

public SourceGame SourceGame { get; set; }
public ObjectType ObjectType { get; set; }

// obect properties
public T Object { get; set; }

public StringTable StringTable { get; set; }
public NewImageTable ImageTable { get; set; }
}

public class NewImageTable
{
public IEnumerable<G1Element32> Elements { get; set; }
public IEnumerable<byte[]> ElementData { get; set; } // this will actually be base-64 encoded strings, not binary data
}
}
Loading
Loading