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

Add PR_RTL_XFLIP to some important places

Okay, the "Font:" thing needed some local code after all, because both
the interface font as well as the level font are used there. But it's
good enough - all the other places can just use the flag.

Notably, I also used this for the menus, since the existing ones are
kinda LTR-oriented, and it's something that we don't *really* have to
do, but I think it shows we care!
This commit is contained in:
Dav999 2024-01-03 22:54:20 +01:00 committed by Misa Elizabeth Kai
parent eac612c309
commit 2b22f7cda2
5 changed files with 67 additions and 51 deletions

View file

@ -573,8 +573,16 @@ static void editormenurender(int tr, int tg, int tb)
int len_label = font::len(0, label);
const char* name = font::get_level_font_display_name();
font::print(0, 2, 230, label, tr / 2, tg / 2, tb / 2);
font::print(PR_FONT_LEVEL, 2 + len_label, 230, name, tr / 2, tg / 2, tb / 2);
int font_x = 2 + len_label;
uint32_t font_flags = PR_FONT_LEVEL;
if (font::is_rtl(PR_FONT_INTERFACE))
{
font_x = SCREEN_WIDTH_PIXELS - font_x;
font_flags |= PR_RIGHT;
}
font::print(PR_RTL_XFLIP, 2, 230, label, tr / 2, tg / 2, tb / 2);
font::print(font_flags, font_x, 230, name, tr / 2, tg / 2, tb / 2);
break;
}
case Menu::ed_music:
@ -652,8 +660,16 @@ static void editormenurender(int tr, int tg, int tb)
int len_label = font::len(0, label);
const char* name = font::get_level_font_display_name();
font::print(0, 2, 230, label, tr/2, tg/2, tb/2);
font::print(PR_FONT_LEVEL, 2+len_label, 230, name, tr/2, tg/2, tb/2);
int font_x = 2 + len_label;
uint32_t font_flags = PR_FONT_LEVEL;
if (font::is_rtl(PR_FONT_INTERFACE))
{
font_x = SCREEN_WIDTH_PIXELS - font_x;
font_flags |= PR_RIGHT;
}
font::print(PR_RTL_XFLIP, 2, 230, label, tr/2, tg/2, tb/2);
font::print(font_flags, font_x, 230, name, tr/2, tg/2, tb/2);
break;
}
default:

View file

@ -14,7 +14,6 @@
#include "Entity.h"
#include "Enums.h"
#include "FileSystemUtils.h"
#include "Font.h"
#include "GlitchrunnerMode.h"
#include "Graphics.h"
#include "LevelDebugger.h"
@ -6487,7 +6486,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
for (uint8_t i = 0; i < font::font_idx_options_n; i++)
{
uint8_t idx = font::font_idx_options[i];
option(font::get_main_font_display_name(idx), true, PR_FONT_IDX(idx, false));
option(font::get_main_font_display_name(idx), true, PR_FONT_IDX(idx, font::is_rtl(PR_FONT_INTERFACE)) | PR_RTL_XFLIP);
if (font::level_font_is_main_idx(idx))
{
option_match = i;

View file

@ -6,6 +6,7 @@
#include <string>
#include <vector>
#include "Font.h"
#include "ScreenSettings.h"
/* FIXME: Can't forward declare this enum in C++, unfortunately.
@ -382,7 +383,7 @@ public:
int menuspacing;
std::vector<MenuStackFrame> menustack;
void inline option(const char* text, bool active = true, uint32_t print_flags = 0)
void inline option(const char* text, bool active = true, uint32_t print_flags = PR_RTL_XFLIP)
{
MenuOption menuoption;
SDL_strlcpy(menuoption.text, text, sizeof(menuoption.text));

View file

@ -285,11 +285,11 @@ void Graphics::map_option(int opt, int num_opts, const std::string& text, bool s
// Account for brackets
x -= (font::len(0, buffer) - font::len(0, text_upper.c_str())) / 2;
font::print(0, x, y, buffer, 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, x, y, buffer, 196, 196, 255 - help.glow);
}
else
{
font::print(0, x, y, loc::remove_toupper_escape_chars(text), 96, 96, 96);
font::print(PR_RTL_XFLIP, x, y, loc::remove_toupper_escape_chars(text), 96, 96, 96);
}
}

View file

@ -1637,20 +1637,20 @@ static void menurender(void)
{
int sp = SDL_max(10, font::height(0));
font::print(0, 32, 65, loc::gettext("RECORDS"), tr, tg, tb);
font::print(PR_RTL_XFLIP, 32, 65, loc::gettext("RECORDS"), tr, tg, tb);
const char* label = loc::gettext("TIME");
int label_len = font::len(0, label);
font::print(0, 32, 65+sp, label, tr, tg, tb);
font::print(PR_RTL_XFLIP, 32, 65+sp, label, tr, tg, tb);
label = loc::gettext("SHINY");
label_len = SDL_max(label_len, font::len(0, label));
font::print(0, 32, 65+sp*2, label, tr, tg, tb);
font::print(PR_RTL_XFLIP, 32, 65+sp*2, label, tr, tg, tb);
label = loc::gettext("LIVES");
label_len = SDL_max(label_len, font::len(0, label));
font::print(0, 32, 65+sp*3, label, tr, tg, tb);
font::print(PR_RTL_XFLIP, 32, 65+sp*3, label, tr, tg, tb);
char buffer[SCREEN_WIDTH_CHARS + 1];
help.format_time(buffer, sizeof(buffer), game.besttimes[id_trial], game.bestframes[id_trial], true);
font::print(0, label_len+48, 65+sp, buffer, tr, tg, tb);
font::print(PR_RTL_XFLIP, label_len+48, 65+sp, buffer, tr, tg, tb);
vformat_buf(
buffer, sizeof(buffer),
@ -1658,8 +1658,8 @@ static void menurender(void)
"n_trinkets:int, max_trinkets:int",
game.besttrinkets[id_trial], max_trinkets
);
font::print(0, label_len+48, 65+sp*2, buffer, tr, tg, tb);
font::print(0, label_len+48, 65+sp*3, help.String(game.bestlives[id_trial]), tr, tg, tb);
font::print(PR_RTL_XFLIP, label_len+48, 65+sp*2, buffer, tr, tg, tb);
font::print(PR_RTL_XFLIP, label_len+48, 65+sp*3, help.String(game.bestlives[id_trial]), tr, tg, tb);
const char* str_par_time = loc::gettext("PAR TIME");
@ -1700,11 +1700,11 @@ static void menurender(void)
}
int center_x = 288 - longest_w/2;
font::print(PR_CEN, center_x, 65, str_par_time, tr, tg, tb);
font::print(PR_CEN, center_x, 65+sp, par_time, tr, tg, tb);
font::print(PR_CEN, center_x, 65+sp*3, str_best_rank, tr, tg, tb);
font::print(PR_CEN | PR_RTL_XFLIP, center_x, 65, str_par_time, tr, tg, tb);
font::print(PR_CEN | PR_RTL_XFLIP, center_x, 65+sp, par_time, tr, tg, tb);
font::print(PR_CEN | PR_RTL_XFLIP, center_x, 65+sp*3, str_best_rank, tr, tg, tb);
font::print(
PR_2X | PR_CEN,
PR_2X | PR_CEN | PR_RTL_XFLIP,
center_x,
66+sp*4,
rank,
@ -2229,10 +2229,10 @@ void gamerender(void)
{
const char* tempstring = loc::gettext("TIME:");
int label_len = font::len(0, tempstring);
font::print(PR_BOR, 6, 6, tempstring, 255,255,255);
font::print(PR_BOR | PR_RTL_XFLIP, 6, 6, tempstring, 255,255,255);
char buffer[SCREEN_WIDTH_CHARS + 1];
game.timestringcenti(buffer, sizeof(buffer));
font::print(PR_BOR, 6+label_len, 6, buffer, 196,196,196);
font::print(PR_BOR | PR_RTL_XFLIP, 6+label_len, 6, buffer, 196,196,196);
}
bool force_roomname_hidden = false;
@ -2480,29 +2480,29 @@ void gamerender(void)
//Draw OSD stuff
const char* tempstring = loc::gettext("TIME:");
int label_len = font::len(0, tempstring);
font::print(PR_BOR, 6, 18, tempstring, 255,255,255);
font::print(PR_BOR | PR_RTL_XFLIP, 6, 18, tempstring, 255,255,255);
tempstring = loc::gettext("DEATH:");
label_len = SDL_max(label_len, font::len(0, tempstring));
font::print(PR_BOR, 6, 30, tempstring, 255,255,255);
font::print(PR_BOR | PR_RTL_XFLIP, 6, 30, tempstring, 255,255,255);
tempstring = loc::gettext("SHINY:");
label_len = SDL_max(label_len, font::len(0, tempstring));
font::print(PR_BOR, 6, 42, tempstring, 255,255,255);
font::print(PR_BOR | PR_RTL_XFLIP, 6, 42, tempstring, 255,255,255);
if(game.timetrialparlost)
{
font::print(PR_BOR, 8+label_len, 18, buffer, 196, 80, 80);
font::print(PR_BOR | PR_RTL_XFLIP, 8+label_len, 18, buffer, 196, 80, 80);
}
else
{
font::print(PR_BOR, 8+label_len, 18, buffer, 196, 196, 196);
font::print(PR_BOR | PR_RTL_XFLIP, 8+label_len, 18, buffer, 196, 196, 196);
}
if(game.deathcounts>0)
{
font::print(PR_BOR, 8+label_len, 30,help.String(game.deathcounts), 196, 80, 80);
font::print(PR_BOR | PR_RTL_XFLIP, 8+label_len, 30,help.String(game.deathcounts), 196, 80, 80);
}
else
{
font::print(PR_BOR, 8+label_len, 30,help.String(game.deathcounts), 196, 196, 196);
font::print(PR_BOR | PR_RTL_XFLIP, 8+label_len, 30,help.String(game.deathcounts), 196, 196, 196);
}
vformat_buf(
buffer, sizeof(buffer),
@ -2512,24 +2512,24 @@ void gamerender(void)
);
if(game.trinkets()<game.timetrialshinytarget)
{
font::print(PR_BOR, 8+label_len, 42, buffer, 196, 80, 80);
font::print(PR_BOR | PR_RTL_XFLIP, 8+label_len, 42, buffer, 196, 80, 80);
}
else
{
font::print(PR_BOR, 8+label_len, 42, buffer, 196, 196, 196);
font::print(PR_BOR | PR_RTL_XFLIP, 8+label_len, 42, buffer, 196, 196, 196);
}
std::string time = game.timetstring(game.timetrialpar);
label_len = font::len(0, time.c_str());
if(game.timetrialparlost)
{
font::print(PR_BOR | PR_RIGHT, 307-label_len-8, 214, loc::gettext("PAR TIME:"), 80, 80, 80);
font::print(PR_BOR, 307-label_len, 214, time, 80, 80, 80);
font::print(PR_BOR | PR_RTL_XFLIP | PR_RIGHT, 307-label_len-8, 214, loc::gettext("PAR TIME:"), 80, 80, 80);
font::print(PR_BOR | PR_RTL_XFLIP, 307-label_len, 214, time, 80, 80, 80);
}
else
{
font::print(PR_BOR | PR_RIGHT, 307-label_len-8, 214, loc::gettext("PAR TIME:"), 255, 255, 255);
font::print(PR_BOR, 307-label_len, 214, time, 196, 196, 196);
font::print(PR_BOR | PR_RTL_XFLIP | PR_RIGHT, 307-label_len-8, 214, loc::gettext("PAR TIME:"), 255, 255, 255);
font::print(PR_BOR | PR_RTL_XFLIP, 307-label_len, 214, time, 196, 196, 196);
}
}
}
@ -3190,8 +3190,8 @@ void maprender(void)
font::print_wrap(PR_CEN, -1, 142, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12);
}
font::print(0, 80-selection_offset, 88, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(0, 80 + 32, 76, loc::gettext("yes, quit to menu"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80-selection_offset, 88, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80 + 32, 76, loc::gettext("yes, quit to menu"), 96, 96, 96);
}
else
{
@ -3205,8 +3205,8 @@ void maprender(void)
font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12);
}
font::print(0, 80-selection_offset, 130, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(0, 80 + 32, 142, loc::gettext("yes, quit to menu"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80-selection_offset, 130, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80 + 32, 142, loc::gettext("yes, quit to menu"), 96, 96, 96);
}
break;
@ -3224,8 +3224,8 @@ void maprender(void)
font::print_wrap(PR_CEN, -1, 142, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12);
}
font::print(0, 80, 88, loc::gettext("no, keep playing"), 96,96,96);
font::print(0, 80+32-selection_offset, 76, loc::gettext("[ YES, QUIT TO MENU ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80, 88, loc::gettext("no, keep playing"), 96,96,96);
font::print(PR_RTL_XFLIP, 80+32-selection_offset, 76, loc::gettext("[ YES, QUIT TO MENU ]"), 196, 196, 255 - help.glow);
}
else
{
@ -3238,8 +3238,8 @@ void maprender(void)
font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to quit? You will lose any unsaved progress."), 196, 196, 255 - help.glow, 12);
}
font::print(0, 80, 130, loc::gettext("no, keep playing"), 96,96,96);
font::print(0, 80+32-selection_offset, 142, loc::gettext("[ YES, QUIT TO MENU ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80, 130, loc::gettext("no, keep playing"), 96,96,96);
font::print(PR_RTL_XFLIP, 80+32-selection_offset, 142, loc::gettext("[ YES, QUIT TO MENU ]"), 196, 196, 255 - help.glow);
}
break;
case 20:
@ -3248,14 +3248,14 @@ void maprender(void)
if (graphics.flipmode)
{
font::print_wrap(PR_CEN, -1, 88, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12);
font::print(0, 80-selection_offset, 142, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(0, 80 + 32, 130, loc::gettext("yes, return"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80-selection_offset, 142, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80 + 32, 130, loc::gettext("yes, return"), 96, 96, 96);
}
else
{
font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12);
font::print(0, 80-selection_offset, 130, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(0, 80 + 32, 142, loc::gettext("yes, return"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80-selection_offset, 130, loc::gettext("[ NO, KEEP PLAYING ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80 + 32, 142, loc::gettext("yes, return"), 96, 96, 96);
}
break;
@ -3265,14 +3265,14 @@ void maprender(void)
if (graphics.flipmode)
{
font::print_wrap(PR_CEN, -1, 88, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12);
font::print(0, 80, 142, loc::gettext("no, keep playing"), 96, 96, 96);
font::print(0, 80 + 32-selection_offset, 130, loc::gettext("[ YES, RETURN ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80, 142, loc::gettext("no, keep playing"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80 + 32-selection_offset, 130, loc::gettext("[ YES, RETURN ]"), 196, 196, 255 - help.glow);
}
else
{
font::print_wrap(PR_CEN, -1, 76, loc::gettext("Do you want to return to the secret laboratory?"), 196, 196, 255 - help.glow, 12);
font::print(0, 80, 130, loc::gettext("no, keep playing"), 96, 96, 96);
font::print(0, 80 + 32-selection_offset, 142, loc::gettext("[ YES, RETURN ]"), 196, 196, 255 - help.glow);
font::print(PR_RTL_XFLIP, 80, 130, loc::gettext("no, keep playing"), 96, 96, 96);
font::print(PR_RTL_XFLIP, 80 + 32-selection_offset, 142, loc::gettext("[ YES, RETURN ]"), 196, 196, 255 - help.glow);
}
}