本文整理汇总了C++中CShipClass::HasLiteralAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ CShipClass::HasLiteralAttribute方法的具体用法?C++ CShipClass::HasLiteralAttribute怎么用?C++ CShipClass::HasLiteralAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CShipClass
的用法示例。
在下文中一共展示了CShipClass::HasLiteralAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateShipTable
void GenerateShipTable (CUniverse &Universe, CXMLElement *pCmdLine, CIDTable &EntityTable)
{
int i, j;
// Some options
bool bAllClasses = (pCmdLine->GetAttributeBool(CONSTLIT("allClasses")) || pCmdLine->GetAttributeBool(CONSTLIT("all")));
// Get the criteria from the command line. Always append 's' because we
// want ship classes.
CString sCriteria = strPatternSubst(CONSTLIT("%s s"), pCmdLine->GetAttribute(CONSTLIT("criteria")));
CDesignTypeCriteria Criteria;
if (CDesignTypeCriteria::ParseCriteria(sCriteria, &Criteria) != NOERROR)
{
printf("ERROR: Unable to parse criteria.\n");
return;
}
// Generate a list of columns to display
TArray<CString> Cols;
Cols.Insert(FIELD_LEVEL);
Cols.Insert(FIELD_NAME);
for (i = 0; i < pCmdLine->GetAttributeCount(); i++)
{
CString sAttrib = pCmdLine->GetAttributeName(i);
if (strEquals(sAttrib, FIELD_BALANCE))
{
Cols.Insert(CONSTLIT("balanceType"));
Cols.Insert(CONSTLIT("combatStrength"));
Cols.Insert(CONSTLIT("damage"));
Cols.Insert(CONSTLIT("defenseStrength"));
}
else if (!IsMainCommandParam(sAttrib)
&& !strEquals(sAttrib, CONSTLIT("shiptable")))
{
CString sValue = pCmdLine->GetAttribute(i);
if (!strEquals(sValue, CONSTLIT("true")))
Cols.Insert(strPatternSubst(CONSTLIT("%s:%s"), sAttrib, sValue));
else
Cols.Insert(sAttrib);
}
}
// Output the header
for (j = 0; j < Cols.GetCount(); j++)
{
if (j != 0)
printf("\t");
printf(Cols[j].GetASCIIZPointer());
}
printf("\n");
// Generate a table
CSymbolTable Table(FALSE, TRUE);
// Loop over all items that match and add them to
// a sorted table.
for (i = 0; i < Universe.GetShipClassCount(); i++)
{
CShipClass *pClass = Universe.GetShipClass(i);
// Only include generic classes unless otherwise specified
if (!bAllClasses && !pClass->HasLiteralAttribute(CONSTLIT("genericClass")))
continue;
if (!pClass->MatchesCriteria(Criteria))
continue;
// Figure out the sort order
char szBuffer[1024];
wsprintf(szBuffer, "%04d%s%d",
pClass->GetLevel(),
pClass->GetNounPhrase(0).GetASCIIZPointer(),
pClass->GetUNID());
Table.AddEntry(CString(szBuffer), (CObject *)pClass);
}
// Output table
for (i = 0; i < Table.GetCount(); i++)
{
CShipClass *pClass = (CShipClass *)Table.GetValue(i);
// Output each row
for (j = 0; j < Cols.GetCount(); j++)
{
if (j != 0)
//.........这里部分代码省略.........
示例2: OutputByShipClass
void OutputByShipClass (SItemTableCtx &Ctx, const SItemTypeList &ItemList, bool bShowUsage)
{
int i, j;
// Make a map of ship classes for each item
TSortMap<DWORD, TArray<CShipClass *>> ItemToShipClass;
for (i = 0; i < g_pUniverse->GetShipClassCount(); i++)
{
CShipClass *pClass = g_pUniverse->GetShipClass(i);
// Skip non-generic ones
if (!pClass->HasLiteralAttribute(CONSTLIT("genericClass")))
continue;
// Add the list of types used by the ship
TSortMap<DWORD, bool> TypesUsed;
pClass->AddTypesUsed(&TypesUsed);
// For each item type, add it to the map
for (j = 0; j < TypesUsed.GetCount(); j++)
{
CDesignType *pType = g_pUniverse->FindDesignType(TypesUsed.GetKey(j));
if (pType && pType->GetType() == designItemType)
{
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
pList->Insert(pClass);
}
}
}
// If we want to show usage, then we print each item along with the
// ship classes using each item.
if (bShowUsage)
{
for (i = 0; i < ItemList.GetCount(); i++)
{
CItemType *pType = ItemList[i];
printf("%s\n", (LPSTR)pType->GetNounPhrase());
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
for (j = 0; j < pList->GetCount(); j++)
printf("\t%s\n", (LPSTR)pList->GetAt(j)->GetName());
if (pList->GetCount() == 0)
printf("\t(none)\n");
printf("\n");
}
}
// Otherwise we categorize by ship class
else
{
// Now make a list of all ship classes that have our items
SByShipClassTypeList ByShipClassTable;
for (i = 0; i < ItemList.GetCount(); i++)
{
const CString &sKey = ItemList.GetKey(i);
CItemType *pType = ItemList[i];
// Loop over all ship classes
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
for (j = 0; j < pList->GetCount(); j++)
{
CString sClassName = pList->GetAt(j)->GetName();
bool bNew;
SShipClassEntry *pEntry = ByShipClassTable.SetAt(sClassName, &bNew);
if (bNew)
pEntry->sShipClassName = sClassName;
pEntry->ItemTable.Insert(sKey, pType);
}
// If no ship class
if (pList->GetCount() == 0)
{
bool bNew;
SShipClassEntry *pEntry = ByShipClassTable.SetAt(CONSTLIT("(none)"), &bNew);
if (bNew)
pEntry->sShipClassName = CONSTLIT("(none)");
pEntry->ItemTable.Insert(sKey, pType);
}
}
// Now loop over all attributes
for (i = 0; i < ByShipClassTable.GetCount(); i++)
{
const SShipClassEntry &Entry = ByShipClassTable[i];
//.........这里部分代码省略.........
示例3: GenerateImageChart
//.........这里部分代码省略.........
switch (pType->GetType())
{
case designItemType:
{
CItemType *pItemType = CItemType::AsType(pType);
CItem Item(pItemType, 1);
// Skip if not in item criteria
if (!Item.MatchesCriteria(ItemCriteria))
continue;
// Skip virtual classes
if (pItemType->IsVirtual())
continue;
// Initialize the entry
NewEntry.pType = pType;
NewEntry.sName = pItemType->GetNounPhrase(0);
NewEntry.pImage = &pItemType->GetImage();
NewEntry.iSize = RectWidth(NewEntry.pImage->GetImageRect());
break;
}
case designShipClass:
{
CShipClass *pClass = CShipClass::AsType(pType);
// Skip non-generic classess
if (!bAll && !pClass->HasLiteralAttribute(CONSTLIT("genericClass")))
continue;
// Initialize the entry
NewEntry.pType = pType;
NewEntry.sName = pClass->GetNounPhrase(0);
NewEntry.iSize = RectWidth(pClass->GetImage().GetImageRect());
NewEntry.pImage = &pClass->GetImage();
NewEntry.iRotation = pClass->Angle2Direction(iRotation);
NewEntry.sSovereignName = (pClass->GetDefaultSovereign() ? pClass->GetDefaultSovereign()->GetTypeNounPhrase() : NULL_STR);
break;
}
case designStationType:
{
CStationType *pStationType = CStationType::AsType(pType);
// Skip generic classes
if (!bAll && !pStationType->HasLiteralAttribute(CONSTLIT("generic")))
continue;
NewEntry.pType = pType;
NewEntry.sName = pStationType->GetNounPhrase(0);
NewEntry.iSize = pStationType->GetSize();
NewEntry.sSovereignName = (pStationType->GetSovereign() ? pStationType->GetSovereign()->GetTypeNounPhrase() : NULL_STR);
InitStationTypeImage(NewEntry, pStationType);
break;
}