本文整理汇总了C++中CShipClass::GetNounPhrase方法的典型用法代码示例。如果您正苦于以下问题:C++ CShipClass::GetNounPhrase方法的具体用法?C++ CShipClass::GetNounPhrase怎么用?C++ CShipClass::GetNounPhrase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CShipClass
的用法示例。
在下文中一共展示了CShipClass::GetNounPhrase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GenerateImageChart
//.........这里部分代码省略.........
TSortMap<CString, SEntryDesc> Table;
for (i = 0; i < Universe.GetDesignTypeCount(); i++)
{
CDesignType *pType = Universe.GetDesignType(i);
SEntryDesc NewEntry;
// Make sure we match the criteria
if (!pType->MatchesCriteria(Criteria))
continue;
// Figure stuff stuff out based on the specific design type
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")))
示例3: ArrangeByRow
void ArrangeByRow (CSymbolTable &Table, SArrangeDesc &Desc, CPaintMap &Map)
{
int iNext = 0;
int y = 0;
int cyHeader = Desc.pHeader->GetHeight();
int cxInternalSpacing = 8;
int cyInternalSpacing = 2 * Desc.pHeader->GetHeight();
int cyNameSpacing = Desc.pHeader->GetHeight() / 2;
while (iNext < Table.GetCount())
{
int i;
int cxWidthLeft = Desc.cxDesiredWidth;
int cyRowHeight = 0;
int iStart = iNext;
// First figure out how many ships will fit
while (iNext < Table.GetCount())
{
CShipClass *pClass = (CShipClass *)Table.GetValue(iNext);
int cxSize = RectWidth(pClass->GetImage().GetImageRect());
if (cxSize > cxWidthLeft && iStart != iNext)
break;
int cxCell = Max(cxSize + cxInternalSpacing, Desc.cxSpacing);
cxWidthLeft -= cxCell;
if (cxSize > cyRowHeight)
cyRowHeight = cxSize;
iNext++;
}
// Compute the total width
int cxRowWidth = Min(Desc.cxDesiredWidth - cxWidthLeft, Desc.cxDesiredWidth);
int xOffset = (Desc.cxDesiredWidth - cxRowWidth) / 2;
// See if any of the ships overlap the text from the previous ships
// If so, we increase y a little bit
int x = Desc.cxSpacing + Desc.cxExtraMargin;
for (i = iStart; i < iNext; i++)
{
CShipClass *pClass = (CShipClass *)Table.GetValue(i);
int cxSize = RectWidth(pClass->GetImage().GetImageRect());
int yOffset = (cyRowHeight - cxSize) / 2;
int xPoint = x + xOffset + cxSize / 2;
int yPoint = y + yOffset;
for (int j = 0; j < iStart; j++)
{
int xText = Map.GetTextX(j);
int yText = Map.GetTextY(j);
int cxText = Map.GetTextWidth(j);
int cyText = Map.GetTextHeight(j) + cyInternalSpacing;
if (xPoint >= xText && xPoint < xText + cxText && yPoint < yText + cyText)
y = yText + cyText + cyInternalSpacing;
}
int cxCell = Max(cxSize + cxInternalSpacing, Desc.cxSpacing);
x += cxCell;
}
// Place the ships
x = Desc.cxSpacing + Desc.cxExtraMargin;
int yOverlapOffset = 0;
for (i = iStart; i < iNext; i++)
{
CShipClass *pClass = (CShipClass *)Table.GetValue(i);
int cxSize = RectWidth(pClass->GetImage().GetImageRect());
int cxCell = Max(cxSize + cxInternalSpacing, Desc.cxSpacing);
// Center vertically
int yOffset = (cyRowHeight - cxSize) / 2;
// Place
Map.Place(i, x + xOffset, y + yOffset, cxSize, cxSize);
// Figure out the position of the text
int cyName;
int cxName = Desc.pHeader->MeasureText(pClass->GetNounPhrase(0), &cyName);
if (cxName <= cxSize)
{
int yText = y + yOffset + cxSize + cyNameSpacing;
Map.PlaceText(i,
x + xOffset + (cxSize - cxName) / 2,
yText,
cxName,
cyName);
yOverlapOffset = yText + cyName + cyNameSpacing;
//.........这里部分代码省略.........
示例4: GenerateShipImageChart
//.........这里部分代码省略.........
// Compute the sort key
char szBuffer[1024];
switch (iOrder)
{
case orderLargest:
wsprintf(szBuffer, "%04d%s%x",
2048 - RectWidth(pClass->GetImage().GetImageRect()),
pClass->GetName().GetASCIIZPointer(),
pClass);
break;
case orderSmallest:
wsprintf(szBuffer, "%04d%s%x",
RectWidth(pClass->GetImage().GetImageRect()),
pClass->GetName().GetASCIIZPointer(),
pClass);
break;
default:
wsprintf(szBuffer, "%s%x", pClass->GetName().GetASCIIZPointer(), pClass);
break;
}
// Add to list
Table.AddEntry(CString(szBuffer), (CObject *)pClass);
}
// Allocate a map that tracks where to paint each ship
CPaintMap Map(Table.GetCount());
// Arrange the ships
SArrangeDesc Desc;
Desc.cxDesiredWidth = Max(512, cxDesiredWidth - (2 * (cxSpacing + cxExtraMargin)));
Desc.cxSpacing = cxSpacing;
Desc.cxExtraMargin = cxExtraMargin;
Desc.pHeader = &NameFont;
ArrangeByRow(Table, Desc, Map);
//ArrangeByCell(Table, cxDesiredWidth, Map);
// Create a large image
CG16bitImage Output;
int cxWidth = Max(cxDesiredWidth, Map.GetWidth());
int cyHeight = Map.GetHeight();
Output.CreateBlank(cxWidth, cyHeight, false);
printf("Creating %dx%d image.\n", cxWidth, cyHeight);
// Paint the images
for (i = 0; i < Table.GetCount(); i++)
{
CShipClass *pClass = (CShipClass *)Table.GetValue(i);
int x = Map.GetX(i);
int y = Map.GetY(i);
if (x != -1)
{
if (!bTextBoxesOnly)
pClass->GetImage().PaintImageUL(Output,
x,
y,
0,
Angle2Direction(iRotation));
// Paint name
int xText = Map.GetTextX(i);
int yText = Map.GetTextY(i);
if (xText != -1)
{
if (bTextBoxesOnly)
Output.Fill(xText, yText, Map.GetTextWidth(i), Map.GetTextHeight(i), 0xffff);
if (!bTextBoxesOnly)
{
Output.FillColumn(x + (Map.GetWidth(i) / 2),
y + Map.GetHeight(i),
yText - (y + Map.GetHeight(i)),
wNameColor);
NameFont.DrawText(Output,
xText,
yText,
wNameColor,
255,
pClass->GetNounPhrase(0));
}
}
}
}
// Write to file or clipboard
OutputImage(Output, sFilespec);
}
示例5: GenerateGameStats
void CPlayerGameStats::GenerateGameStats (CGameStats &Stats, CSpaceObject *pPlayerShip, bool bGameOver) const
// GenerateGameStats
//
// Generates a stats for everything we track
{
int j;
CShip *pShip = (pPlayerShip ? pPlayerShip->AsShip() : NULL);
if (pShip == NULL)
return;
CPlayerShipController *pPlayer = (CPlayerShipController *)pShip->GetController();
if (pPlayer == NULL)
return;
CSovereign *pPlayerSovereign = g_pUniverse->FindSovereign(g_PlayerSovereignUNID);
if (pPlayerSovereign == NULL)
return;
// Base stats
Stats.Insert(CONSTLIT("Genome"), strCapitalize(GetGenomeName(pPlayer->GetPlayerGenome())));
Stats.Insert(CONSTLIT("Score"), strFormatInteger(CalcEndGameScore(), -1, FORMAT_THOUSAND_SEPARATOR | FORMAT_UNSIGNED));
Stats.Insert(CONSTLIT("Ship class"), pShip->GetNounPhrase(0));
CTimeSpan Time = GetPlayTime();
if (!Time.IsBlank())
Stats.Insert(CONSTLIT("Time played"), Time.Format(NULL_STR));
#ifdef REAL_TIME
Time = GetGameTime();
if (!Time.IsBlank())
Stats.Insert(CONSTLIT("Time elapsed in game"), Time.Format(NULL_STR));
#endif
// Some combat stats
CString sDestroyed = GetStat(ENEMY_SHIPS_DESTROYED_STAT);
if (!sDestroyed.IsBlank())
Stats.Insert(CONSTLIT("Enemy ships destroyed"), sDestroyed, CONSTLIT("combat"));
sDestroyed = GetStat(FRIENDLY_SHIPS_DESTROYED_STAT);
if (!sDestroyed.IsBlank())
Stats.Insert(CONSTLIT("Friendly ships destroyed"), sDestroyed, CONSTLIT("combat"));
sDestroyed = GetStat(ENEMY_STATIONS_DESTROYED_STAT);
if (!sDestroyed.IsBlank())
Stats.Insert(CONSTLIT("Enemy stations destroyed"), sDestroyed, CONSTLIT("combat"));
sDestroyed = GetStat(FRIENDLY_STATIONS_DESTROYED_STAT);
if (!sDestroyed.IsBlank())
Stats.Insert(CONSTLIT("Friendly stations destroyed"), sDestroyed, CONSTLIT("combat"));
// Add stat for every station destroyed
CStatCounterArray CounterArray;
CMapIterator i;
m_StationStats.Reset(i);
while (m_StationStats.HasMore(i))
{
SStationTypeStats *pStats;
DWORD dwUNID = m_StationStats.GetNext(i, &pStats);
CStationType *pType = g_pUniverse->FindStationType(dwUNID);
if (pType == NULL)
continue;
CString sName = pType->GetNounPhrase(0);
CString sSort = strPatternSubst(CONSTLIT("%03d%s"), 100 - pType->GetLevel(), sName);
if (pType->GetSovereign()->IsEnemy(pPlayerSovereign))
CounterArray.Insert(sName, pStats->iDestroyed, CONSTLIT("Enemy stations destroyed"), sSort);
else
CounterArray.Insert(sName, pStats->iDestroyed, CONSTLIT("Friendly stations destroyed"), sSort);
}
CounterArray.GenerateGameStats(Stats);
// Add stat for every ship class destroyed
CounterArray.DeleteAll();
m_ShipStats.Reset(i);
while (m_ShipStats.HasMore(i))
{
SShipClassStats *pStats;
DWORD dwUNID = m_ShipStats.GetNext(i, &pStats);
CShipClass *pClass = g_pUniverse->FindShipClass(dwUNID);
if (pClass == NULL)
continue;
CString sName = pClass->GetNounPhrase(0);
CString sSort = strPatternSubst(CONSTLIT("%09d%s"), 100000000 - pClass->GetScore(), sName);
if (pStats->iEnemyDestroyed > 0)
CounterArray.Insert(sName, pStats->iEnemyDestroyed, CONSTLIT("Enemy ships destroyed"), sSort);
if (pStats->iFriendDestroyed > 0)
CounterArray.Insert(sName, pStats->iFriendDestroyed, CONSTLIT("Friendly ships destroyed"), sSort);
//.........这里部分代码省略.........