fix: Fixes issue with cached static gump strings. Fixes bad gump colors (#1771)
### Summary - Fixes an issue that causes CUO to crash due to bad string caching in static gumps - Fixes wrong/bad 16bit html gump hues. - Moves `C16232` (16-bit to 32-bit) and `C32216` (32-bit to 16-bit) to Utility class for broader use. TODO: - Some gumps have different 32bit (for string content) vs 16bit (for localized content) strings. Does this matter?
This commit is contained in:
parent
a001eb03da
commit
622250b8f4
27 changed files with 129 additions and 155 deletions
|
|
@ -91,8 +91,10 @@ public ref struct GumpStringsBuilder
|
|||
|
||||
if (_finalizeLayout)
|
||||
{
|
||||
_hashes[hash] = _stringsCount++;
|
||||
_hashes[hash] = _stringsCount;
|
||||
}
|
||||
|
||||
_stringsCount++;
|
||||
}
|
||||
|
||||
public void FinalizeStrings(ref StaticGumpBuilder builder)
|
||||
|
|
|
|||
|
|
@ -50,22 +50,15 @@ public static class TextDefinitionExtensions
|
|||
}
|
||||
else if (def.String != null)
|
||||
{
|
||||
if (stringColor >= 0) // 8 bits per RGB component (24 bit RGB)
|
||||
{
|
||||
builder.AddHtml(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
def.String.Color(stringColor),
|
||||
back,
|
||||
scroll
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AddHtml(x, y, width, height, def.String, back, scroll);
|
||||
}
|
||||
builder.AddHtml(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
stringColor >= 0 ? def.String.Color(stringColor) : def.String, // 8 bits per RGB component (24 bit RGB)
|
||||
back,
|
||||
scroll
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,22 +93,15 @@ public static class TextDefinitionExtensions
|
|||
}
|
||||
else if (def.String != null)
|
||||
{
|
||||
if (stringColor >= 0) // 8 bits per RGB component (24 bit RGB)
|
||||
{
|
||||
builder.AddHtml(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
def.String.Color(stringColor),
|
||||
back,
|
||||
scroll
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AddHtml(x, y, width, height, def.String, back, scroll);
|
||||
}
|
||||
builder.AddHtml(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
stringColor >= 0 ? def.String.Color(stringColor) : def.String, // 8 bits per RGB component (24 bit RGB)
|
||||
back,
|
||||
scroll
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,22 +136,15 @@ public static class TextDefinitionExtensions
|
|||
}
|
||||
else if (def.String != null)
|
||||
{
|
||||
if (stringColor >= 0) // 8 bits per RGB component (24 bit RGB)
|
||||
{
|
||||
g.AddHtml(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
def.String.Color(stringColor),
|
||||
back,
|
||||
scroll
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.AddHtml(x, y, width, height, def.String, back, scroll);
|
||||
}
|
||||
g.AddHtml(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
stringColor >= 0 ? def.String.Color(stringColor) : def.String, // 8 bits per RGB component (24 bit RGB)
|
||||
back,
|
||||
scroll
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -195,22 +174,15 @@ public static class TextDefinitionExtensions
|
|||
}
|
||||
else if (def.String != null)
|
||||
{
|
||||
if (stringColor >= 0) // 8 bits per RGB component (24 bit RGB)
|
||||
{
|
||||
g.AddHtml(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
string.Format(def.String, args).Color(stringColor),
|
||||
back,
|
||||
scroll
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.AddHtml(x, y, width, height, string.Format(def.String, args), back, scroll);
|
||||
}
|
||||
g.AddHtml(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
stringColor >= 0 ? string.Format(def.String, args).Color(stringColor) : string.Format(def.String, args), // 8 bits per RGB component (24 bit RGB)
|
||||
back,
|
||||
scroll
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1528,4 +1528,28 @@ public static class Utility
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int C16232(this int c16)
|
||||
{
|
||||
c16 &= 0x7FFF;
|
||||
|
||||
var r = ((c16 >> 10) & 0x1F) << 3;
|
||||
var g = ((c16 >> 05) & 0x1F) << 3;
|
||||
var b = (c16 & 0x1F) << 3;
|
||||
|
||||
return (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
public static int C16216(this int c16) => c16 & 0x7FFF;
|
||||
|
||||
public static int C32216(this int c32)
|
||||
{
|
||||
c32 &= 0xFFFFFF;
|
||||
|
||||
var r = ((c32 >> 16) & 0xFF) >> 3;
|
||||
var g = ((c32 >> 08) & 0xFF) >> 3;
|
||||
var b = (c32 & 0xFF) >> 3;
|
||||
|
||||
return (r << 10) | (g << 5) | b;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue