Beispiel #1
0
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();
}
Beispiel #2
0
void editor_toolkit::hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
{
	mouse_action_map::iterator i = mouse_actions_.find(command);
	if (i != mouse_actions_.end()) {
		palette_manager_->active_palette().hide(true);
		mouse_action_ = i->second;
		palette_manager_->adjust_size();

		set_mouseover_overlay();
		gui_.invalidate_game_status();
		palette_manager_->active_palette().hide(false);
	} else {
		ERR_ED << "Invalid hotkey command ("
			<< static_cast<int>(command) << ") passed to set_mouse_action\n";
	}

}
Beispiel #3
0
void editor_toolkit::hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
{
	std::map<hotkey::HOTKEY_COMMAND, mouse_action*>::iterator i = mouse_actions_.find(command);
	if (i != mouse_actions_.end()) {
		mouse_action_ = i->second;
		palette_manager_->adjust_size();

		//TODO make active_palette() private again.
		//palette_manager_->switch_palette();
		gui_.set_palette_report(palette_manager_->active_palette().active_group_report());

		set_mouseover_overlay();
		redraw_toolbar();
		gui_.invalidate_game_status();
	} else {
		ERR_ED << "Invalid hotkey command ("
			<< static_cast<int>(command) << ") passed to set_mouse_action\n";
	}

}
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();
}