mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 18:04:09 +03:00
Migrate more prints and graphics.len calls to font::
I especially focused on graphics.len and the print calls around them, because graphics.len calls appear a bit less often, might be overlooked when migrating print calls (thus possibly using different fonts by accident) and are often used for some kind of right-alignment or centering which can be changed into PR_RIGHT or PR_CEN with a different X anyway. Notably, I also added a new function to generate these kinds of sliders: ....[]............ Different languages means that the slider for analogue stick sensitivity needs to be longer to fit possibly long words for Low/Medium/High, and then different font sizes means that the longer slider won't fit onscreen in a language that needs a 12-wide font. So slider_get() can take a "target width", which dynamically changes the number of characters depending on the width of them in the interface font. I kinda forgot that I could force the 8x8 font instead of adapting the characters in the slider to the font, and other ideas (like using different characters or a more graphical progress bar) have been brought up on Discord, so this might all change again sooner or later.
This commit is contained in:
committed by
Misa Elizabeth Kai
parent
7c55ea7832
commit
a706fb249a
@@ -299,26 +299,33 @@ static bool max_check_string(const char* str, const char* max)
|
||||
max_h = 2;
|
||||
}
|
||||
|
||||
uint8_t font_idx = get_langmeta()->font_idx;
|
||||
uint32_t print_flags = PR_FONT_IDX(font_idx) | PR_CJK_LOW;
|
||||
uint8_t font_w = 8;
|
||||
uint8_t font_h = 8;
|
||||
font::glyph_dimensions_main(get_langmeta()->font_idx, &font_w, &font_h);
|
||||
font::glyph_dimensions_main(font_idx, &font_w, &font_h);
|
||||
|
||||
unsigned short max_w_px = max_w * font_w;
|
||||
unsigned short max_h_px = max_h * SDL_max(10, font_h);
|
||||
unsigned short max_w_px = max_w * 8;
|
||||
unsigned short max_h_px = max_h * 10;
|
||||
|
||||
bool does_overflow = false;
|
||||
|
||||
if (max_h == 1)
|
||||
{
|
||||
does_overflow = graphics.len(str) > (int) max_w_px;
|
||||
max_h_px = font_h;
|
||||
does_overflow = font::len(print_flags, str) > (int) max_w_px;
|
||||
}
|
||||
else
|
||||
{
|
||||
short lines;
|
||||
font::string_wordwrap(str, max_w_px, &lines);
|
||||
does_overflow = lines > (short) max_h;
|
||||
font::string_wordwrap(str, max_w_px, &lines); // TODO: needs to be passed the font!
|
||||
does_overflow = lines*SDL_max(10, font_h) > (short) max_h_px;
|
||||
}
|
||||
|
||||
// Convert max_w and max_h from 8x8 into local
|
||||
max_w = max_w_px / font_w;
|
||||
max_h = max_h_px / SDL_max(10, font_h);
|
||||
|
||||
if (does_overflow)
|
||||
{
|
||||
TextOverflow overflow;
|
||||
@@ -329,6 +336,7 @@ static bool max_check_string(const char* str, const char* max)
|
||||
overflow.max_w_px = max_w_px;
|
||||
overflow.max_h_px = max_h_px;
|
||||
overflow.multiline = max_h > 1;
|
||||
overflow.flags = print_flags;
|
||||
|
||||
text_overflows.push_back(overflow);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user