mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +00:00
- load the hex font as early as possible.
This commit is contained in:
parent
7832ada2fc
commit
010f41a3aa
2 changed files with 27 additions and 14 deletions
|
@ -58,11 +58,12 @@ struct HexDataSource
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void ParseDefinition(int lumpnum)
|
||||
void ParseDefinition(FResourceLump* font)
|
||||
{
|
||||
FScanner sc;
|
||||
|
||||
sc.OpenLumpNum(lumpnum);
|
||||
auto data = font->Lock();
|
||||
sc.OpenMem("newconsolefont.hex", (const char*)data, font->Size());
|
||||
sc.SetCMode(true);
|
||||
glyphdata.Push(0); // ensure that index 0 can be used as 'not present'.
|
||||
while (sc.GetString())
|
||||
|
@ -96,6 +97,7 @@ struct HexDataSource
|
|||
lumb = i * 255 / 17;
|
||||
SmallPal[i] = PalEntry(255, lumb, lumb, lumb);
|
||||
}
|
||||
font->Unlock();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -400,7 +402,7 @@ public:
|
|||
|
||||
FFont *CreateHexLumpFont (const char *fontname, int lump)
|
||||
{
|
||||
if (hexdata.FirstChar == INT_MAX) hexdata.ParseDefinition(lump);
|
||||
assert(hexdata.FirstChar != INT_MAX);
|
||||
return new FHexFont(fontname, lump);
|
||||
}
|
||||
|
||||
|
@ -412,7 +414,7 @@ FFont *CreateHexLumpFont (const char *fontname, int lump)
|
|||
|
||||
FFont *CreateHexLumpFont2(const char *fontname, int lump)
|
||||
{
|
||||
if (hexdata.FirstChar == INT_MAX) hexdata.ParseDefinition(lump);
|
||||
assert(hexdata.FirstChar != INT_MAX);
|
||||
return new FHexFont2(fontname, lump);
|
||||
}
|
||||
|
||||
|
@ -424,8 +426,7 @@ FFont *CreateHexLumpFont2(const char *fontname, int lump)
|
|||
|
||||
uint8_t* GetHexChar(int codepoint)
|
||||
{
|
||||
auto lump = fileSystem.CheckNumForFullName("newconsolefont.hex", 0); // This is always loaded from gzdoom.pk3 to prevent overriding it with incomplete replacements.
|
||||
if (hexdata.FirstChar == INT_MAX) hexdata.ParseDefinition(lump);
|
||||
assert(hexdata.FirstChar != INT_MAX);
|
||||
|
||||
if (hexdata.glyphmap[codepoint] > 0)
|
||||
{
|
||||
|
@ -433,4 +434,13 @@ uint8_t* GetHexChar(int codepoint)
|
|||
return &hexdata.glyphdata[offset];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void LoadHexFont(const char* filename)
|
||||
{
|
||||
auto resf = FResourceFile::OpenResourceFile(filename);
|
||||
if (resf == nullptr) I_FatalError("Unable to open %s", filename);
|
||||
auto hexfont = resf->FindLump("newconsolefont.hex");
|
||||
if (hexfont == nullptr) I_FatalError("Unable to find newconsolefont.hex in %s", filename);
|
||||
hexdata.ParseDefinition(hexfont);
|
||||
}
|
||||
|
|
|
@ -173,6 +173,7 @@ void FreeSBarInfoScript();
|
|||
void I_UpdateWindowTitle();
|
||||
void S_ParseMusInfo();
|
||||
void D_GrabCVarDefaults();
|
||||
void LoadHexFont(const char* filename);
|
||||
|
||||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||
|
||||
|
@ -3474,6 +3475,15 @@ static int D_DoomMain_Internal (void)
|
|||
std::set_new_handler(NewFailure);
|
||||
const char *batchout = Args->CheckValue("-errorlog");
|
||||
|
||||
// [RH] Make sure zdoom.pk3 is always loaded,
|
||||
// as it contains magic stuff we need.
|
||||
wad = BaseFileSearch(BASEWAD, NULL, true, GameConfig);
|
||||
if (wad == NULL)
|
||||
{
|
||||
I_FatalError("Cannot find " BASEWAD);
|
||||
}
|
||||
LoadHexFont(wad); // load hex font early so we have it during startup.
|
||||
|
||||
C_InitConsole(80*8, 25*8, false);
|
||||
I_DetectOS();
|
||||
|
||||
|
@ -3503,13 +3513,6 @@ static int D_DoomMain_Internal (void)
|
|||
extern void D_ConfirmSendStats();
|
||||
D_ConfirmSendStats();
|
||||
|
||||
// [RH] Make sure zdoom.pk3 is always loaded,
|
||||
// as it contains magic stuff we need.
|
||||
wad = BaseFileSearch (BASEWAD, NULL, true, GameConfig);
|
||||
if (wad == NULL)
|
||||
{
|
||||
I_FatalError ("Cannot find " BASEWAD);
|
||||
}
|
||||
FString basewad = wad;
|
||||
|
||||
FString optionalwad = BaseFileSearch(OPTIONALWAD, NULL, true, GameConfig);
|
||||
|
|
Loading…
Reference in a new issue