本文整理汇总了C++中Name::length方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::length方法的具体用法?C++ Name::length怎么用?C++ Name::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Name
的用法示例。
在下文中一共展示了Name::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExamineUnit
void Actor::ExamineUnit(ui::Gui &table, const Point &start, const Point &range) const
{
Point nameplate = start.Moved(Point(1, 0));
Point hp = start.Moved(Point(1, 2));
Point mp = start.Moved(Point(1, 4));
Point effect_position = start.Moved(Point(1, 6));
// name
Name name = GetName();
if (name.length() > 0)
{
table.SetTextColor(Color(1, 1, 1));
table.Write(nameplate, name);
}
// bars
int bar_length = range.X - 2;
int current_health = GetCurrentHealth();
int max_health = GetMaximumHealth();
int current_energy = GetCurrentEnergy();
int max_energy = GetMaximumEnergy();
max_health = (max_health == 0) ? 1 : max_health;
max_energy = (max_energy == 0) ? 1 : max_energy;
int green = bar_length * current_health / max_health;
green = (green == 0 && current_health > 0) ? 1 : green;
green = (green < 0) ? 0 : green;
int blue = bar_length * current_energy / max_energy;
blue = (blue == 0 && current_energy > 0) ? 1 : blue;
blue = (blue < 0) ? 0 : blue;
table.Rectangle(hp, Point(green, 1), 0x085200);
table.Rectangle(hp.Moved(Point(green, 0)), Point(bar_length - green, 1), 0x642800);
table.Rectangle(mp, Point(blue, 1), 0x6b839c);
table.Rectangle(mp.Moved(Point(blue, 0)), Point(bar_length - blue, 1), 0xf0bf9f);
table.SetTextColor(0x1f0c00);
table.WriteInteger(hp.Moved(Point(bar_length - 1, 0)), current_health);
table.WriteInteger(mp.Moved(Point(bar_length - 1, 0)), current_energy);
table.Write(hp.Moved(Point(1, 0)), "HP");
table.Write(mp.Moved(Point(1, 0)), "EP");
// effects
table.SetTextColor(Color(1, 1, 1));
for (auto i = _effects.cbegin(); i != _effects.cend(); ++i)
{
table.Write(effect_position, i->GetName());
effect_position.Y += 2;
}
}
示例2: Filename
Ability::Ability(AbilityID id, const Name &name, const DescriptionText &desc, ScriptInterface &scriptIF)
:m_scriptIF(scriptIF)
{
//Verify input parameters
assert(id > 0);
assert(name.length() > 0);
assert(desc.length() > 0);
m_ID = id;
m_name.assign(name);
m_description.assign(desc);
char file[64], moduleName[64];
sprintf(file, "data/scripts/afx/0x%03x.as", id);
sprintf(moduleName, "afx:0x%03x", id);
m_scriptModuleID = scriptIF.createModuleFromFile(Name(moduleName), Filename(file));
m_scriptContextID = scriptIF.createContext();
}