}
BEGIN_EVENT_TABLE(BombsFrame, wxFrame)
- EVT_MENU(bombsID_EASY, BombsFrame::OnNewEasyGame)
- EVT_MENU(bombsID_MEDIUM, BombsFrame::OnNewMediumGame)
- EVT_MENU(bombsID_HARD, BombsFrame::OnNewHardGame)
- EVT_MENU(wxID_EXIT, BombsFrame::OnExit)
- EVT_MENU(wxID_ABOUT, BombsFrame::OnAbout)
+ EVT_MENU(bombsID_EASY, BombsFrame::OnNewEasyGame)
+ EVT_MENU(bombsID_MEDIUM, BombsFrame::OnNewMediumGame)
+ EVT_MENU(bombsID_HARD, BombsFrame::OnNewHardGame)
+ EVT_MENU(bombsID_EASYCORNER, BombsFrame::OnEasyCorner)
+ EVT_MENU(wxID_EXIT, BombsFrame::OnExit)
+ EVT_MENU(wxID_ABOUT, BombsFrame::OnAbout)
END_EVENT_TABLE()
BombsFrame::BombsFrame(BombsGame *game)
wxSize(300, 300), wxDEFAULT_DIALOG_STYLE|wxMINIMIZE_BOX)
{
m_game = game;
+ m_easyCorner = false;
+ m_lastLevel = bombsID_EASY;
SetIcon(wxICON(bombs));
menuFile->Append(bombsID_NEWGAME, wxT("&New Game"),
menuLevel, wxT("Starts a new game"));
+ menuFile->AppendCheckItem(bombsID_EASYCORNER, wxT("&Easy corner"));
menuFile->AppendSeparator();
menuFile->Append(wxID_EXIT, wxGetStockLabel(wxID_EXIT), wxT("Quits the application"));
}
int numHorzCells = 20, numVertCells = 20;
+ m_lastLevel = level;
switch(level)
{
break;
}
- m_game->Init(numHorzCells, numVertCells);
+ m_game->Init(numHorzCells, numVertCells, m_easyCorner);
GetMenuBar()->Check(level, true);
NewGame(bombsID_HARD, true);
}
+void BombsFrame::OnEasyCorner(wxCommandEvent& WXUNUSED(event))
+{
+ wxString msg;
+ if(m_easyCorner)
+ msg = wxT("enable");
+ else
+ msg = wxT("disable");
+
+ msg = wxT("Do you really want to ") + msg + wxT(" having\ntop left corner always empty for easier start?");
+
+ int ok = wxMessageBox(
+ msg,
+ wxT("Confirm"),
+ wxYES_NO | wxICON_QUESTION,
+ this
+ );
+
+ if(ok!=wxYES)return;
+
+ m_easyCorner = !m_easyCorner;
+
+ NewGame(m_lastLevel, true);
+}
+
BEGIN_EVENT_TABLE(BombsCanvas, wxPanel)
EVT_PAINT(BombsCanvas::OnPaint)
EVT_MOUSE_EVENTS(BombsCanvas::OnMouseEvent)
void OnNewMediumGame(wxCommandEvent& event);
void OnNewHardGame(wxCommandEvent& event);
+ void OnEasyCorner(wxCommandEvent& event);
+
void OnExit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
BombsGame *m_game;
+ bool m_easyCorner;
+ int m_lastLevel;
// Subwindows for reference within the program.
BombsCanvas *m_canvas;
bombsID_NEWGAME = wxID_HIGHEST,
bombsID_EASY,
bombsID_MEDIUM,
- bombsID_HARD
+ bombsID_HARD,
+ bombsID_EASYCORNER
};
class BombsCanvas : public wxPanel
}
// Initialize the play field. Returns false on failure
-bool BombsGame::Init(int aWidth, int aHeight)
+bool BombsGame::Init(int aWidth, int aHeight, bool easyCorner)
{
m_gridFocusX = m_gridFocusY = -1;
}
}
+ /* Force (0,0) not to have a bomb for those that don't want to have
+ to guess on the first move. Better would be to for the MS rule that
+ whatever is picked first isn't a bomb.
+ */
+ if(easyCorner)
+ {
+ m_field[0] = BG_HIDDEN;
+ }
+
m_numBombCells = 0;
for(x=0; x<m_width; x++)
for(y=0; y<m_height; y++)