Project64: Add choosing game dir on welcome screen

This commit is contained in:
zilmar 2020-08-04 22:28:40 +09:30
parent c169291135
commit 883632b4a4
15 changed files with 368 additions and 200 deletions

View File

@ -1,146 +0,0 @@
/****************************************************************************
* *
* Project64 - 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)
{
DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_Lang_Select), NULL, (DLGPROC)LangSelectProc, (LPARAM)this);
}
LRESULT CALLBACK CLanguageSelector::LangSelectProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HBITMAP hbmpBackgroundTop = NULL;
static HFONT hTextFont = NULL;
static CLanguageSelector * lngClass;
switch (uMsg)
{
case WM_INITDIALOG:
{
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)stdstr(Language->LanguageName).ToUTF16().c_str());
if (_stricmp(Language->LanguageName.c_str(), "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);
}
//Get Windows DPI Scale
float DPIScale = CClientDC(hDlg).GetDeviceCaps(LOGPIXELSX) / 96.0f;
// Use the size of the image
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), DPIScale <= 1.0f ? MAKEINTRESOURCE(IDB_ABOUT_LOGO) : MAKEINTRESOURCE(IDB_ABOUT_LOGO_HDPI));
BITMAP bmTL;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
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, L"Arial");
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;
case WM_ERASEBKGND:
{
HPEN outline;
HBRUSH fill;
RECT rect;
outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
fill = CreateSolidBrush(0x00FFFFFF);
SelectObject((HDC)wParam, outline);
SelectObject((HDC)wParam, fill);
GetClientRect(hDlg, &rect);
Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom);
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
if (BeginPaint(hDlg, &ps))
{
RECT rcClient;
GetClientRect(hDlg, &rcClient);
BITMAP bmTL_top;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
SetStretchBltMode(ps.hdc, HALFTONE);
StretchBlt(ps.hdc, 0, 0, rcClient.right, (int)(bmTL_top.bmHeight * rcClient.right / bmTL_top.bmWidth), memdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
EndPaint(hDlg, &ps);
}
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
if (hbmpBackgroundTop)
{
DeleteObject(hbmpBackgroundTop);
}
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(stdstr().FromUTF16(String).c_str());
}
}
EndDialog(hDlg, 0);
break;
}
default:
return FALSE;
}
return TRUE;
}

View File

@ -51,7 +51,6 @@
<ClCompile Include="UserInterface\Debugger\CPULog.cpp" /> <ClCompile Include="UserInterface\Debugger\CPULog.cpp" />
<ClCompile Include="UserInterface\Debugger\Debugger-CPULogView.cpp" /> <ClCompile Include="UserInterface\Debugger\Debugger-CPULogView.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="Multilanguage\LanguageSelector.cpp" />
<ClCompile Include="Plugins\PluginList.cpp" /> <ClCompile Include="Plugins\PluginList.cpp" />
<ClCompile Include="Settings\GuiSettings.cpp" /> <ClCompile Include="Settings\GuiSettings.cpp" />
<ClCompile Include="Settings\NotificationSettings.cpp" /> <ClCompile Include="Settings\NotificationSettings.cpp" />
@ -110,17 +109,19 @@
<ClCompile Include="UserInterface\Settings\SettingsPage.cpp" /> <ClCompile Include="UserInterface\Settings\SettingsPage.cpp" />
<ClCompile Include="UserInterface\SupportEnterCode.cpp" /> <ClCompile Include="UserInterface\SupportEnterCode.cpp" />
<ClCompile Include="UserInterface\SupportWindow.cpp" /> <ClCompile Include="UserInterface\SupportWindow.cpp" />
<ClCompile Include="UserInterface\WelcomeScreen.cpp" />
<ClCompile Include="UserInterface\WTLControls\EditNumber32.cpp" /> <ClCompile Include="UserInterface\WTLControls\EditNumber32.cpp" />
<ClCompile Include="UserInterface\WTLControls\GetCWindowText.cpp" />
<ClCompile Include="UserInterface\WTLControls\HexEditCtrl.cpp" /> <ClCompile Include="UserInterface\WTLControls\HexEditCtrl.cpp" />
<ClCompile Include="UserInterface\WTLControls\ModifiedEditBox.cpp" /> <ClCompile Include="UserInterface\WTLControls\ModifiedEditBox.cpp" />
<ClCompile Include="UserInterface\WTLControls\PartialGroupBox.cpp" /> <ClCompile Include="UserInterface\WTLControls\PartialGroupBox.cpp" />
<ClCompile Include="UserInterface\WTLControls\wtl-BitmapPicture.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="DiscordRPC.h" /> <ClInclude Include="DiscordRPC.h" />
<ClInclude Include="UserInterface\Debugger\CPULog.h" /> <ClInclude Include="UserInterface\Debugger\CPULog.h" />
<ClInclude Include="UserInterface\Debugger\Debugger-CPULogView.h" /> <ClInclude Include="UserInterface\Debugger\Debugger-CPULogView.h" />
<ClInclude Include="N64System\Debugger\OpInfo.h" /> <ClInclude Include="N64System\Debugger\OpInfo.h" />
<ClInclude Include="Multilanguage\LanguageSelector.h" />
<ClInclude Include="N64System.h" /> <ClInclude Include="N64System.h" />
<ClInclude Include="Settings\GuiSettings.h" /> <ClInclude Include="Settings\GuiSettings.h" />
<ClInclude Include="Settings\NotificationSettings.h" /> <ClInclude Include="Settings\NotificationSettings.h" />
@ -184,6 +185,7 @@
<ClInclude Include="UserInterface\Settings\SettingsPage.h" /> <ClInclude Include="UserInterface\Settings\SettingsPage.h" />
<ClInclude Include="UserInterface\SupportEnterCode.h" /> <ClInclude Include="UserInterface\SupportEnterCode.h" />
<ClInclude Include="UserInterface\SupportWindow.h" /> <ClInclude Include="UserInterface\SupportWindow.h" />
<ClInclude Include="UserInterface\WelcomeScreen.h" />
<ClInclude Include="UserInterface\WTLControls\DisplayMode.h" /> <ClInclude Include="UserInterface\WTLControls\DisplayMode.h" />
<ClInclude Include="UserInterface\WTLControls\EditNumber32.h" /> <ClInclude Include="UserInterface\WTLControls\EditNumber32.h" />
<ClInclude Include="UserInterface\WTLControls\GetCWindowText.h" /> <ClInclude Include="UserInterface\WTLControls\GetCWindowText.h" />
@ -193,6 +195,7 @@
<ClInclude Include="UserInterface\WTLControls\ModifiedEditBox.h" /> <ClInclude Include="UserInterface\WTLControls\ModifiedEditBox.h" />
<ClInclude Include="UserInterface\WTLControls\PartialGroupBox.h" /> <ClInclude Include="UserInterface\WTLControls\PartialGroupBox.h" />
<ClInclude Include="UserInterface\WTLControls\TooltipDialog.h" /> <ClInclude Include="UserInterface\WTLControls\TooltipDialog.h" />
<ClInclude Include="UserInterface\WTLControls\wtl-BitmapPicture.h" />
<ClInclude Include="WTLApp.h" /> <ClInclude Include="WTLApp.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -20,9 +20,6 @@
<Filter Include="Source Files\User Interface Source\Debugger Source"> <Filter Include="Source Files\User Interface Source\Debugger Source">
<UniqueIdentifier>{89244064-68f5-44d9-9021-7a592d910e43}</UniqueIdentifier> <UniqueIdentifier>{89244064-68f5-44d9-9021-7a592d910e43}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Source Files\Multilanguage Source">
<UniqueIdentifier>{94e87bf5-3b11-4f61-8a4a-333690ecf588}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Plugin Source"> <Filter Include="Source Files\Plugin Source">
<UniqueIdentifier>{242ae4a5-b150-44e6-b31c-027acd6d38b0}</UniqueIdentifier> <UniqueIdentifier>{242ae4a5-b150-44e6-b31c-027acd6d38b0}</UniqueIdentifier>
</Filter> </Filter>
@ -43,9 +40,6 @@
<Filter Include="Header Files\User Interface Headers\WTL Controls Headers"> <Filter Include="Header Files\User Interface Headers\WTL Controls Headers">
<UniqueIdentifier>{838a58e7-e1d2-45d3-bcf0-dcedad19610c}</UniqueIdentifier> <UniqueIdentifier>{838a58e7-e1d2-45d3-bcf0-dcedad19610c}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Header Files\Multilanguage Headers">
<UniqueIdentifier>{5531af4d-33bb-4e84-8a55-c971a18ec7bf}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Settings"> <Filter Include="Header Files\Settings">
<UniqueIdentifier>{8eaf5c00-c88d-418e-a27c-d658c547ab79}</UniqueIdentifier> <UniqueIdentifier>{8eaf5c00-c88d-418e-a27c-d658c547ab79}</UniqueIdentifier>
</Filter> </Filter>
@ -132,9 +126,6 @@
<ClCompile Include="Settings\NotificationSettings.cpp"> <ClCompile Include="Settings\NotificationSettings.cpp">
<Filter>Source Files\Settings Files</Filter> <Filter>Source Files\Settings Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Multilanguage\LanguageSelector.cpp">
<Filter>Source Files\Multilanguage Source</Filter>
</ClCompile>
<ClCompile Include="UserInterface\RomInformationClass.cpp"> <ClCompile Include="UserInterface\RomInformationClass.cpp">
<Filter>Source Files\User Interface Source</Filter> <Filter>Source Files\User Interface Source</Filter>
</ClCompile> </ClCompile>
@ -246,14 +237,20 @@
<ClCompile Include="UserInterface\SupportWindow.cpp"> <ClCompile Include="UserInterface\SupportWindow.cpp">
<Filter>Source Files\User Interface Source</Filter> <Filter>Source Files\User Interface Source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="UserInterface\WelcomeScreen.cpp">
<Filter>Source Files\User Interface Source</Filter>
</ClCompile>
<ClCompile Include="UserInterface\WTLControls\wtl-BitmapPicture.cpp">
<Filter>Source Files\User Interface Source\WTL Controls Source</Filter>
</ClCompile>
<ClCompile Include="UserInterface\WTLControls\GetCWindowText.cpp">
<Filter>Source Files\User Interface Source\WTL Controls Source</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="UserInterface\resource.h"> <ClInclude Include="UserInterface\resource.h">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Multilanguage\LanguageSelector.h">
<Filter>Header Files\Multilanguage Headers</Filter>
</ClInclude>
<ClInclude Include="UserInterface\CheatClassUI.h"> <ClInclude Include="UserInterface\CheatClassUI.h">
<Filter>Header Files\User Interface Headers</Filter> <Filter>Header Files\User Interface Headers</Filter>
</ClInclude> </ClInclude>
@ -482,6 +479,12 @@
<ClInclude Include="UserInterface\Debugger\Debugger-RegisterTabData.h"> <ClInclude Include="UserInterface\Debugger\Debugger-RegisterTabData.h">
<Filter>Header Files\User Interface Headers\Debugger Headers</Filter> <Filter>Header Files\User Interface Headers\Debugger Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="UserInterface\WelcomeScreen.h">
<Filter>Header Files\User Interface Headers</Filter>
</ClInclude>
<ClInclude Include="UserInterface\WTLControls\wtl-BitmapPicture.h">
<Filter>Header Files\User Interface Headers\WTL Controls Headers</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="res\divider.cur"> <None Include="res\divider.cur">

View File

@ -936,8 +936,8 @@ stdstr CRegisterTabs::CopyTabRegisters(int id)
{ {
str += stdstr_f( str += stdstr_f(
"\r\n%s %s", "\r\n%s %s",
::GetCWindowText(label).c_str(), ::GetCWindowText(*label).c_str(),
::GetCWindowText(edit).c_str()); ::GetCWindowText(*edit).c_str());
}); });
switch (id) switch (id)
@ -1042,7 +1042,7 @@ uint64_t CEditReg64::GetValue()
stdstr CEditReg64::GetValueText() stdstr CEditReg64::GetValueText()
{ {
return ::GetCWindowText(this); return ::GetCWindowText(*this);
} }
LRESULT CEditReg64::OnLostFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) LRESULT CEditReg64::OnLostFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)

View File

@ -496,14 +496,18 @@ BEGIN
PUSHBUTTON "Close",IDCANCEL,154,110,50,14 PUSHBUTTON "Close",IDCANCEL,154,110,50,14
END END
IDD_Lang_Select DIALOGEX 0, 0, 233, 120 IDD_Welcome DIALOGEX 0, 0, 234, 126
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION
CAPTION "Project64" CAPTION "Project64 - Welcome"
FONT 8, "MS Shell Dlg", 0, 0, 0x0 FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN BEGIN
DEFPUSHBUTTON "OK",IDOK,90,99,50,12 DEFPUSHBUTTON "OK",IDOK,90,108,50,12
LTEXT "Select Language:",IDC_SELECT_LANG,12,77,86,12 LTEXT "Select Language:",IDC_SELECT_LANG,12,77,86,12
COMBOBOX IDC_LANG_SEL,105,77,112,120,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_LANG_SEL,82,77,130,120,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_BMP_LOGO,"Static",SS_BLACKFRAME,1,0,232,74
LTEXT "Game Directory:",IDC_GAME_DIR_STATIC,12,91,86,12
EDITTEXT IDC_GAME_DIR,82,91,130,12,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_SELECT_GAME_DIR,215,91,14,12
END END
IDD_Debugger_Memory DIALOGEX 0, 0, 321, 199 IDD_Debugger_Memory DIALOGEX 0, 0, 321, 199
@ -1584,12 +1588,10 @@ BEGIN
BOTTOMMARGIN, 124 BOTTOMMARGIN, 124
END END
IDD_Lang_Select, DIALOG IDD_Welcome, DIALOG
BEGIN BEGIN
LEFTMARGIN, 7 RIGHTMARGIN, 233
RIGHTMARGIN, 230 BOTTOMMARGIN, 120
TOPMARGIN, 7
BOTTOMMARGIN, 107
END END
IDD_Debugger_Memory, DIALOG IDD_Debugger_Memory, DIALOG
@ -2224,6 +2226,11 @@ BEGIN
0 0
END END
IDD_Welcome AFX_DIALOG_LAYOUT
BEGIN
0
END
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //

View File

@ -333,7 +333,7 @@ uint32_t CEditNumber32::GetValue(void)
stdstr CEditNumber32::GetValueText(void) stdstr CEditNumber32::GetValueText(void)
{ {
return ::GetCWindowText(this); return ::GetCWindowText(*this);
} }
void CEditNumber32::SetValue(uint32_t Value, DisplayMode Display) void CEditNumber32::SetValue(uint32_t Value, DisplayMode Display)

View File

@ -0,0 +1,16 @@
#include "stdafx.h"
#include "GetCWindowText.h"
#include <Common\StdString.h>
std::string GetCWindowText(const CWindow & window)
{
int nLen = window.GetWindowTextLength();
if (nLen == 0)
{
return "";
}
std::wstring WindowText;
WindowText.resize(nLen + 1);
window.GetWindowText((wchar_t *)WindowText.c_str(), nLen + 1);
return stdstr().FromUTF16(WindowText.c_str());
}

View File

@ -1,17 +1,5 @@
#pragma once #pragma once
#include <string>
#include "stdafx.h" std::string GetCWindowText(const CWindow & window);
inline static stdstr GetCWindowText(const CWindow *window)
{
stdstr Result;
int nLen = ::GetWindowTextLengthW(window->m_hWnd);
if (nLen == 0)
{
return Result;
}
std::wstring WindowText;
WindowText.resize(nLen + 1);
::GetWindowTextW(window->m_hWnd, (wchar_t *)WindowText.c_str(), nLen + 1);
return Result.FromUTF16(WindowText.c_str());
}

View File

@ -80,7 +80,7 @@ void CModifiedEditBox::SetChanged(bool Changed)
stdstr CModifiedEditBox::GetWindowText(void) stdstr CModifiedEditBox::GetWindowText(void)
{ {
ATLASSERT(::IsWindow(m_hWnd)); ATLASSERT(::IsWindow(m_hWnd));
return ::GetCWindowText(this); return ::GetCWindowText(*this);
} }
void CModifiedEditBox::SetTextField(HWND hWnd) void CModifiedEditBox::SetTextField(HWND hWnd)

View File

@ -0,0 +1,103 @@
/****************************************************************************
* *
* Project64 - 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 "wtl-BitmapPicture.h"
CBitmapPicture::CBitmapPicture() :
m_hBitmap(NULL),
m_nResourceID(-1),
m_ResourceIcon(false)
{
memset(&m_bmInfo, 0, sizeof(m_bmInfo));
m_BackgroundBrush.CreateSolidBrush(::GetSysColor(COLOR_3DFACE));
}
LRESULT CBitmapPicture::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL &/*bHandled*/)
{
CPaintDC dc(m_hWnd);
CRect rect;
GetClientRect(&rect);
CBrush PaintBrush;
HBRUSH OldBrush = dc.SelectBrush(m_BackgroundBrush);
dc.PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
if (m_ResourceIcon)
{
CIcon hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), m_nResourceID > 0 ? MAKEINTRESOURCE(m_nResourceID) : m_strResourceName.c_str(), IMAGE_ICON, m_IconWidth, m_IconHeight, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
if (!hIcon.IsNull())
{
dc.DrawIconEx(0, 0, hIcon, rect.Width(), rect.Height(), 0, NULL, DI_NORMAL);
}
}
else
{
CBitmap hBmp = (HBITMAP)::LoadImage(ModuleHelper::GetResourceInstance(), m_nResourceID > 0 ? MAKEINTRESOURCE(m_nResourceID) : m_strResourceName.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
BITMAP bm;
hBmp.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(dc);
dcMem.SelectBitmap(hBmp);
dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
}
dc.SelectBrush(OldBrush);
return 0;
}
bool CBitmapPicture::SetIcon(LPCWSTR lpszResourceName, uint32_t nWidth, uint32_t nHeight)
{
CIcon hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), lpszResourceName, IMAGE_ICON, nWidth, nHeight, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
if (hIcon.IsNull())
{
return false;
}
ICONINFO IconInfo;
if (!hIcon.GetIconInfo(&IconInfo))
{
return false;
}
if (IS_INTRESOURCE(lpszResourceName))
{
m_nResourceID = (int)lpszResourceName;
}
else
{
m_strResourceName = lpszResourceName;
}
m_ResourceIcon = true;
m_IconWidth = nWidth;
m_IconHeight = nHeight;
return true;
}
bool CBitmapPicture::SetBitmap(HBITMAP hBitmap)
{
m_hBitmap.Attach(hBitmap);
return ::GetObject(m_hBitmap, sizeof(BITMAP), &m_bmInfo) != 0;
}
void CBitmapPicture::SetBitmap(LPCWSTR lpszResourceName)
{
if (IS_INTRESOURCE(lpszResourceName))
{
m_nResourceID = (int)lpszResourceName;
}
else
{
m_strResourceName = lpszResourceName;
}
m_ResourceIcon = false;
}
void CBitmapPicture::SetBackroundBrush(HBRUSH brush)
{
m_BackgroundBrush.Attach(brush);
}

View File

@ -10,16 +10,33 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
class CLanguageSelector class CBitmapPicture :
public CWindowImpl <CBitmapPicture>
{ {
public: public:
CLanguageSelector(); BEGIN_MSG_MAP(CBitmapPicture)
MESSAGE_HANDLER(WM_PAINT, OnPaint);
END_MSG_MAP()
void Select(void); CBitmapPicture();
LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL &/*bHandled*/);
bool SetIcon(LPCWSTR lpszResourceName, uint32_t nWidth, uint32_t nHeight);
void SetBitmap(LPCWSTR lpszResourceName);
void SetBackroundBrush(HBRUSH brush);
private: private:
CLanguageSelector(const CLanguageSelector&); // Disable copy constructor CBitmapPicture(const CBitmapPicture&);
CLanguageSelector& operator=(const CLanguageSelector&); // Disable assignment CBitmapPicture& operator=(const CBitmapPicture&);
static LRESULT CALLBACK LangSelectProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); bool CBitmapPicture::SetBitmap(HBITMAP hBitmap);
int m_nResourceID;
std::wstring m_strResourceName;
uint32_t m_IconWidth, m_IconHeight;
bool m_ResourceIcon;
BITMAP m_bmInfo;
CBitmap m_hBitmap;
CBrush m_BackgroundBrush;
}; };

View File

@ -0,0 +1,127 @@
/****************************************************************************
* *
* Project64 - 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 "WelcomeScreen.h"
#include "resource.h"
WelcomeScreen::WelcomeScreen()
{
}
void WelcomeScreen::SelectGameDir(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
{
wchar_t Buffer[MAX_PATH], Directory[MAX_PATH];
LPITEMIDLIST pidl;
BROWSEINFOW bi;
stdstr InitialDir = g_Settings->LoadStringVal(RomList_GameDir);
std::wstring wTitle = L"Select Game Directory";
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = Buffer;
bi.lpszTitle = wTitle.c_str();
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = (BFFCALLBACK)SelectDirCallBack;
bi.lParam = (DWORD)InitialDir.c_str();
if ((pidl = SHBrowseForFolderW(&bi)) != NULL)
{
if (SHGetPathFromIDListW(pidl, Directory))
{
stdstr path;
CPath SelectedDir(path.FromUTF16(Directory), "");
if (SelectedDir.DirectoryExists())
{
GetDlgItem(IDC_GAME_DIR).SetWindowText(Directory);
}
}
}
}
LRESULT WelcomeScreen::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_Logo.SubclassWindow(GetDlgItem(IDC_BMP_LOGO));
m_Logo.SetBitmap(MAKEINTRESOURCE(IDB_ABOUT_LOGO));
LanguageList LangList = g_Lang->GetLangList();
CComboBox LangCB(GetDlgItem(IDC_LANG_SEL));
for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++)
{
int Index = LangCB.AddString(stdstr(Language->LanguageName).ToUTF16().c_str());
if (_stricmp(Language->LanguageName.c_str(), "English") == 0)
{
LangCB.SetCurSel(Index);
}
}
if (LangCB.GetCurSel() < 0)
{
LangCB.SetCurSel(0);
}
return TRUE;
}
LRESULT WelcomeScreen::OnColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(0, 0, 0));
SetBkMode(hdcStatic, TRANSPARENT);
return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
}
LRESULT WelcomeScreen::OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
static HPEN outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
static HBRUSH fill = CreateSolidBrush(0x00FFFFFF);
SelectObject((HDC)wParam, outline);
SelectObject((HDC)wParam, fill);
RECT rect;
GetClientRect(&rect);
Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom);
return TRUE;
}
LRESULT WelcomeScreen::OnOkCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
CComboBox LangCB(GetDlgItem(IDC_LANG_SEL));
int Index = LangCB.GetCurSel();
if (Index >= 0)
{
wchar_t String[255];
LangCB.GetLBText(Index, String);
g_Lang->SetLanguage(stdstr().FromUTF16(String).c_str());
}
CPath GameDir(GetCWindowText(GetDlgItem(IDC_GAME_DIR)).c_str(), "");
if (GameDir.DirectoryExists())
{
g_Settings->SaveString(RomList_GameDir, GameDir.GetDirectory().c_str());
Notify().AddRecentDir(GameDir);
}
EndDialog(0);
return TRUE;
}
int CALLBACK WelcomeScreen::SelectDirCallBack(HWND hwnd, DWORD uMsg, DWORD /*lp*/, DWORD lpData)
{
switch (uMsg)
{
case BFFM_INITIALIZED:
// WParam is TRUE since you are passing a path.
// It would be FALSE if you were passing a pidl.
if (lpData)
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
}
break;
}
return 0;
}

View File

@ -0,0 +1,45 @@
/****************************************************************************
* *
* Project64 - 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
#include <Project64\UserInterface\WTLControls\wtl-BitmapPicture.h>
#include "resource.h"
class WelcomeScreen :
public CDialogImpl<WelcomeScreen>
{
public:
BEGIN_MSG_MAP_EX(CEnhancementConfig)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnColorStatic)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
COMMAND_ID_HANDLER_EX(IDC_SELECT_GAME_DIR, SelectGameDir)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
END_MSG_MAP()
enum { IDD = IDD_Lang_Select };
WelcomeScreen(void);
private:
WelcomeScreen(const WelcomeScreen&);
WelcomeScreen& operator=(const WelcomeScreen&);
void SelectGameDir(UINT Code, int id, HWND ctl);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnOkCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
static int CALLBACK SelectDirCallBack(HWND hwnd, DWORD uMsg, DWORD lp, DWORD lpData);
CBitmapPicture m_Logo;
};

View File

@ -47,6 +47,7 @@
#define IDR_CHEAT_MENU 160 #define IDR_CHEAT_MENU 160
#define IDD_Debugger_AddBreakpoint 160 #define IDD_Debugger_AddBreakpoint 160
#define IDD_Lang_Select 161 #define IDD_Lang_Select 161
#define IDD_Welcome 161
#define IDD_Settings_GameRecompiler 162 #define IDD_Settings_GameRecompiler 162
#define IDD_Settings_GamePlugin 163 #define IDD_Settings_GamePlugin 163
#define IDD_Settings_GameStatus 164 #define IDD_Settings_GameStatus 164
@ -233,6 +234,7 @@
#define IDC_INFO3 1083 #define IDC_INFO3 1083
#define IDC_START_ON_ROM_OPEN 1084 #define IDC_START_ON_ROM_OPEN 1084
#define IDC_LABEL1 1084 #define IDC_LABEL1 1084
#define IDC_BMP_LOGO 1084
#define IDC_BLOCK_LINKING 1085 #define IDC_BLOCK_LINKING 1085
#define IDC_LABEL2 1085 #define IDC_LABEL2 1085
#define IDC_LABEL3 1086 #define IDC_LABEL3 1086
@ -243,6 +245,7 @@
#define IDC_SAVE_TYPE 1089 #define IDC_SAVE_TYPE 1089
#define IDC_MENU_ITEMS 1089 #define IDC_MENU_ITEMS 1089
#define IDC_PAGELIST 1090 #define IDC_PAGELIST 1090
#define IDC_GAME_DIR_STATIC 1090
#define IDC_CPU_TYPE_TEXT 1092 #define IDC_CPU_TYPE_TEXT 1092
#define IDC_ZIP 1092 #define IDC_ZIP 1092
#define IDC_SETTING_INFO 1092 #define IDC_SETTING_INFO 1092
@ -715,7 +718,9 @@
#define IDC_COPYTABREGISTERS_BTN 1574 #define IDC_COPYTABREGISTERS_BTN 1574
#define IDC_MEMORY_SIZE_NOTE 1574 #define IDC_MEMORY_SIZE_NOTE 1574
#define IDC_F0_LBL 1575 #define IDC_F0_LBL 1575
#define IDC_GAME_DIR 1575
#define IDC_F1_LBL 1576 #define IDC_F1_LBL 1576
#define IDC_SELECT_GAME_DIR 1576
#define IDC_F2_LBL 1577 #define IDC_F2_LBL 1577
#define IDC_F3_LBL 1578 #define IDC_F3_LBL 1578
#define IDC_F4_LBL 1579 #define IDC_F4_LBL 1579
@ -933,9 +938,9 @@
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 219 #define _APS_NEXT_RESOURCE_VALUE 220
#define _APS_NEXT_COMMAND_VALUE 40121 #define _APS_NEXT_COMMAND_VALUE 40121
#define _APS_NEXT_CONTROL_VALUE 1575 #define _APS_NEXT_CONTROL_VALUE 1577
#define _APS_NEXT_SYMED_VALUE 102 #define _APS_NEXT_SYMED_VALUE 102
#endif #endif
#endif #endif

View File

@ -1,7 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include <Project64-core/AppInit.h> #include <Project64-core\AppInit.h>
#include "Multilanguage\LanguageSelector.h" #include "UserInterface\WelcomeScreen.h"
#include "Settings/UISettings.h" #include "Settings\UISettings.h"
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/) int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/)
{ {
@ -11,7 +11,7 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /
AppInit(&Notify(), CPath(CPath::MODULE_DIRECTORY), __argc, __argv); AppInit(&Notify(), CPath(CPath::MODULE_DIRECTORY), __argc, __argv);
if (!g_Lang->IsLanguageLoaded()) if (!g_Lang->IsLanguageLoaded())
{ {
CLanguageSelector().Select(); WelcomeScreen().DoModal();
} }
//Create the main window with Menu //Create the main window with Menu