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