- display the savepics.

- fixed level name list in Exhumed.
This commit is contained in:
Christoph Oelckers 2020-01-14 22:37:23 +01:00
parent 5739b4b024
commit 4aacd6d958
4 changed files with 161 additions and 34 deletions

View file

@ -403,7 +403,7 @@ unsigned FSavegameManager::ExtractSaveData(int index)
PNGHandle *png = M_VerifyPNG(picreader); PNGHandle *png = M_VerifyPNG(picreader);
if (png != nullptr) if (png != nullptr)
{ {
SavePic = nullptr; // not yet implemented: PNGTexture_CreateFromFile(png, node->Filename); SavePic = PNGTexture_CreateFromFile(png, node->Filename);
delete png; delete png;
if (SavePic && SavePic->GetWidth() == 1 && SavePic->GetHeight() == 1) if (SavePic && SavePic->GetWidth() == 1 && SavePic->GetHeight() == 1)
{ {

View file

@ -511,3 +511,129 @@ int FPNGTexture::CopyPixels(FBitmap *bmp, int conversion)
} }
//==========================================================================
//
// A savegame picture
// This is essentially a stripped down version of the PNG texture
// only supporting the features actually present in a savegame
// that does not use an image source, because image sources are not
// meant to be transient data like the savegame picture.
//
//==========================================================================
class FPNGFileTexture : public FTexture
{
public:
FPNGFileTexture (FileReader &lump, int width, int height, uint8_t colortype);
virtual FBitmap GetBgraBitmap(const PalEntry *remap, int *trans) override;
protected:
FileReader fr;
uint8_t ColorType;
int PaletteSize;
};
//==========================================================================
//
//
//
//==========================================================================
FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
{
if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0)
{
return nullptr;
}
// Savegame images can only be either 8 bit paletted or 24 bit RGB
auto &data = png->File;
int width = data.ReadInt32BE();
int height = data.ReadInt32BE();
uint8_t bitdepth = data.ReadUInt8();
uint8_t colortype = data.ReadUInt8();
uint8_t compression = data.ReadUInt8();
uint8_t filter = data.ReadUInt8();
uint8_t interlace = data.ReadUInt8();
// Reject anything that cannot be put into a savegame picture by GZDoom itself.
if (compression != 0 || filter != 0 || interlace > 0 || bitdepth != 8 || (colortype != 2 && colortype != 3)) return nullptr;
else return new FPNGFileTexture (png->File, width, height, colortype);
}
//==========================================================================
//
//
//
//==========================================================================
FPNGFileTexture::FPNGFileTexture (FileReader &lump, int width, int height, uint8_t colortype)
: ColorType(colortype)
{
Size.x = width;
Size.y = height;
fr = std::move(lump);
}
//===========================================================================
//
// FPNGTexture::CopyPixels
//
//===========================================================================
FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans)
{
FBitmap bmp;
// Parse pre-IDAT chunks. I skip the CRCs. Is that bad?
PalEntry pe[256];
uint32_t len, id;
int pixwidth = Size.x * (ColorType == 2? 3:1);
FileReader *lump = &fr;
bmp.Create(Size.x, Size.y);
lump->Seek(33, FileReader::SeekSet);
lump->Read(&len, 4);
lump->Read(&id, 4);
while (id != MAKE_ID('I','D','A','T') && id != MAKE_ID('I','E','N','D'))
{
len = BigLong((unsigned int)len);
if (id != MAKE_ID('P','L','T','E'))
lump->Seek (len, FileReader::SeekCur);
else
{
PaletteSize = std::min<int> (len / 3, 256);
for(int i = 0; i < PaletteSize; i++)
{
pe[i].r = lump->ReadUInt8();
pe[i].g = lump->ReadUInt8();
pe[i].b = lump->ReadUInt8();
pe[i].a = 255;
}
}
lump->Seek(4, FileReader::SeekCur); // Skip CRC
lump->Read(&len, 4);
id = MAKE_ID('I','E','N','D');
lump->Read(&id, 4);
}
auto StartOfIDAT = (uint32_t)lump->Tell() - 8;
TArray<uint8_t> Pixels(pixwidth * Size.y);
lump->Seek (StartOfIDAT, FileReader::SeekSet);
lump->Read(&len, 4);
lump->Read(&id, 4);
M_ReadIDAT (*lump, Pixels.Data(), Size.x, Size.y, pixwidth, 8, ColorType, 0, BigLong((unsigned int)len));
if (ColorType == 3)
{
bmp.CopyPixelData(0, 0, Pixels.Data(), Size.x, Size.y, 1, Size.x, 0, pe);
}
else
{
bmp.CopyPixelDataRGB(0, 0, Pixels.Data(), Size.x, Size.y, 3, pixwidth, 0, CF_RGB);
}
return bmp;
}

View file

@ -164,6 +164,7 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
if (cmd.mTexture != nullptr) if (cmd.mTexture != nullptr)
{ {
auto tex = cmd.mTexture; auto tex = cmd.mTexture;
if (cmd.mType == F2DDrawer::DrawTypeRotateSprite) if (cmd.mType == F2DDrawer::DrawTypeRotateSprite)
{ {
// todo: Set up hictinting. (broken as the feature is...) // todo: Set up hictinting. (broken as the feature is...)

View file

@ -2090,36 +2090,36 @@ The Morgue/mortuary (dm),TXTS_T_MAP24,,,,,,,,,,,,,,,,,,,,,,
Island Caves (dm),TXTS_T_MAP25,,,,,,,,,,,,,,,,,,,,,, Island Caves (dm),TXTS_T_MAP25,,,,,,,,,,,,,,,,,,,,,,
Twin Dragon,TXTS_T_TITLE,,,,,,,,,,,,,,,,,,,,,, Twin Dragon,TXTS_T_TITLE,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP00,Training,,,,,,,,,,,,,,,,,,,,,, Training,TXT_EX_MAP00,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP01,Abu Simbel,,,,,,,,,,,,,,,,,,,,,, Abu Simbel,TXT_EX_MAP01,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP02,Dendur,,,,,,,,,,,,,,,,,,,,,, Dendur,TXT_EX_MAP02,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP03,Kalabash,,,,,,,,,,,,,,,,,,,,,, Kalabash,TXT_EX_MAP03,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP04,El Subua,,,,,,,,,,,,,,,,,,,,,, El Subua,TXT_EX_MAP04,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP05,El Derr,,,,,,,,,,,,,,,,,,,,,, El Derr,TXT_EX_MAP05,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP06,Abu Churab,,,,,,,,,,,,,,,,,,,,,, Abu Churab,TXT_EX_MAP06,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP07,Philae,,,,,,,,,,,,,,,,,,,,,, Philae,TXT_EX_MAP07,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP08,El Kab,,,,,,,,,,,,,,,,,,,,,, El Kab,TXT_EX_MAP08,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP09,Aswan,,,,,,,,,,,,,,,,,,,,,, Aswan,TXT_EX_MAP09,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP10,10,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,, 10,TXT_EX_MAP10,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP11,Qubbet el Kawa,,,,,,,,,,,,,,,,,,,,,, Qubbet el Kawa,TXT_EX_MAP11,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP12,Abydos,,,,,,,,,,,,,,,,,,,,,, Abydos,TXT_EX_MAP12,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP13,Edufu,,,,,,,,,,,,,,,,,,,,,, Edufu,TXT_EX_MAP13,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP14,West Bank,,,,,,,,,,,,,,,,,,,,,, West Bank,TXT_EX_MAP14,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP15,Luxor,,,,,,,,,,,,,,,,,,,,,, Luxor,TXT_EX_MAP15,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP16,Karnak,,,,,,,,,,,,,,,,,,,,,, Karnak,TXT_EX_MAP16,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP17,Saqqara,,,,,,,,,,,,,,,,,,,,,, Saqqara,TXT_EX_MAP17,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP18,Mitrrahn,,,,,,,,,,,,,,,,,,,,,, Mitrrahn,TXT_EX_MAP18,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP19,19,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,, 19,TXT_EX_MAP19,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP20,20,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,, 20,TXT_EX_MAP20,Does not have a readable name.,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP21,Level 21,No names exist for the MP levels,,,,,,,,,,,,,,,,,,,,, Level 21,TXT_EX_MAP21,No names exist for the MP levels,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP22,Level 22,,,,,,,,,,,,,,,,,,,,,, Level 22,TXT_EX_MAP22,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP23,Level 23,,,,,,,,,,,,,,,,,,,,,, Level 23,TXT_EX_MAP23,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP24,Level 24,,,,,,,,,,,,,,,,,,,,,, Level 24,TXT_EX_MAP24,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP25,Level 25,,,,,,,,,,,,,,,,,,,,,, Level 25,TXT_EX_MAP25,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP26,Level 26,,,,,,,,,,,,,,,,,,,,,, Level 26,TXT_EX_MAP26,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP27,Level 27,,,,,,,,,,,,,,,,,,,,,, Level 27,TXT_EX_MAP27,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP28,Level 28,,,,,,,,,,,,,,,,,,,,,, Level 28,TXT_EX_MAP28,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP29,Level 29,,,,,,,,,,,,,,,,,,,,,, Level 29,TXT_EX_MAP29,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP30,Level 30,,,,,,,,,,,,,,,,,,,,,, Level 30,TXT_EX_MAP30,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP31,Level 31,,,,,,,,,,,,,,,,,,,,,, Level 31,TXT_EX_MAP31,,,,,,,,,,,,,,,,,,,,,,
TXT_EX_MAP32,Level 32,,,,,,,,,,,,,,,,,,,,,, Level 32,TXT_EX_MAP32,,,,,,,,,,,,,,,,,,,,,,
1 default Identifier Remarks Filter eng enc ena enz eni ens enj enb enl ent enw cs de el eo es esm esn esg esc esa esd esv eso esr ess esf esl esy esz esb ese esh esi esu fi fr hu it jp ko nl pl pt ptg ro ru sr
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125