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


C++ Body::GetLabel方法代码示例

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


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

示例1: OnClickObject

void SystemView::OnClickObject(const SystemBody *b)
{
	m_selectedObject = b;
	std::string desc;
	std::string data;

	desc += std::string(Lang::NAME_OBJECT);
	desc += ":\n";
	data += b->GetName()+"\n";

	desc += std::string(Lang::DAY_LENGTH);
	desc += std::string(Lang::ROTATIONAL_PERIOD);
	desc += ":\n";
	data += stringf(Lang::N_DAYS, formatarg("days", b->GetRotationPeriodInDays())) + "\n";

	desc += std::string(Lang::RADIUS);
	desc += ":\n";
	data += format_distance(b->GetRadius())+"\n";

	if (b->GetParent()) {
		desc += std::string(Lang::SEMI_MAJOR_AXIS);
	desc += ":\n";
		data += format_distance(b->GetOrbit().GetSemiMajorAxis())+"\n";

		desc += std::string(Lang::ORBITAL_PERIOD);
	desc += ":\n";
		data += stringf(Lang::N_DAYS, formatarg("days", b->GetOrbit().Period() / (24*60*60))) + "\n";
	}
	m_infoLabel->SetText(desc);
	m_infoText->SetText(data);

	// click on object (in same system) sets/unsets it as nav target
	SystemPath path = m_system->GetPathOf(b);
	if (m_game->GetSpace()->GetStarSystem()->GetPath() == m_system->GetPath()) {
		Body* body = m_game->GetSpace()->FindBodyForPath(&path);
		if (body != 0) {
			if(Pi::player->GetNavTarget() == body) {
				Pi::player->SetNavTarget(body);
				Pi::player->SetNavTarget(0);
				m_game->log->Add(Lang::UNSET_NAVTARGET);
			}
			else {
				Pi::player->SetNavTarget(body);
				m_game->log->Add(Lang::SET_NAVTARGET_TO + body->GetLabel());
			}
		}
	}
}
开发者ID:tomm,项目名称:pioneer,代码行数:48,代码来源:SystemView.cpp

示例2: l_body_get_label

static int l_body_get_label(lua_State *l)
{
	Body *b = LuaObject<Body>::CheckFromLua(1);
	LuaPush(l, b->GetLabel());
	return 1;
}
开发者ID:Zordey,项目名称:pioneer,代码行数:6,代码来源:LuaBody.cpp

示例3: Update

void ObjectViewerView::Update()
{
	if (Pi::KeyState(SDLK_EQUALS)) viewingDist *= 0.99f;
	if (Pi::KeyState(SDLK_MINUS)) viewingDist *= 1.01f;
	viewingDist = Clamp(viewingDist, 10.0f, 1e12f);

	char buf[128];
	Body *body = Pi::player->GetNavTarget();
	if(body && (body != lastTarget)) {
		// Reset view distance for new target.
		viewingDist = body->GetBoundingRadius() * 2.0f;
		lastTarget = body;

		if (body->IsType(Object::TERRAINBODY)) {
			TerrainBody *tbody = static_cast<TerrainBody*>(body);
			const SystemBody *sbody = tbody->GetSystemBody();
			m_sbodyVolatileGas->SetText(stringf("%0{f.3}", sbody->m_volatileGas.ToFloat()));
			m_sbodyVolatileLiquid->SetText(stringf("%0{f.3}", sbody->m_volatileLiquid.ToFloat()));
			m_sbodyVolatileIces->SetText(stringf("%0{f.3}", sbody->m_volatileIces.ToFloat()));
			m_sbodyLife->SetText(stringf("%0{f.3}", sbody->m_life.ToFloat()));
			m_sbodyVolcanicity->SetText(stringf("%0{f.3}", sbody->m_volcanicity.ToFloat()));
			m_sbodyMetallicity->SetText(stringf("%0{f.3}", sbody->m_metallicity.ToFloat()));
			m_sbodySeed->SetText(stringf("%0{i}", int(sbody->seed)));
			m_sbodyMass->SetText(stringf("%0{f}", sbody->mass.ToFloat()));
			m_sbodyRadius->SetText(stringf("%0{f}", sbody->radius.ToFloat()));
		}
	}
	snprintf(buf, sizeof(buf), "View dist: %s     Object: %s", format_distance(viewingDist).c_str(), (body ? body->GetLabel().c_str() : "<none>"));
	m_infoLabel->SetText(buf);

	if (body && body->IsType(Object::TERRAINBODY)) m_vbox->ShowAll();
	else m_vbox->HideAll();
}
开发者ID:gamebytes,项目名称:pioneer,代码行数:33,代码来源:ObjectViewerView.cpp

示例4: l_body_attr_label

/*
 * Attribute: label
 *
 * The label for the body. This is what is displayed in the HUD and usually
 * matches the name of the planet, space station, etc if appropriate.
 *
 * Availability:
 *
 *   alpha 10
 *
 * Status:
 *
 *   stable
 */
static int l_body_attr_label(lua_State *l)
{
	Body *b = LuaBody::GetFromLua(1);
	lua_pushstring(l, b->GetLabel().c_str());
	return 1;
}
开发者ID:jbuck,项目名称:pioneer,代码行数:20,代码来源:LuaBody.cpp

示例5: l_body_is_more_important_than

static int l_body_is_more_important_than(lua_State *l)
{
	Body *body = LuaObject<Body>::CheckFromLua(1);
	Body *other = LuaObject<Body>::CheckFromLua(2);

	// compare body and other
	// push true if body is "more important" than other
	// the most important body is shown on the hud and
	// bodies are sorted by importance in menus

	if(body == other)
	{
		LuaPush<bool>(l, false);
		return 1;
	}

	Object::Type a = body->GetType();
	const SystemBody *sb_a = body->GetSystemBody();
	bool a_gas_giant = sb_a && sb_a->GetSuperType() == SystemBody::SUPERTYPE_GAS_GIANT;
	bool a_planet = sb_a && sb_a->IsPlanet();
	bool a_moon = sb_a && sb_a->IsMoon();

	Object::Type b = other->GetType();
	const SystemBody *sb_b = other->GetSystemBody();
	bool b_gas_giant = sb_b && sb_b->GetSuperType() == SystemBody::SUPERTYPE_GAS_GIANT;
	bool b_planet = sb_b && sb_b->IsPlanet();
	bool b_moon = sb_b && sb_b->IsMoon();

	bool result = false;

	// if type is the same, just sort alphabetically
	// planets are different, because moons are
	// less important (but don't have their own type)
	if(a == b && a != Object::Type::PLANET) result = body->GetLabel() < other->GetLabel();
	// a star is larger than any other object
	else if(a == Object::Type::STAR) result = true;
	// any (non-star) object is smaller than a star
	else if(b == Object::Type::STAR) result = false;
	// a gas giant is larger than anything but a star,
	// but remember to keep total order in mind: if both are
	// gas giants, order alphabetically
	else if(a_gas_giant) result = !b_gas_giant || body->GetLabel() < other->GetLabel();
	// any (non-star, non-gas giant) object is smaller than a gas giant
	else if(b_gas_giant) result = false;
	// between two planets or moons, alphabetic
	else if(a_planet && b_planet) result = body->GetLabel() < other->GetLabel();
	else if(a_moon && b_moon) result = body->GetLabel() < other->GetLabel();
	// a planet is larger than any non-planet
	else if(a_planet) result = true;
	// a non-planet is smaller than any planet
	else if(b_planet) result = false;
	// a moon is larger than any non-moon
	else if(a_moon) result = true;
	// a non-moon is smaller than any moon
	else if(b_moon) result = false;
	// spacestation > city > ship > hyperspace cloud > cargo body > missile > projectile
	else if(a == Object::Type::SPACESTATION) result = true;
	else if(b == Object::Type::SPACESTATION) result = false;
    else if(a == Object::Type::CITYONPLANET) result = true;
    else if(b == Object::Type::CITYONPLANET) result = false;
	else if(a == Object::Type::SHIP) result = true;
	else if(b == Object::Type::SHIP) result = false;
	else if(a == Object::Type::HYPERSPACECLOUD) result = true;
	else if(b == Object::Type::HYPERSPACECLOUD) result = false;
	else if(a == Object::Type::CARGOBODY) result = true;
	else if(b == Object::Type::CARGOBODY) result = false;
	else if(a == Object::Type::MISSILE) result = true;
	else if(b == Object::Type::MISSILE) result = false;
	else if(a == Object::Type::PROJECTILE) result = true;
	else if(b == Object::Type::PROJECTILE) result = false;
	else Error("don't know how to compare %i and %i\n", a, b);

	LuaPush<bool>(l, result);
	return 1;
}
开发者ID:irigi,项目名称:pioneer,代码行数:75,代码来源:LuaBody.cpp


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