Skip to content

Commit

Permalink
enh - draw keys in keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
w3irDv committed Sep 24, 2024
1 parent 73810c8 commit a70e717
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 21 deletions.
5 changes: 3 additions & 2 deletions include/utils/Colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#define COLOR_KEY Color(0xFF3333FF)
#define COLOR_KEY_S Color(0xFF666600)
#define COLOR_KEY_C Color(0xFF0000FF)
1 change: 1 addition & 0 deletions include/utils/DrawUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class DrawUtils {

static uint32_t deinitScreen();

static void drawKey(int x,int y,int x_off,Color color);



Expand Down
2 changes: 1 addition & 1 deletion romfs/languages/SChinese.json
Original file line number Diff line number Diff line change
Expand Up @@ -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: 备份",
Expand Down
13 changes: 6 additions & 7 deletions romfs/languages/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down Expand Up @@ -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 <>"
}
5 changes: 3 additions & 2 deletions romfs/languages/japanese.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 3 additions & 3 deletions src/menu/BackupSetListState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 4 additions & 1 deletion src/menu/KeyboardState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_<keyboard->getKeyboardRowSize(row_);column_++)
for (int column_=0;column_<keyboard->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"));
Expand Down
11 changes: 7 additions & 4 deletions src/menu/TitleOptionsState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <utils/InputUtils.h>
#include <utils/LanguageUtils.h>

#define TAG_OFF 17

void TitleOptionsState::render() {
if (this->state == STATE_DO_SUBSTATE) {
if (this->subState == nullptr) {
Expand Down Expand Up @@ -50,6 +52,7 @@ void TitleOptionsState::render() {
consolePrintPos(M_OFF, 5, " < %03u > (%s)", slot,
emptySlot ? LanguageUtils::gettext("Empty")
: LanguageUtils::gettext("Used"));

}

if (this->isWiiUTitle) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions src/utils/DrawUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
5 changes: 4 additions & 1 deletion src/utils/KeyboardUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <locale>
#include <codecvt>

#define MAX_INPUT_SIZE 30

void Keyboard::render() {
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit a70e717

Please sign in to comment.