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)
{
graphics.createtextboxflipme("", -1, 12, 165, 165, 255);
graphics.createtextboxflipme("", -1, 12, TEXT_COLOUR("cyan"));
graphics.addline(" ");
graphics.addline("");
graphics.addline("");
graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
graphics.setimage(TEXTIMAGE_LEVELCOMPLETE);
}
void Game::crewmate_textbox(const int color)
@ -2861,12 +2862,13 @@ void Game::updatestate(void)
setstatedelay(75);
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.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
graphics.setimage(TEXTIMAGE_GAMECOMPLETE);
break;
case 3502:
{

View File

@ -944,7 +944,7 @@ void Graphics::drawgui(void)
continue;
}
if (textboxes[i].yp == 12 && textboxes[i].r == 165)
if (textboxes[i].image == TEXTIMAGE_LEVELCOMPLETE)
{
// 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
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);
}
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 )
{
if (!INBOUNDS_VEC(m, textboxes))

View File

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

View File

@ -54,6 +54,7 @@ scriptclass::scriptclass(void)
textbuttons = false;
textlarge = false;
textbox_sprites.clear();
textbox_image = TEXTIMAGE_NONE;
}
void scriptclass::add_default_colours(void)
@ -530,6 +531,7 @@ void scriptclass::run(void)
textpadtowidth = 0;
textboxtimer = 0;
textbox_sprites.clear();
textbox_image = TEXTIMAGE_NONE;
translate_dialogue();
}
@ -709,6 +711,21 @@ void scriptclass::run(void)
sprite.col = ss_toi(words[4]);
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")
{
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.setimage(textbox_image);
// Some textbox formatting that can be set by translations...
if (textcentertext)
{

View File

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

View File

@ -30,6 +30,8 @@ textboxclass::textboxclass(void)
fill_buttons = false;
sprites.clear();
image = TEXTIMAGE_NONE;
}
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);
}
void textboxclass::setimage(TextboxImage new_image)
{
image = new_image;
}
void textboxclass::centerx(void)
{
resize();

View File

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