修正长度超出限定长度不渲染的问题

把filebrowser.c的字面常量变成宏常量
修改了字体文件名
This commit is contained in:
root 2022-08-10 13:26:01 +08:00
parent c7de48e5a0
commit c5e0516ec1
3 changed files with 12 additions and 8 deletions

View File

@ -342,7 +342,10 @@ const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned max
next = next_unicode(utf8_line, &unicode))
{
int error = render_unicode(font, &linex, maxwidth, height, unicode, option, localram);
if (error)
if (error > 0 ) break;
else if(error < 0 ) error = render_unicode(font, &linex, maxwidth, height, '?', option, localram);
if( error )
{
free( localram );
fClose(font);

View File

@ -40,9 +40,11 @@
#define SCREEN_COLS 19
#define SCREEN_ROWS 14u
#define LINENO_TO_Y(y) 4+(y)*15
#define LINENO_TO_Y(y) 15+(y)*15
#define CWIDTH 320u
#define CHEIGHT 240u
#define CLEFTMARGIN 20u
#define CLINELIMIT 282u
#define ENT_TYPE_FILE (0)
#define ENT_TYPE_DIR (1)
@ -140,7 +142,7 @@ static void showDirList(const DirList *const dList, u32 start)
//ee_printf(printStr, i - start, &dList->ptrs[i][1]); // TODO: use acf to display
ee_printf("\x1b[%dm", *dList -> ptrs[i] == ENT_TYPE_FILE ? 37 : 36);
acf_draw(20, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, 292, &dList->ptrs[i][1] );
acf_draw(CLEFTMARGIN, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, CLINELIMIT, &dList->ptrs[i][1] );
}
}
@ -165,22 +167,21 @@ Result browseFiles(const char *const basePath, char selected[512])
s32 oldCursorPos = 0;
while(1)
{
// TODO: use acf to display
if( dList->num > 0 ){
//ee_printf(*dList->ptrs[oldCursorPos] == ENT_TYPE_FILE ? "\x1b[%lu;H\x1b[37m %.51s" : "\x1b[%lu;H\x1b[36m %.51s", oldCursorPos - windowPos, &dList->ptrs[oldCursorPos][1]); // Clear old cursor.
//ee_printf("\x1b[%lu;H\x1b[33m>%.51s", cursorPos - windowPos, &dList->ptrs[cursorPos][1]); // Draw cursor.
if( oldCursorPos != cursorPos )
{
ee_printf("\x1b[%dm", *dList -> ptrs[oldCursorPos] == ENT_TYPE_FILE ? 37:36);
acf_draw( 20, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, 292, &dList->ptrs[oldCursorPos][1] );
acf_draw( CLEFTMARGIN, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, &dList->ptrs[oldCursorPos][1] );
}
ee_printf("\x1b[33m");
acf_draw( 20, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, 292, &dList->ptrs[cursorPos][1] );
acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, &dList->ptrs[cursorPos][1] );
}
else {
//ee_printf("\x1b[%lu;H\x1b[0m>%.51s", cursorPos - windowPos, "<no gba rom>");
ee_printf("\x1b[0m");
acf_draw( 20, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, 292, "<NO GBA ROM>" );
acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, "<NO GBA ROM>" );
}
u32 kDown;

View File

@ -684,7 +684,7 @@ Result oafParseConfigEarly(void)
// Create the saves folder.
if((res = fMkdir(OAF_SAVE_DIR)) != RES_OK && res != RES_FR_EXIST) break;
if((res = acf_set_font("wqy11.acf")) != RES_OK ) break;
if((res = acf_set_font("wqy11.fnt")) != RES_OK ) break;
// Parse the config.
res = parseOafConfig("config.ini", true);