From d9effc31436e5a0249d52c781d2c6f50e5f0a207 Mon Sep 17 00:00:00 2001 From: fincs Date: Mon, 5 Aug 2019 22:45:01 +0200 Subject: [PATCH] Display hbmenu and hbloader version, side by side. Align "Applet Mode" text to the right. --- common/font.c | 12 ++++++------ common/menu.c | 29 +++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/common/font.c b/common/font.c index 803cad9..2acdf7d 100644 --- a/common/font.c +++ b/common/font.c @@ -43,7 +43,7 @@ static bool FontSetType(u32 font) case interuimedium30: scale = 8; break; - + case largestar: scale = 18; break; @@ -313,8 +313,8 @@ void GetTextDimensions(u32 font, const char* text, uint32_t* width_out, uint32_t width = x; } - *width_out = width; - *height_out = height; + if(width_out) *width_out = width; + if(height_out) *height_out = height; } bool fontInitialize(void) @@ -380,11 +380,11 @@ void fontExit() if (s_font_libret==0) FT_Done_FreeType(s_font_library); } -/*Automatically gives you the desired x-coordinate +/*Automatically gives you the desired x-coordinate *based on the string length and desired alignment *rY=reference point... where to align around *align='t','b','c' translates to (top,bottom,center) - *'t' aligned, top of text aligns with rY, + *'t' aligned, top of text aligns with rY, *you get the rest.... */ uint32_t GetTextYCoordinate(u32 font, uint32_t rY, const char* text, const char align) { @@ -405,7 +405,7 @@ uint32_t GetTextYCoordinate(u32 font, uint32_t rY, const char* text, const char } } -/*Automatically gives you the desired x-coordinate +/*Automatically gives you the desired x-coordinate *based on the string length and desired alignment *rX=reference point... where to align around *text=string you want to display diff --git a/common/menu.c b/common/menu.c index 199ada3..9674ec0 100644 --- a/common/menu.c +++ b/common/menu.c @@ -496,7 +496,7 @@ void drawNetwork(int tmpX) { } } -void drawStatus() { +u32 drawStatus() { char timeString[9]; @@ -509,12 +509,14 @@ void drawStatus() { sprintf(timeString, "%02d:%02d:%02d", hours, minutes, seconds); - int tmpX = GetTextXCoordinate(interuimedium20, 1180, timeString, 'r'); + u32 tmpX = GetTextXCoordinate(interuimedium20, 1180, timeString, 'r'); DrawText(interuimedium20, tmpX, 0 + 47 + 10, themeCurrent.textColor, timeString); drawCharge(); drawNetwork(tmpX); + + return tmpX; } void drawButtons(menu_s* menu, bool emptyDir, int *x_image_out) { @@ -603,11 +605,28 @@ void menuLoop(void) { menuTimer += 0.05; drawImage(40, 20, 140, 60, themeCurrent.hbmenuLogoImage, IMAGE_MODE_RGBA32); - DrawText(interuiregular14, 180, 46 + 18, themeCurrent.textColor, VERSION); + DrawText(interuiregular14, 184, 46 + 18, themeCurrent.textColor, VERSION); + u32 statusXPos = drawStatus(); + #ifdef __SWITCH__ AppletType at = appletGetAppletType(); if (at != AppletType_Application && at != AppletType_SystemApplication) { - DrawText(interuimedium30, 640-32, 46 + 18, themeCurrent.attentionTextColor, textGetString(StrId_AppletMode)); + const char* appletMode = textGetString(StrId_AppletMode); + u32 x_pos = GetTextXCoordinate(interuimedium30, statusXPos, appletMode, 'r'); + DrawText(interuimedium30, x_pos - 32, 46 + 18, themeCurrent.attentionTextColor, appletMode); + } + const char* loaderInfo = envGetLoaderInfo(); + if (loaderInfo) { + u32 x_pos = 43; + char* spacePos = strchr(loaderInfo, ' '); + if (spacePos) { + char tempbuf[64] = {0}; + size_t tempsize = spacePos - loaderInfo + 1; + if (tempsize > sizeof(tempbuf)-1) tempsize = sizeof(tempbuf)-1; + memcpy(tempbuf, loaderInfo, tempsize); + x_pos = GetTextXCoordinate(interuiregular14, 184, tempbuf, 'r'); + } + DrawText(interuiregular14, x_pos, 46 + 18 + 20, themeCurrent.textColor, loaderInfo); } #endif @@ -620,8 +639,6 @@ void menuLoop(void) { DrawText(interuiregular14, 180 + 256, 46 + 16 + 18, themeCurrent.textColor, tmpstr); #endif - drawStatus(); - memset(&netloader_state, 0, sizeof(netloader_state)); netloaderGetState(&netloader_state);