Skip to content

Commit

Permalink
Add an "Open Data Folder" button in simulation settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Aug 5, 2014
1 parent b889c62 commit 10a2600
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/gui/options/OptionsView.cpp
@@ -1,11 +1,19 @@
#include <stdio.h>
#ifdef WIN
#include <direct.h>
#define getcwd _getcwd
#else
#include <unistd.h>
#endif

#include "OptionsView.h"
#include "gui/Style.h"
#include "gui/interface/Button.h"
#include "gui/interface/Label.h"
#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);
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 10a2600

Please sign in to comment.