- allow specifying full palettes in translation definitions.
This commit is contained in:
parent
27b8284881
commit
0c04cddd28
8 changed files with 92 additions and 14 deletions
|
|
@ -770,6 +770,35 @@ bool FRemapTable::AddToTranslation(const char *range)
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Adds raw colors to a given translation
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
bool FRemapTable::AddColors(int start, int count, const uint8_t*colors)
|
||||
{
|
||||
int end = start + count;
|
||||
if (IndexOutOfRange(start, end))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = start; i < end; ++i)
|
||||
{
|
||||
auto br = colors[0];
|
||||
auto bg = colors[1];
|
||||
auto bb = colors[2];
|
||||
colors += 3;
|
||||
|
||||
int j = GPalette.Remap[i];
|
||||
Palette[j] = PalEntry(j == 0 ? 0 : 255, br, bg, bb);
|
||||
Remap[j] = ColorMatcher.Pick(Palette[j]);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Stores a copy of this translation in the DECORATE translation table
|
||||
|
|
@ -1521,16 +1550,30 @@ void R_ParseTrnslate()
|
|||
do
|
||||
{
|
||||
sc.MustGetToken(TK_StringConst);
|
||||
|
||||
try
|
||||
{
|
||||
NewTranslation.AddToTranslation(sc.String);
|
||||
int pallump = Wads.CheckNumForFullName(sc.String, true, ns_global);
|
||||
if (pallump) //
|
||||
{
|
||||
int start = 0;
|
||||
if (sc.CheckToken(','))
|
||||
{
|
||||
sc.MustGetValue(false);
|
||||
start = sc.Number;
|
||||
}
|
||||
uint8_t palette[768];
|
||||
int numcolors = ReadPalette(pallump, palette);
|
||||
NewTranslation.AddColors(start, numcolors, palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewTranslation.AddToTranslation(sc.String);
|
||||
}
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
catch (CRecoverableError & err)
|
||||
{
|
||||
sc.ScriptMessage("Error in translation '%s':\n" TEXTCOLOR_YELLOW "%s\n", sc.String, err.GetMessage());
|
||||
}
|
||||
|
||||
} while (sc.CheckToken(','));
|
||||
|
||||
int trans = NewTranslation.StoreTranslation(TRANSLATION_Custom);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue