2015-10-25 19:20:23 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
2015-11-10 05:21:49 +00:00
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
2015-10-25 19:20:23 +00:00
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "LanguageSelector.h"
|
|
|
|
|
|
|
|
CLanguageSelector::CLanguageSelector()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
void CLanguageSelector::Select(void)
|
2015-10-25 19:20:23 +00:00
|
|
|
{
|
2015-12-30 20:31:04 +00:00
|
|
|
DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_Lang_Select), NULL, (DLGPROC)LangSelectProc, (LPARAM)this);
|
2015-10-25 19:20:23 +00:00
|
|
|
}
|
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
LRESULT CALLBACK CLanguageSelector::LangSelectProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2015-10-25 19:20:23 +00:00
|
|
|
{
|
|
|
|
static HBITMAP hbmpBackgroundTop = NULL;
|
|
|
|
static HFONT hTextFont = NULL;
|
|
|
|
static CLanguageSelector * lngClass;
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2015-11-13 06:35:20 +00:00
|
|
|
{
|
|
|
|
lngClass = (CLanguageSelector *)lParam;
|
2015-10-25 19:20:23 +00:00
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
LanguageList LangList = g_Lang->GetLangList();
|
|
|
|
if (LangList.size() == 0)
|
|
|
|
{
|
|
|
|
EndDialog(hDlg, 0);
|
|
|
|
}
|
|
|
|
for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++)
|
|
|
|
{
|
2015-12-30 20:31:04 +00:00
|
|
|
int index = SendMessageW(GetDlgItem(hDlg, IDC_LANG_SEL), CB_ADDSTRING, 0, (WPARAM)stdstr(Language->LanguageName).ToUTF16().c_str());
|
2015-12-23 20:04:36 +00:00
|
|
|
if (_stricmp(Language->LanguageName.c_str(), "English") == 0)
|
2015-10-25 19:20:23 +00:00
|
|
|
{
|
2015-11-13 06:35:20 +00:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, index, 0);
|
2015-10-25 19:20:23 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-13 06:35:20 +00:00
|
|
|
|
|
|
|
int Index = SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETCURSEL, 0, 0);
|
|
|
|
if (Index < 0)
|
2015-10-25 19:20:23 +00:00
|
|
|
{
|
2015-11-13 06:35:20 +00:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, 0, 0);
|
2015-10-25 19:20:23 +00:00
|
|
|
}
|
2015-11-13 06:35:20 +00:00
|
|
|
|
|
|
|
// Use the size of the image
|
|
|
|
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO));
|
|
|
|
BITMAP bmTL;
|
|
|
|
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
|
|
|
|
|
2015-12-30 20:31:04 +00:00
|
|
|
hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
|
2015-11-13 06:35:20 +00:00
|
|
|
SendDlgItemMessage(hDlg, IDC_SELECT_LANG, WM_SETFONT, (WPARAM)hTextFont, TRUE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
{
|
|
|
|
HDC hdcStatic = (HDC)wParam;
|
|
|
|
SetTextColor(hdcStatic, RGB(0, 0, 0));
|
|
|
|
SetBkMode(hdcStatic, TRANSPARENT);
|
|
|
|
return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
|
|
|
|
}
|
|
|
|
break;
|
2015-11-11 03:00:15 +00:00
|
|
|
case WM_ERASEBKGND:
|
2015-11-13 06:35:20 +00:00
|
|
|
{
|
|
|
|
HPEN outline;
|
|
|
|
HBRUSH fill;
|
|
|
|
RECT rect;
|
2015-11-11 03:00:15 +00:00
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
|
|
|
|
fill = CreateSolidBrush(0x00FFFFFF);
|
|
|
|
SelectObject((HDC)wParam, outline);
|
|
|
|
SelectObject((HDC)wParam, fill);
|
2015-11-11 03:00:15 +00:00
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
GetClientRect(hDlg, &rect);
|
2015-11-11 03:00:15 +00:00
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-25 19:20:23 +00:00
|
|
|
case WM_PAINT:
|
2015-11-13 06:35:20 +00:00
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
2015-10-25 19:20:23 +00:00
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
if (BeginPaint(hDlg, &ps))
|
|
|
|
{
|
|
|
|
RECT rcClient;
|
|
|
|
GetClientRect(hDlg, &rcClient);
|
2015-10-25 19:20:23 +00:00
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
BITMAP bmTL_top;
|
|
|
|
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
|
2015-10-25 19:20:23 +00:00
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
HDC memdc = CreateCompatibleDC(ps.hdc);
|
|
|
|
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
|
|
|
|
BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY);
|
|
|
|
SelectObject(memdc, save);
|
|
|
|
DeleteDC(memdc);
|
2015-10-25 19:20:23 +00:00
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
EndPaint(hDlg, &ps);
|
2015-10-25 19:20:23 +00:00
|
|
|
}
|
2015-11-13 06:35:20 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-10-25 19:20:23 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDOK:
|
|
|
|
if (hbmpBackgroundTop)
|
|
|
|
{
|
|
|
|
DeleteObject(hbmpBackgroundTop);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hTextFont)
|
|
|
|
{
|
|
|
|
::DeleteObject(hTextFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2015-11-13 06:35:20 +00:00
|
|
|
int Index = SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETCURSEL, 0, 0);
|
2015-10-25 19:20:23 +00:00
|
|
|
|
|
|
|
if (Index >= 0)
|
|
|
|
{
|
|
|
|
wchar_t String[255];
|
2015-11-13 06:35:20 +00:00
|
|
|
SendMessageW(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETLBTEXT, Index, (LPARAM)String);
|
2015-12-23 20:04:36 +00:00
|
|
|
g_Lang->SetLanguage(stdstr().FromUTF16(String).c_str());
|
2015-10-25 19:20:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-13 06:35:20 +00:00
|
|
|
EndDialog(hDlg, 0);
|
2015-10-25 19:20:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|