X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FbbtkwxGUIEditorGraphicBBS.cxx;h=af3e5ce7d1e592f1ebddd3f15cc0c8e569f48a21;hb=de7c0454ab8fc1b0b97dcd7112dfdb4a55ac0215;hp=36014fa6e33b89ed3344916f898106d3218289b8;hpb=e4d5a319ef249bde6c4f4ddfee66f6258558bf91;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 36014fa..af3e5ce 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -78,6 +78,11 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) : _actualPkgBrowserBoxName = ""; _actualPkgBrowserPkgName = ""; refreshGUIControls(); + + ///////////////////////////////// + /// IMPORTANT!! FOR SAVE&LOAD PROCESSES THE VERSION IS VERY IMPORTANT. + /// RaC 2012 2nd Hackfest + _currentBBGversion="1.4"; } //========================================================================= @@ -140,7 +145,8 @@ void wxGUIEditorGraphicBBS::initToolbar() { wxNullBitmap, wxITEM_NORMAL, _T("Complex box"), _T("Complex box")); toolbar->SetToggle(ID_BTNCOMPLEXBOX, true); - //toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add input to Complex box"), + // RaC 2012 2nd HackFest - Now Complex inputs are any external input + // toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add input to Complex box"), // bmp_complexinputport, wxNullBitmap, wxITEM_NORMAL, // _T("Add input to Complex box"), _T("Add input to Complex box")); toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add external input (Complex box or console app)"), @@ -232,6 +238,8 @@ void wxGUIEditorGraphicBBS::initMenu() { fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS")); fileMenu->Append(ID_SAVE_AS_COMPLEXBOX, _T("Save complex box"), _T("Save complex box")); + fileMenu->Append(ID_EXPORT_CONSOLEAPP, _T("Export console commands"), + _T("Export console execution commands")); fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit")); Connect(ID_NEW, wxEVT_COMMAND_MENU_SELECTED, @@ -248,6 +256,10 @@ void wxGUIEditorGraphicBBS::initMenu() { ID_SAVE_AS_COMPLEXBOX, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualComplexBox)); + Connect( + ID_EXPORT_CONSOLEAPP, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExportConsoleExecCommand)); Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit)); @@ -606,7 +618,9 @@ void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename) { std::string content = ""; // writing file header content += "# ----------------------------------\n"; - content += "# - BBTKGEditor v 1.3 BBS BlackBox Script\n"; + content += "# - BBTKGEditor v "; + content += _currentBBGversion; //VERSION + content += " BBS BlackBox Script\n"; content += "# - "; content += filename; content += "\n"; @@ -666,7 +680,9 @@ void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename) { // writing file header content += "# ----------------------------------\n"; - content += "# - BBTKGEditor v 1.3 BBS BlackBox Script (Complex Box)\n"; + content += "# - BBTKGEditor v "; + content += _currentBBGversion;//VERSION + content += " BBS BlackBox Script (Complex Box)\n"; content += "# - "; content += filename; content += "\n"; @@ -701,7 +717,9 @@ void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) { // writing file header content += "# ----------------------------------\n"; - content += "# - BBTKGEditor v 1.3 BBG BlackBox Diagram file\n"; + content += "# - BBTKGEditor v "; + content += _currentBBGversion; //VERSION + content += " BBG BlackBox Diagram file\n"; content += "# - "; content += filename; @@ -795,6 +813,100 @@ void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) { void wxGUIEditorGraphicBBS::OnSaveAsActualDiagram(wxCommandEvent& event) { SaveCurrentDiagramAs(); } + +//========================================================================= +void wxGUIEditorGraphicBBS::OnExportConsoleExecCommand(wxCommandEvent& event) +{ + wxFileDialog * saveFileDialog = new wxFileDialog(this, + wxT("Export console command"), wxEmptyString, wxT("ConsoleApp.txt"), + wxT("*.txt;*.bbs;*.bbg;*.sh;*.bat"), wxSAVE | wxOVERWRITE_PROMPT); + + if (saveFileDialog->ShowModal() == wxID_OK) + { + wxString fileName = saveFileDialog->GetPath(); + std::string filename = (const char*) (fileName.mb_str()); + filename=CheckExtension (filename, ".txt"); + + ofstream file; + file.open(filename.c_str()); + + std::vector extInputs = _tabsMgr->getActualTabPanel()->getSceneManager()->GetExternalInputsNames(); + + //TODO PUT IN A METHOD OF A FILES AND TEXT MANAGER CLASS !!! + //std::string inputsInCommentsWin=""; + //std::string inputsInCommentsUnix=""; + //std::string inputsInOneLineWin=""; + std::string inputsInOneLineUnix=""; + for (unsigned int i = 0; i < extInputs.size(); ++i) + { + /* No gusto la idea al jefe pero por si acaso ... + * RaC 2012 2nd HackFest + * + inputsInCommentsWin+="REM "; + inputsInCommentsWin+=extInputs[i]; + inputsInCommentsWin+="=\"value\"\n"; + inputsInCommentsUnix+="# "; + inputsInCommentsUnix+=extInputs[i]; + inputsInCommentsUnix+="=\"value\"\n"; + + char buffer [50]; + sprintf (buffer, "%d", (i+1)); + inputsInOneLineWin+=extInputs[i]; + inputsInOneLineWin+="=\"%"; + inputsInOneLineWin+=buffer; + inputsInOneLineWin+="\" "; + */ + inputsInOneLineUnix+=extInputs[i]; + inputsInOneLineUnix+="=\"\" "; + + } + + + std::string content = ""; + // writing file header + content += "# ----------------------------------\n"; + content += "# - BBTKGEditor v "; + content += _currentBBGversion; //VERSION + content += " Console Commands to execute BBS application\n"; + content += "# - "; + content += filename; + content += "\n"; + content += "# ----------------------------------\n"; + content += "\n"; + content += "\n"; + content += "# Command to execute bbi\n"; + content += "bbi "; + content += inputsInOneLineUnix; + + /* No gusto la idea al jefe pero por si acaso ... + * RaC 2012 2nd HackFest + content += "# For Windows (copy the following lines to a .bat file)\n"; + content += "REM BBS application\n"; + content += "REM Inputs:\n"; + content += inputsInCommentsWin; + content += "REM To use previous inputs, put %$inputName% in the corresponding input of the execution bbi line\n"; + content += "bbi applicationBBS.bbs "; + content += inputsInOneLineWin; + content += "\n"; + content += "\n"; + content += "# For Linux or Mac (copy the following lines to a .sh file)\n"; + content += "#!/bin/bash\n"; + content += "# BBS application\n"; + content += "# Inputs:\n"; + content += inputsInCommentsUnix; + content += "# To use previous inputs, put $inputName in the corresponding input of the execution bbi line\n"; + content += "bbi applicationBBS.bbs "; + content += inputsInOneLineUnix; + content += "\n"; + */ + + file << content; + file.close(); + } + + +} + //========================================================================= void wxGUIEditorGraphicBBS::refreshGUIControls() { @@ -804,18 +916,20 @@ void wxGUIEditorGraphicBBS::refreshGUIControls() { wxToolBar* toolbar = GetToolBar(); if (_tabsMgr->isActualDiagramComplexBox()) { toolbar->ToggleTool(ID_BTNCOMPLEXBOX, true); - toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true); + //toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true); RaC2012 2nd HackFest toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, true); GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX, true); GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, false); + GetMenuBar()->GetMenu(0)->Enable(ID_EXPORT_CONSOLEAPP, false); } else { toolbar->ToggleTool(ID_BTNCOMPLEXBOX, false); - toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, false); + //toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, false); RaC2012 2nd HackFest toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, false); GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX, false); GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, true); + GetMenuBar()->GetMenu(0)->Enable(ID_EXPORT_CONSOLEAPP, true); } //RaC2012 2ndHackFest