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

View file

@ -817,7 +817,7 @@ void DBaseStatusBar::RefreshBackground () const
if (setblocks >= 10)
{
FTexture *p = TexMan[gameinfo.Border.b];
FTexture *p = TexMan.GetTextureByName(gameinfo.Border.b);
if (p != NULL)
{
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 ())
{
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,
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);
}
}
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);
}
}
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];
NSCursor* cursor = nil;

View file

@ -565,12 +565,16 @@ public:
if ((unsigned)texnum.GetIndex() >= Textures.Size()) return NULL;
return Textures[texnum.GetIndex()].Texture;
}
FTexture *operator[] (const char *texname)
FTexture *GetTextureByName(const char *name, bool animate = false)
{
FTextureID texnum = GetTextureID (texname, ETextureType::MiscPatch);
if (!texnum.Exists()) return NULL;
return Textures[texnum.GetIndex()].Texture;
FTextureID texnum = GetTextureID (name, ETextureType::MiscPatch);
if (!texnum.Exists()) return nullptr;
if (!animate) return Textures[texnum.GetIndex()].Texture;
else return Textures[Translation[texnum.GetIndex()]].Texture;
}
FTexture *ByIndex(int i)
{
if (unsigned(i) >= Textures.Size()) return NULL;
@ -589,18 +593,15 @@ public:
}
return Textures[picnum].Texture;
}
/*
FTexture *operator() (const char *texname)
{
FTextureID texnum = GetTextureID (texname, ETextureType::MiscPatch);
if (texnum.texnum == -1) return NULL;
return Textures[Translation[texnum.texnum]].Texture;
}
*/
FTexture *ByIndexTranslated(int i)
{
if (unsigned(i) >= Textures.Size()) return NULL;
return Textures[Translation[i]].Texture;
}
//public:
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;
// Draw top and bottom sides.
p = TexMan[border->t];
p = TexMan.GetTextureByName(border->t);
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);
// Draw left and right sides.
p = TexMan[border->l];
p = TexMan.GetTextureByName(border->l);
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);
// Draw beveled corners.
DrawTexture (TexMan[border->tl], left-offset, top-offset, TAG_DONE);
DrawTexture (TexMan[border->tr], left+width, top-offset, TAG_DONE);
DrawTexture (TexMan[border->bl], left-offset, top+height, TAG_DONE);
DrawTexture (TexMan[border->br], left+width, top+height, TAG_DONE);
DrawTexture (TexMan.GetTextureByName(border->tl), left-offset, top-offset, TAG_DONE);
DrawTexture (TexMan.GetTextureByName(border->tr), left+width, top-offset, TAG_DONE);
DrawTexture (TexMan.GetTextureByName(border->bl), left-offset, top+height, TAG_DONE);
DrawTexture (TexMan.GetTextureByName(border->br), left+width, top+height, TAG_DONE);
}
DEFINE_ACTION_FUNCTION(_Screen, DrawFrame)

View file

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