Added map path setting via cli argument
This commit is contained in:
parent
ec43ed7c52
commit
a2cf3d1c30
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -9,7 +9,7 @@
|
||||
"request": "launch",
|
||||
"name": "Debug",
|
||||
"program": "${workspaceFolder}/build/wxMahjong",
|
||||
"args": [],
|
||||
"args": ["./resources/layouts/Flower.smlf"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"LD_LIBRARY_PATH": "$LD_LIBRARY_PATH:/usr/local/lib"
|
||||
|
6
App.cpp
6
App.cpp
@ -1,12 +1,18 @@
|
||||
#include "App.h"
|
||||
#include "MainFrame.h"
|
||||
|
||||
#include <wx/filefn.h>
|
||||
|
||||
wxIMPLEMENT_APP(MyApp);
|
||||
|
||||
bool MyApp::OnInit() {
|
||||
wxImage::AddHandler(new wxPNGHandler());
|
||||
|
||||
MainFrame* frame = new MainFrame();
|
||||
|
||||
if (argc >= 2 && wxFileExists(argv[1]))
|
||||
frame->layoutPath = argv[1];
|
||||
|
||||
frame->Show(true);
|
||||
SetTopWindow(frame);
|
||||
|
||||
|
@ -18,7 +18,7 @@ MainFrame::MainFrame()
|
||||
bindMenu();
|
||||
|
||||
Bind(wxEVT_SHOW, [this](wxShowEvent& _) -> void {
|
||||
if (openLayout())
|
||||
if (!layoutPath.IsEmpty() || openLayout())
|
||||
panel->Start(layoutPath, solveable,
|
||||
[this](const wxSize& size) -> void {
|
||||
this->SetMinClientSize(size);
|
||||
@ -41,7 +41,6 @@ MainFrame::MainFrame()
|
||||
CreateStatusBar(2);
|
||||
|
||||
panel = new GamePanel(this);
|
||||
panel->SetFocus();
|
||||
}
|
||||
|
||||
void MainFrame::initMenu() {
|
||||
|
@ -12,6 +12,8 @@ class MainFrame : public wxFrame {
|
||||
public:
|
||||
MainFrame();
|
||||
|
||||
wxString layoutPath;
|
||||
|
||||
private:
|
||||
void initMenu();
|
||||
void bindMenu();
|
||||
@ -21,7 +23,6 @@ private:
|
||||
bool openLayout();
|
||||
|
||||
const wxString dataDirPath;
|
||||
wxString layoutPath;
|
||||
|
||||
bool solveable = false; // determites wether to generate solveable or
|
||||
// completely random map
|
||||
|
Loading…
x
Reference in New Issue
Block a user