Reworked game board layout opening and its starting in MainFrame
This commit is contained in:
parent
7b436c15c4
commit
43c90fc63b
@ -20,7 +20,8 @@ MainFrame::MainFrame()
|
|||||||
panel = new GamePanel(this);
|
panel = new GamePanel(this);
|
||||||
panel->SetFocus();
|
panel->SetFocus();
|
||||||
|
|
||||||
openLayout();
|
if (openLayout())
|
||||||
|
panel->Start(layoutPath, solveable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::initMenu() {
|
void MainFrame::initMenu() {
|
||||||
@ -53,7 +54,8 @@ void MainFrame::bindMenu() {
|
|||||||
}, IDM_Exit);
|
}, IDM_Exit);
|
||||||
|
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
||||||
openLayout();
|
if (openLayout())
|
||||||
|
panel->Start(layoutPath, solveable);
|
||||||
}, IDM_Open);
|
}, IDM_Open);
|
||||||
|
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
||||||
@ -69,16 +71,14 @@ void MainFrame::bindMenu() {
|
|||||||
}, IDM_Rules);
|
}, IDM_Rules);
|
||||||
|
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
||||||
if (layoutPath.IsEmpty())
|
if (!layoutPath.IsEmpty() || openLayout()) {
|
||||||
openLayout();
|
|
||||||
else
|
|
||||||
panel->Start(layoutPath, solveable);
|
panel->Start(layoutPath, solveable);
|
||||||
|
Refresh();
|
||||||
Refresh();
|
}
|
||||||
}, IDM_New_Game);
|
}, IDM_New_Game);
|
||||||
|
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
Bind(wxEVT_MENU, [this](wxCommandEvent& evt) -> void {
|
||||||
solveable = _.IsChecked();
|
solveable = evt.IsChecked();
|
||||||
}, IDM_Solveable);
|
}, IDM_Solveable);
|
||||||
|
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
||||||
@ -90,13 +90,16 @@ void MainFrame::bindMenu() {
|
|||||||
}, IDM_Reshuffle);
|
}, IDM_Reshuffle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::openLayout() {
|
/**
|
||||||
wxFileDialog openFileDlg(this, "Открыть карту", dataDirPath + wxFileName::GetPathSeparator() + _("layouts"), "Turtle.smlf", "Файлы Mahjong карт (*.smlf)|*.smlf", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
* Shows a file opening dialog asking for .smlf file if succed, sets its path to layoutPath
|
||||||
|
* @return true if user have chosen a file, false if cancelled
|
||||||
|
*/
|
||||||
|
bool MainFrame::openLayout() {
|
||||||
|
wxFileDialog openFileDlg(this, _("Открыть карту"), dataDirPath + wxFileName::GetPathSeparator() + _("layouts"), _("Turtle.smlf"), _("Файлы Mahjong карт (*.smlf)|*.smlf"), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||||
|
|
||||||
if (openFileDlg.ShowModal() == wxID_CANCEL)
|
if (openFileDlg.ShowModal() == wxID_CANCEL)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
layoutPath = openFileDlg.GetPath();
|
layoutPath = openFileDlg.GetPath();
|
||||||
|
return true;
|
||||||
panel->Start(layoutPath, solveable);
|
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,14 @@ private:
|
|||||||
void initMenu();
|
void initMenu();
|
||||||
void bindMenu();
|
void bindMenu();
|
||||||
|
|
||||||
void openLayout();
|
|
||||||
|
|
||||||
GamePanel *panel;
|
GamePanel *panel;
|
||||||
|
|
||||||
|
bool openLayout();
|
||||||
|
|
||||||
const wxString dataDirPath;
|
const wxString dataDirPath;
|
||||||
wxString layoutPath;
|
wxString layoutPath;
|
||||||
|
|
||||||
bool solveable = false;
|
bool solveable = false; // determites wether to generate solveable or completely random map
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
Loading…
x
Reference in New Issue
Block a user