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

📄 menu.cpp

📁 Blood 2全套源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	HDECOLOR	red = m_pClientDE->SetupColor2 (0.596f, 0.031f, 0.094f, DFALSE);
	HDECOLOR	black = m_pClientDE->SetupColor1 (0.0f, 0.0f, 0.0f, DFALSE);

	DDWORD		nWidth = 0, nHeight = 0;
	m_pClientDE->GetSurfaceDims(hScreen, &nWidth, &nHeight);
	int			x = nWidth;
	int			y = nHeight;
	DFLOAT		xRatio = (DFLOAT)nWidth / 640.0f;
	DFLOAT		yRatio = (DFLOAT)nHeight / 480.0f;

	int			nSpacing = m_pMenuCursor->GetHeight() * 2;
	int			nCount = 0;
//	int			y = (int)((MENU_TOP + MENU_HEIGHT - FONT_HEIGHT) * yRatio);
//	int			x = (int)(MENU_LEFT * xRatio);

	// Text menu, draw the text items
	m_pClientDE->ScaleSurfaceToSurface (hScreen, m_hDimBack, NULL, NULL);
//	m_pClientDE->DrawSurfaceToSurface(hScreen, m_hDimBack, NULL, 0, 0);
	// TODO: Replace this title with "NEW GAME" - GK 8/21/98
	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_hCustomTitle, NULL, (int)(MENU_TITLE_X * xRatio), (int)(MENU_TITLE_Y * yRatio), transColor);
	m_pMenuCursor->SetDest(hScreen);
	m_pMenuCursor->SetJustify(CF_JUSTIFY_CENTER);

	do
	{
		m_pMenuCursor->SetLoc((short)x >> 1, ((short)y >> 1) - (m_pMenuCursor->GetHeight() >> 1));

//		m_pMenuCursor->SetLoc(x, y);
		m_pMenuCursor->DrawSolid(m_pClientDE->GetStringData(pItem->hString), 3, 3, black);
		if(m_pCurrentItem == pItem)
			m_pMenuCursor->DrawSolid(m_pClientDE->GetStringData(pItem->hString), red);
		else
			m_pMenuCursor->DrawSolid(m_pClientDE->GetStringData(pItem->hString), white);

		y -= nSpacing;
		pItem = pItem->pPrev;
	} while (pItem != m_pCurrentItem->pTop->pPrev);
}

//***************************************************************************
//*****		Function:	DrawSaveGameMenu(HSURFACE hScreen)
//*****		Details:	Draws the save game screen
//***************************************************************************

void	CMenu::DrawSaveGameMenu(HSURFACE hScreen)
{
	MENUITEM	*pItem = m_pCurrentItem->pTop->pPrev;
	HDECOLOR	transColor = m_pClientDE->SetupColor1(1.0f, 0.0f, 1.0f, DFALSE);
	HDECOLOR	white = m_pClientDE->SetupColor1(1.0f, 1.0f, 1.0f, DFALSE);
	HDECOLOR	red = m_pClientDE->SetupColor2 (0.596f, 0.031f, 0.094f, DFALSE);
	HDECOLOR	black = m_pClientDE->SetupColor1 (0.0f, 0.0f, 0.0f, DFALSE);

	DDWORD		nWidth = 0, nHeight = 0;
	m_pClientDE->GetSurfaceDims(hScreen, &nWidth, &nHeight);
	DFLOAT		xRatio = (DFLOAT)nWidth / 640.0f;
	DFLOAT		yRatio = (DFLOAT)nHeight / 480.0f;

	int			nSpacing = m_pMenuCursor->GetHeight();
	int			nCount = 0;
	int			y = (int)((MENU_TOP + MENU_HEIGHT - FONT_HEIGHT) * yRatio);
	int			x = (int)(MENU_LEFT * xRatio);

	// Text menu, draw the text items
	m_pClientDE->ScaleSurfaceToSurface (hScreen, m_hDimBack, NULL, NULL);
//	m_pClientDE->DrawSurfaceToSurface(hScreen, m_hDimBack, NULL, 0, 0);
	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_hSaveTitle, NULL, (int)(MENU_TITLE_X * xRatio), (int)(MENU_TITLE_Y * yRatio), transColor);
	m_pMenuCursor->SetDest(hScreen);
	m_pMenuCursor->SetJustify(CF_JUSTIFY_LEFT);

	char szMenuText[125];
	do
	{
		_mbscpy((unsigned char*)szMenuText, (const unsigned char*)m_pClientDE->GetStringData(pItem->hString));

		// Get additional menu item text, if available
		CSavedGameInfo *pSGInfo = DNULL;
		if (g_pBloodClientShell && (pSGInfo = g_pBloodClientShell->GetSavedGameInfo()))
		{
			if (pItem->nID >= ID_SAVEGAME && pItem->nID <= ID_SAVESLOT9)
			{
				_mbscat((unsigned char*)szMenuText, (const unsigned char*)pSGInfo->gSaveSlotInfo[pItem->nID - ID_SAVEGAME].szName);
			}
		}

		m_pMenuCursor->SetLoc(x, y);
		m_pMenuCursor->DrawSolid(szMenuText, 3, 3, black);
		if(m_pCurrentItem == pItem)
			m_pMenuCursor->DrawSolid(szMenuText, red);
		else
			m_pMenuCursor->DrawSolid(szMenuText, white);

		y -= nSpacing;
		pItem = pItem->pPrev;
	} while (pItem != m_pCurrentItem->pTop->pPrev);
}

//***************************************************************************
//*****		Function:	DrawLoadGameMenu(HSURFACE hScreen)
//*****		Details:	Draws the load game selection screen
//***************************************************************************

void	CMenu::DrawLoadGameMenu(HSURFACE hScreen)
{
	MENUITEM	*pItem = m_pCurrentItem->pTop->pPrev;
	HDECOLOR	transColor = m_pClientDE->SetupColor1(1.0f, 0.0f, 1.0f, DFALSE);
	HDECOLOR	white = m_pClientDE->SetupColor1(1.0f, 1.0f, 1.0f, DFALSE);
	HDECOLOR	red = m_pClientDE->SetupColor2 (0.596f, 0.031f, 0.094f, DFALSE);
	HDECOLOR	black = m_pClientDE->SetupColor1 (0.0f, 0.0f, 0.0f, DFALSE);

	DDWORD		nWidth = 0, nHeight = 0;
	m_pClientDE->GetSurfaceDims(hScreen, &nWidth, &nHeight);
	DFLOAT		xRatio = (DFLOAT)nWidth / 640.0f;
	DFLOAT		yRatio = (DFLOAT)nHeight / 480.0f;

	int			nSpacing = m_pMenuCursor->GetHeight();
	int			nCount = 0;
	int			y = (int)((MENU_TOP + MENU_HEIGHT - FONT_HEIGHT) * yRatio);
	int			x = (int)(MENU_LEFT * xRatio);

	// Text menu, draw the text items
	m_pClientDE->ScaleSurfaceToSurface (hScreen, m_hDimBack, NULL, NULL);
//	m_pClientDE->DrawSurfaceToSurface(hScreen, m_hDimBack, NULL, 0, 0);
	m_pClientDE->DrawSurfaceToSurfaceTransparent(hScreen, m_hLoadTitle, NULL, (int)(MENU_TITLE_X * xRatio), (int)(MENU_TITLE_Y * yRatio), transColor);
	m_pMenuCursor->SetDest(hScreen);
	m_pMenuCursor->SetJustify(CF_JUSTIFY_LEFT);

	char szMenuText[125];
	do
	{
		_mbscpy((unsigned char*)szMenuText, (const unsigned char*)m_pClientDE->GetStringData(pItem->hString));

		// Get additional menu item text, if available
		CSavedGameInfo *pSGInfo = DNULL;
		if (g_pBloodClientShell && (pSGInfo = g_pBloodClientShell->GetSavedGameInfo()))
		{
			if (pItem->nID == ID_LOADAUTOSAVE)	// Get current world name
			{
				_mbscat((unsigned char*)szMenuText, (const unsigned char*)pSGInfo->gCurrentSaveInfo.szName);
			}
			else if (pItem->nID == ID_LOADQUICKSAVE)
			{
				_mbscat((unsigned char*)szMenuText, (const unsigned char*)pSGInfo->gQuickSaveInfo.szName);
			}
			else if (pItem->nID >= ID_LOADSLOT0 && pItem->nID <= ID_LOADSLOT9)
			{
				_mbscat((unsigned char*)szMenuText, (const unsigned char*)pSGInfo->gSaveSlotInfo[pItem->nID - ID_LOADSLOT0].szName);
			}
		}

		m_pMenuCursor->SetLoc(x, y);
		m_pMenuCursor->DrawSolid(szMenuText, 3, 3, black);
		if(m_pCurrentItem == pItem)
			m_pMenuCursor->DrawSolid(szMenuText, red);
		else
			m_pMenuCursor->DrawSolid(szMenuText, white);

		y -= nSpacing;
		pItem = pItem->pPrev;
	} while (pItem != m_pCurrentItem->pTop->pPrev);
}

//***************************************************************************
//*****		Function:	DrawOptions(HSURFACE hScreen)
//*****		Details:	Draws the options screen
//***************************************************************************

void	CMenu::DrawOptions(HSURFACE hScreen)
{
	HDECOLOR	white = m_pClientDE->SetupColor1(1.0f, 1.0f, 1.0f, DFALSE);
	HDECOLOR	red = m_pClientDE->SetupColor2 (0.596f, 0.031f, 0.094f, DFALSE);
	HDECOLOR	black = m_pClientDE->SetupColor1 (0.0f, 0.0f, 0.0f, DFALSE);
	DDWORD		x, y;
	short		i, max;
	char		*string1, *string2, tempString[50];
	OPTIONITEM	*op;
	DRect		rect;

	m_pClientDE->GetSurfaceDims(hScreen, &x, &y);
	m_pClientDE->ScaleSurfaceToSurface (hScreen, m_hDimBack, NULL, NULL);
//	m_pClientDE->DrawSurfaceToSurface (hScreen, m_hDimBack, NULL, 0, 0);
	m_pMenuCursor->SetDest(hScreen);

	m_pMenuCursor->SetJustify(CF_JUSTIFY_CENTER);
	m_pMenuCursor->SetLoc((short)x >> 1, (short)y - m_pMenuCursor->GetHeight() * 2);
	m_pMenuCursor->DrawSolid("*** NOTE: These menus are currently under construction! ***", white);
	m_pMenuCursor->NewLine();
	m_pMenuCursor->DrawSolid("*** Not all options are functional ***", white);

	if((m_bOSInputMode == 1) && (m_bOptionsOn == 2))
	{
		DDWORD	i, size = MAX_INPUT_BUFFER_SIZE;
		m_pClientDE->TrackDevice(m_pInput, &size);
		for(i = 0; i < size; i++)
		{
			if(m_pInput[i].m_InputValue)
			{
				m_pClientDE->PlaySoundLocal("sounds/interface/MenuSwitch3.wav", NULL, SOUNDPRIORITY_MISC_HIGH);

				m_gGotKeyPress = 1;
				m_gKeyPressTime = m_pClientDE->GetTime();
				if(_mbsicmp((const unsigned char*)m_pInput[i].m_ControlName, (const unsigned char*)"Escape") == 0)
				{
					m_pOSSubItems[m_bOSCategory][m_bOSSubItem].num1 = 0;
					memset(m_pOSSubItems[m_bOSCategory][m_bOSSubItem].extra, 0, 64);
				}
				else
				{
					m_pOSSubItems[m_bOSCategory][m_bOSSubItem].num1 = (short)m_pInput[i].m_InputValue;
					_mbscpy((unsigned char*)m_pOSSubItems[m_bOSCategory][m_bOSSubItem].extra, (const unsigned char*)m_pInput[i].m_ControlName);
				}

				if(_mbsicmp((const unsigned char*)m_pInput[i].m_ControlName, (const unsigned char*)"Left Alt") == 0)
				{
//					m_bOSInputMode = 0;
					m_gGotKeyPress = 0;
				}
				else if(_mbsicmp((const unsigned char*)m_pInput[i].m_ControlName, (const unsigned char*)"Right Alt") == 0)
				{
//					m_bOSInputMode = 0;
					m_gGotKeyPress = 0;
				}

				m_bOSInputMode = 0;
				m_pClientDE->EndDeviceTrack();
				break;
			}
		}
	}

	if(m_bOSInputMode == 2)
	{
		m_pMenuCursor->SetJustify(CF_JUSTIFY_CENTER);
		m_pMenuCursor->SetLoc((short)x >> 1, ((short)y >> 1) - (m_pMenuCursor->GetHeight() >> 1));
		m_pMenuCursor->DrawSolid(m_szOSInputString, white);
		return;
	}

	if(m_bOptionsOn == 1)
	{
		m_pMenuCursor->SetJustify(CF_JUSTIFY_CENTER);
		m_pMenuCursor->SetLoc((short)x >> 1, ((short)y >> 1) - ((m_pMenuCursor->GetHeight() * 14) >> 1));
		for(char i = 0; i < OS_NUM_CATEGORIES; i++)
		{
			m_pMenuCursor->DrawSolid(m_pOSCategory[i].string1, 3, 3, black);

			if(i == m_bOSCategory)
				m_pMenuCursor->DrawSolid(m_pOSCategory[i].string1, red);
			else
				m_pMenuCursor->DrawSolid(m_pOSCategory[i].string1, white);

			m_pMenuCursor->NewLine();
		}
	}
	else
	{
		if(m_pOSCategory[m_bOSCategory].num1 < 14)
		{
			m_pMenuCursor->SetLoc((short)x >> 1, ((short)y >> 1) - ((m_pMenuCursor->GetHeight() * m_pOSCategory[m_bOSCategory].num1) >> 1));
			max = m_pOSCategory[m_bOSCategory].num1;
		}
		else
		{
			m_pMenuCursor->SetLoc((short)x >> 1, ((short)y >> 1) - ((m_pMenuCursor->GetHeight() * 14) >> 1));
			max = 14;
		}

		for(i = m_bOSTopSubItem; i < m_bOSTopSubItem + max; i++)
		{
			op = &(m_pOSSubItems[m_bOSCategory][i]);
			switch(op->type)
			{
				case	1:		// Title / File
					m_pMenuCursor->SetJustify(CF_JUSTIFY_CENTER);
					string1 = op->string1;
					m_pMenuCursor->DrawSolid(string1, 3, 3, black);
					if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid(string1, red);
						else				m_pMenuCursor->DrawSolid(string1, white);
					break;
				case	2:		// Slider
					m_pMenuCursor->SetJustify(CF_JUSTIFY_LEFT);
					string1 = op->string1;
					m_pMenuCursor->DrawSolid(string1, -147, 3, black);
					if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid(string1, -150, 0, red);
						else				m_pMenuCursor->DrawSolid(string1, -150, 0, white);

					rect.top = m_pMenuCursor->GetY() + (m_pMenuCursor->GetHeight() >> 1) - 1;
					rect.bottom = rect.top + 2;
					rect.left = m_pMenuCursor->GetX();
					rect.right = rect.left + 150;
					m_pClientDE->FillRect(hScreen, &rect, white);

					rect.top = m_pMenuCursor->GetY() + 1;
					rect.bottom = rect.top + m_pMenuCursor->GetHeight() - 2;
					rect.left = m_pMenuCursor->GetX() + ((140 / op->num2) * op->num1);
					rect.right = rect.left + 10;

					if(i == m_bOSSubItem)
						m_pClientDE->FillRect(hScreen, &rect, red);
					else
						m_pClientDE->FillRect(hScreen, &rect, white);
					break;
				case	3:		// Toggle / T or F
					m_pMenuCursor->SetJustify(CF_JUSTIFY_LEFT);
					string1 = op->string1;
					m_pMenuCursor->DrawSolid(string1, -147, 3, black);
					if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid(string1, -150, 0, red);
						else				m_pMenuCursor->DrawSolid(string1, -150, 0, white);

					m_pMenuCursor->SetJustify(CF_JUSTIFY_RIGHT);
					if(op->num1)
					{
						m_pMenuCursor->DrawSolid("ON", 153, 3, black);
						if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid("ON", 150, 0, red);
							else				m_pMenuCursor->DrawSolid("ON", 150, 0, white);
					}
					else
					{
						m_pMenuCursor->DrawSolid("OFF", 153, 3, black);
						if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid("OFF", 150, 0, red);
							else				m_pMenuCursor->DrawSolid("OFF", 150, 0, white);
					}
					break;
				case	4:		// Value range
				case	6:
					m_pMenuCursor->SetJustify(CF_JUSTIFY_LEFT);
					string1 = op->string1;
					m_pMenuCursor->DrawSolid(string1, -147, 3, black);
					if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid(string1, -150, 0, red);
						else				m_pMenuCursor->DrawSolid(string1, -150, 0, white);

					m_pMenuCursor->SetJustify(CF_JUSTIFY_RIGHT);
					itoa(op->num1, tempString, 10);
					if((m_bOSInputMode == 1) && (i == m_bOSSubItem))
					{
						m_pMenuCursor->DrawSolid("_\0", 153, 3, black);
						m_pMenuCursor->DrawSolid("_\0", 150, 0, red);
					}
					else if(!op->num1)
					{
						m_pMenuCursor->DrawSolid("NA", 153, 3, black);
						if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid("NA", 150, 0, red);
							else				m_pMenuCursor->DrawSolid("NA", 150, 0, white);
					}
					else
					{
						if(op->type == 6)
						{
							string1 = op->extra;
							m_pMenuCursor->DrawSolid(string1, 153, 3, black);
							if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid(string1, 150, 0, red);
								else				m_pMenuCursor->DrawSolid(string1, 150, 0, white);
						}
						else
						{
							m_pMenuCursor->DrawSolid(tempString, 153, 3, black);
							if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid(tempString, 150, 0, red);
								else				m_pMenuCursor->DrawSolid(tempString, 150, 0, white);
						}
					}
					break;
				case	5:		// Text represented by a value
					m_pMenuCursor->SetJustify(CF_JUSTIFY_LEFT);
					string1 = op->string1;
					m_pMenuCursor->DrawSolid(string1, -147, 3, black);
					if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid(string1, -150, 0, red);
						else				m_pMenuCursor->DrawSolid(string1, -150, 0, white);

					m_pMenuCursor->SetJustify(CF_JUSTIFY_RIGHT);

					if(op->string2)
					{
						string1 = op->string2[op->num1];
						m_pMenuCursor->DrawSolid(string1, 153, 3, black);
						if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid(string1, 150, 0, red);
							else				m_pMenuCursor->DrawSolid(string1, 150, 0, white);
					}
					else
					{
						RMode	*modeIndex = m_pRModes;
						char	i, tempStr1[250], tempStr2[15];

						for(i = 0; i < op->num1; i++)		modeIndex = modeIndex->m_pNext;
						itoa(modeIndex->m_Width, tempStr1, 10);
						itoa(modeIndex->m_Height, tempStr2, 10);
						for(i = 9; i > 0; i--)		tempStr2[i] = tempStr2[i - 1];
						tempStr2[0] = 'x';
						_mbscat((unsigned char*)tempStr1, (const unsigned char*)tempStr2);
						itoa(modeIndex->m_BitDepth, tempStr2, 10);
						for(i = 9; i > 0; i--)		tempStr2[i] = tempStr2[i - 1];
						tempStr2[0] = 'x';
						_mbscat((unsigned char*)tempStr1, (const unsigned char*)tempStr2);

						m_pMenuCursor->DrawSolid(tempStr1, 153, 3, black);
						if(i == m_bOSSubItem)	m_pMenuCursor->DrawSolid(tempStr1, 150, 0, red);
							else				m_pMenuCursor->DrawSol

⌨️ 快捷键说明

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