Refactor emulator status reporting (and fix the statusbar doesn't update bug)
[lsnes.git] / src / platform / wxwidgets / window-romload.cpp
blob42e39ee116cfbde8068412d88da1a12b270a8ada
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 std::map<int, std::string> cores;
18 std::map<int, std::string> types;
19 std::map<int, std::string> exts;
20 std::string spec = "All Files (*)|*.*";
21 int nent = 1;
23 //Collect all extensions.
24 for(auto i : core_type::get_core_types())
26 cores[nent] = i->get_core_identifier();
27 types[nent] = i->get_hname();
28 bool f = true;
29 for(auto j : i->get_extensions()) {
30 if(!f)
31 exts[nent] = exts[nent] + ";";
32 f = false;
33 exts[nent] = exts[nent] + "*." + j;
35 if(exts[nent] == "")
36 continue;
37 spec = spec + "|" + mangle_name(cores[nent]) + " / " + mangle_name(types[nent]) +
38 "(" + exts[nent] + ")|" + exts[nent];
39 nent++;
41 wxFileDialog* d = new wxFileDialog(parent, towxstring("Choose ROM to load"), towxstring(path),
42 towxstring(""), towxstring(spec), wxFD_OPEN);
43 int r = d->ShowModal();
44 if(r == wxID_CANCEL) {
45 delete d;
46 return false;
48 filename = tostdstring(d->GetPath());
49 int idx = d->GetFilterIndex();
50 if(idx > 0) {
51 core = cores[idx];
52 type = types[idx];
54 delete d;
55 return true;