From 9d83b340fbb281cae1a7d8c7382c2dceccda2bba Mon Sep 17 00:00:00 2001 From: Takkkom <76614532+Takkkom@users.noreply.github.com> Date: Sat, 27 Jan 2024 17:27:08 +0900 Subject: [PATCH] =?UTF-8?q?Window=E3=81=AEicon=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20(#569)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FDK/src/01.Framework/Core/Game.cs | 20 ++++++++++++++++++-- OpenTaiko/src/Common/TJAPlayer3.cs | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/FDK/src/01.Framework/Core/Game.cs b/FDK/src/01.Framework/Core/Game.cs index 791a12e6..ed8a3924 100644 --- a/FDK/src/01.Framework/Core/Game.cs +++ b/FDK/src/01.Framework/Core/Game.cs @@ -30,6 +30,7 @@ using SkiaSharp; using FDK; using Silk.NET.GLFW; using System.Runtime.InteropServices; +using Silk.NET.Core; namespace SampleFramework { @@ -43,6 +44,8 @@ namespace SampleFramework internal static List AsyncActions = new(); + private string strIconFileName; + protected string _Text = ""; protected string Text { @@ -244,11 +247,20 @@ namespace SampleFramework //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()); + } + /// /// Initializes a new instance of the class. /// - protected Game() + protected Game(string iconFileName) { + strIconFileName = iconFileName; + MainThreadID = Thread.CurrentThread.ManagedThreadId; Configuration(); @@ -266,11 +278,13 @@ namespace SampleFramework options.API = GraphicsAPI.None; options.WindowBorder = WindowBorder.Resizable; options.Title = Text; - + + Silk.NET.Windowing.Glfw.GlfwWindowing.Use(); //Silk.NET.Windowing.Sdl.SdlWindowing.Use(); Window_ = Window.Create(options); + Window_.Load += Window_Load; Window_.Closing += Window_Closing; Window_.Update += Window_Update; @@ -393,6 +407,8 @@ namespace SampleFramework public void Window_Load() { + Window_.SetWindowIcon(new ReadOnlySpan(GetIconData(strIconFileName))); + Context = new AngleContext(GraphicsDeviceType_, Window_); Context.MakeCurrent(); diff --git a/OpenTaiko/src/Common/TJAPlayer3.cs b/OpenTaiko/src/Common/TJAPlayer3.cs index 09e2d704..2dec7fcc 100644 --- a/OpenTaiko/src/Common/TJAPlayer3.cs +++ b/OpenTaiko/src/Common/TJAPlayer3.cs @@ -539,7 +539,7 @@ namespace TJAPlayer3 // コンストラクタ - public TJAPlayer3() + public TJAPlayer3() : base("OpenTaiko.ico") { TJAPlayer3.app = this; }