Improve level metadata display and font handling

- If the level font is higher than 10 pixels, the third description
  line (Desc3) is disabled and unavailable. CJK languages require less
  characters to convey the same message (140 characters caused people
  to cram tweets in all languages except CJK) and this gives us enough
  room in the levels list without having to cram the metadata even more
  than it already was or showing less levels per page.
- The "Untitled Level" and "by Unknown" now selectively show up in the
  interface font instead of the level font.
This commit is contained in:
Dav999-v
2023-01-19 20:15:17 +01:00
committed by Misa Elizabeth Kai
parent 653eee505b
commit 8d5e3b1a8a
5 changed files with 122 additions and 47 deletions

View File

@@ -198,7 +198,11 @@ static void menurender(void)
}else{
// TODO: Use level-specific font (via PR_FONT_IDX?)
font::print(PR_2X | PR_CEN, -1, 15, cl.ListOfMetaData[tmp].title, tr, tg, tb);
uint32_t level_flags = PR_FONT_8X8; // TEMP
uint32_t title_flags = cl.ListOfMetaData[tmp].title_is_gettext ? PR_FONT_INTERFACE : level_flags;
uint32_t creator_flags = cl.ListOfMetaData[tmp].creator_is_gettext ? PR_FONT_INTERFACE : level_flags;
font::print(title_flags | PR_2X | PR_CEN, -1, 15, cl.ListOfMetaData[tmp].title, tr, tg, tb);
char creatorline[SCREEN_WIDTH_CHARS + 1];
vformat_buf(
creatorline, sizeof(creatorline),
@@ -206,11 +210,15 @@ static void menurender(void)
"author:str",
cl.ListOfMetaData[tmp].creator.c_str()
);
graphics.Print( -1, 40, creatorline, tr, tg, tb, true);
graphics.Print( -1, 50, cl.ListOfMetaData[tmp].website, tr, tg, tb, true);
graphics.Print( -1, 70, cl.ListOfMetaData[tmp].Desc1, tr, tg, tb, true);
graphics.Print( -1, 80, cl.ListOfMetaData[tmp].Desc2, tr, tg, tb, true);
graphics.Print( -1, 90, cl.ListOfMetaData[tmp].Desc3, tr, tg, tb, true);
int sp = SDL_max(10, font::height(level_flags));
font::print(creator_flags | PR_CEN, -1, 40, creatorline, tr, tg, tb);
font::print(level_flags | PR_CEN, -1, 40+sp, cl.ListOfMetaData[tmp].website, tr, tg, tb);
font::print(level_flags | PR_CEN, -1, 40+sp*3, cl.ListOfMetaData[tmp].Desc1, tr, tg, tb);
font::print(level_flags | PR_CEN, -1, 40+sp*4, cl.ListOfMetaData[tmp].Desc2, tr, tg, tb);
if (sp <= 10)
{
font::print(level_flags | PR_CEN, -1, 40+sp*5, cl.ListOfMetaData[tmp].Desc3, tr, tg, tb);
}
}
}
break;
@@ -2588,7 +2596,10 @@ void maprender(void)
else if(map.custommode){
LevelMetaData& meta = cl.ListOfMetaData[game.playcustomlevel];
font::print(PR_2X | PR_CEN | PR_FONT_LEVEL, -1, FLIP(45, 8), meta.title, 196, 196, 255 - help.glow);
uint32_t title_flags = meta.title_is_gettext ? PR_FONT_INTERFACE : PR_FONT_LEVEL;
uint32_t creator_flags = meta.creator_is_gettext ? PR_FONT_INTERFACE : PR_FONT_LEVEL;
font::print(title_flags | PR_2X | PR_CEN, -1, FLIP(45, 8), meta.title, 196, 196, 255 - help.glow);
char buffer[SCREEN_WIDTH_CHARS + 1];
vformat_buf(
buffer, sizeof(buffer),
@@ -2596,11 +2607,15 @@ void maprender(void)
"author:str",
meta.creator.c_str()
);
font::print(PR_CEN | PR_FONT_LEVEL, -1, FLIP(70, 8), buffer, 196, 196, 255 - help.glow);
font::print(PR_CEN | PR_FONT_LEVEL, -1, FLIP(80, 8), meta.website, 196, 196, 255 - help.glow);
font::print(PR_CEN | PR_FONT_LEVEL, -1, FLIP(100, 8), meta.Desc1, 196, 196, 255 - help.glow);
font::print(PR_CEN | PR_FONT_LEVEL, -1, FLIP(110, 8), meta.Desc2, 196, 196, 255 - help.glow);
font::print(PR_CEN | PR_FONT_LEVEL, -1, FLIP(120, 8), meta.Desc3, 196, 196, 255 - help.glow);
int sp = SDL_max(10, font::height(PR_FONT_LEVEL));
font::print(creator_flags | PR_CEN, -1, FLIP(70, 8), buffer, 196, 196, 255 - help.glow);
font::print(PR_FONT_LEVEL | PR_CEN, -1, FLIP(70+sp, 8), meta.website, 196, 196, 255 - help.glow);
font::print(PR_FONT_LEVEL | PR_CEN, -1, FLIP(70+sp*3, 8), meta.Desc1, 196, 196, 255 - help.glow);
font::print(PR_FONT_LEVEL | PR_CEN, -1, FLIP(70+sp*4, 8), meta.Desc2, 196, 196, 255 - help.glow);
if (sp <= 10)
{
font::print(PR_FONT_LEVEL | PR_CEN, -1, FLIP(70+sp*5, 8), meta.Desc3, 196, 196, 255 - help.glow);
}
int remaining = cl.numcrewmates() - game.crewmates();