1
0
mirror of synced 2024-11-24 07:30:21 +01:00

Windowのiconを修正 (#569)

This commit is contained in:
Takkkom 2024-01-27 17:27:08 +09:00 committed by GitHub
parent a97ea616e3
commit 9d83b340fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View File

@ -30,6 +30,7 @@ using SkiaSharp;
using FDK; using FDK;
using Silk.NET.GLFW; using Silk.NET.GLFW;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Silk.NET.Core;
namespace SampleFramework namespace SampleFramework
{ {
@ -43,6 +44,8 @@ namespace SampleFramework
internal static List<Action> AsyncActions = new(); internal static List<Action> AsyncActions = new();
private string strIconFileName;
protected string _Text = ""; protected string _Text = "";
protected string Text protected string Text
{ {
@ -244,11 +247,20 @@ namespace SampleFramework
//GetError(); //GetError();
} }
private RawImage GetIconData(string fileName)
{
SKCodec codec = SKCodec.Create(fileName);
using SKBitmap bitmap = SKBitmap.Decode(codec, new SKImageInfo(codec.Info.Width, codec.Info.Height, SKColorType.Rgba8888));
return new RawImage(bitmap.Width, bitmap.Height, bitmap.GetPixelSpan().ToArray());
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Game"/> class. /// Initializes a new instance of the <see cref="Game"/> class.
/// </summary> /// </summary>
protected Game() protected Game(string iconFileName)
{ {
strIconFileName = iconFileName;
MainThreadID = Thread.CurrentThread.ManagedThreadId; MainThreadID = Thread.CurrentThread.ManagedThreadId;
Configuration(); Configuration();
@ -266,11 +278,13 @@ namespace SampleFramework
options.API = GraphicsAPI.None; options.API = GraphicsAPI.None;
options.WindowBorder = WindowBorder.Resizable; options.WindowBorder = WindowBorder.Resizable;
options.Title = Text; options.Title = Text;
Silk.NET.Windowing.Glfw.GlfwWindowing.Use(); Silk.NET.Windowing.Glfw.GlfwWindowing.Use();
//Silk.NET.Windowing.Sdl.SdlWindowing.Use(); //Silk.NET.Windowing.Sdl.SdlWindowing.Use();
Window_ = Window.Create(options); Window_ = Window.Create(options);
Window_.Load += Window_Load; Window_.Load += Window_Load;
Window_.Closing += Window_Closing; Window_.Closing += Window_Closing;
Window_.Update += Window_Update; Window_.Update += Window_Update;
@ -393,6 +407,8 @@ namespace SampleFramework
public void Window_Load() public void Window_Load()
{ {
Window_.SetWindowIcon(new ReadOnlySpan<RawImage>(GetIconData(strIconFileName)));
Context = new AngleContext(GraphicsDeviceType_, Window_); Context = new AngleContext(GraphicsDeviceType_, Window_);
Context.MakeCurrent(); Context.MakeCurrent();

View File

@ -539,7 +539,7 @@ namespace TJAPlayer3
// コンストラクタ // コンストラクタ
public TJAPlayer3() public TJAPlayer3() : base("OpenTaiko.ico")
{ {
TJAPlayer3.app = this; TJAPlayer3.app = this;
} }