LabeledRect DebriefingScreen::initialize(int text_id, bool do_score) { Resource rsrc("text", "txt", text_id); _message.assign(utf8::decode(rsrc.data())); int text_height = GetInterfaceTextHeightFromWidth(_message, kLarge, kTextWidth); Rect text_bounds(0, 0, kTextWidth, text_height); if (do_score) { text_bounds.bottom += kScoreTableHeight; } text_bounds.center_in(viewport()); LabeledRect data_item = interface_item(text_bounds); _pix_bounds = pix_bounds(data_item); _message_bounds = text_bounds; _message_bounds.offset(-_pix_bounds.left, -_pix_bounds.top); return data_item; }
void update_mission_brief_point( interfaceItemType *dataItem, long whichBriefPoint, const Scenario* scenario, coordPointType *corner, long scale, Rect *bounds, vector<inlinePictType>& inlinePict, Rect& highlight_rect, vector<pair<Point, Point> >& lines, String& text) { if (whichBriefPoint < kMissionBriefPointOffset) { // No longer handled here. return; } whichBriefPoint -= kMissionBriefPointOffset; Rect hiliteBounds; long headerID, headerNumber, contentID; BriefPoint_Data_Get(whichBriefPoint, scenario, &headerID, &headerNumber, &contentID, &hiliteBounds, corner, scale, 16, 32, bounds); hiliteBounds.offset(bounds->left, bounds->top); // TODO(sfiera): catch exception. Resource rsrc("text", "txt", contentID); text.assign(macroman::decode(rsrc.data())); short textHeight = GetInterfaceTextHeightFromWidth(text, dataItem->style, kMissionDataWidth); if (hiliteBounds.left == hiliteBounds.right) { dataItem->bounds.left = (bounds->right - bounds->left) / 2 - (kMissionDataWidth / 2) + bounds->left; dataItem->bounds.right = dataItem->bounds.left + kMissionDataWidth; dataItem->bounds.top = (bounds->bottom - bounds->top) / 2 - (textHeight / 2) + bounds->top; dataItem->bounds.bottom = dataItem->bounds.top + textHeight; } else { if ((hiliteBounds.left + (hiliteBounds.right - hiliteBounds.left) / 2) > (bounds->left + (bounds->right - bounds->left) / 2)) { dataItem->bounds.right = hiliteBounds.left - kMissionDataHBuffer; dataItem->bounds.left = dataItem->bounds.right - kMissionDataWidth; } else { dataItem->bounds.left = hiliteBounds.right + kMissionDataHBuffer; dataItem->bounds.right = dataItem->bounds.left + kMissionDataWidth; } dataItem->bounds.top = hiliteBounds.top + (hiliteBounds.bottom - hiliteBounds.top) / 2 - textHeight / 2; dataItem->bounds.bottom = dataItem->bounds.top + textHeight; if (dataItem->bounds.top < (bounds->top + kMissionDataTopBuffer)) { dataItem->bounds.top = bounds->top + kMissionDataTopBuffer; dataItem->bounds.bottom = dataItem->bounds.top + textHeight; } if (dataItem->bounds.bottom > (bounds->bottom - kMissionDataBottomBuffer)) { dataItem->bounds.bottom = bounds->bottom - kMissionDataBottomBuffer; dataItem->bounds.top = dataItem->bounds.bottom - textHeight; } if (dataItem->bounds.left < (bounds->left + kMissionDataVBuffer)) { dataItem->bounds.left = bounds->left + kMissionDataVBuffer; dataItem->bounds.right = dataItem->bounds.left + kMissionDataWidth; } if (dataItem->bounds.right > (bounds->right - kMissionDataVBuffer)) { dataItem->bounds.right = bounds->right - kMissionDataVBuffer; dataItem->bounds.left = dataItem->bounds.right - kMissionDataWidth; } hiliteBounds.right++; hiliteBounds.bottom++; highlight_rect = hiliteBounds; Rect newRect; GetAnyInterfaceItemGraphicBounds(*dataItem, &newRect); lines.clear(); if (dataItem->bounds.right < hiliteBounds.left) { Point p1(hiliteBounds.left, hiliteBounds.top); Point p2(newRect.right + kMissionLineHJog, hiliteBounds.top); Point p3(newRect.right + kMissionLineHJog, newRect.top); Point p4(newRect.right + 2, newRect.top); lines.push_back(make_pair(p1, p2)); lines.push_back(make_pair(p2, p3)); lines.push_back(make_pair(p3, p4)); Point p5(hiliteBounds.left, hiliteBounds.bottom - 1); Point p6(newRect.right + kMissionLineHJog, hiliteBounds.bottom - 1); Point p7(newRect.right + kMissionLineHJog, newRect.bottom - 1); Point p8(newRect.right + 2, newRect.bottom - 1); lines.push_back(make_pair(p5, p6)); lines.push_back(make_pair(p6, p7)); lines.push_back(make_pair(p7, p8)); } else { Point p1(hiliteBounds.right, hiliteBounds.top); Point p2(newRect.left - kMissionLineHJog, hiliteBounds.top); Point p3(newRect.left - kMissionLineHJog, newRect.top); Point p4(newRect.left - 3, newRect.top); lines.push_back(make_pair(p1, p2)); lines.push_back(make_pair(p2, p3)); lines.push_back(make_pair(p3, p4)); Point p5(hiliteBounds.right, hiliteBounds.bottom - 1); Point p6(newRect.left - kMissionLineHJog, hiliteBounds.bottom - 1); Point p7(newRect.left - kMissionLineHJog, newRect.bottom - 1); Point p8(newRect.left - 3, newRect.bottom - 1); lines.push_back(make_pair(p5, p6)); lines.push_back(make_pair(p6, p7)); lines.push_back(make_pair(p7, p8)); } } dataItem->item.labeledRect.label.stringID = headerID; dataItem->item.labeledRect.label.stringNumber = headerNumber; Rect newRect; GetAnyInterfaceItemGraphicBounds(*dataItem, &newRect); populate_inline_picts(dataItem->bounds, text, dataItem->style, inlinePict); }