From a70e71706580e6d70d9068910714273869cc5c24 Mon Sep 17 00:00:00 2001 From: w3irDv <170813473+w3irDv@users.noreply.github.com> Date: Tue, 24 Sep 2024 23:30:24 +0200 Subject: [PATCH] enh - draw keys in keyboard --- include/utils/Colors.h | 5 +++-- include/utils/DrawUtils.h | 1 + romfs/languages/SChinese.json | 2 +- romfs/languages/english.json | 13 ++++++------- romfs/languages/japanese.json | 5 +++-- src/menu/BackupSetListState.cpp | 6 +++--- src/menu/KeyboardState.cpp | 5 ++++- src/menu/TitleOptionsState.cpp | 11 +++++++---- src/utils/DrawUtils.cpp | 7 +++++++ src/utils/KeyboardUtils.cpp | 5 ++++- 10 files changed, 39 insertions(+), 21 deletions(-) diff --git a/include/utils/Colors.h b/include/utils/Colors.h index 6709168..a51198e 100644 --- a/include/utils/Colors.h +++ b/include/utils/Colors.h @@ -7,5 +7,6 @@ #define COLOR_LIST_HIGH Color(0x40D050FF) #define COLOR_LIST Color(0x00FF00FF) #define COLOR_INFO Color(0x88CC88FF) -#define COLOR_KEY Color(0xFF6666FF) -#define COLOR_KEY_S Color(0xFF666600) \ No newline at end of file +#define COLOR_KEY Color(0xFF3333FF) +#define COLOR_KEY_S Color(0xFF666600) +#define COLOR_KEY_C Color(0xFF0000FF) \ No newline at end of file diff --git a/include/utils/DrawUtils.h b/include/utils/DrawUtils.h index a75d292..ed5c226 100644 --- a/include/utils/DrawUtils.h +++ b/include/utils/DrawUtils.h @@ -81,6 +81,7 @@ class DrawUtils { static uint32_t deinitScreen(); + static void drawKey(int x,int y,int x_off,Color color); diff --git a/romfs/languages/SChinese.json b/romfs/languages/SChinese.json index 47857af..9510358 100644 --- a/romfs/languages/SChinese.json +++ b/romfs/languages/SChinese.json @@ -93,7 +93,7 @@ "Failed to delete savefile.": "删除保存数据失败。", "Failed to delete user folder: %s": "删除user文件夹失败: %s", "Failed to import savedata from loadiine.": "导入loadiine保存数据失败。", - "Failed to export savedata to loadiine.": "导出保存数据到loadiine失败。" + "Failed to export savedata to loadiine.": "导出保存数据到loadiine失败。", "\ue083 Sort: %s \ue084": "\ue083 排序: %s \ue084", "\ue000: Select BackupSet \ue001: Back": "\ue000: 选择备份设置 \ue001: 备份", "\ue002: Change BackupSet \ue000: Restore \ue001: Back": "\ue002: 更改备份设置 \ue000: 恢复 \ue001: 备份", diff --git a/romfs/languages/english.json b/romfs/languages/english.json index 7c61215..006a8bc 100644 --- a/romfs/languages/english.json +++ b/romfs/languages/english.json @@ -52,7 +52,7 @@ "\ue000: Import \ue001: Back": "\ue000: Import \ue001: Back", "\ue000: Export \ue001: Back": "\ue000: Export \ue001: Back", "\ue000: Copy \ue001: Back": "\ue000: Copy \ue001: Back", - "Press \ue044 to exit.": "Press \ue044 to exit.", + "Press \ue044 to exit.": "\ue044 Exit", "No Wii U titles found.": "No Wii U titles found.", "No vWii saves found.": "No vWii saves found.", "CBHC save. Could be dangerous to modify. Continue?": "CBHC save. Could be dangerous to modify. Continue?", @@ -134,13 +134,12 @@ "Tasks": "Tasks", "Initializing BackupSets metadata.": "Initializing BackupSets metadata.", "Please wait. First write to SD may be slow.": "Please wait. First write to SD may be slow.", - "1234567890-=": "1234567890-=", - "KB_N_0": "1234567890-= ", + "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", - "KB_N_2": "asdfghjkl;' ", - "KB_N_3": "zxcvbnm ,./ ", + "KB_N_2": "asdfghjkl;'", + "KB_N_3": "zxcvbnm ,./", "KB_S_0": "!@#$%^&*()_+~", "KB_S_1": "QWERTYUIOP{}\\", - "KB_S_2": "ASDFGHJKL:\" ", - "KB_S_3": "ZXCVBNM <> " + "KB_S_2": "ASDFGHJKL:\"", + "KB_S_3": "ZXCVBNM <>" } \ No newline at end of file diff --git a/romfs/languages/japanese.json b/romfs/languages/japanese.json index dfa1809..98d59fc 100644 --- a/romfs/languages/japanese.json +++ b/romfs/languages/japanese.json @@ -95,6 +95,7 @@ "Failed to delete user folder: %s": "ユーザー フォルダの削除に失敗しました: %s", "Failed to import savedata from loadiine.": "loadiine からセーブデータをインポートできませんでした。", "Failed to export savedata to loadiine.": "セーブデータを loadiine にエクスポートできませんでした。", - "KB_N_0": "セーブデータを load", - "KB_S_1": "うーん、本当によろしいです" + "\ue001: Back": "\ue001: 戻る", + "KB_N_0": "セーブデータを TEST", + "KB_S_1": "うーん、本当によろし TEST" } \ No newline at end of file diff --git a/src/menu/BackupSetListState.cpp b/src/menu/BackupSetListState.cpp index 1c8b1dc..ffa51ca 100644 --- a/src/menu/BackupSetListState.cpp +++ b/src/menu/BackupSetListState.cpp @@ -65,9 +65,9 @@ void BackupSetListState::render() { DrawUtils::setFontColor(COLOR_LIST_HIGH); if ( backupSetItem == BackupSetList::getBackupSetEntry()) DrawUtils::setFontColor(COLOR_INFO); - consolePrintPos(M_OFF, i + 2, " %s", backupSetItem.c_str()); - consolePrintPos(24, i+2,"%s", BackupSetList::currentBackupSetList->getStretchedSerialIdAt(i+scroll).c_str()); - consolePrintPos(38, i+2,"%s", BackupSetList::currentBackupSetList->getTagAt(i+scroll).c_str()); + consolePrintPos(M_OFF-1, i + 2, " %s", backupSetItem.substr(0,15).c_str()); + consolePrintPos(21, i+2,"%s", BackupSetList::currentBackupSetList->getStretchedSerialIdAt(i+scroll).c_str()); + consolePrintPos(33, i+2,"%s", BackupSetList::currentBackupSetList->getTagAt(i+scroll).c_str()); } DrawUtils::setFontColor(COLOR_TEXT); consolePrintPos(-1, 2 + cursorPos, "\u2192"); diff --git a/src/menu/KeyboardState.cpp b/src/menu/KeyboardState.cpp index 4aa4f5a..34b342f 100644 --- a/src/menu/KeyboardState.cpp +++ b/src/menu/KeyboardState.cpp @@ -21,13 +21,16 @@ void KeyboardState::render() { DrawUtils::setFontColor(COLOR_TEXT); DrawUtils::setFont(); //was kFont for (int row_=0;row_<4;row_++) - for (int column_=0;column_getKeyboardRowSize(row_);column_++) + for (int column_=0;column_getKeyboardRowSize(row_);column_++) { kConsolePrintPos(KB_X_OFFSET+column_,KB_Y_OFFSET+row_,KB_ROW_OFFSET*row_, "%s", keyboard->getKey(row_,column_).c_str()); + DrawUtils::drawKey(KB_X_OFFSET+column_,KB_Y_OFFSET+row_,KB_ROW_OFFSET*row_,COLOR_WHITE); + } DrawUtils::setFontColor(COLOR_KEY_S); kConsolePrintPos(cursorPosX+KB_X_OFFSET,cursorPosY+KB_Y_OFFSET,cursorPosY*KB_ROW_OFFSET-3,"%s", keyboard->getCurrentKey().c_str()); kConsolePrintPos(cursorPosX+KB_X_OFFSET,cursorPosY+KB_Y_OFFSET,cursorPosY*KB_ROW_OFFSET+3,"%s", keyboard->getCurrentKey().c_str()); DrawUtils::setFontColor(COLOR_KEY); kConsolePrintPos(cursorPosX+KB_X_OFFSET,cursorPosY+KB_Y_OFFSET,cursorPosY*KB_ROW_OFFSET,"%s", keyboard->getCurrentKey().c_str()); + DrawUtils::drawKey(cursorPosX+KB_X_OFFSET,cursorPosY+KB_Y_OFFSET,cursorPosY*KB_ROW_OFFSET,COLOR_KEY_C); DrawUtils::setFontColor(COLOR_TEXT); DrawUtils::setFont(); consolePrintPosAligned(17, 4, 2, LanguageUtils::gettext("\ue000: Press Key \uE003: Shift \uE002: Del \ue045: OK! \ue001: Back")); diff --git a/src/menu/TitleOptionsState.cpp b/src/menu/TitleOptionsState.cpp index 475fa53..aa7c5b8 100644 --- a/src/menu/TitleOptionsState.cpp +++ b/src/menu/TitleOptionsState.cpp @@ -9,6 +9,8 @@ #include #include +#define TAG_OFF 17 + void TitleOptionsState::render() { if (this->state == STATE_DO_SUBSTATE) { if (this->subState == nullptr) { @@ -50,6 +52,7 @@ void TitleOptionsState::render() { consolePrintPos(M_OFF, 5, " < %03u > (%s)", slot, emptySlot ? LanguageUtils::gettext("Empty") : LanguageUtils::gettext("Used")); + } if (this->isWiiUTitle) { @@ -108,8 +111,8 @@ void TitleOptionsState::render() { consolePrintPos(M_OFF, 15, LanguageUtils::gettext("Date: %s"), metadataObj->simpleFormat().c_str()); tag = metadataObj->getTag(); - newTag = tag; - consolePrintPosAligned (14,0,4,"tag %s, newtag %s",tag.c_str(),newTag.c_str()); + if ( tag != "" ) + consolePrintPos(TAG_OFF, 5,"[%s]",tag.c_str()); } delete metadataObj; } @@ -173,8 +176,8 @@ void TitleOptionsState::render() { consolePrintPos(M_OFF, 15, LanguageUtils::gettext("Date: %s"), metadataObj->simpleFormat().c_str()); tag = metadataObj->getTag(); - newTag = tag; - consolePrintPosAligned (14,0,4,"tag %s, newtag %s",tag.c_str(),newTag.c_str()); + if ( tag != "" ) + consolePrintPos(TAG_OFF, 5,"[%s]",tag.c_str()); } delete metadataObj; } diff --git a/src/utils/DrawUtils.cpp b/src/utils/DrawUtils.cpp index 12a628a..0149513 100644 --- a/src/utils/DrawUtils.cpp +++ b/src/utils/DrawUtils.cpp @@ -475,4 +475,11 @@ void DrawUtils::drawRGB5A3(int x, int y, float scale, uint8_t *fileContent) { drawRect(x - 3, y - 3, x + nw + 2, y + nh + 2, 255, 255, 255, 128); } } +} + +void DrawUtils::drawKey(int x,int y,int x_off,Color color) { + int xtop = x*52-26+x_off+5; + int ytop = (y+Y_OFF)*50-25-5; + drawRect(xtop,ytop,xtop+52,ytop+50,color.r,color.g,color.b,color.a); + } \ No newline at end of file diff --git a/src/utils/KeyboardUtils.cpp b/src/utils/KeyboardUtils.cpp index 124c2be..736c2b8 100644 --- a/src/utils/KeyboardUtils.cpp +++ b/src/utils/KeyboardUtils.cpp @@ -3,6 +3,8 @@ #include #include +#define MAX_INPUT_SIZE 30 + void Keyboard::render() { } @@ -66,7 +68,8 @@ void Keyboard::shiftPressed() { } void Keyboard::kbKeyPressed() { - input.append(ucs4ToUtf8(currentKey)); + if (input.size() < MAX_INPUT_SIZE ) + input.append(ucs4ToUtf8(currentKey)); } void Keyboard::delPressed() {