Display a progress bar for netloader in the msgbox. Adjusted the language.c netloader strings so that the total newlines for each StrId matches. Fixed GetTextXCoordinate with 'c'. Moved the menuMsgBoxSetNetloaderState call into menuUpdateNetloader and only pass netloaderState into menuUpdateNetloader, etc. Use theme colors in msgbox. Various msgbox adjustments. Added progressBarColor to theme.

This commit is contained in:
yellows8 2018-10-24 18:38:50 -04:00
parent e648cc9485
commit d97eebc26f
7 changed files with 73 additions and 39 deletions

View File

@ -418,7 +418,7 @@ uint32_t GetTextXCoordinate(u32 font, uint32_t rX, const char* text, const char
if(fC<0) return 0;
else return fC;
case 'c':
return (rX+(width_o>>1));//>>1 is a bitwise shift for dividing by 2
return (rX-(width_o>>1));//>>1 is a bitwise shift for dividing by 2
case 'l':
default:
return rX;

View File

@ -786,64 +786,64 @@ const char* const g_strings[StrId_Max][16] =
[StrId_NetLoaderOffline] =
{
STR_EN("Offline, waiting for network…\n\n\n"),
STR_FR("Hors-ligne, en attente d'une connection...\n\n\n"),
STR_IT("Disconnesso, in attesa della connessione…\n\n\n"),
STR_JP("オフラインです。ネットワーク接続を待っています…\n\n\n"),
STR_KO("연결 끊김, 네트워크 기다리는 중…\n\n\n"),
STR_ZH("无法连接网络,等待网络连接…\n\n\n"),
STR_TW("當前離線,等待網路連線…\n\n\n"),
STR_EN("Offline, waiting for network…"),
STR_FR("Hors-ligne, en attente d'une connection..."),
STR_IT("Disconnesso, in attesa della connessione…"),
STR_JP("オフラインです。ネットワーク接続を待っています…"),
STR_KO("연결 끊김, 네트워크 기다리는 중…"),
STR_ZH("无法连接网络,等待网络连接…"),
STR_TW("當前離線,等待網路連線…"),
},
[StrId_NetLoaderActive] =
{
STR_EN(
"Waiting for nxlink to connect…\n"
"IP Addr: %lu.%lu.%lu.%lu, Port: %d\n\n"
"IP Addr: %lu.%lu.%lu.%lu, Port: %d"
),
STR_ES(
"Esperando a que se conecte nxlink…\n"
"Dir.IP: %lu.%lu.%lu.%lu, Puerto: %d\n\n"
"Dir.IP: %lu.%lu.%lu.%lu, Puerto: %d"
),
STR_DE(
"Warte auf Verbindung von 3dslink…\n"
"IP Addr: %lu.%lu.%lu.%lu, Port: %d\n\n"
"IP Addr: %lu.%lu.%lu.%lu, Port: %d"
),
STR_FR(
"En attente de la connexion de nxlink…\n"
"Adr. IP : %lu.%lu.%lu.%lu, Port : %d\n\n"
"Adr. IP : %lu.%lu.%lu.%lu, Port : %d"
),
STR_IT(
"In attesa della connessione di nxlink…\n"
"Ind. IP : %lu.%lu.%lu.%lu, Porta : %d\n\n"
"Ind. IP : %lu.%lu.%lu.%lu, Porta : %d"
),
STR_JP(
"nxlinkが接続されるのを待っています…\n"
"IPアドレス%lu.%lu.%lu.%lu, ポート番号:%d\n\n"
"IPアドレス%lu.%lu.%lu.%lu, ポート番号:%d"
),
STR_PT(
"A aguardar pela conexão do nxlink…\n"
"End. IP: %lu.%lu.%lu.%lu, Porta: %d\n\n"
"End. IP: %lu.%lu.%lu.%lu, Porta: %d"
),
STR_NL(
"Wachten op nxlink verbinding…\n"
"IP Addr: %lu.%lu.%lu.%lu, Poort: %d\n\n"
"IP Addr: %lu.%lu.%lu.%lu, Poort: %d"
),
STR_KO(
"nxlink의 연결을 대기중…\n"
"IP 주소: %lu.%lu.%lu.%lu, 포트: %d\n\n"
"IP 주소: %lu.%lu.%lu.%lu, 포트: %d"
),
STR_RU(
"Ожидание подключения nxlink…\n"
"айпи адрес: %lu.%lu.%lu.%lu, Порт: %d\n\n"
"айпи адрес: %lu.%lu.%lu.%lu, Порт: %d"
),
STR_ZH(
"等待 nxlink 连接…\n"
"IP 地址:%lu.%lu.%lu.%lu端口%d\n\n"
"IP 地址:%lu.%lu.%lu.%lu端口%d"
),
STR_TW(
"等待 nxlink 連接…\n"
"IP 位址:%lu.%lu.%lu.%lu連接埠%d\n\n"
"IP 位址:%lu.%lu.%lu.%lu連接埠%d"
),
},

View File

@ -493,9 +493,13 @@ void drawButtons(menu_s* menu, bool emptyDir, int *x_image_out) {
}
}
void menuUpdateNetloader(char* netloader_displaytext, size_t netloader_displaytext_size, netloaderState *netloader_state) {
void menuUpdateNetloader(netloaderState *netloader_state) {
bool enable_progress = 0;
float progress = 0;
char netloader_displaytext[260];
char textbody[256];
memset(netloader_displaytext, 0, sizeof(netloader_displaytext));
memset(textbody, 0, sizeof(textbody));
u32 ip = gethostid();
@ -505,11 +509,16 @@ void menuUpdateNetloader(char* netloader_displaytext, size_t netloader_displayte
else {
if (!netloader_state->sock_connected)
snprintf(textbody, sizeof(textbody)-1, textGetString(StrId_NetLoaderActive), ip&0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF, NXLINK_SERVER_PORT);
else
else {
enable_progress = 1;
progress = (float)netloader_state->filetotal / netloader_state->filelen;
snprintf(textbody, sizeof(textbody)-1, textGetString(StrId_NetLoaderTransferring), netloader_state->filetotal/1024, netloader_state->filelen/1024);
}
}
snprintf(netloader_displaytext, netloader_displaytext_size-1, "%s\n\n\n%s", textGetString(StrId_NetLoader), textbody);
snprintf(netloader_displaytext, sizeof(netloader_displaytext)-1, "%s\n\n\n%s", textGetString(StrId_NetLoader), textbody);
menuMsgBoxSetNetloaderState(1, netloader_displaytext, enable_progress, progress);
}
void menuLoop(void) {
@ -519,7 +528,6 @@ void menuLoop(void) {
int x, y;
int menupath_x_endpos = 918 + 40;
netloaderState netloader_state;
char netloader_displaytext[256];
for (y=0; y<450; y++) {
for (x=0; x<1280; x+=4) {// don't draw bottom pixels as they are covered by the waves
@ -564,17 +572,13 @@ void menuLoop(void) {
menuScan(".");//Reload the menu since netloader may have deleted the NRO if the transfer aborted.
menuCloseMsgBox();
menuMsgBoxSetNetloaderState(0, NULL);
menuMsgBoxSetNetloaderState(0, NULL, 0, 0);
if (netloader_state.errormsg[0]) menuCreateMsgBox(780,300, netloader_state.errormsg);
}
if(hbmenu_state == HBMENU_NETLOADER_ACTIVE) {
memset(netloader_displaytext, 0, sizeof(netloader_displaytext));
menuUpdateNetloader(netloader_displaytext, sizeof(netloader_displaytext), &netloader_state);
menuMsgBoxSetNetloaderState(1, netloader_displaytext);
menuUpdateNetloader(&netloader_state);
}
menu = menuGetCurrent();
@ -585,7 +589,7 @@ void menuLoop(void) {
if (netloader_state.launch_app) {
hbmenu_state = HBMENU_DEFAULT;
menuCloseMsgBox();
menuMsgBoxSetNetloaderState(0, NULL);
menuMsgBoxSetNetloaderState(0, NULL, 0, 0);
menuCreateMsgBox(240,240, textGetString(StrId_Loading));
launchMenuEntryTask(netloader_state.me);
}

View File

@ -5,6 +5,8 @@ MessageBox currMsgBox;
static bool msgboxNetloaderEnabled;
static char msgboxNetloaderText[256];
static bool msgboxNetloaderProgressEnabled;
static float msgboxNetloaderProgress;
void drawMsgBoxBgToBuff(color_t *buff, int width, int height) {
int x, y;
@ -12,7 +14,7 @@ void drawMsgBoxBgToBuff(color_t *buff, int width, int height) {
int circle_center_x, circle_center_y;
int corner_size = 0;
float rad, alpha;
color_t base_color = MakeColor(255, 255, 255, 255);
color_t base_color = themeCurrent.backgroundColor;
color_t color;
for (y=0; y<height; y++) {
@ -95,6 +97,9 @@ void menuDrawMsgBox() {
const char* textptr = currMsgBox.text;
int progress_width = (int)(msgboxNetloaderProgress*currMsgBox.width);
char progress_text[32];
border_color = MakeColor(themeCurrent.highlightColor.r + (255 - themeCurrent.highlightColor.r) * highlight_multiplier, themeCurrent.highlightColor.g + (255 - themeCurrent.highlightColor.g) * highlight_multiplier, themeCurrent.highlightColor.b + (255 - themeCurrent.highlightColor.b) * highlight_multiplier, 255);
// Darken the background
@ -116,6 +121,9 @@ void menuDrawMsgBox() {
curr_color = border_color;
}
}
else if (msgboxNetloaderProgressEnabled && y > currMsgBox.height - 80 && x < progress_width) {
curr_color = themeCurrent.progressBarColor;
}
DrawPixel(start_x+x, start_y+y, curr_color);
}
@ -123,13 +131,26 @@ void menuDrawMsgBox() {
if (msgboxNetloaderEnabled) textptr = msgboxNetloaderText;
GetTextDimensions(interuimedium20, textptr, &text_width, &text_height);
GetTextDimensions(interuiregular18, textptr, &text_width, &text_height);
x = GetTextXCoordinate(interuiregular18, start_x + (currMsgBox.width / 2), textptr, 'c');
if (text_width < currMsgBox.width && text_height < sep_start_y) {
DrawText(interuiregular18, start_x + (currMsgBox.width - text_width) / 2, start_y + (currMsgBox.height - text_height - 80) / 2, MakeColor(0, 0, 0, 255), textptr);
DrawText(interuiregular18, x, start_y + (currMsgBox.height - text_height - 80) / 2, themeCurrent.textColor, textptr);
}
if (!msgboxNetloaderEnabled) DrawText(interuimedium20, start_x + 365, start_y + 245 + 26, MakeColor(0, 0, 0, 255), textGetString(StrId_MsgBox_OK));
y = start_y + 245 + 26;
if (!msgboxNetloaderEnabled) {
x = GetTextXCoordinate(interuimedium20, start_x + (currMsgBox.width / 2), textGetString(StrId_MsgBox_OK), 'c');
DrawText(interuimedium20, x, y, themeCurrent.textColor, textGetString(StrId_MsgBox_OK));
}
if (msgboxNetloaderEnabled && msgboxNetloaderProgressEnabled) {
memset(progress_text, 0, sizeof(progress_text));
snprintf(progress_text, sizeof(progress_text)-1, "%.02f%%", msgboxNetloaderProgress*100);
x = GetTextXCoordinate(interuiregular18, start_x + (currMsgBox.width / 2), progress_text, 'c');
DrawText(interuiregular18, x, y, themeCurrent.textColor, progress_text);
}
shadow_start_y = start_y + currMsgBox.height;
@ -184,9 +205,12 @@ MessageBox menuGetCurrentMsgBox() {
return currMsgBox;
}
void menuMsgBoxSetNetloaderState(bool enabled, const char *text) {
void menuMsgBoxSetNetloaderState(bool enabled, const char *text, bool enable_progress, float progress) {
msgboxNetloaderEnabled = enabled;
memset(msgboxNetloaderText, 0, sizeof(msgboxNetloaderText));
if (text) strncpy(msgboxNetloaderText, text, sizeof(msgboxNetloaderText)-1);
msgboxNetloaderProgressEnabled = enable_progress;
msgboxNetloaderProgress = progress;
}

View File

@ -13,4 +13,4 @@ void menuCloseMsgBox();
bool menuIsMsgBoxOpen();
void menuDrawMsgBox(void);
MessageBox menuGetCurrentMsgBox();
void menuMsgBoxSetNetloaderState(bool enabled, const char *text);
void menuMsgBoxSetNetloaderState(bool enabled, const char *text, bool enable_progress, float progress);

View File

@ -28,6 +28,7 @@ void themeStartup(ThemePreset preset) {
.separatorColor = MakeColor(219, 218, 219, 255),
.borderColor = MakeColor(255,255,255,255),
.borderTextColor = MakeColor(64,64,64,255),
.progressBarColor = MakeColor(0,224,0,255),
.enableWaveBlending = 0,
.buttonAText = "\uE0E0",
.buttonBText = "\uE0E1",
@ -47,6 +48,7 @@ void themeStartup(ThemePreset preset) {
.separatorColor = MakeColor(219, 218, 219, 255),
.borderColor = MakeColor(255,255,255,255),
.borderTextColor = MakeColor(64,64,64,255),
.progressBarColor = MakeColor(0,224,0,255),
.enableWaveBlending = 0,
.buttonAText = "\uE0A0",
.buttonBText = "\uE0A1",
@ -63,7 +65,7 @@ void themeStartup(ThemePreset preset) {
config_t cfg = {0};
config_init(&cfg);
config_setting_t *theme = NULL;
color_t text, frontWave, middleWave, backWave, background, highlight, separator, borderColor, borderTextColor;
color_t text, frontWave, middleWave, backWave, background, highlight, separator, borderColor, borderTextColor, progressBarColor;
int waveBlending;
const char *AText, *BText, *YText, *PText, *MText;
bool good_cfg = false;
@ -106,6 +108,8 @@ void themeStartup(ThemePreset preset) {
borderColor = themeDefault->borderColor;
if (!colorFromSetting(config_setting_lookup(theme, "borderTextColor"), &borderTextColor))
borderTextColor = themeDefault->borderTextColor;
if (!colorFromSetting(config_setting_lookup(theme, "progressBarColor"), &progressBarColor))
progressBarColor = themeDefault->progressBarColor;
if (!config_setting_lookup_int(theme, "enableWaveBlending", &waveBlending))
waveBlending = themeDefault->enableWaveBlending;
if (!config_setting_lookup_string(theme, "buttonAText", &AText))
@ -128,6 +132,7 @@ void themeStartup(ThemePreset preset) {
.separatorColor = separator,
.borderColor = borderColor,
.borderTextColor = borderTextColor,
.progressBarColor = progressBarColor,
.enableWaveBlending = waveBlending,
.hbmenuLogoImage = themeDefault->hbmenuLogoImage
};

View File

@ -14,6 +14,7 @@ typedef struct
color_t separatorColor;
color_t borderColor;
color_t borderTextColor;
color_t progressBarColor;
bool enableWaveBlending;
char buttonAText[32];
char buttonBText[32];