mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-26 22:01:26 +00:00
- abstract the external translation interface.
The translation table array now only gets accessed from within r_translate.cpp.
This commit is contained in:
parent
d00ad60437
commit
0a7344e432
11 changed files with 158 additions and 122 deletions
|
@ -1614,9 +1614,9 @@ void FLevelLocals::QueueBody (AActor *body)
|
||||||
GetTranslationType(body->Translation) == TRANSLATION_PlayersExtra)
|
GetTranslationType(body->Translation) == TRANSLATION_PlayersExtra)
|
||||||
{
|
{
|
||||||
// This needs to be able to handle multiple levels, in case a level with dead players is used as a secondary one later.
|
// This needs to be able to handle multiple levels, in case a level with dead players is used as a secondary one later.
|
||||||
*translationtables[TRANSLATION_PlayerCorpses][modslot] = *TranslationToTable(body->Translation);
|
CopyTranslation(TRANSLATION(TRANSLATION_PlayerCorpses, modslot), body->Translation);
|
||||||
body->Translation = TRANSLATION(TRANSLATION_PlayerCorpses,modslot);
|
body->Translation = TRANSLATION(TRANSLATION_PlayerCorpses, modslot);
|
||||||
translationtables[TRANSLATION_PlayerCorpses][modslot]->UpdateNative();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int skinidx = body->player->userinfo.GetSkin();
|
const int skinidx = body->player->userinfo.GetSkin();
|
||||||
|
|
|
@ -84,7 +84,7 @@ FBuildTexture::FBuildTexture(const FString &pathprefix, int tilenum, const uint8
|
||||||
TArray<uint8_t> FBuildTexture::CreatePalettedPixels(int conversion)
|
TArray<uint8_t> FBuildTexture::CreatePalettedPixels(int conversion)
|
||||||
{
|
{
|
||||||
TArray<uint8_t> Pixels(Width * Height, true);
|
TArray<uint8_t> Pixels(Width * Height, true);
|
||||||
FRemapTable *Remap = translationtables[TRANSLATION_Standard][Translation];
|
FRemapTable *Remap = GetTranslation(TRANSLATION_Standard, Translation);
|
||||||
for (int i = 0; i < Width*Height; i++)
|
for (int i = 0; i < Width*Height; i++)
|
||||||
{
|
{
|
||||||
auto c = RawPixels[i];
|
auto c = RawPixels[i];
|
||||||
|
@ -95,7 +95,7 @@ TArray<uint8_t> FBuildTexture::CreatePalettedPixels(int conversion)
|
||||||
|
|
||||||
int FBuildTexture::CopyPixels(FBitmap *bmp, int conversion)
|
int FBuildTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
PalEntry *Remap = translationtables[TRANSLATION_Standard][Translation]->Palette;
|
PalEntry *Remap = GetTranslation(TRANSLATION_Standard, Translation)->Palette;
|
||||||
bmp->CopyPixelData(0, 0, RawPixels, Width, Height, Height, 1, 0, Remap);
|
bmp->CopyPixelData(0, 0, RawPixels, Width, Height, Height, 1, 0, Remap);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,6 @@ TArray<uint8_t> FIMGZTexture::CreatePalettedPixels(int conversion)
|
||||||
int FIMGZTexture::CopyPixels(FBitmap *bmp, int conversion)
|
int FIMGZTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
||||||
else return CopyTranslatedPixels(bmp, translationtables[TRANSLATION_Standard][STD_Grayscale]->Palette);
|
else return CopyTranslatedPixels(bmp, GetTranslation(TRANSLATION_Standard, STD_Grayscale)->Palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ TArray<uint8_t> FPatchTexture::CreatePalettedPixels(int conversion)
|
||||||
int FPatchTexture::CopyPixels(FBitmap *bmp, int conversion)
|
int FPatchTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||||
{
|
{
|
||||||
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
||||||
else return CopyTranslatedPixels(bmp, translationtables[TRANSLATION_Standard][STD_Grayscale]->Palette);
|
else return CopyTranslatedPixels(bmp, GetTranslation(TRANSLATION_Standard, STD_Grayscale)->Palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -122,7 +122,7 @@ public:
|
||||||
|
|
||||||
int CopyPixels(FBitmap *bmp, int conversion) override
|
int CopyPixels(FBitmap *bmp, int conversion) override
|
||||||
{
|
{
|
||||||
bmp->CopyPixelData(0, 0, Pixels, Width, Height, Height, 1, 0, translationtables[TRANSLATION_Standard][8]->Palette);
|
bmp->CopyPixelData(0, 0, Pixels, Width, Height, Height, 1, 0, GetTranslation(TRANSLATION_Standard, STD_Gray)->Palette);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace ImageHelpers
|
||||||
{
|
{
|
||||||
if (wantluminance)
|
if (wantluminance)
|
||||||
{
|
{
|
||||||
return translationtables[TRANSLATION_Standard][srcisgrayscale ? STD_Gray : STD_Grayscale]->Remap;
|
return GetTranslation(TRANSLATION_Standard, srcisgrayscale ? STD_Gray : STD_Grayscale)->Remap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -406,17 +406,8 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)
|
||||||
{
|
{
|
||||||
Level->Players[i]->mo = nullptr;
|
Level->Players[i]->mo = nullptr;
|
||||||
}
|
}
|
||||||
// [RH] Clear any scripted translation colors the previous level may have set.
|
ClearScriptedTranslations();
|
||||||
for (i = 0; i < int(translationtables[TRANSLATION_LevelScripted].Size()); ++i)
|
|
||||||
{
|
|
||||||
FRemapTable *table = translationtables[TRANSLATION_LevelScripted][i];
|
|
||||||
if (table != nullptr)
|
|
||||||
{
|
|
||||||
delete table;
|
|
||||||
translationtables[TRANSLATION_LevelScripted][i] = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
translationtables[TRANSLATION_LevelScripted].Clear();
|
|
||||||
|
|
||||||
// Initial height of PointOfView will be set by player think.
|
// Initial height of PointOfView will be set by player think.
|
||||||
auto p = Level->GetConsolePlayer();
|
auto p = Level->GetConsolePlayer();
|
||||||
|
|
|
@ -6771,6 +6771,7 @@ int DLevelScript::RunScript()
|
||||||
ScriptFunction *activeFunction = NULL;
|
ScriptFunction *activeFunction = NULL;
|
||||||
FRemapTable *translation = 0;
|
FRemapTable *translation = 0;
|
||||||
int resultValue = 1;
|
int resultValue = 1;
|
||||||
|
int transi = -1;
|
||||||
|
|
||||||
if (InModuleScriptNumber >= 0)
|
if (InModuleScriptNumber >= 0)
|
||||||
{
|
{
|
||||||
|
@ -9500,13 +9501,9 @@ scriptwait:
|
||||||
sp--;
|
sp--;
|
||||||
if (i >= 1 && i <= MAX_ACS_TRANSLATIONS)
|
if (i >= 1 && i <= MAX_ACS_TRANSLATIONS)
|
||||||
{
|
{
|
||||||
translation = translationtables[TRANSLATION_LevelScripted].GetVal(i - 1);
|
translation = new FRemapTable;
|
||||||
if (translation == NULL)
|
|
||||||
{
|
|
||||||
translation = new FRemapTable;
|
|
||||||
translationtables[TRANSLATION_LevelScripted].SetVal(i - 1, translation);
|
|
||||||
}
|
|
||||||
translation->MakeIdentity();
|
translation->MakeIdentity();
|
||||||
|
transi = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -9593,7 +9590,7 @@ scriptwait:
|
||||||
case PCD_ENDTRANSLATION:
|
case PCD_ENDTRANSLATION:
|
||||||
if (translation != NULL)
|
if (translation != NULL)
|
||||||
{
|
{
|
||||||
translation->UpdateNative();
|
UpdateTranslation(TRANSLATION(TRANSLATION_LevelScripted, transi), translation);
|
||||||
translation = NULL;
|
translation = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -53,7 +53,69 @@
|
||||||
|
|
||||||
#include "gi.h"
|
#include "gi.h"
|
||||||
|
|
||||||
TAutoGrowArray<FRemapTablePtr, FRemapTable *> translationtables[NUM_TRANSLATION_TABLES];
|
static TAutoGrowArray<FRemapTablePtr, FRemapTable *> TranslationTables[NUM_TRANSLATION_TABLES];
|
||||||
|
|
||||||
|
void UpdateTranslation(int trans, FRemapTable* remap)
|
||||||
|
{
|
||||||
|
TranslationTables[GetTranslationType(trans)].SetVal(GetTranslationIndex(trans), remap);
|
||||||
|
remap->UpdateNative();
|
||||||
|
}
|
||||||
|
|
||||||
|
int AddTranslation(int slot, FRemapTable* remap)
|
||||||
|
{
|
||||||
|
auto i = TranslationTables[slot].Push(remap);
|
||||||
|
return TRANSLATION(slot, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
FRemapTable* GetTranslation(int slot, int index)
|
||||||
|
{
|
||||||
|
return TranslationTables[slot].GetVal(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CopyTranslation(int dest, int src)
|
||||||
|
{
|
||||||
|
*TranslationTables[GetTranslationType(dest)][GetTranslationType(src)] = *TranslationToTable(src);
|
||||||
|
TranslationTables[GetTranslationType(dest)][GetTranslationType(src)]->UpdateNative();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClearScriptedTranslations()
|
||||||
|
{
|
||||||
|
// [RH] Clear any scripted translation colors the previous level may have set.
|
||||||
|
for (unsigned i = 0; i < TranslationTables[TRANSLATION_LevelScripted].Size(); ++i)
|
||||||
|
{
|
||||||
|
FRemapTable* table = TranslationTables[TRANSLATION_LevelScripted][i];
|
||||||
|
if (table != nullptr)
|
||||||
|
{
|
||||||
|
delete table;
|
||||||
|
TranslationTables[TRANSLATION_LevelScripted][i] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TranslationTables[TRANSLATION_LevelScripted].Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
FRemapTable *TranslationToTable(int translation)
|
||||||
|
{
|
||||||
|
unsigned int type = GetTranslationType(translation);
|
||||||
|
unsigned int index = GetTranslationIndex(translation);
|
||||||
|
TAutoGrowArray<FRemapTablePtr, FRemapTable *> *slots;
|
||||||
|
|
||||||
|
if (type <= 0 || type >= NUM_TRANSLATION_TABLES)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
slots = &TranslationTables[type];
|
||||||
|
if (index >= slots->Size())
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return slots->operator[](index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const uint8_t IcePalette[16][3] =
|
const uint8_t IcePalette[16][3] =
|
||||||
|
@ -191,9 +253,9 @@ void FRemapTable::StaticSerializeTranslations(FSerializer &arc)
|
||||||
int w;
|
int w;
|
||||||
if (arc.isWriting())
|
if (arc.isWriting())
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < translationtables[TRANSLATION_LevelScripted].Size(); ++i)
|
for (unsigned int i = 0; i < TranslationTables[TRANSLATION_LevelScripted].Size(); ++i)
|
||||||
{
|
{
|
||||||
trans = translationtables[TRANSLATION_LevelScripted][i];
|
trans = TranslationTables[TRANSLATION_LevelScripted][i];
|
||||||
if (trans != NULL && !trans->IsIdentity())
|
if (trans != NULL && !trans->IsIdentity())
|
||||||
{
|
{
|
||||||
if (arc.BeginObject(nullptr))
|
if (arc.BeginObject(nullptr))
|
||||||
|
@ -210,11 +272,11 @@ void FRemapTable::StaticSerializeTranslations(FSerializer &arc)
|
||||||
while (arc.BeginObject(nullptr))
|
while (arc.BeginObject(nullptr))
|
||||||
{
|
{
|
||||||
arc("index", w);
|
arc("index", w);
|
||||||
trans = translationtables[TRANSLATION_LevelScripted].GetVal(w);
|
trans = TranslationTables[TRANSLATION_LevelScripted].GetVal(w);
|
||||||
if (trans == NULL)
|
if (trans == NULL)
|
||||||
{
|
{
|
||||||
trans = new FRemapTable;
|
trans = new FRemapTable;
|
||||||
translationtables[TRANSLATION_LevelScripted].SetVal(w, trans);
|
TranslationTables[TRANSLATION_LevelScripted].SetVal(w, trans);
|
||||||
}
|
}
|
||||||
trans->Serialize(arc);
|
trans->Serialize(arc);
|
||||||
arc.EndObject();
|
arc.EndObject();
|
||||||
|
@ -708,21 +770,21 @@ int FRemapTable::StoreTranslation(int slot)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < translationtables[slot].Size(); i++)
|
for (i = 0; i < TranslationTables[slot].Size(); i++)
|
||||||
{
|
{
|
||||||
if (*this == *translationtables[slot][i])
|
if (*this == *TranslationTables[slot][i])
|
||||||
{
|
{
|
||||||
// A duplicate of this translation already exists
|
// A duplicate of this translation already exists
|
||||||
return TRANSLATION(slot, i);
|
return TRANSLATION(slot, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (translationtables[slot].Size() >= MAX_DECORATE_TRANSLATIONS)
|
if (TranslationTables[slot].Size() >= MAX_DECORATE_TRANSLATIONS)
|
||||||
{
|
{
|
||||||
I_Error("Too many DECORATE translations");
|
I_Error("Too many DECORATE translations");
|
||||||
}
|
}
|
||||||
FRemapTable *newtrans = new FRemapTable;
|
FRemapTable *newtrans = new FRemapTable;
|
||||||
*newtrans = *this;
|
*newtrans = *this;
|
||||||
i = translationtables[slot].Push(newtrans);
|
i = TranslationTables[slot].Push(newtrans);
|
||||||
return TRANSLATION(slot, i);
|
return TRANSLATION(slot, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +804,7 @@ int CreateBloodTranslation(PalEntry color)
|
||||||
if (BloodTranslationColors.Size() == 0)
|
if (BloodTranslationColors.Size() == 0)
|
||||||
{
|
{
|
||||||
// Don't use the first slot.
|
// Don't use the first slot.
|
||||||
translationtables[TRANSLATION_Blood].Push(NULL);
|
TranslationTables[TRANSLATION_Blood].Push(NULL);
|
||||||
BloodTranslationColors.Push(0);
|
BloodTranslationColors.Push(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,7 +834,7 @@ int CreateBloodTranslation(PalEntry color)
|
||||||
trans->Palette[i] = pe;
|
trans->Palette[i] = pe;
|
||||||
trans->Remap[i] = entry;
|
trans->Remap[i] = entry;
|
||||||
}
|
}
|
||||||
translationtables[TRANSLATION_Blood].Push(trans);
|
TranslationTables[TRANSLATION_Blood].Push(trans);
|
||||||
return BloodTranslationColors.Push(color);
|
return BloodTranslationColors.Push(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,35 +844,11 @@ int CreateBloodTranslation(PalEntry color)
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
FRemapTable *TranslationToTable(int translation)
|
|
||||||
{
|
|
||||||
unsigned int type = GetTranslationType(translation);
|
|
||||||
unsigned int index = GetTranslationIndex(translation);
|
|
||||||
TAutoGrowArray<FRemapTablePtr, FRemapTable *> *slots;
|
|
||||||
|
|
||||||
if (type <= 0 || type >= NUM_TRANSLATION_TABLES)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
slots = &translationtables[type];
|
|
||||||
if (index >= slots->Size())
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return slots->operator[](index);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static void PushIdentityTable(int slot)
|
static void PushIdentityTable(int slot)
|
||||||
{
|
{
|
||||||
FRemapTable *table = new FRemapTable;
|
FRemapTable *table = new FRemapTable;
|
||||||
table->MakeIdentity();
|
table->MakeIdentity();
|
||||||
translationtables[slot].Push(table);
|
TranslationTables[slot].Push(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -857,84 +895,84 @@ void R_InitTranslationTables ()
|
||||||
{
|
{
|
||||||
for (i = 0x70; i < 0x80; i++)
|
for (i = 0x70; i < 0x80; i++)
|
||||||
{ // map green ramp to gray, brown, red
|
{ // map green ramp to gray, brown, red
|
||||||
translationtables[TRANSLATION_Standard][0]->Remap[i] = 0x60 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][0]->Remap[i] = 0x60 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][1]->Remap[i] = 0x40 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][1]->Remap[i] = 0x40 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][2]->Remap[i] = 0x20 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][2]->Remap[i] = 0x20 + (i&0xf);
|
||||||
|
|
||||||
translationtables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[0x60 + (i&0xf)] | MAKEARGB(255,0,0,0);
|
TranslationTables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[0x60 + (i&0xf)] | MAKEARGB(255,0,0,0);
|
||||||
translationtables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[0x40 + (i&0xf)] | MAKEARGB(255,0,0,0);
|
TranslationTables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[0x40 + (i&0xf)] | MAKEARGB(255,0,0,0);
|
||||||
translationtables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[0x20 + (i&0xf)] | MAKEARGB(255,0,0,0);
|
TranslationTables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[0x20 + (i&0xf)] | MAKEARGB(255,0,0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (gameinfo.gametype == GAME_Heretic)
|
else if (gameinfo.gametype == GAME_Heretic)
|
||||||
{
|
{
|
||||||
for (i = 225; i <= 240; i++)
|
for (i = 225; i <= 240; i++)
|
||||||
{
|
{
|
||||||
translationtables[TRANSLATION_Standard][0]->Remap[i] = 114+(i-225); // yellow
|
TranslationTables[TRANSLATION_Standard][0]->Remap[i] = 114+(i-225); // yellow
|
||||||
translationtables[TRANSLATION_Standard][1]->Remap[i] = 145+(i-225); // red
|
TranslationTables[TRANSLATION_Standard][1]->Remap[i] = 145+(i-225); // red
|
||||||
translationtables[TRANSLATION_Standard][2]->Remap[i] = 190+(i-225); // blue
|
TranslationTables[TRANSLATION_Standard][2]->Remap[i] = 190+(i-225); // blue
|
||||||
|
|
||||||
translationtables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[114+(i-225)] | MAKEARGB(255,0,0,0);
|
TranslationTables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[114+(i-225)] | MAKEARGB(255,0,0,0);
|
||||||
translationtables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[145+(i-225)] | MAKEARGB(255,0,0,0);
|
TranslationTables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[145+(i-225)] | MAKEARGB(255,0,0,0);
|
||||||
translationtables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[190+(i-225)] | MAKEARGB(255,0,0,0);
|
TranslationTables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[190+(i-225)] | MAKEARGB(255,0,0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (gameinfo.gametype == GAME_Strife)
|
else if (gameinfo.gametype == GAME_Strife)
|
||||||
{
|
{
|
||||||
for (i = 0x20; i <= 0x3F; ++i)
|
for (i = 0x20; i <= 0x3F; ++i)
|
||||||
{
|
{
|
||||||
translationtables[TRANSLATION_Standard][0]->Remap[i] = i - 0x20;
|
TranslationTables[TRANSLATION_Standard][0]->Remap[i] = i - 0x20;
|
||||||
translationtables[TRANSLATION_Standard][1]->Remap[i] = i - 0x20;
|
TranslationTables[TRANSLATION_Standard][1]->Remap[i] = i - 0x20;
|
||||||
translationtables[TRANSLATION_Standard][2]->Remap[i] = 0xD0 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][2]->Remap[i] = 0xD0 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][3]->Remap[i] = 0xD0 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][3]->Remap[i] = 0xD0 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][4]->Remap[i] = i - 0x20;
|
TranslationTables[TRANSLATION_Standard][4]->Remap[i] = i - 0x20;
|
||||||
translationtables[TRANSLATION_Standard][5]->Remap[i] = i - 0x20;
|
TranslationTables[TRANSLATION_Standard][5]->Remap[i] = i - 0x20;
|
||||||
translationtables[TRANSLATION_Standard][6]->Remap[i] = i - 0x20;
|
TranslationTables[TRANSLATION_Standard][6]->Remap[i] = i - 0x20;
|
||||||
}
|
}
|
||||||
for (i = 0x50; i <= 0x5F; ++i)
|
for (i = 0x50; i <= 0x5F; ++i)
|
||||||
{
|
{
|
||||||
// Merchant hair
|
// Merchant hair
|
||||||
translationtables[TRANSLATION_Standard][4]->Remap[i] = 0x80 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][4]->Remap[i] = 0x80 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x10 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][5]->Remap[i] = 0x10 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][6]->Remap[i] = 0x40 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][6]->Remap[i] = 0x40 + (i&0xf);
|
||||||
}
|
}
|
||||||
for (i = 0x80; i <= 0x8F; ++i)
|
for (i = 0x80; i <= 0x8F; ++i)
|
||||||
{
|
{
|
||||||
translationtables[TRANSLATION_Standard][0]->Remap[i] = 0x40 + (i&0xf); // red
|
TranslationTables[TRANSLATION_Standard][0]->Remap[i] = 0x40 + (i&0xf); // red
|
||||||
translationtables[TRANSLATION_Standard][1]->Remap[i] = 0xB0 + (i&0xf); // rust
|
TranslationTables[TRANSLATION_Standard][1]->Remap[i] = 0xB0 + (i&0xf); // rust
|
||||||
translationtables[TRANSLATION_Standard][2]->Remap[i] = 0x10 + (i&0xf); // gray
|
TranslationTables[TRANSLATION_Standard][2]->Remap[i] = 0x10 + (i&0xf); // gray
|
||||||
translationtables[TRANSLATION_Standard][3]->Remap[i] = 0x30 + (i&0xf); // dark green
|
TranslationTables[TRANSLATION_Standard][3]->Remap[i] = 0x30 + (i&0xf); // dark green
|
||||||
translationtables[TRANSLATION_Standard][4]->Remap[i] = 0x50 + (i&0xf); // gold
|
TranslationTables[TRANSLATION_Standard][4]->Remap[i] = 0x50 + (i&0xf); // gold
|
||||||
translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x60 + (i&0xf); // bright green
|
TranslationTables[TRANSLATION_Standard][5]->Remap[i] = 0x60 + (i&0xf); // bright green
|
||||||
translationtables[TRANSLATION_Standard][6]->Remap[i] = 0x90 + (i&0xf); // blue
|
TranslationTables[TRANSLATION_Standard][6]->Remap[i] = 0x90 + (i&0xf); // blue
|
||||||
}
|
}
|
||||||
for (i = 0xC0; i <= 0xCF; ++i)
|
for (i = 0xC0; i <= 0xCF; ++i)
|
||||||
{
|
{
|
||||||
translationtables[TRANSLATION_Standard][4]->Remap[i] = 0xA0 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][4]->Remap[i] = 0xA0 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x20 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][5]->Remap[i] = 0x20 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][6]->Remap[i] = (i&0xf);
|
TranslationTables[TRANSLATION_Standard][6]->Remap[i] = (i&0xf);
|
||||||
}
|
}
|
||||||
translationtables[TRANSLATION_Standard][6]->Remap[0xC0] = 1;
|
TranslationTables[TRANSLATION_Standard][6]->Remap[0xC0] = 1;
|
||||||
for (i = 0xD0; i <= 0xDF; ++i)
|
for (i = 0xD0; i <= 0xDF; ++i)
|
||||||
{
|
{
|
||||||
translationtables[TRANSLATION_Standard][4]->Remap[i] = 0xB0 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][4]->Remap[i] = 0xB0 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x30 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][5]->Remap[i] = 0x30 + (i&0xf);
|
||||||
translationtables[TRANSLATION_Standard][6]->Remap[i] = 0x10 + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][6]->Remap[i] = 0x10 + (i&0xf);
|
||||||
}
|
}
|
||||||
for (i = 0xF1; i <= 0xF6; ++i)
|
for (i = 0xF1; i <= 0xF6; ++i)
|
||||||
{
|
{
|
||||||
translationtables[TRANSLATION_Standard][0]->Remap[i] = 0xDF + (i&0xf);
|
TranslationTables[TRANSLATION_Standard][0]->Remap[i] = 0xDF + (i&0xf);
|
||||||
}
|
}
|
||||||
for (i = 0xF7; i <= 0xFB; ++i)
|
for (i = 0xF7; i <= 0xFB; ++i)
|
||||||
{
|
{
|
||||||
translationtables[TRANSLATION_Standard][0]->Remap[i] = i - 6;
|
TranslationTables[TRANSLATION_Standard][0]->Remap[i] = i - 6;
|
||||||
}
|
}
|
||||||
for (i = 0; i < 7; ++i)
|
for (i = 0; i < 7; ++i)
|
||||||
{
|
{
|
||||||
for (int j = 0x20; j <= 0xFB; ++j)
|
for (int j = 0x20; j <= 0xFB; ++j)
|
||||||
{
|
{
|
||||||
translationtables[TRANSLATION_Standard][i]->Palette[j] =
|
TranslationTables[TRANSLATION_Standard][i]->Palette[j] =
|
||||||
GPalette.BaseColors[translationtables[TRANSLATION_Standard][i]->Remap[j]] | MAKEARGB(255,0,0,0);
|
GPalette.BaseColors[TranslationTables[TRANSLATION_Standard][i]->Remap[j]] | MAKEARGB(255,0,0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -948,7 +986,7 @@ void R_InitTranslationTables ()
|
||||||
{
|
{
|
||||||
IcePaletteRemap[i] = ColorMatcher.Pick (IcePalette[i][0], IcePalette[i][1], IcePalette[i][2]);
|
IcePaletteRemap[i] = ColorMatcher.Pick (IcePalette[i][0], IcePalette[i][1], IcePalette[i][2]);
|
||||||
}
|
}
|
||||||
FRemapTable *remap = translationtables[TRANSLATION_Standard][STD_Ice];
|
FRemapTable *remap = TranslationTables[TRANSLATION_Standard][STD_Ice];
|
||||||
remap->Remap[0] = 0;
|
remap->Remap[0] = 0;
|
||||||
remap->Palette[0] = 0;
|
remap->Palette[0] = 0;
|
||||||
for (i = 1; i < 256; ++i)
|
for (i = 1; i < 256; ++i)
|
||||||
|
@ -963,7 +1001,7 @@ void R_InitTranslationTables ()
|
||||||
|
|
||||||
// The alphatexture translation. This is just a standard index as gray mapping.
|
// The alphatexture translation. This is just a standard index as gray mapping.
|
||||||
PushIdentityTable(TRANSLATION_Standard);
|
PushIdentityTable(TRANSLATION_Standard);
|
||||||
remap = translationtables[TRANSLATION_Standard][STD_Gray];
|
remap = TranslationTables[TRANSLATION_Standard][STD_Gray];
|
||||||
remap->Remap[0] = 0;
|
remap->Remap[0] = 0;
|
||||||
remap->Palette[0] = 0;
|
remap->Palette[0] = 0;
|
||||||
for (i = 1; i < 256; i++)
|
for (i = 1; i < 256; i++)
|
||||||
|
@ -974,7 +1012,7 @@ void R_InitTranslationTables ()
|
||||||
|
|
||||||
// Palette to grayscale ramp. For internal use only, because the remap does not map to the palette.
|
// Palette to grayscale ramp. For internal use only, because the remap does not map to the palette.
|
||||||
PushIdentityTable(TRANSLATION_Standard);
|
PushIdentityTable(TRANSLATION_Standard);
|
||||||
remap = translationtables[TRANSLATION_Standard][STD_Grayscale];
|
remap = TranslationTables[TRANSLATION_Standard][STD_Grayscale];
|
||||||
remap->Remap[0] = 0;
|
remap->Remap[0] = 0;
|
||||||
remap->Palette[0] = 0;
|
remap->Palette[0] = 0;
|
||||||
for (i = 1; i < 256; i++)
|
for (i = 1; i < 256; i++)
|
||||||
|
@ -1000,15 +1038,15 @@ void R_DeinitTranslationTables()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NUM_TRANSLATION_TABLES; ++i)
|
for (int i = 0; i < NUM_TRANSLATION_TABLES; ++i)
|
||||||
{
|
{
|
||||||
for (unsigned int j = 0; j < translationtables[i].Size(); ++j)
|
for (unsigned int j = 0; j < TranslationTables[i].Size(); ++j)
|
||||||
{
|
{
|
||||||
if (translationtables[i][j] != NULL)
|
if (TranslationTables[i][j] != NULL)
|
||||||
{
|
{
|
||||||
delete translationtables[i][j];
|
delete TranslationTables[i][j];
|
||||||
translationtables[i][j] = NULL;
|
TranslationTables[i][j] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
translationtables[i].Clear();
|
TranslationTables[i].Clear();
|
||||||
}
|
}
|
||||||
BloodTranslationColors.Clear();
|
BloodTranslationColors.Clear();
|
||||||
}
|
}
|
||||||
|
@ -1290,9 +1328,9 @@ void R_BuildPlayerTranslation (int player)
|
||||||
|
|
||||||
R_CreatePlayerTranslation (h, s, v, colorset,
|
R_CreatePlayerTranslation (h, s, v, colorset,
|
||||||
&Skins[players[player].userinfo.GetSkin()],
|
&Skins[players[player].userinfo.GetSkin()],
|
||||||
translationtables[TRANSLATION_Players][player],
|
TranslationTables[TRANSLATION_Players][player],
|
||||||
translationtables[TRANSLATION_PlayersExtra][player],
|
TranslationTables[TRANSLATION_PlayersExtra][player],
|
||||||
translationtables[TRANSLATION_RainPillar][player]
|
TranslationTables[TRANSLATION_RainPillar][player]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1325,7 +1363,7 @@ DEFINE_ACTION_FUNCTION(_Translation, SetPlayerTranslation)
|
||||||
PARAM_UINT(pnum);
|
PARAM_UINT(pnum);
|
||||||
PARAM_POINTER(cls, FPlayerClass);
|
PARAM_POINTER(cls, FPlayerClass);
|
||||||
|
|
||||||
if (pnum >= MAXPLAYERS || tgroup >= NUM_TRANSLATION_TABLES || tnum >= translationtables[tgroup].Size())
|
if (pnum >= MAXPLAYERS || tgroup >= NUM_TRANSLATION_TABLES || tnum >= TranslationTables[tgroup].Size())
|
||||||
{
|
{
|
||||||
ACTION_RETURN_BOOL(false);
|
ACTION_RETURN_BOOL(false);
|
||||||
}
|
}
|
||||||
|
@ -1338,7 +1376,7 @@ DEFINE_ACTION_FUNCTION(_Translation, SetPlayerTranslation)
|
||||||
{
|
{
|
||||||
PlayerSkin = R_FindSkin(Skins[PlayerSkin].Name, int(cls - &PlayerClasses[0]));
|
PlayerSkin = R_FindSkin(Skins[PlayerSkin].Name, int(cls - &PlayerClasses[0]));
|
||||||
R_GetPlayerTranslation(PlayerColor, GetColorSet(cls->Type, PlayerColorset),
|
R_GetPlayerTranslation(PlayerColor, GetColorSet(cls->Type, PlayerColorset),
|
||||||
&Skins[PlayerSkin], translationtables[tgroup][tnum]);
|
&Skins[PlayerSkin], TranslationTables[tgroup][tnum]);
|
||||||
}
|
}
|
||||||
ACTION_RETURN_BOOL(true);
|
ACTION_RETURN_BOOL(true);
|
||||||
}
|
}
|
||||||
|
@ -1402,7 +1440,7 @@ DEFINE_ACTION_FUNCTION(_Translation, GetID)
|
||||||
void R_ParseTrnslate()
|
void R_ParseTrnslate()
|
||||||
{
|
{
|
||||||
customTranslationMap.Clear();
|
customTranslationMap.Clear();
|
||||||
translationtables[TRANSLATION_Custom].Clear();
|
TranslationTables[TRANSLATION_Custom].Clear();
|
||||||
|
|
||||||
int lump;
|
int lump;
|
||||||
int lastlump = 0;
|
int lastlump = 0;
|
||||||
|
@ -1425,7 +1463,7 @@ void R_ParseTrnslate()
|
||||||
{
|
{
|
||||||
sc.ScriptError("Translation must be in the range [0,%d]", max);
|
sc.ScriptError("Translation must be in the range [0,%d]", max);
|
||||||
}
|
}
|
||||||
base = translationtables[TRANSLATION_Standard][sc.Number];
|
base = TranslationTables[TRANSLATION_Standard][sc.Number];
|
||||||
}
|
}
|
||||||
else if (sc.TokenType == TK_Identifier)
|
else if (sc.TokenType == TK_Identifier)
|
||||||
{
|
{
|
||||||
|
@ -1434,7 +1472,7 @@ void R_ParseTrnslate()
|
||||||
{
|
{
|
||||||
sc.ScriptError("Base translation '%s' not found in '%s'", sc.String, newtrans.GetChars());
|
sc.ScriptError("Base translation '%s' not found in '%s'", sc.String, newtrans.GetChars());
|
||||||
}
|
}
|
||||||
base = translationtables[GetTranslationType(tnum)][GetTranslationIndex(tnum)];
|
base = TranslationTables[GetTranslationType(tnum)][GetTranslationIndex(tnum)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,7 +108,6 @@ private:
|
||||||
FRemapTable *Ptr;
|
FRemapTable *Ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TAutoGrowArray<FRemapTablePtr, FRemapTable *> translationtables[NUM_TRANSLATION_TABLES];
|
|
||||||
|
|
||||||
#define TRANSLATION_SHIFT 16
|
#define TRANSLATION_SHIFT 16
|
||||||
#define TRANSLATION_MASK ((1<<TRANSLATION_SHIFT)-1)
|
#define TRANSLATION_MASK ((1<<TRANSLATION_SHIFT)-1)
|
||||||
|
@ -128,6 +127,12 @@ inline int GetTranslationIndex(uint32_t trans)
|
||||||
}
|
}
|
||||||
// Retrieve the FRemapTable that an actor's translation value maps to.
|
// Retrieve the FRemapTable that an actor's translation value maps to.
|
||||||
FRemapTable *TranslationToTable(int translation);
|
FRemapTable *TranslationToTable(int translation);
|
||||||
|
void UpdateTranslation(int trans, FRemapTable* remap);
|
||||||
|
int AddTranslation(int slot, FRemapTable* remap);
|
||||||
|
FRemapTable* GetTranslation(int slot, int index);
|
||||||
|
void CopyTranslation(int dest, int src);
|
||||||
|
void ClearScriptedTranslations();
|
||||||
|
|
||||||
|
|
||||||
#define MAX_ACS_TRANSLATIONS 65535
|
#define MAX_ACS_TRANSLATIONS 65535
|
||||||
#define MAX_DECORATE_TRANSLATIONS 65535
|
#define MAX_DECORATE_TRANSLATIONS 65535
|
||||||
|
|
|
@ -129,8 +129,13 @@ void V_DrawPaletteTester(int paletteno)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 16; ++j)
|
for (int j = 0; j < 16; ++j)
|
||||||
{
|
{
|
||||||
int palindex = (t > 1) ? translationtables[TRANSLATION_Standard][t - 2]->Remap[k] : k;
|
PalEntry pe;
|
||||||
PalEntry pe = GPalette.BaseColors[palindex];
|
if (t > 1)
|
||||||
|
{
|
||||||
|
auto palette = GetTranslation(TRANSLATION_Standard, t - 2)->Palette;
|
||||||
|
pe = palette[k];
|
||||||
|
}
|
||||||
|
else GPalette.BaseColors[k];
|
||||||
k++;
|
k++;
|
||||||
screen->Dim(pe, 1.f, j*blocksize, i*blocksize, blocksize, blocksize);
|
screen->Dim(pe, 1.f, j*blocksize, i*blocksize, blocksize, blocksize);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue