migrate to FTranslationID support

So far this only adapts to the changes in the backend without making further use of this type.
This commit is contained in:
Christoph Oelckers 2023-11-09 19:22:32 +01:00
parent 990cf3eafc
commit c19fd602d5
23 changed files with 107 additions and 53 deletions

View file

@ -10,6 +10,7 @@ class FGameTexture;
class FTextureID; class FTextureID;
enum EUpscaleFlags : int; enum EUpscaleFlags : int;
class FConfigFile; class FConfigFile;
struct FTranslationID;
struct SystemCallbacks struct SystemCallbacks
{ {

View file

@ -220,7 +220,7 @@ FRemapTable* PaletteContainer::AddRemap(FRemapTable* remap)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void PaletteContainer::UpdateTranslation(int trans, FRemapTable* remap) void PaletteContainer::UpdateTranslation(FTranslationID trans, FRemapTable* remap)
{ {
auto newremap = AddRemap(remap); auto newremap = AddRemap(remap);
TranslationTables[GetTranslationType(trans)].SetVal(GetTranslationIndex(trans), newremap); TranslationTables[GetTranslationType(trans)].SetVal(GetTranslationIndex(trans), newremap);
@ -232,7 +232,7 @@ void PaletteContainer::UpdateTranslation(int trans, FRemapTable* remap)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count) FTranslationID PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count)
{ {
uint32_t id = 0; uint32_t id = 0;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -249,9 +249,9 @@ int PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void PaletteContainer::CopyTranslation(int dest, int src) void PaletteContainer::CopyTranslation(FTranslationID dest, FTranslationID src)
{ {
TranslationTables[GetTranslationType(dest)].SetVal(GetTranslationIndex(dest), TranslationToTable(src)); TranslationTables[GetTranslationType(dest)].SetVal(GetTranslationIndex(dest), TranslationToTable(src.index()));
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -260,8 +260,9 @@ void PaletteContainer::CopyTranslation(int dest, int src)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
FRemapTable *PaletteContainer::TranslationToTable(int translation) FRemapTable *PaletteContainer::TranslationToTable(int translation) const
{ {
if (IsLuminosityTranslation(translation)) return nullptr;
unsigned int type = GetTranslationType(translation); unsigned int type = GetTranslationType(translation);
unsigned int index = GetTranslationIndex(translation); unsigned int index = GetTranslationIndex(translation);
@ -278,14 +279,14 @@ FRemapTable *PaletteContainer::TranslationToTable(int translation)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int PaletteContainer::StoreTranslation(int slot, FRemapTable *remap) FTranslationID PaletteContainer::StoreTranslation(int slot, FRemapTable *remap)
{ {
unsigned int i; unsigned int i;
auto size = NumTranslations(slot); auto size = NumTranslations(slot);
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
{ {
if (*remap == *TranslationToTable(TRANSLATION(slot, i))) if (*remap == *TranslationToTable(TRANSLATION(slot, i).index()))
{ {
// A duplicate of this translation already exists // A duplicate of this translation already exists
return TRANSLATION(slot, i); return TRANSLATION(slot, i);
@ -821,8 +822,8 @@ bool FRemapTable::AddColors(int start, int count, const uint8_t*colors, int tran
} }
// placeholder // placeholder
int R_FindCustomTranslation(FName name) FTranslationID R_FindCustomTranslation(FName name)
{ {
return -1; return NO_TRANSLATION;
} }

View file

@ -43,6 +43,8 @@ private:
}; };
// outside facing translation ID
struct FTranslationID struct FTranslationID
{ {
public: public:
@ -67,21 +69,22 @@ public:
{ {
return ID == other.ID; return ID == other.ID;
} }
bool operator ==(int other) const = delete;
bool operator !=(int other) const = delete;
constexpr int index() const constexpr int index() const
{ {
return ID; return ID;
} }
constexpr bool isvalid() const constexpr bool isvalid() const
{ {
return ID > 0; return ID >= 0;
} }
private: private:
int ID; int ID;
}; };
constexpr FTranslationID NO_TRANSLATION = FTranslationID::fromInt(0);
constexpr FTranslationID INVALID_TRANSLATION = FTranslationID::fromInt(-1);
// A class that initializes unusued pointers to NULL. This is used so that when // A class that initializes unusued pointers to NULL. This is used so that when
// the TAutoGrowArray below is expanded, the new elements will be NULLed. // the TAutoGrowArray below is expanded, the new elements will be NULLed.
class FRemapTablePtr class FRemapTablePtr
@ -107,28 +110,45 @@ enum
TRANSLATIONTYPE_MASK = (255 << TRANSLATION_SHIFT) TRANSLATIONTYPE_MASK = (255 << TRANSLATION_SHIFT)
}; };
inline constexpr uint32_t TRANSLATION(uint8_t a, uint32_t b) inline constexpr FTranslationID TRANSLATION(uint8_t a, uint32_t b)
{ {
return (a << TRANSLATION_SHIFT) | b; return FTranslationID::fromInt((a << TRANSLATION_SHIFT) | b);
} }
inline constexpr uint32_t LuminosityTranslation(int range, uint8_t min, uint8_t max) inline constexpr int MakeLuminosityTranslation(int range, uint8_t min, uint8_t max)
{ {
// ensure that the value remains positive. // ensure that the value remains positive.
return ( (1 << 30) | ((range&0x3fff) << 16) | (min << 8) | max ); return ( (1 << 30) | ((range&0x3fff) << 16) | (min << 8) | max );
} }
inline constexpr bool IsLuminosityTranslation(FTranslationID trans)
{
return trans.index() > 0 && (trans.index() & (1 << 30));
}
inline constexpr bool IsLuminosityTranslation(int trans) inline constexpr bool IsLuminosityTranslation(int trans)
{ {
return trans > 0 && (trans & (1 << 30)); return trans > 0 && (trans & (1 << 30));
} }
inline constexpr int GetTranslationType(uint32_t trans) inline constexpr int GetTranslationType(FTranslationID trans)
{
assert(!IsLuminosityTranslation(trans));
return (trans.index() & TRANSLATIONTYPE_MASK) >> TRANSLATION_SHIFT;
}
inline constexpr int GetTranslationIndex(FTranslationID trans)
{
assert(!IsLuminosityTranslation(trans));
return (trans.index() & TRANSLATION_MASK);
}
inline constexpr int GetTranslationType(int trans)
{ {
assert(!IsLuminosityTranslation(trans)); assert(!IsLuminosityTranslation(trans));
return (trans & TRANSLATIONTYPE_MASK) >> TRANSLATION_SHIFT; return (trans & TRANSLATIONTYPE_MASK) >> TRANSLATION_SHIFT;
} }
inline constexpr int GetTranslationIndex(uint32_t trans) inline constexpr int GetTranslationIndex(int trans)
{ {
assert(!IsLuminosityTranslation(trans)); assert(!IsLuminosityTranslation(trans));
return (trans & TRANSLATION_MASK); return (trans & TRANSLATION_MASK);
@ -162,11 +182,11 @@ public:
void Clear(); void Clear();
int DetermineTranslucency(FileReader& file); int DetermineTranslucency(FileReader& file);
FRemapTable* AddRemap(FRemapTable* remap); FRemapTable* AddRemap(FRemapTable* remap);
void UpdateTranslation(int trans, FRemapTable* remap); void UpdateTranslation(FTranslationID trans, FRemapTable* remap);
int AddTranslation(int slot, FRemapTable* remap, int count = 1); FTranslationID AddTranslation(int slot, FRemapTable* remap, int count = 1);
void CopyTranslation(int dest, int src); void CopyTranslation(FTranslationID dest, FTranslationID src);
int StoreTranslation(int slot, FRemapTable* remap); FTranslationID StoreTranslation(int slot, FRemapTable* remap);
FRemapTable* TranslationToTable(int translation); FRemapTable* TranslationToTable(int translation) const;
void GenerateGlobalBrightmapFromColormap(const uint8_t* cmapdata, int numlevels); void GenerateGlobalBrightmapFromColormap(const uint8_t* cmapdata, int numlevels);
void PushIdentityTable(int slot) void PushIdentityTable(int slot)
@ -174,7 +194,7 @@ public:
AddTranslation(slot, nullptr); AddTranslation(slot, nullptr);
} }
FRemapTable* GetTranslation(int slot, int index) FRemapTable* GetTranslation(int slot, int index) const
{ {
if (TranslationTables.Size() <= (unsigned)slot) return nullptr; if (TranslationTables.Size() <= (unsigned)slot) return nullptr;
return TranslationTables[slot].GetVal(index); return TranslationTables[slot].GetVal(index);
@ -192,6 +212,28 @@ public:
return TranslationTables[slot].Size(); return TranslationTables[slot].Size();
} }
};
struct LuminosityTranslationDesc
{
int colorrange;
int lum_min;
int lum_max;
static LuminosityTranslationDesc fromInt(int translation)
{
LuminosityTranslationDesc t;
t.colorrange = (translation >> 16) & 0x3fff;
t.lum_min = (translation >> 8) & 0xff;
t.lum_max = translation & 0xff;
return t;
}
static LuminosityTranslationDesc fromID(FTranslationID translation)
{
return fromInt(translation.index());
}
}; };
extern PaletteContainer GPalette; extern PaletteContainer GPalette;

View file

@ -1060,7 +1060,7 @@ void FFont::LoadTranslations()
for (int i = 0; i < NumTextColors; i++) for (int i = 0; i < NumTextColors; i++)
{ {
if (i == CR_UNTRANSLATED) Translations[i] = 0; if (i == CR_UNTRANSLATED) Translations[i] = 0;
else Translations[i] = LuminosityTranslation(i*2 + TranslationType, minlum, maxlum); else Translations[i] = MakeLuminosityTranslation(i*2 + TranslationType, minlum, maxlum);
} }
} }

View file

@ -324,7 +324,7 @@ public:
for (int i = 0; i < NumTextColors; i++) for (int i = 0; i < NumTextColors; i++)
{ {
if (i == CR_UNTRANSLATED) Translations[i] = 0; if (i == CR_UNTRANSLATED) Translations[i] = 0;
else Translations[i] = LuminosityTranslation(i * 2 + 1, minlum, maxlum); else Translations[i] = MakeLuminosityTranslation(i * 2 + 1, minlum, maxlum);
} }
} }
@ -388,7 +388,7 @@ public:
for (int i = 0; i < NumTextColors; i++) for (int i = 0; i < NumTextColors; i++)
{ {
if (i == CR_UNTRANSLATED) Translations[i] = 0; if (i == CR_UNTRANSLATED) Translations[i] = 0;
else Translations[i] = LuminosityTranslation(i * 2, minlum, maxlum); else Translations[i] = MakeLuminosityTranslation(i * 2, minlum, maxlum);
} }
} }
}; };

View file

@ -195,7 +195,7 @@ void FSingleLumpFont::LoadTranslations()
for (int i = 0; i < NumTextColors; i++) for (int i = 0; i < NumTextColors; i++)
{ {
if (i == CR_UNTRANSLATED) Translations[i] = 0; if (i == CR_UNTRANSLATED) Translations[i] = 0;
else Translations[i] = LuminosityTranslation(i * 2 + (FontType == FONT1 ? 1 : 0), minlum, maxlum); else Translations[i] = MakeLuminosityTranslation(i * 2 + (FontType == FONT1 ? 1 : 0), minlum, maxlum);
} }
} }

View file

@ -196,7 +196,7 @@ void FSpecialFont::LoadTranslations()
remap.Remap[i] = i; remap.Remap[i] = i;
} }
} }
trans = GPalette.StoreTranslation(TRANSLATION_Internal, &remap); trans = GPalette.StoreTranslation(TRANSLATION_Internal, &remap).index();
} }
} }

View file

@ -49,7 +49,7 @@
extern FRandom pr_exrandom; extern FRandom pr_exrandom;
FMemArena FxAlloc(65536); FMemArena FxAlloc(65536);
CompileEnvironment compileEnvironment; CompileEnvironment compileEnvironment;
int R_FindCustomTranslation(FName name); FTranslationID R_FindCustomTranslation(FName name);
struct FLOP struct FLOP
{ {

View file

@ -48,6 +48,7 @@
#include "types.h" #include "types.h"
#include "vmintern.h" #include "vmintern.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "palettecontainer.h"
struct FState; // needed for FxConstant. Maybe move the state constructor to a subclass later? struct FState; // needed for FxConstant. Maybe move the state constructor to a subclass later?
@ -508,6 +509,13 @@ public:
isresolved = true; isresolved = true;
} }
FxConstant(FTranslationID state, const FScriptPosition& pos) : FxExpression(EFX_Constant, pos)
{
value.Int = state.index();
ValueType = value.Type = TypeTranslationID;
isresolved = true;
}
FxConstant(VMFunction* state, const FScriptPosition& pos) : FxExpression(EFX_Constant, pos) FxConstant(VMFunction* state, const FScriptPosition& pos) : FxExpression(EFX_Constant, pos)
{ {
value.pointer = state; value.pointer = state;

View file

@ -1372,16 +1372,16 @@ DEFINE_ACTION_FUNCTION_NATIVE(DObject, FindFunction, FindFunctionPointer)
ACTION_RETURN_POINTER(FindFunctionPointer(cls, fn.GetIndex())); ACTION_RETURN_POINTER(FindFunctionPointer(cls, fn.GetIndex()));
} }
int R_FindCustomTranslation(FName name); FTranslationID R_FindCustomTranslation(FName name);
static int ZFindTranslation(int intname) static int ZFindTranslation(int intname)
{ {
return R_FindCustomTranslation(ENamedName(intname)); return R_FindCustomTranslation(ENamedName(intname)).index();
} }
static int MakeTransID(int g, int s) static int MakeTransID(int g, int s)
{ {
return TRANSLATION(g, s); return TRANSLATION(g, s).index();
} }
DEFINE_ACTION_FUNCTION_NATIVE(_Translation, GetID, ZFindTranslation) DEFINE_ACTION_FUNCTION_NATIVE(_Translation, GetID, ZFindTranslation)

View file

@ -601,7 +601,7 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag
DTA_ClipBottom, twod->GetHeight(), DTA_ClipBottom, twod->GetHeight(),
DTA_ClipRight, clipwidth < 0? twod->GetWidth() : int(x + boxwidth * clipwidth), DTA_ClipRight, clipwidth < 0? twod->GetWidth() : int(x + boxwidth * clipwidth),
DTA_Color, color, DTA_Color, color,
DTA_TranslationIndex, translation? translation : (flags & DI_TRANSLATABLE) ? GetTranslation() : 0, DTA_TranslationIndex, translation? translation : (flags & DI_TRANSLATABLE) ? GetTranslation().index() : 0,
DTA_ColorOverlay, (flags & DI_DIM) ? MAKEARGB(170, 0, 0, 0) : 0, DTA_ColorOverlay, (flags & DI_DIM) ? MAKEARGB(170, 0, 0, 0) : 0,
DTA_Alpha, Alpha, DTA_Alpha, Alpha,
DTA_AlphaChannel, !!(flags & DI_ALPHAMAPPED), DTA_AlphaChannel, !!(flags & DI_ALPHAMAPPED),
@ -686,7 +686,7 @@ void DStatusBarCore::DrawRotated(FGameTexture* tex, double x, double y, int flag
DTA_Color, color, DTA_Color, color,
DTA_CenterOffsetRel, !!(flags & DI_ITEM_RELCENTER), DTA_CenterOffsetRel, !!(flags & DI_ITEM_RELCENTER),
DTA_Rotate, angle, DTA_Rotate, angle,
DTA_TranslationIndex, translation ? translation : (flags & DI_TRANSLATABLE) ? GetTranslation() : 0, DTA_TranslationIndex, translation ? translation : (flags & DI_TRANSLATABLE) ? GetTranslation().index() : 0,
DTA_ColorOverlay, (flags & DI_DIM) ? MAKEARGB(170, 0, 0, 0) : 0, DTA_ColorOverlay, (flags & DI_DIM) ? MAKEARGB(170, 0, 0, 0) : 0,
DTA_Alpha, Alpha, DTA_Alpha, Alpha,
DTA_AlphaChannel, !!(flags & DI_ALPHAMAPPED), DTA_AlphaChannel, !!(flags & DI_ALPHAMAPPED),
@ -704,7 +704,7 @@ void DStatusBarCore::DrawRotated(FGameTexture* tex, double x, double y, int flag
// //
//============================================================================ //============================================================================
void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, int pt, int style) void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, FTranslationID pt, int style)
{ {
bool monospaced = monospacing != EMonospacing::Off; bool monospaced = monospacing != EMonospacing::Off;
double dx = 0; double dx = 0;
@ -823,11 +823,11 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d
DTA_FillColor, 0, DTA_FillColor, 0,
TAG_DONE); TAG_DONE);
} }
DrawChar(twod, font, pt == 0? fontcolor : CR_NATIVEPAL, rx, ry, ch, DrawChar(twod, font, pt == NO_TRANSLATION? fontcolor : CR_NATIVEPAL, rx, ry, ch,
DTA_DestWidthF, rw, DTA_DestWidthF, rw,
DTA_DestHeightF, rh, DTA_DestHeightF, rh,
DTA_Alpha, Alpha, DTA_Alpha, Alpha,
DTA_TranslationIndex, pt, DTA_TranslationIndex, pt.index(),
DTA_LegacyRenderStyle, ERenderStyle(style), DTA_LegacyRenderStyle, ERenderStyle(style),
TAG_DONE); TAG_DONE);
@ -840,10 +840,11 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d
} }
} }
void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int pt, int style) void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int pt_, int style)
{ {
if (font == nullptr || font->mFont == nullptr) ThrowAbortException(X_READ_NIL, nullptr); if (font == nullptr || font->mFont == nullptr) ThrowAbortException(X_READ_NIL, nullptr);
if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
auto pt = FTranslationID::fromInt(pt_);
// resolve auto-alignment before making any adjustments to the position values. // resolve auto-alignment before making any adjustments to the position values.
if (!(flags & DI_SCREEN_MANUAL_ALIGN)) if (!(flags & DI_SCREEN_MANUAL_ALIGN))

View file

@ -179,7 +179,7 @@ public:
void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false); void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false);
void SetSize(int reltop = 32, int hres = 320, int vres = 200, int hhres = -1, int hvres = -1); void SetSize(int reltop = 32, int hres = 320, int vres = 200, int hhres = -1, int hvres = -1);
virtual DVector2 GetHUDScale() const; virtual DVector2 GetHUDScale() const;
virtual uint32_t GetTranslation() const { return 0; } virtual FTranslationID GetTranslation() const { return NO_TRANSLATION; }
void SetDrawSize(int reltop, int hres, int vres); void SetDrawSize(int reltop, int hres, int vres);
virtual void SetScale(); virtual void SetScale();
void ValidateResolution(int& hres, int& vres) const; void ValidateResolution(int& hres, int& vres) const;
@ -188,7 +188,7 @@ public:
void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, ERenderStyle style = STYLE_Translucent, PalEntry color = 0xffffffff, int translation = 0, double clipwidth = -1.0); void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, ERenderStyle style = STYLE_Translucent, PalEntry color = 0xffffffff, int translation = 0, double clipwidth = -1.0);
void DrawRotated(FTextureID texture, double x, double y, int flags, double angle, double Alpha, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent); void DrawRotated(FTextureID texture, double x, double y, int flags, double angle, double Alpha, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent);
void DrawRotated(FGameTexture* tex, double x, double y, int flags, double angle, double Alpha, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent); void DrawRotated(FGameTexture* tex, double x, double y, int flags, double angle, double Alpha, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent);
void DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, int pt, int style); void DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, FTranslationID pt, int style);
void TransformRect(double& x, double& y, double& w, double& h, int flags = 0); void TransformRect(double& x, double& y, double& w, double& h, int flags = 0);
void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0); void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0);
void SetClipRect(double x, double y, double w, double h, int flags = 0); void SetClipRect(double x, double y, double w, double h, int flags = 0);

View file

@ -527,7 +527,7 @@ static void renderDrawMapView(const DVector2& cpos, const DVector2& cangvect, co
auto flortex = sect->floortexture; auto flortex = sect->floortexture;
if (!flortex.isValid()) continue; if (!flortex.isValid()) continue;
int translation = TRANSLATION(Translation_Remap + curbasepal, sector[i].floorpal); int translation = TRANSLATION(Translation_Remap + curbasepal, sector[i].floorpal).index();
PalEntry light = shadeToLight(sector[i].floorshade); PalEntry light = shadeToLight(sector[i].floorshade);
for (auto section : sectionsPerSector[i]) for (auto section : sectionsPerSector[i])
@ -580,7 +580,7 @@ static void renderDrawMapView(const DVector2& cpos, const DVector2& cangvect, co
color.a = uint8_t(alpha * 255); color.a = uint8_t(alpha * 255);
} }
int translation = TRANSLATION(Translation_Remap + curbasepal, actor->spr.pal); int translation = TRANSLATION(Translation_Remap + curbasepal, actor->spr.pal).index();
const static unsigned indices[] = { 0, 1, 2, 0, 2, 3 }; const static unsigned indices[] = { 0, 1, 2, 0, 2, 3 };
twod->AddPoly(TexMan.GetGameTexture(actor->spr.spritetexture(), true), vertices.Data(), vertices.Size(), indices, 6, translation, color, rs, &viewport3d); twod->AddPoly(TexMan.GetGameTexture(actor->spr.spritetexture(), true), vertices.Data(), vertices.Size(), indices, 6, translation, color, rs, &viewport3d);
} }

View file

@ -1540,7 +1540,7 @@ DEFINE_ACTION_FUNCTION(_Raze, PickTexture)
PARAM_PROLOGUE; PARAM_PROLOGUE;
PARAM_INT(texid); PARAM_INT(texid);
TexturePick pick; TexturePick pick;
if (PickTexture(TexMan.GetGameTexture(FSetTextureID(texid)), TRANSLATION(Translation_Remap, 0), pick)) if (PickTexture(TexMan.GetGameTexture(FSetTextureID(texid)), TRANSLATION(Translation_Remap, 0).index(), pick))
{ {
ACTION_RETURN_INT(pick.texture->GetID().GetIndex()); ACTION_RETURN_INT(pick.texture->GetID().GetIndex());
} }

View file

@ -57,7 +57,7 @@ F2DDrawer twodpsp;
void hud_drawsprite(double sx, double sy, double sz, double a, FTextureID texid, int dashade, int dapalnum, int dastat, double alpha) void hud_drawsprite(double sx, double sy, double sz, double a, FTextureID texid, int dashade, int dapalnum, int dastat, double alpha)
{ {
alpha *= (dastat & RS_TRANS1)? glblend[0].def[!!(dastat & RS_TRANS2)].alpha : 1.; alpha *= (dastat & RS_TRANS1)? glblend[0].def[!!(dastat & RS_TRANS2)].alpha : 1.;
int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum).index();
auto tex = TexMan.GetGameTexture(texid, true); auto tex = TexMan.GetGameTexture(texid, true);

View file

@ -63,7 +63,7 @@ static void doprecache(FTextureID texid, int palette)
{ {
if ((palette < (MAXPALOOKUPS - RESERVEDPALS)) && (!lookups.checkTable(palette))) return; if ((palette < (MAXPALOOKUPS - RESERVEDPALS)) && (!lookups.checkTable(palette))) return;
int palid = TRANSLATION(Translation_Remap + curbasepal, palette); int palid = TRANSLATION(Translation_Remap + curbasepal, palette).index();
auto tex = TexMan.GetGameTexture(texid); auto tex = TexMan.GetGameTexture(texid);
PrecacheTex(tex, palid); PrecacheTex(tex, palid);

View file

@ -254,7 +254,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
} }
state.SetMaterial(texture, UF_Texture, 0, Sprite == nullptr? CLAMP_NONE : CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette), -1); state.SetMaterial(texture, UF_Texture, 0, Sprite == nullptr? CLAMP_NONE : CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette).index(), -1);
state.SetLightIndex(dynlightindex); state.SetLightIndex(dynlightindex);
state.Draw(DT_Triangles, vertindex, vertcount); state.Draw(DT_Triangles, vertindex, vertcount);

View file

@ -56,7 +56,7 @@ void initSkyInfo(HWDrawInfo *di, HWSkyInfo* sky, sectortype* sector, int plane)
SkyDefinition skydef; SkyDefinition skydef;
if (!skytex) if (!skytex)
{ {
int remap = TRANSLATION(Translation_Remap + curbasepal, palette); int remap = TRANSLATION(Translation_Remap + curbasepal, palette).index();
skydef = getSky(texid); skydef = getSky(texid);
int tw = (int)tex->GetDisplayWidth(); int tw = (int)tex->GetDisplayWidth();

View file

@ -115,7 +115,7 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent)
if (modelframe == 0) if (modelframe == 0)
{ {
state.SetMaterial(texture, UF_Texture, 0, CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette), -1); state.SetMaterial(texture, UF_Texture, 0, CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette).index(), -1);
state.SetNormal(0, 0, 0); state.SetNormal(0, 0, 0);
@ -157,7 +157,7 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent)
mr.BeginDrawModel(RenderStyle, nullptr, rotmat, mirrored); mr.BeginDrawModel(RenderStyle, nullptr, rotmat, mirrored);
TArray<VSMatrix> a; TArray<VSMatrix> a;
mr.SetupFrame(model, 0, 0, 0, a, 0); mr.SetupFrame(model, 0, 0, 0, a, 0);
model->RenderFrame(&mr, TexMan.GetGameTexture(model->GetPaletteTexture()), 0, 0, 0.f, TRANSLATION(Translation_Remap + curbasepal, palette), nullptr, a, 0); model->RenderFrame(&mr, TexMan.GetGameTexture(model->GetPaletteTexture()), 0, 0, 0.f, TRANSLATION(Translation_Remap + curbasepal, palette).index(), nullptr, a, 0);
mr.EndDrawModel(RenderStyle, nullptr); mr.EndDrawModel(RenderStyle, nullptr);
state.SetDepthFunc(DF_Less); state.SetDepthFunc(DF_Less);
state.SetVertexBuffer(screen->mVertexData); state.SetVertexBuffer(screen->mVertexData);

View file

@ -189,7 +189,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
{ {
SetLightAndFog(di, state, fade, palette, shade, visibility, alpha); SetLightAndFog(di, state, fade, palette, shade, visibility, alpha);
state.SetMaterial(texture, UF_Texture, 0, (flags & (HWF_CLAMPX | HWF_CLAMPY)), TRANSLATION(Translation_Remap + curbasepal, palette), -1); state.SetMaterial(texture, UF_Texture, 0, (flags & (HWF_CLAMPX | HWF_CLAMPY)), TRANSLATION(Translation_Remap + curbasepal, palette).index(), -1);
if (Sprite == nullptr) if (Sprite == nullptr)
{ {

View file

@ -373,7 +373,7 @@ bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wanti
applytint = true; applytint = true;
if (!(h.tintFlags & TINTF_APPLYOVERPALSWAP)) useremap = 0; if (!(h.tintFlags & TINTF_APPLYOVERPALSWAP)) useremap = 0;
} }
pick.translation = IsLuminosityTranslation(paletteid)? paletteid : paletteid == 0? 0 : TRANSLATION(usepalette + Translation_Remap, useremap); pick.translation = IsLuminosityTranslation(paletteid)? paletteid : paletteid == 0? 0 : TRANSLATION(usepalette + Translation_Remap, useremap).index();
} }
else pick.translation |= 0x80000000; else pick.translation |= 0x80000000;
} }

View file

@ -4,6 +4,7 @@
#include "gamefuncs.h" #include "gamefuncs.h"
#include "tiletexture.h" #include "tiletexture.h"
#include "s_soundinternal.h" #include "s_soundinternal.h"
#include "palettecontainer.h"
class FGameTexture; class FGameTexture;
// extended texture info for which there is no room in the texture manager. // extended texture info for which there is no room in the texture manager.

View file

@ -125,7 +125,7 @@ FSavegameInfo GameInterface::GetSaveSig()
void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam) void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam)
{ {
int mclock = I_GetBuildTime(); int mclock = I_GetBuildTime();
int color = TRANSLATION(Translation_Remap, playercolor2lookup(playercolor)); auto color = TRANSLATION(Translation_Remap, playercolor2lookup(playercolor));
auto basetex = TexMan.CheckForTexture("PLAYERWALK", ETextureType::Any); auto basetex = TexMan.CheckForTexture("PLAYERWALK", ETextureType::Any);
if (!basetex.isValid()) return; if (!basetex.isValid()) return;
// these are normal in-game animations. Duke has 4 frames, RR has 8, each with 5 rotations that must have consecutive IDs. // these are normal in-game animations. Duke has 4 frames, RR has 8, each with 5 rotations that must have consecutive IDs.
@ -136,7 +136,7 @@ void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam)
double scale = isRR() ? 0.375 : 0.75; double scale = isRR() ? 0.375 : 0.75;
double scaley = isRR() ? 0.3 : 0.75; double scaley = isRR() ? 0.3 : 0.75;
DrawTexture(twod, tex, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TranslationIndex, color, DTA_ScaleX, scale, DTA_ScaleY, scaley, TAG_DONE); DrawTexture(twod, tex, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TranslationIndex, color.index(), DTA_ScaleX, scale, DTA_ScaleY, scaley, TAG_DONE);
} }
END_DUKE_NS END_DUKE_NS