1 #include "platform/wxwidgets/menu_loadrom.hpp"
2 #include "platform/wxwidgets/platform.hpp"
3 #include "core/dispatch.hpp"
4 #include "core/instance.hpp"
6 loadrom_menu::loadrom_menu(wxWindow
* win
, int wxid_low
, int wxid_high
, std::function
<void(core_type
* name
)> cb
)
10 wxid_range_low
= wxid_low
;
11 wxid_range_high
= wxid_high
;
13 win
->Connect(wxid_low
, wxid_high
, wxEVT_COMMAND_MENU_SELECTED
,
14 wxCommandEventHandler(loadrom_menu::on_select
), NULL
, this);
15 corelistener
.set(notify_new_core
, [this]() { this->update(); });
19 void loadrom_menu::on_select(wxCommandEvent
& e
)
23 if(id
< wxid_range_low
|| id
> wxid_range_high
)
26 callback(entries
[id
]);
29 void loadrom_menu::update()
32 auto ents
= core_type::get_core_types();
33 int id
= wxid_range_low
;
37 std::map
<std::string
, core_type
*> ents2
;
39 ents2
[i
->get_hname() + " [" + i
->get_core_identifier() + "]..."] = i
;
42 if(id
>= wxid_range_high
)
44 if(i
.second
->is_hidden())
46 if(i
.second
->isnull())
48 entries
[id
] = i
.second
;
49 items
[id
] = Append(id
, towxstring(i
.first
));