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)); } } }
C4Network2StartWaitDlg::C4Network2StartWaitDlg() : C4GUI::Dialog(DialogWidth, DialogHeight, LoadResStr("IDS_NET_CAPTION"), false) { C4GUI::ComponentAligner caAll(GetContainedClientRect(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent); C4GUI::ComponentAligner caButtonArea(caAll.GetFromBottom(C4GUI_ButtonAreaHgt), 0,0); // create top label C4GUI::Label *pLbl; AddElement(pLbl = new C4GUI::Label(LoadResStr("IDS_NET_WAITFORSTART"), caAll.GetFromTop(25), ACenter)); // create client list box AddElement(pClientListBox = new C4Network2ClientListBox(caAll.GetAll(), true)); // place abort button C4GUI::Button *pBtnAbort = new C4GUI::CancelButton(caButtonArea.GetCentered(C4GUI_DefButtonWdt, C4GUI_ButtonHgt)); AddElement(pBtnAbort); }
C4ChartDialog::C4ChartDialog() : Dialog(DialogWidth, DialogHeight, LoadResStr("IDS_NET_STATISTICS"), false) { // register singleton pChartDlg = this; // add main chart switch component C4GUI::ComponentAligner caAll(GetContainedClientRect(), 5,5); pChartTabular = new C4GUI::Tabular(caAll.GetAll(), C4GUI::Tabular::tbTop); AddElement(pChartTabular); // add some graphs as subcomponents AddChart(StdStrBuf("oc")); AddChart(StdStrBuf("FPS")); AddChart(StdStrBuf("NetIO")); if (::Network.isEnabled()) AddChart(StdStrBuf("Pings")); AddChart(StdStrBuf("Control")); AddChart(StdStrBuf("APM")); }
C4Network2ClientListDlg::C4Network2ClientListDlg() : Dialog(::pGUI->GetPreferredDlgRect().Wdt*3/4, ::pGUI->GetPreferredDlgRect().Hgt*3/4, LoadResStr("IDS_NET_CAPTION"), false) { // component layout CStdFont *pUseFont = &::GraphicsResource.TextFont; C4GUI::ComponentAligner caAll(GetContainedClientRect(), 0,0); C4Rect rcStatus = caAll.GetFromBottom(pUseFont->GetLineHeight()); // create game options; max 1/2 of dialog height pGameOptions = new C4GameOptionsList(caAll.GetFromTop(caAll.GetInnerHeight()/2), true, C4GameOptionsList::GOLS_Runtime); pGameOptions->SetDecoration(false, nullptr, true, false); pGameOptions->SetSelectionDiabled(); // but resize to actually used height int32_t iFreedHeight = pGameOptions->ContractToElementHeight(); caAll.ExpandTop(iFreedHeight); AddElement(pGameOptions); // create client list box AddElement(pListBox = new C4Network2ClientListBox(caAll.GetAll(), false)); // create status label AddElement(pStatusLabel = new C4GUI::Label("", rcStatus)); // add timer Application.Add(this); // initial update Update(); }