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

Add textoutline(on/off/default)

This commit adds a new scripting command for textbox visual control,
where you're able to force the transparent textbox's outline on or off.
This commit is contained in:
NyakoFox 2024-11-03 16:07:55 -04:00 committed by Misa Elizabeth Kai
parent 45e60fa69c
commit 98a0931225
6 changed files with 60 additions and 7 deletions

View file

@ -929,13 +929,20 @@ void Graphics::drawgui(void)
size_t j; size_t j;
for (j = 0; j < textboxes[i].lines.size(); j++) for (j = 0; j < textboxes[i].lines.size(); j++)
{ {
font::print( const int x = text_xp;
print_flags | PR_BOR, const int y = yp + text_yoff + text_sign * (j * (font_height + textboxes[i].linegap));
text_xp, if (!textboxes[i].force_outline)
yp + text_yoff + text_sign * (j * (font_height + textboxes[i].linegap)), {
textbox_line(buffer, sizeof(buffer), i, j), font::print(print_flags | PR_BOR, x, y, textbox_line(buffer, sizeof(buffer), i, j), 0, 0, 0);
0, 0, 0 }
); else if (textboxes[i].outline)
{
// We're forcing an outline, so we'll have to draw it ourselves instead of relying on PR_BOR.
font::print(print_flags, x - 1, y, textbox_line(buffer, sizeof(buffer), i, j), 0, 0, 0);
font::print(print_flags, x + 1, y, textbox_line(buffer, sizeof(buffer), i, j), 0, 0, 0);
font::print(print_flags, x, y - 1, textbox_line(buffer, sizeof(buffer), i, j), 0, 0, 0);
font::print(print_flags, x, y + 1, textbox_line(buffer, sizeof(buffer), i, j), 0, 0, 0);
}
} }
for (j = 0; j < textboxes[i].lines.size(); j++) for (j = 0; j < textboxes[i].lines.size(); j++)
{ {
@ -1483,6 +1490,18 @@ void Graphics::setimage(TextboxImage image)
textboxes[m].setimage(image); textboxes[m].setimage(image);
} }
void Graphics::textboxoutline(bool enabled)
{
if (!INBOUNDS_VEC(m, textboxes))
{
vlog_error("textboxoutline() out-of-bounds!");
return;
}
textboxes[m].force_outline = true;
textboxes[m].outline = enabled;
}
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

@ -137,6 +137,8 @@ public:
void setimage(TextboxImage image); void setimage(TextboxImage image);
void textboxoutline(bool enabled);
void textboxindex(int index); void textboxindex(int index);
void textboxremove(void); void textboxremove(void);

View file

@ -568,6 +568,8 @@ void scriptclass::run(void)
textbox_sprites.clear(); textbox_sprites.clear();
textbox_image = TEXTIMAGE_NONE; textbox_image = TEXTIMAGE_NONE;
textbox_forcepos = false; textbox_forcepos = false;
textbox_force_outline = false;
textbox_outline = false;
} }
else if (words[0] == "position") else if (words[0] == "position")
{ {
@ -746,6 +748,23 @@ void scriptclass::run(void)
textbox_image = TEXTIMAGE_NONE; textbox_image = TEXTIMAGE_NONE;
} }
} }
else if (words[0] == "textoutline")
{
if (words[1] == "default")
{
textbox_force_outline = false;
}
else if (words[1] == "on")
{
textbox_force_outline = true;
textbox_outline = true;
}
else if (words[1] == "off")
{
textbox_force_outline = true;
textbox_outline = false;
}
}
else if (words[0] == "flipme") else if (words[0] == "flipme")
{ {
textflipme = !textflipme; textflipme = !textflipme;
@ -803,6 +822,11 @@ void scriptclass::run(void)
} }
} }
if (textbox_force_outline)
{
graphics.textboxoutline(textbox_outline);
}
TextboxOriginalContext context = TextboxOriginalContext(); TextboxOriginalContext context = TextboxOriginalContext();
context.text_case = textcase; context.text_case = textcase;
context.lines = std::vector<std::string>(txt); context.lines = std::vector<std::string>(txt);

View file

@ -123,6 +123,8 @@ public:
std::vector<TextboxSprite> textbox_sprites; std::vector<TextboxSprite> textbox_sprites;
TextboxImage textbox_image; TextboxImage textbox_image;
bool textbox_forcepos; bool textbox_forcepos;
bool textbox_force_outline;
bool textbox_outline;
//Misc //Misc
int i, j, k; int i, j, k;

View file

@ -43,6 +43,9 @@ textboxclass::textboxclass(int gap)
image = TEXTIMAGE_NONE; image = TEXTIMAGE_NONE;
force_outline = false;
outline = false;
crewmate_position = TextboxCrewmatePosition(); crewmate_position = TextboxCrewmatePosition();
original = TextboxOriginalContext(); original = TextboxOriginalContext();
original.text_case = 1; original.text_case = 1;

View file

@ -137,6 +137,9 @@ public:
std::vector<TextboxSprite> sprites; std::vector<TextboxSprite> sprites;
TextboxImage image; TextboxImage image;
bool force_outline;
bool outline;
TextboxCrewmatePosition crewmate_position; TextboxCrewmatePosition crewmate_position;
TextboxOriginalContext original; TextboxOriginalContext original;
TextboxSpacing spacing; TextboxSpacing spacing;