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

📄 npcwnd.cpp

📁 传奇2客户端源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
						}
						else
							nCount++;
					}

					if (nCount)
					{
						if (nLineCnt >= m_nStartLine && nLineCnt <= m_nStartLine + MAX_SHOW_LINE)
							g_xMainWnd.PutsHan(NULL, tRect.left + POS_DRAWSTART_X + nLine, tRect.top + ((nLineCnt - m_nStartLine) * (tSize.cy + LINE_GAP)) + POS_DRAWSTART_Y,
												color, RGB(0, 0, 0), szTempText, hFont);

						nRow++;
						nLine += tSize.cx;
					}

					pScriptLine->m_Rect.bottom	= pScriptLine->m_Rect.top + (nRow * (tSize.cy + LINE_GAP));

				}
				else
				{
					pScriptLine->m_Rect.left	= tRect.left + POS_DRAWSTART_X + nLine;
					pScriptLine->m_Rect.top		= tRect.top + ((nLineCnt - m_nStartLine) * (tSize.cy + LINE_GAP)) + POS_DRAWSTART_Y;
					pScriptLine->m_Rect.right	= pScriptLine->m_Rect.left + tSize.cx;
					pScriptLine->m_Rect.bottom	= pScriptLine->m_Rect.top + tSize.cy;

					if (nLineCnt >= m_nStartLine && nLineCnt <= m_nStartLine + MAX_SHOW_LINE)
						g_xMainWnd.PutsHan(NULL, pScriptLine->m_Rect.left, pScriptLine->m_Rect.top,
											color, RGB(0, 0, 0), pScriptLine->m_pszScriptText, hFont);
				
					nLine += tSize.cx;
				}

				DeleteObject(hFont);
				
				break;
			}
			case SCRIPT_TAG:
			{
				if (strcmp(pScriptLine->m_pszScriptText, "FCOLOR") == 0)
				{
					int nColor = atoi(pScriptLine->m_pszScriptCommand);

					TextColor = ScriptTxtColor[nColor];
				}
				else if (strcmp(pScriptLine->m_pszScriptText, "NPCIMG") == 0)
				{
					if (!m_xNPCImage.m_pbCurrImage)
					{
					//	m_xNPCImage.DeleteImage();

						m_xNPCImage.NewLoad(".\\Data\\NPCFace.WIL", FALSE, TRUE);
					}

					if (m_xNPCImage.NewSetIndex(1))
						g_xMainWnd.DrawWithImageForComp(40, 30, m_xNPCImage.m_lpstNewCurrWilImageInfo->shWidth, 
																m_xNPCImage.m_lpstNewCurrWilImageInfo->shHeight, 
																(WORD *)m_xNPCImage.m_pbCurrImage);

					POS_DRAWSTART_X		= 150;
					MAX_NPCSTR_WIDTH	= 365;
				}

				break;
			}
		}

		ScriptList.MoveNextNode();
	}

	m_nMaxLine = nLineCnt;
}

BOOL CNPCWnd::OnLButtonDown(POINT ptMouse)
{
	CScriptLine*	pScriptLine;

	ScriptList.MoveCurrentToTop();

	for (int i = 0; i < ScriptList.GetCounter(); i++)
	{
		pScriptLine = ScriptList.GetCurrentData();

		if (pScriptLine->m_btScriptType == SCRIPT_BUTTON)
		{
			if (PtInRect(&pScriptLine->m_Rect, ptMouse))
				pScriptLine->m_fIsSelected = TRUE;
			else
				pScriptLine->m_fIsSelected = FALSE;
		}

		ScriptList.MoveNextNode();
	}

	return FALSE;
}

BOOL CNPCWnd::OnLButtonUp(POINT ptMouse)
{
	CScriptLine*	pScriptLine;

	ScriptList.MoveCurrentToTop();

	for (int i = 0; i < ScriptList.GetCounter(); i++)
	{
		pScriptLine = ScriptList.GetCurrentData();

		if (pScriptLine->m_btScriptType == SCRIPT_BUTTON)
		{
			if (PtInRect(&pScriptLine->m_Rect, ptMouse))
			{
				if (pScriptLine->m_pszScriptCommand[0] == '@' && pScriptLine->m_pszScriptCommand[1] == '@')
				{
					if (strcmp(pScriptLine->m_pszScriptCommand, "@@buildguildnow") == 0)
					{
						char szBuildGuild[128];

						sprintf(szBuildGuild, "%s%c%s", pScriptLine->m_pszScriptCommand, 13, "啊力飘屈荤颇");

						g_xClientSocket.SendNPCMessage(CM_MERCHANTDLGSELECT,(DWORD)m_nNpcId, 0, szBuildGuild);
					}
				}
				else
					g_xClientSocket.SendNPCMessage(CM_MERCHANTDLGSELECT,(DWORD)m_nNpcId, 0, pScriptLine->m_pszScriptCommand);
			}
		}

		pScriptLine->m_fIsSelected = FALSE;

		ScriptList.MoveNextNode();
	}

	return FALSE;
}

void CNPCWnd::OnMouseMove(POINT ptMouse)
{
	CScriptLine*	pScriptLine;

	ScriptList.MoveCurrentToTop();

	for (int i = 0; i < ScriptList.GetCounter(); i++)
	{
		pScriptLine = ScriptList.GetCurrentData();

		if (pScriptLine->m_btScriptType == SCRIPT_BUTTON)
		{
			if (PtInRect(&pScriptLine->m_Rect, ptMouse))
				pScriptLine->m_fIsFocused	= TRUE;
			else
				pScriptLine->m_fIsFocused	= FALSE;

		}

		ScriptList.MoveNextNode();
	}
}

void CNPCWnd::ResetDialog()
{
	CScriptLine*	pScriptLine;

	ScriptList.MoveCurrentToTop();

	for (int i = 0; i < ScriptList.GetCounter();)
	{
		pScriptLine = ScriptList.GetCurrentData();

		if (pScriptLine)
			delete pScriptLine;

		ScriptList.DeleteCurrentNodeEx();
	}

	m_nStartLine	= 0;
	m_nMaxLine		= MAX_SHOW_LINE;
}

VOID CNPCWnd::OnScrollDown()
{
	if (m_nMaxLine > MAX_SHOW_LINE)
	{
		if (m_nStartLine <= 0)
			m_nStartLine = 0;
		else
			m_nStartLine--;
	}
}

VOID CNPCWnd::OnScrollUp()
{
	if (m_nMaxLine > MAX_SHOW_LINE)
	{
		if (m_nStartLine >= m_nMaxLine)
			m_nStartLine = m_nMaxLine;
		else
			m_nStartLine++;
	}
}
























//////////////////////////////////////////////////////////////////

BOOL	CNPCWnd::ClickCommandProcess(CMTxtBtn* ClickedBtn)		// 酒贰 俊 乐绰 巴甸 辆钦
{
/*	m_pClickedTxtBtn = ClickedBtn;
	if(ClickedBtn!=NULL)
	{
		if(strcmp(m_xTxtAnalysis.UpperCase(ClickedBtn->Param),BUILD_GUILD)==0)				// 巩颇 汲赋 贸府
		{
			CHAR	szMsg[MAX_PATH];
			HINSTANCE hLib;
			hLib = LoadLibrary("Ats.dll"); // Load Dll
			LoadString(hLib,ASK_MAKE_BIG_GUILD,szMsg,MAX_PATH);	
			FreeLibrary(hLib);
			if(!m_xMsgBox.IsActive())	SetWndRectExtend();
			m_xMsgBox.ShowMessageBox(szMsg,MSG_EDITEXIST|MSG_BTN_OK);	// OK
			SetNpcEditBoxPos();
			// 巩颇 汲赋芒阑 凯绊 巩颇 疙阑 涝仿 罐绰促.
			m_nNpcMsgState = 1;
			return TRUE;
		}
		else if(strcmp(m_xTxtAnalysis.UpperCase(ClickedBtn->Param),GUILD_WAR)==0)			// 巩颇傈里
		{
			CHAR	szMsg[MAX_PATH];
			HINSTANCE hLib;
			hLib = LoadLibrary("Ats.dll"); // Load Dll
			LoadString(hLib,ASK_OTHERSNAME,szMsg,MAX_PATH);	
			FreeLibrary(hLib);
			if(!m_xMsgBox.IsActive())	SetWndRectExtend();
			m_xMsgBox.ShowMessageBox(szMsg,MSG_EDITEXIST|MSG_BTN_OK);	// OK
			SetNpcEditBoxPos();
			// 巩里阑 且 惑措 巩颇甫 涝仿 罐绰促.
			m_nNpcMsgState = 2;
			return TRUE;
		}
		else if(strcmp(m_xTxtAnalysis.UpperCase(ClickedBtn->Param),WITHDRAWAL_CASTLE)==0)	// 己 陛绊俊辑 捣 哗扁
		{
			CHAR	szMsg[MAX_PATH];
			HINSTANCE hLib;
			hLib = LoadLibrary("Ats.dll"); // Load Dll
			LoadString(hLib,ASK_WITHDRAWAL,szMsg,MAX_PATH);	
			FreeLibrary(hLib);
			if(!m_xMsgBox.IsActive())	SetWndRectExtend();
			m_xMsgBox.ShowMessageBox(szMsg,MSG_EDITEXIST|MSG_BTN_OK);	// OK
			SetNpcEditBoxPos();
			// 己 陛绊芒阑 凯绢 哗绢尘 捣阑 涝仿 罐绰促.
			m_nNpcMsgState = 3;
			return TRUE;
		}
		else if(strcmp(m_xTxtAnalysis.UpperCase(ClickedBtn->Param),RECEIPT_CASTLE)==0)		// 己 陛绊俊 捣 持扁
		{
			CHAR	szMsg[MAX_PATH];
			HINSTANCE hLib;
			hLib = LoadLibrary("Ats.dll"); // Load Dll
			LoadString(hLib,ASK_RECEIPT,szMsg,MAX_PATH);	
			FreeLibrary(hLib);
			if(!m_xMsgBox.IsActive())	SetWndRectExtend();
			m_xMsgBox.ShowMessageBox(szMsg,MSG_EDITEXIST|MSG_BTN_OK);	// OK
			SetNpcEditBoxPos();
			// 己 陛绊芒阑 凯绢 持阑 捣 咀荐甫 涝仿 罐绰促.
			m_nNpcMsgState = 4;
			return TRUE;
		}
		else
		{
			m_nNpcMsgState = 0;
			m_pClickedTxtBtn = NULL;
			SendCommandToSrv(ClickedBtn->Param);
		}
	}
//		酒公巴档 贸府 窍瘤 臼澜 */
	return FALSE;
}

BOOL CNPCWnd::SendCommandToSrv(CHAR* szMsg)
{
	// 扁夯 皋矫瘤 贸府
	g_xClientSocket.SendNPCMessage(CM_MERCHANTDLGSELECT,(DWORD)m_nNpcId,0,szMsg);
	return FALSE;
}

VOID CNPCWnd::SetWndRectExtend(VOID)
{
//	m_rectExtended = m_rcWnd;
//	m_rcWnd.left = 0;
//	m_rcWnd.top = 0;
//	m_rcWnd.right = 800;
//	m_rcWnd.bottom = 560;
}

VOID CNPCWnd::SetWndRectReduce(VOID)
{
//	m_rcWnd = m_rectExtended;
}

VOID CNPCWnd::SetNpcEditBoxPos(VOID)
{
	// Edit Box 包访
//	m_rcEditBoxFrame.left = 247;
//	m_rcEditBoxFrame.top = 256;
//	m_rcEditBoxFrame.right = 467;
//	m_rcEditBoxFrame.bottom = 272;
//	MoveWindow(g_xChatEditBox.GetSafehWnd(), g_xMainWnd.m_rcWindow.left + m_rcWnd.left + m_rcEditBoxFrame.left, 
//		g_xMainWnd.m_rcWindow.top + m_rcWnd.top + m_rcEditBoxFrame.top, 
//		m_rcEditBoxFrame.right - m_rcEditBoxFrame.left, 
//		m_rcEditBoxFrame.bottom - m_rcEditBoxFrame.top, TRUE);
//	SetWindowText(g_xChatEditBox.GetSafehWnd(),NULL);
//	g_xChatEditBox.SetLimitText(30);
//	SetFocus(g_xChatEditBox.GetSafehWnd());
//	ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_SHOW);
}

VOID CNPCWnd::OnEnterKeyDown(VOID)
{
	CHAR	szTxt[MAX_PATH];
	ZeroMemory(szTxt,MAX_PATH);
	if(m_xMsgBox.IsActive())
	{
		SetWndRectReduce();
		GetWindowText(g_xChatEditBox.GetSafehWnd(),szTxt,MAX_PATH);
		if(szTxt[0]==NULL)
		{
			strncpy(szTxt,g_xChatEditBox.m_szInputMsg,strlen(g_xChatEditBox.m_szInputMsg));
		}
		// For Editbox to Chatting
		SetFocus(g_xMainWnd.GetSafehWnd());
		ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_HIDE);
		g_xChatEditBox.SetLimitText(90);// 眉泼芒 Limit length 肺 官操绢 霖促.
		MoveWindow(g_xChatEditBox.GetSafehWnd(), g_xMainWnd.m_rcWindow.left+_INPUT_EDITWND_XPOS, 
			g_xMainWnd.m_rcWindow.top+_INPUT_EDITWND_YPOS, _INPUT_EDITWND_WIDTH, _INPUT_EDITWND_HEIGHT, TRUE);
		switch(m_nNpcMsgState)
		{
		case 1:
		case 2:
			// 巩颇 积己
			// 巩里 脚没
			{
				CHAR szMsg[MAX_PATH*2];
				strcpy(szMsg,m_pClickedTxtBtn->Param);
				strcat(szMsg,"/\0");
				strcat(szMsg,szTxt);
				SendCommandToSrv(szMsg);
			break;
			}
		case 3:
		case 4:
			{
			// 己磊陛 茫扁
			// 己磊陛 嘎扁扁
			break;
			}
		}
		g_xChatEditBox.m_szInputMsg[0] = NULL;
		SetWindowText(g_xChatEditBox.GetSafehWnd(),NULL);
		m_xMsgBox.HideMessageBox();
	}
}

BOOL CNPCWnd::OnMsgInputted(VOID)
{
	if(!m_xMsgBox.IsActive())
		return FALSE;
	OnEnterKeyDown();
	return TRUE;
}

⌨️ 快捷键说明

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