mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- added a 'testfinale' CCMD, so that the layout of finale texts can be tested more easily
This commit is contained in:
parent
86620aaba5
commit
23a62cbe12
4 changed files with 60 additions and 0 deletions
|
@ -366,6 +366,27 @@ const char *FStringTable::GetString(const char *name, uint32_t *langtable) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// Finds a string by name in a given language
|
||||
const char *FStringTable::GetLanguageString(const char *name, uint32_t langtable) const
|
||||
{
|
||||
if (name == nullptr || *name == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
FName nm(name, true);
|
||||
if (nm != NAME_None)
|
||||
{
|
||||
auto map = allStrings.CheckKey(langtable);
|
||||
if (map == nullptr) return nullptr;
|
||||
auto item = map->CheckKey(nm);
|
||||
if (item)
|
||||
{
|
||||
return item->GetChars();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Finds a string by name and returns its value. If the string does
|
||||
// not exist, returns the passed name instead.
|
||||
const char *FStringTable::operator() (const char *name) const
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
UpdateLanguage();
|
||||
}
|
||||
|
||||
const char *GetLanguageString(const char *name, uint32_t langtable) const;
|
||||
const char *GetString(const char *name, uint32_t *langtable) const;
|
||||
const char *operator() (const char *name) const; // Never returns NULL
|
||||
const char *operator[] (const char *name) const
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "d_net.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "utf8.h"
|
||||
#include "templates.h"
|
||||
|
||||
FIntermissionDescriptorList IntermissionDescriptors;
|
||||
|
||||
|
@ -314,6 +315,7 @@ void DIntermissionScreenText::Drawer ()
|
|||
|
||||
int cx = (mTextX - 160)*CleanXfac + screen->GetWidth() / 2;
|
||||
int cy = (mTextY - 100)*CleanYfac + screen->GetHeight() / 2;
|
||||
cx = MAX<int>(0, cx);
|
||||
int startx = cx;
|
||||
|
||||
// Does this text fall off the end of the screen? If so, try to eliminate some margins first.
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
#include "intermission/intermission.h"
|
||||
#include "g_level.h"
|
||||
#include "w_wad.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "gstrings.h"
|
||||
#include "gi.h"
|
||||
|
||||
|
||||
static void ReplaceIntermission(FName intname,FIntermissionDescriptor *desc)
|
||||
|
@ -904,3 +906,37 @@ void F_StartFinale (const char *music, int musicorder, int cdtrack, unsigned int
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CCMD(testfinale)
|
||||
{
|
||||
if (argv.argc() < 2)
|
||||
{
|
||||
Printf("Usage: testfinale stringlabel [langId]\n");
|
||||
return;
|
||||
}
|
||||
const char *text;
|
||||
|
||||
if (argv.argc() == 2)
|
||||
{
|
||||
text = GStrings.GetString(argv[1], nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto len = strlen(argv[2]);
|
||||
if (len < 2 || len > 3)
|
||||
{
|
||||
Printf("Language ID must be 2 or 3 characters\n");
|
||||
return;
|
||||
}
|
||||
auto id = MAKE_ID(tolower(argv[2][0]), tolower(argv[2][1]), tolower(argv[2][2]), 0);
|
||||
text = GStrings.GetLanguageString(argv[1], id);
|
||||
}
|
||||
if (text == nullptr)
|
||||
{
|
||||
Printf("Text does not exist\n");
|
||||
return;
|
||||
}
|
||||
|
||||
F_StartFinale(gameinfo.finaleMusic, gameinfo.finaleOrder, -1, 0, gameinfo.FinaleFlat, text, false, false, true, true, false);
|
||||
}
|
Loading…
Reference in a new issue