Migrate more prints to font::, determine font for most textboxes

Some textboxes need to be in the level font (like room names, cutscene
dialogue, etc - even in the main game), and some need to be in the
interface font (like when you collect a shiny trinket or crewmate). So
most of these textboxes now have graphics.textboxprintflags(font_flag)
as appropriate.

RoomnameTranslator.cpp is now also migrated to the new print system -
in room name translator mode, the room name is now displayed in the 8x8
font if it's untranslated and the level font if it is.
This commit is contained in:
Dav999-v 2023-01-13 05:11:39 +01:00 committed by Misa Elizabeth Kai
parent 6ca83114bc
commit 48a4e19635
11 changed files with 157 additions and 56 deletions

View File

@ -430,9 +430,9 @@ static void editormenurender(int tr, int tg, int tb)
}
case Menu::ed_music:
{
graphics.bigprint( -1, 65, loc::gettext("Map Music"), tr, tg, tb, true);
font::print(PR_2X | PR_CEN | PR_CJK_HIGH, -1, 65, loc::gettext("Map Music"), tr, tg, tb);
graphics.PrintWrap( -1, 85, loc::gettext("Current map music:"), tr, tg, tb, true);
font::print_wrap(PR_CEN | PR_CJK_LOW, -1, 85, loc::gettext("Current map music:"), tr, tg, tb);
const char* songname;
switch(cl.levmusic)
{
@ -1219,13 +1219,13 @@ void editorrender(void)
{
if(i+ed.pagey<(int)ed.sb.size())
{
font::print(PR_FONT_LEVEL, 16, 20+(i*font_height), ed.sb[i+ed.pagey], 123, 111, 218);
font::print(PR_FONT_LEVEL | PR_CJK_LOW, 16, 20+(i*font_height), ed.sb[i+ed.pagey], 123, 111, 218);
}
}
//Draw cursor
if(ed.entframe<2)
{
font::print(PR_FONT_LEVEL, 16+font::len(PR_FONT_LEVEL, ed.sb[ed.pagey+ed.sby]),20+(ed.sby*font_height),"_",123, 111, 218);
font::print(PR_FONT_LEVEL | PR_CJK_LOW, 16+font::len(PR_FONT_LEVEL, ed.sb[ed.pagey+ed.sby]),20+(ed.sby*font_height),"_",123, 111, 218);
}
break;
}

View File

@ -400,6 +400,9 @@ void load_main(void)
load_font_filename(false, item);
}
FILESYSTEM_freeEnumerate(&handle);
//font_idx_interface = 1; // TODO TEMP
//font_idx_custom = 1;
}
void load_custom(void)
@ -717,6 +720,10 @@ static Font* container_get(FontContainer* container, size_t idx)
{
return &fonts_main.fonts[0];
}
if (fonts_custom.count > 0)
{
return &fonts_custom.fonts[0];
}
return NULL;
}
@ -857,7 +864,7 @@ void print(
}
}
int h_diff_8 = pf.font_sel->glyph_h-8;
int h_diff_8 = (pf.font_sel->glyph_h-8)*pf.scale;
if (h_diff_8 < 0)
{
/* If the font is less high than 8,

View File

@ -662,6 +662,7 @@ void Game::levelcomplete_textbox(void)
graphics.addline(" ");
graphics.addline("");
graphics.addline("");
graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
}
@ -672,7 +673,7 @@ void Game::crewmate_textbox(const int r, const int g, const int b)
/* This is a special case for wrapping, we MUST have two lines.
* So just make sure it can't fit in one line. */
const char* text = loc::gettext("You have rescued a crew member!");
std::string wrapped = font::string_wordwrap_balanced(text, graphics.len(text)-1);
std::string wrapped = font::string_wordwrap_balanced(text, font::len(PR_FONT_INTERFACE, text)-1);
size_t startline = 0;
size_t newline;
@ -685,6 +686,7 @@ void Game::crewmate_textbox(const int r, const int g, const int b)
} while (newline != std::string::npos);
graphics.addline("");
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxcentertext();
graphics.textboxpad(5, 2);
graphics.textboxcenterx();
@ -704,6 +706,7 @@ void Game::remaining_textbox(void)
}
graphics.createtextboxflipme(buffer, -1, 128 + 16, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxpad(2, 2);
graphics.textboxcenterx();
}
@ -711,6 +714,7 @@ void Game::remaining_textbox(void)
void Game::actionprompt_textbox(void)
{
graphics.createtextboxflipme(loc::gettext("Press ACTION to continue"), -1, 196, 164, 164, 255);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxpad(1, 1);
graphics.textboxcenterx();
}
@ -725,6 +729,7 @@ void Game::savetele_textbox(void)
if (savetele())
{
graphics.createtextboxflipme(loc::gettext("Game Saved"), -1, 12, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxpad(3, 3);
graphics.textboxcenterx();
graphics.textboxtimer(25);
@ -732,6 +737,7 @@ void Game::savetele_textbox(void)
else
{
graphics.createtextboxflipme(loc::gettext("ERROR: Could not save game!"), -1, 12, 255, 60, 60);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(2);
graphics.textboxpad(1, 1);
graphics.textboxcenterx();
@ -814,11 +820,13 @@ void Game::updatestate(void)
setstate(3);
graphics.createtextbox("To do: write quick", 50, 80, 164, 164, 255);
graphics.addline("intro to story!");
graphics.textboxprintflags(PR_FONT_8X8);
//Oh no! what happen to rest of crew etc crash into dimension
break;
case 4:
//End of opening cutscene for now
graphics.createtextbox(loc::gettext("Press arrow keys or WASD to move"), -1, 195, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(4);
graphics.textboxcentertext();
graphics.textboxpad(2, 2);
@ -850,6 +858,7 @@ void Game::updatestate(void)
{
obj.flags[13] = true;
graphics.createtextbox(loc::gettext("Press ENTER to view map and quicksave"), -1, 155, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(4);
graphics.textboxcentertext();
graphics.textboxpad(2, 2);
@ -942,6 +951,7 @@ void Game::updatestate(void)
floorceiling, crewmate
);
graphics.createtextbox(loc::gettext(english), -1, 3, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(2);
graphics.textboxpadtowidth(36*8);
graphics.textboxcenterx();
@ -971,6 +981,7 @@ void Game::updatestate(void)
english = "You can't continue to the next room until they are safely across.";
}
graphics.createtextbox(loc::gettext(english), -1, 3, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(2);
graphics.textboxpadtowidth(36*8);
graphics.textboxcenterx();
@ -1013,6 +1024,7 @@ void Game::updatestate(void)
floorceiling, crewmate
);
graphics.createtextbox(loc::gettext(english), -1, 3, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(2);
graphics.textboxpadtowidth(36*8);
graphics.textboxcenterx();
@ -1049,6 +1061,7 @@ void Game::updatestate(void)
//Arrow key tutorial
obj.removetrigger(17);
graphics.createtextbox(loc::gettext("If you prefer, you can press UP or DOWN instead of ACTION to flip."), -1, 187, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(2);
graphics.textboxcentertext();
graphics.textboxpad(1, 1);
@ -1082,6 +1095,7 @@ void Game::updatestate(void)
obj.flags[3] = true;
setstate(0);
graphics.createtextbox(loc::gettext("Press ACTION to flip"), -1, 25, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(4);
graphics.textboxcentertext();
graphics.textboxpad(2, 2);
@ -1693,12 +1707,14 @@ void Game::updatestate(void)
hascontrol = false;
graphics.createtextbox("Captain! I've been so worried!", 60, 90, 164, 255, 164);
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(12);
}
break;
case 104:
graphics.createtextbox("I'm glad you're ok!", 135, 152, 164, 164, 255);
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(11);
graphics.textboxactive();
@ -1708,6 +1724,7 @@ void Game::updatestate(void)
graphics.createtextbox("I've been trying to find a", 74, 70, 164, 255, 164);
graphics.addline("way out, but I keep going");
graphics.addline("around in circles...");
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(2);
graphics.textboxactive();
@ -1722,6 +1739,7 @@ void Game::updatestate(void)
case 108:
graphics.createtextbox("Don't worry! I have a", 125, 152, 164, 164, 255);
graphics.addline("teleporter key!");
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(11);
graphics.textboxactive();
@ -1736,6 +1754,7 @@ void Game::updatestate(void)
obj.entities[i].state = 1;
}
graphics.createtextbox("Follow me!", 185, 154, 164, 164, 255);
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(11);
graphics.textboxactive();
@ -1763,6 +1782,7 @@ void Game::updatestate(void)
graphics.createtextbox("Sorry Eurogamers! Teleporting around", 60 - 20, 200, 255, 64, 64);
graphics.addline("the map doesn't work in this version!");
graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
incstate();
break;
@ -1816,6 +1836,7 @@ void Game::updatestate(void)
hascontrol = false;
graphics.createtextbox("Captain! You're ok!", 60-10, 90-40, 255, 255, 134);
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(14);
break;
@ -1824,6 +1845,7 @@ void Game::updatestate(void)
{
graphics.createtextbox("I've found a teleporter, but", 60-20, 90 - 40, 255, 255, 134);
graphics.addline("I can't get it to go anywhere...");
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(2);
graphics.textboxactive();
@ -1831,6 +1853,7 @@ void Game::updatestate(void)
}
case 126:
graphics.createtextbox("I can help with that!", 125, 152-40, 164, 164, 255);
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(11);
graphics.textboxactive();
@ -1838,6 +1861,7 @@ void Game::updatestate(void)
case 128:
graphics.createtextbox("I have the teleporter", 130, 152-35, 164, 164, 255);
graphics.addline("codex for our ship!");
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(11);
graphics.textboxactive();
@ -1846,6 +1870,7 @@ void Game::updatestate(void)
case 130:
{
graphics.createtextbox("Yey! Let's go home!", 60-30, 90-35, 255, 255, 134);
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(14);
graphics.textboxactive();
@ -1944,6 +1969,7 @@ void Game::updatestate(void)
advancetext = true;
incstate();
graphics.createtextboxflipme(loc::gettext("Congratulations!\n\nYou have found a shiny trinket!"), 50, 85, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
int h = graphics.textboxwrap(2);
graphics.textboxcentertext();
graphics.textboxpad(1, 1);
@ -1970,6 +1996,7 @@ void Game::updatestate(void)
trinkets(), max_trinkets
);
graphics.createtextboxflipme(buffer, 50, 95+h, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(2);
graphics.textboxcentertext();
graphics.textboxpad(1, 1);
@ -2010,6 +2037,7 @@ void Game::updatestate(void)
advancetext = true;
incstate();
graphics.createtextboxflipme(loc::gettext("Congratulations!\n\nYou have found a lost crewmate!"), 50, 85, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
int h = graphics.textboxwrap(2);
graphics.textboxcentertext();
graphics.textboxpad(1, 1);
@ -2030,6 +2058,7 @@ void Game::updatestate(void)
);
graphics.createtextboxflipme(buffer, 50, 95+h, 174, 174, 174);
}
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(4);
graphics.textboxcentertext();
graphics.textboxpad(2, 2);
@ -2236,6 +2265,7 @@ void Game::updatestate(void)
advancetext = true;
hascontrol = false;
graphics.createtextbox("Hello?", 125+24, 152-20, 164, 164, 255);
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(11);
graphics.textboxactive();
@ -2244,6 +2274,7 @@ void Game::updatestate(void)
advancetext = true;
hascontrol = false;
graphics.createtextbox("Is anyone there?", 125+8, 152-24, 164, 164, 255);
graphics.textboxprintflags(PR_FONT_8X8);
incstate();
music.playef(11);
graphics.textboxactive();
@ -2775,6 +2806,7 @@ void Game::updatestate(void)
graphics.addline(" ");
graphics.addline("");
graphics.addline("");
graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
break;
case 3502:
@ -2783,6 +2815,7 @@ void Game::updatestate(void)
setstatedelay(45+15);
graphics.createtextboxflipme(loc::gettext("All Crew Members Rescued!"), -1, 64, 0, 0, 0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
char buffer[SCREEN_WIDTH_CHARS + 1];
timestringcenti(buffer, sizeof(buffer));
savetime = buffer;
@ -2801,7 +2834,9 @@ void Game::updatestate(void)
trinkets()
);
graphics.createtextboxflipme(label, 168-graphics.len(label), 84, 0,0,0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.createtextboxflipme(buffer, 180, 84, 0, 0, 0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
break;
}
case 3504:
@ -2812,7 +2847,9 @@ void Game::updatestate(void)
const char* label = loc::gettext("Game Time:");
std::string tempstring = savetime;
graphics.createtextboxflipme(label, 168-graphics.len(label), 96, 0,0,0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.createtextboxflipme(tempstring, 180, 96, 0, 0, 0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
break;
}
case 3505:
@ -2822,7 +2859,9 @@ void Game::updatestate(void)
const char* label = loc::gettext("Total Flips:");
graphics.createtextboxflipme(label, 168-graphics.len(label), 123, 0,0,0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.createtextboxflipme(help.String(totalflips), 180, 123, 0, 0, 0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
break;
}
case 3506:
@ -2832,7 +2871,9 @@ void Game::updatestate(void)
const char* label = loc::gettext("Total Deaths:");
graphics.createtextboxflipme(label, 168-graphics.len(label), 135, 0,0,0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.createtextboxflipme(help.String(deathcounts), 180, 135, 0, 0, 0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
break;
}
case 3507:
@ -2849,7 +2890,9 @@ void Game::updatestate(void)
hardestroomdeaths
);
graphics.createtextboxflipme(buffer, -1, 158, 0,0,0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.createtextboxflipme(hardestroom, -1, 170, 0, 0, 0);
graphics.textboxprintflags(PR_FONT_INTERFACE);
break;
}
case 3508:

View File

@ -842,9 +842,10 @@ void Graphics::drawgui(void)
int text_yoff;
int yp;
bool opaque;
int font_height = font::height(textboxes[i].print_flags);
if (flipmode)
{
text_yoff = textboxes[i].lines.size() * 8;
text_yoff = 8 + (textboxes[i].lines.size() - 1) * font_height;
}
else
{
@ -854,7 +855,7 @@ void Graphics::drawgui(void)
yp = textboxes[i].yp;
if (flipmode && textboxes[i].flipme)
{
yp = SCREEN_HEIGHT_PIXELS - yp - 8 * (textboxes[i].lines.size() + 2);
yp = SCREEN_HEIGHT_PIXELS - yp - 16 - textboxes[i].lines.size() * font_height;
}
if (textboxes[i].r == 0 && textboxes[i].g == 0 && textboxes[i].b == 0)
@ -878,9 +879,9 @@ void Graphics::drawgui(void)
for (j = 0; j < textboxes[i].lines.size(); j++)
{
font::print(
PR_COLORGLYPH_BRI(tl_lerp*255) | PR_CJK_LOW,
textboxes[i].print_flags | PR_COLORGLYPH_BRI(tl_lerp*255) | PR_CJK_LOW,
textboxes[i].xp + 8,
yp + text_yoff + text_sign * (j * font::height(PR_FONT_LEVEL)),
yp + text_yoff + text_sign * (j * font_height),
textboxes[i].lines[j],
r, g, b
);
@ -1422,8 +1423,7 @@ void Graphics::createtextboxreal(
textboxclass text;
text.lines.push_back(t);
text.xp = xp;
int length = utf8::unchecked::distance(t.begin(), t.end());
if (xp == -1) text.xp = 160 - (((length / 2) + 1) * 8);
if (xp == -1) text.xp = 160 - ((font::len(PR_FONT_LEVEL, t) / 2) + 8);
text.yp = yp;
text.initcol(r, g, b);
text.flipme = flipme;
@ -3172,6 +3172,18 @@ void Graphics::textboxcentertext()
textboxes[m].centertext();
}
void Graphics::textboxprintflags(const uint32_t flags)
{
if (!INBOUNDS_VEC(m, textboxes))
{
vlog_error("textboxprintflags() out-of-bounds!");
return;
}
textboxes[m].print_flags = flags;
textboxes[m].resize();
}
void Graphics::textboxcommsrelay()
{
/* Special treatment for the gamestate textboxes in Comms Relay */
@ -3180,6 +3192,7 @@ void Graphics::textboxcommsrelay()
vlog_error("textboxcommsrelay() out-of-bounds!");
return;
}
textboxprintflags(PR_FONT_INTERFACE);
textboxwrap(11);
textboxes[m].xp = 224 - textboxes[m].w;
}
@ -3480,9 +3493,9 @@ SDL_Color Graphics::crewcolourreal(int t)
return col_crewcyan;
}
void Graphics::render_roomname(const char* roomname, int r, int g, int b)
void Graphics::render_roomname(uint32_t font_flag, const char* roomname, int r, int g, int b)
{
int font_height = font::height(PR_FONT_LEVEL);
int font_height = font::height(font_flag);
if (font_height <= 8)
{
footerrect.h = font_height + 2;
@ -3495,6 +3508,6 @@ void Graphics::render_roomname(const char* roomname, int r, int g, int b)
set_blendmode(SDL_BLENDMODE_BLEND);
fill_rect(&footerrect, getRGBA(0, 0, 0, translucentroomname ? 127 : 255));
font::print(PR_CEN | PR_BOR | PR_FONT_LEVEL | PR_CJK_LOW, -1, footerrect.y+1, roomname, r, g, b);
font::print(font_flag | PR_CEN | PR_BOR | PR_CJK_LOW, -1, footerrect.y+1, roomname, r, g, b);
set_blendmode(SDL_BLENDMODE_NONE);
}

View File

@ -109,6 +109,8 @@ public:
void textboxcentertext();
void textboxprintflags(uint32_t flags);
void textboxcommsrelay();
void textboxadjust(void);
@ -404,7 +406,7 @@ public:
SDL_Color crewcolourreal(int t);
void render_roomname(const char* roomname, int r, int g, int b);
void render_roomname(uint32_t font_flag, const char* roomname, int r, int g, int b);
char error[128];
char error_title[128]; /* for SDL_ShowSimpleMessageBox */

View File

@ -1915,11 +1915,13 @@ void gamerender(void)
}
bool force_roomname_hidden = false;
bool roomname_untranslated = false;
int roomname_r = 196, roomname_g = 196, roomname_b = 255 - help.glow;
if (roomname_translator::enabled)
{
roomname_translator::overlay_render(
&force_roomname_hidden,
&roomname_untranslated,
&roomname_r, &roomname_g, &roomname_b
);
}
@ -1937,7 +1939,11 @@ void gamerender(void)
roomname = loc::gettext_roomname(map.custommode, game.roomx, game.roomy, map.roomname, map.roomname_special);
}
graphics.render_roomname(roomname, roomname_r, roomname_g, roomname_b);
graphics.render_roomname(
roomname_untranslated ? PR_FONT_8X8 : PR_FONT_LEVEL,
roomname,
roomname_r, roomname_g, roomname_b
);
}
if (map.roomtexton)
@ -2091,8 +2097,8 @@ void gamerender(void)
y1 = 10;
y2 = 30;
}
graphics.bigbprint( -1, y1, loc::gettext("Survive for"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2);
graphics.bigbprint( -1, y2, loc::gettext("60 seconds!"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2);
font::print(PR_2X | PR_CEN | PR_BOR | PR_CJK_HIGH, -1, y1, loc::gettext("Survive for"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
font::print(PR_2X | PR_CEN | PR_BOR, -1, y2, loc::gettext("60 seconds!"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
}
}
else if(game.swngame==7)

View File

@ -1,6 +1,7 @@
#include "RoomnameTranslator.h"
#include "Constants.h"
#include "Font.h"
#include "Game.h"
#include "Graphics.h"
#include "GraphicsUtil.h"
@ -44,10 +45,10 @@ namespace roomname_translator
{
use_explanation = "[no explanation]";
}
graphics.PrintWrap(0, 10, use_explanation, 0,192,255, false, 8, 320);
font::print_wrap(PR_BOR | PR_FONT_8X8, 0, 10, use_explanation, 0,192,255, 8, 320);
}
void overlay_render(bool* force_roomname_hidden, int* roomname_r, int* roomname_g, int* roomname_b)
void overlay_render(bool* force_roomname_hidden, bool* roomname_untranslated, int* roomname_r, int* roomname_g, int* roomname_b)
{
if (edit_mode || help_screen)
{
@ -60,59 +61,69 @@ namespace roomname_translator
graphics.set_blendmode(SDL_BLENDMODE_NONE);
if (help_screen)
{
graphics.bprint(0, 0, "=== Room name translation mode help ===", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 0, "=== Room name translation mode help ===", 255,255,255);
if (expl_mode)
{
graphics.bprint(0, 20, "You can currently access EXPL mode to", 255,255,255);
graphics.bprint(0, 30, "set explanations for room names.", 255,255,255);
graphics.bprint(0, 40, "(Use Ctrl+E to switch to NAME mode.)", 255,255,255);
font::print_wrap(
PR_BOR | PR_FONT_8X8,
0, 20,
"You can currently access EXPL mode to\n"
"set explanations for room names.\n"
"(Use Ctrl+E to switch to NAME mode.)",
255,255,255
);
const char* first_part = "Unexplained room names are ";
graphics.bprint(0, 60, first_part, 255,255,255);
graphics.bprint(graphics.len(first_part), 60, "cyan.", 64, 255, 255-help.glow);
font::print(PR_BOR | PR_FONT_8X8, 0, 60, first_part, 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, graphics.len(first_part), 60, "cyan.", 64, 255, 255-help.glow);
}
else
{
graphics.bprint(0, 20, "You can currently access NAME mode to", 255,255,255);
graphics.bprint(0, 30, "translate room names.", 255,255,255);
graphics.bprint(0, 40, "(Use Ctrl+E to switch to EXPL mode.)", 255,255,255);
font::print_wrap(
PR_BOR | PR_FONT_8X8,
0, 20,
"You can currently access NAME mode to\n"
"translate room names.\n"
"(Use Ctrl+E to switch to EXPL mode.)",
255,255,255
);
const char* first_part = "English room names are ";
graphics.bprint(0, 60, first_part, 255,255,255);
graphics.bprint(graphics.len(first_part), 60, "cyan.", 0, 192, 255-help.glow);
font::print(PR_BOR | PR_FONT_8X8, 0, 60, first_part, 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, graphics.len(first_part), 60, "cyan.", 0, 192, 255-help.glow);
}
graphics.bprint(0, 80, "KEYS:", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 80, "KEYS:", 255,255,255);
if (expl_mode)
{
graphics.bprint(0, 90, "Tab - switch between play/expl modes", 255,255,255);
graphics.bprint(0, 100, "E/Enter - set room name explanation", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 90, "Tab - switch between play/expl modes", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 100, "E/Enter - set room name explanation", 255,255,255);
}
else
{
graphics.bprint(0, 90, "Tab - switch between play/name modes", 255,255,255);
graphics.bprint(0, 100, "E/Enter - set room name translation", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 90, "Tab - switch between play/name modes", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 100, "E/Enter - set room name translation", 255,255,255);
}
graphics.bprint(0, 110, "I - toggle invincibility", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 110, "I - toggle invincibility", 255,255,255);
if (expl_mode)
{
graphics.bprint(0, 120, ". - set blank explanation", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 120, ". - set blank explanation", 255,255,255);
}
*force_roomname_hidden = true;
return;
}
else if (expl_mode)
{
graphics.bprint(0, 0, "Expl mode [TAB]", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 0, "Expl mode [TAB]", 255,255,255);
}
else
{
graphics.bprint(0, 0, "Name mode [TAB]", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 0, 0, "Name mode [TAB]", 255,255,255);
}
}
else
{
graphics.bprint(0, 0, "Play mode [TAB]", 255,255,255);
graphics.bprint(320-64, 10, "F1: Help", 192,192,192);
font::print(PR_BOR | PR_FONT_8X8, 0, 0, "Play mode [TAB]", 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 320-64, 10, "F1: Help", 192,192,192);
}
char buffer[SCREEN_WIDTH_CHARS + 1];
@ -128,11 +139,11 @@ namespace roomname_translator
}
vformat_buf(buffer, sizeof(buffer), "{n|digits=3|spaces} left", "n:int", n_left);
graphics.bprint(144, 0, buffer, 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 144, 0, buffer, 255,255,255);
if (map.invincibility)
{
graphics.bprint(224, 0, "INV", 255,255,128);
font::print(PR_BOR | PR_FONT_8X8, 224, 0, "INV", 255,255,128);
}
vformat_buf(buffer, sizeof(buffer),
@ -140,7 +151,7 @@ namespace roomname_translator
"x:int, y:int",
game.roomx % 100, game.roomy % 100
);
graphics.bprint(320-56, 0, buffer, 255,255,255);
font::print(PR_BOR | PR_FONT_8X8, 320-56, 0, buffer, 255,255,255);
if (map.roomname_special)
{
@ -154,13 +165,14 @@ namespace roomname_translator
// No room name at all, so no translation/explanation interface
if (edit_mode)
{
graphics.bprint(-1, 221, "[no roomname]", 0,192,255, true);
font::print(PR_CEN | PR_BOR | PR_FONT_8X8, -1, 229-font::height(PR_FONT_LEVEL), "[no roomname]", 0,192,255);
}
}
else if (!expl_mode)
{
// Name mode affects play mode a bit as well...
bool roomname_is_translated = loc::get_roomname_translation(map.custommode, game.roomx, game.roomy)[0] != '\0';
*roomname_untranslated = !roomname_is_translated;
if (edit_mode)
{
@ -173,21 +185,21 @@ namespace roomname_translator
{
english_roomname = map.roomname;
}
graphics.bprint(-1, 221, english_roomname, 0,192,255, true);
font::print(PR_CEN | PR_BOR | PR_FONT_8X8, -1, 229-font::height(PR_FONT_LEVEL), english_roomname, 0,192,255);
print_explanation(loc::get_roomname_explanation(map.custommode, game.roomx, game.roomy));
if (key.textentry())
{
*force_roomname_hidden = true;
graphics.render_roomname(key.keybuffer.c_str(), 255,255,255);
int name_w = graphics.len(key.keybuffer);
graphics.bprint((320-name_w)/2+name_w, 231, "_", 255,255,255);
graphics.render_roomname(PR_FONT_LEVEL, key.keybuffer.c_str(), 255,255,255);
int name_w = font::len(PR_FONT_LEVEL, key.keybuffer);
font::print(PR_BOR | PR_FONT_LEVEL, (320-name_w)/2+name_w, 231, "_", 255,255,255);
}
else if (!roomname_is_translated)
{
*force_roomname_hidden = true;
graphics.render_roomname("[no translation]", 255,255,128);
graphics.render_roomname(PR_FONT_8X8, "[no translation]", 255,255,128);
}
}
else if (!roomname_is_translated)
@ -214,7 +226,7 @@ namespace roomname_translator
{
print_explanation((key.keybuffer + "_").c_str());
graphics.PrintWrap(0, 90, "Use \".\" to set no explanation", 255,255,255, false, 8, 320);
font::print_wrap(PR_BOR | PR_FONT_8X8, 0, 90, "Use \".\" to set no explanation", 255,255,255, 8, 320);
}
else
{
@ -248,11 +260,15 @@ namespace roomname_translator
if (loc::save_roomname_explanation_to_files(map.custommode, game.roomx, game.roomy, explanation))
{
graphics.createtextboxflipme(success_message, -1, 176, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
graphics.textboxtimer(25);
}
else
{
graphics.createtextboxflipme("ERROR: Could not save to all langs!", -1, 176, 255, 60, 60);
graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
graphics.textboxtimer(50);
}
}
@ -262,6 +278,8 @@ namespace roomname_translator
if (loc::save_roomname_to_file(loc::lang, map.custommode, game.roomx, game.roomy, translation, NULL))
{
graphics.createtextboxflipme("Translation saved!", -1, 176, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
graphics.textboxtimer(25);
}
else
@ -271,6 +289,7 @@ namespace roomname_translator
graphics.addline("1) Do the language files exist?");
graphics.addline("2) Make sure there is no \"lang\"");
graphics.addline(" folder next to the regular saves.");
graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
graphics.textboxtimer(180);
}
@ -330,6 +349,8 @@ namespace roomname_translator
if (loc::lang == "en")
{
graphics.createtextboxflipme("ERROR: Can't add EN-EN translation", -1, 176, 255, 60, 60);
graphics.textboxprintflags(PR_FONT_8X8);
graphics.textboxcenterx();
graphics.textboxtimer(50);
}
else

View File

@ -13,7 +13,7 @@ namespace roomname_translator
void set_enabled(bool value);
bool is_pausing(void);
void overlay_render(bool* force_roomname_hidden, int* roomname_r, int* roomname_g, int* roomname_b);
void overlay_render(bool* force_roomname_hidden, bool* roomname_untranslated, int* roomname_r, int* roomname_g, int* roomname_b);
bool overlay_input(void);
}

View File

@ -1768,6 +1768,7 @@ void scriptclass::run(void)
graphics.textboxremovefast();
graphics.createtextboxflipme(loc::gettext("Congratulations!\n\nYou have found a shiny trinket!"), 50, 85, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
int h = graphics.textboxwrap(2);
graphics.textboxcentertext();
graphics.textboxpad(1, 1);
@ -1794,6 +1795,7 @@ void scriptclass::run(void)
game.trinkets(), max_trinkets
);
graphics.createtextboxflipme(buffer, 50, 95+h, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(2);
graphics.textboxcentertext();
graphics.textboxpad(1, 1);
@ -1816,6 +1818,7 @@ void scriptclass::run(void)
graphics.textboxremovefast();
graphics.createtextbox(loc::gettext("Congratulations!\n\nYou have found the secret lab!"), 50, 85, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(2);
graphics.textboxcentertext();
graphics.textboxpad(1, 1);
@ -1837,6 +1840,7 @@ void scriptclass::run(void)
graphics.textboxremovefast();
graphics.createtextbox(loc::gettext("The secret lab is separate from the rest of the game. You can now come back here at any time by selecting the new SECRET LAB option in the play menu."), 50, 85, 174, 174, 174);
graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.textboxwrap(0);
graphics.textboxcenterx();
graphics.textboxcentery();

View File

@ -23,6 +23,8 @@ textboxclass::textboxclass(void)
flipme = false;
rand = 0;
print_flags = PR_FONT_LEVEL;
}
void textboxclass::centerx(void)
@ -102,13 +104,13 @@ void textboxclass::resize(void)
int max = 0;
for (size_t iter = 0; iter < lines.size(); iter++)
{
int len = font::len(PR_FONT_LEVEL, lines[iter]);
int len = font::len(print_flags, lines[iter]);
if (len > (unsigned int)max) max = len;
}
// 16 for the borders
w = max + 16;
h = lines.size()*font::height(PR_FONT_LEVEL) + 16;
h = lines.size()*font::height(print_flags) + 16;
}
void textboxclass::addline(const std::string& t)

View File

@ -1,6 +1,7 @@
#ifndef TEXTBOX_H
#define TEXTBOX_H
#include <stdint.h>
#include <string>
#include <vector>
@ -47,6 +48,8 @@ public:
bool flipme;
int rand;
uint32_t print_flags;
};
#endif /* TEXTBOX_H */