aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSemperVinco <w.deweijer@hotmail.com>2017-03-05 01:56:15 +0100
committerSemperVinco <w.deweijer@hotmail.com>2017-03-05 01:56:15 +0100
commitbc95e212a5c29ee60e98eb2f93130fc4f79ee442 (patch)
tree6f4e5aabcc215e853880c09bd09941f4cd23b44d
parent59e14944328f237089213410acc90de3b278eb23 (diff)
Use Native_File_Chooser, segfaults after choosing
-rw-r--r--gui.cpp44
1 files 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 <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
-#include <FL/Fl_File_Chooser.H>
+//#include <FL/Fl_File_Chooser.H>
+#include <FL/Fl_Native_File_Chooser.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Window.H>
@@ -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; i<count; i++) {
+ cout << fc.filename(i) << endl;
+ // simulation->add(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){