Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into vulkan2
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed Apr 10, 2019
2 parents 85b754b + 8b0dd13 commit 7b06fbe
Show file tree
Hide file tree
Showing 41 changed files with 155 additions and 3,801 deletions.
24 changes: 17 additions & 7 deletions src/gameconfigfile.cpp
Expand Up @@ -210,13 +210,23 @@ void FGameConfigFile::DoAutoloadSetup (FIWadManager *iwad_man)
RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload");
RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload");
RenameSection("Freedoom.Autoload", "doom.freedoom.Autoload");
RenameSection("DoomBFG.Autoload", "doom.doom1.bfg.Autoload");
RenameSection("DoomU.Autoload", "doom.doom1.ultimate.Autoload");
RenameSection("Doom1.Autoload", "doom.doom1.registered.Autoload");
RenameSection("TNT.Autoload", "doom.doom2.tnt.Autoload");
RenameSection("Plutonia.Autoload", "doom.doom2.plutonia.Autoload");
RenameSection("Doom2BFG.Autoload", "doom.doom2.bfg.Autoload");
RenameSection("Doom2.Autoload", "doom.doom2.commercial.Autoload");
RenameSection("DoomBFG.Autoload", "doom.id.doom1.bfg.Autoload");
RenameSection("DoomU.Autoload", "doom.id.doom1.ultimate.Autoload");
RenameSection("Doom1.Autoload", "doom.id.doom1.registered.Autoload");
RenameSection("TNT.Autoload", "doom.id.doom2.tnt.Autoload");
RenameSection("Plutonia.Autoload", "doom.id.doom2.plutonia.Autoload");
RenameSection("Doom2BFG.Autoload", "doom.id.doom2.bfg.Autoload");
RenameSection("Doom2.Autoload", "doom.id.doom2.commercial.Autoload");
}
else if (last < 218)
{
RenameSection("doom.doom1.bfg.Autoload", "doom.id.doom1.bfg.Autoload");
RenameSection("doom.doom1.ultimate.Autoload", "doom.id.doom1.ultimate.Autoload");
RenameSection("doom.doom1.registered.Autoload", "doom.id.doom1.registered.Autoload");
RenameSection("doom.doom2.tnt.Autoload", "doom.id.doom2.tnt.Autoload");
RenameSection("doom.doom2.plutonia.Autoload", "doom.id.doom2.plutonia.Autoload");
RenameSection("doom.doom2.bfg.Autoload", "doom.id.doom2.bfg.Autoload");
RenameSection("doom.doom2.commercial.Autoload", "doom.id.doom2.commercial.Autoload");
}
const FString *pAuto;
for (int num = 0; (pAuto = iwad_man->GetAutoname(num)) != NULL; num++)
Expand Down
22 changes: 20 additions & 2 deletions src/gamedata/g_mapinfo.cpp
Expand Up @@ -765,12 +765,30 @@ void FMapInfoParser::ParseCluster()
ParseAssign();
if (ParseLookupName(clusterinfo->EnterText))
clusterinfo->flags |= CLUSTER_LOOKUPENTERTEXT;
else
{
FStringf testlabel("CLUSTERENTER%d", clusterinfo->cluster);
if (GStrings.MatchDefaultString(testlabel, clusterinfo->EnterText))
{
clusterinfo->EnterText = testlabel;
clusterinfo->flags |= CLUSTER_LOOKUPENTERTEXT;
}
}
}
else if (sc.Compare("exittext"))
{
ParseAssign();
if (ParseLookupName(clusterinfo->ExitText))
clusterinfo->flags |= CLUSTER_LOOKUPEXITTEXT;
else
{
FStringf testlabel("CLUSTEREXIT%d", clusterinfo->cluster);
if (GStrings.MatchDefaultString(testlabel, clusterinfo->ExitText))
{
clusterinfo->ExitText = testlabel;
clusterinfo->flags |= CLUSTER_LOOKUPEXITTEXT;
}
}
}
else if (sc.Compare("music"))
{
Expand Down Expand Up @@ -1933,8 +1951,8 @@ level_info_t *FMapInfoParser::ParseMapHeader(level_info_t &defaultinfo)
// Workaround to allow localizazion of IWADs which do not have a string label here (e.g. HACX.WAD)
// This checks for a string labelled with the MapName and if that is identical to what got parsed here
// the string table entry will be used.
auto c = GStrings.GetLanguageString(levelinfo->MapName, FStringTable::default_table);
if (c && !strcmp(c, sc.String))

if (GStrings.MatchDefaultString(levelinfo->MapName, sc.String))
{
levelinfo->flags |= LEVEL_LOOKUPLEVELNAME;
levelinfo->LevelName = levelinfo->MapName;
Expand Down
13 changes: 12 additions & 1 deletion src/gamedata/resourcefiles/resourcefile.cpp
Expand Up @@ -367,6 +367,7 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize)
{
// Entries in archives are sorted alphabetically
qsort(lumps, NumLumps, lumpsize, lumpcmp);


// Filter out lumps using the same names as the Autoload.* sections
// in the ini file use. We reduce the maximum lump concidered after
Expand Down Expand Up @@ -406,7 +407,17 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize,
return 0;
}
filter << "filter/" << filtername << '/';
if (FindPrefixRange(filter, lumps, lumpsize, max, start, end))

bool found = FindPrefixRange(filter, lumps, lumpsize, max, start, end);

// Workaround for old Doom filter names.
if (!found && filtername.IndexOf("doom.id.doom") == 0)
{
filter.Substitute("doom.id.doom", "doom.doom");
found = FindPrefixRange(filter, lumps, lumpsize, max, start, end);
}

if (found)
{
void *from = (uint8_t *)lumps + start * lumpsize;

Expand Down
31 changes: 30 additions & 1 deletion src/gamedata/stringtable.cpp
Expand Up @@ -250,6 +250,10 @@ bool FStringTable::ParseLanguageCSV(const TArray<uint8_t> &buffer)
{
InsertString(langentry.second, strName, str);
}
else
{
DeleteString(langentry.second, strName);
}
}
}
}
Expand Down Expand Up @@ -372,6 +376,17 @@ void FStringTable::LoadLanguage (const TArray<uint8_t> &buffer)
//
//==========================================================================

void FStringTable::DeleteString(int langid, FName label)
{
allStrings[langid].Remove(label);
}

//==========================================================================
//
//
//
//==========================================================================

void FStringTable::InsertString(int langid, FName label, const FString &string)
{
const char *strlangid = (const char *)&langid;
Expand All @@ -386,7 +401,7 @@ void FStringTable::InsertString(int langid, FName label, const FString &string)
break;
}
FString macroname(te.strings[0].GetChars() + index + 2, endindex - index - 2);
FStringf lookupstr("%s/%s", strlangid, macroname.GetChars());
FStringf lookupstr("%s/%s", strlangid, macroname.GetChars());
FStringf replacee("@[%s]", macroname.GetChars());
FName lookupname(lookupstr, true);
auto replace = allMacros.CheckKey(lookupname);
Expand Down Expand Up @@ -550,6 +565,20 @@ const char *FStringTable::GetLanguageString(const char *name, uint32_t langtable
return nullptr;
}

bool FStringTable::MatchDefaultString(const char *name, const char *content) const
{
// This only compares the first line to avoid problems with bad linefeeds. For the few cases where this feature is needed it is sufficient.
auto c = GetLanguageString(name, FStringTable::default_table);
if (!c) return false;

// Check a secondary key, in case the text comparison cannot be done due to needed orthographic fixes (see Harmony's exit text)
FStringf checkkey("%s_CHECK", name);
auto cc = GetLanguageString(checkkey, FStringTable::default_table);
if (cc) c = cc;

return (c && !strnicmp(c, content, strcspn(content, "\n\r\t")));
}

//==========================================================================
//
// Finds a string by name and returns its value. If the string does
Expand Down
2 changes: 2 additions & 0 deletions src/gamedata/stringtable.h
Expand Up @@ -89,6 +89,7 @@ class FStringTable
}

const char *GetLanguageString(const char *name, uint32_t langtable, int gender = -1) const;
bool MatchDefaultString(const char *name, const char *content) const;
const char *GetString(const char *name, uint32_t *langtable, int gender = -1) const;
const char *operator() (const char *name) const; // Never returns NULL
const char *operator[] (const char *name) const
Expand All @@ -110,6 +111,7 @@ class FStringTable
bool LoadLanguageFromSpreadsheet(int lumpnum, const TArray<uint8_t> &buffer);
bool readMacros(int lumpnum);
void InsertString(int langid, FName label, const FString &string);
void DeleteString(int langid, FName label);

static size_t ProcessEscapes (char *str);
};
Expand Down
63 changes: 33 additions & 30 deletions src/hu_scores.cpp
Expand Up @@ -130,6 +130,9 @@ void HU_SortPlayers
*/

bool SB_ForceActive = false;
static FFont *displayFont;
static int FontScale;


// PRIVATE DATA DEFINITIONS ------------------------------------------------

Expand All @@ -143,6 +146,9 @@ bool SB_ForceActive = false;

void HU_DrawScores (player_t *player)
{
displayFont = NewSmallFont;
FontScale = MAX(screen->GetHeight() / 400, 1);

if (deathmatch)
{
if (teamplay)
Expand Down Expand Up @@ -195,15 +201,15 @@ void HU_DrawScores (player_t *player)

void HU_GetPlayerWidths(int &maxnamewidth, int &maxscorewidth, int &maxiconheight)
{
maxnamewidth = SmallFont->StringWidth("Name");
maxnamewidth = displayFont->StringWidth("Name");
maxscorewidth = 0;
maxiconheight = 0;

for (int i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
{
int width = SmallFont->StringWidth(players[i].userinfo.GetName());
int width = displayFont->StringWidth(players[i].userinfo.GetName());
if (width > maxnamewidth)
{
maxnamewidth = width;
Expand Down Expand Up @@ -235,6 +241,11 @@ void HU_GetPlayerWidths(int &maxnamewidth, int &maxscorewidth, int &maxiconheigh
//
//==========================================================================

static void HU_DrawFontScaled(double x, double y, int color, const char *text)
{
screen->DrawText(displayFont, color, x / FontScale, y / FontScale, text, DTA_VirtualWidth, screen->GetWidth() / FontScale, DTA_VirtualHeight, screen->GetHeight() / FontScale, TAG_END);
}

static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYERS])
{
int color;
Expand All @@ -258,7 +269,7 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER
}

HU_GetPlayerWidths(maxnamewidth, maxscorewidth, maxiconheight);
height = SmallFont->GetHeight() * CleanYfac;
height = displayFont->GetHeight() * FontScale;
lineheight = MAX(height, maxiconheight * CleanYfac);
ypadding = (lineheight - height + 1) / 2;

Expand Down Expand Up @@ -327,23 +338,16 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER
*text_name = GStrings("SCORE_NAME"),
*text_delay = GStrings("SCORE_DELAY");

col2 = (SmallFont->StringWidth(text_color) + 8) * CleanXfac;
col3 = col2 + (SmallFont->StringWidth(text_frags) + 8) * CleanXfac;
col4 = col3 + maxscorewidth * CleanXfac;
col5 = col4 + (maxnamewidth + 8) * CleanXfac;
x = (SCREENWIDTH >> 1) - (((SmallFont->StringWidth(text_delay) * CleanXfac) + col5) >> 1);
col2 = (displayFont->StringWidth(text_color) + 16) * FontScale;
col3 = col2 + (displayFont->StringWidth(text_frags) + 16) * FontScale;
col4 = col3 + maxscorewidth * FontScale;
col5 = col4 + (maxnamewidth + 16) * FontScale;
x = (SCREENWIDTH >> 1) - (((displayFont->StringWidth(text_delay) * FontScale) + col5) >> 1);

screen->DrawText (SmallFont, color, x, y, text_color,
DTA_CleanNoMove, true, TAG_DONE);

screen->DrawText (SmallFont, color, x + col2, y, text_frags,
DTA_CleanNoMove, true, TAG_DONE);

screen->DrawText (SmallFont, color, x + col4, y, text_name,
DTA_CleanNoMove, true, TAG_DONE);

screen->DrawText(SmallFont, color, x + col5, y, text_delay,
DTA_CleanNoMove, true, TAG_DONE);
//HU_DrawFontScaled(x, y, color, text_color);
HU_DrawFontScaled(x + col2, y, color, text_frags);
HU_DrawFontScaled(x + col4, y, color, text_name);
HU_DrawFontScaled(x + col5, y, color, text_delay);

y += height + 6 * CleanYfac;
bottom -= height;
Expand Down Expand Up @@ -385,9 +389,8 @@ static void HU_DrawTimeRemaining (int y)
mysnprintf (str, countof(str), "Level ends in %d:%02d:%02d", hours, minutes, seconds);
else
mysnprintf (str, countof(str), "Level ends in %d:%02d", minutes, seconds);

screen->DrawText (SmallFont, CR_GREY, SCREENWIDTH/2 - SmallFont->StringWidth (str)/2*CleanXfac,
y, str, DTA_CleanNoMove, true, TAG_DONE);

HU_DrawFontScaled(SCREENWIDTH / 2 - displayFont->StringWidth(str) / 2 * FontScale, y, CR_GRAY, str);
}
}

Expand All @@ -407,7 +410,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
// The teamplay mode uses colors to show teams, so we need some
// other way to do highlighting. And it may as well be used for
// all modes for the sake of consistancy.
screen->Dim(MAKERGB(200,245,255), 0.125f, col1 - 12*CleanXfac, y - 1, col5 + (maxnamewidth + 24)*CleanXfac, height + 2);
screen->Dim(MAKERGB(200,245,255), 0.125f, col1 - 12*FontScale, y - 1, col5 + (maxnamewidth + 24)*FontScale, height + 2);
}

col2 += col1;
Expand All @@ -419,8 +422,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
HU_DrawColorBar(col1, y, height, (int)(player - players));
mysnprintf (str, countof(str), "%d", deathmatch ? player->fragcount : player->killcount);

screen->DrawText (SmallFont, color, col2, y + ypadding, player->playerstate == PST_DEAD && !deathmatch ? "DEAD" : str,
DTA_CleanNoMove, true, TAG_DONE);
HU_DrawFontScaled(col2, y + ypadding, color, player->playerstate == PST_DEAD && !deathmatch ? "DEAD" : str);

auto icon = FSetTextureID(player->mo->IntVar(NAME_ScoreIcon));
if (icon.isValid())
Expand All @@ -431,8 +433,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
TAG_DONE);
}

screen->DrawText (SmallFont, color, col4, y + ypadding, player->userinfo.GetName(),
DTA_CleanNoMove, true, TAG_DONE);
HU_DrawFontScaled(col4, y + ypadding, color, player->userinfo.GetName());

int avgdelay = 0;
for (int i = 0; i < BACKUPTICS; i++)
Expand All @@ -443,8 +444,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,

mysnprintf(str, countof(str), "%d", (avgdelay * ticdup) * (1000 / TICRATE));

screen->DrawText(SmallFont, color, col5, y + ypadding, str,
DTA_CleanNoMove, true, TAG_DONE);
HU_DrawFontScaled(col5, y + ypadding, color, str);

if (teamplay && Teams[player->userinfo.GetTeam()].GetLogo().IsNotEmpty ())
{
Expand All @@ -467,7 +467,10 @@ void HU_DrawColorBar(int x, int y, int height, int playernum)
D_GetPlayerColor (playernum, &h, &s, &v, NULL);
HSVtoRGB (&r, &g, &b, h, s, v);

screen->Clear (x, y, x + 24*CleanXfac, y + height, -1,
//float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT);
//if (!AspectTallerThanWide(aspect)) x += (screen->GetWidth() - AspectBaseWidth(aspect)) / 2;

screen->Clear (x, y, x + 24*FontScale, y + height, -1,
MAKEARGB(255,clamp(int(r*255.f),0,255),
clamp(int(g*255.f),0,255),
clamp(int(b*255.f),0,255)));
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Expand Up @@ -65,7 +65,7 @@ const char *GetVersionString();
// Version stored in the ini's [LastRun] section.
// Bump it if you made some configuration change that you want to
// be able to migrate in FGameConfigFile::DoGlobalSetup().
#define LASTRUNVERSION "217"
#define LASTRUNVERSION "218"

// Protocol version used in demos.
// Bump it if you change existing DEM_ commands or add new ones.
Expand Down

0 comments on commit 7b06fbe

Please sign in to comment.