diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2017-09-19 21:14:46 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-19 21:14:46 -0300 |
commit | fa2776e9a939a793a9e46a0cc5880dda868e7028 (patch) | |
tree | 302f16d6d9af20a293d18d8a553ba2eac19a0fae /Project/main.cpp | |
parent | 3be51dc6e55414c76e7059a8dffa74a99268a7c8 (diff) | |
parent | 011fe58b631f66b715b0ba0d3f8be58277b355b2 (diff) | |
download | PSP.git-fa2776e9a939a793a9e46a0cc5880dda868e7028.tar.gz PSP.git-fa2776e9a939a793a9e46a0cc5880dda868e7028.tar.xz PSP.git-fa2776e9a939a793a9e46a0cc5880dda868e7028.zip |
Merge pull request #38 from Thales1330/wip/open-dot-psp
Wip open dot psp
Diffstat (limited to 'Project/main.cpp')
-rw-r--r-- | Project/main.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Project/main.cpp b/Project/main.cpp index a138a63..de8cac3 100644 --- a/Project/main.cpp +++ b/Project/main.cpp @@ -3,6 +3,7 @@ #include <wx/image.h> #include <wx/stdpaths.h> #include <wx/textfile.h> +#include <wx/cmdline.h> #include "MainFrame.h" #include "PropertiesData.h" @@ -15,12 +16,13 @@ class MainApp : public wxApp virtual ~MainApp() {} bool LoadInitFile(PropertiesData* propertiesData) { - wxTextFile file("config.ini"); + wxFileName fn(wxStandardPaths::Get().GetExecutablePath()); + wxTextFile file(fn.GetPath() + "\\config.ini"); auto data = propertiesData->GetGeneralPropertiesData(); if(!file.Create()) { if(!file.Open()) return false; - + wxString line; for(line = file.GetFirstLine(); !file.Eof(); line = file.GetNextLine()) { wxString tag = ""; @@ -53,7 +55,7 @@ class MainApp : public wxApp } } file.Close(); - } else { // Create default init file. + } else { // Create default init file. if(!file.Open()) return false; // Default parameters. @@ -95,7 +97,19 @@ class MainApp : public wxApp wxLocale* locale = new wxLocale(); LoadCatalogs(locale, propertiesData); - MainFrame* mainFrame = new MainFrame(NULL, locale, propertiesData); + wxString openFilePath = ""; + + wxCmdLineParser cmdLineParser(wxApp::argc, wxApp::argv); + cmdLineParser.AddParam("", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); + if(cmdLineParser.Parse() == 0) { + wxCmdLineArgs args = cmdLineParser.GetArguments(); + for(auto it = args.begin(), itEnd = args.end(); it != itEnd; ++it) { + if(it->GetKind() == wxCMD_LINE_PARAM) { + openFilePath = it->GetStrVal(); + } + } + } + MainFrame* mainFrame = new MainFrame(NULL, locale, propertiesData, openFilePath); mainFrame->SetIcon(wxICON(aaaaprogicon)); SetTopWindow(mainFrame); return GetTopWindow()->Show(); |