From f6f2216f855219e15d8406ef657e893883150a3a Mon Sep 17 00:00:00 2001 From: ac-stef Date: Wed, 29 Apr 2015 00:11:20 +0200 Subject: [PATCH] keep menu selection during menu rebuild Not clearing the menu selection in a followup "newmenu" command does not seem to have negative effects - and keeps the selection. Initaction ("menuinit") is now executed before the selction focus is set during menu->open. This avoids old hover commands to be executed before the menu gets deleted during rebuild. --- source/src/menus.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 4b025f79..335e512c 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -805,9 +805,9 @@ void *addmenu(const char *name, const char *title, bool allowinput, void (__cdec m->name = name; m->initaction = NULL; m->header = m->footer = NULL; + m->menusel = 0; } m->title = title; - m->menusel = 0; m->mdl = NULL; m->allowinput = allowinput; m->inited = false; @@ -1228,9 +1228,9 @@ void gmenu::open() inited = false; if(!allowinput) menusel = 0; if(!forwardkeys) player1->stopmoving(); - if(items.inrange(menusel)) items[menusel]->focus(true); setcontext("menu", name); if(initaction) execute(initaction); + if(items.inrange(menusel)) items[menusel]->focus(true); init(); resetcontext(); }