Пример #1
0
void CUIHelper::CreateClassInfoReactor (CShipClass *pClass, const CDeviceDescList &Devices, int x, int y, int cxWidth, DWORD dwOptions, int *retcyHeight, IAnimatron **retpInfo) const

//	CreateClassInfoReactor
//
//	Creates info about the ship class' reactor

	{
	const CVisualPalette &VI = m_HI.GetVisuals();

	//	Get reactor info from the ship class

	const ReactorDesc *pReactorDesc = pClass->GetReactorDesc();
	if (pReactorDesc == NULL)
		{
		if (retcyHeight)
			*retcyHeight = 0;

		CAniSequencer::Create(CVector(x, y), (CAniSequencer **)retpInfo);
		return;
		}

	CDeviceClass *pReactor = Devices.GetNamedDevice(devReactor);
	if (pReactor)
		pReactorDesc = pReactor->GetReactorDesc();

	//	Get the icon (OK if this is NULL)

	CItemType *pItemIcon = (pReactor ? pReactor->GetItemType() : g_pUniverse->FindItemType(NOVA25_REACTOR_UNID));

	//	Create the info

	CString sText = strPatternSubst(CONSTLIT("{/rtf {/f:LargeBold;/c:%d; %s} {/f:MediumBold;/c:%d; %s}}"),
			CG16bitImage::RGBFromPixel(VI.GetColor(colorTextDialogLabel)),
			CTextBlock::Escape(ReactorPower2String(pReactorDesc->iMaxPower)),
			CG16bitImage::RGBFromPixel(VI.GetColor(colorTextDialogInput)),
			(pReactor ? CTextBlock::Escape(pReactor->GetItemType()->GetNounPhrase()) : strPatternSubst(CONSTLIT("%s reactor"), CTextBlock::Escape(pClass->GetShortName()))));

	CreateClassInfoSpecialItem(pItemIcon, sText, x, y, cxWidth, dwOptions, retcyHeight, retpInfo);
	}
Пример #2
0
void CReactorDisplay::Update (void)

//	Update
//
//	Updates the buffer from data

	{
	if (m_pPlayer == NULL)
		return;

	CShip *pShip = m_pPlayer->GetShip();
	const CPlayerSettings *pSettings = pShip->GetClass()->GetPlayerSettings();
	const SReactorImageDesc &ReactorDesc = pSettings->GetReactorDesc();

	int yOffset = (RectHeight(m_rcRect) - RectHeight(ReactorDesc.ReactorImage.GetImageRect())) / 2;

	//	Paint the background

	ReactorDesc.ReactorImage.PaintImageUL(m_Buffer, 0, yOffset, 0, 0);

	//	Calculate fuel values

	int iFuelLeft = pShip->GetFuelLeft();
	int iMaxFuel = pShip->GetMaxFuel();
	int iFuelLevel = (iMaxFuel > 0 ? (Min((iFuelLeft * 100 / iMaxFuel) + 1, 100)) : 0);

	//	Paint the fuel level

	CG16bitImage *pFuelImage = NULL;
	RECT rcSrcRect;
	bool bBlink;
	if (iFuelLevel < 15)
		{
		pFuelImage = &ReactorDesc.FuelLowLevelImage.GetImage(NULL_STR);
		rcSrcRect = ReactorDesc.FuelLowLevelImage.GetImageRect();
		bBlink = true;
		}
	else
		{
		pFuelImage = &ReactorDesc.FuelLevelImage.GetImage(NULL_STR);
		rcSrcRect = ReactorDesc.FuelLevelImage.GetImageRect();
		bBlink = false;
		}

	if (!bBlink || ((m_iTickCount % 2) == 0))
		{
		int cxFuelLevel = RectWidth(rcSrcRect) * iFuelLevel / 100;
		m_Buffer.ColorTransBlt(rcSrcRect.left,
				rcSrcRect.top,
				cxFuelLevel,
				RectHeight(rcSrcRect),
				255,
				*pFuelImage,
				ReactorDesc.xFuelLevelImage,
				yOffset + ReactorDesc.yFuelLevelImage);
		}

	//	Paint fuel level text

	m_Buffer.Fill(ReactorDesc.rcFuelLevelText.left,
			yOffset + ReactorDesc.rcFuelLevelText.top,
			RectWidth(ReactorDesc.rcFuelLevelText),
			RectHeight(ReactorDesc.rcFuelLevelText),
			DEFAULT_TRANSPARENT_COLOR);

	CString sFuelLevel = strPatternSubst(CONSTLIT("fuel"));
	int cxWidth = m_pFonts->Small.MeasureText(sFuelLevel);
	m_pFonts->Small.DrawText(m_Buffer,
			ReactorDesc.rcFuelLevelText.left,
			yOffset + ReactorDesc.rcFuelLevelText.top,
			m_pFonts->wHelpColor,
			sFuelLevel,
			0);

	//	Calculate the power level

	int iPowerUsage = pShip->GetPowerConsumption();
	int iMaxPower = pShip->GetMaxPower();
	int iPowerLevel;
	if (iMaxPower)
		iPowerLevel = Min((iPowerUsage * 100 / iMaxPower) + 1, 120);
	else
		iPowerLevel = 0;

	if (iPowerLevel >= 100)
		m_iOverloading++;
	else
		m_iOverloading = 0;

	bBlink = (m_iOverloading > 0);

	//	Paint the power level

	if (!bBlink || ((m_iOverloading % 2) == 1))
		{
		CG16bitImage *pPowerImage = &ReactorDesc.PowerLevelImage.GetImage(NULL_STR);
		rcSrcRect = ReactorDesc.PowerLevelImage.GetImageRect();
		int cxPowerLevel = RectWidth(rcSrcRect) * iPowerLevel / 120;
		m_Buffer.ColorTransBlt(rcSrcRect.left,
				rcSrcRect.top,
				cxPowerLevel,
				RectHeight(rcSrcRect),
				255,
				*pPowerImage,
				ReactorDesc.xPowerLevelImage,
				yOffset + ReactorDesc.yPowerLevelImage);
		}

	//	Paint power level text

	m_Buffer.Fill(ReactorDesc.rcPowerLevelText.left,
			yOffset + ReactorDesc.rcPowerLevelText.top,
			RectWidth(ReactorDesc.rcPowerLevelText),
			RectHeight(ReactorDesc.rcPowerLevelText),
			DEFAULT_TRANSPARENT_COLOR);

	CString sPowerLevel = strPatternSubst(CONSTLIT("power usage"));
	int cyHeight;
	cxWidth = m_pFonts->Small.MeasureText(sPowerLevel, &cyHeight);
	m_pFonts->Small.DrawText(m_Buffer,
			ReactorDesc.rcPowerLevelText.left,
			yOffset + ReactorDesc.rcPowerLevelText.bottom - cyHeight,
			m_pFonts->wHelpColor,
			sPowerLevel,
			0);

	//	Paint the reactor name (we paint on top of the levels)

	WORD wColor;
	if (pShip->GetReactorDesc()->fDamaged)
		wColor = DAMAGED_TEXT_COLOR;
	else
		wColor = m_pFonts->wTitleColor;

	CString sReactorName = strPatternSubst(CONSTLIT("%s (%s)"), 
			pShip->GetReactorName(),
			ReactorPower2String(iMaxPower));

	m_pFonts->Medium.DrawText(m_Buffer,
			ReactorDesc.rcReactorText.left,
			yOffset + ReactorDesc.rcReactorText.top,
			wColor,
			sReactorName,
			0);

	m_iTickCount++;
	}