mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
- fixed hires replacements for colorized font characters.
This commit is contained in:
parent
454816299e
commit
f0d2aef9d9
6 changed files with 18 additions and 17 deletions
|
@ -968,10 +968,11 @@ int FFont::GetMaxAscender(const uint8_t* string) const
|
|||
|
||||
void FFont::LoadTranslations()
|
||||
{
|
||||
unsigned int count = LastChar - FirstChar + 1;
|
||||
unsigned int count = min<unsigned>(Chars.Size(), LastChar - FirstChar + 1);
|
||||
uint32_t usedcolors[256] = {};
|
||||
TArray<double> Luminosity;
|
||||
|
||||
if (count == 0) return;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
if (Chars[i].OriginalPic)
|
||||
|
@ -1005,6 +1006,7 @@ void FFont::LoadTranslations()
|
|||
|
||||
FFont::FFont (int lump, FName nm)
|
||||
{
|
||||
FirstChar = LastChar = 0;
|
||||
Next = FirstFont;
|
||||
FirstFont = this;
|
||||
Lump = lump;
|
||||
|
|
|
@ -105,7 +105,6 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FGameTexture
|
|||
auto pic = charlumps[i];
|
||||
Chars[i].OriginalPic = MakeGameTexture(pic->GetTexture(), nullptr, ETextureType::FontChar);
|
||||
Chars[i].OriginalPic->CopySize(pic, true);
|
||||
Chars[i].OriginalPic->SetName(FStringf("@@%s.%d", name, i));
|
||||
TexMan.AddGameTexture(Chars[i].OriginalPic);
|
||||
Chars[i].XMove = (int)Chars[i].OriginalPic->GetDisplayWidth();
|
||||
if (sysCallbacks.FontCharCreated) sysCallbacks.FontCharCreated(pic, Chars[i].OriginalPic);
|
||||
|
|
|
@ -1547,7 +1547,7 @@ DEFINE_ACTION_FUNCTION(_Raze, PickTexture)
|
|||
PARAM_PROLOGUE;
|
||||
PARAM_INT(texid);
|
||||
TexturePick pick;
|
||||
if (PickTexture(nullptr, TexMan.GetGameTexture(FSetTextureID(texid)), TRANSLATION(Translation_Remap, 0), pick))
|
||||
if (PickTexture(TexMan.GetGameTexture(FSetTextureID(texid)), TRANSLATION(Translation_Remap, 0), pick))
|
||||
{
|
||||
ACTION_RETURN_INT(pick.texture->GetID().GetIndex());
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ static int compareChar(int code, FFont* gamefont, FFont* myfont)
|
|||
|
||||
// If there's a hires version attached to the base, treat this as the base being different.
|
||||
TexturePick pick;
|
||||
if (PickTexture(nullptr, c1, 0, pick) && pick.texture != c1) return 0;
|
||||
if (PickTexture(c1, 0, pick) && pick.texture != c1) return 0;
|
||||
|
||||
auto t1 = c1->GetTexture();
|
||||
auto t2 = c2->GetTexture();
|
||||
|
|
|
@ -489,7 +489,6 @@ struct SetAnim
|
|||
};
|
||||
|
||||
void processSetAnim(const char* cmd, FScriptPosition& pos, SetAnim& imp);
|
||||
class FRenderState;
|
||||
class FGameTexture;
|
||||
bool PickTexture(FRenderState* state, FGameTexture* tex, int paletteid, TexturePick& pick);
|
||||
bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wantindexed = false);
|
||||
|
||||
|
|
|
@ -322,18 +322,22 @@ int tileSetSkybox(int picnum, int palnum, FString* facenames)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
bool PickTexture(FRenderState *state, FGameTexture* tex, int paletteid, TexturePick& pick)
|
||||
bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wantindexed)
|
||||
{
|
||||
if (!tex->isValid() || tex->GetTexelWidth() <= 0 || tex->GetTexelHeight() <= 0) return false;
|
||||
|
||||
if (tex->GetUseType() == ETextureType::FontChar && paletteid != 0)
|
||||
{
|
||||
int a = 0;
|
||||
}
|
||||
|
||||
int usepalette = 0, useremap = 0;
|
||||
if (!IsLuminosityTranslation(paletteid))
|
||||
{
|
||||
usepalette = paletteid == 0 ? 0 : GetTranslationType(paletteid) - Translation_Remap;
|
||||
useremap = GetTranslationIndex(paletteid);
|
||||
}
|
||||
bool foggy = state && (state->GetFogColor() & 0xffffff);
|
||||
int TextureType = hw_int_useindexedcolortextures && !foggy? TT_INDEXED : TT_TRUECOLOR;
|
||||
int TextureType = wantindexed? TT_INDEXED : TT_TRUECOLOR;
|
||||
|
||||
pick.translation = paletteid;
|
||||
pick.basepalTint = 0xffffff;
|
||||
|
@ -344,11 +348,7 @@ bool PickTexture(FRenderState *state, FGameTexture* tex, int paletteid, TextureP
|
|||
|
||||
int hipalswap = usepalette >= 0 ? useremap : 0;
|
||||
auto rep = (hw_hightile && !(h.tintFlags & TINTF_ALWAYSUSEART)) ? FindReplacement(tex->GetID(), hipalswap, false) : nullptr;
|
||||
if (IsLuminosityTranslation(paletteid))
|
||||
{
|
||||
// For a luminosity translation we only want the plain texture as-is.
|
||||
}
|
||||
else if (rep || tex->GetTexture()->isHardwareCanvas())
|
||||
if (rep || tex->GetTexture()->isHardwareCanvas())
|
||||
{
|
||||
if (usepalette > 0)
|
||||
{
|
||||
|
@ -364,7 +364,7 @@ bool PickTexture(FRenderState *state, FGameTexture* tex, int paletteid, TextureP
|
|||
}
|
||||
if (!rep || rep->palnum != hipalswap || (h.tintFlags & TINTF_APPLYOVERALTPAL))
|
||||
applytint = true;
|
||||
pick.translation = 0;
|
||||
if (!IsLuminosityTranslation(paletteid)) pick.translation = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -376,7 +376,7 @@ bool PickTexture(FRenderState *state, FGameTexture* tex, int paletteid, TextureP
|
|||
applytint = true;
|
||||
if (!(h.tintFlags & TINTF_APPLYOVERPALSWAP)) useremap = 0;
|
||||
}
|
||||
pick.translation = paletteid == 0? 0 : TRANSLATION(usepalette + Translation_Remap, useremap);
|
||||
pick.translation = IsLuminosityTranslation(paletteid)? paletteid : paletteid == 0? 0 : TRANSLATION(usepalette + Translation_Remap, useremap);
|
||||
}
|
||||
else pick.translation |= 0x80000000;
|
||||
}
|
||||
|
@ -403,7 +403,8 @@ bool PreBindTexture(FRenderState* state, FGameTexture*& tex, EUpscaleFlags& flag
|
|||
|
||||
if (tex->GetUseType() == ETextureType::Special) return true;
|
||||
|
||||
if (PickTexture(state, tex, translation, pick))
|
||||
bool foggy = state && (state->GetFogColor() & 0xffffff);
|
||||
if (PickTexture(tex, translation, pick, hw_int_useindexedcolortextures && !foggy))
|
||||
{
|
||||
int TextureType = (pick.translation & 0x80000000) ? TT_INDEXED : TT_TRUECOLOR;
|
||||
int lookuppal = pick.translation & 0x7fffffff;
|
||||
|
|
Loading…
Reference in a new issue