Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
203 lines
6.4 KiB
C++
203 lines
6.4 KiB
C++
// HumanChannel.cpp: implementation of the CHumanChannel class.
|
||
//
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
#include "ClientMain.h"
|
||
#include "WinInput.h"
|
||
#include "HumanChannel.h"
|
||
#include "GUITextEdit.h"
|
||
|
||
#include "GUIMessageBox.h"
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Construction/Destruction
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
CHumanChannel::CHumanChannel()
|
||
{
|
||
|
||
}
|
||
|
||
CHumanChannel::~CHumanChannel()
|
||
{
|
||
|
||
}
|
||
|
||
BOOL CHumanChannel::Init(unsigned short x, unsigned short y)
|
||
{
|
||
CSprite *lpSprite;
|
||
lpSprite = new CSprite;
|
||
lpSprite->Create(x, y, 0, 0, 256, 256, g_ClientMain.m_lpInterface->m_lstTexture[41]);
|
||
m_lstSprite.push_back(lpSprite);
|
||
|
||
lpSprite = new CSprite;
|
||
lpSprite->Create(x + 256, y, 0, 0, 117, 256, g_ClientMain.m_lpInterface->m_lstTexture[42]);
|
||
m_lstSprite.push_back(lpSprite);
|
||
|
||
CGUIButton *lpButton;
|
||
lpButton = new CGUIButton;
|
||
lpButton->m_nMethod = BUTTON_NORMAL;
|
||
lpButton->m_lpNormalButton = new CSprite;
|
||
lpButton->m_lpNormalButton->Create(193, 210, 117, 132, 198, 165, g_ClientMain.m_lpInterface->m_lstTexture[42]);
|
||
lpButton->m_lpOnMouseButton = new CSprite;
|
||
lpButton->m_lpOnMouseButton->Create(193, 210, 117, 0, 198, 33, g_ClientMain.m_lpInterface->m_lstTexture[42]);
|
||
lpButton->m_lpClickMouseButton = new CSprite;
|
||
lpButton->m_lpClickMouseButton->Create(193, 210, 117, 66, 198, 99, g_ClientMain.m_lpInterface->m_lstTexture[42]);
|
||
lpButton->SetTooltip(&m_TooltipManager, g_StringTable.m_strString[560]);
|
||
lpButton->SetMove(x, y);
|
||
m_ButtonManager.AddButton(lpButton);
|
||
|
||
lpButton = new CGUIButton;
|
||
lpButton->m_nMethod = BUTTON_NORMAL;
|
||
lpButton->m_lpNormalButton = new CSprite;
|
||
lpButton->m_lpNormalButton->Create(279, 210, 117, 165, 198, 198, g_ClientMain.m_lpInterface->m_lstTexture[42]);
|
||
lpButton->m_lpOnMouseButton = new CSprite;
|
||
lpButton->m_lpOnMouseButton->Create(279, 210, 117, 33, 198, 66, g_ClientMain.m_lpInterface->m_lstTexture[42]);
|
||
lpButton->m_lpClickMouseButton = new CSprite;
|
||
lpButton->m_lpClickMouseButton->Create(279, 210, 117, 99, 198, 132, g_ClientMain.m_lpInterface->m_lstTexture[42]);
|
||
lpButton->SetTooltip(&m_TooltipManager, g_StringTable.m_strString[561]);
|
||
lpButton->SetMove(x, y);
|
||
m_ButtonManager.AddButton(lpButton);
|
||
|
||
m_bShow = FALSE;
|
||
|
||
m_dwWindowKind = WINDOW_FIX;
|
||
|
||
m_rcWindowSize.left = x; m_rcWindowSize.top = y;
|
||
m_rcWindowSize.right = x + 373; m_rcWindowSize.bottom = y + 256;
|
||
|
||
m_rcMoveEdge.left = x; m_rcMoveEdge.top = y;
|
||
m_rcMoveEdge.right = x + 373; m_rcMoveEdge.bottom = y + 20;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
void CHumanChannel::InitValue(void)
|
||
{
|
||
}
|
||
|
||
BOOL CHumanChannel::Update(BOOL &bClick, BOOL &bEdge)
|
||
{
|
||
if(g_DeviceInput.InRect(m_rcWindowSize.left, m_rcWindowSize.top, m_rcWindowSize.right, m_rcWindowSize.bottom))
|
||
{
|
||
bEdge = TRUE;
|
||
|
||
if(g_DeviceInput.GetIsLeftMouseDown() || g_DeviceInput.GetIsMiddleMouseDown() || g_DeviceInput.GetIsRightMouseDown() ||
|
||
g_DeviceInput.GetIsLeftMousePress() || g_DeviceInput.GetIsMiddleMousePress() || g_DeviceInput.GetIsRightMousePress() ||
|
||
g_DeviceInput.GetIsLeftMouseUp() || g_DeviceInput.GetIsMiddleMouseUp() || g_DeviceInput.GetIsRightMouseUp())
|
||
{
|
||
bClick = TRUE;
|
||
}
|
||
}
|
||
|
||
m_ButtonManager.Update();
|
||
m_TooltipManager.Update();
|
||
|
||
unsigned long i;
|
||
for(i = 0; i < m_cChannelNum; i++)
|
||
{
|
||
if(g_DeviceInput.InRect(m_rcWindowSize.left + 20,
|
||
m_rcWindowSize.top + 70 + i * 16, m_rcWindowSize.left + 352,
|
||
m_rcWindowSize.top + 70 + 16 + i * 16) && g_DeviceInput.GetIsLeftMouseDown())
|
||
{
|
||
m_dwSelectChannel = i;
|
||
}
|
||
}
|
||
|
||
if(m_ButtonManager.m_lstButton[0]->m_nState == BUTTON_CLICK) // <20><><EFBFBD><EFBFBD><EEB0A1>
|
||
{
|
||
if(m_aryChannel[m_dwSelectChannel])
|
||
{
|
||
g_ClientMain.m_dwClientMode = CLIENT_ZONEMOVE;
|
||
g_ClientMain.m_Network.m_nsNetworkState = NS_ZONEMOVE;
|
||
if(g_ClientMain.m_bTestServerVersion)
|
||
{
|
||
g_ClientMain.m_Network.m_pSocket->ServerZone(g_ClientMain.m_dwNextZone, 0);
|
||
} else
|
||
{
|
||
if(g_ClientMain.m_dwNextZone == 2 || g_ClientMain.m_dwNextZone == 4 ||
|
||
g_ClientMain.m_dwNextZone == 5 || g_ClientMain.m_dwNextZone == 6)
|
||
{
|
||
g_ClientMain.m_Network.m_pSocket->ServerZone(g_ClientMain.m_dwNextZone, 0);
|
||
} else
|
||
{
|
||
g_ClientMain.m_Network.m_pSocket->ServerZone(g_ClientMain.m_dwNextZone, m_dwSelectChannel);
|
||
}
|
||
}
|
||
} else
|
||
{
|
||
CGUIMessageBox *lpMessageBox;
|
||
lpMessageBox = new CGUIMessageBox;
|
||
lpMessageBox->Create(g_StringTable.m_strString[562]);
|
||
}
|
||
} else if(m_ButtonManager.m_lstButton[1]->m_nState == BUTTON_CLICK) // <20><><EFBFBD><EFBFBD>
|
||
{
|
||
ShowWindow(FALSE);
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
void CHumanChannel::ShowWindow(BOOL bShow)
|
||
{
|
||
if(bShow)
|
||
{
|
||
m_bShow = TRUE;
|
||
} else
|
||
{
|
||
m_bShow = FALSE;
|
||
}
|
||
}
|
||
|
||
void CHumanChannel::Render(LPDIRECT3DDEVICE8 lpD3DDevice)
|
||
{
|
||
m_lstSprite[0]->Render(lpD3DDevice, m_cAlpha);
|
||
m_lstSprite[1]->Render(lpD3DDevice, m_cAlpha);
|
||
|
||
//22, 70
|
||
unsigned long i;
|
||
RECT rcRect;
|
||
char strText[MAX_PATH];
|
||
for(i = 0; i < m_cChannelNum; i++)
|
||
{
|
||
sprintf(strText, g_StringTable.m_strString[563], i + 1);
|
||
SetRect(&rcRect, m_rcWindowSize.left + 22, m_rcWindowSize.top + 70 + i * 16, m_rcWindowSize.left + 140, m_rcWindowSize.top + 70 + 16 + i * 16);
|
||
g_TextEdit.DrawText(strText, &rcRect, DT_VCENTER | DT_LEFT, D3DCOLOR_RGBA(255, 255, 255, 255));
|
||
|
||
sprintf(strText, "%d%%", m_aryChannel[i]);
|
||
SetRect(&rcRect, m_rcWindowSize.left + 185, m_rcWindowSize.top + 70 + i * 16, m_rcWindowSize.left + 241, m_rcWindowSize.top + 70 + 16 + i * 16);
|
||
g_TextEdit.DrawText(strText, &rcRect, DT_VCENTER | DT_RIGHT, D3DCOLOR_RGBA(255, 255, 255, 255));
|
||
|
||
if(m_aryChannel[i]) strcpy(strText, "Open"); else strcpy(strText, "Close");
|
||
SetRect(&rcRect, m_rcWindowSize.left + 303, m_rcWindowSize.top + 70 + i * 16, m_rcWindowSize.left + 354, m_rcWindowSize.top + 70 + 16 + i * 16);
|
||
g_TextEdit.DrawText(strText, &rcRect, DT_VCENTER | DT_CENTER, D3DCOLOR_RGBA(255, 255, 255, 255));
|
||
}
|
||
|
||
if(g_ClientMain.m_lpCommonInterface)
|
||
{
|
||
g_ClientMain.m_lpCommonInterface->RenderRect(lpD3DDevice, m_rcWindowSize.left + 20,
|
||
m_rcWindowSize.top + 70 + m_dwSelectChannel * 16, m_rcWindowSize.left + 352,
|
||
m_rcWindowSize.top + 70 + 16 + m_dwSelectChannel * 16, 0xFFFFFFFF, 0x80);
|
||
}
|
||
|
||
m_ButtonManager.Render(lpD3DDevice);
|
||
}
|
||
|
||
void CHumanChannel::SetChannel(unsigned char cChannelNum, unsigned short *lpChannel)
|
||
{
|
||
m_cChannelNum = cChannelNum;
|
||
|
||
if(g_ClientMain.m_dwChannelID < m_cChannelNum)
|
||
{
|
||
m_dwSelectChannel = g_ClientMain.m_dwChannelID;
|
||
} else
|
||
{
|
||
m_dwSelectChannel = 0;
|
||
}
|
||
|
||
for(unsigned long i = 0; i < m_cChannelNum; i++)
|
||
{
|
||
m_aryChannel[i] = lpChannel[i];
|
||
}
|
||
}
|