Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧Add automatic scene updates #690

Merged
merged 21 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
55fbf6e
Start work for issue #685
CalvinWilkinson Aug 17, 2023
e9c1084
chore: improve string perf in main window for testing app
CalvinWilkinson Aug 17, 2023
8f4e9fb
refactor: fix disposable pattern in window class
CalvinWilkinson Aug 17, 2023
17c5fa1
refactor: change order of private method
CalvinWilkinson Aug 17, 2023
22c8827
feat: add property to scene manager to know if it has been loaded
CalvinWilkinson Aug 17, 2023
6c4dadf
perf: add small changes to boost collection performance
CalvinWilkinson Aug 17, 2023
ac58a6f
feat: add prop to IRenderer that indicates if a batch has been started
CalvinWilkinson Aug 17, 2023
7df8424
chore: add method code comments to method and try catch to glwindow run
CalvinWilkinson Aug 17, 2023
5b6cea7
refactor: simple code cleanup
CalvinWilkinson Aug 17, 2023
248497b
refactor: simplify and improve renderer factory
CalvinWilkinson Aug 18, 2023
611e882
deps: add nbustitute nuget package to test project
CalvinWilkinson Aug 18, 2023
a0b4955
refactor!: replace IRenderer interface with IBatcher for batching
CalvinWilkinson Aug 18, 2023
6ad8834
feat!: add scene auto props
CalvinWilkinson Aug 18, 2023
1e1d5d4
chore: implement new batcher type into window render method
CalvinWilkinson Aug 18, 2023
544a01f
cleanup: adjust code to for cleanup purposes
CalvinWilkinson Aug 18, 2023
e26b14b
tests: combine unit test methods
CalvinWilkinson Aug 18, 2023
32fdfd9
refactor: refactor type names and comments related to rect to shape
CalvinWilkinson Aug 18, 2023
b41b0fb
ci: fix issues with sync bot workflow
CalvinWilkinson Aug 18, 2023
e5af25c
refactor: refactor word 'GPU' with 'Gpu'
CalvinWilkinson Aug 18, 2023
593b67a
refactor: refactor 'GPU' acronym to 'Gpu'
CalvinWilkinson Aug 18, 2023
d51a180
pr-changes: fix grammer and spelling issues
CalvinWilkinson Aug 18, 2023
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
7 changes: 4 additions & 3 deletions .github/workflows/sync-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
sync_bot:
name: Sync Bot Status Check
name: Sync Bot
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
Expand All @@ -32,20 +32,21 @@ jobs:
Write-Host "::notice::Issue: $issueNumber";

if ($manuallyExecuted -and $issueNumber -eq "0") {
Write-Host "::notice::The issue or PR number must be a value greater than 0.";
Write-Host "::error::The issue or PR number must be a value greater than 0.";
exit 1;
}

<# Deno Args:
1. Organization name
2. Project name
3. Issue number
4. Event Type - set to issue event type
4. Event type - set to issue event type
5. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
"${{ vars.ORGANIZATION_NAME }}" `
"${{ vars.PROJECT_NAME }}" `
"$issueNumber" `
"issue" `
Expand Down
35 changes: 19 additions & 16 deletions Testing/VelaptorTesting/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ namespace VelaptorTesting;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using Scenes;
using Velaptor;
using Velaptor.Batching;
using Velaptor.Factories;
using Velaptor.Graphics.Renderers;
using Velaptor.Input;
using Velaptor.UI;

Expand All @@ -28,19 +29,23 @@ public class MainWindow : Window
private readonly IAppInput<KeyboardState> keyboard;
private readonly Button nextButton;
private readonly Button previousButton;
private readonly IBatcher batcher;
private KeyboardState prevKeyState;

/// <summary>
/// Initializes a new instance of the <see cref="MainWindow"/> class.
/// </summary>
public MainWindow()
{
var rendererFactory = new RendererFactory();
this.batcher = rendererFactory.CreateBatcher();

this.keyboard = InputFactory.CreateKeyboard();

this.nextButton = new Button { Text = "-->" };
this.previousButton = new Button { Text = "<--" };

IRenderer.ClearColor = Color.FromArgb(255, 42, 42, 46);
this.batcher.ClearColor = Color.FromArgb(255, 42, 42, 46);

var textRenderingScene = new TextRenderingScene
{
Expand Down Expand Up @@ -140,15 +145,12 @@ protected override void OnLoad()
this.previousButton.Position = new Point(buttonGroupLeft, buttonTops);
this.nextButton.Position = new Point(this.previousButton.Position.X + (int)this.previousButton.Width + buttonSpacing, buttonTops);

SceneManager.LoadContent();
base.OnLoad();
}

/// <inheritdoc cref="Window.OnUpdate"/>
protected override void OnUpdate(FrameTime frameTime)
{
SceneManager.Update(frameTime);

Title = $"Scene: {SceneManager.CurrentScene?.Name ?? "No Scene Loaded"}";

var currentKeyState = this.keyboard.GetState();
Expand All @@ -174,17 +176,18 @@ protected override void OnUpdate(FrameTime frameTime)
/// <inheritdoc cref="Window.OnDraw"/>
protected override void OnDraw(FrameTime frameTime)
{
IRenderer.Clear();
IRenderer.Begin();
base.OnDraw(frameTime);

SceneManager.Render();
// Render the buttons after the 'base.OnDraw()'. With the rendering being set to auto,
// Anymore drawing has to be done after the base.OnDraw() call with the use of
CalvinWilkinson marked this conversation as resolved.
Show resolved Hide resolved
// the 'Begin()' and 'End()` methods.
this.batcher.Begin();

// Render the scene manager UI on top of all other textures
this.nextButton.Render();
this.previousButton.Render();

IRenderer.End();
base.OnDraw(frameTime);
this.batcher.End();
}

/// <inheritdoc cref="Window.OnUnload"/>
Expand All @@ -205,26 +208,26 @@ private static string SplitByUpperCase(string value)
{
var sections = new List<string>();

var currentSection = string.Empty;
var currentSection = new StringBuilder();

for (var i = 0; i < value.Length; i++)
{
var character = value[i];

if (UpperCaseChars.Contains(character) && i != 0)
{
sections.Add(currentSection);
sections.Add(currentSection.ToString());

currentSection = string.Empty;
currentSection += character;
currentSection.Clear();
currentSection.Append(character);
}
else
{
currentSection += character;
currentSection.Append(character);
}
}

sections.Add(currentSection);
sections.Add(currentSection.ToString());

var result = sections.Aggregate(string.Empty, (current, section) => current + $"{section} ");

Expand Down
8 changes: 6 additions & 2 deletions Testing/VelaptorTesting/Scenes/TextRenderingScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace VelaptorTesting.Scenes;

using System;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using Velaptor.Scene;
Expand Down Expand Up @@ -180,13 +181,15 @@ public override void LoadContent()

this.btnSetStyle.MouseUp += (_, _) =>
{
const string argName = $"{nameof(TextRenderingScene)}.{nameof(this.textFont)}.{nameof(this.textFont.Style)}";

this.textFont.Style = this.textFont.Style switch
{
FontStyle.Regular => FontStyle.Bold,
FontStyle.Bold => FontStyle.Italic,
FontStyle.Italic => FontStyle.Bold | FontStyle.Italic,
FontStyle.Bold | FontStyle.Italic => FontStyle.Regular,
_ => throw new ArgumentOutOfRangeException(nameof(this.textFont.Style), "FontStyle value invalid."),
_ => throw new InvalidEnumArgumentException(argName, (int)this.textFont.Style, typeof(FontStyle)),
};

this.btnSetStyle.Text = $"Style: {this.textFont.Style}";
Expand Down Expand Up @@ -356,7 +359,8 @@ private void LayoutButtonsLeftSide()
}

var totalHeight = (from b in buttons
select (int)b.Height).ToArray().Sum();
select (int)b.Height).Sum();

totalHeight += (buttons.Length - 1) * VertButtonSpacing;
var totalHalfHeight = totalHeight / 2;

Expand Down
Loading
Loading