project64/Source/Project64/UserInterface/WelcomeScreen.cpp

134 lines
4.1 KiB
C++
Raw Normal View History

#include "stdafx.h"
2022-09-21 05:16:07 +00:00
#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;
BROWSEINFO bi;
stdstr InitialDir = g_Settings->LoadStringVal(RomList_GameDir);
std::wstring wTitle = L"Select Game Directory";
bi.hwndOwner = m_hWnd;
2021-04-12 11:35:39 +00:00
bi.pidlRoot = nullptr;
bi.pszDisplayName = Buffer;
bi.lpszTitle = wTitle.c_str();
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = (BFFCALLBACK)SelectDirCallBack;
bi.lParam = (LPARAM)InitialDir.c_str();
2021-04-12 11:35:39 +00:00
if ((pidl = SHBrowseForFolder(&bi)) != nullptr)
{
if (SHGetPathFromIDList(pidl, Directory))
{
stdstr path;
CPath SelectedDir(path.FromUTF16(Directory), "");
if (SelectedDir.DirectoryExists())
{
GetDlgItem(IDC_GAME_DIR).SetWindowText(Directory);
}
}
}
}
2022-09-21 05:16:07 +00:00
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));
2022-09-21 05:16:07 +00:00
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);
}
2021-03-01 09:38:29 +00:00
CButton(GetDlgItem(IDC_RADIO_GLIDEN64)).SetCheck(BST_CHECKED);
return TRUE;
}
2022-09-21 05:16:07 +00:00
LRESULT WelcomeScreen::OnCtlColorStatic(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));
}
2021-03-01 09:38:29 +00:00
BOOL WelcomeScreen::OnEraseBackground(CDCHandle dc)
{
static HPEN outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
static HBRUSH fill = CreateSolidBrush(0x00FFFFFF);
2021-03-01 09:38:29 +00:00
dc.SelectPen(outline);
dc.SelectBrush(fill);
RECT rect;
GetClientRect(&rect);
2021-03-01 09:38:29 +00:00
dc.Rectangle(&rect);
return TRUE;
}
2021-03-01 09:38:29 +00:00
HBRUSH WelcomeScreen::OnCtlColorStatic(CDCHandle dc, CStatic /*wndStatic*/)
{
dc.SetBkColor(RGB(255, 255, 255));
dc.SetDCBrushColor(RGB(255, 255, 255));
return (HBRUSH)GetStockObject(DC_BRUSH);
}
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.GetDriveDirectory().c_str());
Notify().AddRecentDir(GameDir);
}
2021-03-01 09:38:29 +00:00
string Project64VideoPluginPath = g_Settings->LoadStringVal(Plugin_GFX_Default);
2022-09-21 05:16:07 +00:00
if (Project64VideoPluginPath.find("Project64-Video") == string::npos)
{
Project64VideoPluginPath = "GFX\\Project64-Video.dll";
}
g_Settings->SaveString(Plugin_GFX_Default, CButton(GetDlgItem(IDC_RADIO_GLIDEN64)).GetCheck() == BST_CHECKED ? "GFX\\GLideN64\\GLideN64.dll" : Project64VideoPluginPath);
g_Settings->SaveString(Plugin_GFX_Current, g_Settings->LoadStringVal(Plugin_GFX_Default));
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;
}