mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Make main game content use interface font instead of 8x8 font
If a custom level doesn't specify a font, it should be the 8x8 font. But the main game can't specify a font, it's just the interface font because that's for the language that the game is in.
This commit is contained in:
parent
25feb9dbb5
commit
b030ce568f
4 changed files with 51 additions and 24 deletions
|
@ -70,8 +70,9 @@ static FontContainer fonts_custom = {};
|
|||
|
||||
static uint8_t font_idx_8x8 = 0;
|
||||
|
||||
static bool font_idx_custom_is_custom = false;
|
||||
static uint8_t font_idx_custom = 0;
|
||||
static bool font_level_is_interface = false;
|
||||
static bool font_idx_level_is_custom = false;
|
||||
static uint8_t font_idx_level = 0;
|
||||
|
||||
static void codepoint_split(
|
||||
const uint32_t codepoint,
|
||||
|
@ -404,31 +405,40 @@ uint8_t get_font_idx_8x8(void)
|
|||
return font_idx_8x8;
|
||||
}
|
||||
|
||||
void set_custom_font(const char* name)
|
||||
void set_level_font(const char* name)
|
||||
{
|
||||
/* Apply the choice for a certain level-specific font. */
|
||||
/* Apply the choice for a certain level-specific font.
|
||||
* This function is for custom levels. */
|
||||
font_level_is_interface = false;
|
||||
|
||||
if (find_font_by_name(&fonts_custom, name, &font_idx_custom))
|
||||
if (find_font_by_name(&fonts_custom, name, &font_idx_level))
|
||||
{
|
||||
font_idx_custom_is_custom = true;
|
||||
font_idx_level_is_custom = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
font_idx_custom_is_custom = false;
|
||||
if (!find_font_by_name(&fonts_main, name, &font_idx_custom))
|
||||
font_idx_level_is_custom = false;
|
||||
if (!find_font_by_name(&fonts_main, name, &font_idx_level))
|
||||
{
|
||||
if (SDL_strcmp(name, "font") != 0)
|
||||
{
|
||||
set_custom_font("font");
|
||||
set_level_font("font");
|
||||
}
|
||||
else
|
||||
{
|
||||
font_idx_custom = font_idx_8x8;
|
||||
font_idx_level = font_idx_8x8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void set_level_font_interface(void)
|
||||
{
|
||||
/* Set the level font equal to the interface font.
|
||||
* This function is for the main game. */
|
||||
font_level_is_interface = true;
|
||||
}
|
||||
|
||||
static void load_font_filename(bool is_custom, const char* filename)
|
||||
{
|
||||
// Load font.png, and everything that matches *.fontmeta (but not font.fontmeta)
|
||||
|
@ -467,6 +477,7 @@ void load_main(void)
|
|||
load_font_filename(false, item);
|
||||
}
|
||||
FILESYSTEM_freeEnumerate(&handle);
|
||||
font_idx_level = font_idx_8x8;
|
||||
}
|
||||
|
||||
void load_custom(const char* name)
|
||||
|
@ -481,7 +492,7 @@ void load_custom(const char* name)
|
|||
}
|
||||
FILESYSTEM_freeEnumerate(&handle);
|
||||
|
||||
set_custom_font(name);
|
||||
set_level_font(name);
|
||||
}
|
||||
|
||||
void unload_font(Font* f)
|
||||
|
@ -559,17 +570,21 @@ static Font* fontsel_to_font(int sel)
|
|||
|
||||
switch (sel)
|
||||
{
|
||||
case 1:
|
||||
if (!font_level_is_interface)
|
||||
{
|
||||
if (font_idx_level_is_custom)
|
||||
{
|
||||
return container_get(&fonts_custom, font_idx_level);
|
||||
}
|
||||
else
|
||||
{
|
||||
return container_get(&fonts_main, font_idx_level);
|
||||
}
|
||||
}
|
||||
SDL_FALLTHROUGH;
|
||||
case 0:
|
||||
return container_get(&fonts_main, loc::get_langmeta()->font_idx);
|
||||
case 1:
|
||||
if (font_idx_custom_is_custom)
|
||||
{
|
||||
return container_get(&fonts_custom, font_idx_custom);
|
||||
}
|
||||
else
|
||||
{
|
||||
return container_get(&fonts_main, font_idx_custom);
|
||||
}
|
||||
case 2:
|
||||
return container_get(&fonts_main, font_idx_8x8);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,8 @@ bool find_main_font_by_name(const char* name, uint8_t* idx);
|
|||
const char* get_main_font_name(uint8_t idx);
|
||||
uint8_t get_font_idx_8x8(void);
|
||||
|
||||
void set_custom_font(const char* name);
|
||||
void set_level_font(const char* name);
|
||||
void set_level_font_interface(void);
|
||||
void load_main(void);
|
||||
void load_custom(const char* name);
|
||||
void unload_custom(void);
|
||||
|
|
|
@ -7186,7 +7186,7 @@ void Game::returntoeditor(void)
|
|||
ed.roomnamehide = 0;
|
||||
|
||||
// Might've been changed in a script
|
||||
font::set_custom_font(cl.level_font_name.c_str());
|
||||
font::set_level_font(cl.level_font_name.c_str());
|
||||
|
||||
DEFER_CALLBACK(resetbg);
|
||||
music.fadeout();
|
||||
|
|
|
@ -2429,11 +2429,11 @@ void scriptclass::run(void)
|
|||
#ifndef NO_CUSTOM_LEVELS
|
||||
if (words[1] == "")
|
||||
{
|
||||
font::set_custom_font(cl.level_font_name.c_str());
|
||||
font::set_level_font(cl.level_font_name.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
font::set_custom_font(words[1].c_str());
|
||||
font::set_level_font(words[1].c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -2592,6 +2592,17 @@ void scriptclass::startgamemode(const enum StartMode mode)
|
|||
game.gamestate = GAMEMODE;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case Start_EDITOR:
|
||||
case Start_EDITORPLAYTESTING:
|
||||
case Start_CUSTOM:
|
||||
case Start_CUSTOM_QUICKSAVE:
|
||||
break;
|
||||
default:
|
||||
font::set_level_font_interface();
|
||||
}
|
||||
|
||||
game.jumpheld = true;
|
||||
|
||||
switch (mode)
|
||||
|
|
Loading…
Reference in a new issue