Applied patch [ 861884 ] adjustement of bombs demo to wxBombsCE

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24975 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2003-12-23 10:45:28 +00:00
parent e176d9f7c0
commit 23290a8c8f
3 changed files with 20 additions and 6 deletions

View File

@ -53,7 +53,7 @@ bool BombsApp::OnInit()
m_frame = new BombsFrame(&m_game);
m_frame->NewGame(bombsID_EASY);
m_frame->NewGame(bombsID_EASY, false);
return true;
}
@ -121,8 +121,18 @@ void BombsFrame::OnExit(wxCommandEvent& WXUNUSED(event))
Close();
}
void BombsFrame::NewGame(int level)
void BombsFrame::NewGame(int level, bool query)
{
if(query)
{
int ok = wxMessageBox(
wxT("Start new game regardless previous board?"),
wxT("Confirm"),
wxYES_NO | wxICON_QUESTION,
this
);
if(ok!=wxYES)return;
}
int numHorzCells = 20, numVertCells = 20;
@ -162,17 +172,17 @@ void BombsFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
void BombsFrame::OnNewEasyGame(wxCommandEvent& WXUNUSED(event))
{
NewGame(bombsID_EASY);
NewGame(bombsID_EASY, true);
}
void BombsFrame::OnNewMediumGame(wxCommandEvent& WXUNUSED(event))
{
NewGame(bombsID_MEDIUM);
NewGame(bombsID_MEDIUM, true);
}
void BombsFrame::OnNewHardGame(wxCommandEvent& WXUNUSED(event))
{
NewGame(bombsID_HARD);
NewGame(bombsID_HARD, true);
}
BEGIN_EVENT_TABLE(BombsCanvas, wxPanel)

View File

@ -41,7 +41,7 @@ public:
BombsFrame(BombsGame *bombsGame);
void NewGame(int level);
void NewGame(int level, bool query);
private:

View File

@ -340,6 +340,10 @@ void BombsCanvas::OnChar(wxKeyEvent& event)
if ((prevGridFocusX != m_game->m_gridFocusX)
|| (prevGridFocusY != m_game->m_gridFocusY))
{
// cause focused field to be visible after first key hit after launching new game
if( m_game->m_gridFocusX < 0 ) m_game->m_gridFocusX = 0;
if( m_game->m_gridFocusY < 0 ) m_game->m_gridFocusY = 0;
// refresh previous field and focused field
RefreshField(prevGridFocusX, prevGridFocusY,
prevGridFocusX, prevGridFocusY);