Added game finished message
This commit is contained in:
parent
19e1e546ee
commit
827f3ccdf6
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <wx/dcbuffer.h>
|
#include <wx/dcbuffer.h>
|
||||||
|
|
||||||
|
#include "events.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
@ -82,9 +83,20 @@ void GamePanel::OnResize(wxSizeEvent& _) {
|
|||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(END_EVT, wxCommandEvent);
|
||||||
|
|
||||||
void GamePanel::OnTimer(wxTimerEvent& _) {
|
void GamePanel::OnTimer(wxTimerEvent& _) {
|
||||||
controller.stopwatch += 1;
|
controller.stopwatch += 1;
|
||||||
sb->SetStatusText(LTimeToStr(controller.stopwatch), 0);
|
sb->SetStatusText(LTimeToStr(controller.stopwatch), 0);
|
||||||
|
|
||||||
|
if (controller.remaining == 0) {
|
||||||
|
wxCommandEvent event(END_EVT);
|
||||||
|
event.SetString(LTimeToStr(controller.stopwatch));
|
||||||
|
wxPostEvent(GetParent(), event);
|
||||||
|
|
||||||
|
timer.Stop();
|
||||||
|
controller.stopwatch = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamePanel::OnClick(wxMouseEvent& _) {
|
void GamePanel::OnClick(wxMouseEvent& _) {
|
||||||
@ -94,6 +106,8 @@ void GamePanel::OnClick(wxMouseEvent& _) {
|
|||||||
|
|
||||||
drawer.composeBoard(controller.getTable(), controller.gridSize);
|
drawer.composeBoard(controller.getTable(), controller.gridSize);
|
||||||
|
|
||||||
|
wxLogDebug(wxString::Format(_("Remaining %i"), controller.remaining));
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "HelpDlg.h"
|
#include "HelpDlg.h"
|
||||||
#include "RulesDlg.h"
|
#include "RulesDlg.h"
|
||||||
|
|
||||||
|
#include "events.h"
|
||||||
|
|
||||||
#include "resources/icon.xpm"
|
#include "resources/icon.xpm"
|
||||||
|
|
||||||
MainFrame::MainFrame()
|
MainFrame::MainFrame()
|
||||||
@ -23,6 +25,19 @@ MainFrame::MainFrame()
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Bind(END_EVT, [this](wxCommandEvent& evt) -> void {
|
||||||
|
wxMessageDialog dlg(this, _("Хотите сыграть снова?"),
|
||||||
|
_("Игра окончена"), wxYES_NO);
|
||||||
|
dlg.SetExtendedMessage(_("Поздравляем, вы закончили игру за ") +
|
||||||
|
evt.GetString());
|
||||||
|
if (dlg.ShowModal() == wxID_YES) {
|
||||||
|
panel->Start(layoutPath, solveable,
|
||||||
|
[this](const wxSize& size) -> void {
|
||||||
|
this->SetMinClientSize(size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
CreateStatusBar(2);
|
CreateStatusBar(2);
|
||||||
|
|
||||||
panel = new GamePanel(this);
|
panel = new GamePanel(this);
|
||||||
@ -71,17 +86,23 @@ void MainFrame::bindMenu() {
|
|||||||
|
|
||||||
Bind(
|
Bind(
|
||||||
wxEVT_MENU,
|
wxEVT_MENU,
|
||||||
[this](wxCommandEvent& _) -> void { (new HelpDlg(this, -1))->Show(); },
|
[this](wxCommandEvent& _) -> void {
|
||||||
|
(new HelpDlg(this, wxID_ANY))->Show();
|
||||||
|
},
|
||||||
IDM_Help);
|
IDM_Help);
|
||||||
|
|
||||||
Bind(
|
Bind(
|
||||||
wxEVT_MENU,
|
wxEVT_MENU,
|
||||||
[this](wxCommandEvent& _) -> void { (new AboutDlg(this, -1))->Show(); },
|
[this](wxCommandEvent& _) -> void {
|
||||||
|
(new AboutDlg(this, wxID_ANY))->Show();
|
||||||
|
},
|
||||||
IDM_About);
|
IDM_About);
|
||||||
|
|
||||||
Bind(
|
Bind(
|
||||||
wxEVT_MENU,
|
wxEVT_MENU,
|
||||||
[this](wxCommandEvent& _) -> void { (new RulesDlg(this, -1))->Show(); },
|
[this](wxCommandEvent& _) -> void {
|
||||||
|
(new RulesDlg(this, wxID_ANY))->Show();
|
||||||
|
},
|
||||||
IDM_Rules);
|
IDM_Rules);
|
||||||
|
|
||||||
Bind(
|
Bind(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user