Make newmenu subfunction const

This commit is contained in:
Kp 2020-12-19 16:13:26 +00:00
parent 1032462988
commit d4cf9943c5
2 changed files with 7 additions and 7 deletions

View file

@ -236,13 +236,15 @@ struct newmenu_layout
struct newmenu : newmenu_layout, window
{
newmenu(grs_canvas &src, newmenu_layout &&l) :
newmenu_layout(std::move(l)), window(src, x, y, w, h)
using subfunction_type = int(*)(newmenu *menu, const d_event &event, void *userdata);
newmenu(grs_canvas &src, newmenu_layout &&l, subfunction_type subfunction, void *userdata) :
newmenu_layout(std::move(l)), window(src, x, y, w, h),
subfunction(subfunction), userdata(userdata)
{
}
int (*subfunction)(newmenu *menu,const d_event &event, void *userdata);
const subfunction_type subfunction;
int *rval = nullptr; // Pointer to return value (for polling newmenus)
void *userdata; // For whatever - like with window system
void *const userdata; // For whatever - like with window system
virtual window_event_result event_handler(const d_event &) override;
};

View file

@ -1671,9 +1671,7 @@ newmenu *newmenu_do4(const menu_title title, const menu_subtitle subtitle, const
return nullptr;
newmenu_layout nl(title, subtitle, filename, TinyMode, TabsFlag, newmenu_layout::adjusted_citem::create(items, citem));
newmenu_create_structure(nl, *(TinyMode != tiny_mode_flag::normal ? GAME_FONT : MEDIUM1_FONT));
auto menu = std::make_unique<newmenu>(grd_curscreen->sc_canvas, std::move(nl));
menu->subfunction = subfunction;
menu->userdata = userdata;
auto menu = std::make_unique<newmenu>(grd_curscreen->sc_canvas, std::move(nl), subfunction, userdata);
newmenu_free_background();
menu->send_creation_events();