From a167e367612c52d06a954a7320f826babbfefee9 Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:17:16 +0900 Subject: [PATCH] Fix loading language file on launch --- src/dos/dos_keyboard_layout.cpp | 10 ++++++++-- src/shell/shell.cpp | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dos/dos_keyboard_layout.cpp b/src/dos/dos_keyboard_layout.cpp index cdd80d924aa..4e943853210 100644 --- a/src/dos/dos_keyboard_layout.cpp +++ b/src/dos/dos_keyboard_layout.cpp @@ -49,9 +49,12 @@ void DOSBox_SetSysMenu(void); bool OpenGL_using(void), isDBCSCP(void); void change_output(int output), UpdateSDLDrawTexture(); void SwitchLanguage(int oldcp, int newcp, bool confirm); +Bitu DOS_ChangeCodepage(int32_t codepage, const char* codepagefile); void MSG_Init(), JFONT_Init(), runRescan(const char *str); extern int tryconvertcp, toSetCodePage(DOS_Shell *shell, int newCP, int opt); extern bool jfont_init; +extern int msgcodepage; + static FILE* OpenDosboxFile(const char* name) { uint8_t drive; char fullname[DOS_PATHLENGTH]; @@ -1735,9 +1738,12 @@ class DOS_KeyboardLayout: public Module_base { UpdateSDLDrawTexture(); #endif } - SwitchLanguage(cpbak, dos.loaded_codepage, false); } - } + if(msgcodepage) { + SwitchLanguage(dos.loaded_codepage, msgcodepage, false); + DOS_ChangeCodepage(msgcodepage, "auto"); + } + } ~DOS_KeyboardLayout(){ if ((dos.loaded_codepage!=GetDefaultCP()) && (CurMode->type==M_TEXT)) { diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index c0602381f08..c13c546bd7f 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -891,7 +891,8 @@ void DOS_Shell::Prepare(void) { } else if (control->opt_langcp && !name && (layout.empty() || layout=="auto")) SetKEYBCP(); } - if (lastmsgcp && lastmsgcp != dos.loaded_codepage) SwitchLanguage(lastmsgcp, dos.loaded_codepage, true); + //if (lastmsgcp && lastmsgcp != dos.loaded_codepage) SwitchLanguage(lastmsgcp, dos.loaded_codepage, true); + if (msgcodepage && msgcodepage != dos.loaded_codepage) SwitchLanguage(dos.loaded_codepage, msgcodepage, true); } if (country>0&&!control->opt_noconfig) { countryNo = country;