sint32 Strengths::GetTotalWonderCost() const
{
	sint32 i;
	sint32 c = 0;
	for(i = g_theWonderDB->NumRecords() - 1; i >= 0; i--) {
		if(g_player[m_owner]->m_builtWonders & (uint64(1) << uint64(i))) {
			c += wonderutil_Get(i, m_owner)->GetProductionCost();
		}
	}
	return c;
}
Exemple #2
0
void WonderTab::AddWonderItem(sint32 wonder, sint32 player, sint32 turn)
{
	Unit curCity;
	if(!g_theWonderTracker->GetCityWithWonder(wonder, curCity))
		curCity.m_id = 0;

	const WonderRecord *rec = wonderutil_Get(wonder, player);
	ctp2_ListItem *item = (ctp2_ListItem *)aui_Ldl::BuildHierarchyFromRoot("WonderTabListItem");
	Assert(item);
	if(item) {
		ctp2_Static *box = (ctp2_Static *)item->GetChildByIndex(0);

		Assert(box);
		if(box) {
			ctp2_Static *st = (ctp2_Static *)box->GetChildByIndex(0);
			Assert(st);
			if(st) {
				st->SetImage((char *)rec->GetDefaultIcon()->GetFirstFrame());
			}

			st = (ctp2_Static *)box->GetChildByIndex(1);
			Assert(st);
			if(st) {
				st->SetText(rec->GetNameText());
			}

			st = (ctp2_Static *)box->GetChildByIndex(2);
			Assert(st);
			if(st) {
				const char *year = diffutil_GetYearStringFromTurn(g_theGameSettings->GetDifficulty(), turn);
				if(year) {
					st->SetText(year);
				} else {
					st->SetText("error");
				}
				
				item->SetUserData((void*)turn);
			}

			st = (ctp2_Static *)box->GetChildByIndex(3);
			Assert(st);
			if(st) {
				if(curCity.IsValid()) {
					st->SetText(curCity.CD()->GetName());
					st->SetTextColor(g_colorSet->GetColorRef(g_colorSet->ComputePlayerColor(curCity.GetOwner())));
				} else {
					st->SetText("---");
				}
			}

			st = (ctp2_Static *)box->GetChildByIndex(4);
			Assert(st);
			if(st) {
				Player *p = g_player[player];
				if(!p) {
					PointerList<Player>::Walker walk(g_deadPlayer);
					for(; walk.IsValid(); walk.Next()) {
						if(walk.GetObj()->m_owner == player) {
							p = walk.GetObj();
							break;
						}
					}
				}
				if(!p) {
					st->SetText("---");
				} else {					
					MBCHAR buf[k_MAX_NAME_LEN];
					p->m_civilisation->GetCountryName(buf);
					st->SetText(buf);
				}
			}
		}

		item->SetCompareCallback(CompareWonderItems);

		m_list->AddItem(item);
	}
}