Skip to content
Merged
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
8 changes: 7 additions & 1 deletion AssetEditor/Language_En.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
"SettingsWindow.OnlyLoadLod0": "Only load Lod0 for reference meshes",
"SettingsWindow.GridSize": "Grid Size",
"SettingsWindow.AudioModding": "Audio Modding",
"SettingsWindow.SaveButton": "Save"
"SettingsWindow.SaveButton": "Save",

"UpdaterWindow.Title": "Updater",
"UpdaterWindow.UpdateInfo": "A new version of AssetEditor is available!\n\nYour current version is {0}. Update to version {1} to get the latest changes detailed below.",
"UpdaterWindow.ReleaseNotes": "Release Notes",
"UpdaterWindow.UpdateButton": "Update",
"UpdaterWindow.CancelButton": "Cancel"
}
9 changes: 9 additions & 0 deletions AssetEditor/Themes/ControlColours.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@
<SolidColorBrush x:Key="DataGrid.Row.Selected.Background" Color="{DynamicResource AColour.Tone6.Background.Selected}"/>
<SolidColorBrush x:Key="DataGrid.CellItem.Static.Background" Color="{DynamicResource AColour.Tone6.Background.Static}"/>
<SolidColorBrush x:Key="DataGrid.CellItem.MouseOver.Background" Color="{DynamicResource AColour.Tone6.Background.MouseOver}"/>

<SolidColorBrush x:Key="Markdown.Heading.Foreground" Color="{DynamicResource AColour.Foreground.Static}"/>
<SolidColorBrush x:Key="Markdown.Hyperlink.Foreground" Color="{DynamicResource AColour.ColourfulGlyph.Static}"/>
<SolidColorBrush x:Key="Markdown.Hyperlink.MouseOver.Foreground" Color="{DynamicResource AColour.ColourfulGlyph.MouseOver}"/>
<SolidColorBrush x:Key="Markdown.Codeblock.Foregrond" Color="{DynamicResource AColour.AColour.Foreground.Static}"/>
<SolidColorBrush x:Key="Markdown.Codeblock.Background" Color="{DynamicResource AColour.Tone6.Background.Static}"/>
<SolidColorBrush x:Key="Markdown.Codeblock.Border" Color="{DynamicResource AColour.Tone6.Border.Static}"/>
<SolidColorBrush x:Key="Markdown.Note.Background" Color="{DynamicResource AColour.Tone6.Background.Static}"/>
<SolidColorBrush x:Key="Markdown.Note.Border" Color="{DynamicResource AColour.Tone6.Border.Static}"/>

<SolidColorBrush x:Key="Window.Static.Background" Color="{DynamicResource AColour.Tone3.Background.Static}"/>
<SolidColorBrush x:Key="Window.Static.Border" Color="{DynamicResource AColour.Tone2.Background.Static}"/>
Expand Down
281 changes: 206 additions & 75 deletions AssetEditor/Themes/Controls.xaml

Large diffs are not rendered by default.

25 changes: 9 additions & 16 deletions AssetEditor/ViewModels/UpdaterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Text;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Octokit;
Expand All @@ -17,39 +16,33 @@ namespace AssetEditor.ViewModels
{
public class ReleaseNoteItem(Release release)
{
public string ReleaseName { get; } = release.Name;
public string PublishedAt { get; } = $"Published {release.PublishedAt.Value:dd MMM yyyy}";
public string ReleaseName { get; } = $"## [{release.Name}]({release.HtmlUrl})";
public string PublishedAt { get; } = $"{release.PublishedAt!.Value:dd MMM yyyy}";
public string ReleaseNotes { get; } = release.Body;
}

partial class UpdaterViewModel : ObservableObject
public partial class UpdaterViewModel(LocalizationManager localisationManager) : ObservableObject
{
private readonly LocalizationManager _localisationManager = localisationManager;

private readonly ILogger _logger = Logging.Create<UpdaterViewModel>();
private Action _closeAction;
private Action? _closeAction;

private const string AssetEditorUpdaterExe = "AssetEditorUpdater.exe";

private List<Release> _newerReleases = [];

[ObservableProperty] private ObservableCollection<ReleaseNoteItem> _releaseNotesItems = [];

[ObservableProperty] private string _latestVersionInfo;
[ObservableProperty] private string _updateInfo = string.Empty;

public void SetReleaseInfo(List<Release> newerReleases)
{
_newerReleases = newerReleases;

var currentVersion = VersionChecker.GetCurrentVersion();
var latestRelease = _newerReleases[0];
var latestVersion = VersionChecker.ParseReleaseVersion(latestRelease.TagName);

var stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"A new version of AssetEditor is available! The AssetEditor donkeys have been busy...");
stringBuilder.AppendLine();
stringBuilder.AppendLine($"Your current version is {currentVersion}. The latest verison is {latestVersion}.");
stringBuilder.AppendLine();
stringBuilder.AppendLine("Update to get the changes detailed in the release notes below.");
LatestVersionInfo = stringBuilder.ToString();
var currentVersion = VersionChecker.GetCurrentVersion();
UpdateInfo = string.Format(_localisationManager.Get("UpdaterWindow.UpdateInfo"), currentVersion, latestVersion);

ReleaseNotesItems.Clear();
foreach (var release in _newerReleases)
Expand Down
43 changes: 25 additions & 18 deletions AssetEditor/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,32 @@

<Button
Grid.Column="2"
Width="46"
Click="OnMinimizeButtonClick"
Style="{StaticResource TitleBarButtonStyle}"
ToolTip="Minimize">
ToolTip="Minimise"
VerticalAlignment="Stretch"
Height="Auto">
<Path
Width="36"
Width="46"
Height="32"
Data="M 13,15 H 23"
Data="M 18,16 H 28"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1" />
</Button>

<Button
x:Name="maximizeRestoreButton"
Grid.Column="3"
Width="46"
Click="OnMaximizeRestoreButtonClick"
Style="{StaticResource TitleBarButtonStyle}"
ToolTip="Maximize"
ToolTipOpening="MaximizeRestoreButton_ToolTipOpening">
ToolTip="Maximise"
ToolTipOpening="MaximizeRestoreButton_ToolTipOpening"
VerticalAlignment="Stretch"
Height="Auto">
<Path
Width="36"
Width="46"
Height="32"
Data="{Binding ElementName=window, Path=WindowState, Converter={StaticResource windowStateToPathConverter}}"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
Expand All @@ -117,13 +123,16 @@

<Button
Grid.Column="4"
Width="46"
Click="OnCloseButtonClick"
Style="{StaticResource TitleBarCloseButtonStyle}"
ToolTip="Close">
ToolTip="Close"
VerticalAlignment="Stretch"
Height="Auto">
<Path
Width="36"
Width="46"
Height="32"
Data="M 13,11 22,20 M 13,20 22,11"
Data="M 18.5,11 27.5,20 M 18.5,20 27.5,11"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1" />
</Button>
Expand Down Expand Up @@ -215,15 +224,13 @@
</Style>
</TextBlock.Style>
</TextBlock>
<Button Margin="4,0,-4,0" Grid.Column="1"
Command="{Binding DataContext.CloseToolCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl}}"
CommandParameter="{Binding}"
HorizontalContentAlignment="Right"
Content="{materialIcons:MaterialIconExt Kind=CloseThick, Size=13 }">




<Button
Margin="4,0,-4,0"
Grid.Column="1"
Command="{Binding DataContext.CloseToolCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl}}"
CommandParameter="{Binding}"
HorizontalContentAlignment="Right"
Content="{materialIcons:MaterialIconExt Kind=CloseThick, Size=13 }">
</Button>
</Grid>
</DataTemplate>
Expand Down
111 changes: 52 additions & 59 deletions AssetEditor/Views/Updater/UpdaterWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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:Localisation="clr-namespace:Shared.Ui.Common;assembly=Shared.Ui"
xmlns:Updater="clr-namespace:AssetEditor.Views.Updater"
xmlns:MdXaml="clr-namespace:MdXaml;assembly=MdXaml"
xmlns:ViewModels="clr-namespace:AssetEditor.ViewModels"
Expand All @@ -13,9 +14,9 @@
Closed="OnClosed"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Height="545"
Width="800"
Title="Asset Editor Updater">
SizeToContent="Height"
Width="1000"
Title="{Localisation:Loc UpdaterWindow.Title}">

<Grid
Margin="15, 15, 15, 15">
Expand All @@ -29,90 +30,82 @@
Height="Auto"/>
<RowDefinition
Height="Auto"/>
<RowDefinition
Height="Auto"/>
</Grid.RowDefinitions>

<TextBlock
Grid.Row="0"
Text="{Binding LatestVersionInfo}"
Text="{Binding UpdateInfo}"
Margin="0, 0, 0, 20"
FontSize="14"/>

<TextBlock
Grid.Row="1"
Text="Release Notes"
Text="{Localisation:Loc UpdaterWindow.ReleaseNotes}"
Margin="0, 0, 0, 10"
FontSize="20"
FontWeight="SemiBold"/>

<Border
<ScrollViewer
Grid.Row="2"
BorderThickness="1"
BorderBrush="{DynamicResource App.Border}"
Margin="0, 10, 0, 0"
Height="300">

<ScrollViewer
VerticalScrollBarVisibility="Auto"
Padding="10, 10, 10, 10">

<ItemsControl
ItemsSource="{Binding ReleaseNotesItems}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
Padding="0, 0, 0, 20">
<StackPanel>
VerticalScrollBarVisibility="Auto"
MaxHeight="400"
Padding="0">

<TextBlock
Text="{Binding ReleaseName}"
FontSize="18"
FontWeight="SemiBold"/>
<ItemsControl
ItemsSource="{Binding ReleaseNotesItems}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
BorderThickness="1"
BorderBrush="{DynamicResource App.Border}"
Margin="0, 0, 10, 10"
Padding="20, 10, 10, 20">

<TextBlock
Margin="0,4,0,12"
Text="{Binding PublishedAt}"
FontSize="14"/>
<!-- Disable VerticalScrollBarVisibility as we don't won't loads of mini scroll viewers... -->
<StackPanel>
<MdXaml:MarkdownScrollViewer
Markdown="{Binding ReleaseName}"
VerticalScrollBarVisibility="Disabled"
ClickAction="OpenBrowser"
MarkdownStyle="{StaticResource CustomMarkdownStyle}"
PreviewMouseWheel="OnMarkdownScrollViewerPreviewMouseWheel"/>

<!-- Disable VerticalScrollBarVisibility as we don't won't loads of mini scroll viewers... -->
<MdXaml:MarkdownScrollViewer
Markdown="{Binding ReleaseNotes}"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
VerticalScrollBarVisibility="Disabled"
PreviewMouseWheel="OnMarkdownScrollViewerPreviewMouseWheel">
<MdXaml:MarkdownScrollViewer
Markdown="{Binding PublishedAt}"
VerticalScrollBarVisibility="Disabled"
MarkdownStyle="{StaticResource CustomMarkdownStyle}"
PreviewMouseWheel="OnMarkdownScrollViewerPreviewMouseWheel"/>

<MdXaml:MarkdownScrollViewer.Resources>
<Style
TargetType="{x:Type List}">
<Setter
Property="FontSize"
Value="14"/>
</Style>
</MdXaml:MarkdownScrollViewer.Resources>
</MdXaml:MarkdownScrollViewer>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
<MdXaml:MarkdownScrollViewer
Markdown="{Binding ReleaseNotes}"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
VerticalScrollBarVisibility="Disabled"
MarkdownStyle="{StaticResource CustomMarkdownStyle}"
PreviewMouseWheel="OnMarkdownScrollViewerPreviewMouseWheel"
Loaded="OnMarkdownScrollViewerLoaded"/>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>

<StackPanel
Grid.Row="3"
Grid.Row="3"
Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="10, 10, 0, 10">
Margin="10, 10, 0, 0">

<Button
Content="Update"
Content="{Localisation:Loc UpdaterWindow.UpdateButton}"
Width="75"
Height="25"
Margin="0, 0, 5, 0"
Command="{Binding UpdateCommand}"/>

<Button
Content="Cancel"
Content="{Localisation:Loc UpdaterWindow.CancelButton}"
Width="75"
Margin="5, 0, 0, 0"
Command="{Binding CloseWindowActionCommand}"/>
Expand Down
42 changes: 42 additions & 0 deletions AssetEditor/Views/Updater/UpdaterWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using AssetEditor.ViewModels;
using MdXaml;

namespace AssetEditor.Views.Updater
{
Expand Down Expand Up @@ -51,6 +53,46 @@ private void OnWindowLoaded(object sender, RoutedEventArgs e)
viewModel.SetCloseAction(this.Close);
}

private void OnMarkdownScrollViewerLoaded(object sender, RoutedEventArgs e)
{
if (sender is not MarkdownScrollViewer markdownScrollViewer)
return;

var flowDocument = markdownScrollViewer.Document;
if (flowDocument == null)
return;

// We format the list manually as the Controls.xaml doesn't let you set MarkerStyle
// and the spacing before the list is too big but changing the margin of paragraph
// in Controls.xaml changes all blocks rather than just the block for lists.
FormatList(flowDocument);
}

private static void FormatList(FlowDocument flowDocument)
{
var currentBlock = flowDocument.Blocks.FirstBlock;

while (currentBlock != null)
{
var nextBlock = currentBlock.NextBlock;

if (currentBlock is List list)
{
list.MarkerStyle = TextMarkerStyle.Disc;
list.Margin = new Thickness(0);
list.Padding = new Thickness(list.Padding.Left, 0, list.Padding.Right, 0);

if (list.ListItems.FirstListItem?.Blocks.FirstBlock is Paragraph firstParagraph)
firstParagraph.Margin = new Thickness(firstParagraph.Margin.Left, 10, firstParagraph.Margin.Right, firstParagraph.Margin.Bottom);
}

if (currentBlock is Paragraph paragraph && nextBlock is List)
paragraph.Margin = new Thickness(paragraph.Margin.Left, paragraph.Margin.Top, paragraph.Margin.Right, 0);

currentBlock = nextBlock;
}
}

private void OnClosed(object sender, EventArgs e)
{
if (DataContext is UpdaterViewModel viewModel)
Expand Down
Loading
Loading