⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newstatusbar.cpp

📁 Blood 2全套源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		m_pClientDE->DrawSurfaceToSurfaceTransparent(stTab.hTab, stTab.hIcon, DNULL, x, y, m_hTransColor);
	}

	// If there is a bar, draw the portion of it that should be drawn
	if(stTab.hBar && (nFlags & TAB_INC_BAR))
	{
		DRect	rect;
		DDWORD	width, height;

		m_pClientDE->GetSurfaceDims(stTab.hBar, &width, &height);

		rect.top	= 0;
		rect.left	= 0;
		rect.bottom	= height;
		rect.right	= (int)(width * ((float)stTab.value / (float)stTab.max));
		
		m_pClientDE->DrawSurfaceToSurfaceTransparent(stTab.hTab, stTab.hBar, &rect, stTab.barX, stTab.barY, m_hTransColor);
	}

	// Draw the value if needed
	if(stTab.digits && (nFlags & TAB_INC_VALUE))
	{
		char	*value;
		value = new char[stTab.digits + 1];
		memset(value, 0, stTab.digits + 1);

		m_pStatCursor->SetFont(font);
		m_pStatCursor->SetDest(stTab.hTab);
		m_pStatCursor->SetJustify(stTab.valueJ);
		m_pStatCursor->SetLoc((short)stTab.valueX, (short)stTab.valueY);

		sprintf(value, "%d", stTab.value);
		m_pStatCursor->Draw(value);
		delete value;
		value = 0;
	}
}

//*************************************************************************
//*****	Function:	JustifySurface()
//*****	Details:	Get new coordinates for the surface justification
//*************************************************************************

void CNewStatusBar::JustifySurface(HSURFACE surf, DDWORD just, DDWORD &x, DDWORD &y)
{
	if(!m_pClientDE) return;

	DDWORD	width, height;
	m_pClientDE->GetSurfaceDims(surf, &width, &height);

	switch(just)
	{
		case	STATTAB_JUST_NW:											return;
		case	STATTAB_JUST_N:		x -= (width / 2);						return;
		case	STATTAB_JUST_NE:	x -= width;								return;
		case	STATTAB_JUST_E:		x -= width;			y -= (height / 2);	return;
		case	STATTAB_JUST_SE:	x -= width;			y -= height;		return;
		case	STATTAB_JUST_S:		x -= (width / 2);	y -= height;		return;
		case	STATTAB_JUST_SW:						y -= height;		return;
		case	STATTAB_JUST_W:							y -= (height / 2);	return;
		case	STATTAB_JUST_C:		x -= (width / 2);	y -= (height / 2);	return;
		default:															return;
	}
}

//*************************************************************************
//*****	Function:	DrawStatTabs()
//*****	Details:	Draws the stat tabs at the bottom of the screen
//*************************************************************************

void CNewStatusBar::DrawStatTabs()
{
	if(!m_pClientDE) return;

	HSURFACE hScreen	= m_pClientDE->GetScreenSurface();
	DBYTE nInclude		= m_nStatLevel > STATTAB_LOW ? TAB_INC_HIGH : TAB_INC_LOW;

	// Resetup the tabs if the values have changed
	if(m_stHealth.value != m_nOldHealth || m_nStatLevel != m_nOldStatLevel)
	{
		SetupTab(m_stHealth, m_pStatNumbers1, nInclude);
		m_nOldHealth = m_stHealth.value;
	}

	if(m_stArmor.value != m_nOldArmor || m_nStatLevel != m_nOldStatLevel)
	{
		SetupTab(m_stArmor, m_pStatNumbers1, nInclude);
		m_nOldArmor = m_stArmor.value;
	}

	if(m_stAmmo.value != m_nOldAmmo || m_nStatLevel != m_nOldStatLevel)
	{
		SetupTab(m_stAmmo, m_pStatNumbers1, nInclude);
		m_nOldAmmo = m_stAmmo.value;
	}

	if(m_stAltAmmo.value != m_nOldAltAmmo || m_nStatLevel != m_nOldStatLevel)
	{
		SetupTab(m_stAltAmmo, m_pStatNumbers2, nInclude);
		m_nOldAltAmmo = m_stAltAmmo.value;
	}

	m_nOldStatLevel = m_nStatLevel;

	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_stHealth.hTab, DNULL, m_stHealth.locX, m_stHealth.locY, m_hTransColor);
	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_stArmor.hTab, DNULL, m_stArmor.locX, m_stArmor.locY, m_hTransColor);
	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_stAmmo.hTab, DNULL, m_stAmmo.locX, m_stAmmo.locY, m_hTransColor);

	if(m_stAltAmmo.value)
		m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_stAltAmmo.hTab, DNULL, m_stAltAmmo.locX, m_stAltAmmo.locY, m_hTransColor);

	// Draw the currently selected inventory item along with the normal stats
	if(m_stCurrentItem.hIcon)
	{
		SetupTab(m_stCurrentItem, m_pStatFont1, TAB_INC_HIGH);
		m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_stCurrentItem.hTab, DNULL, m_stCurrentItem.locX, m_stCurrentItem.locY, m_hTransColor);

		if(!m_bHighGraphics)
			m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_hItemName, DNULL, m_nItemNameX, m_nItemNameY, m_hTransColor);
	}
}

//*************************************************************************
//*****	Function:	DrawInvTabs()
//*****	Details:	Draws the three item tabs
//*************************************************************************

void CNewStatusBar::DrawInvTabs()
{
	if(!m_pClientDE) return;

	HSURFACE	hScreen	= m_pClientDE->GetScreenSurface();

	// Handle the scrolling in and out of the inventory item tabs
	switch(m_nInvLevel)
	{
		case	INVTAB_SCROLL_IN:
			if(m_fTime - m_fInvUpdateTime > INVTAB_SCROLL_TIME)
			{
				m_fInvScrollRatio = 1.0f;
				m_nInvLevel = INVTAB_STOPPED;
				m_fInvUpdateTime = m_fTime;
			}
			else
				m_fInvScrollRatio = (m_fTime - m_fInvUpdateTime) / INVTAB_SCROLL_TIME;
			break;

		case	INVTAB_STOPPED:
			if(m_fTime - m_fInvUpdateTime > INVTAB_DISP_TIME)
			{
				m_nInvLevel = INVTAB_SCROLL_OUT;
				m_fInvUpdateTime = m_fTime;
			}
			break;
		case	INVTAB_SCROLL_OUT:
			if(m_fTime - m_fInvUpdateTime > INVTAB_SCROLL_TIME)
			{
				m_fInvScrollRatio = 0.0f;
				m_nInvLevel = INVTAB_INVISIBLE;
				m_fInvUpdateTime = m_fTime;
			}
			else
				m_fInvScrollRatio = 1.0f - (m_fTime - m_fInvUpdateTime) / INVTAB_SCROLL_TIME;

			break;
	}

	// Previous item
	if(m_stItems[0].hIcon)
	{
		DDWORD nNewX = (DDWORD)((m_stItems[0].locX + m_stItems[0].sizeX) * m_fInvScrollRatio) - m_stItems[0].sizeX;
		m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_stItems[0].hTab, DNULL, nNewX, m_stItems[0].locY, m_hTransColor);
	}

	// Current item
	if(m_stItems[1].hIcon)
	{
		DDWORD nNewX = (DDWORD)((m_stItems[1].locX + m_stItems[1].sizeX) * m_fInvScrollRatio) - m_stItems[1].sizeX;

		m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_stItems[1].hTab, DNULL, nNewX, m_stItems[1].locY, m_hTransColor);
		m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_hItemName, DNULL, m_nItemNameX, m_nItemNameY, m_hTransColor);
	}

	// Next item
	if(m_stItems[2].hIcon)
	{
		DDWORD nNewX = (DDWORD)((m_stItems[2].locX + m_stItems[2].sizeX) * m_fInvScrollRatio) - m_stItems[2].sizeX;
		m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_stItems[2].hTab, DNULL, nNewX, m_stItems[2].locY, m_hTransColor);
	}
}

//*************************************************************************
//*****	Function:	DrawWeaponTabs()
//*****	Details:	Draws the ten item slots with weapon icons
//*************************************************************************

void CNewStatusBar::DrawWeaponTabs()
{
	if(!m_pClientDE) return;

	HSURFACE	hScreen	= m_pClientDE->GetScreenSurface();

	// Handle the scrolling in and out of the inventory item tabs
	switch(m_nWeapLevel)
	{
		case	WEAPTAB_SCROLL_IN:
			if(m_fTime - m_fWeapUpdateTime > WEAPTAB_SCROLL_TIME)
			{
				m_fWeapScrollRatio = 1.0f;
				m_nWeapLevel = WEAPTAB_STOPPED;
				m_fWeapUpdateTime = m_fTime;
			}
			else
				m_fWeapScrollRatio = (m_fTime - m_fWeapUpdateTime) / WEAPTAB_SCROLL_TIME;
			break;

		case	WEAPTAB_STOPPED:
			break;

		case	WEAPTAB_SCROLL_OUT:
			if(m_fTime - m_fWeapUpdateTime > WEAPTAB_SCROLL_TIME)
			{
				m_fWeapScrollRatio = 0.0f;
				m_nWeapLevel = WEAPTAB_INVISIBLE;
				m_fWeapUpdateTime = m_fTime;
			}
			else
				m_fWeapScrollRatio = 1.0f - (m_fTime - m_fWeapUpdateTime) / WEAPTAB_SCROLL_TIME;

			break;
	}

	DDWORD nNewX = (DDWORD)(m_stWeapons[0].sizeX - (m_stWeapons[0].sizeX * m_fWeapScrollRatio)) + m_stWeapons[0].locX;

	for(int i = 0; i < 10; i++)
		m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_stWeapons[i].hTab, DNULL, nNewX, m_stWeapons[i].locY, m_hTransColor);
}

//*************************************************************************
//*****	Function:	DrawObjectives()
//*****	Details:	Draws the objectives tab
//*************************************************************************

void CNewStatusBar::DrawObjectives()
{
	if(!m_pClientDE) return;

	HSURFACE	hScreen	= m_pClientDE->GetScreenSurface();
	DDWORD		width, height;
	DDWORD		halfWidth, halfHeight;
	DBYTE		scaleIndex = 0;

	m_pClientDE->GetSurfaceDims(m_hObjectives, &width, &height);
	halfWidth = width / 2;
	halfHeight = height / 2;

	// Handle the scrolling in and out of the inventory item tabs
	switch(m_nObjLevel)
	{
		case	OBJTAB_SCALE_UP:
			if(m_fTime - m_fObjUpdateTime > OBJTAB_SCALE_TIME)
			{
				m_fObjScaleRatio = 1.0f;
				m_nObjLevel = OBJTAB_STOPPED;
				m_fObjUpdateTime = m_fTime;
			}
			else
				m_fObjScaleRatio = (m_fTime - m_fObjUpdateTime) / OBJTAB_SCALE_TIME;

			// Scale the rectangle accordingly...
			scaleIndex = (DBYTE)(m_fObjScaleRatio * OBJTAB_SCALE_LEVELS);
			m_rObjectives.top		= (int)(m_nObjectivesY + (halfHeight * (1.0f - g_ObjScaleUpY[scaleIndex])));
			m_rObjectives.left		= (int)(m_nObjectivesX + (halfWidth * (1.0f - g_ObjScaleUpX[scaleIndex])));
			m_rObjectives.bottom	= (int)(m_nObjectivesY + halfHeight + (halfHeight * g_ObjScaleUpY[scaleIndex]));
			m_rObjectives.right		= (int)(m_nObjectivesX + halfWidth + (halfWidth * g_ObjScaleUpX[scaleIndex]));
			break;

		case	OBJTAB_STOPPED:
			// Scale the rectangle accordingly...
			m_rObjectives.top		= m_nObjectivesY;
			m_rObjectives.left		= m_nObjectivesX;
			m_rObjectives.bottom	= m_nObjectivesY + height;
			m_rObjectives.right		= m_nObjectivesX + width;
			break;

		case	OBJTAB_SCALE_DOWN:
			if(m_fTime - m_fObjUpdateTime > OBJTAB_SCALE_TIME)
			{
				m_fObjScaleRatio = 1.0f;
				m_nObjLevel = INVTAB_INVISIBLE;
				m_fObjUpdateTime = m_fTime;
			}
			else
				m_fObjScaleRatio = (m_fTime - m_fObjUpdateTime) / OBJTAB_SCALE_TIME;

			// Scale the rectangle accordingly...
			scaleIndex = (DBYTE)(m_fObjScaleRatio * OBJTAB_SCALE_LEVELS);
			m_rObjectives.top		= (int)(m_nObjectivesY + (halfHeight * (1.0f - g_ObjScaleDownY[scaleIndex])));
			m_rObjectives.left		= (int)(m_nObjectivesX + (halfWidth * (1.0f - g_ObjScaleDownX[scaleIndex])));
			m_rObjectives.bottom	= (int)(m_nObjectivesY + halfHeight + (halfHeight * g_ObjScaleDownY[scaleIndex]));
			m_rObjectives.right		= (int)(m_nObjectivesX + halfWidth + (halfWidth * g_ObjScaleDownX[scaleIndex]));
			break;
	}

	m_pClientDE->ScaleSurfaceToSurfaceTransparent(hScreen, m_hObjectives, &m_rObjectives, DNULL, m_hTransColor);
}

//*************************************************************************
//*****	Function:	DrawObjectivesIcon()
//*****	Details:	Draws the objectives tab
//*************************************************************************

void CNewStatusBar::DrawObjectivesIcon()
{
	if(!m_pClientDE) return;

	HSURFACE	hScreen	= m_pClientDE->GetScreenSurface();
	DDWORD		width, height;
	DDWORD		width2;

	m_pClientDE->GetSurfaceDims(hScreen, &width, &height);
	m_pClientDE->GetSurfaceDims(m_hObjectivesIcon, &width2, &height);
	width = width - width2 - 5;
	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_hObjectivesIcon, DNULL, width, 5, m_hTransColor);
}

//*************************************************************************
//*****	Function:	DrawPowerBar()
//*****	Details:	Draws the power bar
//*************************************************************************

void CNewStatusBar::DrawPowerBar()
{
	if(!m_pClientDE) return;

	HSURFACE	hScreen	= m_pClientDE->GetScreenSurface();

	if(m_fTime - m_fPowerBarUpdate > BARTAB_DISP_TIME)
		m_nPowerBar = BARTAB_NONE;

	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_hPowerBar, DNULL, m_nPowerBarX, m_nPowerBarY, m_hTransColor);
}

//*************************************************************************
//*****	Function:	DrawFlagIcon()
//*****	Details:	Draws the multiplayer flag icon
//*************************************************************************

void CNewStatusBar::DrawFlagIcon()
{
	if(!m_pClientDE) return;
	if (!g_pBloodClientShell->IsMultiplayerTeamBasedGame()) return;

	HSURFACE hScreen = m_pClientDE->GetScreenSurface();
	if (!hScreen) return;

	DDWORD		width, height;
	DDWORD		width2;

	m_pClientDE->GetSurfaceDims(hScreen, &width, &height);
	m_pClientDE->GetSurfaceDims(m_hFlagIcon, &width2, &height);
	width = width - width2 - 5;
	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_hFlagIcon, DNULL, width, m_nTeamIconHeight + 10, m_hTransColor);
}

//*************************************************************************
//*****	Function:	DrawTeamIcon()
//*****	Details:	Draws the multiplayer team icon
//*************************************************************************

void CNewStatusBar::DrawTeamIcon()
{
	if (!m_hTeamIcon) return;
	if (!m_pClientDE) return;
	if (!g_pBloodClientShell->IsMultiplayerTeamBasedGame()) return;

	HSURFACE hScreen = m_pClientDE->GetScreenSurface();
	if (!hScreen) return;

	DDWORD		width, height;
	DDWORD		width2;

	m_pClientDE->GetSurfaceDims(hScreen, &width, &height);
	m_pClientDE->GetSurfaceDims(m_hTeamIcon, &width2, &height);
	width = width - width2 - 5;
	m_nTeamIconHeight = height;
	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_hTeamIcon, DNULL, width, 5, m_hTransColor);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -