Skip to content

Commit

Permalink
Merge pull request #49 from tgiachi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
tgiachi committed May 8, 2023
2 parents 839b145 + 0151269 commit b9ba39f
Show file tree
Hide file tree
Showing 69 changed files with 1,026 additions and 4,496 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ FodyWeavers.xsd
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839


# User-specific stuff
.idea/**/**
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
Expand Down Expand Up @@ -487,4 +489,5 @@ fabric.properties
!.idea/codeStyles
!.idea/runConfigurations

# End of https://www.toptal.com/developers/gitignore/api/csharp,intellij+all
# End of https://www.toptal.com/developers/gitignore/api/csharp,intellij+all
DarkStar.Client/.idea
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to this project will be documented in this file. See [versionize](https://github.com/versionize/versionize) for commit guidelines.

<a name="0.8.0"></a>
## [0.8.0](https://www.github.com/tgiachi/DarkSun/releases/tag/v0.8.0) (2023-5-8)

### ✨ Features

* I've come to a conclusion, I hate typescript, I hate javascript. So the client will be done in Avalonia! 😂 ([2bc4208](https://www.github.com/tgiachi/DarkSun/commit/2bc4208d8860f5d633b5a6bf298dae8c92565566))
* **client:** add initial Avalonia UI project files and setup dependency injection and logging ([abd2165](https://www.github.com/tgiachi/DarkSun/commit/abd21651326cbd88ae59424c479b36fe2470ea28))
* **client:** add splash screen window with DarkStar logo and progress bar ([b8b010e](https://www.github.com/tgiachi/DarkSun/commit/b8b010eba95fc5a4b93e7aab718f08a324e6b017))
* **client:** add support for TileSetListRequestMessage and AccountLoginResponseMessage ([194be72](https://www.github.com/tgiachi/DarkSun/commit/194be7203b1c91a1703b14096cbb79c5721dcfa9))
* **PageViewControl:** add ContentPresenter to PageViewControl ([7091612](https://www.github.com/tgiachi/DarkSun/commit/709161252652c07b2c277d790ab4dc92c533203a))
* **PageViewControl:** add PageViewControl to MainWindow ([c861eff](https://www.github.com/tgiachi/DarkSun/commit/c861effda59220237e1525b60b87d138b9b58222))

### Other

* 🎨 style(.gitignore): add DarkStar.Client/.idea to .gitignore ([1abf55c](https://www.github.com/tgiachi/DarkSun/commit/1abf55ccae5f9eba09a1ac6936c6913a68abfa4d))
* 🐛 fix(LoginPageViewModel.cs): change network client address and port to localhost:5000 ([4c9090e](https://www.github.com/tgiachi/DarkSun/commit/4c9090e726617bfdb64f48375ad069c202a37a32))
* 🔥 chore(DarkStar.Api, DarkStar.Client): remove unused code and files ([e6fa2b8](https://www.github.com/tgiachi/DarkSun/commit/e6fa2b8337013abeed2ff04262fe64e911db964c))

<a name="0.7.0"></a>
## [0.7.0](https://www.github.com/tgiachi/DarkStar/releases/tag/v0.7.0) (2023-5-4)

Expand Down
2 changes: 1 addition & 1 deletion DarkStar.Api.Engine/DarkStar.Api.Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.7.0</Version>
<Version>0.8.0</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>tgiachi (squid@stormwind.it)</Authors>
Expand Down
2 changes: 1 addition & 1 deletion DarkStar.Api/DarkStar.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageProjectUrl>https://github.com/tgiachi/darksun</PackageProjectUrl>
<RepositoryUrl>https://github.com/tgiachi/darksun</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>0.7.0</Version>
<Version>0.8.0</Version>
<Title>Dark Star MMO Api</Title>
<Description> </Description>
<Copyright>MIT License</Copyright>
Expand Down
5 changes: 0 additions & 5 deletions DarkStar.Api/Data/Config/DirectoriesConfig.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace DarkStar.Api.Data.Config;
Expand Down
14 changes: 0 additions & 14 deletions DarkStar.Client/.eslintrc.cjs

This file was deleted.

24 changes: 0 additions & 24 deletions DarkStar.Client/.gitignore

This file was deleted.

22 changes: 22 additions & 0 deletions DarkStar.Client/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="DarkStar.Client.App">

<Application.Resources>
<FontFamily x:Key="DefaultFont">avares://DarkStar.Client/Assets/Fonts/CozetteVector.ttf#CozetteVector</FontFamily>
</Application.Resources>

<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Accents/BaseDark.xaml"/>
<StyleInclude Source="avares://Aura.UI.FluentTheme/AuraUI.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseDark.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>

<Style Selector="Window">
<Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
<Setter Property="FontSize" Value="14" />
</Style>
</Application.Styles>


</Application>
37 changes: 37 additions & 0 deletions DarkStar.Client/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using DarkStar.Client.ViewModels;
using DarkStar.Client.Views;
using PropertyChanged;
using Splat;

namespace DarkStar.Client;

[DoNotNotify]
public partial class App : Application
{
private SplashScreenWindow _splashScreenWindow;
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
_splashScreenWindow = new SplashScreenWindow();
_splashScreenWindow.Show();
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{

desktop.MainWindow = new MainWindow
{
DataContext = Locator.Current.GetService<MainWindowViewModel>()
};

_splashScreenWindow.Close();
}

base.OnFrameworkInitializationCompleted();
}
}
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 DarkStar.Client/Assets/DarkStarSplash.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 DarkStar.Client/Assets/Fonts/Coder_Crux.ttf
Binary file not shown.
Binary file added DarkStar.Client/Assets/Fonts/CozetteVector.ttf
Binary file not shown.
Binary file added DarkStar.Client/Assets/Fonts/ProggyVector.ttf
Binary file not shown.
Binary file added DarkStar.Client/Assets/avalonia-logo.ico
Binary file not shown.
Binary file added DarkStar.Client/Assets/dark_star_icon.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions DarkStar.Client/Attributes/PageViewAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace DarkStar.Client.Attributes;

[AttributeUsage(AttributeTargets.Class)]
public class PageViewAttribute : Attribute
{
public Type View { get; set; }

public PageViewAttribute(Type view) => View = view;
}
11 changes: 11 additions & 0 deletions DarkStar.Client/Controls/PageViewControl.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Name="pageViewControl"
x:Class="DarkStar.Client.Controls.PageViewControl">
<ContentPresenter Width="{Binding ElementName=pageViewControl, Path=Width}"
Height="{Binding ElementName=pageViewControl, Path=Height}" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" x:Name="Presenter" />
</UserControl>
28 changes: 28 additions & 0 deletions DarkStar.Client/Controls/PageViewControl.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Markup.Xaml;
using PropertyChanged;

namespace DarkStar.Client.Controls;

[DoNotNotify]
public partial class PageViewControl : UserControl
{
public ContentPresenter ControlProperty { get; set; } = null!;

public PageViewControl()
{

InitializeComponent();

}

private void InitializeComponent()
{

AvaloniaXamlLoader.Load(this);
ControlProperty = this.GetControl<ContentPresenter>("Presenter");
}
}

9 changes: 9 additions & 0 deletions DarkStar.Client/Controls/RenderControl.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="DarkStar.Client.Controls.RenderControl">

</UserControl>

128 changes: 128 additions & 0 deletions DarkStar.Client/Controls/RenderControl.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using System;
using System.Diagnostics;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Platform;
using Avalonia.Rendering.SceneGraph;
using Avalonia.Skia;
using Avalonia.Threading;
using PropertyChanged;
using SkiaSharp;

namespace DarkStar.Client.Controls;

[DoNotNotify]
public partial class RenderControl : UserControl
{
class CustomDrawOp : ICustomDrawOperation
{
private readonly FormattedText _noSkia;

public CustomDrawOp(Rect bounds, FormattedText noSkia)
{
_noSkia = noSkia;
Bounds = bounds;
}

public void Dispose()
{
// No-op
}

public Rect Bounds { get; }
public bool HitTest(Point p) => false;
public bool Equals(ICustomDrawOperation other) => false;
static Stopwatch St = Stopwatch.StartNew();

public void Render(IDrawingContextImpl context)
{
var canvas = (context as ISkiaDrawingContextImpl)?.SkCanvas;
if (canvas == null)
context.DrawText(Brushes.Black, new Point(), _noSkia.PlatformImpl);
else
{
canvas.Save();
// create the first shader
var colors = new SKColor[]
{
new SKColor(0, 255, 255),
new SKColor(255, 0, 255),
new SKColor(255, 255, 0),
new SKColor(0, 255, 255)
};

var sx = Animate(100, 2, 10);
var sy = Animate(1000, 5, 15);
var lightPosition = new SKPoint(
(float)(Bounds.Width / 2 + Math.Cos(St.Elapsed.TotalSeconds) * Bounds.Width / 4),
(float)(Bounds.Height / 2 + Math.Sin(St.Elapsed.TotalSeconds) * Bounds.Height / 4)
);
using (var sweep =
SKShader.CreateSweepGradient(
new SKPoint((int)Bounds.Width / 2, (int)Bounds.Height / 2),
colors,
null
))
using (var turbulence = SKShader.CreatePerlinNoiseFractalNoise(0.05f, 0.05f, 4, 0))
using (var shader = SKShader.CreateCompose(sweep, turbulence, SKBlendMode.SrcATop))
using (var blur = SKImageFilter.CreateBlur(Animate(100, 2, 10), Animate(100, 5, 15)))
using (var paint = new SKPaint
{
Shader = shader,
ImageFilter = blur
})
canvas.DrawPaint(paint);

using (var pseudoLight = SKShader.CreateRadialGradient(
lightPosition,
(float)(Bounds.Width / 3),
new[]
{
new SKColor(255, 200, 200, 100),
SKColors.Transparent,
new SKColor(40, 40, 40, 220),
new SKColor(20, 20, 20, (byte)Animate(100, 200, 220))
},
new float[] { 0.3f, 0.3f, 0.8f, 1 },
SKShaderTileMode.Clamp
))
using (var paint = new SKPaint
{
Shader = pseudoLight
})
canvas.DrawPaint(paint);
canvas.Restore();
}
}

static int Animate(int d, int from, int to)
{
var ms = (int)(St.ElapsedMilliseconds / d);
var diff = to - from;
var range = diff * 2;
var v = ms % range;
if (v > diff)
v = range - v;
var rv = v + from;
if (rv < from || rv > to)
throw new Exception("WTF");
return rv;
}
}


public RenderControl() => ClipToBounds = true;


public override void Render(DrawingContext context)
{
var noSkia = new FormattedText()
{
Text = "Current rendering API is not Skia"
};
context.Custom(new CustomDrawOp(new Rect(0, 0, Bounds.Width, Bounds.Height), noSkia));
Dispatcher.UIThread.InvokeAsync(InvalidateVisual, DispatcherPriority.Background);
}
}
Loading

0 comments on commit b9ba39f

Please sign in to comment.