本文整理汇总了C++中C4Team::GetColor方法的典型用法代码示例。如果您正苦于以下问题:C++ C4Team::GetColor方法的具体用法?C++ C4Team::GetColor怎么用?C++ C4Team::GetColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C4Team
的用法示例。
在下文中一共展示了C4Team::GetColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateRandomPlayerColor
void C4Team::RecheckColor(C4TeamList &rForList)
{
// number of times trying new player colors
const int32_t C4MaxTeamColorChangeTries = 100;
if (!dwClr)
{
const int defTeamColorCount = 10;
DWORD defTeamColorRGB[defTeamColorCount] = { 0xF40000, 0x00C800, 0xFCF41C, 0x2020FF, // red, green, yellow, blue,
0xC48444, 0xFFFFFF, 0x848484, 0xFF00EF, // brown, white, grey, pink,
0x00FFFF, 0x784830
}; // cyan, dk brown
// no color assigned yet: Generate by team ID
if (iID >=1 && iID <=defTeamColorCount)
{
// default colors
dwClr = defTeamColorRGB[iID-1] | 0xff000000;
}
else
{
// find a new, unused color
for (int32_t iTry=1; iTry<C4MaxTeamColorChangeTries; ++iTry)
{
dwClr = GenerateRandomPlayerColor(iTry);
int32_t iIdx=0; C4Team *pTeam; bool fOK=true;
while ((pTeam = rForList.GetTeamByIndex(iIdx++)))
if (pTeam != this)
if (IsColorConflict(pTeam->GetColor(), dwClr))
{
fOK=false;
break;
}
// color is fine?
if (fOK) return;
// it's not; try next color
}
// Giving up: Use last generated color
}
}
}
示例2: if
bool C4MainMenu::DoRefillInternal(bool &rfRefilled)
{
// Variables
C4FacetSurface fctSymbol;
C4Player *pPlayer;
C4IDList ListItems;
C4Facet fctTarget;
bool fWasEmpty = !GetItemCount();
// Refill
switch (Identification)
{
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4MN_Hostility:
{
// Clear items
ClearItems();
// Refill player
if (!(pPlayer = ::Players.Get(Player))) return false;
// Refill items
C4Player *pPlr; int32_t iIndex;
for (iIndex=0; (pPlr = ::Players.GetByIndex(iIndex)); iIndex++)
// Ignore player self and invisible
if (pPlr != pPlayer) if (!pPlr->IsInvisible())
{
// Symbol
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
pPlayer->DrawHostility(fctSymbol,iIndex);
// Message
StdStrBuf sMsg;
bool isFriendly = pPlayer->Hostility.find(pPlr) == pPlayer->Hostility.end();
if (isFriendly)
sMsg.Format(LoadResStr("IDS_MENU_ATTACK"),pPlr->GetName());
else
sMsg.Format(LoadResStr("IDS_MENU_NOATTACK"),pPlr->GetName());
// Command
char szCommand[1000];
sprintf(szCommand,"SetHostility:%i",pPlr->Number);
// Info caption
char szInfoCaption[C4MaxTitle+1],szFriendly[50],szNot[30]="";
SCopy(LoadResStr(isFriendly ? "IDS_MENU_ATTACKHOSTILE" : "IDS_MENU_ATTACKFRIENDLY"),szFriendly);
if (!isFriendly) SCopy(LoadResStr("IDS_MENU_ATTACKNOT"),szNot);
sprintf(szInfoCaption,LoadResStr("IDS_MENU_ATTACKINFO"),pPlr->GetName(),szFriendly,szNot);
if (iIndex==pPlayer->Number) SCopy(LoadResStr("IDS_MENU_ATTACKSELF"),szInfoCaption);
// Add item
Add(sMsg.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,szInfoCaption);
fctSymbol.Default();
}
break;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4MN_TeamSelection:
case C4MN_TeamSwitch:
{
// Clear items
ClearItems();
// add all teams as menu items
// 2do: Icon
C4Team *pTeam; int32_t i=0; bool fAddNewTeam=Game.Teams.IsAutoGenerateTeams();
for (;;)
{
pTeam = Game.Teams.GetTeamByIndex(i);
if (pTeam)
{
// next regular team
++i;
// do not add a new team if an empty team exists
if (!pTeam->GetPlayerCount()) fAddNewTeam = false;
}
else if (fAddNewTeam)
{
// join new team
fAddNewTeam = false;
}
else
{
// all teams done
break;
}
// create team symbol: Icon spec if specified; otherwise flag for empty and crew for nonempty team
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
const char *szIconSpec = pTeam ? pTeam->GetIconSpec() : NULL;
bool fHasIcon = false;
if (szIconSpec && *szIconSpec)
{
fHasIcon = Game.DrawTextSpecImage(fctSymbol, szIconSpec, NULL, pTeam->GetColor());
}
if (!fHasIcon)
{
if (pTeam && pTeam->GetPlayerCount())
::GraphicsResource.fctCrewClr.DrawClr(fctSymbol, true, pTeam->GetColor());
else
C4GUI::Icon::GetIconFacet(C4GUI::Ico_Team).Draw(fctSymbol, true);
}
StdStrBuf sTeamName;
if (pTeam)
{
sTeamName.Take(pTeam->GetNameWithParticipants());
}
else
//.........这里部分代码省略.........