2 #include "platform/wxwidgets/menu_loadrom.hpp"
3 #include "platform/wxwidgets/platform.hpp"
4 #include "core/dispatch.hpp"
5 #include "core/instance.hpp"
7 loadrom_menu::loadrom_menu(wxWindow
* win
, int wxid_low
, int wxid_high
, std::function
<void(core_type
* name
)> cb
)
11 wxid_range_low
= wxid_low
;
12 wxid_range_high
= wxid_high
;
14 win
->Connect(wxid_low
, wxid_high
, wxEVT_COMMAND_MENU_SELECTED
,
15 wxCommandEventHandler(loadrom_menu::on_select
), NULL
, this);
16 corelistener
.set(notify_new_core
, [this]() { this->update(); });
20 void loadrom_menu::on_select(wxCommandEvent
& e
)
24 if(id
< wxid_range_low
|| id
> wxid_range_high
)
27 callback(entries
[id
]);
30 void loadrom_menu::update()
33 auto ents
= core_type::get_core_types();
34 int id
= wxid_range_low
;
38 std::map
<std::string
, core_type
*> ents2
;
40 ents2
[i
->get_hname() + " [" + i
->get_core_identifier() + "]..."] = i
;
43 if(id
>= wxid_range_high
)
45 if(i
.second
->is_hidden())
47 if(i
.second
->isnull())
49 entries
[id
] = i
.second
;
50 items
[id
] = Append(id
, towxstring(i
.first
));