Skip to content

Commit

Permalink
Add app icon to all host apps.
Browse files Browse the repository at this point in the history
Add logo to WASM host app.
  • Loading branch information
highbyte committed Aug 28, 2024
1 parent 31b49c8 commit 0635d88
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 11 deletions.
Binary file added resources/images/favicon.ico
Binary file not shown.
Binary file added resources/images/favicon.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 resources/images/logo.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 resources/images/logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/apps/Highbyte.DotNet6502.App.SadConsole/EmulatorConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class EmulatorConfig
{
public const string ConfigSectionName = "Highbyte.DotNet6502.SadConsoleConfig";

public string WindowTitle { get; set; }

/// <summary>
/// Optional. Font used for the UI. If not specified, default SadConsole font is used.
/// To use a specific SadConsole Font, include it in your program output directory.
Expand Down Expand Up @@ -53,7 +51,6 @@ public class EmulatorConfig

public EmulatorConfig()
{
WindowTitle = "SadConsole + Highbyte.DotNet6502 emulator.";
UIFont = null;
UIFontSize = Sizes.One;
DefaultEmulator = "C64";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ApplicationIcon>favicon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<None Remove="favicon.ico" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="favicon.ico" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\libraries\Highbyte.DotNet6502.Impl.NAudio\Highbyte.DotNet6502.Impl.NAudio.csproj" />
<ProjectReference Include="..\..\libraries\Highbyte.DotNet6502\Highbyte.DotNet6502.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using SadRogue.Primitives;
using Console = SadConsole.Console;


namespace Highbyte.DotNet6502.App.SadConsole;

/// <summary>
Expand Down Expand Up @@ -129,7 +128,7 @@ public void Run()
.AddFrameRenderEvent(RenderSadConsole)
;

Settings.WindowTitle = _emulatorConfig.WindowTitle;
Settings.WindowTitle = "Highbyte.DotNet6502 emulator + SadConsole (with NAudio)";
Settings.ResizeMode = Settings.WindowResizeOptions.None;

// Start SadConsole window
Expand Down
2 changes: 0 additions & 2 deletions src/apps/Highbyte.DotNet6502.App.SadConsole/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"Highbyte.DotNet6502.SadConsoleConfig": {

"WindowTitle": "Highbyte.DotNet6502 emulator + SadConsole",
"DefaultEmulator": "C64",
"UIFont": null, // UI Console font. Leave blank for default SadConsole font.
"UIFontSize": "One", // UI consoles font (not Emulator console). Possible values: "Quarter", "Half, "One", "Two", "Three", "Four", "Five"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="..\..\..\resources\images\favicon.ico" Link="Resources\Images\favicon.ico" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\libraries\Highbyte.DotNet6502.Impl.NAudio\Highbyte.DotNet6502.Impl.NAudio.csproj" />
<ProjectReference Include="..\..\libraries\Highbyte.DotNet6502\Highbyte.DotNet6502.csproj" />
Expand All @@ -32,4 +36,8 @@
</None>
</ItemGroup>

<ItemGroup>
<Folder Include="Resources\Images\" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/apps/Highbyte.DotNet6502.App.SilkNetNative/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

windowOptions.VSync = false; // TODO: With Vsync=true Silk.NET seem to use incorrect UpdatePerSecond. The actual FPS its called is 10 lower than it should be (measured in the OnUpdate method)
windowOptions.WindowState = WindowState.Normal;
windowOptions.Title = "Highbyte.DotNet6502 emulator in Silk.NET window (+ SkiaSharp, OpenGL, and NAudio)";
windowOptions.Title = "Highbyte.DotNet6502 emulator + Silk.NET (with SkiaSharp, OpenGL, NAudio)";
windowOptions.Size = new Vector2D<int>(windowWidth, windowHeight);
windowOptions.WindowBorder = WindowBorder.Fixed;
windowOptions.API = GraphicsAPI.Default; // = Default = OpenGL 3.3 with forward compatibility
Expand Down
10 changes: 10 additions & 0 deletions src/apps/Highbyte.DotNet6502.App.SilkNetNative/SilkNetHostApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Highbyte.DotNet6502.Systems;
using Highbyte.DotNet6502.Systems.Logging.InMem;
using Microsoft.Extensions.Logging;
using Silk.NET.Core;

namespace Highbyte.DotNet6502.App.SilkNetNative;

Expand Down Expand Up @@ -115,6 +116,8 @@ protected void OnLoad()
{
SetUninitializedWindow();

SetIcon();

_renderContextContainer = CreateRenderContext();
_inputHandlerContext = CreateInputHandlerContext();
_audioHandlerContext = CreateAudioHandlerContext();
Expand Down Expand Up @@ -143,6 +146,13 @@ protected void OnLoad()
_imGuiWindows.Add(_logsPanel);
}

private void SetIcon()
{
//RawImage icon = SilkNetImageLoader.ReadFileAsRawImage("../../../../../../resources/images/favicon.ico");
RawImage icon = SilkNetImageLoader.ReadFileAsRawImage("Highbyte.DotNet6502.App.SilkNetNative.Resources.Images.favicon.ico", isEmbeddedResource: true);
_window.SetWindowIcon(ref icon);
}

protected void OnClosing()
{
base.Close();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Reflection;
using Silk.NET.Core;

namespace Highbyte.DotNet6502.App.SilkNetNative;
public class SilkNetImageLoader
{
public static RawImage ReadFileAsRawImage(string path, bool isEmbeddedResource = false)
{
byte[] fileBytes;
if (isEmbeddedResource)
{
Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream? resourceStream = assembly.GetManifestResourceStream(path))
{
if (resourceStream == null)
throw new Exception($"Cannot open stream to resource {path} in current assembly.");
using (MemoryStream ms = new MemoryStream())
{
resourceStream.CopyTo(ms);
fileBytes = ms.ToArray();
}
}
}
else
{
fileBytes = File.ReadAllBytes(path);
}

var bitmap = SKBitmap.Decode(fileBytes);
byte[] bytes = new byte[bitmap.Pixels.Length * 4];
int index = 0;
foreach (var pixel in bitmap.Pixels)
{
bytes[index++] = pixel.Red;
bytes[index++] = pixel.Green;
bytes[index++] = pixel.Blue;
bytes[index++] = pixel.Alpha;
}
var rawImage = new RawImage(bitmap.Width, bitmap.Height, new Memory<byte>(bytes));
return rawImage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<ItemGroup>
<Folder Include="wwwroot\6502binaries\C64\Assembler\" />
<Folder Include="wwwroot\6502binaries\C64\Basic\" />
<Folder Include="wwwroot\images\" />
</ItemGroup>

<Target Name="CopyC64ExampleBinaries" AfterTargets="AfterBuild">
Expand All @@ -58,4 +59,8 @@
<Copy SourceFiles="..\..\..\samples\Assembler\Generic\Build\snake6502.prg" DestinationFolder="wwwroot\6502binaries\Generic\Assembler" />
</Target>

<Target Name="CopyImages" AfterTargets="AfterBuild">
<Copy SourceFiles="..\..\..\resources\images\logo.png" DestinationFolder="wwwroot\images" />
</Target>

</Project>
7 changes: 4 additions & 3 deletions src/apps/Highbyte.DotNet6502.App.WASM/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@
<div id="canvasUninitialized"
class="canvasUninitializedStyle">

<h2>
The DotNet 6502 emulator!
</h2>
<h2>
<img src="images/logo.png" align="middle" style="width:100px;height:100px;" title="DotNet 6502 logo">
The DotNet 6502 emulator!
</h2>

<p>
A <a href="https://en.wikipedia.org/wiki/MOS_Technology_6502" target="_blank">6502 CPU</a> emulator written in <a href="https://dotnet.microsoft.com/" target="_blank">.NET</a>, rendered with <a href="https://github.com/mono/SkiaSharp" target="_blank">SkiaSharp</a>, compiled to <a href="https://en.wikipedia.org/wiki/WebAssembly" target="_blank">WebAssembly</a> via <a href="https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor" target="_blank">Blazor</a>, running in a browser.
Expand Down
Binary file modified src/apps/Highbyte.DotNet6502.App.WASM/wwwroot/favicon.ico
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.

0 comments on commit 0635d88

Please sign in to comment.