Display as many URLs as can fit on the top screen when installing from URLs.

This commit is contained in:
Steveice10 2017-07-15 13:25:00 -07:00
parent b3370c97af
commit 19e0eaac80
3 changed files with 32 additions and 8 deletions

View File

@ -569,7 +569,7 @@ float screen_get_font_height(float scaleY) {
return scaleY * fontGetInfo()->lineFeed;
}
static void screen_get_string_size_internal(float* width, float* height, const char* text, float scaleX, float scaleY, bool oneLine, bool wrap, float wrapX) {
static void screen_get_string_size_internal(float* width, float* height, const char* text, float scaleX, float scaleY, bool oneLine, bool wrap, float wrapWidth) {
float w = 0;
float h = 0;
float lineWidth = 0;
@ -584,7 +584,7 @@ static void screen_get_string_size_internal(float* width, float* height, const c
while(*p && (units = decode_utf8(&code, p)) != -1 && code > 0) {
p += units;
if(code == '\n' || (wrap && lineWidth + scaleX * fontGetCharWidthInfo(fontGlyphIndexFromCodePoint(code))->charWidth >= wrapX)) {
if(code == '\n' || (wrap && lineWidth + scaleX * fontGetCharWidthInfo(fontGlyphIndexFromCodePoint(code))->charWidth >= wrapWidth)) {
lastAlign = p;
if(lineWidth > w) {
@ -627,8 +627,8 @@ void screen_get_string_size(float* width, float* height, const char* text, float
screen_get_string_size_internal(width, height, text, scaleX, scaleY, false, false, 0);
}
void screen_get_string_size_wrap(float* width, float* height, const char* text, float scaleX, float scaleY, float wrapX) {
screen_get_string_size_internal(width, height, text, scaleX, scaleY, false, true, wrapX);
void screen_get_string_size_wrap(float* width, float* height, const char* text, float scaleX, float scaleY, float wrapWidth) {
screen_get_string_size_internal(width, height, text, scaleX, scaleY, false, true, wrapWidth);
}
static void screen_draw_string_internal(const char* text, float x, float y, float scaleX, float scaleY, u32 colorId, bool centerLines, bool wrap, float wrapX) {
@ -653,10 +653,10 @@ static void screen_draw_string_internal(const char* text, float x, float y, floa
screen_set_blend(blendColor, true, true);
float stringWidth;
screen_get_string_size_internal(&stringWidth, NULL, text, scaleX, scaleY, false, wrap, wrapX);
screen_get_string_size_internal(&stringWidth, NULL, text, scaleX, scaleY, false, wrap, wrapX - x);
float lineWidth;
screen_get_string_size_internal(&lineWidth, NULL, text, scaleX, scaleY, true, wrap, wrapX);
screen_get_string_size_internal(&lineWidth, NULL, text, scaleX, scaleY, true, wrap, wrapX - x);
float currX = x;
if(centerLines) {
@ -675,7 +675,7 @@ static void screen_draw_string_internal(const char* text, float x, float y, floa
if(code == '\n' || (wrap && currX + scaleX * fontGetCharWidthInfo(fontGlyphIndexFromCodePoint(code))->charWidth >= wrapX)) {
lastAlign = p;
screen_get_string_size_internal(&lineWidth, NULL, (const char*) p, scaleX, scaleY, true, wrap, wrapX);
screen_get_string_size_internal(&lineWidth, NULL, (const char*) p, scaleX, scaleY, true, wrap, wrapX - x);
currX = x;
if(centerLines) {

View File

@ -72,6 +72,6 @@ void screen_draw_texture(u32 id, float x, float y, float width, float height);
void screen_draw_texture_crop(u32 id, float x, float y, float width, float height);
float screen_get_font_height(float scaleY);
void screen_get_string_size(float* width, float* height, const char* text, float scaleX, float scaleY);
void screen_get_string_size_wrap(float* width, float* height, const char* text, float scaleX, float scaleY, float wrapX);
void screen_get_string_size_wrap(float* width, float* height, const char* text, float scaleX, float scaleY, float wrapWidth);
void screen_draw_string(const char* text, float x, float y, float scaleX, float scaleY, u32 colorId, bool centerLines);
void screen_draw_string_wrap(const char* text, float x, float y, float scaleX, float scaleY, u32 colorId, bool centerLines, float wrapX);

View File

@ -62,6 +62,28 @@ static void action_install_url_draw_top(ui_view* view, void* data, float x1, flo
if(installData->drawTop != NULL) {
installData->drawTop(view, installData->userData, x1, y1, x2, y2, installData->installInfo.processed);
} else if(installData->installInfo.processed == installData->installInfo.total) {
float urlY = y1 + 5;
u32 index = 0;
while(urlY < y2 && index < installData->installInfo.total) {
float urlWidth = 0;
float urlHeight = 0;
screen_get_string_size_wrap(&urlWidth, &urlHeight, installData->urls[index], 0.5f, 0.5f, x2 - x1 - 10);
float urlX = (x2 - x1 - urlWidth) / 2;
screen_draw_string_wrap(installData->urls[index], urlX, urlY, 0.5f, 0.5f, COLOR_TEXT, false, urlX + urlWidth + 1);
urlY += urlHeight;
index++;
}
} else {
float urlWidth = 0;
float urlHeight = 0;
screen_get_string_size_wrap(&urlWidth, &urlHeight, installData->urls[installData->installInfo.processed], 0.5f, 0.5f, x2 - x1 - 10);
float urlX = (x2 - x1 - urlWidth) / 2;
float urlY = (y2 - y1 - urlHeight) / 2;
screen_draw_string_wrap(installData->urls[installData->installInfo.processed], urlX, urlY, 0.5f, 0.5f, COLOR_TEXT, false, urlX + urlWidth + 1);
}
}
@ -370,6 +392,8 @@ void action_install_url(const char* confirmMessage, const char* urls, void* user
data->installInfo.copyBufferSize = 128 * 1024;
data->installInfo.copyEmpty = false;
data->installInfo.processed = data->installInfo.total;
data->installInfo.isSrcDirectory = action_install_url_is_src_directory;
data->installInfo.makeDstDirectory = action_install_url_make_dst_directory;