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

Add textimage for levelcomplete and gamecomplete

`levelcomplete` and `gamecomplete` were hardcoded using textbox colors
which were offset by 1. This PR fixes that, no longer requiring
slightly-off colors, and instead adding a new property to textboxes
which tell the game to display either level complete or game complete.
This commit is contained in:
AllyTally 2023-08-20 14:11:44 -03:00 committed by Misa Elizabeth Kai
parent b5c9508dd4
commit 103b4d36a1
7 changed files with 56 additions and 4 deletions

View file

@ -663,12 +663,13 @@ void Game::savecustomlevelstats(void)
void Game::levelcomplete_textbox(void) void Game::levelcomplete_textbox(void)
{ {
graphics.createtextboxflipme("", -1, 12, 165, 165, 255); graphics.createtextboxflipme("", -1, 12, TEXT_COLOUR("cyan"));
graphics.addline(" "); graphics.addline(" ");
graphics.addline(""); graphics.addline("");
graphics.addline(""); graphics.addline("");
graphics.textboxprintflags(PR_FONT_8X8); graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx(); graphics.textboxcenterx();
graphics.setimage(TEXTIMAGE_LEVELCOMPLETE);
} }
void Game::crewmate_textbox(const int color) void Game::crewmate_textbox(const int color)
@ -2861,12 +2862,13 @@ void Game::updatestate(void)
setstatedelay(75); setstatedelay(75);
music.play(Music_PLENARY); music.play(Music_PLENARY);
graphics.createtextboxflipme("", -1, 12, 164, 165, 255); graphics.createtextboxflipme("", -1, 12, TEXT_COLOUR("cyan"));
graphics.addline(" "); graphics.addline(" ");
graphics.addline(""); graphics.addline("");
graphics.addline(""); graphics.addline("");
graphics.textboxprintflags(PR_FONT_8X8); graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx(); graphics.textboxcenterx();
graphics.setimage(TEXTIMAGE_GAMECOMPLETE);
break; break;
case 3502: case 3502:
{ {

View file

@ -944,7 +944,7 @@ void Graphics::drawgui(void)
continue; continue;
} }
if (textboxes[i].yp == 12 && textboxes[i].r == 165) if (textboxes[i].image == TEXTIMAGE_LEVELCOMPLETE)
{ {
// Level complete // Level complete
const char* english = "Level Complete!"; const char* english = "Level Complete!";
@ -981,7 +981,7 @@ void Graphics::drawgui(void)
} }
} }
} }
else if (textboxes[i].yp == 12 && textboxes[i].g == 165) else if (textboxes[i].image == TEXTIMAGE_GAMECOMPLETE)
{ {
// Game complete // Game complete
const char* english = "Game Complete!"; const char* english = "Game Complete!";
@ -1430,6 +1430,17 @@ void Graphics::addsprite(int x, int y, int tile, int col)
textboxes[m].addsprite(x, y, tile, col); textboxes[m].addsprite(x, y, tile, col);
} }
void Graphics::setimage(TextboxImage image)
{
if (!INBOUNDS_VEC(m, textboxes))
{
vlog_error("setimage() out-of-bounds!");
return;
}
textboxes[m].setimage(image);
}
void Graphics::addline( const std::string& t ) void Graphics::addline( const std::string& t )
{ {
if (!INBOUNDS_VEC(m, textboxes)) if (!INBOUNDS_VEC(m, textboxes))

View file

@ -124,6 +124,8 @@ public:
void addsprite(int x, int y, int tile, int col); void addsprite(int x, int y, int tile, int col);
void setimage(TextboxImage image);
void textboxremove(void); void textboxremove(void);
void textboxremovefast(void); void textboxremovefast(void);

View file

@ -54,6 +54,7 @@ scriptclass::scriptclass(void)
textbuttons = false; textbuttons = false;
textlarge = false; textlarge = false;
textbox_sprites.clear(); textbox_sprites.clear();
textbox_image = TEXTIMAGE_NONE;
} }
void scriptclass::add_default_colours(void) void scriptclass::add_default_colours(void)
@ -530,6 +531,7 @@ void scriptclass::run(void)
textpadtowidth = 0; textpadtowidth = 0;
textboxtimer = 0; textboxtimer = 0;
textbox_sprites.clear(); textbox_sprites.clear();
textbox_image = TEXTIMAGE_NONE;
translate_dialogue(); translate_dialogue();
} }
@ -709,6 +711,21 @@ void scriptclass::run(void)
sprite.col = ss_toi(words[4]); sprite.col = ss_toi(words[4]);
textbox_sprites.push_back(sprite); textbox_sprites.push_back(sprite);
} }
else if (words[0] == "textimage")
{
if (words[1] == "levelcomplete")
{
textbox_image = TEXTIMAGE_LEVELCOMPLETE;
}
else if (words[1] == "gamecomplete")
{
textbox_image = TEXTIMAGE_GAMECOMPLETE;
}
else
{
textbox_image = TEXTIMAGE_NONE;
}
}
else if (words[0] == "flipme") else if (words[0] == "flipme")
{ {
textflipme = !textflipme; textflipme = !textflipme;
@ -745,6 +762,8 @@ void scriptclass::run(void)
graphics.addsprite(textbox_sprites[i].x, textbox_sprites[i].y, textbox_sprites[i].tile, textbox_sprites[i].col); graphics.addsprite(textbox_sprites[i].x, textbox_sprites[i].y, textbox_sprites[i].tile, textbox_sprites[i].col);
} }
graphics.setimage(textbox_image);
// Some textbox formatting that can be set by translations... // Some textbox formatting that can be set by translations...
if (textcentertext) if (textcentertext)
{ {

View file

@ -125,6 +125,7 @@ public:
bool textlarge; bool textlarge;
int textboxtimer; int textboxtimer;
std::vector<TextboxSprite> textbox_sprites; std::vector<TextboxSprite> textbox_sprites;
TextboxImage textbox_image;
//Misc //Misc
int i, j, k; int i, j, k;

View file

@ -30,6 +30,8 @@ textboxclass::textboxclass(void)
fill_buttons = false; fill_buttons = false;
sprites.clear(); sprites.clear();
image = TEXTIMAGE_NONE;
} }
void textboxclass::addsprite(int x, int y, int tile, int col) void textboxclass::addsprite(int x, int y, int tile, int col)
@ -42,6 +44,11 @@ void textboxclass::addsprite(int x, int y, int tile, int col)
sprites.push_back(sprite); sprites.push_back(sprite);
} }
void textboxclass::setimage(TextboxImage new_image)
{
image = new_image;
}
void textboxclass::centerx(void) void textboxclass::centerx(void)
{ {
resize(); resize();

View file

@ -13,6 +13,13 @@ struct TextboxSprite
int tile; int tile;
}; };
enum TextboxImage
{
TEXTIMAGE_NONE,
TEXTIMAGE_LEVELCOMPLETE,
TEXTIMAGE_GAMECOMPLETE
};
class textboxclass class textboxclass
{ {
public: public:
@ -20,6 +27,8 @@ public:
void addsprite(int x, int y, int tile, int col); void addsprite(int x, int y, int tile, int col);
void setimage(TextboxImage image);
void centerx(void); void centerx(void);
void centery(void); void centery(void);
@ -65,6 +74,7 @@ public:
bool fill_buttons; bool fill_buttons;
std::vector<TextboxSprite> sprites; std::vector<TextboxSprite> sprites;
TextboxImage image;
}; };
#endif /* TEXTBOX_H */ #endif /* TEXTBOX_H */