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;
for (j = 0; j < textboxes[i].lines.size(); j++)
{
font::print(
print_flags | PR_BOR,
text_xp,
yp + text_yoff + text_sign * (j * (font_height + textboxes[i].linegap)),
textbox_line(buffer, sizeof(buffer), i, j),
0, 0, 0
);
const int x = text_xp;
const int y = yp + text_yoff + text_sign * (j * (font_height + textboxes[i].linegap));
if (!textboxes[i].force_outline)
{
font::print(print_flags | PR_BOR, x, y, textbox_line(buffer, sizeof(buffer), i, j), 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++)
{
@@ -1483,6 +1490,18 @@ void Graphics::setimage(TextboxImage 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 )
{
if (!INBOUNDS_VEC(m, textboxes))