Skip to content

Commit 07074d4

Browse files
Merge pull request #301 from Pear-231/Updater
Updater localisation and window bugfix
2 parents a6abf0f + 3fff3c8 commit 07074d4

8 files changed

Lines changed: 352 additions & 171 deletions

File tree

AssetEditor/Language_En.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,11 @@
1111
"SettingsWindow.OnlyLoadLod0": "Only load Lod0 for reference meshes",
1212
"SettingsWindow.GridSize": "Grid Size",
1313
"SettingsWindow.AudioModding": "Audio Modding",
14-
"SettingsWindow.SaveButton": "Save"
14+
"SettingsWindow.SaveButton": "Save",
15+
16+
"UpdaterWindow.Title": "Updater",
17+
"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.",
18+
"UpdaterWindow.ReleaseNotes": "Release Notes",
19+
"UpdaterWindow.UpdateButton": "Update",
20+
"UpdaterWindow.CancelButton": "Cancel"
1521
}

AssetEditor/Themes/ControlColours.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@
264264
<SolidColorBrush x:Key="DataGrid.Row.Selected.Background" Color="{DynamicResource AColour.Tone6.Background.Selected}"/>
265265
<SolidColorBrush x:Key="DataGrid.CellItem.Static.Background" Color="{DynamicResource AColour.Tone6.Background.Static}"/>
266266
<SolidColorBrush x:Key="DataGrid.CellItem.MouseOver.Background" Color="{DynamicResource AColour.Tone6.Background.MouseOver}"/>
267+
268+
<SolidColorBrush x:Key="Markdown.Heading.Foreground" Color="{DynamicResource AColour.Foreground.Static}"/>
269+
<SolidColorBrush x:Key="Markdown.Hyperlink.Foreground" Color="{DynamicResource AColour.ColourfulGlyph.Static}"/>
270+
<SolidColorBrush x:Key="Markdown.Hyperlink.MouseOver.Foreground" Color="{DynamicResource AColour.ColourfulGlyph.MouseOver}"/>
271+
<SolidColorBrush x:Key="Markdown.Codeblock.Foregrond" Color="{DynamicResource AColour.AColour.Foreground.Static}"/>
272+
<SolidColorBrush x:Key="Markdown.Codeblock.Background" Color="{DynamicResource AColour.Tone6.Background.Static}"/>
273+
<SolidColorBrush x:Key="Markdown.Codeblock.Border" Color="{DynamicResource AColour.Tone6.Border.Static}"/>
274+
<SolidColorBrush x:Key="Markdown.Note.Background" Color="{DynamicResource AColour.Tone6.Background.Static}"/>
275+
<SolidColorBrush x:Key="Markdown.Note.Border" Color="{DynamicResource AColour.Tone6.Border.Static}"/>
267276

268277
<SolidColorBrush x:Key="Window.Static.Background" Color="{DynamicResource AColour.Tone3.Background.Static}"/>
269278
<SolidColorBrush x:Key="Window.Static.Border" Color="{DynamicResource AColour.Tone2.Background.Static}"/>

AssetEditor/Themes/Controls.xaml

Lines changed: 206 additions & 75 deletions
Large diffs are not rendered by default.

AssetEditor/ViewModels/UpdaterViewModel.cs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Collections.ObjectModel;
44
using System.Diagnostics;
55
using System.IO;
6-
using System.Text;
76
using CommunityToolkit.Mvvm.ComponentModel;
87
using CommunityToolkit.Mvvm.Input;
98
using Octokit;
@@ -17,39 +16,33 @@ namespace AssetEditor.ViewModels
1716
{
1817
public class ReleaseNoteItem(Release release)
1918
{
20-
public string ReleaseName { get; } = release.Name;
21-
public string PublishedAt { get; } = $"Published {release.PublishedAt.Value:dd MMM yyyy}";
19+
public string ReleaseName { get; } = $"## [{release.Name}]({release.HtmlUrl})";
20+
public string PublishedAt { get; } = $"{release.PublishedAt!.Value:dd MMM yyyy}";
2221
public string ReleaseNotes { get; } = release.Body;
2322
}
2423

25-
partial class UpdaterViewModel : ObservableObject
24+
public partial class UpdaterViewModel(LocalizationManager localisationManager) : ObservableObject
2625
{
26+
private readonly LocalizationManager _localisationManager = localisationManager;
27+
2728
private readonly ILogger _logger = Logging.Create<UpdaterViewModel>();
28-
private Action _closeAction;
29+
private Action? _closeAction;
2930

3031
private const string AssetEditorUpdaterExe = "AssetEditorUpdater.exe";
3132

3233
private List<Release> _newerReleases = [];
3334

3435
[ObservableProperty] private ObservableCollection<ReleaseNoteItem> _releaseNotesItems = [];
35-
36-
[ObservableProperty] private string _latestVersionInfo;
36+
[ObservableProperty] private string _updateInfo = string.Empty;
3737

3838
public void SetReleaseInfo(List<Release> newerReleases)
3939
{
4040
_newerReleases = newerReleases;
4141

42-
var currentVersion = VersionChecker.GetCurrentVersion();
4342
var latestRelease = _newerReleases[0];
4443
var latestVersion = VersionChecker.ParseReleaseVersion(latestRelease.TagName);
45-
46-
var stringBuilder = new StringBuilder();
47-
stringBuilder.AppendLine($"A new version of AssetEditor is available! The AssetEditor donkeys have been busy...");
48-
stringBuilder.AppendLine();
49-
stringBuilder.AppendLine($"Your current version is {currentVersion}. The latest verison is {latestVersion}.");
50-
stringBuilder.AppendLine();
51-
stringBuilder.AppendLine("Update to get the changes detailed in the release notes below.");
52-
LatestVersionInfo = stringBuilder.ToString();
44+
var currentVersion = VersionChecker.GetCurrentVersion();
45+
UpdateInfo = string.Format(_localisationManager.Get("UpdaterWindow.UpdateInfo"), currentVersion, latestVersion);
5346

5447
ReleaseNotesItems.Clear();
5548
foreach (var release in _newerReleases)

AssetEditor/Views/MainWindow.xaml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,32 @@
8989

9090
<Button
9191
Grid.Column="2"
92+
Width="46"
9293
Click="OnMinimizeButtonClick"
9394
Style="{StaticResource TitleBarButtonStyle}"
94-
ToolTip="Minimize">
95+
ToolTip="Minimise"
96+
VerticalAlignment="Stretch"
97+
Height="Auto">
9598
<Path
96-
Width="36"
99+
Width="46"
97100
Height="32"
98-
Data="M 13,15 H 23"
101+
Data="M 18,16 H 28"
99102
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
100103
StrokeThickness="1" />
101104
</Button>
102105

103106
<Button
104107
x:Name="maximizeRestoreButton"
105108
Grid.Column="3"
109+
Width="46"
106110
Click="OnMaximizeRestoreButtonClick"
107111
Style="{StaticResource TitleBarButtonStyle}"
108-
ToolTip="Maximize"
109-
ToolTipOpening="MaximizeRestoreButton_ToolTipOpening">
112+
ToolTip="Maximise"
113+
ToolTipOpening="MaximizeRestoreButton_ToolTipOpening"
114+
VerticalAlignment="Stretch"
115+
Height="Auto">
110116
<Path
111-
Width="36"
117+
Width="46"
112118
Height="32"
113119
Data="{Binding ElementName=window, Path=WindowState, Converter={StaticResource windowStateToPathConverter}}"
114120
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
@@ -117,13 +123,16 @@
117123

118124
<Button
119125
Grid.Column="4"
126+
Width="46"
120127
Click="OnCloseButtonClick"
121128
Style="{StaticResource TitleBarCloseButtonStyle}"
122-
ToolTip="Close">
129+
ToolTip="Close"
130+
VerticalAlignment="Stretch"
131+
Height="Auto">
123132
<Path
124-
Width="36"
133+
Width="46"
125134
Height="32"
126-
Data="M 13,11 22,20 M 13,20 22,11"
135+
Data="M 18.5,11 27.5,20 M 18.5,20 27.5,11"
127136
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
128137
StrokeThickness="1" />
129138
</Button>
@@ -215,15 +224,13 @@
215224
</Style>
216225
</TextBlock.Style>
217226
</TextBlock>
218-
<Button Margin="4,0,-4,0" Grid.Column="1"
219-
Command="{Binding DataContext.CloseToolCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl}}"
220-
CommandParameter="{Binding}"
221-
HorizontalContentAlignment="Right"
222-
Content="{materialIcons:MaterialIconExt Kind=CloseThick, Size=13 }">
223-
224-
225-
226-
227+
<Button
228+
Margin="4,0,-4,0"
229+
Grid.Column="1"
230+
Command="{Binding DataContext.CloseToolCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl}}"
231+
CommandParameter="{Binding}"
232+
HorizontalContentAlignment="Right"
233+
Content="{materialIcons:MaterialIconExt Kind=CloseThick, Size=13 }">
227234
</Button>
228235
</Grid>
229236
</DataTemplate>

AssetEditor/Views/Updater/UpdaterWindow.xaml

Lines changed: 52 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:Localisation="clr-namespace:Shared.Ui.Common;assembly=Shared.Ui"
78
xmlns:Updater="clr-namespace:AssetEditor.Views.Updater"
89
xmlns:MdXaml="clr-namespace:MdXaml;assembly=MdXaml"
910
xmlns:ViewModels="clr-namespace:AssetEditor.ViewModels"
@@ -13,9 +14,9 @@
1314
Closed="OnClosed"
1415
ResizeMode="NoResize"
1516
WindowStartupLocation="CenterScreen"
16-
Height="545"
17-
Width="800"
18-
Title="Asset Editor Updater">
17+
SizeToContent="Height"
18+
Width="1000"
19+
Title="{Localisation:Loc UpdaterWindow.Title}">
1920

2021
<Grid
2122
Margin="15, 15, 15, 15">
@@ -29,90 +30,82 @@
2930
Height="Auto"/>
3031
<RowDefinition
3132
Height="Auto"/>
32-
<RowDefinition
33-
Height="Auto"/>
3433
</Grid.RowDefinitions>
3534

3635
<TextBlock
3736
Grid.Row="0"
38-
Text="{Binding LatestVersionInfo}"
37+
Text="{Binding UpdateInfo}"
38+
Margin="0, 0, 0, 20"
3939
FontSize="14"/>
4040

4141
<TextBlock
4242
Grid.Row="1"
43-
Text="Release Notes"
43+
Text="{Localisation:Loc UpdaterWindow.ReleaseNotes}"
44+
Margin="0, 0, 0, 10"
4445
FontSize="20"
4546
FontWeight="SemiBold"/>
4647

47-
<Border
48+
<ScrollViewer
4849
Grid.Row="2"
49-
BorderThickness="1"
50-
BorderBrush="{DynamicResource App.Border}"
51-
Margin="0, 10, 0, 0"
52-
Height="300">
53-
54-
<ScrollViewer
55-
VerticalScrollBarVisibility="Auto"
56-
Padding="10, 10, 10, 10">
57-
58-
<ItemsControl
59-
ItemsSource="{Binding ReleaseNotesItems}">
60-
<ItemsControl.ItemTemplate>
61-
<DataTemplate>
62-
<Border
63-
Padding="0, 0, 0, 20">
64-
<StackPanel>
50+
VerticalScrollBarVisibility="Auto"
51+
MaxHeight="400"
52+
Padding="0">
6553

66-
<TextBlock
67-
Text="{Binding ReleaseName}"
68-
FontSize="18"
69-
FontWeight="SemiBold"/>
54+
<ItemsControl
55+
ItemsSource="{Binding ReleaseNotesItems}">
56+
<ItemsControl.ItemTemplate>
57+
<DataTemplate>
58+
<Border
59+
BorderThickness="1"
60+
BorderBrush="{DynamicResource App.Border}"
61+
Margin="0, 0, 10, 10"
62+
Padding="20, 10, 10, 20">
7063

71-
<TextBlock
72-
Margin="0,4,0,12"
73-
Text="{Binding PublishedAt}"
74-
FontSize="14"/>
64+
<!-- Disable VerticalScrollBarVisibility as we don't won't loads of mini scroll viewers... -->
65+
<StackPanel>
66+
<MdXaml:MarkdownScrollViewer
67+
Markdown="{Binding ReleaseName}"
68+
VerticalScrollBarVisibility="Disabled"
69+
ClickAction="OpenBrowser"
70+
MarkdownStyle="{StaticResource CustomMarkdownStyle}"
71+
PreviewMouseWheel="OnMarkdownScrollViewerPreviewMouseWheel"/>
7572

76-
<!-- Disable VerticalScrollBarVisibility as we don't won't loads of mini scroll viewers... -->
77-
<MdXaml:MarkdownScrollViewer
78-
Markdown="{Binding ReleaseNotes}"
79-
VerticalAlignment="Stretch"
80-
HorizontalAlignment="Stretch"
81-
VerticalScrollBarVisibility="Disabled"
82-
PreviewMouseWheel="OnMarkdownScrollViewerPreviewMouseWheel">
73+
<MdXaml:MarkdownScrollViewer
74+
Markdown="{Binding PublishedAt}"
75+
VerticalScrollBarVisibility="Disabled"
76+
MarkdownStyle="{StaticResource CustomMarkdownStyle}"
77+
PreviewMouseWheel="OnMarkdownScrollViewerPreviewMouseWheel"/>
8378

84-
<MdXaml:MarkdownScrollViewer.Resources>
85-
<Style
86-
TargetType="{x:Type List}">
87-
<Setter
88-
Property="FontSize"
89-
Value="14"/>
90-
</Style>
91-
</MdXaml:MarkdownScrollViewer.Resources>
92-
</MdXaml:MarkdownScrollViewer>
93-
</StackPanel>
94-
</Border>
95-
</DataTemplate>
96-
</ItemsControl.ItemTemplate>
97-
</ItemsControl>
98-
</ScrollViewer>
99-
</Border>
79+
<MdXaml:MarkdownScrollViewer
80+
Markdown="{Binding ReleaseNotes}"
81+
VerticalAlignment="Stretch"
82+
HorizontalAlignment="Stretch"
83+
VerticalScrollBarVisibility="Disabled"
84+
MarkdownStyle="{StaticResource CustomMarkdownStyle}"
85+
PreviewMouseWheel="OnMarkdownScrollViewerPreviewMouseWheel"
86+
Loaded="OnMarkdownScrollViewerLoaded"/>
87+
</StackPanel>
88+
</Border>
89+
</DataTemplate>
90+
</ItemsControl.ItemTemplate>
91+
</ItemsControl>
92+
</ScrollViewer>
10093

10194
<StackPanel
102-
Grid.Row="3"
95+
Grid.Row="3"
10396
Orientation="Horizontal"
10497
HorizontalAlignment="Right"
105-
Margin="10, 10, 0, 10">
98+
Margin="10, 10, 0, 0">
10699

107100
<Button
108-
Content="Update"
101+
Content="{Localisation:Loc UpdaterWindow.UpdateButton}"
109102
Width="75"
110103
Height="25"
111104
Margin="0, 0, 5, 0"
112105
Command="{Binding UpdateCommand}"/>
113106

114107
<Button
115-
Content="Cancel"
108+
Content="{Localisation:Loc UpdaterWindow.CancelButton}"
116109
Width="75"
117110
Margin="5, 0, 0, 0"
118111
Command="{Binding CloseWindowActionCommand}"/>

AssetEditor/Views/Updater/UpdaterWindow.xaml.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using System.Windows;
33
using System.Windows.Controls;
4+
using System.Windows.Documents;
45
using System.Windows.Input;
56
using System.Windows.Media;
67
using AssetEditor.ViewModels;
8+
using MdXaml;
79

810
namespace AssetEditor.Views.Updater
911
{
@@ -51,6 +53,46 @@ private void OnWindowLoaded(object sender, RoutedEventArgs e)
5153
viewModel.SetCloseAction(this.Close);
5254
}
5355

56+
private void OnMarkdownScrollViewerLoaded(object sender, RoutedEventArgs e)
57+
{
58+
if (sender is not MarkdownScrollViewer markdownScrollViewer)
59+
return;
60+
61+
var flowDocument = markdownScrollViewer.Document;
62+
if (flowDocument == null)
63+
return;
64+
65+
// We format the list manually as the Controls.xaml doesn't let you set MarkerStyle
66+
// and the spacing before the list is too big but changing the margin of paragraph
67+
// in Controls.xaml changes all blocks rather than just the block for lists.
68+
FormatList(flowDocument);
69+
}
70+
71+
private static void FormatList(FlowDocument flowDocument)
72+
{
73+
var currentBlock = flowDocument.Blocks.FirstBlock;
74+
75+
while (currentBlock != null)
76+
{
77+
var nextBlock = currentBlock.NextBlock;
78+
79+
if (currentBlock is List list)
80+
{
81+
list.MarkerStyle = TextMarkerStyle.Disc;
82+
list.Margin = new Thickness(0);
83+
list.Padding = new Thickness(list.Padding.Left, 0, list.Padding.Right, 0);
84+
85+
if (list.ListItems.FirstListItem?.Blocks.FirstBlock is Paragraph firstParagraph)
86+
firstParagraph.Margin = new Thickness(firstParagraph.Margin.Left, 10, firstParagraph.Margin.Right, firstParagraph.Margin.Bottom);
87+
}
88+
89+
if (currentBlock is Paragraph paragraph && nextBlock is List)
90+
paragraph.Margin = new Thickness(paragraph.Margin.Left, paragraph.Margin.Top, paragraph.Margin.Right, 0);
91+
92+
currentBlock = nextBlock;
93+
}
94+
}
95+
5496
private void OnClosed(object sender, EventArgs e)
5597
{
5698
if (DataContext is UpdaterViewModel viewModel)

0 commit comments

Comments
 (0)