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

Initial implementation of textbox sprites

This commit adds a system for displaying sprites in textboxes, meant to
replace the hardcoded system in the main game. This does not support
levelcomplete.png and gamecomplete.png yet, which will most likely just
be special cases.
This commit is contained in:
AllyTally 2023-08-05 19:34:15 -03:00 committed by Misa Elizabeth Kai
parent 187fd85e14
commit 76ea4488af
6 changed files with 67 additions and 1 deletions

View file

@ -1049,6 +1049,17 @@ void Graphics::drawgui(void)
//blue guy //blue guy
draw_sprite(crew_xp, crew_yp, crew_sprite, 75, 75, 255 - help.glow / 4 - textboxes[i].rand); draw_sprite(crew_xp, crew_yp, crew_sprite, 75, 75, 255 - help.glow / 4 - textboxes[i].rand);
} }
for (int index = 0; index < (int) textboxes[i].sprites.size(); index++)
{
TextboxSprite* sprite = &textboxes[i].sprites[index];
draw_sprite(
sprite->x + textboxes[i].xp,
sprite->y + textboxes[i].yp,
sprite->tile,
getcol(sprite->col)
);
}
} }
} }
@ -1428,6 +1439,17 @@ void Graphics::textboxtimer(int t)
textboxes[m].timer = t; textboxes[m].timer = t;
} }
void Graphics::addsprite(int x, int y, int tile, int col)
{
if (!INBOUNDS_VEC(m, textboxes))
{
vlog_error("addsprite() out-of-bounds!");
return;
}
textboxes[m].addsprite(x, y, tile, col);
}
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

@ -122,6 +122,8 @@ public:
void textboxtimer(int t); void textboxtimer(int t);
void addsprite(int x, int y, int tile, int col);
void textboxremove(void); void textboxremove(void);
void textboxremovefast(void); void textboxremovefast(void);

View file

@ -53,6 +53,7 @@ scriptclass::scriptclass(void)
textcase = 1; textcase = 1;
textbuttons = false; textbuttons = false;
textlarge = false; textlarge = false;
textbox_sprites.clear();
} }
void scriptclass::add_default_colours(void) void scriptclass::add_default_colours(void)
@ -528,6 +529,7 @@ void scriptclass::run(void)
textpad_right = 0; textpad_right = 0;
textpadtowidth = 0; textpadtowidth = 0;
textboxtimer = 0; textboxtimer = 0;
textbox_sprites.clear();
translate_dialogue(); translate_dialogue();
} }
@ -698,6 +700,15 @@ void scriptclass::run(void)
{ {
textboxtimer = ss_toi(words[1]); textboxtimer = ss_toi(words[1]);
} }
else if (words[0] == "textsprite")
{
TextboxSprite sprite;
sprite.x = ss_toi(words[1]);
sprite.y = ss_toi(words[2]);
sprite.tile = ss_toi(words[3]);
sprite.col = ss_toi(words[4]);
textbox_sprites.push_back(sprite);
}
else if (words[0] == "flipme") else if (words[0] == "flipme")
{ {
textflipme = !textflipme; textflipme = !textflipme;
@ -729,6 +740,11 @@ void scriptclass::run(void)
graphics.textboxtimer(textboxtimer); graphics.textboxtimer(textboxtimer);
} }
for (size_t i = 0; i < textbox_sprites.size(); i++)
{
graphics.addsprite(textbox_sprites[i].x, textbox_sprites[i].y, textbox_sprites[i].tile, textbox_sprites[i].col);
}
// Some textbox formatting that can be set by translations... // Some textbox formatting that can be set by translations...
if (textcentertext) if (textcentertext)
{ {

View file

@ -2,10 +2,11 @@
#define SCRIPT_H #define SCRIPT_H
#include <map> #include <map>
#include <SDL.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include <SDL.h> #include "Textbox.h"
#define filllines(lines) commands.insert(commands.end(), lines, lines + SDL_arraysize(lines)) #define filllines(lines) commands.insert(commands.end(), lines, lines + SDL_arraysize(lines))
@ -123,6 +124,7 @@ public:
bool textbuttons; bool textbuttons;
bool textlarge; bool textlarge;
int textboxtimer; int textboxtimer;
std::vector<TextboxSprite> textbox_sprites;
//Misc //Misc
int i, j, k; int i, j, k;

View file

@ -28,6 +28,18 @@ textboxclass::textboxclass(void)
print_flags = PR_FONT_LEVEL; print_flags = PR_FONT_LEVEL;
fill_buttons = false; fill_buttons = false;
sprites.clear();
}
void textboxclass::addsprite(int x, int y, int tile, int col)
{
TextboxSprite sprite;
sprite.x = x;
sprite.y = y;
sprite.tile = tile;
sprite.col = col;
sprites.push_back(sprite);
} }
void textboxclass::centerx(void) void textboxclass::centerx(void)

View file

@ -5,11 +5,21 @@
#include <string> #include <string>
#include <vector> #include <vector>
struct TextboxSprite
{
int x;
int y;
int col;
int tile;
};
class textboxclass class textboxclass
{ {
public: public:
textboxclass(void); textboxclass(void);
void addsprite(int x, int y, int tile, int col);
void centerx(void); void centerx(void);
void centery(void); void centery(void);
@ -53,6 +63,8 @@ public:
uint32_t print_flags; uint32_t print_flags;
bool fill_buttons; bool fill_buttons;
std::vector<TextboxSprite> sprites;
}; };
#endif /* TEXTBOX_H */ #endif /* TEXTBOX_H */