Added layout file open dialog
This commit is contained in:
parent
22b2fbd575
commit
ef90850b40
@ -1,23 +1,31 @@
|
||||
#include "./MainFrame.h"
|
||||
#include "MainFrame.h"
|
||||
|
||||
#include "./HelpDlg.h"
|
||||
#include "./RulesDlg.h"
|
||||
#include "./AboutDlg.h"
|
||||
#include "HelpDlg.h"
|
||||
#include "RulesDlg.h"
|
||||
#include "AboutDlg.h"
|
||||
|
||||
MainFrame::MainFrame()
|
||||
: wxFrame(nullptr, wxID_ANY, _("Маджонг (пасьянс)"))
|
||||
: wxFrame(nullptr, wxID_ANY, _("Маджонг (пасьянс)")),
|
||||
dataDirPath(wxStandardPaths::Get().GetUserDataDir())
|
||||
{
|
||||
InitMenu();
|
||||
BindMenu();
|
||||
|
||||
CreateStatusBar();
|
||||
|
||||
panel = new GamePanel(this);
|
||||
panel->SetFocus();
|
||||
panel->Start();
|
||||
}
|
||||
|
||||
MainFrame::~MainFrame() {
|
||||
delete panel;
|
||||
}
|
||||
|
||||
void MainFrame::InitMenu() {
|
||||
wxMenu *menuGame = new wxMenu;
|
||||
menuGame->Append(IDM_New_Game, _("Начать сначала"));
|
||||
menuGame->Append(IDM_Open, _("Открыть карту"));
|
||||
menuGame->AppendSeparator();
|
||||
menuGame->Append(IDM_Exit, _("Выход"));
|
||||
|
||||
@ -38,6 +46,8 @@ void MainFrame::BindMenu() {
|
||||
Close();
|
||||
}, IDM_Exit);
|
||||
|
||||
Bind(wxEVT_MENU, &MainFrame::OnOpen, this, IDM_Open);
|
||||
|
||||
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
||||
(new HelpDlg(this, -1))->Show();
|
||||
}, IDM_Help);
|
||||
@ -54,3 +64,12 @@ void MainFrame::BindMenu() {
|
||||
panel->Start();
|
||||
}, IDM_New_Game);
|
||||
}
|
||||
|
||||
void MainFrame::OnOpen(wxCommandEvent& _) {
|
||||
wxFileDialog openFileDlg(this, "Открыть карту", dataDirPath + wxFileName::GetPathSeparator() + _("layouts"), "Turtle.smlf", "Файлы Mahjong карт (*.smlf)|*.smlf", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
|
||||
if (openFileDlg.ShowModal() == wxID_CANCEL)
|
||||
return;
|
||||
|
||||
GetStatusBar()->PushStatusText(openFileDlg.GetPath());
|
||||
}
|
13
MainFrame.h
13
MainFrame.h
@ -1,25 +1,34 @@
|
||||
#ifndef MainFrame_H_
|
||||
#define MainFrame_H_
|
||||
|
||||
#include "./wxw.h"
|
||||
#include "wxw.h"
|
||||
|
||||
#include "./GamePanel.h"
|
||||
#include "GamePanel.h"
|
||||
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
/// @uml{style[#line.dotted:blue]}
|
||||
class MainFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
MainFrame();
|
||||
~MainFrame();
|
||||
|
||||
private:
|
||||
void InitMenu();
|
||||
void BindMenu();
|
||||
|
||||
void OnOpen(wxCommandEvent& _);
|
||||
|
||||
GamePanel *panel;
|
||||
|
||||
const wxString dataDirPath;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
IDM_Open = wxID_OPEN,
|
||||
IDM_Exit = wxID_EXIT,
|
||||
IDM_Help = wxID_HELP,
|
||||
IDM_About = wxID_ABOUT,
|
||||
|
Loading…
x
Reference in New Issue
Block a user