diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 202b1e60d..5a51b6529 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +December 29, 2007 (Changes by Graf Zahl) +- Changed the FStatusBarTexture for Doom so that it can create a true color + image. + December 28, 2007 - Fixed position of the Doom HUD selectbox as per SnowKate709's guidance. diff --git a/src/g_doom/doom_sbar.cpp b/src/g_doom/doom_sbar.cpp index 21c94d500..5334271b7 100644 --- a/src/g_doom/doom_sbar.cpp +++ b/src/g_doom/doom_sbar.cpp @@ -129,9 +129,8 @@ public: FBaseStatusBar::MultiplayerChanged (); if (multiplayer) { - // draw face background - StatusBarTex.DrawToBar ("STFBANY", 143, 1, - translationtables[TRANSLATION_Players][int(CPlayer - players)]->Remap); + // set face background color + StatusBarTex.SetPlayerRemap(translationtables[TRANSLATION_Players][int(CPlayer - players)]); } } @@ -146,9 +145,8 @@ public: } if (multiplayer) { - // draw face background - StatusBarTex.DrawToBar ("STFBANY", 143, 1, - translationtables[TRANSLATION_Players][int(CPlayer - players)]->Remap); + // set face background color + StatusBarTex.SetPlayerRemap(translationtables[TRANSLATION_Players][int(CPlayer - players)]); } bEvilGrin = false; } @@ -198,19 +196,29 @@ public: private: struct FDoomStatusBarTexture : public FTexture { + void DrawToBar (const char *name, int x, int y, const BYTE *colormap_in = NULL); + public: FDoomStatusBarTexture (); const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); void Unload (); ~FDoomStatusBarTexture (); - void DrawToBar (const char *name, int x, int y, const BYTE *colormap_in = NULL); + void SetPlayerRemap(FRemapTable *remap); + int CopyTrueColorPixels(BYTE *buffer, int buf_pitch, int buf_height, int x, int y); + + FTextureFormat GetFormat() + { + return TEX_RGB; + } + protected: void MakeTexture (); - FTexture * BaseTexture; + FTexture *BaseTexture; BYTE *Pixels; + FRemapTable *STBFremap; } StatusBarTex; @@ -239,13 +247,6 @@ private: } StatusBarTex.Unload (); - if (!deathmatch) - { - StatusBarTex.DrawToBar ("STARMS", 104, 0); - } - - StatusBarTex.DrawToBar ("STTPRCNT", 90, 3); // Health % - StatusBarTex.DrawToBar ("STTPRCNT", 221, 3); // Armor % SB_state = screen->GetPageCount (); FaceLastAttackDown = -1; @@ -1053,6 +1054,7 @@ FDoomStatusBar::FDoomStatusBarTexture::FDoomStatusBarTexture () // now copy all the properties from the base texture CopySize(BaseTexture); Pixels = NULL; + STBFremap = NULL; } const BYTE *FDoomStatusBar::FDoomStatusBarTexture::GetColumn (unsigned int column, const Span **spans_out) @@ -1095,18 +1097,50 @@ void FDoomStatusBar::FDoomStatusBarTexture::MakeTexture () Pixels = new BYTE[Width*Height]; const BYTE *pix = BaseTexture->GetPixels(); memcpy(Pixels, pix, Width*Height); + if (!deathmatch) DrawToBar("STARMS", 104, 0, NULL); + DrawToBar("STTPRCNT", 90, 3, NULL); + DrawToBar("STTPRCNT", 221, 3, NULL); + if (multiplayer) DrawToBar("STFBANY", 143, 1, STBFremap? STBFremap->Remap : NULL); } +int FDoomStatusBar::FDoomStatusBarTexture::CopyTrueColorPixels(BYTE *buffer, int buf_pitch, int buf_height, int x, int y) +{ + FTexture *tex; + + BaseTexture->CopyTrueColorPixels(buffer, buf_pitch, buf_height, x, y); + if (!deathmatch) + { + tex = TexMan["STARMS"]; + if (tex != NULL) + { + tex->CopyTrueColorPixels(buffer, buf_pitch, buf_height, x+104, y); + } + } + + tex = TexMan["STTPRCNT"]; + if (tex != NULL) + { + tex->CopyTrueColorPixels(buffer, buf_pitch, buf_height, x+90, y+3); + tex->CopyTrueColorPixels(buffer, buf_pitch, buf_height, x+221, y+3); + } + if (multiplayer) + { + tex = TexMan["STFBANY"]; + if (tex != NULL) + { + tex->CopyTrueColorTranslated(buffer, buf_pitch, buf_height, x+143, y+1, STBFremap); + } + } + return -1; +} + + + void FDoomStatusBar::FDoomStatusBarTexture::DrawToBar (const char *name, int x, int y, const BYTE *colormap_in) { FTexture *pic; BYTE colormap[256]; - if (Pixels == NULL) - { - MakeTexture (); - } - if (colormap_in != NULL) { for (int i = 0; i < 256; ++i) @@ -1131,6 +1165,13 @@ void FDoomStatusBar::FDoomStatusBarTexture::DrawToBar (const char *name, int x, } } +void FDoomStatusBar::FDoomStatusBarTexture::SetPlayerRemap(FRemapTable *remap) +{ + Unload(); + KillNative(); + STBFremap = remap; +} + FBaseStatusBar *CreateDoomStatusBar () { return new FDoomStatusBar; diff --git a/src/r_defs.h b/src/r_defs.h index 852deb655..3d4c42f69 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -92,6 +92,7 @@ class player_s; // class DSectorEffect; struct sector_t; +struct FRemapTable; enum { @@ -666,6 +667,7 @@ public: virtual const BYTE *GetPixels () = 0; virtual int CopyTrueColorPixels(BYTE *buffer, int buf_pitch, int buf_height, int x, int y); + int CopyTrueColorTranslated(BYTE *buffer, int buf_pitch, int buf_height, int x, int y, FRemapTable *remap); virtual bool UseBasePalette(); virtual int GetSourceLump() { return -1; } diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 830d759e8..db5912fd6 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -39,6 +39,7 @@ #include "r_data.h" #include "templates.h" #include "i_system.h" +#include "r_translate.h" typedef bool (*CheckFunc)(FileReader & file); typedef FTexture * (*CreateFunc)(FileReader & file, int lumpnum); @@ -483,7 +484,19 @@ void FTexture::FillBuffer(BYTE *buff, int pitch, int height, FTextureFormat fmt) int FTexture::CopyTrueColorPixels(BYTE *buffer, int buf_pitch, int buf_height, int x, int y) { - PalEntry * palette = screen->GetPalette(); + PalEntry *palette = screen->GetPalette(); + palette[0].a=255; // temporarily modify the first color's alpha + screen->CopyPixelData(buffer, buf_pitch, buf_height, x, y, + GetPixels(), Width, Height, Height, 1, + palette); + + palette[0].a=0; + return 0; +} + +int FTexture::CopyTrueColorTranslated(BYTE *buffer, int buf_pitch, int buf_height, int x, int y, FRemapTable *remap) +{ + PalEntry *palette = remap->Palette; palette[0].a=255; // temporarily modify the first color's alpha screen->CopyPixelData(buffer, buf_pitch, buf_height, x, y, GetPixels(), Width, Height, Height, 1, diff --git a/tools/updaterevision/updaterevision.vcproj b/tools/updaterevision/updaterevision.vcproj index 202c9d042..f39914dca 100644 --- a/tools/updaterevision/updaterevision.vcproj +++ b/tools/updaterevision/updaterevision.vcproj @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +