当前位置: 首页>>代码示例>>C++>>正文


C++ CShipClass::GetImage方法代码示例

本文整理汇总了C++中CShipClass::GetImage方法的典型用法代码示例。如果您正苦于以下问题:C++ CShipClass::GetImage方法的具体用法?C++ CShipClass::GetImage怎么用?C++ CShipClass::GetImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CShipClass的用法示例。


在下文中一共展示了CShipClass::GetImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ArrangeByCell

void ArrangeByCell (CSymbolTable &Table, int cxDesiredWidth, CPaintMap &Map)
	{
	int i;

	//	Compute the size of each image cell

	int cxCell = 32;
	int cyCell = 32;

	//	Compute the number of rows & columns

	int iInitCols = (cxDesiredWidth / cxCell) + ((cxDesiredWidth % cxCell) ? 1 : 0);
	int iInitRows = AlignUp(20 * Table.GetCount(), iInitCols) / iInitCols;

	//	Create an array that keeps track of which cells we've used up

	CCellMap CellMap(iInitCols, iInitRows);

	//	Figure out where to place all the ships

	for (i = 0; i < Table.GetCount(); i++)
		{
		CShipClass *pClass = (CShipClass *)Table.GetValue(i);

		//	Figure out how many cells we need

		int cxSize = RectWidth(pClass->GetImage().GetImageRect());
		int iCellsNeeded = AlignUp(cxSize, cxCell) / cxCell;
		int cxAreaSize = iCellsNeeded * cxCell;

		//	Position the ship

		int x, y;
		if (CellMap.GetSpace(iCellsNeeded, &x, &y))
			Map.Place(i,
				x * cxCell + (cxAreaSize - cxSize) / 2,
				y * cyCell + (cxAreaSize - cxSize) / 2,
				cxSize,
				cxSize);
		}
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:41,代码来源:ShipImageChart.cpp

示例2: CreateFileEntry


//.........这里部分代码省略.........
		CG16bitImage *pIcon;
		pAdventure->CreateIcon(ADVENTURE_ICON_WIDTH, ADVENTURE_ICON_HEIGHT, &pIcon);

		if (pIcon)
			{
			int xOffset = (ADVENTURE_ICON_WIDTH - pIcon->GetWidth()) / 2;
			IAnimatron *pIconAni = new CAniRect;
			pIconAni->SetPropertyVector(PROP_POSITION, CVector(x + xOffset, 0));
			pIconAni->SetPropertyVector(PROP_SCALE, CVector(pIcon->GetWidth(), pIcon->GetHeight()));
			pIconAni->SetFillMethod(new CAniImageFill(pIcon, true));

			pRoot->AddTrack(pIconAni, 0);

			bHasAdventureIcon = true;
			}

		//	Adventure name

		pName = new CAniText;
		pName->SetPropertyVector(PROP_POSITION, CVector(xText, y));
		pName->SetPropertyVector(PROP_SCALE, CVector(10000, 1000));
		pName->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextDialogLabel));
		pName->SetPropertyFont(PROP_FONT, &MediumFont);
		pName->SetPropertyString(PROP_TEXT, pAdventure->GetName());

		pRoot->AddTrack(pName, 0);
		y += MediumFont.GetHeight();
		}

	//	Create an image of the ship class

	if (pClass)
		{
		const CObjectImageArray &ObjImage = pClass->GetImage();
		if (ObjImage.IsLoaded())
			{
			RECT rcRect = ObjImage.GetImageRect();
			CG16bitImage &Image = ObjImage.GetImage(NULL_STR);
			int cxImage = RectWidth(rcRect);
			int cyImage = RectHeight(rcRect);

			int cxNewWidth = Min(SHIP_IMAGE_WIDTH, cxImage);
			int cyNewHeight = cxNewWidth;

			CG16bitImage *pNewImage = new CG16bitImage;
			pNewImage->CreateFromImageTransformed(Image, 
					rcRect.left, 
					rcRect.top, 
					cxImage,
					cyImage,
					(Metric)cxNewWidth / cxImage,
					(Metric)cyNewHeight / cyImage,
					0.0);

			//	Position

			int xImage = x + m_cxWidth - SHIP_IMAGE_WIDTH + (SHIP_IMAGE_WIDTH - cxNewWidth) / 2;
			int yImage = (SHIP_IMAGE_HEIGHT - cyNewHeight) / 2;

			//	New image frame

			IAnimatron *pImageFrame = new CAniRect;
			pImageFrame->SetPropertyVector(PROP_POSITION, CVector(xImage, yImage));
			pImageFrame->SetPropertyVector(PROP_SCALE, CVector(cxNewWidth, cyNewHeight));
			pImageFrame->SetFillMethod(new CAniImageFill(pNewImage, true));
开发者ID:,项目名称:,代码行数:66,代码来源:

示例3: GenerateImageChart


//.........这里部分代码省略.........
	for (i = 0; i < Universe.GetDesignTypeCount(); i++)
		{
		CDesignType *pType = Universe.GetDesignType(i);
		SEntryDesc NewEntry;

		//	Make sure we match the criteria

		if (!pType->MatchesCriteria(Criteria))
			continue;

		//	Figure stuff stuff out based on the specific design type

		switch (pType->GetType())
			{
			case designItemType:
				{
				CItemType *pItemType = CItemType::AsType(pType);
				CItem Item(pItemType, 1);

				//	Skip if not in item criteria

				if (!Item.MatchesCriteria(ItemCriteria))
					continue;

				//	Skip virtual classes

				if (pItemType->IsVirtual())
					continue;

				//	Initialize the entry

				NewEntry.pType = pType;
				NewEntry.sName = pItemType->GetNounPhrase(0);
				NewEntry.pImage = &pItemType->GetImage();
				NewEntry.iSize = RectWidth(NewEntry.pImage->GetImageRect());
				break;
				}

			case designShipClass:
				{
				CShipClass *pClass = CShipClass::AsType(pType);

				//	Skip non-generic classess

				if (!bAll && !pClass->HasLiteralAttribute(CONSTLIT("genericClass")))
					continue;

				//	Initialize the entry

				NewEntry.pType = pType;
				NewEntry.sName = pClass->GetNounPhrase(0);
				NewEntry.iSize = RectWidth(pClass->GetImage().GetImageRect());
				NewEntry.pImage = &pClass->GetImage();
				NewEntry.iRotation = pClass->Angle2Direction(iRotation);
				NewEntry.sSovereignName = (pClass->GetDefaultSovereign() ? pClass->GetDefaultSovereign()->GetTypeNounPhrase() : NULL_STR);
				break;
				}

			case designStationType:
				{
				CStationType *pStationType = CStationType::AsType(pType);

				//	Skip generic classes

				if (!bAll && !pStationType->HasLiteralAttribute(CONSTLIT("generic")))
					continue;
开发者ID:,项目名称:,代码行数:67,代码来源:

示例4: GenerateShipImageChart

void GenerateShipImageChart (CUniverse &Universe, CXMLElement *pCmdLine)
	{
	int i;

	enum OrderTypes
		{
		orderSmallest = 1,
		orderLargest = 2,
		orderName = 3,
		};

	//	Options

	bool bTextBoxesOnly = pCmdLine->GetAttributeBool(CONSTLIT("textBoxesOnly"));

	//	Figure out what order we want

	CString sOrder = pCmdLine->GetAttribute(CONSTLIT("sort"));
	int iOrder;
	if (strEquals(sOrder, CONSTLIT("smallest")))
		iOrder = orderSmallest;
	else if (strEquals(sOrder, CONSTLIT("largest")))
		iOrder = orderLargest;
	else
		iOrder = orderName;

	//	Image size

	int cxDesiredWidth;
	if (pCmdLine->FindAttributeInteger(CONSTLIT("width"), &cxDesiredWidth))
		cxDesiredWidth = Max(512, cxDesiredWidth);
	else
		cxDesiredWidth = 1280;

	//	Spacing

	int cxSpacing = pCmdLine->GetAttributeInteger(CONSTLIT("xSpacing"));
	int cxExtraMargin = pCmdLine->GetAttributeInteger(CONSTLIT("xMargin"));

	//	Rotation

	int iRotation = pCmdLine->GetAttributeInteger(CONSTLIT("rotation"));

	//	Font for text

	CString sTypeface;
	int iSize;
	bool bBold;
	bool bItalic;

	if (!CG16bitFont::ParseFontDesc(pCmdLine->GetAttribute(CONSTLIT("font")),
			&sTypeface,
			&iSize,
			&bBold,
			&bItalic))
		{
		sTypeface = CONSTLIT("Arial");
		iSize = 10;
		bBold = false;
		bItalic = false;
		}

	CG16bitFont NameFont;
	NameFont.Create(sTypeface, -PointsToPixels(iSize), bBold, bItalic);
	WORD wNameColor = CG16bitImage::RGBValue(255, 255, 255);

	//	Output file

	CString sFilespec = pCmdLine->GetAttribute(CONSTLIT("output"));
	if (!sFilespec.IsBlank())
		sFilespec = pathAddExtensionIfNecessary(sFilespec, CONSTLIT(".bmp"));

	//	Generate a table of ships

	CSymbolTable Table(FALSE, TRUE);
	for (i = 0; i < Universe.GetShipClassCount(); i++)
		{
		CShipClass *pClass = Universe.GetShipClass(i);

		//	Skip player ship classes

		if (pClass->GetPlayerSettings())
			continue;

		//	Skip non-generic classes

		if (!pClass->HasAttribute(CONSTLIT("genericClass")))
			continue;

		//	Compute the sort key

		char szBuffer[1024];
		switch (iOrder)
			{
			case orderLargest:
				wsprintf(szBuffer, "%04d%s%x",
						2048 - RectWidth(pClass->GetImage().GetImageRect()),
						pClass->GetName().GetASCIIZPointer(),
						pClass);
				break;
//.........这里部分代码省略.........
开发者ID:Sdw195,项目名称:Transcendence,代码行数:101,代码来源:ShipImageChart.cpp

示例5: ArrangeByRow

void ArrangeByRow (CSymbolTable &Table, SArrangeDesc &Desc, CPaintMap &Map)
	{
	int iNext = 0;
	int y = 0;
	int cyHeader = Desc.pHeader->GetHeight();

	int cxInternalSpacing = 8;
	int cyInternalSpacing = 2 * Desc.pHeader->GetHeight();
	int cyNameSpacing = Desc.pHeader->GetHeight() / 2;

	while (iNext < Table.GetCount())
		{
		int i;
		int cxWidthLeft = Desc.cxDesiredWidth;
		int cyRowHeight = 0;
		int iStart = iNext;

		//	First figure out how many ships will fit
		
		while (iNext < Table.GetCount())
			{
			CShipClass *pClass = (CShipClass *)Table.GetValue(iNext);
			int cxSize = RectWidth(pClass->GetImage().GetImageRect());
			if (cxSize > cxWidthLeft && iStart != iNext)
				break;

			int cxCell = Max(cxSize + cxInternalSpacing, Desc.cxSpacing);

			cxWidthLeft -= cxCell;
			if (cxSize > cyRowHeight)
				cyRowHeight = cxSize;

			iNext++;
			}

		//	Compute the total width

		int cxRowWidth = Min(Desc.cxDesiredWidth - cxWidthLeft, Desc.cxDesiredWidth);
		int xOffset = (Desc.cxDesiredWidth - cxRowWidth) / 2;

		//	See if any of the ships overlap the text from the previous ships
		//	If so, we increase y a little bit

		int x = Desc.cxSpacing + Desc.cxExtraMargin;
		for (i = iStart; i < iNext; i++)
			{
			CShipClass *pClass = (CShipClass *)Table.GetValue(i);
			int cxSize = RectWidth(pClass->GetImage().GetImageRect());
			int yOffset = (cyRowHeight - cxSize) / 2;

			int xPoint = x + xOffset + cxSize / 2;
			int yPoint = y + yOffset;

			for (int j = 0; j < iStart; j++)
				{
				int xText = Map.GetTextX(j);
				int yText = Map.GetTextY(j);
				int cxText = Map.GetTextWidth(j);
				int cyText = Map.GetTextHeight(j) + cyInternalSpacing;

				if (xPoint >= xText && xPoint < xText + cxText && yPoint < yText + cyText)
					y = yText + cyText + cyInternalSpacing;
				}

			int cxCell = Max(cxSize + cxInternalSpacing, Desc.cxSpacing);
			x += cxCell;
			}

		//	Place the ships

		x = Desc.cxSpacing + Desc.cxExtraMargin;
		int yOverlapOffset = 0;
		for (i = iStart; i < iNext; i++)
			{
			CShipClass *pClass = (CShipClass *)Table.GetValue(i);
			int cxSize = RectWidth(pClass->GetImage().GetImageRect());
			int cxCell = Max(cxSize + cxInternalSpacing, Desc.cxSpacing);

			//	Center vertically

			int yOffset = (cyRowHeight - cxSize) / 2;

			//	Place

			Map.Place(i, x + xOffset, y + yOffset, cxSize, cxSize);

			//	Figure out the position of the text

			int cyName;
			int cxName = Desc.pHeader->MeasureText(pClass->GetNounPhrase(0), &cyName);
			if (cxName <= cxSize)
				{
				int yText = y + yOffset + cxSize + cyNameSpacing;
				Map.PlaceText(i,
						x + xOffset + (cxSize - cxName) / 2,
						yText,
						cxName,
						cyName);

				yOverlapOffset = yText + cyName + cyNameSpacing;
//.........这里部分代码省略.........
开发者ID:Sdw195,项目名称:Transcendence,代码行数:101,代码来源:ShipImageChart.cpp


注:本文中的CShipClass::GetImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。