[Project64] Split language Selection UI out of Language class
This commit is contained in:
parent
0608a8b504
commit
98ea510118
|
@ -495,21 +495,19 @@ void CLanguage::LoadDefaultStrings (void)
|
|||
DEF_STR(MSG_SET_HLE_AUD_MSG, L"Audio HLE requires a third-party plugin!!!\nIf you do not use a third-party audio plugin that supports HLE, you will hear no sound.\n\nChange to audio HLE?");
|
||||
}
|
||||
|
||||
LRESULT CALLBACK LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
CLanguage::CLanguage() :
|
||||
m_emptyString(L"")
|
||||
m_emptyString(L""),
|
||||
m_LanguageLoaded(false)
|
||||
{
|
||||
LoadDefaultStrings();
|
||||
LoadDefaultStrings();
|
||||
if (g_Settings)
|
||||
{
|
||||
m_SelectedLanguage = g_Settings->LoadStringVal(Setting_CurrentLanguage).ToUTF16();
|
||||
}
|
||||
}
|
||||
|
||||
void CLanguage::LoadCurrentStrings ( bool ShowSelectDialog )
|
||||
bool CLanguage::LoadCurrentStrings ( void )
|
||||
{
|
||||
if (ShowSelectDialog)
|
||||
{
|
||||
m_SelectedLanguage = g_Settings->LoadStringVal(Setting_CurrentLanguage).ToUTF16();
|
||||
}
|
||||
|
||||
LanguageList LangList = GetLangList();
|
||||
stdstr Filename;
|
||||
|
||||
|
@ -525,23 +523,17 @@ void CLanguage::LoadCurrentStrings ( bool ShowSelectDialog )
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (ShowSelectDialog && Filename.length() == 0 && LangList.size() > 0)
|
||||
{
|
||||
//Do Dialog box to choose language
|
||||
DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_Lang_Select),NULL,(DLGPROC)LangSelectProc, (LPARAM)this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Filename.length() == 0)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Process the file
|
||||
FILE *file = fopen(Filename.c_str(), "rb");
|
||||
if (file == NULL)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Search for utf8 file marker
|
||||
|
@ -552,7 +544,7 @@ void CLanguage::LoadCurrentStrings ( bool ShowSelectDialog )
|
|||
utf_bom[2] != 0xBF)
|
||||
{
|
||||
fclose(file);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
//String;
|
||||
|
@ -561,339 +553,10 @@ void CLanguage::LoadCurrentStrings ( bool ShowSelectDialog )
|
|||
m_CurrentStrings.insert(GetNextLangString(file));
|
||||
}
|
||||
fclose(file);
|
||||
m_LanguageLoaded = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
WNDPROC pfnWndLangSelectOkProc = NULL;
|
||||
HBITMAP hOkButton = NULL;
|
||||
|
||||
DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
|
||||
{
|
||||
static bool m_fPressed = false;
|
||||
static HBITMAP hOkButtonDown = NULL;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
if (BeginPaint(hWnd,&ps))
|
||||
{
|
||||
if (m_fPressed)
|
||||
{
|
||||
if (hOkButtonDown == NULL)
|
||||
{
|
||||
hOkButtonDown = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK_DOWN));
|
||||
}
|
||||
if (hOkButtonDown)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(hWnd, &rcClient);
|
||||
|
||||
BITMAP bmTL1;
|
||||
GetObject(hOkButtonDown, sizeof(BITMAP), &bmTL1);
|
||||
HDC memdc = CreateCompatibleDC(ps.hdc);
|
||||
HGDIOBJ save = SelectObject(memdc, hOkButtonDown);
|
||||
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hOkButton)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(hWnd, &rcClient);
|
||||
|
||||
BITMAP bmTL1;
|
||||
GetObject(hOkButton, sizeof(BITMAP), &bmTL1);
|
||||
HDC memdc = CreateCompatibleDC(ps.hdc);
|
||||
HGDIOBJ save = SelectObject(memdc, hOkButton);
|
||||
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
}
|
||||
}
|
||||
EndPaint(hWnd,&ps);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
if (::GetCapture() == hWnd)
|
||||
{
|
||||
POINT ptCursor = { ((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)) };
|
||||
ClientToScreen(hWnd, &ptCursor);
|
||||
RECT rect;
|
||||
GetWindowRect(hWnd, &rect);
|
||||
bool uPressed = ::PtInRect(&rect, ptCursor)==TRUE;
|
||||
if ( m_fPressed != uPressed )
|
||||
{
|
||||
m_fPressed = uPressed;
|
||||
::InvalidateRect(hWnd, NULL, TRUE);
|
||||
UpdateWindow(hWnd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
LRESULT lRet = 0;
|
||||
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
SetCapture(hWnd);
|
||||
if ( ::GetCapture()==hWnd )
|
||||
{
|
||||
m_fPressed = true;
|
||||
|
||||
if (m_fPressed)
|
||||
{
|
||||
::InvalidateRect(hWnd, NULL, TRUE);
|
||||
UpdateWindow(hWnd);
|
||||
}
|
||||
}
|
||||
return lRet;
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
LRESULT lRet = 0;
|
||||
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
if ( ::GetCapture() == hWnd )
|
||||
{
|
||||
::ReleaseCapture();
|
||||
if ( m_fPressed )
|
||||
{
|
||||
::SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd);
|
||||
}
|
||||
}
|
||||
m_fPressed = false;
|
||||
|
||||
return lRet;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CallWindowProc(pfnWndLangSelectOkProc, hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static HBITMAP hbmpBackgroundTop = NULL;
|
||||
static HBITMAP hbmpBackgroundBottom = NULL;
|
||||
static HBITMAP hbmpBackgroundMiddle = NULL;
|
||||
static HFONT hTextFont = NULL;
|
||||
static CLanguage * lngClass;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE);
|
||||
{
|
||||
lngClass = (CLanguage *)lParam;
|
||||
|
||||
LanguageList LangList = lngClass->GetLangList();
|
||||
if (LangList.size() == 0)
|
||||
{
|
||||
EndDialog(hDlg,0);
|
||||
}
|
||||
for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++)
|
||||
{
|
||||
int index = SendMessageW(GetDlgItem(hDlg,IDC_LANG_SEL),CB_ADDSTRING,0,(WPARAM)Language->LanguageName.c_str());
|
||||
if (_wcsicmp(Language->LanguageName.c_str(),L"English") == 0)
|
||||
{
|
||||
SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,index,0);
|
||||
}
|
||||
}
|
||||
|
||||
int Index = SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETCURSEL,0,0);
|
||||
if (Index < 0)
|
||||
{
|
||||
SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,0,0);
|
||||
}
|
||||
|
||||
enum { ROUND_EDGE = 15 };
|
||||
|
||||
DWORD dwStyle = GetWindowLong(hDlg, GWL_STYLE);
|
||||
dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
|
||||
SetWindowLong(hDlg, GWL_STYLE, dwStyle);
|
||||
|
||||
// Use the size of the image
|
||||
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_TOP));
|
||||
hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_BOTTOM));
|
||||
hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_MIDDLE));
|
||||
BITMAP bmTL;
|
||||
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
|
||||
|
||||
if (hbmpBackgroundTop)
|
||||
{
|
||||
// int iHeight = bmTL.bmHeight;
|
||||
int iWidth = bmTL.bmWidth;
|
||||
|
||||
RECT rect;
|
||||
GetWindowRect(hDlg, &rect);
|
||||
rect.left -= rect.left;
|
||||
rect.bottom -= rect.top;
|
||||
rect.top -= rect.top;
|
||||
|
||||
// Tweaked
|
||||
HRGN hWindowRegion= CreateRoundRectRgn
|
||||
(
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1,
|
||||
rect.bottom+GetSystemMetrics(SM_CYEDGE)-1,
|
||||
ROUND_EDGE,
|
||||
ROUND_EDGE
|
||||
);
|
||||
|
||||
if (hWindowRegion)
|
||||
{
|
||||
SetWindowRgn(hDlg, hWindowRegion, TRUE);
|
||||
DeleteObject(hWindowRegion);
|
||||
}
|
||||
}
|
||||
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"
|
||||
);
|
||||
SendDlgItemMessage(hDlg,IDC_SELECT_LANG,WM_SETFONT,(WPARAM)hTextFont,TRUE);
|
||||
}
|
||||
|
||||
hOkButton = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK));
|
||||
pfnWndLangSelectOkProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC);
|
||||
::SetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC,(LONG_PTR)LangSelectOkProc);
|
||||
break;
|
||||
case WM_NCHITTEST:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
RECT client, a;
|
||||
GetClientRect(hDlg,&a);
|
||||
GetClientRect(hDlg,&client);
|
||||
ClientToScreen(hDlg,(LPPOINT)&client);
|
||||
client.right += client.left;
|
||||
client.bottom += client.top;
|
||||
|
||||
int nCaption = GetSystemMetrics(SM_CYCAPTION)*4;
|
||||
|
||||
LRESULT lResult = HTCLIENT;
|
||||
|
||||
//check caption
|
||||
if (xPos <= client.right && xPos >= client.left &&
|
||||
(yPos >= client.top+ 0)&& (yPos <= client.top + 0+nCaption))
|
||||
{
|
||||
lResult = HTCAPTION;
|
||||
}
|
||||
SetWindowLong(hDlg, DWLP_MSGRESULT, lResult);
|
||||
return 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;
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
if (BeginPaint(hDlg,&ps))
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(hDlg, &rcClient);
|
||||
|
||||
BITMAP bmTL_top, bmTL_bottom, bmTL_Middle;
|
||||
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
|
||||
GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom);
|
||||
GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle);
|
||||
|
||||
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);
|
||||
|
||||
memdc = CreateCompatibleDC(ps.hdc);
|
||||
save = SelectObject(memdc, hbmpBackgroundMiddle);
|
||||
for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight)
|
||||
{
|
||||
//BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY);
|
||||
BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
}
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
|
||||
BITMAP ;
|
||||
memdc = CreateCompatibleDC(ps.hdc);
|
||||
save = SelectObject(memdc, hbmpBackgroundBottom);
|
||||
BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
|
||||
BITMAP ;
|
||||
|
||||
EndPaint(hDlg,&ps);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
if (hbmpBackgroundTop)
|
||||
{
|
||||
DeleteObject(hbmpBackgroundTop);
|
||||
}
|
||||
if (hbmpBackgroundBottom)
|
||||
{
|
||||
DeleteObject(hbmpBackgroundBottom);
|
||||
}
|
||||
if (hbmpBackgroundMiddle)
|
||||
{
|
||||
DeleteObject(hbmpBackgroundMiddle);
|
||||
}
|
||||
|
||||
if (hTextFont)
|
||||
{
|
||||
::DeleteObject(hTextFont);
|
||||
}
|
||||
|
||||
{
|
||||
int Index = SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETCURSEL,0,0);
|
||||
|
||||
if (Index >= 0)
|
||||
{
|
||||
wchar_t String[255];
|
||||
SendMessageW(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETLBTEXT,Index,(LPARAM)String);
|
||||
lngClass->SetLanguage(String);
|
||||
}
|
||||
}
|
||||
|
||||
EndDialog(hDlg,0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
LanguageList & CLanguage::GetLangList (void)
|
||||
{
|
||||
if (m_LanguageList.size() > 0)
|
||||
|
@ -1043,10 +706,12 @@ LANG_STR CLanguage::GetNextLangString (void * OpenFile)
|
|||
void CLanguage::SetLanguage ( const wchar_t * LanguageName )
|
||||
{
|
||||
m_SelectedLanguage = LanguageName;
|
||||
LoadCurrentStrings(false);
|
||||
stdstr Language;
|
||||
Language.FromUTF16(LanguageName);
|
||||
g_Settings->SaveString(Setting_CurrentLanguage,Language);
|
||||
if (LoadCurrentStrings())
|
||||
{
|
||||
stdstr Language;
|
||||
Language.FromUTF16(LanguageName);
|
||||
g_Settings->SaveString(Setting_CurrentLanguage,Language);
|
||||
}
|
||||
}
|
||||
|
||||
bool CLanguage::IsCurrentLang( LanguageFile & File )
|
||||
|
|
|
@ -34,8 +34,9 @@ public:
|
|||
const std::wstring & GetString ( LanguageStringID StringID );
|
||||
LanguageList & GetLangList ( void );
|
||||
void SetLanguage ( const wchar_t * LanguageName );
|
||||
void LoadCurrentStrings ( bool ShowSelectDialog );
|
||||
bool LoadCurrentStrings ( void );
|
||||
bool IsCurrentLang ( LanguageFile & File );
|
||||
bool IsLanguageLoaded ( void ) const { return m_LanguageLoaded; }
|
||||
|
||||
private:
|
||||
CLanguage(const CLanguage&); // Disable copy constructor
|
||||
|
@ -50,6 +51,8 @@ private:
|
|||
std::wstring GetLangString ( const char * FileName, LanguageStringID ID );
|
||||
LANG_STR GetNextLangString ( void * OpenFile );
|
||||
void LoadDefaultStrings ( void );
|
||||
|
||||
bool m_LanguageLoaded;
|
||||
};
|
||||
|
||||
extern CLanguage * g_Lang;
|
||||
|
|
|
@ -0,0 +1,351 @@
|
|||
/****************************************************************************
|
||||
* *
|
||||
* Project 64 - A Nintendo 64 emulator. *
|
||||
* 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()
|
||||
{
|
||||
}
|
||||
|
||||
void CLanguageSelector::Select ( void )
|
||||
{
|
||||
DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_Lang_Select),NULL,(DLGPROC)LangSelectProc, (LPARAM)this);
|
||||
}
|
||||
|
||||
static WNDPROC pfnWndLangSelectOkProc = NULL;
|
||||
static HBITMAP hOkButton = NULL;
|
||||
|
||||
DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
|
||||
{
|
||||
static bool m_fPressed = false;
|
||||
static HBITMAP hOkButtonDown = NULL;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
if (BeginPaint(hWnd,&ps))
|
||||
{
|
||||
if (m_fPressed)
|
||||
{
|
||||
if (hOkButtonDown == NULL)
|
||||
{
|
||||
hOkButtonDown = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK_DOWN));
|
||||
}
|
||||
if (hOkButtonDown)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(hWnd, &rcClient);
|
||||
|
||||
BITMAP bmTL1;
|
||||
GetObject(hOkButtonDown, sizeof(BITMAP), &bmTL1);
|
||||
HDC memdc = CreateCompatibleDC(ps.hdc);
|
||||
HGDIOBJ save = SelectObject(memdc, hOkButtonDown);
|
||||
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hOkButton)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(hWnd, &rcClient);
|
||||
|
||||
BITMAP bmTL1;
|
||||
GetObject(hOkButton, sizeof(BITMAP), &bmTL1);
|
||||
HDC memdc = CreateCompatibleDC(ps.hdc);
|
||||
HGDIOBJ save = SelectObject(memdc, hOkButton);
|
||||
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
}
|
||||
}
|
||||
EndPaint(hWnd,&ps);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
if (::GetCapture() == hWnd)
|
||||
{
|
||||
POINT ptCursor = { ((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)) };
|
||||
ClientToScreen(hWnd, &ptCursor);
|
||||
RECT rect;
|
||||
GetWindowRect(hWnd, &rect);
|
||||
bool uPressed = ::PtInRect(&rect, ptCursor)==TRUE;
|
||||
if ( m_fPressed != uPressed )
|
||||
{
|
||||
m_fPressed = uPressed;
|
||||
::InvalidateRect(hWnd, NULL, TRUE);
|
||||
UpdateWindow(hWnd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
LRESULT lRet = 0;
|
||||
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
SetCapture(hWnd);
|
||||
if ( ::GetCapture()==hWnd )
|
||||
{
|
||||
m_fPressed = true;
|
||||
|
||||
if (m_fPressed)
|
||||
{
|
||||
::InvalidateRect(hWnd, NULL, TRUE);
|
||||
UpdateWindow(hWnd);
|
||||
}
|
||||
}
|
||||
return lRet;
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
LRESULT lRet = 0;
|
||||
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
if ( ::GetCapture() == hWnd )
|
||||
{
|
||||
::ReleaseCapture();
|
||||
if ( m_fPressed )
|
||||
{
|
||||
::SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd);
|
||||
}
|
||||
}
|
||||
m_fPressed = false;
|
||||
|
||||
return lRet;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CallWindowProc(pfnWndLangSelectOkProc, hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static HBITMAP hbmpBackgroundTop = NULL;
|
||||
static HBITMAP hbmpBackgroundBottom = NULL;
|
||||
static HBITMAP hbmpBackgroundMiddle = NULL;
|
||||
static HFONT hTextFont = NULL;
|
||||
static CLanguageSelector * lngClass;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE);
|
||||
{
|
||||
lngClass = (CLanguageSelector *)lParam;
|
||||
|
||||
LanguageList LangList = g_Lang->GetLangList();
|
||||
if (LangList.size() == 0)
|
||||
{
|
||||
EndDialog(hDlg,0);
|
||||
}
|
||||
for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++)
|
||||
{
|
||||
int index = SendMessageW(GetDlgItem(hDlg,IDC_LANG_SEL),CB_ADDSTRING,0,(WPARAM)Language->LanguageName.c_str());
|
||||
if (_wcsicmp(Language->LanguageName.c_str(),L"English") == 0)
|
||||
{
|
||||
SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,index,0);
|
||||
}
|
||||
}
|
||||
|
||||
int Index = SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETCURSEL,0,0);
|
||||
if (Index < 0)
|
||||
{
|
||||
SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,0,0);
|
||||
}
|
||||
|
||||
enum { ROUND_EDGE = 15 };
|
||||
|
||||
DWORD dwStyle = GetWindowLong(hDlg, GWL_STYLE);
|
||||
dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
|
||||
SetWindowLong(hDlg, GWL_STYLE, dwStyle);
|
||||
|
||||
// Use the size of the image
|
||||
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_TOP));
|
||||
hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_BOTTOM));
|
||||
hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_MIDDLE));
|
||||
BITMAP bmTL;
|
||||
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
|
||||
|
||||
if (hbmpBackgroundTop)
|
||||
{
|
||||
// int iHeight = bmTL.bmHeight;
|
||||
int iWidth = bmTL.bmWidth;
|
||||
|
||||
RECT rect;
|
||||
GetWindowRect(hDlg, &rect);
|
||||
rect.left -= rect.left;
|
||||
rect.bottom -= rect.top;
|
||||
rect.top -= rect.top;
|
||||
|
||||
// Tweaked
|
||||
HRGN hWindowRegion= CreateRoundRectRgn
|
||||
(
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1,
|
||||
rect.bottom+GetSystemMetrics(SM_CYEDGE)-1,
|
||||
ROUND_EDGE,
|
||||
ROUND_EDGE
|
||||
);
|
||||
|
||||
if (hWindowRegion)
|
||||
{
|
||||
SetWindowRgn(hDlg, hWindowRegion, TRUE);
|
||||
DeleteObject(hWindowRegion);
|
||||
}
|
||||
}
|
||||
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"
|
||||
);
|
||||
SendDlgItemMessage(hDlg,IDC_SELECT_LANG,WM_SETFONT,(WPARAM)hTextFont,TRUE);
|
||||
}
|
||||
|
||||
hOkButton = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK));
|
||||
pfnWndLangSelectOkProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC);
|
||||
::SetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC,(LONG_PTR)LangSelectOkProc);
|
||||
break;
|
||||
case WM_NCHITTEST:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
RECT client, a;
|
||||
GetClientRect(hDlg,&a);
|
||||
GetClientRect(hDlg,&client);
|
||||
ClientToScreen(hDlg,(LPPOINT)&client);
|
||||
client.right += client.left;
|
||||
client.bottom += client.top;
|
||||
|
||||
int nCaption = GetSystemMetrics(SM_CYCAPTION)*4;
|
||||
|
||||
LRESULT lResult = HTCLIENT;
|
||||
|
||||
//check caption
|
||||
if (xPos <= client.right && xPos >= client.left &&
|
||||
(yPos >= client.top+ 0)&& (yPos <= client.top + 0+nCaption))
|
||||
{
|
||||
lResult = HTCAPTION;
|
||||
}
|
||||
SetWindowLong(hDlg, DWLP_MSGRESULT, lResult);
|
||||
return 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;
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
if (BeginPaint(hDlg,&ps))
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(hDlg, &rcClient);
|
||||
|
||||
BITMAP bmTL_top, bmTL_bottom, bmTL_Middle;
|
||||
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
|
||||
GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom);
|
||||
GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle);
|
||||
|
||||
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);
|
||||
|
||||
memdc = CreateCompatibleDC(ps.hdc);
|
||||
save = SelectObject(memdc, hbmpBackgroundMiddle);
|
||||
for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight)
|
||||
{
|
||||
//BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY);
|
||||
BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
}
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
|
||||
BITMAP ;
|
||||
memdc = CreateCompatibleDC(ps.hdc);
|
||||
save = SelectObject(memdc, hbmpBackgroundBottom);
|
||||
BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
|
||||
BITMAP ;
|
||||
|
||||
EndPaint(hDlg,&ps);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
if (hbmpBackgroundTop)
|
||||
{
|
||||
DeleteObject(hbmpBackgroundTop);
|
||||
}
|
||||
if (hbmpBackgroundBottom)
|
||||
{
|
||||
DeleteObject(hbmpBackgroundBottom);
|
||||
}
|
||||
if (hbmpBackgroundMiddle)
|
||||
{
|
||||
DeleteObject(hbmpBackgroundMiddle);
|
||||
}
|
||||
|
||||
if (hTextFont)
|
||||
{
|
||||
::DeleteObject(hTextFont);
|
||||
}
|
||||
|
||||
{
|
||||
int Index = SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETCURSEL,0,0);
|
||||
|
||||
if (Index >= 0)
|
||||
{
|
||||
wchar_t String[255];
|
||||
SendMessageW(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETLBTEXT,Index,(LPARAM)String);
|
||||
g_Lang->SetLanguage(String);
|
||||
}
|
||||
}
|
||||
|
||||
EndDialog(hDlg,0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/****************************************************************************
|
||||
* *
|
||||
* Project 64 - A Nintendo 64 emulator. *
|
||||
* http://www.pj64-emu.com/ *
|
||||
* Copyright (C) 2012 Project64. All rights reserved. *
|
||||
* *
|
||||
* License: *
|
||||
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
||||
* *
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
class CLanguageSelector
|
||||
{
|
||||
public:
|
||||
CLanguageSelector ();
|
||||
|
||||
void Select ( void );
|
||||
|
||||
private:
|
||||
CLanguageSelector(const CLanguageSelector&); // Disable copy constructor
|
||||
CLanguageSelector& operator=(const CLanguageSelector&); // Disable assignment
|
||||
|
||||
static LRESULT CALLBACK LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
};
|
|
@ -408,6 +408,10 @@
|
|||
RelativePath="Multilanguage\Language Class.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Multilanguage\LanguageSelector.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="N64 System Source"
|
||||
|
@ -467,10 +471,6 @@
|
|||
RelativePath="N64 System\Mips\Memory Virtual Mem.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\N64 System\Mips\Rumblepak.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\N64 System\Mips\Mempak.cpp"
|
||||
>
|
||||
|
@ -483,6 +483,10 @@
|
|||
RelativePath="N64 System\Mips\Register Class.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\N64 System\Mips\Rumblepak.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="N64 System\Mips\Sram.cpp"
|
||||
>
|
||||
|
@ -781,10 +785,6 @@
|
|||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath="Version.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Multilanguage.h"
|
||||
>
|
||||
|
@ -809,6 +809,10 @@
|
|||
RelativePath="User Interface.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Version.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="WTL App.h"
|
||||
>
|
||||
|
@ -1048,6 +1052,10 @@
|
|||
RelativePath="Multilanguage\Language Class.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Multilanguage\LanguageSelector.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="N64 System Headers"
|
||||
|
@ -1119,10 +1127,6 @@
|
|||
RelativePath="N64 System\Mips\Memory Virtual Mem.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\N64 System\Mips\Rumblepak.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\N64 System\Mips\Mempak.H"
|
||||
>
|
||||
|
@ -1139,6 +1143,10 @@
|
|||
RelativePath="N64 System\Mips\Register Class.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\N64 System\Mips\Rumblepak.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="N64 System\Mips\Sram.h"
|
||||
>
|
||||
|
@ -1323,22 +1331,22 @@
|
|||
<Filter
|
||||
Name="Zlib Headers"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\3rd Party\zlib\zconf.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\3rd Party\zlib\zlib.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\3rd Party\zlib\contrib\minizip\unzip.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\3rd Party\zlib\zconf.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\3rd Party\zlib\contrib\minizip\zip.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\3rd Party\zlib\zlib.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Filter>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include "Multilanguage\LanguageSelector.h"
|
||||
#include <Tlhelp32.h>
|
||||
|
||||
CTraceFileLog * LogFile = NULL;
|
||||
|
@ -204,8 +205,6 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /
|
|||
try
|
||||
{
|
||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL );
|
||||
g_Lang = new CLanguage();
|
||||
|
||||
g_Settings = new CSettings;
|
||||
g_Settings->Initialize(AppName());
|
||||
|
||||
|
@ -229,7 +228,12 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /
|
|||
g_Plugins = new CPlugins(g_Settings->LoadStringVal(Directory_Plugin));
|
||||
|
||||
//Select the language
|
||||
g_Lang->LoadCurrentStrings(true);
|
||||
g_Lang = new CLanguage();
|
||||
if (!g_Lang->LoadCurrentStrings())
|
||||
{
|
||||
CLanguageSelector().Select();
|
||||
}
|
||||
|
||||
|
||||
//Create the main window with Menu
|
||||
WriteTrace(TraceDebug,__FUNCTION__ ": Create Main Window");
|
||||
|
|
Loading…
Reference in New Issue