From 10a26002b467642cca8de440303881c34fe19a6a Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 5 Aug 2014 00:20:56 -0400 Subject: [PATCH] Add an "Open Data Folder" button in simulation settings --- src/gui/options/OptionsView.cpp | 39 ++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/gui/options/OptionsView.cpp b/src/gui/options/OptionsView.cpp index 6459c3708..9ebaf2fd6 100644 --- a/src/gui/options/OptionsView.cpp +++ b/src/gui/options/OptionsView.cpp @@ -1,3 +1,11 @@ +#include +#ifdef WIN + #include + #define getcwd _getcwd +#else + #include +#endif + #include "OptionsView.h" #include "gui/Style.h" #include "gui/interface/Button.h" @@ -5,7 +13,7 @@ #include "gui/interface/DropDown.h" OptionsView::OptionsView(): - ui::Window(ui::Point(-1, -1), ui::Point(300, 310)){ + ui::Window(ui::Point(-1, -1), ui::Point(300, 330)){ ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Simulation Options"); tempLabel->SetTextColour(style::Colour::InformationTitle); @@ -191,6 +199,35 @@ OptionsView::OptionsView(): AddComponent(tempLabel); AddComponent(showAvatars); + class DataFolderAction: public ui::ButtonAction + { + public: + DataFolderAction() { } + void ActionCallback(ui::Button * sender) + { +//one of these should always be defined +#ifdef WIN + const char* openCommand = "start "; +#elif MACOSX + const char* openCommand = "open "; +//#elif LIN +#else + const char* openCommand = "xdg-open "; +#endif + char* workingDirectory = new char[FILENAME_MAX+strlen(openCommand)]; + sprintf(workingDirectory, "%s\"%s\"", openCommand, getcwd(NULL, 0)); + system(workingDirectory); + delete workingDirectory; + } + }; + ui::Button * dataFolderButton = new ui::Button(ui::Point(8, Size.Y-38), ui::Point(90, 16), "Open Data Folder"); + dataFolderButton->SetActionCallback(new DataFolderAction()); + AddComponent(dataFolderButton); + + tempLabel = new ui::Label(ui::Point(dataFolderButton->Position.X+dataFolderButton->Size.X+3, dataFolderButton->Position.Y), ui::Point(Size.X-28, 16), "\bg- Open the data and preferences folder"); + tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; + AddComponent(tempLabel); + class CloseAction: public ui::ButtonAction { public: