- now that all 2D is guaranteed to be drawn in true color, the Heretic E2 end pic can be handled with less hacks.

This removes the entire palette switch and all the special checks to ensure that no menu can be drawn over this image.
Instead it gives this texture its special palette in the texture manager so that the proper image is created right away.

I decided against exposing this as an editing feature because it is far too specific to this particular image and the raw page format it uses.
A quick check of /idgames shows no project ever replacing it - especially no ZDoom-based project - so no extended handling is needed to make this work with other texture formats.
This commit is contained in:
Christoph Oelckers 2018-04-08 10:10:26 +02:00
parent 1897073b60
commit 5eb898107f
7 changed files with 42 additions and 41 deletions

View file

@ -121,26 +121,6 @@ void DIntermissionScreen::Init(FIntermissionAction *desc, bool first)
mFlatfill = desc->mFlatfill;
}
S_Sound (CHAN_VOICE | CHAN_UI, desc->mSound, 1.0f, ATTN_NONE);
if (desc->mPalette.IsNotEmpty() && (lumpnum = Wads.CheckNumForFullName(desc->mPalette, true)) > 0)
{
PalEntry *palette;
uint8_t palbuffer[768];
const uint8_t *orgpal;
FMemLump lump;
int i;
ReadPalette(lumpnum, palbuffer);
orgpal = (uint8_t *)palbuffer;
palette = screen->GetPalette ();
for (i = 256; i > 0; i--, orgpal += 3)
{
*palette++ = PalEntry (orgpal[0], orgpal[1], orgpal[2]);
}
screen->UpdatePalette ();
mPaletteChanged = true;
NoWipe = 1;
M_EnableMenu(false);
}
mOverlays.Resize(desc->mOverlays.Size());
for (unsigned i=0; i < mOverlays.Size(); i++)
{
@ -208,21 +188,6 @@ void DIntermissionScreen::Drawer ()
void DIntermissionScreen::OnDestroy()
{
if (mPaletteChanged)
{
PalEntry *palette;
int i;
palette = screen->GetPalette ();
for (i = 0; i < 256; ++i)
{
palette[i] = GPalette.BaseColors[i];
}
screen->UpdatePalette ();
NoWipe = 5;
mPaletteChanged = false;
M_EnableMenu(true);
}
S_StopSound(CHAN_VOICE);
Super::OnDestroy();
}
@ -793,7 +758,7 @@ bool DIntermissionController::Responder (event_t *ev)
{
if (mScreen != NULL)
{
if (!mScreen->mPaletteChanged && ev->type == EV_KeyDown)
if (ev->type == EV_KeyDown)
{
const char *cmd = Bindings.GetBind (ev->data1);

View file

@ -73,7 +73,6 @@ struct FIntermissionAction
int mCdId;
int mDuration;
FString mBackground;
FString mPalette;
FString mSound;
bool mFlatfill;
bool mMusicLooping;
@ -169,7 +168,6 @@ protected:
public:
int mTicker;
bool mPaletteChanged;
DIntermissionScreen() {}
virtual void Init(FIntermissionAction *desc, bool first);

View file

@ -135,7 +135,7 @@ bool FIntermissionAction::ParseKey(FScanner &sc)
if (sc.CheckToken(','))
{
sc.MustGetToken(TK_StringConst);
mPalette = sc.String;
sc.ScriptMessage("Palette override will be ignored");
}
}
return true;

View file

@ -92,6 +92,7 @@ FFlatTexture::FFlatTexture (int lumpnum)
}
bMasked = false;
bTranslucent = false;
WidthBits = HeightBits = bits;
Width = Height = 1 << bits;
WidthMask = (1 << bits) - 1;

View file

@ -37,6 +37,8 @@
#include "files.h"
#include "w_wad.h"
#include "v_palette.h"
#include "gi.h"
#include "bitmap.h"
#include "textures/textures.h"
@ -48,9 +50,11 @@
class FRawPageTexture : public FWorldTexture
{
int mPaletteLump = -1;
public:
FRawPageTexture (int lumpnum);
uint8_t *MakeTexture (FRenderStyle style) override;
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) override;
};
//==========================================================================
@ -159,6 +163,13 @@ FRawPageTexture::FRawPageTexture (int lumpnum)
WidthBits = 8;
HeightBits = 8;
WidthMask = 255;
// Special case hack for Heretic's E2 end pic. This is not going to be exposed as an editing feature because the implications would be horrible.
if (Name.CompareNoCase("E2END") == 0 && gameinfo.gametype == GAME_Heretic)
{
mPaletteLump = Wads.CheckNumForName("E2PAL");
if (Wads.LumpLength(mPaletteLump) < 768) mPaletteLump = -1;
}
}
//==========================================================================
@ -179,6 +190,9 @@ uint8_t *FRawPageTexture::MakeTexture (FRenderStyle style)
const uint8_t *remap = GetRemap(style);
// This does not handle the custom palette.
// User maps are encouraged to use a real image format when replacing E2END and the original could never be used anywhere else.
// Convert the source image from row-major to column-major format
for (int y = 200; y != 0; --y)
{
@ -188,8 +202,29 @@ uint8_t *FRawPageTexture::MakeTexture (FRenderStyle style)
dest_p += 200;
source_p++;
}
dest_p -= 200*320-1;
dest_p -= 200 * 320 - 1;
}
return Pixels;
}
int FRawPageTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
{
if (mPaletteLump < 0) return FTexture::CopyTrueColorPixels(bmp, x, y, rotate, inf);
else
{
FMemLump lump = Wads.ReadLump(SourceLump);
FMemLump plump = Wads.ReadLump(mPaletteLump);
const uint8_t *source = (const uint8_t *)lump.GetMem();
const uint8_t *psource = (const uint8_t *)plump.GetMem();
PalEntry paldata[256];
for (auto & pe : paldata)
{
pe.r = *psource++;
pe.g = *psource++;
pe.b = *psource++;
pe.a = 255;
}
bmp->CopyPixelData(x, y, source, 320, 200, 1, 320, 0, paldata, inf);
}
}

View file

@ -64,6 +64,8 @@ public:
Width = vertical ? 2 : 256;
Height = vertical ? 256 : 2;
CalcBitSize();
bMasked = false;
bTranslucent = false;
PixelsAreStatic = 2; // The alpha buffer is static, but if this gets used as a regular texture, a separate buffer needs to be made.
// Fill the column/row with shading values.

View file

@ -400,7 +400,7 @@ Intermission Inter_Underwater
{
Image
{
Background = "E2END", 0, "E2PAL"
Background = "E2END", 0
}
GotoTitle
{