Skip to content

Commit

Permalink
Merge branch 'linux' of https://github.com/Measurity/Nitrox into linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Measurity committed Apr 28, 2023
2 parents 1ebf3c6 + a707e79 commit 2e4ee5f
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 32 deletions.
1 change: 1 addition & 0 deletions Nitrox.Launcher/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public MainWindow()
UnhandledExceptionHandler(args.Exception);
}
};

RxApp.DefaultExceptionHandler = Observer.Create<Exception>(UnhandledExceptionHandler);

RegisterModal<ErrorModal, ErrorViewModel>(() => ViewModel!.ErrorDialog);
Expand Down
5 changes: 3 additions & 2 deletions Nitrox.Launcher/Models/Converters/EqualsMultiConveter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using Avalonia.Data.Converters;
Expand All @@ -11,9 +11,10 @@ namespace Nitrox.Launcher.Models.Converters;
/// </summary>
public class EqualityConverter : Converter<EqualityConverter>, IMultiValueConverter, IValueConverter
{
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => Equals(value, parameter);

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException();

public object Convert(IList<object> values, Type targetType, object parameter, CultureInfo culture)
{
foreach (object val1 in values)
Expand Down
2 changes: 1 addition & 1 deletion Nitrox.Launcher/Models/Converters/ToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Globalization;
using Avalonia.Data;
using Avalonia.Data.Converters;
Expand Down
8 changes: 4 additions & 4 deletions Nitrox.Launcher/Models/Design/Controls/RadioButtonGroup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Reactive;
using Avalonia;
using Avalonia.Controls;
Expand All @@ -12,8 +12,7 @@ public class RadioButtonGroup : ItemsControl, IStyleable
public static readonly DirectProperty<RadioButtonGroup, Type> EnumProperty = AvaloniaProperty.RegisterDirect<RadioButtonGroup, Type>(nameof(Enum), o => o.Enum, (o, v) => o.Enum = v);
public static readonly StyledProperty<object> SelectedItemProperty = AvaloniaProperty.Register<RadioButtonGroup, object>(nameof(SelectedItem));

public static readonly DirectProperty<RadioButtonGroup, ReactiveCommand<Button, Unit>> ItemClickCommandProperty =
AvaloniaProperty.RegisterDirect<RadioButtonGroup, ReactiveCommand<Button, Unit>>(nameof(ItemClickCommand), o => o.ItemClickCommand, (o, v) => o.ItemClickCommand = v);
public static readonly DirectProperty<RadioButtonGroup, ReactiveCommand<Button, Unit>> ItemClickCommandProperty = AvaloniaProperty.RegisterDirect<RadioButtonGroup, ReactiveCommand<Button, Unit>>(nameof(ItemClickCommand), o => o.ItemClickCommand, (o, v) => o.ItemClickCommand = v);

private Type @enum;
private ReactiveCommand<Button, Unit> itemClickCommand;
Expand All @@ -28,7 +27,8 @@ public Type Enum
{
return;
}
Items = System.Enum.GetValues(value);

ItemsSource = System.Enum.GetValues(value);
SetAndRaise(EnumProperty, ref @enum, value);
}
}
Expand Down
10 changes: 4 additions & 6 deletions Nitrox.Launcher/Models/Design/MultiDataTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern alias JB;
using System;
extern alias JB;

using System.Collections.Generic;
using Avalonia.Collections;
using Avalonia.Controls;
Expand All @@ -10,8 +10,6 @@

namespace Nitrox.Launcher.Models.Design;

extern alias JB;

/// <summary>
/// Selects a <see cref="DataTemplate"/> based on its <see cref="DataTemplate.DataType"/>.
/// </summary>
Expand All @@ -34,7 +32,7 @@ public bool Match(object data)
return false;
}

public IControl Build(object param)
public Control Build(object param)
{
foreach (DataTemplate template in Content)
{
Expand All @@ -44,6 +42,6 @@ public IControl Build(object param)
}
}

return new TextBlock { Text = param.ToString() };
return new TextBlock() { Text = param.ToString() };
}
}
2 changes: 1 addition & 1 deletion Nitrox.Launcher/Models/Design/NavigationHeader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Nitrox.Launcher.Models.Design;
namespace Nitrox.Launcher.Models.Design;

public class NavigationHeader : INavigationItem
{
Expand Down
9 changes: 6 additions & 3 deletions Nitrox.Launcher/Models/Design/NavigationItem.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
using System.Windows.Input;
using System.Windows.Input;
using ReactiveUI;

namespace Nitrox.Launcher.Models.Design;

internal class NavigationItem : INavigationItem
public class NavigationItem : INavigationItem
{
private readonly string icon;

public ICommand ClickCommand { get; init; }

public string ToolTipText { get; init; }

public string Text { get; }

public string Icon
{
get => icon;
init => icon = value ?? "";
init => icon = value ?? string.Empty;
}

public NavigationItem(string text)
Expand Down
12 changes: 6 additions & 6 deletions Nitrox.Launcher/Models/Design/NitroxAttached.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
Expand Down Expand Up @@ -45,12 +45,12 @@ public static void SetSubtext(AvaloniaObject element, string value)

public static string GetSubtext(AvaloniaObject element) => element.GetValue(SubtextProperty);

public static object GetFocus(IAvaloniaObject obj) => obj.GetValue(FocusProperty);
public static object GetFocus(AvaloniaObject obj) => obj.GetValue(FocusProperty);

/// <summary>
/// Sets the focus to this control when view is loaded.
/// </summary>
public static void SetFocus(IAvaloniaObject obj, object value)
public static void SetFocus(AvaloniaObject obj, object value)
{
static async void TryFocusButton(Button btn)
{
Expand Down Expand Up @@ -79,12 +79,12 @@ static async void TryFocusButton(Button btn)

public static bool GetSelected(AvaloniaObject element) => element.GetValue(SelectedProperty);

public static void SetSelected(IAvaloniaObject obj, bool value) => obj.SetValue(SelectedProperty, value);
public static void SetSelected(AvaloniaObject obj, bool value) => obj.SetValue(SelectedProperty, value);

public static ThemeOption GetTheme(IAvaloniaObject avaloniaObject) => (ThemeOption)(avaloniaObject.GetValue(ThemeProperty) ?? ThemeOption.DARK);
public static ThemeOption GetTheme(AvaloniaObject avaloniaObject) => avaloniaObject.GetValue(ThemeProperty);

/// <summary>
/// Sets the theme of the current visual and its children to the given theme.
/// </summary>
public static void SetTheme(IAvaloniaObject avaloniaObject, ThemeOption value) => avaloniaObject.SetValue(ThemeProperty, value);
public static void SetTheme(AvaloniaObject avaloniaObject, ThemeOption value) => avaloniaObject.SetValue(ThemeProperty, value);
}
2 changes: 1 addition & 1 deletion Nitrox.Launcher/Models/Design/TitleBarItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Windows.Input;
using System.Windows.Input;
using ReactiveUI;

namespace Nitrox.Launcher.Models.Design;
Expand Down
17 changes: 10 additions & 7 deletions Nitrox.Launcher/Nitrox.Launcher.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<LangVersion>$(LangVersion)</LangVersion>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<AvaloniaNameGeneratorIsEnabled>true</AvaloniaNameGeneratorIsEnabled>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

<ItemGroup>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
Expand All @@ -15,13 +18,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview6" />
<!--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.0-preview4" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
<PackageReference Include="ReactiveUI.Validation" Version="3.0.22" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.5.1" />
</ItemGroup>
</Project>

</Project>
2 changes: 1 addition & 1 deletion Nitrox.Launcher/Styles/Nitrox.axaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FluentTheme Mode="Dark" />
<FluentTheme />
<StyleInclude Source="/Styles/Palette/Nitrox.axaml" />
<StyleInclude Source="/Styles/Theme/Index.axaml" />
</Styles>

0 comments on commit 2e4ee5f

Please sign in to comment.