If initsram/initstate points to LSS file, pull the matching member
[lsnes.git] / src / platform / wxwidgets / window-romload.cpp
blob1ad308c92fb6c4616f1d78bea6ef95de80e979fb
1 #include "platform/wxwidgets/window-romload.hpp"
2 #include "platform/wxwidgets/platform.hpp"
3 #include "interface/romtype.hpp"
4 #include "core/misc.hpp"
5 #include <string>
6 #include <sstream>
7 #include <map>
10 wxwindow_romload::wxwindow_romload(const std::string& _path)
12 path = _path;
15 bool wxwindow_romload::show(wxWindow* parent)
17 CHECK_UI_THREAD;
18 std::map<int, std::string> cores;
19 std::map<int, std::string> types;
20 std::map<int, std::string> exts;
21 std::string spec = "All Files (*)|*.*";
22 int nent = 1;
24 //Collect all extensions.
25 for(auto i : core_type::get_core_types())
27 cores[nent] = i->get_core_identifier();
28 types[nent] = i->get_hname();
29 bool f = true;
30 for(auto j : i->get_extensions()) {
31 if(!f)
32 exts[nent] = exts[nent] + ";";
33 f = false;
34 exts[nent] = exts[nent] + "*." + j;
36 if(exts[nent] == "")
37 continue;
38 spec = spec + "|" + mangle_name(cores[nent]) + " / " + mangle_name(types[nent]) +
39 "(" + exts[nent] + ")|" + exts[nent];
40 nent++;
42 wxFileDialog* d = new wxFileDialog(parent, towxstring("Choose ROM to load"), towxstring(path),
43 towxstring(""), towxstring(spec), wxFD_OPEN);
44 int r = d->ShowModal();
45 if(r == wxID_CANCEL) {
46 delete d;
47 return false;
49 filename = tostdstring(d->GetPath());
50 int idx = d->GetFilterIndex();
51 if(idx > 0) {
52 core = cores[idx];
53 type = types[idx];
55 delete d;
56 return true;