aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-03-05 10:25:16 +0100
committertomsmeding <tom.smeding@gmail.com>2017-03-05 10:28:51 +0100
commit9d85ffedb3e35b003f9b0fc1178974e7cf924ed4 (patch)
tree938ce4874d122c6527e99b9496dabbeb718e0135
parentbc95e212a5c29ee60e98eb2f93130fc4f79ee442 (diff)
Fix Native_File_Chooser
-rw-r--r--gui.cpp48
1 files changed, 19 insertions, 29 deletions
diff --git a/gui.cpp b/gui.cpp
index 54dfc8b..5dbf43f 100644
--- a/gui.cpp
+++ b/gui.cpp
@@ -8,6 +8,7 @@
#include <sys/time.h>
#include <FL/Fl.H>
+#include <FL/fl_ask.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
//#include <FL/Fl_File_Chooser.H>
@@ -151,39 +152,28 @@ Simulation *simulation;
static void openBotFileChooser(){
-
- 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");
+ Fl_Native_File_Chooser fc(Fl_Native_File_Chooser::BROWSE_MULTI_FILE);
+ fc.title("Add bots to sim");
+#ifdef __APPLE__
+ fc.filter("Robocom Bot Files\t*.rob");
+#else
+ fc.filter("Robocom Bot Files (*.rob)\t*.rob");
+#endif
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));
+ case -1:
+ cout << "Native File Chooser error: " << fc.errmsg() << endl;
+ break;
+ case 1:
+ break;
+ default: {
+ int count = fc.count();
+ for(int i=0; i<count; i++) {
+ simulation->add(fc.filename(i));
+ }
+ break;
}
- 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){