Yet more StellaX code cleanup.

The 'Browse for ROM directory' button now works, so you can change ROM
directories while within StellaX.

Added a 'Reload' button to the main dialog, so that when you change the
ROM dir, you can immediately reload the directory (instead of having to
quit and restart the app).

Added quotes around romnames; previously, names with spaces would cause
problems.

Removed old 'beta-testers' and 'thanks to' info from the Help dialog,
since it's over 4 years old and none of those people helped me :)

Still TODO is parse stella.pro info (so you can see romname, ms5sum, rarity,
manufacturer, and notes from the GUI), add a gamelist cache mode (so the
stella.pro and roms don't have to be accessed each time you start the
emulator, only when the romdir has changed), and add more options to the
config dialog.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@296 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2004-07-06 22:51:58 +00:00
parent d77a84297b
commit 40f77dc03e
12 changed files with 270 additions and 470 deletions

View File

@ -1,185 +1,117 @@
//////////////////////////////////////////////////////////////////////
//
// ShellBrowser.cpp: implementation of the CShellBrowser class.
//
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1998 Scott D. Killen
// Copyright (c) 2004 by Stephen Anthony
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: BrowseForFolder.cxx,v 1.3 2004-07-06 22:51:58 stephena Exp $
//============================================================================
#include "pch.hxx"
#include "BrowseForFolder.hxx"
//////////////////////////////////////////////////////////////////////
//
// Construction/Destruction
//
CBrowseForFolder::CBrowseForFolder(
const HWND hParent,
const LPITEMIDLIST pidl,
LPCTSTR strTitle)
{
m_hwnd = NULL;
myHwnd = NULL;
myBrowseInfo.pidlRoot = pidl;
myBrowseInfo.pidlRoot = pidl;
myBrowseInfo.hwndOwner = NULL;
myBrowseInfo.pszDisplayName = mySelected;
myBrowseInfo.lpszTitle = "Open ROM Folder ";
myBrowseInfo.pszDisplayName = mySelected;
myBrowseInfo.lpszTitle = strTitle;
myBrowseInfo.ulFlags = BIF_RETURNONLYFSDIRS|BIF_RETURNFSANCESTORS;
myBrowseInfo.lParam = reinterpret_cast<LPARAM>( this );
// myBrowseInfo.lpfn = BrowseCallbackProc;
myBrowseInfo.lParam = reinterpret_cast<LPARAM>( this );
myBrowseInfo.lpfn = BrowseCallbackProc;
}
CBrowseForFolder::~CBrowseForFolder()
{
}
//////////////////////////////////////////////////////////////////////
//
// Implementation
//
void CBrowseForFolder::SetOwner(const HWND hwndOwner)
LPCTSTR CBrowseForFolder::GetSelectedFolder() const
{
if (m_hwnd != NULL)
return;
myBrowseInfo.hwndOwner = hwndOwner;
}
void CBrowseForFolder::SetRoot(const LPITEMIDLIST pidl)
{
if (m_hwnd != NULL)
return;
myBrowseInfo.pidlRoot = pidl;
}
LPCTSTR CBrowseForFolder::GetTitle() const
{
return myBrowseInfo.lpszTitle;
}
bool CBrowseForFolder::SetTitle(
LPCTSTR strTitle
)
{
if (m_hwnd != NULL)
return false;
if ( strTitle == NULL )
{
return false;
}
if ( ! m_pchTitle.Set( strTitle ) )
{
return false;
}
myBrowseInfo.lpszTitle = m_pchTitle.Get();
return true;
}
void CBrowseForFolder::SetFlags(const UINT ulFlags)
{
if (m_hwnd != NULL)
return;
myBrowseInfo.ulFlags = ulFlags;
}
LPCTSTR CBrowseForFolder::GetSelectedFolder(
void
) const
{
return mySelected;
return mySelected;
}
bool CBrowseForFolder::SelectFolder()
{
bool bRet = false;
bool bRet = false;
LPITEMIDLIST pidl;
if ((pidl = ::SHBrowseForFolder(&myBrowseInfo)) != NULL)
{
myPath.Set( _T("") );
if (SUCCEEDED(::SHGetPathFromIDList(pidl, mySelected)))
{
bRet = true;
myPath.Set( mySelected );
}
LPITEMIDLIST pidl;
if ((pidl = SHBrowseForFolder(&myBrowseInfo)) != NULL)
{
myPath.Set( _T("") );
if (SUCCEEDED(SHGetPathFromIDList(pidl, mySelected)))
{
bRet = true;
myPath.Set( mySelected );
}
LPMALLOC pMalloc;
//Retrieve a pointer to the shell's IMalloc interface
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
// free the PIDL that SHBrowseForFolder returned to us.
pMalloc->Free(pidl);
// release the shell's IMalloc interface
(void)pMalloc->Release();
}
}
m_hwnd = NULL;
return bRet;
}
void CBrowseForFolder::OnInit() const
{
LPMALLOC pMalloc;
//Retrieve a pointer to the shell's IMalloc interface
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
// free the PIDL that SHBrowseForFolder returned to us.
pMalloc->Free(pidl);
// release the shell's IMalloc interface
(void)pMalloc->Release();
}
}
myHwnd = NULL;
return bRet;
}
void CBrowseForFolder::OnSelChanged(const LPITEMIDLIST pidl) const
{
(void)pidl;
(void)pidl;
}
void CBrowseForFolder::EnableOK(const bool bEnable) const
{
if (m_hwnd == NULL)
return;
if (myHwnd == NULL)
return;
// (void)SendMessage(m_hwnd, BFFM_ENABLEOK, static_cast(bEnable), NULL);
(void)SendMessage( m_hwnd, BFFM_ENABLEOK, NULL, static_cast<LPARAM>(bEnable) );
// (void)SendMessage(myHwnd, BFFM_ENABLEOK, static_cast(bEnable), NULL);
(void)SendMessage( myHwnd, BFFM_ENABLEOK, NULL, static_cast<LPARAM>(bEnable) );
}
void CBrowseForFolder::SetSelection(const LPITEMIDLIST pidl) const
{
if (m_hwnd == NULL)
return;
if (myHwnd == NULL)
return;
(void)SendMessage(m_hwnd, BFFM_SETSELECTION, FALSE, reinterpret_cast<LPARAM>(pidl));
(void)SendMessage(myHwnd, BFFM_SETSELECTION, FALSE, reinterpret_cast<LPARAM>(pidl));
}
void CBrowseForFolder::SetSelection(
LPCTSTR strPath
) const
void CBrowseForFolder::SetSelection(LPCTSTR strPath) const
{
if (m_hwnd == NULL)
return;
if (myHwnd == NULL)
return;
(void)SendMessage(m_hwnd, BFFM_SETSELECTION, TRUE, reinterpret_cast<LPARAM>(strPath));
}
void CBrowseForFolder::SetStatusText(
LPCTSTR strText
) const
{
if (m_hwnd == NULL)
return;
(void)SendMessage(m_hwnd, BFFM_SETSTATUSTEXT, NULL, reinterpret_cast<LPARAM>(strText));
(void)SendMessage(myHwnd, BFFM_SETSELECTION, TRUE, reinterpret_cast<LPARAM>(strPath));
}
int __stdcall CBrowseForFolder::BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
CBrowseForFolder* pbff = reinterpret_cast<CBrowseForFolder*>( lpData );
pbff->m_hwnd = hwnd;
if (uMsg == BFFM_INITIALIZED)
pbff->OnInit();
else if (uMsg == BFFM_SELCHANGED)
pbff->OnSelChanged( reinterpret_cast<LPITEMIDLIST>( lParam ));
return 0;
}
CBrowseForFolder* pbff = reinterpret_cast<CBrowseForFolder*>( lpData );
pbff->myHwnd = hwnd;
if (uMsg == BFFM_SELCHANGED)
pbff->OnSelChanged( reinterpret_cast<LPITEMIDLIST>( lParam ));
return 0;
}

View File

@ -1,162 +1,76 @@
//////////////////////////////////////////////////////////////////////
//
// ShellBrowser.h: interface for the CShellBrowser class.
//
// Copyright 1998 Scott D. Killen
//
//////////////////////////////////////////////////////////////////////
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1998 Scott D. Killen
// Copyright (c) 2004 by Stephen Anthony
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: BrowseForFolder.hxx,v 1.3 2004-07-06 22:51:58 stephena Exp $
//============================================================================
#ifndef __BROWSE_FOR_FOLDER_
#define __BROWSE_FOR_FOLDER_
#include <shlobj.h>
/////////////////////////////////////////////////////////////////////
//
// CShellBrowser
//
class CBrowseForFolder
{
public:
CBrowseForFolder(const HWND hParent = NULL,
const LPITEMIDLIST pidl = NULL,
LPCTSTR strTitle = NULL );
public:
CBrowseForFolder(const HWND hParent = NULL,
const LPITEMIDLIST pidl = NULL,
LPCTSTR strTitle = NULL );
virtual ~CBrowseForFolder();
virtual ~CBrowseForFolder();
//
// Set the handle of the owner window for the dialog box.
//
void SetOwner(const HWND hwndOwner);
public:
// Call GetSelectedFolder to retrieve the folder selected by the user.
LPCTSTR GetSelectedFolder() const;
//
// Set the root of the heirarchy that will be browsed. Get pidl from
// SHGetSpecialFolderLocation. This can be set to NULL to use the Virtual Folder
// that represents the Windows Desktop.
//
void SetRoot(const LPITEMIDLIST pidl);
// Call SelectFolder to display the dialog and get a selection from the user. Use
// GetSelectedFolder and GetImage to get the results of the dialog.
bool SelectFolder();
//
// Access a string that is displayed above the tree view control in the dialog box.
// This string can be used to specify instructions to the user. strTitle is a
// CString containing the text to be displayed. nTitle is the index of a string
// resource to be loaded. The return value is false if the resource could not be
// loaded.
//
LPCTSTR GetTitle() const;
bool SetTitle(LPCTSTR strTitle);
protected:
// OnSelChanged is called whenever the user selects a different directory. pidl is
// the LPITEMIDLIST of the new selection. Use SHGetPathFromIDList to retrieve the
// path of the selection.
virtual void OnSelChanged(const LPITEMIDLIST pidl) const;
//
// ulFlags = Value specifying the types of folders to be listed in the dialog box
// as well as other options. This member can include zero or more of the following
// values:
//
// BIF_BROWSEFORCOMPUTER Only returns computers. If the user selects
// anything other than a computer, the OK button
// is grayed.
//
// BIF_BROWSEFORPRINTER Only returns printers. If the user selects
// anything other than a printer, the OK button
// is grayed.
//
// BIF_DONTGOBELOWDOMAIN Does not include network folders below the
// domain level in the tree view control.
//
// BIF_RETURNFSANCESTORS Only returns file system ancestors. If the user
// selects anything other than a file system
// ancestor, the OK button is grayed.
//
// BIF_RETURNONLYFSDIRS Only returns file system directories. If the
// user selects folders that are not part of the
// file system, the OK button is grayed.
//
// BIF_STATUSTEXT Includes a status area in the dialog box. The
// callback function can set the status text by
// sending messages to the dialog box.
//
UINT GetFlags() const;
void SetFlags(const UINT ulFlags);
// Call EnableOK to enable the OK button on the active dialog. If bEnable is true
// then the button is enabled, otherwise it is disabled.
// NOTE -- This function should only be called within overrides of OnInit and
// OnSelChanged.
void EnableOK(const bool bEnable) const;
//
// Call GetSelectedFolder to retrieve the folder selected by the user.
//
LPCTSTR GetSelectedFolder() const;
// Call SetSelection to set the selection in the active dialog. pidl is the
// LPITEMIDLIST
// of the path to be selected. strPath is a CString containing the path to be
// selected.
// NOTE -- This function should only be called within overrides of OnInit and
// OnSelChanged.
void SetSelection(const LPITEMIDLIST pidl) const;
void SetSelection(LPCTSTR strPath) const;
//
// Function to retreive the image associated with the selected folder. The image is
// specified as an index to the system image list.
//
int GetImage() const;
private:
static int __stdcall BrowseCallbackProc(HWND hwnd,
UINT uMsg,
LPARAM lParam,
LPARAM lpData);
//
// Call SelectFolder to display the dialog and get a selection from the user. Use
// GetSelectedFolder and GetImage to get the results of the dialog.
//
bool SelectFolder();
protected:
//
// OnInit is called before the dialog is displayed on the screen.
//
virtual void OnInit() const;
//
// OnSelChanged is called whenever the user selects a different directory. pidl is
// the LPITEMIDLIST of the new selection. Use SHGetPathFromIDList to retrieve the
// path of the selection.
//
virtual void OnSelChanged(const LPITEMIDLIST pidl) const;
//
// Call EnableOK to enable the OK button on the active dialog. If bEnable is true
// then the button is enabled, otherwise it is disabled.
// NOTE -- This function should only be called within overrides of OnInit and
// OnSelChanged.
//
void EnableOK(const bool bEnable) const;
//
// Call SetSelection to set the selection in the active dialog. pidl is the
// LPITEMIDLIST
// of the path to be selected. strPath is a CString containing the path to be
// selected.
// NOTE -- This function should only be called within overrides of OnInit and
// OnSelChanged.
//
void SetSelection(const LPITEMIDLIST pidl) const;
void SetSelection(LPCTSTR strPath) const;
//
// Call SetStatusText to set the text in the Status area in the active dialog.
// strText is the text to be displayed.
// NOTE -- This function should only be called within overrides of OnInit and
// OnSelChanged.
//
void SetStatusText(LPCTSTR strText) const;
private:
static int __stdcall BrowseCallbackProc(HWND hwnd,
UINT uMsg,
LPARAM lParam,
LPARAM lpData);
CSimpleString m_pchTitle;
BROWSEINFO myBrowseInfo;
char mySelected[MAX_PATH];
CSimpleString myPath;
HWND m_hwnd;
BROWSEINFO myBrowseInfo;
char mySelected[MAX_PATH];
CSimpleString myPath;
HWND myHwnd;
};
inline UINT CBrowseForFolder::GetFlags() const
{
return myBrowseInfo.ulFlags;
}
inline int CBrowseForFolder::GetImage() const
{
return myBrowseInfo.iImage;
}
#endif

View File

@ -14,7 +14,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ConfigPage.cxx,v 1.2 2004-07-04 20:16:03 stephena Exp $
// $Id: ConfigPage.cxx,v 1.3 2004-07-06 22:51:58 stephena Exp $
//============================================================================
#include "pch.hxx"
@ -154,10 +154,9 @@ BOOL CConfigPage::OnCommand( WORD wNotifyCode, WORD wID, HWND hwndCtl )
if ( wID == IDC_BROWSE )
{
CBrowseForFolder bff( m_hwnd );
CBrowseForFolder bff( m_hwnd, NULL, "Open ROM Folder " );
if ( bff.SelectFolder() )
;
// ::SetDlgItemText( m_hwnd, IDC_ROMPATH, bff.GetSelectedFolder() );
SetDlgItemText( m_hwnd, IDC_ROMPATH, bff.GetSelectedFolder() );
}
return FALSE;

View File

@ -14,7 +14,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: MainDlg.cxx,v 1.2 2004-07-04 20:16:03 stephena Exp $
// $Id: MainDlg.cxx,v 1.3 2004-07-06 22:51:58 stephena Exp $
//============================================================================
#include "pch.hxx"
@ -29,8 +29,6 @@
#define BKGND_BITMAP_TOP 64
#define BKGND_BITMAP_BOTTOM 355
// NOTE: LVS_OWNERDATA doesn't support LVM_SORTITEMS!
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline LPARAM ListView_GetItemData( HWND hwndList, int iItem )
{
@ -54,12 +52,12 @@ CMainDlg::CMainDlg( CGlobalData& rGlobalData, HINSTANCE hInstance )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CMainDlg::ClearList( void )
{
int nCount = ListView_GetItemCount( m_hwndList );
int nCount = ListView_GetItemCount( myHwndList );
for (int i = 0; i < nCount; ++i)
delete (CListData*)ListView_GetItemData( m_hwndList, i );
delete (CListData*)ListView_GetItemData( myHwndList, i );
ListView_DeleteAllItems( m_hwndList );
ListView_DeleteAllItems( myHwndList );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -82,7 +80,7 @@ CMainDlg::StaticDialogFunc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
case WM_INITDIALOG:
pDlg = reinterpret_cast<CMainDlg*>( lParam );
pDlg->m_hwnd = hDlg;
pDlg->myHwnd = hDlg;
(void)::SetWindowLong( hDlg, DWL_USER, reinterpret_cast<LONG>( pDlg ) );
break;
@ -152,7 +150,7 @@ CMainDlg::DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam )
// When the fActive parameter is FALSE, an application should return
// TRUE to indicate that the system should proceed with the default
// processing
SetWindowLong( m_hwnd, DWL_MSGRESULT, TRUE );
SetWindowLong( myHwnd, DWL_MSGRESULT, TRUE );
return TRUE;
case WM_NCLBUTTONDOWN:
@ -161,7 +159,7 @@ CMainDlg::DialogFunc( UINT uMsg, WPARAM wParam, LPARAM lParam )
case WM_SYSCOMMAND:
// Allow Alt-F4 to close the window
if ( wParam == SC_CLOSE )
::EndDialog( m_hwnd, IDCANCEL );
::EndDialog( myHwnd, IDCANCEL );
break;
}
@ -198,26 +196,27 @@ BOOL CMainDlg::OnInitDialog( void )
// Do subclassing
m_CoolCaption.OnInitDialog( hwnd );
m_header.SubclassDlgItem( hwnd, IDC_ROMLIST );
m_btn3d.SubclassDlgItem( hwnd, IDC_TITLE );
m_btnPlay.SubclassDlgItem( hwnd, IDC_PLAY );
m_btnHelp.SubclassDlgItem( hwnd, IDC_ABOUT );
m_btnConfig.SubclassDlgItem( hwnd, IDC_CONFIG );
m_btnExit.SubclassDlgItem( hwnd, IDC_EXIT );
myHeader.SubclassDlgItem( hwnd, IDC_ROMLIST );
myAppTitle.SubclassDlgItem( hwnd, IDC_TITLE );
myPlayButton.SubclassDlgItem( hwnd, IDC_PLAY );
myReloadButton.SubclassDlgItem( hwnd, IDC_RELOAD );
myHelpButton.SubclassDlgItem( hwnd, IDC_ABOUT );
myConfigButton.SubclassDlgItem( hwnd, IDC_CONFIG );
myExitButton.SubclassDlgItem( hwnd, IDC_EXIT );
const int nMaxString = 256;
TCHAR psz[nMaxString + 1];
// Initialize the list view
m_hwndList = ::GetDlgItem( hwnd, IDC_ROMLIST );
ASSERT( m_hwndList );
myHwndList = ::GetDlgItem( hwnd, IDC_ROMLIST );
ASSERT( myHwndList );
// LVS_EX_ONECLICKACTIVATE was causing a/vs in kernel32
::SendMessage( m_hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE,
::SendMessage( myHwndList, LVM_SETEXTENDEDLISTVIEWSTYLE,
0, LVS_EX_FULLROWSELECT );
RECT rc;
::GetClientRect( m_hwndList, &rc );
::GetClientRect( myHwndList, &rc );
LONG lTotalWidth = rc.right-rc.left - GetSystemMetrics(SM_CXVSCROLL);
int cx = lTotalWidth / CListData::GetColumnCount();
@ -232,39 +231,11 @@ BOOL CMainDlg::OnInitDialog( void )
lvc.fmt = LVCFMT_LEFT;
lvc.cx = cx;
lvc.pszText = psz;
ListView_InsertColumn( m_hwndList, i, &lvc );
ListView_InsertColumn( myHwndList, i, &lvc );
}
DWORD dwError = PopulateRomList();
if ( dwError != ERROR_SUCCESS )
{
MessageBoxFromWinError( dwError, _T("PopulateRomList") );
return FALSE;
}
// if items added, select first item and enable play button
int nCount = ListView_GetItemCount( m_hwndList );
if (nCount != 0)
{
m_header.SetSortCol( 0, TRUE );
ListView_SortItems( m_hwndList, ListViewCompareFunc, (LPARAM)this );
ListView_SetItemState( m_hwndList, 0, LVIS_SELECTED | LVIS_FOCUSED,
LVIS_SELECTED | LVIS_FOCUSED );
}
else
{
::EnableWindow(::GetDlgItem( hwnd, IDC_PLAY), FALSE );
}
// Show status text
TCHAR pszStatus[256 + 1];
LoadString(m_hInstance, IDS_STATUSTEXT, pszStatus, 256);
wsprintf( psz, pszStatus, nCount );
SetDlgItemText( hwnd, IDC_ROMCOUNT, psz );
// Show rom path
SetDlgItemText( hwnd, IDC_ROMPATH,
myGlobalData.settings().getString("romdir").c_str() );
// Update the ROM game list
UpdateRomList();
// Set default button
::SendMessage( hwnd, DM_SETDEFID, IDC_PLAY, 0 );
@ -287,7 +258,7 @@ BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
switch (id)
{
case IDC_PLAY:
nItem = (int)::SendMessage( m_hwndList, LVM_GETNEXTITEM,
nItem = (int)::SendMessage( myHwndList, LVM_GETNEXTITEM,
(WPARAM)-1, MAKELPARAM( LVNI_SELECTED, 0 ) );
ASSERT( nItem != -1 );
if ( nItem == -1 )
@ -296,7 +267,7 @@ BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
return TRUE;
}
pListData = (CListData*)ListView_GetItemData( m_hwndList, nItem );
pListData = (CListData*)ListView_GetItemData( myHwndList, nItem );
TCHAR pszPathName[ MAX_PATH + 1 ];
lstrcpy( pszPathName, myGlobalData.settings().getString("romdir").c_str() );
@ -306,7 +277,7 @@ BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
(void)m_stella.PlayROM( pszPathName, myGlobalData );
// Set focus back to the rom list
::SetFocus( m_hwndList );
::SetFocus( myHwndList );
return TRUE;
break; // case IDC_PLAY
@ -341,6 +312,14 @@ BOOL CMainDlg::OnCommand( int id, HWND hwndCtl, UINT codeNotify )
return TRUE;
break; // case IDC_ABOUT
}
case IDC_RELOAD:
{
UpdateRomList();
return TRUE;
break; // case IDC_RELOAD
}
}
return FALSE;
@ -455,13 +434,57 @@ HBRUSH CMainDlg::OnCtlColorStatic( HDC hdcStatic, HWND hwndStatic )
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CMainDlg::UpdateRomList( void )
{
HWND hwndText;
RECT rc;
DWORD dwError = PopulateRomList();
if ( dwError != ERROR_SUCCESS )
MessageBoxFromWinError( dwError, _T("PopulateRomList") );
// if items added, select first item and enable play button
int nCount = ListView_GetItemCount( myHwndList );
if (nCount != 0)
{
myHeader.SetSortCol( 0, TRUE );
ListView_SortItems( myHwndList, ListViewCompareFunc, (LPARAM)this );
ListView_SetItemState( myHwndList, 0, LVIS_SELECTED | LVIS_FOCUSED,
LVIS_SELECTED | LVIS_FOCUSED );
}
else
{
::EnableWindow(::GetDlgItem( *this, IDC_PLAY), FALSE );
}
// Show status text
TCHAR psz[256 + 1];
TCHAR pszStatus[256 + 1];
LoadString(m_hInstance, IDS_STATUSTEXT, pszStatus, 256);
wsprintf( psz, pszStatus, nCount );
hwndText = GetDlgItem( *this, IDC_ROMCOUNT );
GetWindowRect(hwndText, &rc);
ScreenToClient( *this, (LPPOINT)&rc );
ScreenToClient( *this, ((LPPOINT)&rc)+1 );
SetWindowText( hwndText, psz );
InvalidateRect( *this, &rc, TRUE );
// Show rom path
hwndText = GetDlgItem( *this, IDC_ROMPATH );
GetWindowRect(hwndText, &rc);
ScreenToClient( *this, (LPPOINT)&rc );
ScreenToClient( *this, ((LPPOINT)&rc)+1 );
SetWindowText( hwndText, myGlobalData.settings().getString("romdir").c_str() );
InvalidateRect( *this, &rc, TRUE );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DWORD CMainDlg::PopulateRomList( void )
{
DWORD dwRet;
ClearList();
// REVIEW: Support .zip files?
TCHAR pszPath[ MAX_PATH ];
lstrcpy( pszPath, myGlobalData.settings().getString("romdir").c_str() );
@ -470,7 +493,7 @@ DWORD CMainDlg::PopulateRomList( void )
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile( pszPath, &ffd );
ListView_SetItemCount( m_hwndList, 100 );
ListView_SetItemCount( myHwndList, 100 );
int iItem = 0;
BOOL fDone = (hFind == INVALID_HANDLE_VALUE);
@ -494,15 +517,15 @@ DWORD CMainDlg::PopulateRomList( void )
lvi.iSubItem = 0;
lvi.pszText = LPSTR_TEXTCALLBACK;
lvi.lParam = (LPARAM)pListData;
int nItem = ListView_InsertItem( m_hwndList, &lvi );
int nItem = ListView_InsertItem( myHwndList, &lvi );
ASSERT( nItem != -1 );
ListView_SetItemText( m_hwndList, nItem,
ListView_SetItemText( myHwndList, nItem,
CListData::FILENAME_COLUMN, LPSTR_TEXTCALLBACK );
ListView_SetItemText(m_hwndList, nItem,
ListView_SetItemText(myHwndList, nItem,
CListData::MANUFACTURER_COLUMN, LPSTR_TEXTCALLBACK);
ListView_SetItemText( m_hwndList, nItem,
ListView_SetItemText( myHwndList, nItem,
CListData::RARITY_COLUMN, LPSTR_TEXTCALLBACK );
// go to the next rom file
@ -616,55 +639,51 @@ DWORD CMainDlg::ReadRomData(CListData* pListData) const
return ERROR_SUCCESS;
}
void CMainDlg::OnColumnClick(
LPNMLISTVIEW pnmv
)
void CMainDlg::OnColumnClick( LPNMLISTVIEW pnmv )
{
HCURSOR hcur = ::SetCursor(::LoadCursor(NULL, IDC_WAIT));
m_header.SetSortCol(pnmv->iSubItem, TRUE);
myHeader.SetSortCol(pnmv->iSubItem, TRUE);
ListView_SortItems(pnmv->hdr.hwndFrom, ListViewCompareFunc, (LPARAM)this);
// ensure the selected item is visible
int nItem = ListView_GetNextItem( m_hwndList, -1, LVNI_SELECTED );
int nItem = ListView_GetNextItem( myHwndList, -1, LVNI_SELECTED );
if (nItem != -1)
{
ListView_EnsureVisible( m_hwndList, nItem, TRUE );
ListView_EnsureVisible( myHwndList, nItem, TRUE );
}
::SetCursor(hcur);
}
void CMainDlg::OnItemChanged(
LPNMLISTVIEW pnmv
)
void CMainDlg::OnItemChanged( LPNMLISTVIEW pnmv )
{
HWND hwnd = *this;
HWND hwnd = *this;
HWND hwndNote = ::GetDlgItem( hwnd, IDC_ROMNOTE );
HWND hwndNote = ::GetDlgItem( hwnd, IDC_ROMNOTE );
RECT rc;
::GetWindowRect(hwndNote, &rc);
::ScreenToClient( hwnd, (LPPOINT)&rc );
::ScreenToClient( hwnd, ((LPPOINT)&rc)+1 );
RECT rc;
GetWindowRect(hwndNote, &rc);
ScreenToClient( hwnd, (LPPOINT)&rc );
ScreenToClient( hwnd, ((LPPOINT)&rc)+1 );
int iItem = ListView_GetNextItem(pnmv->hdr.hwndFrom, -1, LVNI_SELECTED);
if (iItem == -1)
{
::SetWindowText( hwndNote, _T("") );
::EnableWindow( ::GetDlgItem( hwnd, IDC_PLAY ), FALSE );
::InvalidateRect( hwnd, &rc, TRUE );
return;
}
int iItem = ListView_GetNextItem(pnmv->hdr.hwndFrom, -1, LVNI_SELECTED);
if (iItem == -1)
{
SetWindowText( hwndNote, _T("") );
EnableWindow( ::GetDlgItem( hwnd, IDC_PLAY ), FALSE );
InvalidateRect( hwnd, &rc, TRUE );
return;
}
CListData* pListData = (CListData*)ListView_GetItemData(
pnmv->hdr.hwndFrom,
pnmv->iItem );
CListData* pListData = (CListData*)ListView_GetItemData(
pnmv->hdr.hwndFrom,
pnmv->iItem );
::SetWindowText( hwndNote, pListData->GetNote() );
::InvalidateRect( hwnd, &rc, TRUE );
::EnableWindow( ::GetDlgItem( hwnd, IDC_PLAY ), TRUE );
SetWindowText( hwndNote, pListData->GetNote() );
InvalidateRect( hwnd, &rc, TRUE );
EnableWindow( ::GetDlgItem( hwnd, IDC_PLAY ), TRUE );
}
// ---------------------------------------------------------------------------
@ -700,7 +719,7 @@ int CALLBACK CMainDlg::ListViewCompareFunc(
// while other column metadata requires a call to ReadRomData
//
int nSortCol = pThis->m_header.GetSortCol();
int nSortCol = pThis->myHeader.GetSortCol();
CListData* pItem1 = reinterpret_cast<CListData*>( lParam1 );
if ( ! pItem1->IsPopulated() && nSortCol != 0 )

View File

@ -180,20 +180,21 @@ public:
operator HWND( void ) const
{
return m_hwnd;
return myHwnd;
}
private:
HWND m_hwnd;
HWND myHwnd;
CCoolCaption m_CoolCaption;
CTextButton3d m_btn3d;
CHeaderCtrl m_header;
CRoundButton m_btnPlay;
CRoundButton m_btnHelp;
CRoundButton m_btnConfig;
CRoundButton m_btnExit;
CCoolCaption m_CoolCaption;
CTextButton3d myAppTitle;
CHeaderCtrl myHeader;
CRoundButton myPlayButton;
CRoundButton myHelpButton;
CRoundButton myReloadButton;
CRoundButton myConfigButton;
CRoundButton myExitButton;
//
// Message handlers
@ -235,13 +236,14 @@ private:
// internal data
DWORD PopulateRomList();
void UpdateRomList();
DWORD ReadRomData( CListData* ) const;
HINSTANCE m_hInstance;
// stuff in list
HWND m_hwndList;
HWND myHwndList;
void ClearList();
HFONT m_hfontRomNote;

Binary file not shown.

View File

@ -76,7 +76,7 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "This version of StellaX is released under the GPL."
VALUE "CompanyName", "Stephen Anthony (stephena@users.sourceforge.net)"
VALUE "CompanyName", "Stephen Anthony (sa666_666@hotmail.com)"
VALUE "FileDescription", "StellaX"
VALUE "FileVersion", "1, 4, 0, 0"
VALUE "InternalName", "StellaX"
@ -113,15 +113,15 @@ BEGIN
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE |
WS_BORDER | WS_TABSTOP,7,57,395,143,WS_EX_STATICEDGE
CONTROL "&Play",IDC_PLAY,"Button",BS_OWNERDRAW | WS_TABSTOP,7,
226,200,16
226,149,16
CONTROL "&Options",IDC_CONFIG,"Button",BS_OWNERDRAW | WS_TABSTOP,
230,226,54,16
CONTROL "&Help",IDC_ABOUT,"Button",BS_OWNERDRAW | WS_TABSTOP,289,
226,54,16
CONTROL "E&xit",IDC_EXIT,"Button",BS_OWNERDRAW | WS_TABSTOP,348,
226,54,16
CTEXT "Written by Jeff Miller (miller@zipcon.net)\nStella core by Bradford W. Mott (bwmott@acm.org)",
IDC_STATIC,175,13,227,19,SS_NOPREFIX
CTEXT "Written by Jeff Miller (miller@zipcon.net)\nUpdated by Stephen Anthony (sa666_666@hotmail.com)\nStella core by Bradford W. Mott (bwmott@acm.org)",
IDC_STATIC,175,7,227,28,SS_NOPREFIX
RTEXT "<status>",IDC_ROMCOUNT,322,45,80,8,SS_NOPREFIX
CONTROL "",-1,"Static",SS_ETCHEDHORZ,0,39,411,1
CONTROL "",-1,"Static",SS_ETCHEDHORZ,0,218,411,1
@ -132,37 +132,30 @@ BEGIN
CONTROL "",IDC_ROMNOTE,"Static",SS_LEFTNOWORDWRAP | SS_NOPREFIX |
WS_GROUP,93,205,309,8
LTEXT "Game notes (if available):",-1,7,205,98,8
CONTROL "&Reload",IDC_RELOAD,"Button",BS_OWNERDRAW | WS_TABSTOP,
172,226,54,16
END
IDD_ABOUT_PAGE DIALOGEX 0, 0, 298, 136
IDD_ABOUT_PAGE DIALOGEX 0, 0, 299, 86
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Information"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "You must own legal copies of all ROM images you are using. The Stella team can't tell you where to find ROM images so DON'T ASK. All requests will either be deleted or sent to the appropriate authorities. StellaX is GPL software.",
-1,7,7,283,30,SS_NOPREFIX
-1,7,7,284,30,SS_NOPREFIX
LTEXT "If you have a question or a problem, please try one of these contacts:",
-1,7,44,283,8,SS_NOPREFIX
-1,7,44,284,8,SS_NOPREFIX
LTEXT "Steve Anthony:",-1,7,58,53,8,SS_NOPREFIX
LTEXT "sa666_666@hotmail.com",IDC_EMAIL_MAINTAINER,73,58,122,8,
SS_NOPREFIX | SS_NOTIFY
LTEXT "http://minbar.org",IDC_WEB_MAINTAINER,202,58,72,8,
SS_NOPREFIX | SS_NOTIFY
LTEXT "Stella dev team:",-1,7,70,52,8,SS_NOPREFIX
LTEXT "Stella dev team:",-1,7,70,60,8,SS_NOPREFIX
LTEXT "stella-main@lists.sourceforge.net",IDC_EMAIL_STELLA,73,
70,122,8,SS_NOPREFIX | SS_NOTIFY
LTEXT "http://stella.sf.net",IDC_WEB_STELLA,202,70,68,8,
SS_NOPREFIX | SS_NOTIFY
LTEXT "God, Suzi and Noah",-1,60,94,69,8,SS_NOPREFIX
LTEXT "Bradford Mott, Mike Balfour and Roger Onslow.",-1,60,
107,204,8,SS_NOPREFIX
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,86,283,1
LTEXT "Beta Tester:",-1,7,120,44,8,SS_NOPREFIX
LTEXT "John Hardy IV",IDC_WWW_MAME,60,120,46,8,SS_NOPREFIX |
SS_NOTIFY
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,37,283,1
LTEXT "Thanks To:",-1,7,107,38,8
LTEXT "Dedicated To:",-1,7,94,46,8
CONTROL "",-1,"Static",SS_ETCHEDHORZ,7,37,284,1
END
IDD_CONFIG_PAGE DIALOGEX 0, 0, 306, 199
@ -212,9 +205,9 @@ BEGIN
IDD_ABOUT_PAGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 290
RIGHTMARGIN, 291
TOPMARGIN, 7
BOTTOMMARGIN, 128
BOTTOMMARGIN, 78
END
IDD_CONFIG_PAGE, DIALOG
@ -253,60 +246,23 @@ STRINGTABLE
BEGIN
IDS_STATUSTEXT "%d files found"
IDS_STELLA "StellaX"
IDS_NODIRECTINPUT "DirectInput could not be initialized. Be sure you have DirectX 5.0 or later installed."
IDS_CANTSTARTCONSOLE "Error starting console. You may have chosen an invalid ROM file."
IDS_COINIT_FAILED "Unable to initialize COM subsystem"
IDS_ASS_FAILED "Unable to initialize audio subsystem"
IDS_PAS_FAILED "Unable to create audio stream"
IDS_DD_INIT_FAILED "Unable to initialize DirectDraw object"
IDS_DD_ENUMMODES_FAILED "Unable to enumerate display modes"
IDS_NO_VID_MODE "No compatible video modes were found"
IDS_DI_INIT_FAILED "Unable to initialize DirectInput object"
END
STRINGTABLE
BEGIN
IDS_ALREADYRUNNING "StellaX is already running!"
IDS_BADARGUMENT "Unknown argument given on command line"
END
STRINGTABLE
BEGIN
IDS_DDSDM_FAILED "Unable to set video mode. Your video adapter might be incompatible with stella."
IDS_DSCSBFAILED "IDirectSound::CreateSoundBuffer failed"
IDS_DSSCLFAILED "IDirectSound::SetCooperativeLevel failed"
IDS_FILEFILTER "Stella Files (*.bin)|*.bin|All Files (*.*)|*.*||"
IDS_FILENAME "Filename"
IDS_MANUFACTURER "Manufacturer"
IDS_MIKE """I've heard some folks discussing the possibility of writing an 2600 emulator in a high level language - forget it, not possible."" -- Mike Livesay on rec.games.video.classic"
IDS_NAME "Name"
IDS_NODIRECTDRAW "DirectDraw does not appear to be installed on this system!"
IDS_RARITY "Rarity"
END
STRINGTABLE
BEGIN
IDS_CW_FAILED "CreateWindow failed"
END
STRINGTABLE
BEGIN
IDS_DDSCL_FAILED "IDirectDraw::SetCooperativeLevel failed"
END
STRINGTABLE
BEGIN
IDS_DDCS_FAILED "IDirectDraw::CreateSurface failed"
END
STRINGTABLE
BEGIN
IDS_DDCP_FAILED "IDirectDraw::CreatePalette failed"
END
STRINGTABLE
BEGIN
IDS_ROM_LOAD_FAILED "Unable to load ROM image\n\nCurrent Directory: %s\nPath: %s\nError code: %d - %s"
IDS_NO_ITEM_SELECTED "Before pressing play you must first select a game from the list!"
END

View File

@ -244,5 +244,8 @@
</Filter>
</Files>
<Globals>
<Global
Name="RESOURCE_FILE"
Value="StellaX.rc"/>
</Globals>
</VisualStudioProject>

View File

@ -14,24 +14,20 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: StellaXMain.cxx,v 1.2 2004-07-04 20:16:03 stephena Exp $
// $Id: StellaXMain.cxx,v 1.3 2004-07-06 22:51:58 stephena Exp $
//============================================================================
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <windows.h>
#include <shellapi.h>
#include "resource.h"
#include "GlobalData.hxx"
#include "Settings.hxx"
#include "pch.hxx"
#include "StellaXMain.hxx"
// CStellaXMain
// equivalent to main() in the DOS version of stella
CStellaXMain::CStellaXMain()
{
@ -44,19 +40,20 @@ CStellaXMain::~CStellaXMain()
void CStellaXMain::PlayROM( LPCTSTR filename, CGlobalData& globaldata )
{
string rom = filename;
ostringstream buf;
// Make sure the specfied ROM exists
if(!globaldata.settings().fileExists(filename))
{
ostringstream out;
out << "\"" << rom << "\" doesn't exist";
buf << "\"" << rom << "\" doesn't exist";
MessageBox( NULL, out.str().c_str(), "Unknown ROM", MB_ICONEXCLAMATION|MB_OK);
MessageBox( NULL, buf.str().c_str(), "Unknown ROM", MB_ICONEXCLAMATION|MB_OK);
return;
}
// Assume that the ROM file does exist, attempt to run external Stella
// Since all settings are saved to the stella.ini file, we don't need
// to pass any arguments here ...
ShellExecute(NULL, "open", "stella.exe", rom.c_str(), NULL, 0);
buf << "\"" << rom << "\"";
ShellExecute(NULL, "open", "stella.exe", buf.str().c_str(), NULL, 0);
}

View File

@ -9,44 +9,21 @@
#define IDD_ABOUT_PAGE 106
#define IDD_CONFIG_PAGE 108
#define IDS_ALREADYRUNNING 200
#define IDS_BADARGUMENT 201
#define IDS_BADFRAMERATE 202
#define IDS_BADPADDLEMODE 203
#define IDS_CANTOPEN 204
#define IDS_CW_FAILED 208
#define IDS_DDCP_FAILED 224
#define IDS_DDCS_FAILED 240
#define IDS_DDSCL_FAILED 256
#define IDS_DDSDM_FAILED 272
#define IDS_DSCSBFAILED 273
#define IDS_DSSCLFAILED 274
#define IDS_FATALERROR 275
#define IDS_FILEFILTER 276
#define IDS_FILENAME 277
#define IDS_MANUFACTURER 278
#define IDS_MIKE 279
#define IDS_NAME 280
#define IDS_NODIRECTDRAW 281
#define IDS_NOGOODVIDEOMODE 282
#define IDS_OUTOFMEMORY 283
#define IDS_RARITY 284
#define IDS_RC_FAILED 288
#define IDS_STATUSTEXT 289
#define IDS_STELLA 290
#define IDS_UNKNOWNERROR 291
#define IDS_DEBUGBUILD 292
#define IDS_NODIRECTINPUT 293
#define IDS_FATALSOUNDERROR 294
#define IDS_CANTSTARTCONSOLE 295
#define IDS_COINIT_FAILED 296
#define IDS_ASS_FAILED 297
#define IDS_PAS_FAILED 298
#define IDS_DD_FAILED 299
#define IDS_DD_INIT_FAILED 300
#define IDS_DD_ENUMMODES_FAILED 301
#define IDS_NO_VID_MODE 302
#define IDS_DI_INIT_FAILED 303
#define IDS_ROM_LOAD_FAILED 304
#define IDS_NO_ITEM_SELECTED 305
#define IDC_ABOUT 1001
#define IDC_EMAIL_MAINTAINER 1002
@ -63,6 +40,7 @@
#define IDC_ROMPATH 1013
#define IDC_ROMNOTE 1014
#define IDC_CONFIG 1015
#define IDC_CONFIG2 1016
#define IDC_PADDLE 1017
#define IDC_SOUND 1018
#define IDC_VOLUME 1019
@ -70,8 +48,8 @@
#define IDC_ASPECT 1021
#define IDC_BROWSE 1022
#define IDC_EDIT2 1027
#define IDC_RELOAD 1028
#define IDC_INSTRUCTIONS 2000
#define IDC_ADOBE 2001
#define ID_FILE_EXIT 32771
// Next default values for new objects

Binary file not shown.

Binary file not shown.