1 #include "plat-wxwidgets/platform.hpp"
2 #include "core/settings.hpp"
3 #include "library/string.hpp"
7 #include <wx/control.h>
8 #include <wx/combobox.h>
12 #include <boost/lexical_cast.hpp>
15 #define FIRMWAREPATH "firmwarepath"
16 #define ROMPATH "rompath"
17 #define MOVIEPATH "moviepath"
19 class wxeditor_paths
: public wxDialog
22 wxeditor_paths(wxWindow
* parent
);
24 bool ShouldPreventAppExit() const;
25 void on_cancel(wxCommandEvent
& e
);
26 void on_ok(wxCommandEvent
& e
);
31 wxTextCtrl
* moviepath
;
32 wxTextCtrl
* firmwarepath
;
35 wxeditor_paths::wxeditor_paths(wxWindow
* parent
)
36 : wxDialog(parent
, wxID_ANY
, wxT("lsnes: Paths"), wxDefaultPosition
, wxSize(-1, -1))
38 std::string cur_rompath
, cur_moviepath
, cur_firmwarepath
;
39 runemufn([&cur_firmwarepath
, &cur_moviepath
, &cur_rompath
]() {
40 cur_firmwarepath
= setting::get(FIRMWAREPATH
);
41 cur_rompath
= setting::get(ROMPATH
);
42 cur_moviepath
= setting::get(MOVIEPATH
);
46 wxFlexGridSizer
* top_s
= new wxFlexGridSizer(2, 1, 0, 0);
49 wxFlexGridSizer
* t_s
= new wxFlexGridSizer(3, 2, 0, 0);
50 t_s
->Add(new wxStaticText(this, wxID_ANY
, wxT("ROMs:")), 0, wxGROW
);
51 t_s
->Add(rompath
= new wxTextCtrl(this, wxID_ANY
, towxstring(cur_rompath
), wxDefaultPosition
, wxSize(400, -1)),
53 t_s
->Add(new wxStaticText(this, wxID_ANY
, wxT("Movies:")), 0, wxGROW
);
54 t_s
->Add(moviepath
= new wxTextCtrl(this, wxID_ANY
, towxstring(cur_moviepath
), wxDefaultPosition
,
55 wxSize(400, -1)), 1, wxGROW
);
56 t_s
->Add(new wxStaticText(this, wxID_ANY
, wxT("Firmware:")), 0, wxGROW
);
57 t_s
->Add(firmwarepath
= new wxTextCtrl(this, wxID_ANY
, towxstring(cur_firmwarepath
), wxDefaultPosition
,
58 wxSize(400, -1)), 1, wxGROW
);
61 wxBoxSizer
* pbutton_s
= new wxBoxSizer(wxHORIZONTAL
);
62 pbutton_s
->AddStretchSpacer();
63 pbutton_s
->Add(okbutton
= new wxButton(this, wxID_OK
, wxT("OK")), 0, wxGROW
);
64 pbutton_s
->Add(cancel
= new wxButton(this, wxID_CANCEL
, wxT("Cancel")), 0, wxGROW
);
65 okbutton
->Connect(wxEVT_COMMAND_BUTTON_CLICKED
, wxCommandEventHandler(wxeditor_paths::on_ok
), NULL
, this);
66 cancel
->Connect(wxEVT_COMMAND_BUTTON_CLICKED
,
67 wxCommandEventHandler(wxeditor_paths::on_cancel
), NULL
, this);
68 top_s
->Add(pbutton_s
, 0, wxGROW
);
70 t_s
->SetSizeHints(this);
71 top_s
->SetSizeHints(this);
75 wxeditor_paths::~wxeditor_paths()
79 bool wxeditor_paths::ShouldPreventAppExit() const
84 void wxeditor_paths::on_cancel(wxCommandEvent
& e
)
86 EndModal(wxID_CANCEL
);
89 void wxeditor_paths::on_ok(wxCommandEvent
& e
)
91 std::string cur_rompath
= tostdstring(rompath
->GetValue());
92 std::string cur_moviepath
= tostdstring(moviepath
->GetValue());
93 std::string cur_firmwarepath
= tostdstring(firmwarepath
->GetValue());
94 runemufn([cur_firmwarepath
, cur_moviepath
, cur_rompath
]() {
95 setting::set(ROMPATH
, cur_rompath
);
96 setting::set(MOVIEPATH
, cur_moviepath
);
97 setting::set(FIRMWAREPATH
, cur_firmwarepath
);
102 void wxeditor_paths_display(wxWindow
* parent
)
104 modal_pause_holder hld
;
107 editor
= new wxeditor_paths(parent
);