diff --git a/.vscode/launch.json b/.vscode/launch.json index cc944cd..bad8e42 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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" diff --git a/App.cpp b/App.cpp index 63c079e..79ac0ca 100644 --- a/App.cpp +++ b/App.cpp @@ -1,12 +1,18 @@ #include "App.h" #include "MainFrame.h" +#include + 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); diff --git a/MainFrame.cpp b/MainFrame.cpp index 03aec2e..66fb1b4 100644 --- a/MainFrame.cpp +++ b/MainFrame.cpp @@ -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() { diff --git a/MainFrame.h b/MainFrame.h index 4b7e055..3551236 100644 --- a/MainFrame.h +++ b/MainFrame.h @@ -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