Fix UIColor layout (#1998)

* Fix UIColor layout

* Handle <color(0)> correctly
This commit is contained in:
srkizer 2024-08-07 05:31:24 +09:00 committed by GitHub
parent 88bb224894
commit 018524fb8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 105 additions and 66 deletions

View file

@ -148,10 +148,12 @@ internal sealed class SeStringColorStackSet
if (expr.TryGetUInt(out var bgra))
{
// NOTE: if it reads a `0`, then it seems to be doing something else.
// See case 0x12 from `Component::GUI::AtkFontAnalyzerBase.vf4`.
// Fix when someone figures what's this about.
rgbaStack.Add(ColorHelpers.SwapRedBlue(bgra) | 0xFF000000u);
// <color(0)> adds the color on the top of the stack. This makes usages like <color(gnum99)> effectively
// become a no-op if no value is provided.
if (bgra == 0)
rgbaStack.Add(rgbaStack[^1]);
else
rgbaStack.Add(ColorHelpers.SwapRedBlue(bgra) | 0xFF000000u);
return rgbaStack[^1];
}