- use an alias for the menu bar texture in Blood.

Direct tile access has been disabled for now, hopefully this can be buried deep in the engine for all eternity.
This commit is contained in:
Christoph Oelckers 2020-10-06 20:05:51 +02:00
parent 55e7e34707
commit d22bdf9dc7
7 changed files with 48 additions and 33 deletions

View file

@ -62,6 +62,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "d_net.h" #include "d_net.h"
#include "v_video.h" #include "v_video.h"
#include "v_draw.h" #include "v_draw.h"
#include "texturemanager.h"
#include "statusbar.h" #include "statusbar.h"
BEGIN_BLD_NS BEGIN_BLD_NS
@ -395,6 +396,16 @@ void GameInterface::DrawBackground()
DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
} }
#define x(a, b) registerName(#a, b);
static void SetTileNames()
{
auto registerName = [](const char* name, int index)
{
TexMan.AddAlias(name, tileGetTexture(index));
};
#include "namelist.h"
}
#undef x
void ReadAllRFS(); void ReadAllRFS();
@ -417,6 +428,7 @@ void GameInterface::app_init()
levelLoadDefaults(); levelLoadDefaults();
LoadDefinitions(); LoadDefinitions();
SetTileNames();
TileFiles.SetBackup(); TileFiles.SetBackup();
powerupInit(); powerupInit();

View file

@ -55,46 +55,46 @@ void _consoleSysMsg(const char* pMessage, ...);
#define dassert(x) assert(x) #define dassert(x) assert(x)
#define kMaxSectors MAXSECTORS
#define kMaxWalls MAXWALLS
#define kMaxSprites MAXSPRITES
#define kMaxTiles MAXTILES
#define kMaxStatus MAXSTATUS
#define kMaxPlayers 8
#define kMaxViewSprites maxspritesonscreen #define kMaxViewSprites maxspritesonscreen
#define kMaxVoxels MAXVOXELS enum
{
kMaxSectors = MAXSECTORS,
kMaxWalls = MAXWALLS,
kMaxSprites = MAXSPRITES,
#define kTicRate 120 kMaxTiles = MAXTILES,
#define kTicsPerFrame 4 kMaxStatus = MAXSTATUS,
#define kTicsPerSec (kTicRate/kTicsPerFrame) kMaxPlayers = 8,
kMaxVoxels = MAXVOXELS,
#define TILTBUFFER 4078 kTicRate = 120,
kTicsPerFrame = 4,
kTicsPerSec = (kTicRate / kTicsPerFrame),
#define kExplodeMax 8 kExplodeMax = 8,
#define kLensSize 80 kLensSize = 80,
#define kViewEffectMax 19 kViewEffectMax = 19,
#define kNoTile -1 kNoTile = -1,
// defined by NoOne: //= = = = // = defined = by = NoOne:
// ------------------------------- //= = = = // = -------------------------------
#define kMaxPAL 5 kMaxPAL = 5,
#define kUserPLUStart 15 kUserPLUStart = 15,
#define kDmgFall 0 kDmgFall = 0,
#define kDmgBurn 1 kDmgBurn = 1,
#define kDmgBullet 2 kDmgBullet = 2,
#define kDmgExplode 3 kDmgExplode = 3,
#define kDmgChoke 4 kDmgChoke = 4,
#define kDmgSpirit 5 kDmgSpirit = 5,
#define kDmgElectric 6 kDmgElectric = 6,
#define kDmgMax 7 kDmgMax = 7,
};
// MEDIUM ///////////////////////////////////////////////////// // MEDIUM /////////////////////////////////////////////////////
enum { enum {

View file

@ -1554,7 +1554,7 @@ void FTextureManager::SetTranslation(FTextureID fromtexnum, FTextureID totexnum)
void FTextureManager::AddAlias(const char* name, FGameTexture* tex) void FTextureManager::AddAlias(const char* name, FGameTexture* tex)
{ {
FTextureID id = tex->GetID(); FTextureID id = tex->GetID();
if (tex != Textures[id.GetIndex()].Texture) return; // Whatever got passed in here was not valid, so ignore the alias. if (tex != Textures[id.GetIndex()].Texture || !tex->isValid()) return; // Whatever got passed in here was not valid, so ignore the alias.
aliases.Insert(name, id.GetIndex()); aliases.Insert(name, id.GetIndex());
} }

View file

@ -1195,6 +1195,7 @@ void processSetAnim(const char* cmd, FScriptPosition& pos, SetAnim& imp)
TileSiz tilesiz; TileSiz tilesiz;
PicAnm picanm; PicAnm picanm;
#if 0 // this only gets in if unavoidable. It'd be preferable if the script side can solely operate on texture names.
#include "vm.h" #include "vm.h"
static int GetTexture(int tile, int anim) static int GetTexture(int tile, int anim)
@ -1211,3 +1212,4 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TileFiles, GetTexture, GetTexture)
PARAM_BOOL(animate); PARAM_BOOL(animate);
ACTION_RETURN_INT(GetTexture(tile, animate)); ACTION_RETURN_INT(GetTexture(tile, animate));
} }
#endif

View file

@ -230,7 +230,7 @@ struct TexMan
NOT_FLAT = 24 NOT_FLAT = 24
}; };
native static TextureID CheckForTexture(String name, int usetype, int flags = TryAny); native static TextureID CheckForTexture(String name, int usetype = Type_Any, int flags = TryAny);
native static String GetName(TextureID tex); native static String GetName(TextureID tex);
native static int, int GetSize(TextureID tex); native static int, int GetSize(TextureID tex);
native static Vector2 GetScaledSize(TextureID tex); native static Vector2 GetScaledSize(TextureID tex);

View file

@ -4,7 +4,7 @@ class MenuCustomizerBlood : MenuCustomize
override int DrawCaption(String title, Font fnt, int y, bool drawit) override int DrawCaption(String title, Font fnt, int y, bool drawit)
{ {
let font = generic_ui? NewConsoleFont : BigFont; // this ignores the passed font intentionally. let font = generic_ui? NewConsoleFont : BigFont; // this ignores the passed font intentionally.
let texid = tileFiles.GetTexture(2038, true); let texid = TexMan.CheckForTexture("MENUBAR");
let texsize = TexMan.GetScaledSize(texid); let texsize = TexMan.GetScaledSize(texid);
let fonth = font.GetGlyphHeight("A"); let fonth = font.GetGlyphHeight("A");
if (drawit) if (drawit)

View file

@ -1,5 +1,6 @@
/*
struct TileFiles struct TileFiles
{ {
native static TextureID GetTexture(int tile, bool animate = false); native static TextureID GetTexture(int tile, bool animate = false);
} }
*/