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

Add translingual map legend code + border8

This commit is contained in:
mothbeanie 2023-10-08 18:22:26 -07:00 committed by Misa Elizabeth Kai
parent 7840f72389
commit 3a3ec659d6
3 changed files with 38 additions and 8 deletions

View file

@ -78,6 +78,7 @@ struct PrintFlags
Font* font_sel;
uint8_t brightness;
bool border;
bool border8;
bool align_cen;
bool align_right;
bool cjk_low;
@ -768,11 +769,17 @@ static PrintFlags decode_print_flags(uint32_t flags)
pf.font_sel = fontsel_to_font(FLAG_PART(3, 5));
pf.brightness = ~FLAG_PART(8, 8) & 0xff;
pf.border = flags & PR_BOR;
pf.border8 = flags & PR_BOR8;
pf.align_cen = flags & PR_CEN;
pf.align_right = flags & PR_RIGHT;
pf.cjk_low = flags & PR_CJK_LOW;
pf.cjk_high = flags & PR_CJK_HIGH;
if (pf.border8)
{
pf.border = false;
}
return pf;
}
#undef FLAG_PART
@ -1223,6 +1230,22 @@ void print(
}
}
if (pf.border8)
{
static const int offsets[8][2] = { {0,-1}, {-1,0}, {1,0}, {0,1}, {-1,-1}, {1,1}, {-1,1}, {1,-1} };
for (int offset = 0; offset < 8; offset++)
{
print(
flags & ~PR_BOR8 & ~PR_CEN & ~PR_RIGHT,
x + offsets[offset][0] * pf.scale,
y + offsets[offset][1] * pf.scale,
text,
0, 0, 0
);
}
}
int h_diff_8 = (pf.font_sel->glyph_h-8)*pf.scale;
if (h_diff_8 < 0)
{
@ -1306,6 +1329,12 @@ int print_wrap(
flags &= ~PR_BOR;
}
if (pf.border8 && (r | g | b) != 0)
{
print_wrap(flags, x, y, text, 0, 0, 0, linespacing, maxwidth);
flags &= ~PR_BOR8;
}
// This could fit 64 non-BMP characters onscreen, should be plenty
char buffer[256];
size_t start = 0;

View file

@ -45,6 +45,7 @@
#define PR_FONT_IDX(idx) ((SDL_clamp(idx, 0, 28) + 3) << 3) /* use given font index */
#define PR_BRIGHTNESS(value) /* use this brightness 0-255 for the text (accounts for button glyphs correctly) */\
(((~SDL_clamp((int)(value), 0, 255) & 0xff) << 8))
#define PR_BOR8 (1 << 16) /* draw a black border around the text, filling in the corners (for the map legend) */
#define PR_BOR (1 << 17) /* draw a black border around the text (was bprint/bigbprint) */
#define PR_LEFT (0 << 18) /* default, left-align text/place at x coordinate */
#define PR_CEN (1 << 18) /* center-align text relative to X (X is center) or to screen if X == -1 */

View file

@ -2512,15 +2512,15 @@ static MapRenderData getmaprenderdata(void)
switch (data.zoom)
{
case 4:
data.legendxoff += 21;
data.legendyoff += 16;
data.legendxoff += 20;
data.legendyoff += 14;
break;
case 2:
data.legendxoff += 9;
data.legendxoff += 8;
data.legendyoff += 5;
break;
default:
data.legendxoff += 3;
data.legendxoff += 2;
data.legendyoff += 1;
break;
}
@ -2576,11 +2576,11 @@ static void rendermaplegend(void)
{
if (map.showteleporters && map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
{
graphics.drawtile(data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), 1127 + tile_offset);
font::print(PR_FONT_8X8 | PR_BOR8, data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), "💿", 171, 255, 252);
}
else if (map.showtargets && !map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
{
graphics.drawtile(data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), 1126 + tile_offset);
font::print(PR_FONT_8X8 | PR_BOR8, data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), "", 64, 64, 64);
}
}
@ -2590,7 +2590,7 @@ static void rendermaplegend(void)
{
if (!obj.collect[i])
{
graphics.drawtile(data.legendxoff + (map.shinytrinkets[i].x * 12 * data.zoom), data.legendyoff + (map.shinytrinkets[i].y * 9 * data.zoom), 1086 + tile_offset);
font::print(PR_FONT_8X8 | PR_BOR8, data.legendxoff + (map.shinytrinkets[i].x * 12 * data.zoom), data.legendyoff + (map.shinytrinkets[i].y * 9 * data.zoom), "🪙", 254, 252, 58);
}
}
}
@ -3215,7 +3215,7 @@ void teleporterrender(void)
if (game.useteleporter && (help.slowsine % 16 > 8 || game.noflashingmode))
{
graphics.drawtile(data.legendxoff + data.xoff + (telex * 12 * data.zoom), data.legendyoff + data.yoff + (teley * 9 * data.zoom), 1128 + (graphics.flipmode ? 3 : 0));
font::print(PR_FONT_8X8 | PR_BOR8, data.legendxoff + data.xoff + (telex * 12 * data.zoom), data.legendyoff + data.yoff + (teley * 9 * data.zoom), "💿", 255, 0, 0);
}
graphics.cutscenebars();