1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-02 19:13:31 +02:00

Print activity zone text in correct font, remove Graphics::drawtextbox

Activity zones need to be in the interface font if the message is from
the system (like Press ENTER to activate terminal, which may be in a
different language) and in the level font if it's a customized message
(setactivitytext).

Graphics::drawtextbox was counting the textbox width and height in
8x8 characters, even including the borders as characters, so it'd need
to be told what the font for the textbox is, and then probably only the
height needs to be adapted to the font and not the width because that's
adapted to the screen width... So just call Graphics::drawpixeltextbox
directly instead. It was already weird enough how actual cutscene
textboxes called Graphics::drawtextbox with x/8, y/8 before the
previous commit, (when you already have the pixel width and height!)
only to have that be a wrapper for drawpixeltextbox by doing x*8, y*8.
This commit is contained in:
Dav999-v 2023-01-13 20:32:05 +01:00 committed by Misa Elizabeth Kai
parent 48a4e19635
commit 689d6e3e97
8 changed files with 23 additions and 23 deletions

View File

@ -2,6 +2,8 @@
#include <SDL_stdinc.h>
#include "Font.h"
blockclass::blockclass(void)
{
clear();
@ -28,10 +30,12 @@ void blockclass::clear(void)
activity_x = 0;
activity_y = 0;
/* std::strings get initialized automatically, but this is */
/* in case this function gets called again after construction */
/* std::strings get initialized automatically, but this is
* in case this function gets called again after construction */
script.clear();
prompt.clear();
print_flags = PR_FONT_INTERFACE;
}
void blockclass::rectset(const int xi, const int yi, const int wi, const int hi)

View File

@ -2,6 +2,7 @@
#define BLOCKV_H
#include <SDL.h>
#include <stdint.h>
#include <string>
class blockclass
@ -22,6 +23,7 @@ public:
std::string script, prompt;
int r, g, b;
int activity_x, activity_y;
uint32_t print_flags;
};
#endif /* BLOCKV_H */

View File

@ -4,6 +4,7 @@
#include <SDL.h>
#include "CustomLevels.h"
#include "Font.h"
#include "Game.h"
#include "GlitchrunnerMode.h"
#include "Graphics.h"
@ -1087,8 +1088,13 @@ void entityclass::createblock( int t, int xp, int yp, int w, int h, int trig /*=
if (customactivitytext != "")
{
block.prompt = customactivitytext;
block.print_flags = PR_FONT_LEVEL;
customactivitytext = "";
}
else
{
block.print_flags = PR_FONT_INTERFACE;
}
if (customactivitycolour != "")
{

View File

@ -429,6 +429,7 @@ public:
int oldreadytotele;
int activity_r, activity_g, activity_b, activity_x, activity_y;
std::string activity_lastprompt;
uint32_t activity_print_flags;
std::string telesummary, quicksummary, customquicksummary;
bool save_exists(void);

View File

@ -1334,18 +1334,6 @@ void Graphics::drawpixeltextbox(
drawcoloredtile(x + w - 8, y + h - 8, 47, r, g, b);
}
void Graphics::drawtextbox(
const int x,
const int y,
const int w,
const int h,
const int r,
const int g,
const int b
) {
return drawpixeltextbox(x, y, w*8, 16 + (h-2)*font::height(PR_FONT_LEVEL), r, g, b);
}
void Graphics::textboxactive(void)
{
//Remove all but the most recent textbox

View File

@ -125,8 +125,6 @@ public:
void textboxactive(void);
void drawtextbox(int x, int y, int w, int h, int r, int g, int b);
void drawpixeltextbox(int x, int y, int w, int h, int r, int g, int b);
void drawcrewman(int x, int y, int t, bool act, bool noshift =false);

View File

@ -1427,6 +1427,7 @@ void gamelogic(void)
&& INBOUNDS_VEC(game.activeactivity, obj.blocks))
{
game.activity_lastprompt = obj.blocks[game.activeactivity].prompt;
game.activity_print_flags = obj.blocks[game.activeactivity].print_flags;
game.activity_r = obj.blocks[game.activeactivity].r;
game.activity_g = obj.blocks[game.activeactivity].g;
game.activity_b = obj.blocks[game.activeactivity].b;

View File

@ -2213,12 +2213,12 @@ void gamerender(void)
game.activity_lastprompt.c_str()
);
int centered_x = ((160 ) - ((graphics.len(final_string)) / 2));
int centered_x = ((160 ) - ((font::len(game.activity_print_flags, final_string)) / 2));
if (game.activity_r == 0 && game.activity_g == 0 && game.activity_b == 0)
{
font::print(
PR_COLORGLYPH_BRI(act_alpha*255),
game.activity_print_flags | PR_COLORGLYPH_BRI(act_alpha*255),
centered_x + game.activity_x,
game.activity_y + 12,
final_string,
@ -2229,17 +2229,17 @@ void gamerender(void)
}
else
{
graphics.drawtextbox(
graphics.drawpixeltextbox(
game.activity_x + 4,
game.activity_y + 4,
39,
3,
39*8,
16 + font::height(game.activity_print_flags),
game.activity_r*act_alpha,
game.activity_g*act_alpha,
game.activity_b*act_alpha
);
font::print(
PR_COLORGLYPH_BRI(act_alpha*255) | PR_CJK_LOW,
game.activity_print_flags | PR_COLORGLYPH_BRI(act_alpha*255) | PR_CJK_LOW,
centered_x + game.activity_x,
game.activity_y + 12,
final_string,
@ -2431,7 +2431,7 @@ void maprender(void)
graphics.fill_rect(0, 12, 320, 240, 10, 24, 26 );
//Menubar:
graphics.drawtextbox( -10, 212, 43, 3, 65, 185, 207);
graphics.drawpixeltextbox( -10, 212, 43*8, 16 + font::height(PR_FONT_INTERFACE), 65, 185, 207);
// Draw the selected page name at the bottom
// menupage 0 - 3 is the pause screen