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
10 changes: 5 additions & 5 deletions MapWizard.Desktop/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://Avalonia.Controls.ColorPicker/Themes/Fluent/Fluent.xaml" />
<sukiUi:SukiTheme Locale="en-US" ThemeColor="Blue" />
<materialIcons:MaterialIconStyles />
</Application.Styles>
<StyleInclude Source="avares://Avalonia.Controls.ColorPicker/Themes/Fluent/Fluent.xaml" />
<sukiUi:SukiTheme Locale="en-US" ThemeColor="Blue" />
<materialIcons:MaterialIconStyles />
</Application.Styles>

<Application.Resources>
<converters:IndexToTransformConverter x:Key="IndexToTransformConverter"/>
</Application.Resources>
</Application>
</Application>
2 changes: 0 additions & 2 deletions MapWizard.Desktop/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using MapWizard.Desktop.DependencyInjection;
using MapWizard.Desktop.Services;
Expand All @@ -18,7 +17,6 @@ public override void Initialize()

public override void OnFrameworkInitializationCompleted()
{
BindingPlugins.DataValidators.RemoveAt(0);
var collection = new ServiceCollection();
collection.AddCommonServices();
var services = collection.BuildServiceProvider();
Expand Down
33 changes: 16 additions & 17 deletions MapWizard.Desktop/MapWizard.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,27 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.3.12" />
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="11.3.12" />
<PackageReference Include="Avalonia.Desktop" Version="11.3.12" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.3.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.12" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.12" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.9" />
<PackageReference Include="Avalonia" Version="12.1.0" />
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="12.1.0" />
<PackageReference Include="Avalonia.Desktop" Version="12.1.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="12.1.0" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="12.1.0" />
<PackageReference Include="Avalonia.Wayland" Version="12.1.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
<PackageReference Include="DialogHost.Avalonia" Version="0.11.0" />
<PackageReference Include="JAJ.Packages.MiniAudioEx" Version="3.2.1" />
<PackageReference Include="DialogHost.Avalonia" Version="0.12.3" />
<PackageReference Include="JAJ.Packages.MiniAudioEx" Version="3.3.5" />
<PackageReference Include="ManagedBass" Version="4.0.2" />
<PackageReference Include="MapWizard.BeatmapParser" Version="1.0.6" />
<PackageReference Include="Material.Icons.Avalonia" Version="3.0.0" />
<PackageReference Include="MessageBox.Avalonia" Version="3.3.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.5" />
<PackageReference Include="OsuMemoryDataProvider" Version="0.12.0" />
<PackageReference Include="Material.Icons.Avalonia" Version="3.0.2" />
<PackageReference Include="MessageBox.Avalonia" Version="12.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.10" />
<PackageReference Include="OsuMemoryDataProvider" Version="0.12.2" />
<PackageReference Include="OsuWineMemReader" Version="1.0.1" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.119.2" />
<PackageReference Include="SukiUI" Version="6.0.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="4.150.1" />
<PackageReference Include="SukiUI" Version="7.0.1" />
<PackageReference Include="System.Reactive" Version="6.1.0" />
<PackageReference Include="Velopack" Version="0.0.1298" />
<PackageReference Include="Xaml.Behaviors" Version="11.3.9.5" />
<PackageReference Include="Velopack" Version="1.2.0" />
<PackageReference Include="Xaml.Behaviors" Version="12.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
23 changes: 11 additions & 12 deletions MapWizard.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
using System;
using System.Linq;
using Velopack;

namespace MapWizard.Desktop;

internal static class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
namespace MapWizard.Desktop;

internal static class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args)
{
Expand All @@ -31,6 +30,7 @@ public static void Main(string[] args)
private static AppBuilder BuildAvaloniaApp(bool forceSoftwareRendering)
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseWayland()
.WithInterFont()
.With(new X11PlatformOptions()
{
Expand All @@ -41,9 +41,8 @@ private static AppBuilder BuildAvaloniaApp(bool forceSoftwareRendering)
X11RenderingMode.Glx,
X11RenderingMode.Vulkan,
X11RenderingMode.Software
],
OverlayPopups = true
]
})
.LogToTrace();
}

}
2 changes: 1 addition & 1 deletion MapWizard.Desktop/ViewModels/ComboColourStudioViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private async Task SelectOriginMap(string path)
}
catch (Exception ex)
{
MapWizard.Tools.HelperExtensions.MapWizardLogger.LogException(ex);
Tools.HelperExtensions.MapWizardLogger.LogException(ex);
ShowToast(NotificationType.Error, "Combo Colour Studio", ex.Message);
}
}
Expand Down
2 changes: 1 addition & 1 deletion MapWizard.Desktop/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace MapWizard.Desktop.ViewModels
{
public partial class MainWindowViewModel : ObservableObject
{
private ISukiToastManager ToastManager { get; }
public ISukiToastManager ToastManager { get; }
public ISukiDialogManager DialogManager { get; }

private readonly IThemeService _themeService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:suki="clr-namespace:SukiUI.Controls;assembly=SukiUI"
xmlns:theme="https://github.com/kikipoulet/SukiUI"
xmlns:models="using:MapWizard.Desktop.Models"
xmlns:vm="clr-namespace:MapWizard.Desktop.ViewModels"
mc:Ignorable="d"
d:DesignWidth="900"
d:DesignHeight="700"
x:Class="MapWizard.Desktop.Views.ComboColourStudio.ComboColourStudioView"
x:Name="Root"
x:DataType="vm:ComboColourStudioViewModel"
Padding="16">

Expand Down Expand Up @@ -164,7 +166,7 @@

<ItemsControl ItemsSource="{Binding ComboColours}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="models:AvaloniaComboColour">
<Grid ColumnDefinitions="*,Auto" Margin="0,0,0,6">
<TextBlock FontWeight="Bold"
Text="{Binding Number, StringFormat=Combo {0}}"
Expand All @@ -173,7 +175,7 @@
<controls:ModernColorPicker
SelectedColor="{Binding Colour, Converter={StaticResource AvaloniaColorToColorConverter}, Mode=TwoWay}" />
<Button Classes="Basic"
Command="{Binding DataContext.RemoveColourCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
Command="{Binding #Root.DataContext.RemoveColourCommand}"
CommandParameter="{Binding}"
ToolTip.Tip="Remove this combo colour">
<materialIcons:MaterialIcon Kind="Close" Width="20" Height="20" />
Expand Down Expand Up @@ -241,7 +243,7 @@

<ItemsControl ItemsSource="{Binding ColourPoints}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="models:AvaloniaComboColourPoint">
<Border Classes="ColourPointCard"
Classes.latest="{Binding IsLatestAdded}"
BorderBrush="{DynamicResource ThemeAccentBrush}"
Expand All @@ -268,15 +270,15 @@
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="models:AvaloniaComboColourToken">
<Border Classes="SequenceTokenDragHost"
DragDrop.AllowDrop="True"
DragDrop.DragOver="SequenceToken_OnDragOver"
DragDrop.Drop="SequenceToken_OnDrop">
<controls:ComboColourDropdown
Options="{Binding DataContext.ColourDropdownOptions, RelativeSource={RelativeSource AncestorType=UserControl}}"
Options="{Binding #Root.DataContext.ColourDropdownOptions}"
SelectedComboNumber="{Binding ComboNumber, Mode=TwoWay}"
RemoveTokenCommand="{Binding DataContext.RemoveColourFromPointCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
RemoveTokenCommand="{Binding #Root.DataContext.RemoveColourFromPointCommand}"
RemoveTokenCommandParameter="{Binding}" />
</Border>
</DataTemplate>
Expand All @@ -289,21 +291,21 @@
Spacing="6"
HorizontalAlignment="Right">
<Button Classes="Basic"
Command="{Binding DataContext.AddColourToPointCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
Command="{Binding #Root.DataContext.AddColourToPointCommand}"
CommandParameter="{Binding}"
ToolTip.Tip="Add combo colour to this point sequence">
<materialIcons:MaterialIcon Kind="Add" Width="16" Height="16" />
</Button>

<Button Classes="Basic"
Command="{Binding DataContext.AddColourPointFromSequenceCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
Command="{Binding #Root.DataContext.AddColourPointFromSequenceCommand}"
CommandParameter="{Binding}"
ToolTip.Tip="Create a new colour point from this sequence">
<materialIcons:MaterialIcon Kind="ContentCopy" Width="16" Height="16" />
</Button>

<Button Classes="Basic"
Command="{Binding DataContext.RemoveColourPointCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
Command="{Binding #Root.DataContext.RemoveColourPointCommand}"
CommandParameter="{Binding}"
ToolTip.Tip="Remove this colour point">
<materialIcons:MaterialIcon Kind="Delete" Width="18" Height="18" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ public partial class ComboColourStudioView : UserControl
{
private const double DragStartThreshold = 4;

private Point? _dragStartPoint;
private AvaloniaComboColourToken? _pressedToken;
private AvaloniaComboColourPoint? _pressedPoint;
private Border? _dragSourceHost;
private sealed record DragCandidate(
PointerPressedEventArgs TriggerEvent,
Point StartPosition,
Border Host,
AvaloniaComboColourToken Token,
AvaloniaComboColourPoint Owner);

private DragCandidate? _dragCandidate;
private Border? _activeDropHost;
private bool _dragInProgress;

Expand All @@ -35,42 +39,39 @@ private void OnPointerPressedTunnel(object? sender, PointerPressedEventArgs e)
return;
}

if (!TryGetTokenContextFromSource(e.Source, out var host, out var token, out var point))
if (!TryGetTokenContextFromSource(e.Source, out var host, out var token, out var point) ||
!e.GetCurrentPoint(host).Properties.IsLeftButtonPressed)
{
ResetDragState();
return;
}

var pointer = e.GetCurrentPoint(host);
if (!pointer.Properties.IsLeftButtonPressed)
{
ResetDragState();
return;
}

_pressedToken = token;
_pressedPoint = point;
_dragSourceHost = host;
_dragStartPoint = e.GetPosition(host);
_dragCandidate = new DragCandidate(
e,
e.GetPosition(host),
host,
token,
point);
}

private async void OnPointerMovedTunnel(object? sender, PointerEventArgs e)
{
if (_dragInProgress || _pressedToken is null || _pressedPoint is null || _dragStartPoint is null || _dragSourceHost is null)
var candidate = _dragCandidate;
if (_dragInProgress || candidate is null)
{
return;
}

var current = e.GetCurrentPoint(this);
if (!current.Properties.IsLeftButtonPressed)
{
ClearDragSourceHost();
ResetDragState();
return;
}

var currentPosition = e.GetPosition(_dragSourceHost);
var dragDistance = Math.Abs(currentPosition.X - _dragStartPoint.Value.X) + Math.Abs(currentPosition.Y - _dragStartPoint.Value.Y);
var currentPosition = e.GetPosition(candidate.Host);
var dragDistance = Math.Abs(currentPosition.X - candidate.StartPosition.X) +
Math.Abs(currentPosition.Y - candidate.StartPosition.Y);
if (dragDistance < DragStartThreshold)
{
return;
Expand All @@ -80,17 +81,17 @@ private async void OnPointerMovedTunnel(object? sender, PointerEventArgs e)
dragTransfer.Add(DataTransferItem.CreateText("MapWizardComboColourTokenMove"));

_dragInProgress = true;
_dragSourceHost.Classes.Set("drag-source", true);
candidate.Host.Classes.Set("drag-source", true);
try
{
e.Handled = true;
await DragDrop.DoDragDropAsync(e, dragTransfer, DragDropEffects.Move);
await DragDrop.DoDragDropAsync(candidate.TriggerEvent, dragTransfer, DragDropEffects.Move);
}
finally
{
candidate.Host.Classes.Set("drag-source", false);
_dragInProgress = false;
ClearActiveDropHost();
ClearDragSourceHost();
ResetDragState();
}
}
Expand All @@ -102,7 +103,6 @@ private void OnPointerReleasedTunnel(object? sender, PointerReleasedEventArgs e)
return;
}

ClearDragSourceHost();
ResetDragState();
}

Expand Down Expand Up @@ -196,20 +196,21 @@ private bool TryGetDropContext(
return false;
}

var candidate = _dragCandidate;
var targetPoint = FindOwningColourPoint(host);
if (targetPoint is null || _pressedPoint is null || _pressedToken is null)
if (targetPoint is null || candidate is null)
{
return false;
}

if (!ReferenceEquals(targetPoint, _pressedPoint) ||
ReferenceEquals(target, _pressedToken))
if (!ReferenceEquals(targetPoint, candidate.Owner) ||
ReferenceEquals(target, candidate.Token))
{
return false;
}

sourcePoint = _pressedPoint;
sourceToken = _pressedToken;
sourcePoint = candidate.Owner;
sourceToken = candidate.Token;
targetToken = target;
return true;
}
Expand Down Expand Up @@ -271,10 +272,7 @@ private static bool TryGetTokenContextFromSource(

private void ResetDragState()
{
_dragStartPoint = null;
_pressedToken = null;
_pressedPoint = null;
_dragSourceHost = null;
_dragCandidate = null;
}

private void ClearActiveDropHost()
Expand All @@ -288,13 +286,4 @@ private void ClearActiveDropHost()
_activeDropHost = null;
}

private void ClearDragSourceHost()
{
if (_dragSourceHost is null)
{
return;
}

_dragSourceHost.Classes.Set("drag-source", false);
}
}
Loading
Loading