bool C4Object::CreateContentsByList(C4IDList &idlist) { int32_t cnt,cnt2; for (cnt=0; idlist.GetID(cnt); cnt++) for (cnt2=0; cnt2<idlist.GetCount(cnt); cnt2++) if (!CreateContents(C4Id2Def(idlist.GetID(cnt)))) return false; return true; }
void C4GoalDisplay::SetGoals(const C4IDList &rAllGoals, const C4IDList &rFulfilledGoals, int32_t iGoalSymbolHeight) { // clear previous ClearChildren(); // determine goal display area by goal count int32_t iGoalSymbolMargin = C4GUI_DefDlgSmallIndent; int32_t iGoalSymbolAreaHeight = 2*iGoalSymbolMargin + iGoalSymbolHeight; int32_t iGoalAreaWdt = GetClientRect().Wdt; int32_t iGoalsPerRow = Max<int32_t>(1, iGoalAreaWdt / iGoalSymbolAreaHeight); int32_t iGoalCount = rAllGoals.GetNumberOfIDs(); int32_t iRowCount = (iGoalCount-1) / iGoalsPerRow + 1; C4Rect rcNewBounds = GetBounds(); rcNewBounds.Hgt = GetMarginTop()+GetMarginBottom()+iRowCount*iGoalSymbolAreaHeight; SetBounds(rcNewBounds); C4GUI::ComponentAligner caAll(GetClientRect(), 0,0, true); // place goal symbols in this area int32_t iGoal = 0; for (int32_t iRow=0; iRow<iRowCount; ++iRow) { int32_t iColCount = Min<int32_t>(iGoalCount - iGoal, iGoalsPerRow); C4GUI::ComponentAligner caGoalArea(caAll.GetFromTop(iGoalSymbolAreaHeight, iColCount*iGoalSymbolAreaHeight), iGoalSymbolMargin,iGoalSymbolMargin, false); for (int32_t iCol=0; iCol<iColCount; ++iCol,++iGoal) { C4ID idGoal = rAllGoals.GetID(iGoal); bool fFulfilled = !!rFulfilledGoals.GetIDCount(idGoal, 1); AddElement(new GoalPicture(caGoalArea.GetGridCell(iCol, iColCount, iRow, iRowCount), idGoal, fFulfilled)); } } }