Added map path setting via cli argument

This commit is contained in:
Dmitriy Shishkov 2022-06-06 13:02:17 +03:00
parent ec43ed7c52
commit a2cf3d1c30
No known key found for this signature in database
GPG Key ID: 26720CB2A9608C97
4 changed files with 10 additions and 4 deletions

2
.vscode/launch.json vendored
View File

@ -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"

View File

@ -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);

View File

@ -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() {

View File

@ -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