Skip to content

Commit

Permalink
Add textimage for levelcomplete and gamecomplete
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
AllyTally authored and InfoTeddy committed Nov 19, 2023
1 parent b5c9508 commit 103b4d3
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 4 deletions.
6 changes: 4 additions & 2 deletions desktop_version/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
{
Expand Down
15 changes: 13 additions & 2 deletions desktop_version/src/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!";
Expand Down Expand Up @@ -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!";
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions desktop_version/src/Graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class Graphics

void addsprite(int x, int y, int tile, int col);

void setimage(TextboxImage image);

void textboxremove(void);

void textboxremovefast(void);
Expand Down
19 changes: 19 additions & 0 deletions desktop_version/src/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ scriptclass::scriptclass(void)
textbuttons = false;
textlarge = false;
textbox_sprites.clear();
textbox_image = TEXTIMAGE_NONE;
}

void scriptclass::add_default_colours(void)
Expand Down Expand Up @@ -530,6 +531,7 @@ void scriptclass::run(void)
textpadtowidth = 0;
textboxtimer = 0;
textbox_sprites.clear();
textbox_image = TEXTIMAGE_NONE;

translate_dialogue();
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions desktop_version/src/Script.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class scriptclass
bool textlarge;
int textboxtimer;
std::vector<TextboxSprite> textbox_sprites;
TextboxImage textbox_image;

//Misc
int i, j, k;
Expand Down
7 changes: 7 additions & 0 deletions desktop_version/src/Textbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions desktop_version/src/Textbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ struct TextboxSprite
int tile;
};

enum TextboxImage
{
TEXTIMAGE_NONE,
TEXTIMAGE_LEVELCOMPLETE,
TEXTIMAGE_GAMECOMPLETE
};

class textboxclass
{
public:
textboxclass(void);

void addsprite(int x, int y, int tile, int col);

void setimage(TextboxImage image);

void centerx(void);

void centery(void);
Expand Down Expand Up @@ -65,6 +74,7 @@ class textboxclass
bool fill_buttons;

std::vector<TextboxSprite> sprites;
TextboxImage image;
};

#endif /* TEXTBOX_H */

0 comments on commit 103b4d3

Please sign in to comment.