From bc95e212a5c29ee60e98eb2f93130fc4f79ee442 Mon Sep 17 00:00:00 2001 From: SemperVinco Date: Sun, 5 Mar 2017 01:56:15 +0100 Subject: Use Native_File_Chooser, segfaults after choosing --- gui.cpp | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/gui.cpp b/gui.cpp index 353b6fb..54dfc8b 100644 --- a/gui.cpp +++ b/gui.cpp @@ -10,7 +10,8 @@ #include #include #include -#include +//#include +#include #include #include #include @@ -150,16 +151,39 @@ Simulation *simulation; static void openBotFileChooser(){ - Fl_File_Chooser *fc=new Fl_File_Chooser( - "programs","Robocom Bot Files (*.rob)",Fl_File_Chooser::MULTI,"Add bots to sim"); - fc->callback([](Fl_File_Chooser *fc,void*){ - if(fc->shown())return; - int count=fc->count(); - for(int i=1;i<=count;i++){ - simulation->add(fc->value(i)); + + Fl_Native_File_Chooser fc; + // fc.type(Fl_Native_File_Chooser::BROWSE_MULTI_FILE); + // fc.title("Add bots to sim"); + // fc.filter("Robocom Bot Files (*.rob)\t*.rob"); + + switch(fc.show()) { + case -1: + cout << "Error: " << fc.errmsg() << endl; + break; + case 1: + cout << "Cancelled" << endl; + break; + default: + int count = fc.count(); + for(int i=0; iadd(fc.filename(i)); } - }); - fc->show(); + break; + } + + // Fl_File_Chooser *fc=new Fl_File_Chooser( + // "programs","Robocom Bot Files (*.rob)",Fl_File_Chooser::MULTI,"Add bots to sim"); + // fc->callback([](Fl_File_Chooser *fc,void*){ + // if(fc->shown())return; + // int count=fc->count(); + // for(int i=1;i<=count;i++){ + // cout << fc->value(i) << endl; + // simulation->add(fc->value(i)); + // } + // }); + // fc->show(); } static BotList* makeBotlist(Fl_Group *parent){ -- cgit v1.2.3-70-g09d2