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 "HelpDlg.h"
|
||||||
#include "./RulesDlg.h"
|
#include "RulesDlg.h"
|
||||||
#include "./AboutDlg.h"
|
#include "AboutDlg.h"
|
||||||
|
|
||||||
MainFrame::MainFrame()
|
MainFrame::MainFrame()
|
||||||
: wxFrame(nullptr, wxID_ANY, _("Маджонг (пасьянс)"))
|
: wxFrame(nullptr, wxID_ANY, _("Маджонг (пасьянс)")),
|
||||||
|
dataDirPath(wxStandardPaths::Get().GetUserDataDir())
|
||||||
{
|
{
|
||||||
InitMenu();
|
InitMenu();
|
||||||
BindMenu();
|
BindMenu();
|
||||||
|
|
||||||
|
CreateStatusBar();
|
||||||
|
|
||||||
panel = new GamePanel(this);
|
panel = new GamePanel(this);
|
||||||
panel->SetFocus();
|
panel->SetFocus();
|
||||||
panel->Start();
|
panel->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MainFrame::~MainFrame() {
|
||||||
|
delete panel;
|
||||||
|
}
|
||||||
|
|
||||||
void MainFrame::InitMenu() {
|
void MainFrame::InitMenu() {
|
||||||
wxMenu *menuGame = new wxMenu;
|
wxMenu *menuGame = new wxMenu;
|
||||||
menuGame->Append(IDM_New_Game, _("Начать сначала"));
|
menuGame->Append(IDM_New_Game, _("Начать сначала"));
|
||||||
|
menuGame->Append(IDM_Open, _("Открыть карту"));
|
||||||
menuGame->AppendSeparator();
|
menuGame->AppendSeparator();
|
||||||
menuGame->Append(IDM_Exit, _("Выход"));
|
menuGame->Append(IDM_Exit, _("Выход"));
|
||||||
|
|
||||||
@ -38,6 +46,8 @@ void MainFrame::BindMenu() {
|
|||||||
Close();
|
Close();
|
||||||
}, IDM_Exit);
|
}, IDM_Exit);
|
||||||
|
|
||||||
|
Bind(wxEVT_MENU, &MainFrame::OnOpen, this, IDM_Open);
|
||||||
|
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
Bind(wxEVT_MENU, [this](wxCommandEvent& _) -> void {
|
||||||
(new HelpDlg(this, -1))->Show();
|
(new HelpDlg(this, -1))->Show();
|
||||||
}, IDM_Help);
|
}, IDM_Help);
|
||||||
@ -54,3 +64,12 @@ void MainFrame::BindMenu() {
|
|||||||
panel->Start();
|
panel->Start();
|
||||||
}, IDM_New_Game);
|
}, 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_
|
#ifndef MainFrame_H_
|
||||||
#define 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]}
|
/// @uml{style[#line.dotted:blue]}
|
||||||
class MainFrame : public wxFrame
|
class MainFrame : public wxFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MainFrame();
|
MainFrame();
|
||||||
|
~MainFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitMenu();
|
void InitMenu();
|
||||||
void BindMenu();
|
void BindMenu();
|
||||||
|
|
||||||
|
void OnOpen(wxCommandEvent& _);
|
||||||
|
|
||||||
GamePanel *panel;
|
GamePanel *panel;
|
||||||
|
|
||||||
|
const wxString dataDirPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
IDM_Open = wxID_OPEN,
|
||||||
IDM_Exit = wxID_EXIT,
|
IDM_Exit = wxID_EXIT,
|
||||||
IDM_Help = wxID_HELP,
|
IDM_Help = wxID_HELP,
|
||||||
IDM_About = wxID_ABOUT,
|
IDM_About = wxID_ABOUT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user