Skip to content

Commit

Permalink
Merge all client projects (launcher, symbiote, switcher) into one.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp committed Jan 10, 2024
1 parent 1cf1712 commit ea4294f
Show file tree
Hide file tree
Showing 54 changed files with 381 additions and 503 deletions.
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"program": "${workspaceFolder}/out/bin/src/server/daemon/debug/arised.dll"
},
{
"name": ".NET: Launch Switcher",
"name": ".NET: Launch Client",
"presentation": {
"group": "arise"
},
Expand All @@ -52,8 +52,8 @@
"searchNuGetOrgSymbolServer": true
},
"console": "internalConsole",
"cwd": "${workspaceFolder}/src/client/switcher",
"program": "${workspaceFolder}/out/bin/src/client/switcher/debug/arise.dll",
"cwd": "${workspaceFolder}/src/client",
"program": "${workspaceFolder}/out/bin/src/client/debug/arise.dll",
"args": [
"--Launcher:GameConsole",
"true"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<div align="center">
<img src="arise.png"
width="128" />
width="128"
alt="TERA Arise" />
</div>

<div align="center">
Expand Down
2 changes: 1 addition & 1 deletion arise.proj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.Build.Traversal">
<ItemGroup>
<ProjectReference Include="src/*/*/*.*proj" />
<ProjectReference Include="src/**/*.csproj" />
</ItemGroup>
</Project>
213 changes: 98 additions & 115 deletions arise.sln

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions src/client/Directory.Build.props

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Arise.Client.Game.Memory;
using Arise.Client.Game.Net;
using Arise.Client.Memory;
using Arise.Client.Net;
using static Iced.Intel.AssemblerRegisters;

namespace Arise.Client.Data;
namespace Arise.Client.Game.Data;

[RegisterSingleton<TeraDataCenterLoader>]
internal sealed unsafe class TeraDataCenterLoader : IHostedService
{
private readonly CodeManager _codeManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Arise.Client.Net;
using Arise.Client.Game.Net;

namespace Arise.Client;
namespace Arise.Client.Game;

internal sealed class GameApplicationHost : IHostedService
{
Expand Down
14 changes: 14 additions & 0 deletions src/client/Game/GameOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Arise.Client.Game;

internal sealed class GameOptions : IOptions<GameOptions>
{
public bool Console { get; set; }

public Uri WorldServerUri { get; set; } = new("arise://localhost:7801");

public string AccountName { get; set; } = "arise@localhost";

public string SessionTicket { get; set; } = "bc8d0fc43b795e0634fa5934a2d3b14d5348da9f13fa26ae57acefaf337f5731";

GameOptions IOptions<GameOptions>.Value => this;
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using Arise.Client.Memory;
using Arise.Client.Game.Memory;

namespace Arise.Client.Launcher;
namespace Arise.Client.Game.Launcher;

[RegisterSingleton<TeraLauncherProxyManager>]
internal sealed unsafe partial class TeraLauncherProxyManager : IHostedService
{
private readonly Queue<FunctionHook> _hooks = new();

private readonly IOptions<SymbioteOptions> _options;
private readonly IOptions<GameOptions> _options;

private readonly CodeManager _codeManager;

public TeraLauncherProxyManager(IOptions<SymbioteOptions> options, CodeManager codeManager)
public TeraLauncherProxyManager(IOptions<GameOptions> options, CodeManager codeManager)
{
_options = options;
_codeManager = codeManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Arise.Client.Memory;
namespace Arise.Client.Game.Memory;

internal static unsafe class TeraMemory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Arise.Client.Net.Sessions;
using Arise.Server.Net.Sessions;
using Arise.Client.Game.Net.Sessions;

namespace Arise.Client.Net;
namespace Arise.Client.Game.Net;

[RegisterSingleton<GameClient>]
internal sealed partial class GameClient : IHostedService
{
private static partial class Log
Expand Down Expand Up @@ -35,7 +33,7 @@ public static partial void ArisePacketReceived(

private readonly IHostApplicationLifetime _hostLifetime;

private readonly IOptions<SymbioteOptions> _options;
private readonly IOptions<GameOptions> _options;

private readonly ILogger<GameClient> _logger;

Expand All @@ -47,7 +45,7 @@ public static partial void ArisePacketReceived(

public GameClient(
IHostApplicationLifetime hostLifetime,
IOptions<SymbioteOptions> options,
IOptions<GameOptions> options,
ILogger<GameClient> logger,
ObjectPoolProvider objectPoolProvider,
GameClientSessionDispatcher sessionDispatcher,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Arise.Client.Net.Sessions;
using Arise.Client.Game.Net.Sessions;

namespace Arise.Client.Net.Handlers;
namespace Arise.Client.Game.Net.Handlers;

internal sealed partial class GameClientPacketHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Arise.Client.Net.Handlers;
namespace Arise.Client.Game.Net.Handlers;

internal sealed partial class GameClientPacketHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Arise.Client.Net.Sessions;
namespace Arise.Client.Game.Net.Sessions;

internal sealed class GameClientSession : GameSession
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Arise.Client.Net.Handlers;
using Arise.Client.Net.Sessions;
using Arise.Client.Game.Net.Handlers;

namespace Arise.Server.Net.Sessions;
namespace Arise.Client.Game.Net.Sessions;

[RegisterSingleton<GameClientSessionDispatcher>]
internal sealed partial class GameClientSessionDispatcher :
GameSessionDispatcher<GameClientSession, GameClientPacketHandler>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Arise.Client.Net;
namespace Arise.Client.Game.Net;

[RegisterSingleton<TeraConnectionManager>]
internal sealed unsafe partial class TeraConnectionManager : IHostedService
{
private enum State
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Arise.Client.Launcher.Gateway;
namespace Arise.Client.Gateway;

internal sealed class GatewayClient
{
Expand All @@ -18,10 +18,4 @@ public GatewayClient(HttpClient client)
client, new RefitSettings(new SystemTextJsonContentSerializer(IGatewayClient.JsonContext.Options)));
_client = client;
}

[RegisterServices]
internal static void Register(IServiceCollection services)
{
_ = services.AddHttpClient<GatewayClient>();
}
}
24 changes: 24 additions & 0 deletions src/client/Launcher/Controllers/MainController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Arise.Client.Launcher.Media;

namespace Arise.Client.Launcher.Controllers;

internal sealed class MainController : LauncherController
{
private readonly MusicPlayer? _musicPlayer;

public MainController(IServiceProvider services)
: base(services)
{
_musicPlayer = services.GetService<MusicPlayer>(); // Not available in the Avalonia designer.

this.WhenActivated((CompositeDisposable disposable) =>
{
if (_musicPlayer is not { } player)
return;

player.Play();

disposable.Add(Disposable.Create(player, static player => player.Stop()));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ internal sealed partial class LauncherApplication : Application
{
private readonly IServiceProvider _services;

private readonly IHostApplicationLifetime _hostLifetime;

public LauncherApplication(IServiceProvider services, IHostApplicationLifetime hostLifetime)
public LauncherApplication(IServiceProvider services)
{
_services = services;
_hostLifetime = hostLifetime;
}

public override void Initialize()
Expand All @@ -25,21 +22,25 @@ public override void Initialize()

public override void OnFrameworkInitializationCompleted()
{
var lifetime = Unsafe.As<IClassicDesktopStyleApplicationLifetime>(ApplicationLifetime!);
if (Design.IsDesignMode)
return;

var hostLifetime = _services.GetRequiredService<IHostApplicationLifetime>();
var avaloniaLifetime = Unsafe.As<IClassicDesktopStyleApplicationLifetime>(ApplicationLifetime!);

// Ensure that Ctrl-C in the console works as expected.
_ = _hostLifetime.ApplicationStopping.UnsafeRegister(
static lifetime =>
_ = hostLifetime.ApplicationStopping.UnsafeRegister(
static avaloniaLifetime =>
Dispatcher.UIThread.Post(
() => Unsafe.As<IClassicDesktopStyleApplicationLifetime>(lifetime!).Shutdown(),
() => Unsafe.As<IClassicDesktopStyleApplicationLifetime>(avaloniaLifetime!).Shutdown(),
DispatcherPriority.MaxValue),
state: lifetime);
state: avaloniaLifetime);

var window = ActivatorUtilities.CreateInstance<MainWindow>(_services);

window.DataContext = ActivatorUtilities.CreateInstance<MainController>(_services);

lifetime.MainWindow = window;
avaloniaLifetime.MainWindow = window;

base.OnFrameworkInitializationCompleted();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Arise.Client.Launcher.Logging;
using Arise.Client.Logging;

namespace Arise.Client.Launcher;

[RegisterSingleton<LauncherApplicationHost>]
internal sealed class LauncherApplicationHost : IHostedService
{
private readonly IServiceProvider _services;
Expand All @@ -29,12 +28,8 @@ Task IHostedService.StartAsync(CancellationToken cancellationToken)

try
{
_ = AppBuilder
.Configure(() => ActivatorUtilities.CreateInstance<LauncherApplication>(@this._services))
.UseWin32()
.UseSkia()
.UseReactiveUI()
.WithInterFont()
_ = Program
.BuildAvaloniaApp(@this._services)
.StartWithClassicDesktopLifetime([], ShutdownMode.OnMainWindowClose);
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,4 @@ internal sealed class LauncherOptions : IOptions<LauncherOptions>
public bool GameConsole { get; set; }

LauncherOptions IOptions<LauncherOptions>.Value => this;

[RegisterServices]
public static void Register(IServiceCollection services)
{
_ = services
.AddOptions<LauncherOptions>()
.BindConfiguration("Launcher");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Arise.Client.Launcher.Media;

[RegisterSingleton<MusicPlayer>]
internal sealed class MusicPlayer : IDisposable
{
private readonly WasapiOut _wasapi = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Style Selector="Window">
<Setter Property="WindowStartupLocation" Value="CenterScreen" />
<Setter Property="Title" Value="{Binding Title}" />
<Setter Property="Icon" Value="../arise.png" />
<Setter Property="Icon" Value="../../arise.png" />
<Setter Property="CanResize" Value="False" />
<Setter Property="ExtendClientAreaToDecorationsHint" Value="True" />
<Setter Property="ExtendClientAreaTitleBarHeightHint" Value="25" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
Width="1280"
Height="720">
<Window.Background>
<ImageBrush Source="{Binding Background}"
<ImageBrush Source="../../image_background.webp"
Stretch="Fill" />
</Window.Background>

<Image Source="{Binding Logo}"
<Image Source="../../image_logo.webp"
Stretch="Uniform" />
</Window>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Arise.Client.Launcher.Windows;

[RegisterTransient<MainWindow>]
internal sealed partial class MainWindow : LauncherWindow<MainController>
{
public MainWindow()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Arise.Client.Launcher.Logging;
namespace Arise.Client.Logging;

[RegisterSingleton<AvaloniaLogSink>]
[SuppressMessage("", "CA1848")]
[SuppressMessage("", "CA2254")]
internal sealed class AvaloniaLogSink : ILogSink
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AllocConsole
AttachConsole

ATTACH_PARENT_PROCESS
Loading

0 comments on commit ea4294f

Please sign in to comment.