- switched the entire status bar code to use FGameTexture.

- scale the automap parchment to clean 320x200 dimensions.
This commit is contained in:
Christoph Oelckers 2020-04-14 00:55:16 +02:00
parent 5d8adb90c4
commit c7db5b932e
16 changed files with 129 additions and 105 deletions

View file

@ -1239,8 +1239,8 @@ void DAutomap::ScrollParchment (double dmapx, double dmapy)
if (backtex != nullptr) if (backtex != nullptr)
{ {
int pwidth = backtex->GetDisplayWidth(); int pwidth = int(backtex->GetDisplayWidth() * CleanXfac);
int pheight = backtex->GetDisplayHeight(); int pheight = int(backtex->GetDisplayHeight() * CleanYfac);
while(mapxstart > 0) while(mapxstart > 0)
mapxstart -= pwidth; mapxstart -= pwidth;
@ -1591,8 +1591,8 @@ void DAutomap::clearFB (const AMColor &color)
auto backtex = TexMan.GetGameTexture(mapback); auto backtex = TexMan.GetGameTexture(mapback);
if (backtex != nullptr) if (backtex != nullptr)
{ {
int pwidth = backtex->GetDisplayWidth(); int pwidth = int(backtex->GetDisplayWidth() * CleanXfac);
int pheight = backtex->GetDisplayHeight(); int pheight = int(backtex->GetDisplayHeight() * CleanYfac);
int x, y; int x, y;
//blit the automap background to the screen. //blit the automap background to the screen.
@ -1600,7 +1600,7 @@ void DAutomap::clearFB (const AMColor &color)
{ {
for (x = int(mapxstart); x < f_w; x += pwidth) for (x = int(mapxstart); x < f_w; x += pwidth)
{ {
DrawTexture(twod, backtex, x, y, DTA_ClipBottom, f_h, DTA_TopOffset, 0, DTA_LeftOffset, 0, TAG_DONE); DrawTexture(twod, backtex, x, y, DTA_ClipBottom, f_h, DTA_TopOffset, 0, DTA_LeftOffset, 0, DTA_DestWidth, pwidth, DTA_DestHeight, pheight, TAG_DONE);
} }
} }
} }

View file

@ -183,6 +183,11 @@ public:
void FillPolygon(int* rx1, int* ry1, int* xb1, int32_t npoints, int picnum, int palette, int shade, int props, const FVector2& xtex, const FVector2& ytex, const FVector2& otex, void FillPolygon(int* rx1, int* ry1, int* xb1, int32_t npoints, int picnum, int palette, int shade, int props, const FVector2& xtex, const FVector2& ytex, const FVector2& otex,
int clipx1, int clipy1, int clipx2, int clipy2); int clipx1, int clipy1, int clipx2, int clipy2);
void AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin = false); void AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin = false);
void AddFlatFill(int left, int top, int right, int bottom, FGameTexture* src, bool local_origin = false)
{
AddFlatFill(left, top, right, bottom, src->GetTexture(), local_origin);
}
void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style = nullptr); void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style = nullptr);
void ClearScreen(PalEntry color = 0xff000000); void ClearScreen(PalEntry color = 0xff000000);

View file

@ -868,3 +868,9 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits)
SystemTextures.AddHardwareTexture(0, false, hwtex); SystemTextures.AddHardwareTexture(0, false, hwtex);
} }
bool FGameTexture::isUserContent() const
{
int filenum = fileSystem.GetFileContainer(wrapped.GetSourceLump());
return (filenum > fileSystem.GetMaxIwadNum());
}

View file

@ -40,6 +40,11 @@ public:
return InternalGetTexture(texnum.GetIndex(), animate, true, false); return InternalGetTexture(texnum.GetIndex(), animate, true, false);
} }
FGameTexture* GetGameTextureByName(const char *name, bool animate = false)
{
return reinterpret_cast<FGameTexture*>(GetTextureByName(name, animate));
}
FTexture *GetTexture(FTextureID texnum, bool animate = false) FTexture *GetTexture(FTextureID texnum, bool animate = false)
{ {
return InternalGetTexture(texnum.GetIndex(), animate, true, false); return InternalGetTexture(texnum.GetIndex(), animate, true, false);
@ -67,6 +72,12 @@ public:
} }
FTexture *FindTexture(const char *texname, ETextureType usetype = ETextureType::MiscPatch, BITFIELD flags = TEXMAN_TryAny); FTexture *FindTexture(const char *texname, ETextureType usetype = ETextureType::MiscPatch, BITFIELD flags = TEXMAN_TryAny);
FGameTexture* FindGameTexture(const char* texname, ETextureType usetype = ETextureType::MiscPatch, BITFIELD flags = TEXMAN_TryAny)
{
return reinterpret_cast<FGameTexture*>(FindTexture(texname, usetype, flags));
}
bool OkForLocalization(FTextureID texnum, const char *substitute, int locnum); bool OkForLocalization(FTextureID texnum, const char *substitute, int locnum);
void FlushAll(); void FlushAll();

View file

@ -579,14 +579,14 @@ class FGameTexture
public: public:
FTexture* GetTexture() { return &wrapped; } FTexture* GetTexture() { return &wrapped; }
int GetDisplayWidth() /*const*/ { return wrapped.GetDisplayWidth(); } double GetDisplayWidth() /*const*/ { return wrapped.GetDisplayWidthDouble(); }
int GetDisplayHeight() /*const*/ { return wrapped.GetDisplayHeight(); } double GetDisplayHeight() /*const*/ { return wrapped.GetDisplayHeightDouble(); }
int GetTexelWidth() /*const*/ { return wrapped.GetTexelWidth(); } int GetTexelWidth() /*const*/ { return wrapped.GetTexelWidth(); }
int GetTexelHeight() /*const*/ { return wrapped.GetTexelHeight(); } int GetTexelHeight() /*const*/ { return wrapped.GetTexelHeight(); }
int GetTexelLeftOffset(int adjusted) /*const*/ { return wrapped.GetTexelLeftOffset(adjusted); } int GetTexelLeftOffset(int adjusted = 0) /*const*/ { return wrapped.GetTexelLeftOffset(adjusted); }
int GetTexelTopOffset(int adjusted) /*const*/ { return wrapped.GetTexelTopOffset(adjusted); } int GetTexelTopOffset(int adjusted = 0) /*const*/ { return wrapped.GetTexelTopOffset(adjusted); }
double GetDisplayLeftOffset(int adjusted) /*const*/ { return wrapped.GetDisplayLeftOffsetDouble(adjusted); } double GetDisplayLeftOffset(int adjusted = 0) /*const*/ { return wrapped.GetDisplayLeftOffsetDouble(adjusted); }
double GetDisplayTopOffset(int adjusted) /*const*/ { return wrapped.GetDisplayTopOffsetDouble(adjusted); } double GetDisplayTopOffset(int adjusted = 0) /*const*/ { return wrapped.GetDisplayTopOffsetDouble(adjusted); }
bool isValid() { return wrapped.isValid(); } bool isValid() { return wrapped.isValid(); }
bool isWarped() { return wrapped.isWarped(); } bool isWarped() { return wrapped.isWarped(); }
@ -598,6 +598,8 @@ public:
ISoftwareTexture* GetSoftwareTexture() { return wrapped.GetSoftwareTexture(); } ISoftwareTexture* GetSoftwareTexture() { return wrapped.GetSoftwareTexture(); }
void SetSoftwareTexture(ISoftwareTexture* swtex) { wrapped.SetSoftwareTextue(swtex); } void SetSoftwareTexture(ISoftwareTexture* swtex) { wrapped.SetSoftwareTextue(swtex); }
bool isUserContent() const;
}; };

View file

@ -1170,7 +1170,7 @@ void C_DrawConsole ()
else if (ConBottom) else if (ConBottom)
{ {
int visheight; int visheight;
FTexture *conpic = TexMan.GetTexture(conback); FGameTexture *conpic = TexMan.GetGameTexture(conback);
visheight = ConBottom; visheight = ConBottom;

View file

@ -894,18 +894,14 @@ bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo)
{ {
if (texids[i]->isValid() && langtable[i] != FStringTable::default_table) if (texids[i]->isValid() && langtable[i] != FStringTable::default_table)
{ {
FTexture *tex = TexMan.GetTexture(*texids[i]); FGameTexture *tex = TexMan.GetGameTexture(*texids[i]);
if (tex != nullptr) if (tex != nullptr && !tex->isUserContent())
{
int filenum = fileSystem.GetFileContainer(tex->GetSourceLump());
if (filenum >= 0 && filenum <= fileSystem.GetMaxIwadNum())
{ {
texids[i]->SetInvalid(); texids[i]->SetInvalid();
} }
} }
} }
} }
}
CheckWarpTransMap (wminfo.next, true); CheckWarpTransMap (wminfo.next, true);
nextlevel = wminfo.next; nextlevel = wminfo.next;

View file

@ -42,6 +42,7 @@
class player_t; class player_t;
struct FRemapTable; struct FRemapTable;
class FGameTexture;
enum EHudState enum EHudState
{ {
@ -233,7 +234,7 @@ struct FMugShotFrame
FMugShotFrame(); FMugShotFrame();
~FMugShotFrame(); ~FMugShotFrame();
FTexture *GetTexture(const char *default_face, const char *skin_face, int random, int level=0, FGameTexture *GetTexture(const char *default_face, const char *skin_face, int random, int level=0,
int direction=0, bool usesLevels=false, bool health2=false, bool healthspecial=false, int direction=0, bool usesLevels=false, bool health2=false, bool healthspecial=false,
bool directional=false); bool directional=false);
}; };
@ -256,7 +257,7 @@ struct FMugShotState
void Tick(); void Tick();
void Reset(); void Reset();
FMugShotFrame &GetCurrentFrame() { return Frames[Position]; } FMugShotFrame &GetCurrentFrame() { return Frames[Position]; }
FTexture *GetCurrentFrameTexture(const char *default_face, const char *skin_face, int level=0, int direction=0) FGameTexture *GetCurrentFrameTexture(const char *default_face, const char *skin_face, int level=0, int direction=0)
{ {
return GetCurrentFrame().GetTexture(default_face, skin_face, Random, level, direction, bUsesLevels, bHealth2, bHealthSpecial, bDirectional); return GetCurrentFrame().GetTexture(default_face, skin_face, Random, level, direction, bUsesLevels, bHealth2, bHealthSpecial, bDirectional);
} }
@ -287,7 +288,7 @@ class FMugShot
void Tick(player_t *player); void Tick(player_t *player);
bool SetState(const char *state_name, bool wait_till_done=false, bool reset=false); bool SetState(const char *state_name, bool wait_till_done=false, bool reset=false);
int UpdateState(player_t *player, StateFlags stateflags=STANDARD); int UpdateState(player_t *player, StateFlags stateflags=STANDARD);
FTexture *GetFace(player_t *player, const char *default_face, int accuracy, StateFlags stateflags=STANDARD); FGameTexture *GetFace(player_t *player, const char *default_face, int accuracy, StateFlags stateflags=STANDARD);
private: private:
FMugShotState *CurrentState; FMugShotState *CurrentState;
@ -308,7 +309,7 @@ int FindMugShotStateIndex(FName state);
// Base Status Bar ---------------------------------------------------------- // Base Status Bar ----------------------------------------------------------
class FTexture; class FGameTexture;
enum enum
{ {
@ -525,7 +526,7 @@ DBaseStatusBar *CreateCustomStatusBar(int script=0);
void ST_LoadCrosshair(bool alwaysload=false); void ST_LoadCrosshair(bool alwaysload=false);
void ST_Clear(); void ST_Clear();
void ST_CreateStatusBar(bool bTitleLevel); void ST_CreateStatusBar(bool bTitleLevel);
extern FTexture *CrosshairImage; extern FGameTexture *CrosshairImage;
int GetInventoryIcon(AActor *item, uint32_t flags, int *applyscale = nullptr); int GetInventoryIcon(AActor *item, uint32_t flags, int *applyscale = nullptr);

View file

@ -71,11 +71,11 @@ FMugShotFrame::~FMugShotFrame()
// //
// FMugShotFrame :: GetTexture // FMugShotFrame :: GetTexture
// //
// Assemble a graphic name with the specified prefix and return the FTexture. // Assemble a graphic name with the specified prefix and return the FGameTexture.
// //
//=========================================================================== //===========================================================================
FTexture *FMugShotFrame::GetTexture(const char *default_face, const char *skin_face, int random, int level, FGameTexture *FMugShotFrame::GetTexture(const char *default_face, const char *skin_face, int random, int level,
int direction, bool uses_levels, bool health2, bool healthspecial, bool directional) int direction, bool uses_levels, bool health2, bool healthspecial, bool directional)
{ {
int index = !directional ? random % Graphic.Size() : direction; int index = !directional ? random % Graphic.Size() : direction;
@ -97,7 +97,7 @@ FTexture *FMugShotFrame::GetTexture(const char *default_face, const char *skin_f
} }
sprite.UnlockBuffer(); sprite.UnlockBuffer();
} }
return TexMan.GetTexture(TexMan.CheckForTexture(sprite, ETextureType::Any, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_AllowSkins)); return TexMan.GetGameTexture(TexMan.CheckForTexture(sprite, ETextureType::Any, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_AllowSkins));
} }
//=========================================================================== //===========================================================================
@ -459,7 +459,7 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags)
// //
//=========================================================================== //===========================================================================
FTexture *FMugShot::GetFace(player_t *player, const char *default_face, int accuracy, StateFlags stateflags) FGameTexture *FMugShot::GetFace(player_t *player, const char *default_face, int accuracy, StateFlags stateflags)
{ {
int angle = UpdateState(player, stateflags); int angle = UpdateState(player, stateflags);
int level = 0; int level = 0;

View file

@ -1191,7 +1191,7 @@ public:
} }
//draws an image with the specified flags //draws an image with the specified flags
void DrawGraphic(FTexture* texture, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, double Alpha, bool fullScreenOffsets, bool translate=false, bool dim=false, int offsetflags=0, bool alphaMap=false, int forceWidth=-1, int forceHeight=-1, const double *clip = nulclip, bool clearDontDraw=false) const void DrawGraphic(FGameTexture* texture, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, double Alpha, bool fullScreenOffsets, bool translate=false, bool dim=false, int offsetflags=0, bool alphaMap=false, int forceWidth=-1, int forceHeight=-1, const double *clip = nulclip, bool clearDontDraw=false) const
{ {
if (texture == NULL) if (texture == NULL)
return; return;
@ -1201,11 +1201,11 @@ public:
if((offsetflags & SBarInfoCommand::CENTER) == SBarInfoCommand::CENTER) if((offsetflags & SBarInfoCommand::CENTER) == SBarInfoCommand::CENTER)
{ {
if (forceWidth < 0) dx -= (texture->GetDisplayWidthDouble()/2.0)-texture->GetDisplayLeftOffsetDouble(); if (forceWidth < 0) dx -= (texture->GetDisplayWidth()/2.0)-texture->GetDisplayLeftOffset();
else dx -= forceWidth*(0.5-(texture->GetDisplayLeftOffsetDouble()/texture->GetDisplayWidthDouble())); else dx -= forceWidth*(0.5-(texture->GetDisplayLeftOffset()/texture->GetDisplayWidth()));
if (forceHeight < 0) dy -= (texture->GetDisplayHeightDouble()/2.0)-texture->GetDisplayTopOffsetDouble(); if (forceHeight < 0) dy -= (texture->GetDisplayHeight()/2.0)-texture->GetDisplayTopOffset();
else dy -= forceHeight*(0.5-(texture->GetDisplayTopOffsetDouble()/texture->GetDisplayHeightDouble())); else dy -= forceHeight*(0.5-(texture->GetDisplayTopOffset()/texture->GetDisplayHeight()));
} }
dx += xOffset; dx += xOffset;
@ -1214,12 +1214,12 @@ public:
if(!fullScreenOffsets) if(!fullScreenOffsets)
{ {
double tmp = 0; double tmp = 0;
w = forceWidth < 0 ? texture->GetDisplayWidthDouble() : forceWidth; w = forceWidth < 0 ? texture->GetDisplayWidth() : forceWidth;
h = forceHeight < 0 ? texture->GetDisplayHeightDouble() : forceHeight; h = forceHeight < 0 ? texture->GetDisplayHeight() : forceHeight;
double dcx = clip[0] == 0 ? 0 : dx + clip[0] - texture->GetDisplayLeftOffsetDouble(); double dcx = clip[0] == 0 ? 0 : dx + clip[0] - texture->GetDisplayLeftOffset();
double dcy = clip[1] == 0 ? 0 : dy + clip[1] - texture->GetDisplayTopOffsetDouble(); double dcy = clip[1] == 0 ? 0 : dy + clip[1] - texture->GetDisplayTopOffset();
double dcr = clip[2] == 0 ? INT_MAX : dx + w - clip[2] - texture->GetDisplayLeftOffsetDouble(); double dcr = clip[2] == 0 ? INT_MAX : dx + w - clip[2] - texture->GetDisplayLeftOffset();
double dcb = clip[3] == 0 ? INT_MAX : dy + h - clip[3] - texture->GetDisplayTopOffsetDouble(); double dcb = clip[3] == 0 ? INT_MAX : dy + h - clip[3] - texture->GetDisplayTopOffset();
if(clip[0] != 0 || clip[1] != 0) if(clip[0] != 0 || clip[1] != 0)
{ {
@ -1283,8 +1283,8 @@ public:
bool xright = *x < 0 && !x.RelCenter(); bool xright = *x < 0 && !x.RelCenter();
bool ybot = *y < 0 && !y.RelCenter(); bool ybot = *y < 0 && !y.RelCenter();
w = (forceWidth < 0 ? texture->GetDisplayWidthDouble() : forceWidth); w = (forceWidth < 0 ? texture->GetDisplayWidth() : forceWidth);
h = (forceHeight < 0 ? texture->GetDisplayHeightDouble() : forceHeight); h = (forceHeight < 0 ? texture->GetDisplayHeight() : forceHeight);
if(vid_fps && rx < 0 && ry >= 0) if(vid_fps && rx < 0 && ry >= 0)
ry += 10; ry += 10;
@ -1301,10 +1301,10 @@ public:
// Check for clipping // Check for clipping
if(clip[0] != 0 || clip[1] != 0 || clip[2] != 0 || clip[3] != 0) if(clip[0] != 0 || clip[1] != 0 || clip[2] != 0 || clip[3] != 0)
{ {
rcx = clip[0] == 0 ? 0 : rx+((clip[0] - texture->GetDisplayLeftOffsetDouble())*Scale.X); rcx = clip[0] == 0 ? 0 : rx+((clip[0] - texture->GetDisplayLeftOffset())*Scale.X);
rcy = clip[1] == 0 ? 0 : ry+((clip[1] - texture->GetDisplayTopOffsetDouble())*Scale.Y); rcy = clip[1] == 0 ? 0 : ry+((clip[1] - texture->GetDisplayTopOffset())*Scale.Y);
rcr = clip[2] == 0 ? INT_MAX : rx+w-((clip[2] + texture->GetDisplayLeftOffsetDouble())*Scale.X); rcr = clip[2] == 0 ? INT_MAX : rx+w-((clip[2] + texture->GetDisplayLeftOffset())*Scale.X);
rcb = clip[3] == 0 ? INT_MAX : ry+h-((clip[3] + texture->GetDisplayTopOffsetDouble())*Scale.Y); rcb = clip[3] == 0 ? INT_MAX : ry+h-((clip[3] + texture->GetDisplayTopOffset())*Scale.Y);
} }
if(clearDontDraw) if(clearDontDraw)
@ -1393,7 +1393,7 @@ public:
else else
width = font->GetCharWidth((unsigned char) script->spacingCharacter); width = font->GetCharWidth((unsigned char) script->spacingCharacter);
bool redirected = false; bool redirected = false;
FTexture* c = font->GetChar(ch, fontcolor, &width); auto c = font->GetChar(ch, fontcolor, &width);
if(c == NULL) //missing character. if(c == NULL) //missing character.
{ {
continue; continue;
@ -1405,8 +1405,8 @@ public:
double rx, ry, rw, rh; double rx, ry, rw, rh;
rx = ax + xOffset; rx = ax + xOffset;
ry = ay + yOffset; ry = ay + yOffset;
rw = c->GetDisplayWidthDouble(); rw = c->GetDisplayWidth();
rh = c->GetDisplayHeightDouble(); rh = c->GetDisplayHeight();
if(script->spacingCharacter != '\0') if(script->spacingCharacter != '\0')
{ {

View file

@ -69,8 +69,8 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
{ {
double scale1, scale2; double scale1, scale2;
scale1 = scale2 = 1.0f; scale1 = scale2 = 1.0f;
double texwidth = (int) (texture->GetDisplayWidthDouble()*spawnScaleX); double texwidth = (int) (texture->GetDisplayWidth()*spawnScaleX);
double texheight = (int) (texture->GetDisplayHeightDouble()*spawnScaleY); double texheight = (int) (texture->GetDisplayHeight()*spawnScaleY);
if (w != -1 && (w<texwidth || (flags & DI_FORCESCALE))) if (w != -1 && (w<texwidth || (flags & DI_FORCESCALE)))
{ {
@ -93,8 +93,8 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
} }
else if (applyscale) else if (applyscale)
{ {
w=(int) (texture->GetDisplayWidthDouble()*spawnScaleX); w=(int) (texture->GetDisplayWidth()*spawnScaleX);
h=(int) (texture->GetDisplayHeightDouble()*spawnScaleY); h=(int) (texture->GetDisplayHeight()*spawnScaleY);
} }
statusBar->DrawGraphic(texture, imgx, imgy, block->XOffset(), block->YOffset(), frameAlpha, block->FullScreenOffsets(), statusBar->DrawGraphic(texture, imgx, imgy, block->XOffset(), block->YOffset(), frameAlpha, block->FullScreenOffsets(),
translatable, false, offset, false, w, h); translatable, false, offset, false, w, h);
@ -241,7 +241,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
applyscale = false; applyscale = false;
} }
if(type == PLAYERICON) if(type == PLAYERICON)
texture = TexMan.ByIndex(statusBar->CPlayer->mo->IntVar(NAME_ScoreIcon), true); texture = TexMan.GameByIndex(statusBar->CPlayer->mo->IntVar(NAME_ScoreIcon), true);
else if(type == AMMO1) else if(type == AMMO1)
{ {
auto ammo = statusBar->ammo1; auto ammo = statusBar->ammo1;
@ -270,7 +270,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
{ {
auto item = statusBar->CPlayer->mo->FindInventory(NAME_Sigil); auto item = statusBar->CPlayer->mo->FindInventory(NAME_Sigil);
if (item != NULL) if (item != NULL)
texture = TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true); texture = TexMan.GetGameTexture(item->TextureIDVar(NAME_Icon), true);
} }
else if(type == HEXENARMOR_ARMOR || type == HEXENARMOR_SHIELD || type == HEXENARMOR_HELM || type == HEXENARMOR_AMULET) else if(type == HEXENARMOR_ARMOR || type == HEXENARMOR_SHIELD || type == HEXENARMOR_HELM || type == HEXENARMOR_AMULET)
{ {
@ -292,9 +292,9 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
} }
} }
else if(type == INVENTORYICON) else if(type == INVENTORYICON)
texture = TexMan.GetTexture(sprite, true); texture = TexMan.GetGameTexture(sprite, true);
else if(type == SELECTEDINVENTORYICON && statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) != NULL) else if(type == SELECTEDINVENTORYICON && statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) != NULL)
texture = TexMan.GetTexture(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel)->TextureIDVar(NAME_Icon), true); texture = TexMan.GetGameTexture(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel)->TextureIDVar(NAME_Icon), true);
else if(image >= 0) else if(image >= 0)
texture = statusBar->Images[image]; texture = statusBar->Images[image];
@ -316,7 +316,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
spawnScaleY = item->Scale.Y; spawnScaleY = item->Scale.Y;
} }
texture = TexMan.GetTexture(icon, true); texture = TexMan.GetGameTexture(icon, true);
} }
enum ImageType enum ImageType
@ -353,7 +353,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
SBarInfoCoordinate imgy; SBarInfoCoordinate imgy;
Offset offset; Offset offset;
FTexture *texture; FGameTexture *texture;
double alpha; double alpha;
}; };
@ -1618,7 +1618,7 @@ class CommandDrawMugShot : public SBarInfoCommand
void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar) void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar)
{ {
FTexture *face = statusBar->wrapper->mugshot.GetFace(statusBar->CPlayer, defaultFace, accuracy, stateFlags); FGameTexture *face = statusBar->wrapper->mugshot.GetFace(statusBar->CPlayer, defaultFace, accuracy, stateFlags);
if (face != NULL) if (face != NULL)
statusBar->DrawGraphic(face, x, y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); statusBar->DrawGraphic(face, x, y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
} }
@ -2045,10 +2045,10 @@ class CommandDrawShader : public SBarInfoCommand
} }
GetCoordinates(sc, fullScreenOffsets, x, y); GetCoordinates(sc, fullScreenOffsets, x, y);
sc.MustGetToken(';'); sc.MustGetToken(';');
shaders[0] = TexMan.FindTexture("BarShaderHF"); shaders[0] = TexMan.FindGameTexture("BarShaderHF");
shaders[1] = TexMan.FindTexture("BarShaderHR"); shaders[1] = TexMan.FindGameTexture("BarShaderHR");
shaders[2] = TexMan.FindTexture("BarShaderVF"); shaders[2] = TexMan.FindGameTexture("BarShaderVF");
shaders[3] = TexMan.FindTexture("BarShaderVR"); shaders[3] = TexMan.FindGameTexture("BarShaderVR");
} }
protected: protected:
bool vertical; bool vertical;
@ -2059,7 +2059,7 @@ class CommandDrawShader : public SBarInfoCommand
SBarInfoCoordinate y; SBarInfoCoordinate y;
private: private:
FTexture *shaders[4]; FGameTexture *shaders[4];
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -2132,7 +2132,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgARTIBOX], rx, ry, block->XOffset(), block->YOffset(), bgalpha, block->FullScreenOffsets()); statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgARTIBOX], rx, ry, block->XOffset(), block->YOffset(), bgalpha, block->FullScreenOffsets());
if(style != STYLE_Strife) //Strife draws the cursor before the icons if(style != STYLE_Strife) //Strife draws the cursor before the icons
statusBar->DrawGraphic(TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true), rx - (style == STYLE_HexenStrict ? 2 : 0), ry - (style == STYLE_HexenStrict ? 1 : 0), block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0); statusBar->DrawGraphic(TexMan.GetGameTexture(item->TextureIDVar(NAME_Icon), true), rx - (style == STYLE_HexenStrict ? 2 : 0), ry - (style == STYLE_HexenStrict ? 1 : 0), block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
if(item == statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel)) if(item == statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel))
{ {
if(style == STYLE_Heretic) if(style == STYLE_Heretic)
@ -2147,7 +2147,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgSELECTBOX], rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgSELECTBOX], rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
} }
if(style == STYLE_Strife) if(style == STYLE_Strife)
statusBar->DrawGraphic(TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true), rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0); statusBar->DrawGraphic(TexMan.GetGameTexture(item->TextureIDVar(NAME_Icon), true), rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
if(counters != NULL && (alwaysShowCounter || item->IntVar(NAME_Amount) != 1)) if(counters != NULL && (alwaysShowCounter || item->IntVar(NAME_Amount) != 1))
{ {
counters[i]->valueArgument = item->IntVar(NAME_Amount); counters[i]->valueArgument = item->IntVar(NAME_Amount);
@ -2255,7 +2255,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand
} }
int GetCounterSpacing(const DSBarInfo *statusBar) const int GetCounterSpacing(const DSBarInfo *statusBar) const
{ {
FTexture *box = (style != STYLE_Strife) FGameTexture *box = (style != STYLE_Strife)
? statusBar->Images[statusBar->invBarOffset + imgARTIBOX] ? statusBar->Images[statusBar->invBarOffset + imgARTIBOX]
: statusBar->Images[statusBar->invBarOffset + imgCURSOR]; : statusBar->Images[statusBar->invBarOffset + imgCURSOR];
if (box == NULL) if (box == NULL)
@ -2265,13 +2265,14 @@ class CommandDrawInventoryBar : public SBarInfoCommand
else else
{ {
int spacing; int spacing;
// Intentionally rounded down.
if (!vertical) if (!vertical)
{ {
spacing = box->GetDisplayWidth(); spacing = (int)box->GetDisplayWidth();
} }
else else
{ {
spacing = box->GetDisplayHeight(); spacing = (int)box->GetDisplayHeight();
} }
return spacing + ((style != STYLE_Strife) ? 1 : -1); return spacing + ((style != STYLE_Strife) ? 1 : -1);
} }
@ -2368,24 +2369,25 @@ class CommandDrawKeyBar : public SBarInfoCommand
} }
if(i >= keyOffset) //Should we start drawing? if(i >= keyOffset) //Should we start drawing?
{ {
auto tex = TexMan.GetGameTexture(item->TextureIDVar(NAME_Icon), true);
if(!vertical) if(!vertical)
{ {
statusBar->DrawGraphic(TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true), x+slotOffset, y+rowOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); statusBar->DrawGraphic(tex, x+slotOffset, y+rowOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
rowWidth = rowIconSize == -1 ? TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true)->GetDisplayHeight()+2 : rowIconSize; rowWidth = rowIconSize == -1 ? (int)tex->GetDisplayHeight()+2 : rowIconSize;
} }
else else
{ {
statusBar->DrawGraphic(TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true), x+rowOffset, y+slotOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); statusBar->DrawGraphic(tex, x+rowOffset, y+slotOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
rowWidth = rowIconSize == -1 ? TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true)->GetDisplayWidth()+2 : rowIconSize; rowWidth = rowIconSize == -1 ? (int)tex->GetDisplayWidth()+2 : rowIconSize;
} }
// If cmd.special is -1 then the slot size is auto detected // If cmd.special is -1 then the slot size is auto detected
if(iconSize == -1) if(iconSize == -1)
{ {
if(!vertical) if(!vertical)
slotOffset += (reverse ? -1 : 1) * (TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true)->GetDisplayWidth() + 2); slotOffset += (reverse ? -1 : 1) * ((int)tex->GetDisplayWidth() + 2);
else else
slotOffset += (reverse ? -1 : 1) * (TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true)->GetDisplayHeight() + 2); slotOffset += (reverse ? -1 : 1) * ((int)tex->GetDisplayHeight() + 2);
} }
else else
slotOffset += (reverse ? -iconSize : iconSize); slotOffset += (reverse ? -iconSize : iconSize);
@ -2491,8 +2493,8 @@ class CommandDrawBar : public SBarInfoCommand
return; //don't draw anything. return; //don't draw anything.
assert(statusBar->Images[foreground] != NULL); assert(statusBar->Images[foreground] != NULL);
FTexture *fg = statusBar->Images[foreground]; FGameTexture *fg = statusBar->Images[foreground];
FTexture *bg = (background != -1) ? statusBar->Images[background] : NULL; FGameTexture *bg = (background != -1) ? statusBar->Images[background] : NULL;
double value = drawValue; double value = drawValue;
if(border != 0) if(border != 0)
@ -2514,7 +2516,7 @@ class CommandDrawBar : public SBarInfoCommand
// {cx, cy, cr, cb} // {cx, cy, cr, cb}
double Clip[4] = {0, 0, 0, 0}; double Clip[4] = {0, 0, 0, 0};
int sizeOfImage = (horizontal ? fg->GetDisplayWidth()-border*2 : fg->GetDisplayHeight()-border*2); double sizeOfImage = (horizontal ? fg->GetDisplayWidth()-border*2 : fg->GetDisplayHeight()-border*2);
Clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - sizeOfImage *value; Clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - sizeOfImage *value;
// Draw background // Draw background
if(border != 0) if(border != 0)
@ -3108,15 +3110,15 @@ class CommandDrawGem : public SBarInfoCommand
void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar) void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar)
{ {
FTexture *chainImg = statusBar->Images[chain]; FGameTexture *chainImg = statusBar->Images[chain];
FTexture *gemImg = statusBar->Images[gem]; FGameTexture *gemImg = statusBar->Images[gem];
if(chainImg == NULL) if(chainImg == NULL)
return; return;
SBarInfoCoordinate drawY = y; SBarInfoCoordinate drawY = y;
if(wiggle && drawValue != goalValue) // Should only wiggle when the value doesn't equal what is being drawn. if(wiggle && drawValue != goalValue) // Should only wiggle when the value doesn't equal what is being drawn.
drawY += chainWiggle; drawY += chainWiggle;
int chainWidth = chainImg->GetDisplayWidth(); double chainWidth = chainImg->GetDisplayWidth();
int offset = (int) (((double) (chainWidth-leftPadding-rightPadding)/100)*drawValue); int offset = (int) (((double) (chainWidth-leftPadding-rightPadding)/100)*drawValue);
statusBar->DrawGraphic(chainImg, x+(offset%chainSize), drawY, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); statusBar->DrawGraphic(chainImg, x+(offset%chainSize), drawY, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
if(gemImg != NULL) if(gemImg != NULL)

View file

@ -95,7 +95,7 @@ DBaseStatusBar *StatusBar;
extern int setblocks; extern int setblocks;
FTexture *CrosshairImage; FGameTexture *CrosshairImage;
static int CrosshairNum; static int CrosshairNum;
CVAR (Int, paletteflash, 0, CVAR_ARCHIVE) CVAR (Int, paletteflash, 0, CVAR_ARCHIVE)
@ -192,7 +192,7 @@ void ST_LoadCrosshair(bool alwaysload)
} }
} }
CrosshairNum = num; CrosshairNum = num;
CrosshairImage = TexMan.GetTexture(texid); CrosshairImage = TexMan.GetGameTexture(texid);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1015,11 +1015,12 @@ void DBaseStatusBar::RefreshBackground () const
if (setblocks >= 10) if (setblocks >= 10)
{ {
FTexture *p = TexMan.GetTextureByName(gameinfo.Border.b); FGameTexture *p = TexMan.GetGameTextureByName(gameinfo.Border.b);
if (p != NULL) if (p != NULL)
{ {
twod->AddFlatFill(0, y, x, y + p->GetDisplayHeight(), p, true); int h = int(0.5 + p->GetDisplayHeight());
twod->AddFlatFill(x2, y, twod->GetWidth(), y + p->GetDisplayHeight(), p, true); twod->AddFlatFill(0, y, x, y + h, p, true);
twod->AddFlatFill(x2, y, twod->GetWidth(), y + h, p, true);
} }
} }
} }
@ -1546,10 +1547,10 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla
if (!texture.isValid()) if (!texture.isValid())
return; return;
FTexture *tex = TexMan.GetTexture(texture, !(flags & DI_DONTANIMATE)); FGameTexture *tex = TexMan.GetGameTexture(texture, !(flags & DI_DONTANIMATE));
double texwidth = tex->GetDisplayWidthDouble() * scaleX; double texwidth = tex->GetDisplayWidth() * scaleX;
double texheight = tex->GetDisplayHeightDouble() * scaleY; double texheight = tex->GetDisplayHeight() * scaleY;
if (boxwidth > 0 || boxheight > 0) if (boxwidth > 0 || boxheight > 0)
{ {
@ -1601,14 +1602,14 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla
{ {
case DI_ITEM_HCENTER: x -= boxwidth / 2; break; case DI_ITEM_HCENTER: x -= boxwidth / 2; break;
case DI_ITEM_RIGHT: x -= boxwidth; break; case DI_ITEM_RIGHT: x -= boxwidth; break;
case DI_ITEM_HOFFSET: x -= tex->GetDisplayLeftOffsetDouble() * boxwidth / texwidth; break; case DI_ITEM_HOFFSET: x -= tex->GetDisplayLeftOffset() * boxwidth / texwidth; break;
} }
switch (flags & DI_ITEM_VMASK) switch (flags & DI_ITEM_VMASK)
{ {
case DI_ITEM_VCENTER: y -= boxheight / 2; break; case DI_ITEM_VCENTER: y -= boxheight / 2; break;
case DI_ITEM_BOTTOM: y -= boxheight; break; case DI_ITEM_BOTTOM: y -= boxheight; break;
case DI_ITEM_VOFFSET: y -= tex->GetDisplayTopOffsetDouble() * boxheight / texheight; break; case DI_ITEM_VOFFSET: y -= tex->GetDisplayTopOffset() * boxheight / texheight; break;
} }
if (!fullscreenOffsets) if (!fullscreenOffsets)
@ -1737,20 +1738,20 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
} }
int width; int width;
FTexture* c = font->GetChar(ch, fontcolor, &width); auto c = font->GetChar(ch, fontcolor, &width);
if (c == NULL) //missing character. if (c == NULL) //missing character.
{ {
continue; continue;
} }
if (!monospaced) //If we are monospaced lets use the offset if (!monospaced) //If we are monospaced lets use the offset
x += (c->GetDisplayLeftOffsetDouble() + 1); //ignore x offsets since we adapt to character size x += (c->GetDisplayLeftOffset() + 1); //ignore x offsets since we adapt to character size
double rx, ry, rw, rh; double rx, ry, rw, rh;
rx = x + drawOffset.X; rx = x + drawOffset.X;
ry = y + drawOffset.Y; ry = y + drawOffset.Y;
rw = c->GetDisplayWidthDouble(); rw = c->GetDisplayWidth();
rh = c->GetDisplayHeightDouble(); rh = c->GetDisplayHeight();
if (monospacing == EMonospacing::CellCenter) if (monospacing == EMonospacing::CellCenter)
rx += (spacing - rw) / 2; rx += (spacing - rw) / 2;

View file

@ -69,8 +69,8 @@ public:
int GetWidthBits() { return WidthBits; } int GetWidthBits() { return WidthBits; }
int GetHeightBits() { return HeightBits; } int GetHeightBits() { return HeightBits; }
int GetScaledWidth () { return mTexture->GetDisplayWidth(); } double GetScaledWidth () { return mTexture->GetDisplayWidth(); }
int GetScaledHeight () { return mTexture->GetDisplayHeight(); } double GetScaledHeight () { return mTexture->GetDisplayHeight(); }
// Now with improved offset adjustment. // Now with improved offset adjustment.
int GetLeftOffset(int adjusted) { return mTexture->GetTexelLeftOffset(adjusted); } int GetLeftOffset(int adjusted) { return mTexture->GetTexelLeftOffset(adjusted); }

View file

@ -105,8 +105,8 @@ namespace swrenderer
// but right now, I just want to get them drawing. // but right now, I just want to get them drawing.
tz = (pos.X - thread->Viewport->viewpoint.Pos.X) * thread->Viewport->viewpoint.TanCos + (pos.Y - thread->Viewport->viewpoint.Pos.Y) * thread->Viewport->viewpoint.TanSin; tz = (pos.X - thread->Viewport->viewpoint.Pos.X) * thread->Viewport->viewpoint.TanCos + (pos.Y - thread->Viewport->viewpoint.Pos.Y) * thread->Viewport->viewpoint.TanSin;
int scaled_to = pic->GetScaledTopOffsetSW(); double scaled_to = pic->GetScaledTopOffsetSW();
int scaled_bo = scaled_to - pic->GetScaledHeight(); double scaled_bo = scaled_to - pic->GetScaledHeight();
gzt = pos.Z + scale.Y * scaled_to; gzt = pos.Z + scale.Y * scaled_to;
gzb = pos.Z + scale.Y * scaled_bo; gzb = pos.Z + scale.Y * scaled_bo;

View file

@ -72,11 +72,11 @@ void FImageCollection::Uninit ()
ImageMap.Clear(); ImageMap.Clear();
} }
FTexture *FImageCollection::operator[] (int index) const FGameTexture *FImageCollection::operator[] (int index) const
{ {
if ((unsigned int)index >= ImageMap.Size()) if ((unsigned int)index >= ImageMap.Size())
{ {
return NULL; return NULL;
} }
return ImageMap[index].Exists()? TexMan.GetPalettedTexture(ImageMap[index], true) : NULL; return ImageMap[index].Exists()? TexMan.GetGameTexture(ImageMap[index], true) : NULL;
} }

View file

@ -37,7 +37,7 @@
#include "doomtype.h" #include "doomtype.h"
#include "r_defs.h" #include "r_defs.h"
class FTexture; class FGameTexture;
class FImageCollection class FImageCollection
{ {
@ -49,7 +49,7 @@ public:
void Add(const char **patchnames, int numPatches, ETextureType namespc = ETextureType::Any); void Add(const char **patchnames, int numPatches, ETextureType namespc = ETextureType::Any);
void Uninit(); void Uninit();
FTexture *operator[] (int index) const; FGameTexture *operator[] (int index) const;
protected: protected:
TArray<FTextureID> ImageMap; TArray<FTextureID> ImageMap;