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
74 changes: 66 additions & 8 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,74 @@ jobs:
date_stamp="$(date -u +%Y%m%d)"
default_tag_name="pre-${date_stamp}"

latest_stable_tag="$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n 1)"
if [[ -z "${latest_stable_tag}" ]]; then
base_version="0.1.0"
else
base_version="${latest_stable_tag#v}"
# Every tag that carries a semver version: stable vX.Y.Z and plain
# semver pre-releases such as 3.0.0-rc2. Tags like pre-YYYYMMDD do not
# encode a version and are intentionally ignored (their versions never
# exceed the stable-based auto line).
all_versions="$(
git tag -l \
| sed -E 's/^v//' \
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$' \
| sort -u || true
)"

latest_stable_base="$(
printf '%s\n' "${all_versions}" \
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \
| sort -V | tail -n 1 || true
)"

latest_prerelease_base="$(
printf '%s\n' "${all_versions}" \
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+-' \
| sed -E 's/-.*$//' \
| sort -V | tail -n 1 || true
)"

# An unreleased line is "in progress" when its base is newer than the
# latest stable, e.g. 3.0.0-rc2 while the latest stable is v2.7.2.
active_line=""
if [[ -n "${latest_prerelease_base}" ]]; then
newest_base="$(printf '%s\n%s\n' "${latest_stable_base:-0.0.0}" "${latest_prerelease_base}" | sort -V | tail -n 1)"
if [[ "${newest_base}" == "${latest_prerelease_base}" && "${latest_prerelease_base}" != "${latest_stable_base}" ]]; then
active_line="${latest_prerelease_base}"
fi
fi

IFS='.' read -r major minor patch <<< "${base_version}"
next_patch=$((patch + 1))
default_next_version="${major}.${minor}.${next_patch}-pre.${date_stamp}"
if [[ -n "${active_line}" ]]; then
# Continue the in-progress line with a date-stamped release candidate.
# The date keeps it ordering above the previous candidate
# (3.0.0-rc3.20260917 > 3.0.0-rc2) while still allowing only one
# pre-release per day; the tag always equals the version so the next
# run can detect it again.
escaped_line="${active_line//./\\.}"
highest_pre="$(printf '%s\n' "${all_versions}" | grep -E "^${escaped_line}-" | sort -V | tail -n 1)"
suffix="${highest_pre#${active_line}-}"
rc_number=""

if [[ "${suffix}" =~ ^rc([0-9]+)$ ]]; then
# Manually cut candidate (e.g. rc2) -> start the next one (rc3).
rc_number=$(( BASH_REMATCH[1] + 1 ))
elif [[ "${suffix}" =~ ^rc([0-9]+)\. ]]; then
# Date-stamped candidate (e.g. rc3.20260917) -> keep the same
# candidate number and just refresh the date.
rc_number="${BASH_REMATCH[1]}"
else
highest_rc="$(printf '%s\n' "${all_versions}" | grep -Eo "^${escaped_line}-rc[0-9]+" | grep -Eo '[0-9]+$' | sort -n | tail -n 1 || true)"
rc_number=$(( ${highest_rc:-0} + 1 ))
fi

default_next_version="${active_line}-rc${rc_number}.${date_stamp}"
default_tag_name="${default_next_version}"
else
if [[ -z "${latest_stable_base}" ]]; then
latest_stable_base="0.1.0"
fi

IFS='.' read -r major minor patch <<< "${latest_stable_base}"
next_patch=$((patch + 1))
default_next_version="${major}.${minor}.${next_patch}-pre.${date_stamp}"
fi

tag_name="${default_tag_name}"
next_version="${default_next_version}"
Expand Down
6 changes: 3 additions & 3 deletions MapWizard.Desktop/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
xmlns:local="clr-namespace:MapWizard.Desktop"
xmlns:mapWizardTheme="clr-namespace:MapWizard.Theme;assembly=MapWizard.Theme"
xmlns:converters="clr-namespace:MapWizard.Desktop.Converters"
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
x:Class="MapWizard.Desktop.App">

<Application.DataTemplates>
Expand All @@ -15,8 +14,6 @@
<FluentTheme />
<StyleInclude Source="avares://Avalonia.Controls.ColorPicker/Themes/Fluent/Fluent.xaml" />
<mapWizardTheme:MapWizardTheme />
<materialIcons:MaterialIconStyles />

<!-- Desktop interaction states should respond immediately. -->
<Style Selector="Button, ToggleButton, ListBoxItem, ComboBoxItem, MenuItem, TabItem, TreeViewItem">
<Setter Property="Transitions"><Transitions /></Setter>
Expand All @@ -25,6 +22,9 @@

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="avares://MapWizard.Desktop/Assets/BrandIcons.axaml" />
</ResourceDictionary.MergedDictionaries>
<converters:IndexToTransformConverter x:Key="IndexToTransformConverter" />
<!-- ThemeService populates these dictionaries from MapWizard.Theme palettes. -->
<ResourceDictionary.ThemeDictionaries>
Expand Down
239 changes: 0 additions & 239 deletions MapWizard.Desktop/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
using Avalonia.Threading;
using Avalonia.VisualTree;
using MapWizard.Desktop.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using MapWizard.Desktop.Controls;
using MapWizard.Desktop.DependencyInjection;
using MapWizard.Desktop.Services;
using MapWizard.Desktop.Views;
Expand Down Expand Up @@ -42,8 +40,6 @@ public override void OnFrameworkInitializationCompleted()
{
var services = _services ?? throw new InvalidOperationException("Application services were not initialized.");
var mainWindow = services.GetRequiredService<MainWindow>();
// Defer the startup update check until the window is open so that the
// modal host is live; otherwise the update modal falls back to a toast.
mainWindow.Opened += (_, _) => mainWindow.GetViewModel().RequestStartupUpdateCheck();

switch (ApplicationLifetime)
Expand All @@ -57,240 +53,5 @@ public override void OnFrameworkInitializationCompleted()
}

base.OnFrameworkInitializationCompleted();
RunResizeProbe();
RunChromeProbe();
}

/// <summary>
/// Prints title-bar control geometry for chrome alignment debugging.
/// Enable with MAPWIZARD_CHROME_PROBE=1.
/// </summary>
private static void RunChromeProbe()
{
if (Environment.GetEnvironmentVariable("MAPWIZARD_CHROME_PROBE") != "1" ||
Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
desktop.MainWindow is not Views.MainWindow window)
{
return;
}

void Dump()
{
Console.WriteLine("== chrome probe ==");
foreach (var scrollBar in window.GetVisualDescendants().OfType<ScrollBar>())
{
var b = scrollBar.TranslatePoint(new Point(0, 0), window) ?? default;
var owner = scrollBar.GetVisualAncestors().OfType<Control>().Take(3)
.Select(c => c.GetType().Name + (c.Classes.Count > 0 ? $"[{string.Join("+", c.Classes)}]" : null));
Console.WriteLine(
$"scrollbar {scrollBar.Orientation} pos={b.X:F2},{b.Y:F2} size={scrollBar.Bounds.Width:F2}x{scrollBar.Bounds.Height:F2} chain={string.Join(" -> ", owner)}");
}

Console.WriteLine($"window pos={window.Position.X}x{window.Position.Y} size={window.Bounds.Width:F2}x{window.Bounds.Height:F2}");
foreach (var border in window.GetVisualDescendants().OfType<Border>()
.Where(b => b.Classes.Contains("ContentIsland")))
{
var o = border.TranslatePoint(new Point(0, 0), window) ?? default;
Console.WriteLine($"contentIsland pos={o.X:F2},{o.Y:F2} size={border.Bounds.Width:F2}x{border.Bounds.Height:F2} clip={border.ClipToBounds}");
}

foreach (var viewer in window.GetVisualDescendants().OfType<SmoothScrollViewer>())
{
var o = viewer.TranslatePoint(new Point(0, 0), window) ?? default;
Console.WriteLine($"smoothViewer pos={o.X:F2},{o.Y:F2} size={viewer.Bounds.Width:F2}x{viewer.Bounds.Height:F2}");
}
Console.WriteLine(" scrollbar dump end.");
foreach (var button in window.GetVisualDescendants().OfType<Avalonia.Controls.Primitives.TemplatedControl>())
{
if (!button.Classes.Contains("WindowControlButton") &&
!button.Classes.Contains("TitleBarActionButton"))
{
continue;
}

var origin = button.TranslatePoint(new Point(0, 0), window) ?? default;
Console.WriteLine(
$"{string.Join("+", button.Classes)} pos={origin.X:F1},{origin.Y:F1} size={button.Bounds.Width:F1}x{button.Bounds.Height:F1}");

foreach (var child in button.GetVisualDescendants().OfType<Visual>())
{
if (child is not Avalonia.Controls.Shapes.Path || child.Bounds.Size.Width == 0)
{
continue;
}

var childPos = child.TranslatePoint(new Point(0, 0), button) ?? default;
Console.WriteLine(
$" path pos={childPos.X:F1},{childPos.Y:F1} size={child.Bounds.Width:F1}x{child.Bounds.Height:F1}");
}
}

foreach (var border in window.GetVisualDescendants().OfType<Border>()
.Where(b => b.Classes.Contains("TitleBarIsland")))
{
var origin = border.TranslatePoint(new Point(0, 0), window) ?? default;
Console.WriteLine(
$"island pos={origin.X:F1},{origin.Y:F1} size={border.Bounds.Width:F1}x{border.Bounds.Height:F1}");
}
}

window.Opened += (_, _) => DispatcherTimer.RunOnce(() =>
{
var page = Environment.GetEnvironmentVariable("MAPWIZARD_RESIZE_PROBE_PAGE");
if (!string.IsNullOrEmpty(page))
{
switch (page.ToLowerInvariant())
{
case "hitsoundcopier": window.NavigateToHitSoundCopier(); break;
case "metadata": window.NavigateToMetadataManager(); break;
case "colourstudio": window.NavigateToComboColourStudio(); break;
case "settings": window.NavigateToSettings(); break;
default: break;
}
}

DispatcherTimer.RunOnce(Dump, TimeSpan.FromMilliseconds(400));
}, TimeSpan.FromMilliseconds(600));
}

private static void RunResizeProbe()
{
if (Environment.GetEnvironmentVariable("MAPWIZARD_RESIZE_PROBE") != "1" ||
Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
desktop.MainWindow is not { } window)
{
return;
}

DispatcherTimer.RunOnce(
() =>
{
var flags = (Environment.GetEnvironmentVariable("MAPWIZARD_RESIZE_PROBE_FLAGS") ?? string.Empty)
.Split(',', StringSplitOptions.RemoveEmptyEntries);

if (flags.Contains("nomask"))
{
foreach (var viewer in window.GetVisualDescendants().OfType<SmoothScrollViewer>())
{
viewer.IsScrollFadeEnabled = false;
}
}

if (flags.Contains("noshadow"))
{
foreach (var border in window.GetVisualDescendants().OfType<Border>())
{
border.BoxShadow = default;
}
}

if (flags.Contains("bake") || flags.Contains("small"))
{
foreach (var border in window.GetVisualDescendants().OfType<Border>()
.Where(b => b.Classes.Contains("WindowBackdrop")))
{
var brush = new Avalonia.Media.RadialGradientBrush
{
Center = new Avalonia.RelativePoint(0.5, 0, Avalonia.RelativeUnit.Relative),
GradientOrigin = new Avalonia.RelativePoint(0.5, 0, Avalonia.RelativeUnit.Relative),
RadiusX = new Avalonia.RelativeScalar(0.75, Avalonia.RelativeUnit.Relative),
RadiusY = new Avalonia.RelativeScalar(0.75, Avalonia.RelativeUnit.Relative)
};
brush.GradientStops.Add(new Avalonia.Media.GradientStop(Avalonia.Media.Color.Parse("#0EB8DB87"), 0));
brush.GradientStops.Add(new Avalonia.Media.GradientStop(Avalonia.Media.Colors.Transparent, 1));
border.Opacity = 1;
border.Background = brush;
if (flags.Contains("small"))
{
border.Height = 320;
border.VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top;
}
}
}

if (flags.Contains("nobackdrop"))
{
foreach (var border in window.GetVisualDescendants().OfType<Border>()
.Where(b => b.Classes.Contains("WindowBackdrop")))
{
border.IsVisible = false;
}
}

var page = Environment.GetEnvironmentVariable("MAPWIZARD_RESIZE_PROBE_PAGE");
if (window is Views.MainWindow mainWindow && !string.IsNullOrEmpty(page))
{
switch (page.ToLowerInvariant())
{
case "hitsoundcopier": mainWindow.NavigateToHitSoundCopier(); break;
case "metadata": mainWindow.NavigateToMetadataManager(); break;
case "colourstudio": mainWindow.NavigateToComboColourStudio(); break;
case "settings": mainWindow.NavigateToSettings(); break;
case "start": mainWindow.NavigateToStart(); break;
}
}

Measure(window);
},
TimeSpan.FromMilliseconds(1500));
}

private static void Measure(Avalonia.Controls.Window window)
{
var sample = new System.Collections.Generic.List<double>();
var frames = new System.Collections.Generic.List<double>();
var compositor = Avalonia.Rendering.Composition.Compositor.TryGetDefaultCompositor();
double lastFrame = Stopwatch.GetTimestamp();
Action? frameRequest = null;
frameRequest = () =>
{
var now2 = Stopwatch.GetTimestamp();
frames.Add((now2 - lastFrame) * 1000d / Stopwatch.Frequency);
lastFrame = now2;
};
var cpuStart = Process.GetCurrentProcess().TotalProcessorTime;
var wall = Stopwatch.StartNew();
var last = Stopwatch.GetTimestamp();
var tick = 0;

var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(5) };
timer.Tick += (_, _) =>
{
var now = Stopwatch.GetTimestamp();
sample.Add((now - last) * 1000d / Stopwatch.Frequency);
last = now;
tick++;

var axis = Environment.GetEnvironmentVariable("MAPWIZARD_RESIZE_PROBE_AXIS") ?? "both";
var phase = tick * 0.06;
if (axis != "height")
{
window.Width = 1180 + (Math.Sin(phase) * 90);
}
if (axis != "width")
{
window.Height = 700 + (Math.Cos(phase) * 60);
}
compositor?.RequestCompositionUpdate(frameRequest!);

if (tick < 600)
{
return;
}

timer.Stop();
wall.Stop();
var cpu = Process.GetCurrentProcess().TotalProcessorTime - cpuStart;
var ordered = sample.OrderBy(x => x).ToArray();
var p95 = ordered[(int)(ordered.Length * 0.95)];
var frameStats = frames.Count == 0
? "frames=0"
: $"frames={frames.Count} frameMs={frames.Average():F2} p95Frame={frames.OrderBy(x => x).ElementAt((int)(frames.Count * 0.95)):F2}";
Console.WriteLine(
$"PROBE resize ticks={sample.Count} wall={wall.ElapsedMilliseconds}ms cpu={cpu.TotalMilliseconds:F0}ms " +
$"avgTick={sample.Average():F2}ms p95Tick={p95:F2}ms maxTick={ordered[^1]:F2}ms {frameStats}");
(Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.Shutdown();
};
timer.Start();
}
}
6 changes: 6 additions & 0 deletions MapWizard.Desktop/Assets/BrandIcons.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Simple Icons (CC0) brand marks, 24x24 viewBox. -->
<StreamGeometry x:Key="BrandGithub">M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12</StreamGeometry>
<StreamGeometry x:Key="BrandDiscord">M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z</StreamGeometry>
</ResourceDictionary>
Binary file added MapWizard.Desktop/Assets/app-icon-256.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 MapWizard.Desktop/Assets/app-icon-64.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 modified MapWizard.Desktop/Assets/app-icon.icns
Binary file not shown.
Binary file modified MapWizard.Desktop/Assets/app-icon.ico
Binary file not shown.
Loading