void editor_toolkit::init_mouse_actions(context_manager& cmanager) { mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_PAINT, std::make_shared<mouse_action_paint>(&brush_, key_, *palette_manager_->terrain_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_FILL, std::make_shared<mouse_action_fill>(key_, *palette_manager_->terrain_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_SELECT, std::make_shared<mouse_action_select>(&brush_, key_, *palette_manager_->empty_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_STARTING_POSITION, std::make_shared<mouse_action_starting_position>(key_, *palette_manager_->location_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_LABEL, std::make_shared<mouse_action_map_label>(key_, *palette_manager_->empty_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_UNIT, std::make_shared<mouse_action_unit>(key_, *palette_manager_->unit_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_VILLAGE, std::make_shared<mouse_action_village>(key_, *palette_manager_->empty_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_CLIPBOARD_PASTE, std::make_shared<mouse_action_paste>(cmanager.get_clipboard(), key_, *palette_manager_->empty_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_ITEM, std::make_shared<mouse_action_item>(key_, *palette_manager_->item_palette_.get()))); for (const theme::menu& menu : gui_.get_theme().menus()) { if (menu.items().size() == 1) { hotkey::HOTKEY_COMMAND hk = hotkey::get_id(menu.items().front()); mouse_action_map::iterator i = mouse_actions_.find(hk); if (i != mouse_actions_.end()) { i->second->set_toolbar_button(&menu); } } } mouse_action_ = (mouse_actions_.find(hotkey::HOTKEY_EDITOR_TOOL_PAINT))->second; set_mouseover_overlay(); }
void editor_toolkit::init_mouse_actions(const config& game_config, context_manager& cmanager) { mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_PAINT, new mouse_action_paint(&brush_, key_, *palette_manager_->terrain_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_FILL, new mouse_action_fill(key_, *palette_manager_->terrain_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_SELECT, new mouse_action_select(&brush_, key_, *palette_manager_->empty_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_STARTING_POSITION, new mouse_action_starting_position(key_, *palette_manager_->empty_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_LABEL, new mouse_action_map_label(key_, *palette_manager_->empty_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_UNIT, new mouse_action_unit(key_, *palette_manager_->unit_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_VILLAGE, new mouse_action_village(key_, *palette_manager_->empty_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_PASTE, new mouse_action_paste(cmanager.get_clipboard(), key_, *palette_manager_->empty_palette_.get()))); mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_ITEM, new mouse_action_item(key_, *palette_manager_->item_palette_.get()))); BOOST_FOREACH(const theme::menu& menu, gui_.get_theme().menus()) { if (menu.items().size() == 1) { hotkey::HOTKEY_COMMAND hk = hotkey::get_id(menu.items().front()); mouse_action_map::iterator i = mouse_actions_.find(hk); if (i != mouse_actions_.end()) { i->second->set_toolbar_button(&menu); } } } BOOST_FOREACH(const config &c, game_config.child_range("editor_tool_hint")) { mouse_action_map::iterator i = mouse_actions_.find(hotkey::get_id(c["id"])); if (i != mouse_actions_.end()) { mouse_action_hints_.insert(std::make_pair(i->first, c["text"])); } } mouse_action_ = (mouse_actions_.find(hotkey::HOTKEY_EDITOR_TOOL_PAINT))->second; set_mouseover_overlay(); }