1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Add setfont scripting command

The <font> in the level file is basically the starting font, but it can
be changed at any time via scripting.
This commit is contained in:
Dav999-v 2023-01-20 04:57:06 +01:00 committed by Misa Elizabeth Kai
parent 7db0e73109
commit cc6b00a711
4 changed files with 21 additions and 1 deletions

View file

@ -404,7 +404,7 @@ uint8_t get_font_idx_8x8(void)
return font_idx_8x8;
}
static void set_custom_font(const char* name)
void set_custom_font(const char* name)
{
/* Apply the choice for a certain level-specific font. */

View file

@ -64,6 +64,7 @@ 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 load_main(void);
void load_custom(const char* name);
void unload_custom(void);

View file

@ -7185,6 +7185,9 @@ void Game::returntoeditor(void)
ed.notedelay = 0;
ed.roomnamehide = 0;
// Might've been changed in a script
font::set_custom_font(cl.level_font_name.c_str());
DEFER_CALLBACK(resetbg);
music.fadeout();
//If warpdir() is used during playtesting, we need to set it back after!

View file

@ -2424,6 +2424,19 @@ void scriptclass::run(void)
position--;
}
}
else if (words[0] == "setfont")
{
#ifndef NO_CUSTOM_LEVELS
if (words[1] == "")
{
font::set_custom_font(cl.level_font_name.c_str());
}
else
{
font::set_custom_font(words[1].c_str());
}
#endif
}
position++;
}
@ -3433,6 +3446,9 @@ bool scriptclass::loadcustom(const std::string& t)
}else if(words[0] == "loadtext"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "setfont"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "destroy"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);