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>
335 lines
13 KiB
C++
335 lines
13 KiB
C++
// HumanUpgrade.cpp: implementation of the CHumanUpgrade class.
|
||
//
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
#include "ClientMain.h"
|
||
#include "WinInput.h"
|
||
#include "HumanUpgrade.h"
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Construction/Destruction
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
CHumanUpgrade::CHumanUpgrade()
|
||
{
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[0] = NULL;
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[1] = NULL;
|
||
}
|
||
|
||
CHumanUpgrade::~CHumanUpgrade()
|
||
{
|
||
|
||
}
|
||
|
||
BOOL CHumanUpgrade::Init(unsigned short x, unsigned short y)
|
||
{
|
||
CSprite *lpSprite;
|
||
lpSprite = new CSprite;
|
||
lpSprite->Create(x, y, 0, 0, 222, 256, g_ClientMain.m_lpInterface->m_lstTexture[29]);
|
||
m_lstSprite.push_back(lpSprite);
|
||
|
||
lpSprite = new CSprite;
|
||
lpSprite->Create(x, y + 256, 0, 0, 222, 39, g_ClientMain.m_lpInterface->m_lstTexture[30]);
|
||
m_lstSprite.push_back(lpSprite);
|
||
|
||
CGUIButton *lpButton;
|
||
lpButton = new CGUIButton;
|
||
lpButton->m_nMethod = BUTTON_SIMPLECHECK;
|
||
lpButton->m_lpNormalButton = new CSprite;
|
||
lpButton->m_lpNormalButton->Create(63, 251, 114, 0, 182, 26, g_ClientMain.m_lpInterface->m_lstTexture[12]);
|
||
lpButton->m_lpClickMouseButton = new CSprite;
|
||
lpButton->m_lpClickMouseButton->Create(63, 251, 182, 0, 250, 26, g_ClientMain.m_lpInterface->m_lstTexture[12]);
|
||
lpButton->SetTooltip(&m_TooltipManager, g_StringTable.m_strString[260]);
|
||
lpButton->SetMove(x, y);
|
||
m_ButtonManager.AddButton(lpButton);
|
||
|
||
lpButton = new CGUIButton;
|
||
lpButton->m_nMethod = BUTTON_SIMPLE;
|
||
lpButton->m_lpNormalButton = new CSprite;
|
||
lpButton->m_lpNormalButton->Create(139, 251, 114, 26, 182, 52, g_ClientMain.m_lpInterface->m_lstTexture[12]);
|
||
lpButton->m_lpClickMouseButton = new CSprite;
|
||
lpButton->m_lpClickMouseButton->Create(139, 251, 182, 26, 250, 52, g_ClientMain.m_lpInterface->m_lstTexture[12]);
|
||
lpButton->SetTooltip(&m_TooltipManager, g_StringTable.m_strString[261]);
|
||
lpButton->SetMove(x, y);
|
||
m_ButtonManager.AddButton(lpButton);
|
||
|
||
lpButton = new CGUIButton;
|
||
lpButton->m_nMethod = BUTTON_SIMPLE;
|
||
lpButton->m_lpNormalButton = new CSprite;
|
||
lpButton->m_lpNormalButton->Create(162, 141, 49, 162, 98, 196, g_ClientMain.m_lpInterface->m_lstTexture[12]);
|
||
lpButton->m_lpClickMouseButton = new CSprite;
|
||
lpButton->m_lpClickMouseButton->Create(162, 141, 0, 162, 49, 196, g_ClientMain.m_lpInterface->m_lstTexture[12]);
|
||
lpButton->SetTooltip(&m_TooltipManager, g_StringTable.m_strString[262]);
|
||
lpButton->SetMove(x, y);
|
||
m_ButtonManager.AddButton(lpButton);
|
||
|
||
lpButton = new CGUIButton;
|
||
lpButton->m_nMethod = BUTTON_SIMPLE;
|
||
lpButton->m_lpNormalButton = new CSprite;
|
||
lpButton->m_lpNormalButton->Create(190, 1, 0, 0, 28, 28, g_ClientMain.m_lpInterface->m_lpCommonWindow);
|
||
lpButton->m_lpClickMouseButton = new CSprite;
|
||
lpButton->m_lpClickMouseButton->Create(190, 1, 28, 0, 56, 28, g_ClientMain.m_lpInterface->m_lpCommonWindow);
|
||
lpButton->SetTooltip(&m_TooltipManager, g_StringTable.m_strString[263]);
|
||
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 + 222; m_rcWindowSize.bottom = y + 296;
|
||
|
||
m_rcMoveEdge.left = x; m_rcMoveEdge.top = y;
|
||
m_rcMoveEdge.right = x + 222; m_rcMoveEdge.bottom = y + 20;
|
||
|
||
InitValue();
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
void CHumanUpgrade::InitValue(void)
|
||
{
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[0] = NULL;
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[1] = NULL;
|
||
}
|
||
|
||
BOOL CHumanUpgrade::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;
|
||
}
|
||
}
|
||
|
||
POINT *ptMousePos = g_DeviceInput.GetMousePosition();
|
||
unsigned long dwMousePosX = ptMousePos->x - (m_rcWindowSize.left + 36);
|
||
unsigned long dwMousePosY = ptMousePos->y - (m_rcWindowSize.top + 81);
|
||
unsigned long dwWindowX = dwMousePosX / 26;
|
||
unsigned long dwWindowY = dwMousePosY / 26;
|
||
|
||
m_ButtonManager.Update();
|
||
m_TooltipManager.Update();
|
||
|
||
if(g_DeviceInput.InRect(m_rcWindowSize.left + 36, m_rcWindowSize.top + 81, m_rcWindowSize.left + 113, m_rcWindowSize.top + 184))
|
||
{
|
||
if(g_DeviceInput.GetIsLeftMouseDown())
|
||
{
|
||
if(g_ClientMain.m_lpPickItem)
|
||
{
|
||
if(g_ClientMain.m_lpPickItem->GetIsEnableUpgrade())
|
||
{
|
||
if(g_ClientMain.m_lpPickItem->GetIsEquip())
|
||
{
|
||
Item::ItemPos pItemIndex;
|
||
pItemIndex.m_cIndex = 0;
|
||
pItemIndex.m_cPos = ClientSocket::ItemPos_Upgrade;
|
||
|
||
if(!g_ClientMain.m_csStatus.m_lpUpgrade[0])
|
||
{
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̵<EFBFBD>
|
||
if(g_ClientMain.m_lpPickItem->m_lpItemBase->GetPos() == pItemIndex)
|
||
{
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[0] = g_ClientMain.m_lpPickItem;
|
||
g_ClientMain.SetPickItem(NULL);
|
||
} else
|
||
{
|
||
g_ClientMain.m_Network.SendTakeItem(g_ClientMain.m_lpPickItem, &pItemIndex, 1);
|
||
}
|
||
} else
|
||
{
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>
|
||
g_ClientMain.m_Network.SendSwapItem(g_ClientMain.m_lpPickItem, &pItemIndex, g_ClientMain.m_csStatus.m_lpUpgrade[0]);
|
||
}
|
||
}
|
||
}
|
||
} else
|
||
{
|
||
if(g_ClientMain.m_csStatus.m_lpUpgrade[0])
|
||
{
|
||
g_ClientMain.SetPickItem(g_ClientMain.m_csStatus.m_lpUpgrade[0]);
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[0] = NULL;
|
||
}
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
} else if(g_DeviceInput.InRect(m_rcWindowSize.left + 141, m_rcWindowSize.top + 81, m_rcWindowSize.left + 166, m_rcWindowSize.top + 106))
|
||
{
|
||
if(g_DeviceInput.GetIsLeftMouseDown())
|
||
{
|
||
if(g_ClientMain.m_lpPickItem) // <20>տ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
{
|
||
if(g_ClientMain.m_lpPickItem->GetItemType() == Item::CItemType::MATERIAL)
|
||
{
|
||
if(g_ClientMain.m_csStatus.m_lpUpgrade[1])
|
||
{
|
||
if(g_ClientMain.m_lpPickItem->GetProtoTypeID() == g_ClientMain.m_csStatus.m_lpUpgrade[1]->GetProtoTypeID())
|
||
{
|
||
/* g_ClientMain.m_Network.m_nsNetworkState = NS_TAKEITEM;
|
||
|
||
TakeType pTakeType;
|
||
pTakeType.m_cSrcPos = g_ClientMain.m_lpPickItem->m_dwItemPos;
|
||
pTakeType.m_cSrcIndex = g_ClientMain.m_lpPickItem->m_lpItemBase->m_ItemInfo.m_nItemIndex;
|
||
pTakeType.m_cDstPos = g_ClientMain.m_csStatus.m_lpUpgrade[1]->m_dwItemPos;
|
||
pTakeType.m_cDstIndex = g_ClientMain.m_csStatus.m_lpUpgrade[1]->m_lpItemBase->m_ItemInfo.m_nItemIndex;
|
||
|
||
if(g_ClientMain.m_csStatus.m_lpUpgrade[1]->GetMaxDurability() - g_ClientMain.m_csStatus.m_lpUpgrade[1]->m_lpItemBase->m_nNowDurability < g_ClientMain.m_lpPickItem->m_lpItemBase->m_nNowDurability)
|
||
{
|
||
pTakeType.m_cSrcIndex.m_cNum = g_ClientMain.m_csStatus.m_lpUpgrade[1]->GetMaxDurability() - g_ClientMain.m_csStatus.m_lpUpgrade[1]->m_lpItemBase->m_nNowDurability;
|
||
} else
|
||
{
|
||
pTakeType.m_cSrcIndex.m_cNum = g_ClientMain.m_lpPickItem->m_lpItemBase->m_nNowDurability;
|
||
}
|
||
|
||
g_ClientMain.m_Network.m_pSocket->CharStackItem(g_ClientMain.m_dwMyChrID, pTakeType);*/
|
||
unsigned char cNum;
|
||
if(g_ClientMain.m_csStatus.m_lpUpgrade[1]->GetMaxDurability() - g_ClientMain.m_csStatus.m_lpUpgrade[1]->GetNowDurability() < g_ClientMain.m_lpPickItem->GetNowDurability())
|
||
{
|
||
cNum = g_ClientMain.m_csStatus.m_lpUpgrade[1]->GetMaxDurability() - g_ClientMain.m_csStatus.m_lpUpgrade[1]->GetNowDurability();
|
||
} else
|
||
{
|
||
cNum = g_ClientMain.m_lpPickItem->GetNowDurability();
|
||
}
|
||
g_ClientMain.m_Network.SendSplitItem(g_ClientMain.m_lpPickItem, &g_ClientMain.m_csStatus.m_lpUpgrade[1]->m_lpItemBase->GetPos(), cNum);
|
||
|
||
return TRUE;
|
||
} else // <20>ٸ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||
{
|
||
Item::ItemPos pItemIndex;
|
||
pItemIndex.m_cIndex = 1;
|
||
pItemIndex.m_cPos = ClientSocket::ItemPos_Upgrade;
|
||
|
||
g_ClientMain.m_Network.SendSwapItem(g_ClientMain.m_lpPickItem, &pItemIndex, g_ClientMain.m_csStatus.m_lpUpgrade[1]);
|
||
|
||
return TRUE;
|
||
}
|
||
} else
|
||
{
|
||
CItemInstance *lpExistItem = g_ClientMain.m_csStatus.GetInventoryItem(g_ClientMain.m_lpPickItem->m_lpItemBase->GetPos());
|
||
|
||
Item::ItemPos pItemIndex;
|
||
pItemIndex.m_cIndex = 1;
|
||
pItemIndex.m_cPos = ClientSocket::ItemPos_Upgrade;
|
||
|
||
if(g_ClientMain.m_lpPickItem->m_lpItemBase->GetPos() == pItemIndex)
|
||
{
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[1] = g_ClientMain.m_lpPickItem;
|
||
g_ClientMain.SetPickItem(NULL);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
if(lpExistItem)
|
||
{
|
||
/* g_ClientMain.m_Network.m_nsNetworkState = NS_TAKEITEM;
|
||
|
||
TakeType pTakeType;
|
||
pTakeType.m_cSrcPos = g_ClientMain.m_lpPickItem->m_dwItemPos;
|
||
pTakeType.m_cSrcIndex = g_ClientMain.m_lpPickItem->m_lpItemBase->m_ItemInfo.m_nItemIndex;
|
||
pTakeType.m_cDstPos = TakeType::TS_UPGRADE;
|
||
pTakeType.m_cDstIndex.m_cIndex = 1;
|
||
pTakeType.m_cSrcIndex.m_cNum = g_ClientMain.m_lpPickItem->m_lpItemBase->m_nNowDurability;
|
||
|
||
g_ClientMain.m_Network.m_pSocket->CharStackItem(g_ClientMain.m_dwMyChrID, pTakeType);*/
|
||
g_ClientMain.m_Network.SendSplitItem(g_ClientMain.m_lpPickItem, &pItemIndex, g_ClientMain.m_lpPickItem->GetNowDurability());
|
||
} else
|
||
{
|
||
g_ClientMain.m_Network.SendTakeItem(g_ClientMain.m_lpPickItem, &pItemIndex, g_ClientMain.m_lpPickItem->GetNowDurability());
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
}
|
||
} else
|
||
{
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ݴ´<DDB4>.
|
||
if(g_ClientMain.m_csStatus.m_lpUpgrade[1])
|
||
{
|
||
g_ClientMain.SetPickItem(g_ClientMain.m_csStatus.m_lpUpgrade[1]);
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[1] = NULL;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if(m_ButtonManager.m_lstButton[0]->m_nState == BUTTON_CLICK)
|
||
{
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>
|
||
} else if(m_ButtonManager.m_lstButton[1]->m_nState == BUTTON_CLICK)
|
||
{
|
||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>
|
||
} else if(m_ButtonManager.m_lstButton[2]->m_nState == BUTTON_CLICK)
|
||
{
|
||
// <20><>ȭ<EFBFBD>ϱ<EFBFBD>
|
||
g_ClientMain.m_Network.m_pSocket->CharUpgradeItem(g_ClientMain.m_dwMyChrID, g_ClientMain.m_csStatus.m_lpUpgrade[1]->GetNowDurability());
|
||
} else if(m_ButtonManager.m_lstButton[3]->m_nState == BUTTON_CLICK)
|
||
{
|
||
m_ButtonManager.m_lstButton[3]->m_nState = BUTTON_NONE;
|
||
ShowWindow(FALSE);
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
void CHumanUpgrade::ShowWindow(BOOL bShow)
|
||
{
|
||
m_bShow = bShow;
|
||
|
||
m_ButtonManager.m_lstButton[0]->ShowButton(bShow);
|
||
m_ButtonManager.m_lstButton[1]->ShowButton(bShow);
|
||
m_ButtonManager.m_lstButton[2]->ShowButton(bShow);
|
||
}
|
||
|
||
void CHumanUpgrade::Render(LPDIRECT3DDEVICE8 lpD3DDevice)
|
||
{
|
||
m_lstSprite[0]->Render(lpD3DDevice, m_cAlpha);
|
||
m_lstSprite[1]->Render(lpD3DDevice, m_cAlpha);
|
||
|
||
if(g_ClientMain.m_csStatus.m_lpUpgrade[0])
|
||
{
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[0]->m_wPutX = m_rcWindowSize.left + 36 +
|
||
((77 / 2) - (g_ClientMain.m_csStatus.m_lpUpgrade[0]->m_lpSprite->GetSizeX() / 2));
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[0]->m_wPutY = m_rcWindowSize.top + 81 +
|
||
((103 / 2) - (g_ClientMain.m_csStatus.m_lpUpgrade[0]->m_lpSprite->GetSizeY() / 2));
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[0]->Render(lpD3DDevice);
|
||
}
|
||
if(g_ClientMain.m_csStatus.m_lpUpgrade[1])
|
||
{
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[1]->m_wPutX = m_rcWindowSize.left + 141 + ((24 - g_ClientMain.m_csStatus.m_lpUpgrade[1]->m_lpSprite->GetSizeX()) / 2);
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[1]->m_wPutY = m_rcWindowSize.top + 81 + ((24 - g_ClientMain.m_csStatus.m_lpUpgrade[1]->m_lpSprite->GetSizeY()) / 2);
|
||
g_ClientMain.m_csStatus.m_lpUpgrade[1]->Render(lpD3DDevice);
|
||
}
|
||
|
||
if(g_ClientMain.m_lpPickItem)
|
||
{
|
||
if(g_DeviceInput.InRect(m_rcWindowSize.left + 36, m_rcWindowSize.top + 81, m_rcWindowSize.left + 113, m_rcWindowSize.top + 184))
|
||
{
|
||
if(g_ClientMain.m_lpPickItem->GetIsEnableUpgrade())
|
||
{
|
||
g_ClientMain.m_lpCommonInterface->RenderRect(lpD3DDevice, m_rcWindowSize.left + 36, m_rcWindowSize.top + 81, m_rcWindowSize.left + 113, m_rcWindowSize.top + 184, 0xFF0000FF, 0x80);
|
||
} else
|
||
{
|
||
g_ClientMain.m_lpCommonInterface->RenderRect(lpD3DDevice, m_rcWindowSize.left + 36, m_rcWindowSize.top + 81, m_rcWindowSize.left + 113, m_rcWindowSize.top + 184, 0xFFFF0000, 0x80);
|
||
}
|
||
} else if(g_DeviceInput.InRect(m_rcWindowSize.left + 141, m_rcWindowSize.top + 81, m_rcWindowSize.left + 166, m_rcWindowSize.top + 106))
|
||
{
|
||
if(g_ClientMain.m_lpPickItem->GetItemType() == Item::CItemType::MATERIAL)
|
||
{
|
||
g_ClientMain.m_lpCommonInterface->RenderRect(lpD3DDevice, m_rcWindowSize.left + 141, m_rcWindowSize.top + 81, m_rcWindowSize.left + 166, m_rcWindowSize.top + 106, 0xFF0000FF, 0x80);
|
||
} else
|
||
{
|
||
g_ClientMain.m_lpCommonInterface->RenderRect(lpD3DDevice, m_rcWindowSize.left + 141, m_rcWindowSize.top + 81, m_rcWindowSize.left + 166, m_rcWindowSize.top + 106, 0xFFFF0000, 0x80);
|
||
}
|
||
}
|
||
}
|
||
|
||
m_ButtonManager.Render(lpD3DDevice);
|
||
}
|