-Added proper multiple languages support. Now you can change the language via menu.

This commit is contained in:
cyberwarriorx 2007-05-18 02:33:51 +00:00
parent 2dcec43917
commit 1eaa4622dd
3 changed files with 146 additions and 5 deletions

View File

@ -433,6 +433,53 @@ BOOL LoadROM(char * filename)
return FALSE; return FALSE;
} }
void SetLanguage(int langid)
{
switch(langid)
{
case 1:
// French
SetThreadLocale(MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
SORT_DEFAULT));
break;
case 0:
// English
SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
SORT_DEFAULT));
break;
default: break;
break;
}
}
void SaveLanguage(int langid)
{
char text[80];
sprintf(text, "%d", langid);
WritePrivateProfileString("General", "Language", text, IniName);
}
void CheckLanguage(UINT id)
{
int i;
for (i = IDC_LANGENGLISH; i < IDC_LANGFRENCH+1; i++)
CheckMenuItem(menu, i, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(menu, id, MF_BYCOMMAND | MF_CHECKED);
}
void ChangeLanguage(int id)
{
HMENU newmenu;
SetLanguage(id);
newmenu = LoadMenu(hAppInst, "MENU_PRINCIPAL");
SetMenu(hwnd, newmenu);
DestroyMenu(menu);
menu = newmenu;
}
int WINAPI WinMain (HINSTANCE hThisInstance, int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPSTR lpszArgument, LPSTR lpszArgument,
@ -446,6 +493,11 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
hAppInst=hThisInstance; hAppInst=hThisInstance;
InitializeCriticalSection(&section); InitializeCriticalSection(&section);
GetINIPath(IniName, MAX_PATH);
GetPrivateProfileString("General", "Language", "-1", text, 80, IniName);
SetLanguage(atoi(text));
sprintf(text, "DeSmuME v%s", VERSION); sprintf(text, "DeSmuME v%s", VERSION);
hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL)); hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL));
@ -476,10 +528,11 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
LogStart(); LogStart();
#endif #endif
GetINIPath(IniName, MAX_PATH);
NDS_Init(); NDS_Init();
GetPrivateProfileString("General", "Language", "0", text, 80, IniName);
CheckLanguage(IDC_LANGENGLISH+atoi(text));
GetPrivateProfileString("Video", "FrameSkip", "AUTO", text, 80, IniName); GetPrivateProfileString("Video", "FrameSkip", "AUTO", text, 80, IniName);
if (strcmp(text, "AUTO") == 0) if (strcmp(text, "AUTO") == 0)
@ -1341,6 +1394,16 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
CheckMenuItem(menu, LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(menu, LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
} }
return 0; return 0;
case IDC_LANGENGLISH:
SaveLanguage(0);
ChangeLanguage(0);
CheckLanguage(LOWORD(wParam));
return 0;
case IDC_LANGFRENCH:
SaveLanguage(1);
ChangeLanguage(1);
CheckLanguage(LOWORD(wParam));
return 0;
case IDM_WEBSITE: case IDM_WEBSITE:
ShellExecute(NULL, "open", "http://desmume.sourceforge.net", NULL, NULL, SW_SHOWNORMAL); ShellExecute(NULL, "open", "http://desmume.sourceforge.net", NULL, NULL, SW_SHOWNORMAL);
return 0; return 0;

View File

@ -133,6 +133,9 @@ void refreshAll();
#define IDM_IMPORTBACKUPMEMORY 201 #define IDM_IMPORTBACKUPMEMORY 201
#define IDC_LANGENGLISH 210
#define IDC_LANGFRENCH 211
#define IDD_MEM_VIEWER 301 #define IDD_MEM_VIEWER 301
#define IDC_8_BIT 302 #define IDC_8_BIT 302
#define IDC_16_BIT 303 #define IDC_16_BIT 303

View File

@ -37,8 +37,39 @@ MENU_PRINCIPAL MENU
MENUITEM "&Ouvrir", IDM_OPEN MENUITEM "&Ouvrir", IDM_OPEN
MENUITEM "&Info rom", IDM_GAME_INFO MENUITEM "&Info rom", IDM_GAME_INFO
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "&Printscreen", IDM_PRINTSCREEN MENUITEM "Save State As", IDM_STATE_SAVE
MENUITEM "&Quick Printscreen", IDM_QUICK_PRINTSCREEN MENUITEM "Load State As", IDM_STATE_LOAD
POPUP "Save State"
{
MENUITEM "1", IDM_STATE_SAVE_F1
MENUITEM "2", IDM_STATE_SAVE_F2
MENUITEM "3", IDM_STATE_SAVE_F3
MENUITEM "4", IDM_STATE_SAVE_F4
MENUITEM "5", IDM_STATE_SAVE_F5
MENUITEM "6", IDM_STATE_SAVE_F6
MENUITEM "7", IDM_STATE_SAVE_F7
MENUITEM "8", IDM_STATE_SAVE_F8
MENUITEM "9", IDM_STATE_SAVE_F9
MENUITEM "10", IDM_STATE_SAVE_F10
}
POPUP "Load State"
{
MENUITEM "1", IDM_STATE_LOAD_F1
MENUITEM "2", IDM_STATE_LOAD_F2
MENUITEM "3", IDM_STATE_LOAD_F3
MENUITEM "4", IDM_STATE_LOAD_F4
MENUITEM "5", IDM_STATE_LOAD_F5
MENUITEM "6", IDM_STATE_LOAD_F6
MENUITEM "7", IDM_STATE_LOAD_F7
MENUITEM "8", IDM_STATE_LOAD_F8
MENUITEM "9", IDM_STATE_LOAD_F9
MENUITEM "10", IDM_STATE_LOAD_F10
}
MENUITEM SEPARATOR
MENUITEM "Import Backup Memory", IDM_IMPORTBACKUPMEMORY
MENUITEM SEPARATOR
MENUITEM "Save Screenshot &As", IDM_PRINTSCREEN
MENUITEM "&Quick Screenshot", IDM_QUICK_PRINTSCREEN
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "&Quitter", IDM_QUIT MENUITEM "&Quitter", IDM_QUIT
} }
@ -68,6 +99,40 @@ MENU_PRINCIPAL MENU
//MENUITEM "&DeMagnify", IDC_DEMAGNIFY //MENUITEM "&DeMagnify", IDC_DEMAGNIFY
MENUITEM "&Force Maintain Ratio", IDC_FORCERATIO MENUITEM "&Force Maintain Ratio", IDC_FORCERATIO
} }
POPUP "&Config"
{
POPUP "&Save Type"
{
MENUITEM "Autodetect", IDC_SAVETYPE1
MENUITEM "EEPROM 4kbit", IDC_SAVETYPE2
MENUITEM "EEPROM 64kbit", IDC_SAVETYPE3
MENUITEM "EEPROM 512kbit", IDC_SAVETYPE4
MENUITEM "FRAM 256kbit", IDC_SAVETYPE5
MENUITEM "FLASH 2mbit", IDC_SAVETYPE6
}
MENUITEM "Control Config", IDM_CONFIG
MENUITEM "Sound Settings", IDM_SOUNDSETTINGS
MENUITEM "Firmware Settings", IDM_FIRMSETTINGS
POPUP "&Frame Skip"
{
MENUITEM "Auto", IDC_FRAMESKIPAUTO
MENUITEM "0", IDC_FRAMESKIP0
MENUITEM "1", IDC_FRAMESKIP1
MENUITEM "2", IDC_FRAMESKIP2
MENUITEM "3", IDC_FRAMESKIP3
MENUITEM "4", IDC_FRAMESKIP4
MENUITEM "5", IDC_FRAMESKIP5
MENUITEM "6", IDC_FRAMESKIP6
MENUITEM "7", IDC_FRAMESKIP7
MENUITEM "8", IDC_FRAMESKIP8
MENUITEM "9", IDC_FRAMESKIP9
}
POPUP "&Language"
{
MENUITEM "English", IDC_LANGENGLISH
MENUITEM "French", IDC_LANGFRENCH
}
}
POPUP "&Outils" POPUP "&Outils"
{ {
MENUITEM "&Desassembleur", IDM_DISASSEMBLER MENUITEM "&Desassembleur", IDM_DISASSEMBLER
@ -92,8 +157,13 @@ MENU_PRINCIPAL MENU
MENUITEM "Sub BG 3", IDM_SBG3, CHECKED MENUITEM "Sub BG 3", IDM_SBG3, CHECKED
} }
} }
POPUP "&Help"
{
MENUITEM "&Website", IDM_WEBSITE
MENUITEM "&Forums", IDM_FORUM
MENUITEM "&Submit a bug report", IDM_SUBMITBUGREPORT
}
} }
IDD_MEM_VIEWER DIALOG DISCARDABLE 0, 0, 428, 178 IDD_MEM_VIEWER DIALOG DISCARDABLE 0, 0, 428, 178
STYLE WS_SYSMENU STYLE WS_SYSMENU
@ -405,6 +475,11 @@ MENU_PRINCIPAL MENU
MENUITEM "8", IDC_FRAMESKIP8 MENUITEM "8", IDC_FRAMESKIP8
MENUITEM "9", IDC_FRAMESKIP9 MENUITEM "9", IDC_FRAMESKIP9
} }
POPUP "&Language"
{
MENUITEM "English", IDC_LANGENGLISH
MENUITEM "French", IDC_LANGFRENCH
}
} }
POPUP "&Tools" POPUP "&Tools"
{ {