Skip to content
Open
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
17 changes: 17 additions & 0 deletions Race Element.UI/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:themes="clr-namespace:Avalonia.Themes.Neumorphism;assembly=Avalonia.Themes.Neumorphism"
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
x:Class="RaceElement.UI.App"
xmlns:local="using:RaceElement.UI"
RequestedThemeVariant="Light">

<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

<Application.Styles>
<themes:NeumorphismTheme BaseTheme="Light" PrimaryColor="LightBlue" SecondaryColor="Lime" />
<StyleInclude Source="avares://Material.Icons.Avalonia/MaterialIconStyles.axaml" />
</Application.Styles>
</Application>
35 changes: 35 additions & 0 deletions Race Element.UI/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Avalonia;
using Avalonia.Markup.Xaml;
using Avalonia.Controls.ApplicationLifetimes;
using RaceElement.UI.ViewModels;
using RaceElement.UI.Views;

namespace RaceElement.UI;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainWindow
{
DataContext = new MainWindowViewModel()
};
}

base.OnFrameworkInitializationCompleted();
}

}
Binary file added Race Element.UI/Assets/Banner.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 Race Element.UI/Assets/acc-list-image.jpg
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 Race Element.UI/Assets/acc.ico
Binary file not shown.
Binary file added Race Element.UI/Assets/acevo-list-image.jpg
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 Race Element.UI/Assets/acevo.ico
Binary file not shown.
Binary file added Race Element.UI/Assets/iracing-list-image.jpg
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 Race Element.UI/Assets/iracing.ico
Binary file not shown.
Binary file added Race Element.UI/Assets/lmu-list-image.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 Race Element.UI/Assets/lmu.ico
Binary file not shown.
Binary file added Race Element.UI/Assets/raceelement.ico
Binary file not shown.
24 changes: 24 additions & 0 deletions Race Element.UI/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using Avalonia;
using Avalonia.Styling;
using Avalonia.ReactiveUI;

namespace RaceElement.UI;

internal sealed 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) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.UseReactiveUI();
}
43 changes: 43 additions & 0 deletions Race Element.UI/RaceElement.UI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>

<ItemGroup>
<Folder Include="Models\" />
<AvaloniaResource Include="Assets\**" />
</ItemGroup>

<ItemGroup>
<AvaloniaResource Remove="Assets\race element icon 2.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.2.6" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.6" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.6" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.6" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.6">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.2.6" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.3.1" />
<PackageReference Include="Neumorphism.Avalonia" Version="0.11.2" />
</ItemGroup>

<ItemGroup>
<Compile Update="Views\MainTopMenuView.axaml.cs">
<DependentUpon>MainTopMenuView.axaml</DependentUpon>
</Compile>
<Compile Update="Views\Pages\OverlaySettingPages\ControlButtonsPanelView.axaml.cs">
<DependentUpon>ControlButtonsPanelView.axaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>
75 changes: 75 additions & 0 deletions Race Element.UI/Services/GameSelectionService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Create a new file: Race Element.UI/Services/GameSelectionService.cs
using ReactiveUI;
using System;
using System.Diagnostics;

namespace RaceElement.UI.Services;

public enum SupportedGame
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
IRacing,
ACC,
ACEvo,
LMU
}

/// <summary>
/// Provides application-wide access to the currently selected game
/// </summary>
public class GameSelectionService : ReactiveObject
{
#region Singleton
private static readonly Lazy<GameSelectionService> _instance =
new Lazy<GameSelectionService>(() => new GameSelectionService());

public static GameSelectionService Instance => _instance.Value;
#endregion

#region Events
public event Action<SupportedGame>? GameChanged;
#endregion

#region Properties
private SupportedGame _selectedGame = SupportedGame.ACC; // Default game

public SupportedGame SelectedGame => _selectedGame;
#endregion

#region Constructor
// Private constructor for singleton
private GameSelectionService()
{
}
#endregion

#region Public Methods

/// <summary>
/// Updates the selected game and performs any game-specific initialization logic
/// </summary>
/// <param name="game">The game identifier</param>
/// <returns>True if the selection was valid and processed, false otherwise</returns>
public bool SelectGame(SupportedGame game)
{
if (game == _selectedGame)
return false;

_selectedGame = game;
GameChanged?.Invoke(game); // Convert SupportedGame enum to string
return true;
}
/// <summary>
/// Updates the selected game (internal - only used by MainTopMenuViewModel)
/// </summary>
public void UpdateSelectedGame(SupportedGame game)
{
_selectedGame = game;
}

// Helper methods to check for specific games
public bool IsIRacing => SelectedGame == SupportedGame.IRacing;
public bool IsACC => SelectedGame == SupportedGame.ACC;
public bool IsACEvo => SelectedGame == SupportedGame.ACEvo;
public bool IsLMU => SelectedGame == SupportedGame.LMU;
#endregion
}
Loading