-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from tgiachi/dev
Dev
- Loading branch information
Showing
69 changed files
with
1,026 additions
and
4,496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.