当前位置: 首页>>代码示例>>C++>>正文


C++ unit_type::get_cfg方法代码示例

本文整理汇总了C++中unit_type::get_cfg方法的典型用法代码示例。如果您正苦于以下问题:C++ unit_type::get_cfg方法的具体用法?C++ unit_type::get_cfg怎么用?C++ unit_type::get_cfg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unit_type的用法示例。


在下文中一共展示了unit_type::get_cfg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: show_unit_description

void show_unit_description(CVideo& video, const unit_type &t)
{
	std::string var_id = t.get_cfg()["variation_id"].str();
	if (var_id.empty())
		var_id = t.get_cfg()["variation_name"].str();
	bool hide_help = t.hide_help();
	bool use_variation = false;
	if (!var_id.empty()) {
		const unit_type *parent = unit_types.find(t.id());
		assert(parent);
		if (hide_help) {
			hide_help = parent->hide_help();
		} else {
			use_variation = true;
		}
	}

	if (use_variation)
		help::show_variation_help(video, t.id(), var_id, hide_help);
	else
		help::show_unit_help(video, t.id(), t.show_variations_in_help(), hide_help);
}
开发者ID:Wedge009,项目名称:wesnoth,代码行数:22,代码来源:help.cpp

示例2: add_advancement

void unit_type_data::add_advancement(unit_type& to_unit) const
{
    const config& cfg = to_unit.get_cfg();

    for (const config &af : cfg.child_range("advancefrom"))
    {
        const std::string &from = af["unit"];
        int xp = af["experience"];

        unit_type_data::unit_type_map::iterator from_unit = types_.find(from);

		if (from_unit == types_.end()) {
			std::ostringstream msg;
			msg << "unit type '" << from << "' not found when resolving [advancefrom] tag for '"
				<< to_unit.log_id() << "'";
			throw config::error(msg.str());
		}

        // Fix up advance_from references
        from_unit->second.add_advancement(to_unit, xp);

        DBG_UT << "Added advancement ([advancefrom]) from " << from << " to " << to_unit.log_id() << "\n";
    }
}
开发者ID:PoignardAzur,项目名称:wesnoth,代码行数:24,代码来源:types.cpp


注:本文中的unit_type::get_cfg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。