Skip to content

Commit

Permalink
0.6.0.31 - Misc updates (#772)
Browse files Browse the repository at this point in the history
- Change OpenTaiko.log's encoding to UTF-8
- Fallback to SkiaSharp's default typeface if all other methods fail
- Log Egl related errors
  • Loading branch information
DragonRatTiger authored Dec 30, 2024
1 parent 65c4c77 commit f94adf2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
18 changes: 17 additions & 1 deletion FDK/src/01.Framework/Rendering/Angle/AngleContext.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using OpenTK.Graphics.Egl; //OpenTKさん ありがとう!
using Silk.NET.Core.Contexts;
using Silk.NET.GLFW;
Expand All @@ -13,18 +14,24 @@ public class AngleContext : IGLContext {
public AngleContext(AnglePlatformType anglePlatformType, IWindow window) {
nint windowHandle;
nint display;
NativeWindowFlags selectedflag; // For logging

if (window.Native.Kind.HasFlag(NativeWindowFlags.Win32)) {
selectedflag = NativeWindowFlags.Win32;
windowHandle = window.Native.Win32.Value.Hwnd;
display = window.Native.Win32.Value.HDC;
} else if (window.Native.Kind.HasFlag(NativeWindowFlags.X11)) {
selectedflag = NativeWindowFlags.X11;
windowHandle = (nint)window.Native.X11.Value.Window;
// Temporary fix for the segfaults
// Note than X11 Display number is NOT always 0, it can be 1, 2 and so on for example in cases of user switching
display = 0;// Egl.GetDisplay(window.Native.X11.Value.Display);
} else if (window.Native.Kind.HasFlag(NativeWindowFlags.Cocoa)) {
selectedflag = NativeWindowFlags.Cocoa;
windowHandle = window.Native.Cocoa.Value;
display = 0;
} else if (window.Native.Kind.HasFlag(NativeWindowFlags.Wayland)) {
selectedflag = NativeWindowFlags.Wayland;
windowHandle = window.Native.Wayland.Value.Surface;
display = window.Native.Wayland.Value.Display;
} else {
Expand Down Expand Up @@ -94,7 +101,16 @@ public AngleContext(AnglePlatformType anglePlatformType, IWindow window) {
//Surface = Egl.CreatePlatformWindowSurfaceEXT(Display, configs[0], windowHandle, null);
Surface = Egl.CreateWindowSurface(Display, configs[0], windowHandle, 0);

var error1 = Egl.GetError();
var error = Egl.GetError();
if (error != OpenTK.Graphics.Egl.ErrorCode.SUCCESS) {
Trace.TraceError("Ran into an error while setting up the window surface. OpenTaiko might be broken... :^(" +
$"\nEgl Error: {error}" +
$"\nWindow Flags: {window.Native.Kind} (Selected {selectedflag})" +
$"\nAnglePlatformType: {anglePlatformType}" +
$"\nDisplay: {Display}" +
$"\nContext: {Context}" +
$"\nSurface: {Surface}");
}
}

public nint Handle { get; set; }
Expand Down
9 changes: 8 additions & 1 deletion FDK/src/04.Graphics/TextRenderer/CSkiaSharpTextRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Drawing;
using System.Text.RegularExpressions;
using SkiaSharp;
Expand Down Expand Up @@ -57,8 +58,14 @@ protected void Initialize(string fontpath, int pt, CFontRenderer.FontStyle style
if (File.Exists(fontpath))
paint.Typeface = SKTypeface.FromFile(fontpath, 0);

if (paint.Typeface == null) {
Trace.TraceWarning($"The requested font '{fontpath}' could not be found from a file or font family name. Falling back to SkiaSharp's default typeface.");
paint.Typeface = SKTypeface.CreateDefault();
}

// If a font couldn't be loaded despite the fallback implemented above, we're absolutely cooked.
if (paint.Typeface == null)
throw new FileNotFoundException(fontpath);
throw new FileNotFoundException("All attempts to load this font failed, including using SkiaSharp's default typeface as a fallback.", fontpath);

paint.TextSize = (pt * 1.3f);
paint.IsAntialias = true;
Expand Down
17 changes: 17 additions & 0 deletions OpenTaiko/src/Common/ImGuiDebugWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,23 @@ private static void Profile() {
ImGui.EndCombo();
}

if (ImGui.TreeNodeEx("Edit Nameplate")) {

ImGui.InputInt("Title Id", ref OpenTaiko.SaveFileInstances[save].data.TitleId);

ImGui.InputText("Title", ref OpenTaiko.SaveFileInstances[save].data.Title, 1024);

ImGui.InputInt("Title Rarity", ref OpenTaiko.SaveFileInstances[save].data.TitleRarityInt);

ImGui.InputInt("Title Type", ref OpenTaiko.SaveFileInstances[save].data.TitleType);

if (ImGui.Button("Update")) {
OpenTaiko.SaveFileInstances[save].tApplyHeyaChanges();
OpenTaiko.NamePlate.tNamePlateRefreshTitles(save);
}
ImGui.TreePop();
}

if (ImGui.BeginCombo("Dan Title", OpenTaiko.SaveFileInstances[save].data.Dan)) {
foreach (var dan in OpenTaiko.SaveFileInstances[save].data.DanTitles) {
if (ImGui.Selectable(dan.Key)) {
Expand Down
2 changes: 1 addition & 1 deletion OpenTaiko/src/Common/OpenTaiko.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ private void tStartupProcess() {
Trace.AutoFlush = true;
if (ConfigIni.bOutputLogs) {
try {
Trace.Listeners.Add(new CTraceLogListener(new StreamWriter(System.IO.Path.Combine(strEXEのあるフォルダ, "OpenTaiko.log"), false, Encoding.GetEncoding(OpenTaiko.sEncType))));
Trace.Listeners.Add(new CTraceLogListener(new StreamWriter(System.IO.Path.Combine(strEXEのあるフォルダ, "OpenTaiko.log"), false, Encoding.UTF8)));
} catch (System.UnauthorizedAccessException) // #24481 2011.2.20 yyagi
{
int c = (CultureInfo.CurrentUICulture.TwoLetterISOLanguageName == "ja") ? 0 : 1;
Expand Down

0 comments on commit f94adf2

Please sign in to comment.