From acf15d935f0f5d6493a3b7b0b40b90b96a35dd7d Mon Sep 17 00:00:00 2001 From: root <182859762@qq.com> Date: Sun, 2 Oct 2022 19:26:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8Afilebrowser.c=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=89=8D=E6=99=AF=E8=89=B2=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE=E5=80=BC=E8=80=8C=E4=B8=8D=E6=98=AFrgb565?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/arm11/atp.c | 4 ++-- source/arm11/filebrowser.c | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/source/arm11/atp.c b/source/arm11/atp.c index 691f755..2ecbff1 100644 --- a/source/arm11/atp.c +++ b/source/arm11/atp.c @@ -60,8 +60,8 @@ const char *acf_put_text(int x, int y, int width, int height, int maxwidth, u8 c static void screen_clean() { memset(consoleGet()->frameBuffer, 0, WINDOW_WIDTH*WINDOW_HEIGHT*sizeof(uint16_t)); - acf_put_text( 5, 215, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH-10, ATP_COLOR_BLUE, ATP_PLACEMENT_LEFT, ta ); - acf_put_text( 5, 215, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH-10, ATP_COLOR_BLUE, ATP_PLACEMENT_RIGHT, tb ); + if( ta[0] ) acf_put_text( 5, 215, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH-10, ATP_COLOR_BLUE, ATP_PLACEMENT_LEFT, ta ); + if( tb[0] ) acf_put_text( 5, 215, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH-10, ATP_COLOR_BLUE, ATP_PLACEMENT_RIGHT, tb ); } // wait key pressed, if power key is pressed, return 0 diff --git a/source/arm11/filebrowser.c b/source/arm11/filebrowser.c index c899f0c..a7e516e 100644 --- a/source/arm11/filebrowser.c +++ b/source/arm11/filebrowser.c @@ -59,10 +59,11 @@ typedef struct char *ptrs[MAX_DIR_ENTRIES]; // For fast sorting. } DirList; -const char *acf_put_text(int x, int y, int width, int height, int maxwidth, u8 color, u8 placement, const char* text); +extern const char *acf_put_text(int x, int y, int width, int height, int maxwidth, u8 color, u8 placement, const char* text); + const char *acf_draw(int x, int y, int width, int height, int maxwidth, u8 color, const char* text) { - return atp_put_text(x, y, width, height, maxwidth, color, ATP_PLACEMENT_LEFT, text); + return acf_put_text(x, y, width, height, maxwidth, color, ATP_PLACEMENT_LEFT, text); } static const char *page[] = { @@ -90,7 +91,7 @@ static const char *page[] = { "女儿情长埋葬" }; -static atp_error_t test_show( atp_callerdata_t data, atp_counter_t idx, atp_text_t *ptext, atp_itemval_t *pval, atp_color_t *c, atp_placement_t *p ) +static atp_error_t test_show( atp_callerdata_t , atp_counter_t idx, atp_text_t *ptext, atp_itemval_t *, atp_color_t *, atp_placement_t * ) { if( idx < sizeof(page) ){ *ptext = page[idx]; @@ -184,7 +185,7 @@ static void showDirList(const DirList *const dList, u32 start) //ee_printf(printStr, i - start, &dList->ptrs[i][1]); // TODO: use acf to display const uint8_t fg = *dList -> ptrs[i] == ENT_TYPE_FILE ? 7 : 6; - acf_draw(CLEFTMARGIN, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(fg), &dList->ptrs[i][1] ); + acf_draw(CLEFTMARGIN, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, CLINELIMIT, fg, &dList->ptrs[i][1] ); } } @@ -215,13 +216,13 @@ Result browseFiles(const char *const basePath, char selected[512]) if( oldCursorPos != cursorPos && windowPos <= (u32)oldCursorPos && (u32)oldCursorPos < windowPos + SCREEN_ROWS ) { const uint8_t fg = *dList -> ptrs[oldCursorPos] == ENT_TYPE_FILE ? 7:6; - acf_draw( CLEFTMARGIN, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(fg), &dList->ptrs[oldCursorPos][1] ); + acf_draw( CLEFTMARGIN, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, fg, &dList->ptrs[oldCursorPos][1] ); } - acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(3), &dList->ptrs[cursorPos][1] ); + acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, 3, &dList->ptrs[cursorPos][1] ); } else { //ee_printf("\x1b[%lu;H\x1b[0m>%.51s", cursorPos - windowPos, ""); - acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(7), "" ); + acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, 7, "" ); } u32 kDown; @@ -296,7 +297,12 @@ Result browseFiles(const char *const basePath, char selected[512]) } if( kDown & KEY_X ){ - if( atp_show( 22, test_show, NULL ) == 0 ) goto end; + atp_tips(curDir, NULL); + if( atp_show( 22, test_show, NULL ) == ATP_POWER_OFF ) + { + res = RES_NOT_FOUND; + goto end; + } } }