Try reusing one pick-spell dialog
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include "mathutil.hpp"
|
#include "mathutil.hpp"
|
||||||
#include "fileio/fileio.hpp"
|
#include "fileio/fileio.hpp"
|
||||||
#include "fileio/resmgr/res_font.hpp"
|
#include "fileio/resmgr/res_font.hpp"
|
||||||
|
#include "fileio/resmgr/res_dialog.hpp"
|
||||||
#include "dialogxml/dialogs/strdlog.hpp"
|
#include "dialogxml/dialogs/strdlog.hpp"
|
||||||
#include "dialogxml/dialogs/choicedlog.hpp"
|
#include "dialogxml/dialogs/choicedlog.hpp"
|
||||||
#include "dialogxml/widgets/scrollbar.hpp"
|
#include "dialogxml/widgets/scrollbar.hpp"
|
||||||
@@ -351,11 +352,16 @@ static void init_buttons() {
|
|||||||
init_btn(help_btn, BTN_HELP, {273,12});
|
init_btn(help_btn, BTN_HELP, {273,12});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Spell dialog is slow to open on Windows, so keep it prepared and reuse it.
|
||||||
|
std::unique_ptr<cDialog> storeCastSpell;
|
||||||
|
|
||||||
// NOTE: this should possibly be moved to boe.ui.cpp at some point
|
// NOTE: this should possibly be moved to boe.ui.cpp at some point
|
||||||
static void init_ui() {
|
static void init_ui() {
|
||||||
cDialog::init();
|
cDialog::init();
|
||||||
init_scrollbars();
|
init_scrollbars();
|
||||||
init_buttons();
|
init_buttons();
|
||||||
|
|
||||||
|
storeCastSpell.reset(new cDialog(*ResMgr::dialogs.get("cast-spell")));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern bool record_verbose;
|
extern bool record_verbose;
|
||||||
@@ -1270,6 +1276,7 @@ void handle_events() {
|
|||||||
ResMgr::fonts.drain();
|
ResMgr::fonts.drain();
|
||||||
|
|
||||||
adjust_window_mode();
|
adjust_window_mode();
|
||||||
|
storeCastSpell.reset(new cDialog(*ResMgr::dialogs.get("cast-spell")));
|
||||||
init_mini_map();
|
init_mini_map();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2060,8 +2060,8 @@ eSpell pick_spell(short pc_num,eSkill type) { // 70 - no spell OW spell num
|
|||||||
|
|
||||||
set_cursor(sword_curs);
|
set_cursor(sword_curs);
|
||||||
|
|
||||||
cDialog castSpell(*ResMgr::dialogs.get("cast-spell"));
|
extern std::unique_ptr<cDialog> storeCastSpell;
|
||||||
|
cDialog& castSpell = *storeCastSpell;
|
||||||
castSpell.attachClickHandlers(std::bind(pick_spell_caster, _1, _2, type, std::ref(dark), std::ref(former_spell)), {"caster1","caster2","caster3","caster4","caster5","caster6"});
|
castSpell.attachClickHandlers(std::bind(pick_spell_caster, _1, _2, type, std::ref(dark), std::ref(former_spell)), {"caster1","caster2","caster3","caster4","caster5","caster6"});
|
||||||
castSpell.attachClickHandlers(std::bind(pick_spell_target,_1,_2, type, std::ref(dark), std::ref(former_spell)), {"target1","target2","target3","target4","target5","target6"});
|
castSpell.attachClickHandlers(std::bind(pick_spell_target,_1,_2, type, std::ref(dark), std::ref(former_spell)), {"target1","target2","target3","target4","target5","target6"});
|
||||||
castSpell.attachClickHandlers(std::bind(pick_spell_event_filter, _1, _2, type,std::ref(former_spell)), {"other", "help"});
|
castSpell.attachClickHandlers(std::bind(pick_spell_event_filter, _1, _2, type,std::ref(former_spell)), {"other", "help"});
|
||||||
|
|||||||
Reference in New Issue
Block a user