📄 wince_gamelist.cpp
字号:
/* PocketCultMAME - MAME Emulator for PocketPC
(c) Copyright 2006 Manuel Castrillo Mart韓ez
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <windowsx.h>
#include <wingdi.h>
#include <aygshell.h>
#include <commctrl.h>
#include "wince_driver.h"
#include "wince_options.h"
#include "wince_cfg.h"
#include "resource.h"
extern "C" {
extern char path_mame[];
extern void setFullScreenDialog( HWND hDlg );
extern cfgStruct GameConfig; // from wince_cfg.cpp
}
extern HWND hWnd; // from wince_mame.cpp
extern HINSTANCE g_hInstance;
extern int GameIndexToConfigure; // from wince_options.cpp
HWND lstGames;
int gamesIndex[1024*2];
int gameIndexCounter = 0;
bool defaultImageError = FALSE;
///
/// Fill game list
///
void fillGamelist()
{
WIN32_FIND_DATA fd;
TCHAR Path[MAX_PATH];
char wMAMEPath[MAX_PATH];
char gameName[1024];
HANDLE hFind;
BOOL bFind;
// Clear list of index
memset( &gamesIndex, 0, sizeof(gamesIndex));
// Find .zip games
sprintf(wMAMEPath,"%sroms\\*.zip\0", path_mame);
mbstowcs( Path, wMAMEPath, MAX_PATH );
hFind = FindFirstFile( Path, &fd);
bFind = (hFind != INVALID_HANDLE_VALUE);
while(bFind)
{
if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
!(fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
{
char fullGameName[1024];
TCHAR wfullGameName[1024];
int gameIndexNumber;
char *extensionPosition;
wcstombs( gameName, fd.cFileName, MAX_PATH );
extensionPosition = strrchr(gameName, '.');
*extensionPosition = '\0';
if( gameExist( gameName, fullGameName, gameIndexNumber) )
{
mbstowcs( wfullGameName, fullGameName, 1024);
gamesIndex[ gameIndexCounter ] = gameIndexNumber;
ListBox_AddString( lstGames, wfullGameName );
gameIndexCounter++;
}
}
bFind = FindNextFile(hFind, &fd);
}
FindClose(hFind);
}
bool LoadScreenshot(char *sFile, HWND hWndDialog, UINT nIDStatic)
{
TCHAR Path[MAX_PATH];
char wMAMEPath[MAX_PATH];
WIN32_FIND_DATA fd;
// Find screenshot
sprintf(wMAMEPath,"%sscreenshots\\%s.gif\0", path_mame, sFile); // Try as gif
mbstowcs( Path, wMAMEPath, MAX_PATH );
if( FindFirstFile( Path, &fd) == INVALID_HANDLE_VALUE )
{
sprintf(wMAMEPath,"%sscreenshots\\%s.jpg\0", path_mame, sFile); // Try as jpg
mbstowcs( Path, wMAMEPath, MAX_PATH );
if( FindFirstFile( Path, &fd) == INVALID_HANDLE_VALUE )
{
sprintf(wMAMEPath,"%sscreenshots\\noshot.gif\0", path_mame); // Try default image
mbstowcs( Path, wMAMEPath, MAX_PATH );
if( FindFirstFile( Path, &fd) == INVALID_HANDLE_VALUE )
{
if( !defaultImageError )
MessageBox( hWndDialog, _T("Please, create a 180x135 default image called 'noshot.gif'. Image will not change."), _T("Default image missing"), MB_OK | MB_ICONEXCLAMATION );
defaultImageError = TRUE;
return( FALSE );
}
}
}
HWND hWndStatic = GetDlgItem(hWndDialog, nIDStatic);
HBITMAP hBitmap = (HBITMAP)SHLoadImageFile(Path);
if(NULL != hBitmap)
{
BITMAP bm;
GetObject(hBitmap, sizeof(BITMAP), &bm);
if( bm.bmWidth == 180 && bm.bmHeight == 135 )
{
SendMessage(hWndStatic,STM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBitmap);
return(TRUE);
}
else
{
MessageBox( hWndDialog, _T("Invalid screenshot size, it is not 180x135."), _T("Error"), MB_OK | MB_ICONEXCLAMATION );
return(FALSE);
}
}
else
{
MessageBox( hWndDialog, _T("Error reading screenshot image file!"), _T("Error"), MB_OK | MB_ICONEXCLAMATION );
return(FALSE);
}
}
///
/// Gamelist
///
LRESULT CALLBACK dlgListGames(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
lstGames = GetDlgItem( hDlg, IDC_lstGames );
int selectedItem;
SHINITDLGINFO shidi;
switch (message)
{
case WM_INITDIALOG:
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN | SHIDIF_FULLSCREENNOMENUBAR;
shidi.hDlg = hDlg;
SHInitDialog(&shidi);
setFullScreenDialog( hDlg );
fillGamelist();
LoadScreenshot("default", hDlg, IDC_imgScreenShot);
UpdateWindow(hDlg);
return TRUE;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_lstGames:
char *ItemText;
selectedItem = ListBox_GetCurSel( lstGames );
if( selectedItem > -1 && selectedItem <= gameIndexCounter )
{
GameIndexToConfigure = gamesIndex[selectedItem]; // Game to configure
ItemText = (char *)gameNameByIndex( gamesIndex[selectedItem] );
LoadScreenshot(ItemText, hDlg, IDC_imgScreenShot);
loadConfiguration( ItemText, GameConfig);
}
break;
case IDOK :
case IDC_btnStart :
selectedItem = ListBox_GetCurSel( lstGames );
if(selectedItem < 0)
{
MessageBox( hDlg, _T("Please, select a game to start."), _T("Start"), MB_OK);
}
else
{
EndDialog(hDlg, gamesIndex[selectedItem] );
return TRUE;
}
break;
case IDC_btnOptions :
DialogBox( g_hInstance, (LPCTSTR)IDD_dlgOptions, hWnd, (DLGPROC)dlgOptions);
SetForegroundWindow(hDlg);
SHFullScreen(hDlg, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON);
UpdateWindow(hDlg);
break;
case IDC_btnExit :
EndDialog(hDlg, -1);
return FALSE;
}
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -