Use shared-font. Setting s_textLang is still disabled, until language.c is updated. Check for setsysInitialize failure. Moved .nxfnt files into data/unused/. Currently text will not display with the pc-build since no font is loaded for it. Disabled y+=baseline in text-drawing, and adjusted all callers y-pos to manually add the original baseline (so that y-pos matches with the different font).

This commit is contained in:
yellows8 2018-04-28 11:53:47 -04:00
parent 4563794505
commit 1e232372d2
17 changed files with 257 additions and 68 deletions

View File

@ -44,7 +44,7 @@ DIST_PATH := $(TARGET)_v$(APP_VERSION)
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O2 -ffunction-sections \ CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES) $(ARCH) $(DEFINES) `freetype-config --cflags`
CFLAGS += $(INCLUDE) -D__SWITCH__ -DVERSION=\"v$(APP_VERSION)\" CFLAGS += $(INCLUDE) -D__SWITCH__ -DVERSION=\"v$(APP_VERSION)\"
@ -53,7 +53,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lnx -lm -lz LIBS := `freetype-config --libs`
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing # list of directories containing libraries, this must be the top level containing

View File

@ -23,11 +23,10 @@ test : pc_main/main.cpp pc_main/pc_launch.c \
common/menu-entry.c common/menu-list.c common/message-box.c common/text.c \ common/menu-entry.c common/menu-list.c common/message-box.c common/text.c \
common/nanojpeg.c common/ui.c common/math.c common/theme.c \ common/nanojpeg.c common/ui.c common/math.c common/theme.c \
common/netloader.c \ common/netloader.c \
build_pc/tahoma24.o build_pc/tahoma12.o build_pc/interuimedium20.o build_pc/interuimedium30.o \
build_pc/interuiregular14.o build_pc/interuiregular18.o \
build_pc/invalid_icon.bin.o build_pc/folder_icon.bin.o \ build_pc/invalid_icon.bin.o build_pc/folder_icon.bin.o \
build_pc/button_a_light.bin.o build_pc/button_a_dark.bin.o build_pc/button_b_light.bin.o build_pc/button_b_dark.bin.o build_pc/hbmenu_logo_light.bin.o build_pc/hbmenu_logo_dark.bin.o build_pc/button_a_light.bin.o build_pc/button_a_dark.bin.o build_pc/button_b_light.bin.o build_pc/button_b_dark.bin.o build_pc/hbmenu_logo_light.bin.o build_pc/hbmenu_logo_dark.bin.o \
gcc -Wall -O2 -g -DVERSION=\"v$(APP_VERSION)\" $(EXTRA_CFLAGS) $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ -lm -lz $(EXTRA_LDFLAGS) -I. -iquote $(DEVKITPRO)/libnx/include -Ibuild_pc -g -o $@ #build_pc/tahoma24.o build_pc/tahoma12.o build_pc/interuimedium20.o build_pc/interuimedium30.o build_pc/interuiregular14.o build_pc/interuiregular18.o
gcc -Wall -O2 -g -DVERSION=\"v$(APP_VERSION)\" $(EXTRA_CFLAGS) `freetype-config --cflags` $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ `freetype-config --libs` -lm -lz $(EXTRA_LDFLAGS) -I. -iquote $(DEVKITPRO)/libnx/include -Ibuild_pc -g -o $@
build_pc/tahoma12.o : data/tahoma12.nxfnt build_pc/tahoma12.o : data/tahoma12.nxfnt
mkdir -p $(dir $@) mkdir -p $(dir $@)

View File

@ -22,6 +22,7 @@
typedef uint8_t u8; typedef uint8_t u8;
typedef uint32_t u32; typedef uint32_t u32;
typedef uint64_t u64; typedef uint64_t u64;
typedef u32 Result;
#ifdef _WIN32 #ifdef _WIN32
@ -42,6 +43,12 @@ typedef union {
}; };
} color_t; } color_t;
// when building for pc we need to include these separately
#ifndef __SWITCH__
#include "switch/nro.h"
#include "switch/nacp.h"
#endif
#include "font.h" #include "font.h"
#include "menu.h" #include "menu.h"
#include "text.h" #include "text.h"
@ -51,12 +58,6 @@ typedef union {
#include "math.h" #include "math.h"
#include "theme.h" #include "theme.h"
// when building for pc we need to include these separately
#ifndef __SWITCH__
#include "switch/nro.h"
#include "switch/nacp.h"
#endif
void menuStartup(); void menuStartup();
void menuLoop(); void menuLoop();
@ -147,6 +148,9 @@ static inline color_t FetchPixelColor(uint32_t x, uint32_t y)
#endif #endif
void DrawPixel(uint32_t x, uint32_t y, color_t clr); void DrawPixel(uint32_t x, uint32_t y, color_t clr);
void DrawText(const ffnt_header_t* font, uint32_t x, uint32_t y, color_t clr, const char* text); void DrawText(u32 font, uint32_t x, uint32_t y, color_t clr, const char* text);
void DrawTextTruncate(const ffnt_header_t* font, uint32_t x, uint32_t y, color_t clr, const char* text, uint32_t max_width, const char* end_text); void DrawTextTruncate(u32 font, uint32_t x, uint32_t y, color_t clr, const char* text, uint32_t max_width, const char* end_text);
void GetTextDimensions(const ffnt_header_t* font, const char* text, uint32_t* width_out, uint32_t* height_out); void GetTextDimensions(u32 font, const char* text, uint32_t* width_out, uint32_t* height_out);
bool fontInitialize(void);
void fontExit();

View File

@ -1,6 +1,65 @@
#include "common.h" #include "common.h"
static inline const ffnt_page_t* FontGetPage(const ffnt_header_t* font, uint32_t page_id) #include <ft2build.h>
#include FT_FREETYPE_H
#ifdef __SWITCH__
#define FONT_FACES_MAX PlSharedFontType_Total
#else
#define FONT_FACES_MAX 1
#endif
static FT_Error s_font_libret=1, s_font_facesret[FONT_FACES_MAX];
static FT_Library s_font_library;
static FT_Face s_font_faces[FONT_FACES_MAX];
static FT_Face s_font_lastusedface;
static size_t s_font_faces_total = 0;
static bool FontSetType(u32 font)
{
u32 i=0;
u32 scale=0;
FT_Error ret=0;
switch(font)
{
case interuiregular14:
scale = 4;
break;
case interuiregular18:
scale = 5;
break;
case interuimedium20:
scale = 6;
break;
case interuimedium30:
scale = 8;
break;
default:
return false;
break;
}
for (i=0; i<s_font_faces_total; i++) {
ret = FT_Set_Char_Size(
s_font_faces[i], /* handle to face object */
0, /* char_width in 1/64th of points */
scale*64, /* char_height in 1/64th of points */
300, /* horizontal device resolution */
300); /* vertical device resolution */
if (ret) return false;
}
return true;
}
/*static inline const ffnt_page_t* FontGetPage(const ffnt_header_t* font, uint32_t page_id)
{ {
//__builtin_printf("GetPage %u\n", (unsigned int)page_id); //__builtin_printf("GetPage %u\n", (unsigned int)page_id);
if (page_id >= font->npages) if (page_id >= font->npages)
@ -9,27 +68,69 @@ static inline const ffnt_page_t* FontGetPage(const ffnt_header_t* font, uint32_t
if (ent->size == 0) if (ent->size == 0)
return NULL; return NULL;
return (const ffnt_page_t*)((const uint8_t*)font + ent->offset); return (const ffnt_page_t*)((const uint8_t*)font + ent->offset);
} }*/
static inline bool FontLoadGlyph(glyph_t* glyph, const ffnt_header_t* font, uint32_t codepoint) static inline bool FontLoadGlyph(glyph_t* glyph, u32 font, uint32_t codepoint)
{ {
FT_Face face;
FT_Error ret=0;
FT_GlyphSlot slot;
FT_UInt glyph_index;
FT_Bitmap* bitmap;
u32 i=0;
//__builtin_printf("LoadGlyph %u\n", (unsigned int)codepoint); //__builtin_printf("LoadGlyph %u\n", (unsigned int)codepoint);
const ffnt_page_t* page = FontGetPage(font, codepoint >> 8); /*const ffnt_page_t* page = FontGetPage(font, codepoint >> 8);
if (!page) if (!page)
return false; return false;
codepoint &= 0xFF; codepoint &= 0xFF;
uint32_t off = page->hdr.pos[codepoint]; uint32_t off = page->hdr.pos[codepoint];
if (off == ~(uint32_t)0) if (off == ~(uint32_t)0)
return false; return false;*/
if (s_font_faces_total==0) return false;
for (i=0; i<s_font_faces_total; i++) {
face = s_font_faces[i];
s_font_lastusedface = face;
glyph_index = FT_Get_Char_Index(face, codepoint);
if (glyph_index==0) continue;
ret = FT_Load_Glyph(
face, /* handle to face object */
glyph_index, /* glyph index */
FT_LOAD_DEFAULT);
if (ret==0)
{
ret = FT_Render_Glyph( face->glyph, /* glyph slot */
FT_RENDER_MODE_NORMAL); /* render mode */
}
if (ret) return false;
break;
}
slot = face->glyph;
bitmap = &slot->bitmap;
//__builtin_printf("%c %u\n", (char)codepoint, (unsigned int)off); //__builtin_printf("%c %u\n", (char)codepoint, (unsigned int)off);
glyph->width = page->hdr.widths[codepoint]; /*glyph->width = page->hdr.widths[codepoint];
glyph->height = page->hdr.heights[codepoint]; glyph->height = page->hdr.heights[codepoint];
glyph->advance = page->hdr.advances[codepoint]; glyph->advance = page->hdr.advances[codepoint];
glyph->posX = page->hdr.posX[codepoint]; glyph->posX = page->hdr.posX[codepoint];
glyph->posY = page->hdr.posY[codepoint]; glyph->posY = page->hdr.posY[codepoint];
glyph->data = &page->data[off]; glyph->data = &page->data[off];*/
glyph->width = bitmap->width;
glyph->height = bitmap->rows;
glyph->pitch = bitmap->pitch;
glyph->data = bitmap->buffer;
glyph->advance = slot->advance.x >> 6;
glyph->posX = slot->bitmap_left;
glyph->posY = slot->bitmap_top;
return true; return true;
} }
@ -38,16 +139,17 @@ static void DrawGlyph(uint32_t x, uint32_t y, color_t clr, const glyph_t* glyph)
uint32_t i, j; uint32_t i, j;
const uint8_t* data = glyph->data; const uint8_t* data = glyph->data;
x += glyph->posX; x += glyph->posX;
y += glyph->posY; y -= glyph->posY; //y += glyph->posY;
//__builtin_printf("DrawGlyph %u %u %08X\n", (unsigned int)x, (unsigned int)y, (unsigned int)clr.abgr); //__builtin_printf("DrawGlyph %u %u %08X\n", (unsigned int)x, (unsigned int)y, (unsigned int)clr.abgr);
for (j = 0; j < glyph->height; j ++) for (j = 0; j < glyph->height; j ++)
{ {
for (i = 0; i < glyph->width; i ++) for (i = 0; i < glyph->width; i ++)
{ {
clr.a = *data++; clr.a = data[i];
if (!clr.a) continue; if (!clr.a) continue;
DrawPixel(x+i, y+j, clr); DrawPixel(x+i, y+j, clr);
} }
data+= glyph->pitch;
} }
} }
@ -118,11 +220,15 @@ static inline uint32_t DecodeUTF8(const char** ptr)
return 0xFFFD; return 0xFFFD;
} }
static void DrawText_(const ffnt_header_t* font, uint32_t x, uint32_t y, color_t clr, const char* text, uint32_t max_width, const char* end_text) static void DrawText_(u32 font, uint32_t x, uint32_t y, color_t clr, const char* text, uint32_t max_width, const char* end_text)
{ {
//__builtin_printf("DrawText %u %u %08X %s\n", (unsigned int)x, (unsigned int)y, (unsigned int)clr.abgr, text); //__builtin_printf("DrawText %u %u %08X %s\n", (unsigned int)x, (unsigned int)y, (unsigned int)clr.abgr, text);
y += font->baseline; //y += font->baseline;
uint32_t origX = x; uint32_t origX = x;
if (s_font_faces_total==0) return;
if (!FontSetType(font)) return;
s_font_lastusedface = s_font_faces[0];
while (*text) while (*text)
{ {
if (max_width && x-origX >= max_width) { if (max_width && x-origX >= max_width) {
@ -142,7 +248,7 @@ static void DrawText_(const ffnt_header_t* font, uint32_t x, uint32_t y, color_t
} }
x = origX; x = origX;
y += font->height; y += s_font_lastusedface->size->metrics.height / 64;
continue; continue;
} }
@ -157,20 +263,24 @@ static void DrawText_(const ffnt_header_t* font, uint32_t x, uint32_t y, color_t
} }
} }
void DrawText(const ffnt_header_t* font, uint32_t x, uint32_t y, color_t clr, const char* text) void DrawText(u32 font, uint32_t x, uint32_t y, color_t clr, const char* text)
{ {
DrawText_(font, x, y, clr, text, 0, NULL); DrawText_(font, x, y, clr, text, 0, NULL);
} }
void DrawTextTruncate(const ffnt_header_t* font, uint32_t x, uint32_t y, color_t clr, const char* text, uint32_t max_width, const char* end_text) void DrawTextTruncate(u32 font, uint32_t x, uint32_t y, color_t clr, const char* text, uint32_t max_width, const char* end_text)
{ {
DrawText_(font, x, y, clr, text, max_width, end_text); DrawText_(font, x, y, clr, text, max_width, end_text);
} }
void GetTextDimensions(const ffnt_header_t* font, const char* text, uint32_t* width_out, uint32_t* height_out) void GetTextDimensions(u32 font, const char* text, uint32_t* width_out, uint32_t* height_out)
{ {
uint32_t x = 0; uint32_t x = 0;
uint32_t width = 0, height = 0; uint32_t width = 0, height = 0;
if (s_font_faces_total==0) return;
if (!FontSetType(font)) return;
s_font_lastusedface = s_font_faces[0];
while (*text) while (*text)
{ {
glyph_t glyph; glyph_t glyph;
@ -179,7 +289,7 @@ void GetTextDimensions(const ffnt_header_t* font, const char* text, uint32_t* wi
if (codepoint == '\n') if (codepoint == '\n')
{ {
x = 0; x = 0;
height += font->height; height += s_font_lastusedface->size->metrics.height / 64;
continue; continue;
} }
@ -198,3 +308,51 @@ void GetTextDimensions(const ffnt_header_t* font, const char* text, uint32_t* wi
*width_out = width; *width_out = width;
*height_out = height; *height_out = height;
} }
bool fontInitialize(void)
{
FT_Error ret=0;
u32 i;
for (i=0; i<FONT_FACES_MAX; i++) s_font_facesret[i] = 1;
ret = FT_Init_FreeType(&s_font_library);
s_font_libret = ret;
if (s_font_libret) return false;
#ifdef __SWITCH__
PlFontData fonts[PlSharedFontType_Total];
Result rc=0;
rc = plGetSharedFont(textGetLanguageCode(), fonts, FONT_FACES_MAX, &s_font_faces_total);
if (R_FAILED(rc)) return false;
for (i=0; i<s_font_faces_total; i++) {
ret = FT_New_Memory_Face( s_font_library,
fonts[i].address, /* first byte in memory */
fonts[i].size, /* size in bytes */
0, /* face_index */
&s_font_faces[i]);
s_font_facesret[i] = ret;
if (ret) return false;
}
#endif
#ifndef __SWITCH__
//TODO: How to handle this? Until this is impl'd no font will be displayed for pc-build.
#endif
return true;
}
void fontExit()
{
u32 i=0;
for (i=0; i<s_font_faces_total; i++)
if (s_font_facesret[i]==0) FT_Done_Face(s_font_faces[i]);
if (s_font_libret==0) FT_Done_FreeType(s_font_library);
}

View File

@ -26,19 +26,19 @@ typedef struct {
typedef struct { typedef struct {
uint8_t width, height; uint8_t width, height;
int8_t posX, posY, advance; int8_t posX, posY, advance, pitch;
const uint8_t* data; const uint8_t* data;
} glyph_t; } glyph_t;
extern const ffnt_header_t tahoma24_nxfnt; //extern const ffnt_header_t tahoma24_nxfnt;//These tahoma fonts aren't used anymore.
extern const ffnt_header_t tahoma12_nxfnt; //extern const ffnt_header_t tahoma12_nxfnt;
extern const ffnt_header_t interuimedium20_nxfnt; /*extern const ffnt_header_t interuimedium20_nxfnt;
extern const ffnt_header_t interuimedium30_nxfnt; extern const ffnt_header_t interuimedium30_nxfnt;
extern const ffnt_header_t interuiregular14_nxfnt; extern const ffnt_header_t interuiregular14_nxfnt;
extern const ffnt_header_t interuiregular18_nxfnt; extern const ffnt_header_t interuiregular18_nxfnt;*/
#define tahoma24 &tahoma24_nxfnt //#define tahoma24 &tahoma24_nxfnt
#define tahoma12 &tahoma12_nxfnt //#define tahoma12 &tahoma12_nxfnt
#define interuimedium20 &interuimedium20_nxfnt #define interuimedium20 2//&interuimedium20_nxfnt
#define interuimedium30 &interuimedium30_nxfnt #define interuimedium30 3//&interuimedium30_nxfnt
#define interuiregular14 &interuiregular14_nxfnt #define interuiregular14 0//&interuiregular14_nxfnt
#define interuiregular18 &interuiregular18_nxfnt #define interuiregular18 1//&interuiregular18_nxfnt

View File

@ -457,14 +457,25 @@ uint8_t *downscaleImg(const uint8_t *image, int srcWidth, int srcHeight, int des
} }
void menuEntryParseNacp(menuEntry_s* me) { void menuEntryParseNacp(menuEntry_s* me) {
int lang = 0;//TODO: Update this once libnx supports settings get-language. NacpLanguageEntry *langentry = NULL;
if (me->nacp==NULL) return; if (me->nacp==NULL) return;
strncpy(me->name, me->nacp->lang[lang].name, sizeof(me->name)-1);
strncpy(me->author, me->nacp->lang[lang].author, sizeof(me->author)-1);
strncpy(me->version, me->nacp->version, sizeof(me->version)-1); strncpy(me->version, me->nacp->version, sizeof(me->version)-1);
#ifdef __SWITCH__
Result rc=0;
rc = nacpGetLanguageEntry(me->nacp, &langentry);
if (R_SUCCEEDED(rc) && langentry!=NULL) {
#else
langentry = &me->nacp->lang[0];
if (1) {
#endif
strncpy(me->name, langentry->name, sizeof(me->name)-1);
strncpy(me->author, langentry->author, sizeof(me->author)-1);
}
free(me->nacp); free(me->nacp);
me->nacp = NULL; me->nacp = NULL;
} }

View File

@ -206,21 +206,21 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
} }
} }
DrawTextTruncate(interuiregular14, start_x + 4, start_y + 4, MakeColor(64, 64, 64, 255), me->name, 140 - 32, "..."); DrawTextTruncate(interuiregular14, start_x + 4, start_y + 4 + 18, MakeColor(64, 64, 64, 255), me->name, 140 - 32, "...");
if (is_active) { if (is_active) {
start_x = 1280 - 790; start_x = 1280 - 790;
start_y = 135; start_y = 135;
DrawTextTruncate(interuimedium30, start_x, start_y, themeCurrent.textColor, me->name, 1280 - start_x - 120 ,"..."); DrawTextTruncate(interuimedium30, start_x, start_y + 39, themeCurrent.textColor, me->name, 1280 - start_x - 120 ,"...");
if (me->type != ENTRY_TYPE_FOLDER) { if (me->type != ENTRY_TYPE_FOLDER) {
memset(tmpstr, 0, sizeof(tmpstr)); memset(tmpstr, 0, sizeof(tmpstr));
snprintf(tmpstr, sizeof(tmpstr)-1, "%s: %s", textGetString(StrId_AppInfo_Author), me->author); snprintf(tmpstr, sizeof(tmpstr)-1, "%s: %s", textGetString(StrId_AppInfo_Author), me->author);
DrawText(interuiregular14, start_x, start_y + 28 + 30, themeCurrent.textColor, tmpstr); DrawText(interuiregular14, start_x, start_y + 28 + 30 + 18, themeCurrent.textColor, tmpstr);
memset(tmpstr, 0, sizeof(tmpstr)); memset(tmpstr, 0, sizeof(tmpstr));
snprintf(tmpstr, sizeof(tmpstr)-1, "%s: %s", textGetString(StrId_AppInfo_Version), me->version); snprintf(tmpstr, sizeof(tmpstr)-1, "%s: %s", textGetString(StrId_AppInfo_Version), me->version);
DrawText(interuiregular14, start_x, start_y + 28 + 30 + 18 + 6, themeCurrent.textColor, tmpstr); DrawText(interuiregular14, start_x, start_y + 28 + 30 + 18 + 6 + 18, themeCurrent.textColor, tmpstr);
} }
} }
} }
@ -322,7 +322,7 @@ void drawTime() {
sprintf(timeString, "%02d:%02d:%02d", hours, minutes, seconds); sprintf(timeString, "%02d:%02d:%02d", hours, minutes, seconds);
DrawText(interuimedium20, 1280 - (9 * 16) - 30, 30, MakeColor(255, 255, 255, 255), timeString); DrawText(interuimedium20, 1280 - (9 * 16) - 30, 30 + 26, MakeColor(255, 255, 255, 255), timeString);
} }
@ -342,7 +342,7 @@ void drawBackBtn(menu_s* menu, bool emptyDir) {
#endif #endif
{ {
drawImage(x_image, 720 - 48, 32, 32, themeCurrent.buttonBImage, IMAGE_MODE_RGBA32); drawImage(x_image, 720 - 48, 32, 32, themeCurrent.buttonBImage, IMAGE_MODE_RGBA32);
DrawText(interuimedium20, x_text, 720 - 47, themeCurrent.textColor, textGetString(StrId_Actions_Back)); DrawText(interuimedium20, x_text, 720 - 47 + 26, themeCurrent.textColor, textGetString(StrId_Actions_Back));
} }
} }
@ -364,8 +364,8 @@ void menuLoop() {
menuTimer += 0.05; menuTimer += 0.05;
drawImage(40, 20, 140, 60, themeCurrent.hbmenuLogoImage, IMAGE_MODE_RGBA32); drawImage(40, 20, 140, 60, themeCurrent.hbmenuLogoImage, IMAGE_MODE_RGBA32);
DrawText(interuiregular14, 180, 46, themeCurrent.textColor, VERSION); DrawText(interuiregular14, 180, 46 + 18, themeCurrent.textColor, VERSION);
DrawTextTruncate(interuiregular18, 40, 720 - 47, themeCurrent.textColor, menu->dirname, 918, "..."); DrawTextTruncate(interuiregular18, 40, 720 - 47 + 24, themeCurrent.textColor, menu->dirname, 918, "...");
#ifdef PERF_LOG_DRAW//Seperate from the PERF_LOG define since this might affect perf. #ifdef PERF_LOG_DRAW//Seperate from the PERF_LOG define since this might affect perf.
extern u64 g_tickdiff_vsync; extern u64 g_tickdiff_vsync;
@ -374,10 +374,10 @@ void menuLoop() {
char tmpstr[64]; char tmpstr[64];
snprintf(tmpstr, sizeof(tmpstr)-1, "%lu", g_tickdiff_vsync); snprintf(tmpstr, sizeof(tmpstr)-1, "%lu", g_tickdiff_vsync);
DrawText(interuiregular14, 180 + 256, 46, themeCurrent.textColor, tmpstr); DrawText(interuiregular14, 180 + 256, 46 + 18, themeCurrent.textColor, tmpstr);
snprintf(tmpstr, sizeof(tmpstr)-1, "%lu", g_tickdiff_frame); snprintf(tmpstr, sizeof(tmpstr)-1, "%lu", g_tickdiff_frame);
DrawText(interuiregular14, 180 + 256, 46 + 16, themeCurrent.textColor, tmpstr); DrawText(interuiregular14, 180 + 256, 46 + 16 + 18, themeCurrent.textColor, tmpstr);
#endif #endif
//drawTime(); //drawTime();
@ -397,7 +397,7 @@ void menuLoop() {
} }
} }
} else { } else {
DrawText(interuiregular14, 64, 128, themeCurrent.textColor, textGetString(StrId_NoAppsFound_Msg)); DrawText(interuiregular14, 64, 128 + 18, themeCurrent.textColor, textGetString(StrId_NoAppsFound_Msg));
} }
drawBackBtn(menu, true); drawBackBtn(menu, true);
} }
@ -437,11 +437,11 @@ void menuLoop() {
if(active_entry != NULL) { if(active_entry != NULL) {
if (active_entry->type != ENTRY_TYPE_FOLDER) { if (active_entry->type != ENTRY_TYPE_FOLDER) {
drawImage(1280 - 126 - 30 - 32, 720 - 48, 32, 32, themeCurrent.buttonAImage, IMAGE_MODE_RGBA32); drawImage(1280 - 126 - 30 - 32, 720 - 48, 32, 32, themeCurrent.buttonAImage, IMAGE_MODE_RGBA32);
DrawText(interuiregular18, 1280 - 90 - 30 - 32, 720 - 47, themeCurrent.textColor, textGetString(StrId_Actions_Launch)); DrawText(interuiregular18, 1280 - 90 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, textGetString(StrId_Actions_Launch));
} }
else { else {
drawImage(1280 - 126 - 30 - 32, 720 - 48, 32, 32, themeCurrent.buttonAImage, IMAGE_MODE_RGBA32); drawImage(1280 - 126 - 30 - 32, 720 - 48, 32, 32, themeCurrent.buttonAImage, IMAGE_MODE_RGBA32);
DrawText(interuiregular18, 1280 - 90 - 30 - 32, 720 - 47, themeCurrent.textColor, textGetString(StrId_Actions_Open)); DrawText(interuiregular18, 1280 - 90 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, textGetString(StrId_Actions_Open));
} }
} }

View File

@ -127,7 +127,7 @@ void menuDrawMsgBox() {
DrawText(interuiregular18, start_x + (currMsgBox.width - text_width) / 2, start_y + (currMsgBox.height - text_height - 80) / 2, MakeColor(0, 0, 0, 255), currMsgBox.text); DrawText(interuiregular18, start_x + (currMsgBox.width - text_width) / 2, start_y + (currMsgBox.height - text_height - 80) / 2, MakeColor(0, 0, 0, 255), currMsgBox.text);
} }
DrawText(interuimedium20, start_x + 365, start_y + 245, MakeColor(0, 0, 0, 255), textGetString(StrId_MsgBox_OK)); DrawText(interuimedium20, start_x + 365, start_y + 245 + 26, MakeColor(0, 0, 0, 255), textGetString(StrId_MsgBox_OK));
shadow_start_y = start_y + currMsgBox.height; shadow_start_y = start_y + currMsgBox.height;

View File

@ -1,5 +1,7 @@
#include "text.h" #include "text.h"
static u64 s_textLanguageCode = 0;
#ifdef __SWITCH__ #ifdef __SWITCH__
static int s_textLang = SetLanguage_ENUS; static int s_textLang = SetLanguage_ENUS;
#else #else
@ -8,16 +10,16 @@ static int s_textLang = 1;
void textInit(void) { void textInit(void) {
#ifdef __SWITCH__ #ifdef __SWITCH__
//u64 LanguageCode=0; s32 Language=0;
//s32 Language=0;
s_textLang = SetLanguage_ENUS; s_textLang = SetLanguage_ENUS;
//TODO: Re-enable this once the font supports all used languages.
/*Result rc = setInitialize(); Result rc = setInitialize();
if (R_SUCCEEDED(rc)) rc = setGetSystemLanguage(&LanguageCode); if (R_SUCCEEDED(rc)) rc = setGetSystemLanguage(&s_textLanguageCode);
if (R_SUCCEEDED(rc)) rc = setMakeLanguage(LanguageCode, &Language); if (R_SUCCEEDED(rc)) rc = setMakeLanguage(s_textLanguageCode, &Language);
if (R_SUCCEEDED(rc) && Language < 16) s_textLang = Language; //if (R_SUCCEEDED(rc) && Language < 16) s_textLang = Language;//TODO: Re-enable this once language.c supports all used languages.
setExit();*/ setExit();
if (R_FAILED(rc)) fatalSimple(-8);
#else #else
s_textLang = 1; s_textLang = 1;
#endif #endif
@ -36,3 +38,7 @@ const char* textGetString(StrId id) {
#endif #endif
return str; return str;
} }
u64 textGetLanguageCode(void) {
return s_textLanguageCode;
}

View File

@ -5,3 +5,4 @@
void textInit(void); void textInit(void);
int textGetLang(void); int textGetLang(void);
const char* textGetString(StrId id); const char* textGetString(StrId id);
u64 textGetLanguageCode(void);

View File

@ -20,6 +20,7 @@ void audio_exit(void);
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
Result lastret=0; Result lastret=0;
Result rc=0;
char msg[256]; char msg[256];
#ifdef PERF_LOG #ifdef PERF_LOG
@ -31,13 +32,20 @@ int main(int argc, char **argv)
appletSetScreenShotPermission(1); appletSetScreenShotPermission(1);
ColorSetId theme; ColorSetId theme;
setsysInitialize(); rc = setsysInitialize();
if (R_FAILED(rc)) fatalSimple(-5);
setsysGetColorSetId(&theme); setsysGetColorSetId(&theme);
rc = plInitialize();
if (R_FAILED(rc)) fatalSimple(-6);
themeStartup((ThemePreset)theme); themeStartup((ThemePreset)theme);
textInit(); textInit();
menuStartup(); menuStartup();
launchInit(); launchInit();
if (!fontInitialize()) fatalSimple(-7);
#ifdef ENABLE_AUDIO #ifdef ENABLE_AUDIO
audio_initialize(); audio_initialize();
@ -88,7 +96,9 @@ int main(int argc, char **argv)
audio_exit(); audio_exit();
#endif #endif
fontExit();
launchExit(); launchExit();
plExit();
setsysExit(); setsysExit();
gfxExit(); gfxExit();