Renamed the operator() and [] methods in FTextureManager which take a name

The operators cannot be easily searched for so this makes it hard to do any evaluations on the use of this method.
This commit is contained in:
Christoph Oelckers 2018-12-07 02:43:27 +01:00
parent 9fedecbe60
commit 3dc9eab743
8 changed files with 34 additions and 32 deletions

View file

@ -184,18 +184,19 @@ CVAR (Int, snd_drawoutput, 0, 0);
CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL) CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL)
{ {
bool res = false; bool res = false;
if (!stricmp(self, "None" ) && gameinfo.CursorPic.IsNotEmpty()) if (!stricmp(self, "None" ) && gameinfo.CursorPic.IsNotEmpty())
{ {
res = I_SetCursor(TexMan[gameinfo.CursorPic]); res = I_SetCursor(TexMan.GetTextureByName(gameinfo.CursorPic));
} }
else else
{ {
res = I_SetCursor(TexMan[self]); res = I_SetCursor(TexMan.GetTextureByName(self));
} }
if (!res) if (!res)
{ {
I_SetCursor(TexMan["cursor"]); I_SetCursor(TexMan.GetTextureByName("cursor"));
} }
} }
@ -834,7 +835,7 @@ void D_Display ()
int x; int x;
FString pstring = "By "; FString pstring = "By ";
tex = TexMan(gameinfo.PauseSign); tex = TexMan.GetTextureByName(gameinfo.PauseSign, true);
x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 + x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 +
tex->GetDisplayLeftOffset() * CleanXfac; tex->GetDisplayLeftOffset() * CleanXfac;
screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE); screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE);
@ -1241,7 +1242,7 @@ void D_DoAdvanceDemo (void)
case 3: case 3:
if (gameinfo.advisoryTime) if (gameinfo.advisoryTime)
{ {
Advisory = TexMan["ADVISOR"]; Advisory = TexMan.GetTextureByName("ADVISOR");
demosequence = 1; demosequence = 1;
pagetic = (int)(gameinfo.advisoryTime * TICRATE); pagetic = (int)(gameinfo.advisoryTime * TICRATE);
break; break;

View file

@ -817,7 +817,7 @@ void DBaseStatusBar::RefreshBackground () const
if (setblocks >= 10) if (setblocks >= 10)
{ {
FTexture *p = TexMan[gameinfo.Border.b]; FTexture *p = TexMan.GetTextureByName(gameinfo.Border.b);
if (p != NULL) if (p != NULL)
{ {
screen->FlatFill(0, y, x, y + p->GetDisplayHeight(), p, true); screen->FlatFill(0, y, x, y + p->GetDisplayHeight(), p, true);

View file

@ -445,7 +445,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
if (teamplay && Teams[player->userinfo.GetTeam()].GetLogo().IsNotEmpty ()) if (teamplay && Teams[player->userinfo.GetTeam()].GetLogo().IsNotEmpty ())
{ {
FTexture *pic = TexMan[Teams[player->userinfo.GetTeam()].GetLogo().GetChars ()]; FTexture *pic = TexMan.GetTextureByName(Teams[player->userinfo.GetTeam()].GetLogo().GetChars ());
screen->DrawTexture (pic, col1 - (pic->GetDisplayWidth() + 2) * CleanXfac, y, screen->DrawTexture (pic, col1 - (pic->GetDisplayWidth() + 2) * CleanXfac, y,
DTA_CleanNoMove, true, TAG_DONE); DTA_CleanNoMove, true, TAG_DONE);
} }

View file

@ -501,7 +501,7 @@ double FindShortestTextureAround (sector_t *sec)
CheckShortestTex (check->sidedef[1]->GetTexture(side_t::bottom), minsize); CheckShortestTex (check->sidedef[1]->GetTexture(side_t::bottom), minsize);
} }
} }
return minsize < FLT_MAX ? minsize : TexMan[0]->GetDisplayHeight(); return minsize < FLT_MAX ? minsize : TexMan.ByIndex(0)->GetDisplayHeight();
} }
// //
@ -526,7 +526,7 @@ double FindShortestUpperAround (sector_t *sec)
CheckShortestTex (check->sidedef[1]->GetTexture(side_t::top), minsize); CheckShortestTex (check->sidedef[1]->GetTexture(side_t::top), minsize);
} }
} }
return minsize < FLT_MAX ? minsize : TexMan[0]->GetDisplayHeight(); return minsize < FLT_MAX ? minsize : TexMan.ByIndex(0)->GetDisplayHeight();
} }
// //

View file

@ -647,7 +647,7 @@ CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINI
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
bool I_SetCursor(FTexture* cursorpic) bool I_SetCursor(FTexture *cursorpic)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSCursor* cursor = nil; NSCursor* cursor = nil;

View file

@ -565,12 +565,16 @@ public:
if ((unsigned)texnum.GetIndex() >= Textures.Size()) return NULL; if ((unsigned)texnum.GetIndex() >= Textures.Size()) return NULL;
return Textures[texnum.GetIndex()].Texture; return Textures[texnum.GetIndex()].Texture;
} }
FTexture *operator[] (const char *texname)
FTexture *GetTextureByName(const char *name, bool animate = false)
{ {
FTextureID texnum = GetTextureID (texname, ETextureType::MiscPatch); FTextureID texnum = GetTextureID (name, ETextureType::MiscPatch);
if (!texnum.Exists()) return NULL; if (!texnum.Exists()) return nullptr;
return Textures[texnum.GetIndex()].Texture; if (!animate) return Textures[texnum.GetIndex()].Texture;
else return Textures[Translation[texnum.GetIndex()]].Texture;
} }
FTexture *ByIndex(int i) FTexture *ByIndex(int i)
{ {
if (unsigned(i) >= Textures.Size()) return NULL; if (unsigned(i) >= Textures.Size()) return NULL;
@ -589,18 +593,15 @@ public:
} }
return Textures[picnum].Texture; return Textures[picnum].Texture;
} }
/*
FTexture *operator() (const char *texname) FTexture *operator() (const char *texname)
{ {
FTextureID texnum = GetTextureID (texname, ETextureType::MiscPatch); FTextureID texnum = GetTextureID (texname, ETextureType::MiscPatch);
if (texnum.texnum == -1) return NULL; if (texnum.texnum == -1) return NULL;
return Textures[Translation[texnum.texnum]].Texture; return Textures[Translation[texnum.texnum]].Texture;
} }
*/
FTexture *ByIndexTranslated(int i)
{
if (unsigned(i) >= Textures.Size()) return NULL;
return Textures[Translation[i]].Texture;
}
//public: //public:
FTextureID PalCheck(FTextureID tex); FTextureID PalCheck(FTextureID tex);

View file

@ -1304,22 +1304,22 @@ void DFrameBuffer::DrawFrame (int left, int top, int width, int height)
int bottom = top + height; int bottom = top + height;
// Draw top and bottom sides. // Draw top and bottom sides.
p = TexMan[border->t]; p = TexMan.GetTextureByName(border->t);
FlatFill(left, top - p->GetDisplayHeight(), right, top, p, true); FlatFill(left, top - p->GetDisplayHeight(), right, top, p, true);
p = TexMan[border->b]; p = TexMan.GetTextureByName(border->b);
FlatFill(left, bottom, right, bottom + p->GetDisplayHeight(), p, true); FlatFill(left, bottom, right, bottom + p->GetDisplayHeight(), p, true);
// Draw left and right sides. // Draw left and right sides.
p = TexMan[border->l]; p = TexMan.GetTextureByName(border->l);
FlatFill(left - p->GetDisplayWidth(), top, left, bottom, p, true); FlatFill(left - p->GetDisplayWidth(), top, left, bottom, p, true);
p = TexMan[border->r]; p = TexMan.GetTextureByName(border->r);
FlatFill(right, top, right + p->GetDisplayWidth(), bottom, p, true); FlatFill(right, top, right + p->GetDisplayWidth(), bottom, p, true);
// Draw beveled corners. // Draw beveled corners.
DrawTexture (TexMan[border->tl], left-offset, top-offset, TAG_DONE); DrawTexture (TexMan.GetTextureByName(border->tl), left-offset, top-offset, TAG_DONE);
DrawTexture (TexMan[border->tr], left+width, top-offset, TAG_DONE); DrawTexture (TexMan.GetTextureByName(border->tr), left+width, top-offset, TAG_DONE);
DrawTexture (TexMan[border->bl], left-offset, top+height, TAG_DONE); DrawTexture (TexMan.GetTextureByName(border->bl), left-offset, top+height, TAG_DONE);
DrawTexture (TexMan[border->br], left+width, top+height, TAG_DONE); DrawTexture (TexMan.GetTextureByName(border->br), left+width, top+height, TAG_DONE);
} }
DEFINE_ACTION_FUNCTION(_Screen, DrawFrame) DEFINE_ACTION_FUNCTION(_Screen, DrawFrame)

View file

@ -383,13 +383,13 @@ bool DInterBackground::LoadBackground(bool isenterpic)
case 1: // Splat case 1: // Splat
sc.MustGetString(); sc.MustGetString();
splat = TexMan[sc.String]; splat = TexMan.GetTextureByName(sc.String);
break; break;
case 2: // Pointers case 2: // Pointers
while (sc.GetString() && !sc.Crossed) while (sc.GetString() && !sc.Crossed)
{ {
yah.Push(TexMan[sc.String]); yah.Push(TexMan.GetTextureByName(sc.String));
} }
if (sc.Crossed) if (sc.Crossed)
sc.UnGet(); sc.UnGet();
@ -481,14 +481,14 @@ bool DInterBackground::LoadBackground(bool isenterpic)
if (!sc.CheckString("{")) if (!sc.CheckString("{"))
{ {
sc.MustGetString(); sc.MustGetString();
an.frames.Push(TexMan[sc.String]); an.frames.Push(TexMan.GetTextureByName(sc.String));
} }
else else
{ {
while (!sc.CheckString("}")) while (!sc.CheckString("}"))
{ {
sc.MustGetString(); sc.MustGetString();
an.frames.Push(TexMan[sc.String]); an.frames.Push(TexMan.GetTextureByName(sc.String));
} }
} }
an.ctr = -1; an.ctr = -1;
@ -503,7 +503,7 @@ bool DInterBackground::LoadBackground(bool isenterpic)
an.loc.y = sc.Number; an.loc.y = sc.Number;
sc.MustGetString(); sc.MustGetString();
an.frames.Reserve(1); // allocate exactly one element an.frames.Reserve(1); // allocate exactly one element
an.frames[0] = TexMan[sc.String]; an.frames[0] = TexMan.GetTextureByName(sc.String);
anims.Push(an); anims.Push(an);
break; break;