Skip to content

Commit

Permalink
Merge branch 'preview' into renovate/fluentassertions-6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinWilkinson authored Sep 17, 2024
2 parents 72deb06 + 3714e6c commit e1d6da5
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Testing/AvaloniaTesting/AvaloniaTesting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.2" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.2" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
24 changes: 12 additions & 12 deletions Testing/VelaptorTesting/Content/Atlas/Main-Atlas.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,68 @@
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",

"Bounds": "0, 0, 30, 36",
"Bounds": "0, 0, 30, 38",
"FrameIndex": 0,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "31, 0, 30, 36",
"Bounds": "31, 0, 30, 38",
"FrameIndex": 1,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "62, 0, 30, 36",
"Bounds": "62, 0, 30, 38",
"FrameIndex": 2,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "93, 0, 30, 36",
"Bounds": "93, 0, 30, 38",
"FrameIndex": 3,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "124, 0, 30, 36",
"Bounds": "124, 0, 30, 38",
"FrameIndex": 4,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "155, 0, 30, 36",
"Bounds": "155, 0, 30, 38",
"FrameIndex": 5,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "186, 0, 30, 36",
"Bounds": "186, 0, 30, 38",
"FrameIndex": 6,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "217, 0, 30, 36",
"Bounds": "217, 0, 30, 38",
"FrameIndex": 7,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "248, 0, 30, 36",
"Bounds": "248, 0, 30, 38",
"FrameIndex": 8,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "279, 0, 30, 36",
"Bounds": "279, 0, 30, 38",
"FrameIndex": 9,
"Name": "samus"
},
{
"$type": "Velaptor.Graphics.AtlasSubTextureData, Velaptor",
"Bounds": "3, 39, 75, 75",
"Bounds": "0, 39, 100, 100",
"FrameIndex": -1,
"Name": "octagon-flip"
"Name": "logo-flip"
}
]
Binary file modified Testing/VelaptorTesting/Content/Atlas/Main-Atlas.pdn
Binary file not shown.
Binary file modified Testing/VelaptorTesting/Content/Atlas/Main-Atlas.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 not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Testing/VelaptorTesting/Content/Audio/test-song.ogg
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion Testing/VelaptorTesting/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ public class MainWindow : Window
/// </summary>
public MainWindow()
{
this.batcher = RendererFactory.CreateBatcher();
Width = 1920;
Height = 1080;

this.batcher = RendererFactory.CreateBatcher();
this.keyboard = HardwareFactory.GetKeyboard();

this.batcher.ClearColor = Color.FromArgb(255, 42, 42, 46);
Expand Down
12 changes: 6 additions & 6 deletions Testing/VelaptorTesting/Scenes/AnimatedGraphicsScene.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="AnimatedGraphicsScene.cs" company="KinsonDigital">
// <copyright file="AnimatedGraphicsScene.cs" company="KinsonDigital">
// Copyright (c) KinsonDigital. All rights reserved.
// </copyright>

Expand Down Expand Up @@ -78,13 +78,13 @@ public override void LoadContent()

var sldSpeed = ctrlFactory.CreateSlider();
sldSpeed.Name = "sldSpeed";
sldSpeed.Text = "Speed:";
sldSpeed.Min = 8;
sldSpeed.Max = 500;
sldSpeed.Value = 32;
sldSpeed.Text = "Speed(fps):";
sldSpeed.Min = 0;
sldSpeed.Max = 60;
sldSpeed.Value = 60;
sldSpeed.ValueChanged += (_, speed) =>
{
this.animSpeed = speed;
this.animSpeed = 1000f / speed;
};

optForward.Selected += (_, _) =>
Expand Down
74 changes: 58 additions & 16 deletions Testing/VelaptorTesting/Scenes/AudioScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace VelaptorTesting.Scenes;
using System;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Numerics;
using KdGui;
using KdGui.Factories;
Expand All @@ -26,10 +27,12 @@ public class AudioScene : SceneBase
private ILoader<IAudio>? loader;
private IAudio? audio;
private ISlider? sldPosition;
private string? lblCurrentTimeName;
private string? lblStateName;
private string? lblRepeatsName;
private string? lblLengthName;
private string? lblCurrentTimeName;
private string? lblStateName;
private string? lblAudioTypeName;
private string? currentAudioType = "OGG";

/// <summary>
/// Initializes a new instance of the <see cref="AudioScene"/> class.
Expand All @@ -43,7 +46,7 @@ public override void LoadContent()
this.backgroundManager.Load(new Vector2(WindowCenter.X, WindowCenter.Y));

this.loader = ContentLoaderFactory.CreateAudioLoader();
this.audio = this.loader.Load("test-song", AudioBuffer.Stream);
this.audio = this.loader.Load("ridley-draygon-theme.ogg", AudioBuffer.Stream);

CreateInfoCtrls();
CreateAudioCtrls();
Expand All @@ -56,6 +59,9 @@ public override void Update(FrameTime frameTime)
{
var currentTime = GetFormattedTime(this.audio.Position.Minutes, this.audio.Position.Seconds);

var lblAudioType = this.grpInfoCtrls.GetControl<ILabel>(this.lblAudioTypeName);
lblAudioType.Text = $"Audio Type: {this.currentAudioType}";

var lblLengthCtrl = this.grpInfoCtrls.GetControl<ILabel>(this.lblLengthName);
lblLengthCtrl.Text = $"Audio Length: {GetFormattedTime(this.audio.Length.Minutes, this.audio.Length.Seconds)}";

Expand All @@ -69,6 +75,9 @@ public override void Update(FrameTime frameTime)
base.Update(frameTime);
}

/// <summary>
/// <inheritdoc cref="IDrawable.Render"/>
/// </summary>
public override void Render()
{
this.backgroundManager?.Render();
Expand Down Expand Up @@ -130,41 +139,73 @@ private void CreateInfoCtrls()
var lblDesc = this.ctrlFactory.CreateLabel();
lblDesc.Name = nameof(lblDesc);
lblDesc.Text = "Use the audio controls to manipulate the audio.";
lblDesc.Text += $"\n---------------------------------------------------------";

var lblState = this.ctrlFactory.CreateLabel();
lblState.Name = nameof(lblState);
this.lblStateName = nameof(lblState);
lblState.Text = "Audio State: Stopped";
var lblRepeats = this.ctrlFactory.CreateLabel();
lblRepeats.Name = nameof(lblRepeats);
this.lblRepeatsName = nameof(lblRepeats);
lblRepeats.Text = "Repeat Enabled: no";

var lblCurrentTime = this.ctrlFactory.CreateLabel();
this.lblCurrentTimeName = nameof(lblCurrentTime);
lblCurrentTime.Name = nameof(lblCurrentTime);
lblCurrentTime.Text = "Current Time: 00:00";
var lblAudioType = this.ctrlFactory.CreateLabel();
lblAudioType.Name = nameof(lblAudioType);
this.lblAudioTypeName = nameof(lblAudioType);
lblAudioType.Text = $"Audio Type: {this.currentAudioType ?? string.Empty}";

var lblLength = this.ctrlFactory.CreateLabel();
this.lblLengthName = nameof(lblLength);
lblLength.Name = nameof(lblLength);
lblLength.Text = "Audio Length: 00:00";

var lblRepeats = this.ctrlFactory.CreateLabel();
lblRepeats.Name = nameof(lblRepeats);
this.lblRepeatsName = nameof(lblRepeats);
lblRepeats.Text = "Repeat Enabled: no";
var lblCurrentTime = this.ctrlFactory.CreateLabel();
this.lblCurrentTimeName = nameof(lblCurrentTime);
lblCurrentTime.Name = nameof(lblCurrentTime);
lblCurrentTime.Text = "Current Time: 00:00";

var lblState = this.ctrlFactory.CreateLabel();
lblState.Name = nameof(lblState);
this.lblStateName = nameof(lblState);
lblState.Text = "Audio State: Stopped";

this.grpInfoCtrls = this.ctrlFactory.CreateControlGroup();
this.grpInfoCtrls.Title = "Audio Info";
this.grpInfoCtrls.AutoSizeToFitContent = true;
this.grpInfoCtrls.TitleBarVisible = false;

this.grpInfoCtrls.Add(lblDesc);
this.grpInfoCtrls.Add(lblRepeats);
this.grpInfoCtrls.Add(lblAudioType);
this.grpInfoCtrls.Add(lblLength);
this.grpInfoCtrls.Add(lblCurrentTime);
this.grpInfoCtrls.Add(lblState);
this.grpInfoCtrls.Add(lblDesc);
}

private void CreateAudioCtrls()
{
var audioList = this.ctrlFactory.CreateComboBox();
audioList.Label = "Audio File";

audioList.Items.Add("Ridley Draygon Theme (OGG)");
audioList.Items.Add("Ridleys Hideout (MP3)");
audioList.Items.Add("Mother Brain Final Battle (OGG)");
audioList.SelectedItemIndexChanged += (_, i) =>
{
this.audio.Stop();
this.loader.Unload(this.audio);
var chosenItem = audioList.Items[i];
var audioName = chosenItem switch
{
"Ridley Draygon Theme (OGG)" => "ridley-draygon-theme.ogg",
"Ridleys Hideout (MP3)" => "ridleys-hideout.mp3",
"Mother Brain Final Battle (OGG)" => "mother-brain-final-battle.ogg",
_ => throw new ArgumentException($"The audio item '{chosenItem}' is not supported."),
};
this.audio = this.loader.Load(audioName, AudioBuffer.Stream);
this.currentAudioType = Path.GetExtension(this.audio.FilePath).ToUpper().TrimStart('.');
};

var sldVolume = this.ctrlFactory.CreateSlider();
sldVolume.Name = nameof(sldVolume);
sldVolume.Min = 0f;
Expand Down Expand Up @@ -252,6 +293,7 @@ private void CreateAudioCtrls()
this.grpAudioCtrls.AutoSizeToFitContent = true;
this.grpAudioCtrls.TitleBarVisible = false;

this.grpAudioCtrls.Add(audioList);
this.grpAudioCtrls.Add(sldVolume);
this.grpAudioCtrls.Add(this.sldPosition);
this.grpAudioCtrls.Add(btnRewind);
Expand Down
2 changes: 1 addition & 1 deletion Testing/VelaptorTesting/Scenes/KeyboardScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public override void LoadContent()
this.grpControls.AutoSizeToFitContent = true;
this.grpControls.TitleBarVisible = false;

this.grpControls.Add(downKeys);
this.grpControls.Add(instructions);
this.grpControls.Add(downKeys);

base.LoadContent();
}
Expand Down
4 changes: 2 additions & 2 deletions Testing/VelaptorTesting/Scenes/NonAnimatedGraphicsScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ public override void Render()

this.textureRenderer.Render(
this.mainAtlas,
"octagon-flip",
"logo-flip",
new Vector2(WindowCenter.X, WindowCenter.Y),
0F,
1f,
2f,
Color.White,
this.renderEffects);

Expand Down
8 changes: 4 additions & 4 deletions Testing/VelaptorTesting/Scenes/ShapeScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private void CreateCircleCtrls()
var cmbCircleSolidColor = this.ctrlFactory.CreateComboBox();
cmbCircleSolidColor.Name = nameof(cmbCircleSolidColor);
this.cmbCircleSolidColorName = nameof(cmbCircleSolidColor);
cmbCircleSolidColor.Label = "Solid Color:";
cmbCircleSolidColor.Label = "Color:";
cmbCircleSolidColor.Width = 100;
cmbCircleSolidColor.Items =
[
Expand Down Expand Up @@ -388,8 +388,8 @@ private void CreateCircleGradCtrls()
this.grpCircleClrGradCtrls.Position = new Point(WindowPadding, WindowCenter.Y - this.grpCircleClrGradCtrls.HalfHeight);
};
this.grpCircleClrGradCtrls.Add(cmbCircleGradType);
this.grpCircleClrGradCtrls.Add(cmbCircleGradStopColor);
this.grpCircleClrGradCtrls.Add(cmbCircleGradStartColor);
this.grpCircleClrGradCtrls.Add(cmbCircleGradStopColor);
}

private void CreateRectGradCtrls()
Expand Down Expand Up @@ -457,8 +457,8 @@ private void CreateRectGradCtrls()
this.grpRectClrGradCtrls.Position = new Point(WindowPadding, WindowCenter.Y - this.grpRectClrGradCtrls.HalfHeight);
};
this.grpRectClrGradCtrls.Add(cmbRectGradType);
this.grpRectClrGradCtrls.Add(cmbRectGradStopColor);
this.grpRectClrGradCtrls.Add(cmbRectGradStartColor);
this.grpRectClrGradCtrls.Add(cmbRectGradStopColor);
}

private void CreateRectCtrls()
Expand Down Expand Up @@ -531,7 +531,7 @@ private void CreateRectCtrls()
var cmbRectSolidColor = this.ctrlFactory.CreateComboBox();
cmbRectSolidColor.Name = nameof(cmbRectSolidColor);
this.cmbRectSolidColorName = nameof(cmbRectSolidColor);
cmbRectSolidColor.Label = "Solid Color:";
cmbRectSolidColor.Label = "Color:";
cmbRectSolidColor.Width = 100;
cmbRectSolidColor.Items =
[
Expand Down
12 changes: 9 additions & 3 deletions Testing/VelaptorTesting/VelaptorTesting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@
<None Update="Content\Graphics\layered-rendering-background.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\Audio\test-song.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\Atlas\Main-Atlas.pdn">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\Audio\mother-brain-final-battle.ogg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Content\Audio\ridley-draygon-theme.ogg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Content\Audio\ridleys-hideout.mp3">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 2 additions & 5 deletions Velaptor/OpenGL/GLWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,8 @@ private void Init(uint width, uint height)
this.glInputContext.Mice[0].MouseMove += GLMouseMove_MouseMove;
this.glInputContext.Mice[0].Scroll += GLMouseInput_MouseScroll;

// Manually invoke the resize to set the viewport
// This will make sure that no strange issues occur during initialization.
// One strange issue was without this line and a window size of exactly 1280 x 720,
// all rendering would not occur. This prevents this issue from occurring.
GLWindow_Resize(new Vector2D<int>(1280, 720));
// Manually invoke the resize to update the rest of the system such as the viewport.
GLWindow_Resize(new Vector2D<int>((int)width, (int)height));

this.appService.Init();
}
Expand Down

0 comments on commit e1d6da5

Please sign in to comment.