Skip to content

Commit

Permalink
Disable UI texts scaling option for chinese language.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinnegatamante committed Jun 28, 2021
1 parent 1758719 commit 53a2b59
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 12 deletions.
1 change: 1 addition & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ vita_create_vpk(${PROJECT_NAME}.vpk ${VITA_TITLEID} ${PROJECT_NAME}.self
VERSION ${VITA_VERSION}
NAME ${VITA_APP_NAME}
FILE ${PROJECT_SOURCE_DIR}/Roboto.ttf Roboto.ttf
FILE ${PROJECT_SOURCE_DIR}/Roboto_compact.ttf Roboto_compact.ttf
FILE ${PROJECT_SOURCE_DIR}/sce_sys/icon0.png sce_sys/icon0.png
FILE ${PROJECT_SOURCE_DIR}/sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
FILE ${PROJECT_SOURCE_DIR}/sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
Expand Down
Binary file added Source/Roboto_compact.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions Source/SysVita/UI/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ extern bool pendingDownload;
extern bool custom_path_str_dirty;
extern bool net_path_str_dirty;
extern bool is_main_menu;
extern bool fontDirty;

extern uint64_t cur_playtime;
extern char *raw_net_romlist;
Expand Down
23 changes: 15 additions & 8 deletions Source/SysVita/UI/MenuBarScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ float ver_len = 0.0f;
bool calculate_ver_len = true;
bool pendingDownload = false;
bool is_main_menu = true;
bool fontDirty = false;

bool oldBigText = false;
int gLanguageIndex = SCE_SYSTEM_PARAM_LANG_ENGLISH_US;
int gUiTheme = DARK_THEME;
int gAspectRatio = RATIO_16_9;
Expand Down Expand Up @@ -526,8 +526,9 @@ void DrawExtraMenu() {
if (ImGui::MenuItem(lang_strings[STR_MENU_MENUBAR], nullptr, gHideMenubar)){
gHideMenubar = !gHideMenubar;
}
if (ImGui::MenuItem(lang_strings[STR_BIG_TEXT], nullptr, gBigText)){
if (ImGui::MenuItem(lang_strings[STR_BIG_TEXT], nullptr, gBigText, gLanguageIndex != SCE_SYSTEM_PARAM_LANG_CHINESE_S)){
gBigText = !gBigText;
fontDirty = true;
}
ImGui::Separator();
if (ImGui::MenuItem(lang_strings[STR_MENU_AUTOUPDATE], nullptr, gAutoUpdate)){
Expand Down Expand Up @@ -858,8 +859,14 @@ void DrawCommonMenuBar() {
if (ImGui::MenuItem("Türk", nullptr, gLanguageIndex == SCE_SYSTEM_PARAM_LANG_TURKISH)){
setTranslation(SCE_SYSTEM_PARAM_LANG_TURKISH);
}
if (ImGui::MenuItem("中国人", nullptr, gLanguageIndex == SCE_SYSTEM_PARAM_LANG_CHINESE_S)){
setTranslation(SCE_SYSTEM_PARAM_LANG_CHINESE_S);
if (gLanguageIndex == SCE_SYSTEM_PARAM_LANG_CHINESE_S) {
if (ImGui::MenuItem("中国人", nullptr, gLanguageIndex == SCE_SYSTEM_PARAM_LANG_CHINESE_S)){
setTranslation(SCE_SYSTEM_PARAM_LANG_CHINESE_S);
}
} else {
if (ImGui::MenuItem("Chinese", nullptr, gLanguageIndex == SCE_SYSTEM_PARAM_LANG_CHINESE_S)){
setTranslation(SCE_SYSTEM_PARAM_LANG_CHINESE_S);
}
}
ImGui::EndMenu();
}
Expand Down Expand Up @@ -1075,11 +1082,11 @@ void DrawPendingDialog() {

void DrawMenuBar() {
// Checking if a UI scale change is performed
if (oldBigText != gBigText) {
if (fontDirty) {
ImGui::GetIO().Fonts->Clear();
ImGui_ImplVitaGL_InvalidateDeviceObjects();
reloadFont();
oldBigText = gBigText;
fontDirty = false;
}

if (custom_path_str_dirty) {
Expand Down Expand Up @@ -1169,11 +1176,11 @@ void DrawInGameMenuBar() {
}

// Checking if a UI scale change is performed
if (oldBigText != gBigText) {
if (fontDirty) {
ImGui::GetIO().Fonts->Clear();
ImGui_ImplVitaGL_InvalidateDeviceObjects();
reloadFont();
oldBigText = gBigText;
fontDirty = false;
}

ImGui_ImplVitaGL_NewFrame();
Expand Down
23 changes: 21 additions & 2 deletions Source/SysVita/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,19 @@ static int updaterThread(unsigned int args, void* arg) {
}

void reloadFont() {
static const ImWchar ranges[] = {
static const ImWchar compact_ranges[] = { // All languages except chinese
0x0020, 0x00FF, // Basic Latin + Latin Supplement
0x0100, 0x024F, // Latin Extended
0x0370, 0x03FF, // Greek
0x0400, 0x052F, // Cyrillic + Cyrillic Supplement
0x0590, 0x05FF, // Hebrew
0x1E00, 0x1EFF, // Latin Extended Additional
0x2DE0, 0x2DFF, // Cyrillic Extended-A
0xA640, 0xA69F, // Cyrillic Extended-B
0,
};

static const ImWchar ranges[] = { // All languages with chinese included
0x0020, 0x00FF, // Basic Latin + Latin Supplement
0x0100, 0x024F, // Latin Extended
0x0370, 0x03FF, // Greek
Expand All @@ -336,7 +348,11 @@ void reloadFont() {
0,
};

ImGui::GetIO().Fonts->AddFontFromFileTTF("app0:/Roboto.ttf", 16.0f * UI_SCALE, NULL, ranges);
if (gLanguageIndex == SCE_SYSTEM_PARAM_LANG_CHINESE_S) {
gBigText = false;
ImGui::GetIO().Fonts->AddFontFromFileTTF("app0:/Roboto.ttf", 16.0f * UI_SCALE, NULL, ranges);
} else
ImGui::GetIO().Fonts->AddFontFromFileTTF("app0:/Roboto_compact.ttf", 16.0f * UI_SCALE, NULL, compact_ranges);
}

void start_net() {
Expand Down Expand Up @@ -621,6 +637,9 @@ void showDialog(char *text, void (*yes_func)(), void (*no_func)(), int type, cha
}

void setTranslation(int idx) {
if (idx != gLanguageIndex && (gLanguageIndex == SCE_SYSTEM_PARAM_LANG_CHINESE_S || idx == SCE_SYSTEM_PARAM_LANG_CHINESE_S))
fontDirty = true;

char langFile[LANG_STR_SIZE * 2];
char identifier[LANG_ID_SIZE], buffer[LANG_STR_SIZE];

Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ steps:
- script: |
git clone https://github.com/Rinnegatamante/vitaGL
cd vitaGL
make -j$(nproc) HAVE_SBRK=1 NO_DEBUG=1 HAVE_UNFLIPPED_FBOS=1
sudo -E make HAVE_SBRK=1 NO_DEBUG=1 HAVE_UNFLIPPED_FBOS=1 install
make -j$(nproc) NO_DEBUG=1 HAVE_UNFLIPPED_FBOS=1
sudo -E make NO_DEBUG=1 HAVE_UNFLIPPED_FBOS=1 install
displayName: 'Build vitaGL'

- script: |
Expand Down

0 comments on commit 53a2b59

Please sign in to comment.