本文整理汇总了C++中CUnit::GetTypeName方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnit::GetTypeName方法的具体用法?C++ CUnit::GetTypeName怎么用?C++ CUnit::GetTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnit
的用法示例。
在下文中一共展示了CUnit::GetTypeName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawUnitInfo_inventory
//Wyrmgus start
static void DrawUnitInfo_inventory(CUnit &unit)
{
CUnit *uins = unit.UnitInside;
size_t j = 0;
for (int i = 0; i < unit.InsideCount; ++i, uins = uins->NextContained) {
if (!uins->Type->BoolFlag[ITEM_INDEX].value || j >= UI.InventoryButtons.size()) {
continue;
}
CIcon &icon = *uins->Type->Icon.Icon;
int flag = (ButtonAreaUnderCursor == ButtonAreaInventory && static_cast<size_t>(ButtonUnderCursor) == j) ?
IconActive : 0;
if (flag && ((MouseButtons & LeftButton) || (MouseButtons & RightButton))) {
flag |= IconClicked;
}
flag |= IconCommandButton;
if (unit.IsItemEquipped(uins)) {
flag |= IconSelected;
}
const PixelPos pos(UI.InventoryButtons[j].X, UI.InventoryButtons[j].Y);
uins->GetIcon().Icon->DrawUnitIcon(*UI.InventoryButtons[j].Style, flag, pos, "", unit.Player->Index);
if (ButtonAreaUnderCursor == ButtonAreaInventory
&& static_cast<size_t>(ButtonUnderCursor) == j) {
//Wyrmgus start
// UI.StatusLine.Set(uins->Type->Name);
if (!Preference.NoStatusLineTooltips) {
UI.StatusLine.Set(uins->GetTypeName());
}
//hackish way to make the popup appear correctly for the inventory item
ButtonAction *ba = new ButtonAction;
if (!uins->Name.empty()) {
ba->Hint = uins->Name;
} else {
ba->Hint = uins->GetTypeName();
}
ba->Pos = j;
ba->Level = unit.Type->ButtonLevelForInventory;
ba->Action = ButtonUnit;
ba->Value = UnitNumber(*uins);
ba->Popup = "popup-item-inventory";
DrawPopup(*ba, UI.InventoryButtons[j], UI.InventoryButtons[j].X, UI.InventoryButtons[j].Y);
delete ba;
LastDrawnButtonPopup = NULL;
//Wyrmgus end
}
++j;
}
}
示例2: label
/**
** Draw text with variable.
**
** @param unit unit with variable to show.
** @param defaultfont default font if no specific font in extra data.
*/
/* virtual */ void CContentTypeText::Draw(const CUnit &unit, CFont *defaultfont) const
{
std::string text; // Optional text to display.
int x = this->Pos.x;
int y = this->Pos.y;
CFont &font = this->Font ? *this->Font : *defaultfont;
Assert(&font);
Assert(this->Index == -1 || ((unsigned int) this->Index < UnitTypeVar.GetNumberVariable()));
//Wyrmgus start
// CLabel label(font);
CLabel label(font, this->TextColor, this->HighlightColor);
//Wyrmgus end
if (this->Text) {
text = EvalString(this->Text);
std::string::size_type pos;
if ((pos = text.find("~|")) != std::string::npos) {
x += (label.Draw(x - font.getWidth(text.substr(0, pos)), y, text) - font.getWidth(text.substr(0, pos)));
} else if (this->Centered) {
x += (label.DrawCentered(x, y, text) * 2);
} else {
x += label.Draw(x, y, text);
}
}
if (this->ShowName) {
//Wyrmgus start
// label.DrawCentered(x, y, unit.Type->Name);
label.DrawCentered(x, y, unit.GetTypeName());
//Wyrmgus end
return;
}
if (this->Index != -1) {
if (!this->Stat) {
EnumVariable component = this->Component;
switch (component) {
case VariableValue:
case VariableMax:
case VariableIncrease:
case VariableDiff:
case VariablePercent:
label.Draw(x, y, GetComponent(unit, this->Index, component, 0).i);
break;
case VariableName:
label.Draw(x, y, GetComponent(unit, this->Index, component, 0).s);
break;
default:
Assert(0);
}
} else {
int value = unit.Type->MapDefaultStat.Variables[this->Index].Value;
int diff = unit.Stats->Variables[this->Index].Value - value;
if (!diff) {
label.Draw(x, y, value);
} else {
char buf[64];
snprintf(buf, sizeof(buf), diff > 0 ? "%d~<+%d~>" : "%d~<-%d~>", value, diff);
label.Draw(x, y, buf);
}
}
}
}