Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "StdAfx.h"
- #include "WndFastJewelSelect.h"
- #include "ResData.h"
- #include "DPClient.h"
- extern CDPClient g_DPlay;
- CWndFastJewelSelect::CWndFastJewelSelect() : gemOptions(nullptr), startButton(nullptr), cancelbutton(nullptr), itemStatic(nullptr), gemStatic(nullptr), itemTexture(nullptr), gemTexture(nullptr),
- itemElem(nullptr), gemItem(nullptr), tickTimer(0)
- {
- }
- CWndFastJewelSelect::~CWndFastJewelSelect()
- {
- if (itemElem)
- itemElem->SetExtra(0);
- if (gemItem)
- gemItem->SetExtra(0);
- gemItem = itemElem = nullptr;
- }
- BOOL CWndFastJewelSelect::Initialize(CWndBase* pWndParent, DWORD)
- {
- return InitDialog(g_Neuz.GetSafeHwnd(), APP_FASTJEWEL, 0, CPoint(0, 0), pWndParent);
- }
- void CWndFastJewelSelect::putItem(const unsigned long id)
- {
- CItemElem* pTempElem = dynamic_cast<CItemElem*>(g_pPlayer->GetItemId(id));
- if (!pTempElem)
- return;
- ItemProp* pItemProp = pTempElem->GetProp();
- if (!pItemProp)
- return;
- putItem(pTempElem, pItemProp);
- }
- void CWndFastJewelSelect::putItem(CItemElem* pItemElem, const ItemProp* iProp)
- {
- if (iProp->dwReferStat1 == WEAPON_ULTIMATE)
- {
- const auto size = pItemElem->GetUltimatePiercingSize();
- int i = 0;
- for (; i < size; ++i)
- {
- if (pItemElem->GetUltimatePiercingItem(i) == 0)
- break;
- }
- if (size == 0 || i == size)
- {
- g_WndMng.PutString("Need an item with avaliable slots!");
- return;
- }
- itemElem = pItemElem;
- itemElem->SetExtra(itemElem->m_nItemNum);
- itemTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, iProp->szIcon), 0xffff00ff);
- }
- else if (iProp->dwItemKind3 == IK3_ULTIMATE)
- {
- gemItem = pItemElem;
- gemItem->SetExtra(gemItem->m_nItemNum);
- gemTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, iProp->szIcon), 0xffff00ff);
- }
- }
- void CWndFastJewelSelect::setDefaultGemTexture()
- {
- std::string textureName;
- switch (xRandom(5))
- {
- case 0:
- textureName = "Itm_GenMatRuby.dds";
- break;
- case 1:
- textureName = "Itm_GenMatTopaz.dds";
- break;
- case 2:
- textureName = "Itm_GenMatSapphire.dds";
- break;
- case 3:
- textureName = "Itm_GenMatEmerald.dds";
- break;
- case 4:
- default:
- textureName = "Itm_GenMatDiamond.dds";
- break;
- }
- gemTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, textureName.c_str()), 0xffff00ff);
- }
- void CWndFastJewelSelect::OnInitialUpdate()
- {
- CWndNeuz::OnInitialUpdate();
- gemOptions = dynamic_cast<CWndComboBox*>(GetDlgItem(WIDC_COMBOBOX1));
- for (auto& iter : prj.m_UltimateWeapon.m_vecGemAbilityKind)
- {
- const int pos = gemOptions->AddString(g_WndMng.findDstString(iter.nAbility));
- gemOptions->SetItemData(pos, iter.nAbility);
- }
- gemOptions->SetCurSel(0);
- gemOptions->AddWndStyle(EBS_READONLY);
- startButton = dynamic_cast<CWndButton*>(GetDlgItem(WIDC_BUTTON10));
- cancelbutton = dynamic_cast<CWndButton*>(GetDlgItem(WIDC_BUTTON11));
- itemStatic = dynamic_cast<CWndStatic*>(GetDlgItem(WIDC_STATIC1));
- gemStatic = dynamic_cast<CWndStatic*>(GetDlgItem(WIDC_STATIC2));
- setDefaultGemTexture();
- MoveParentCenter();
- }
- void CWndFastJewelSelect::OnLButtonUp(UINT nFlags, CPoint point)
- {
- if (itemStatic && itemStatic->GetWndRect().PtInRect(point))
- {
- if (itemElem)
- {
- itemElem->SetExtra(0);
- itemElem = nullptr;
- itemTexture = nullptr;
- }
- }
- if (gemStatic && gemStatic->GetWndRect().PtInRect(point))
- {
- if (gemItem)
- {
- gemItem->SetExtra(0);
- gemItem = nullptr;
- setDefaultGemTexture();
- }
- }
- }
- void CWndFastJewelSelect::OnDraw(C2DRender* p2DRender)
- {
- if (gemTexture && gemStatic)
- {
- if (gemItem)
- {
- gemTexture->Render(p2DRender, CPoint(gemStatic->GetWndRect().left, gemStatic->GetWndRect().top));
- p2DRender->TextOut(gemStatic->GetWndRect().left, gemStatic->GetWndRect().bottom - 6, 0.8f, 0.8f, std::to_string(gemItem->GetExtra()).c_str(), 0xff000000);
- }
- else
- gemTexture->Render(p2DRender, CPoint(gemStatic->GetWndRect().left, gemStatic->GetWndRect().top), 80);
- }
- if (itemElem)
- {
- if (itemTexture && itemStatic)
- itemTexture->Render(p2DRender, CPoint(itemStatic->GetWndRect().left, itemStatic->GetWndRect().top));
- if (!tickTimer)
- {
- if (gemItem)
- startButton->EnableWindow(true);
- else
- startButton->EnableWindow(false);
- }
- }
- if (tickTimer)
- {
- if (g_tmCurrent >= tickTimer)
- {
- startButton->EnableWindow(true);
- tickTimer = 0;
- }
- else
- startButton->EnableWindow(false);
- }
- }
- BOOL CWndFastJewelSelect::OnDropIcon(LPSHORTCUT pShortcut, CPoint point)
- {
- CWndBase* pWndFrame = pShortcut->m_pFromWnd->GetFrameWnd();
- if (!pWndFrame)
- return false;
- if (pWndFrame->GetWndId() != APP_INVENTORY && pWndFrame->GetWndId() != APP_BAG_EX)
- {
- SetForbid(true);
- return false;
- }
- if (pShortcut->m_dwShortcut == SHORTCUT_ITEM)
- putItem(pShortcut->m_dwId);
- return false;
- }
- BOOL CWndFastJewelSelect::OnChildNotify(const UINT message, const UINT nID, LRESULT* pLResult)
- {
- switch (nID)
- {
- case WIDC_BUTTON10:
- {
- if (gemOptions->GetCurSel() < 0 || !itemElem || !gemItem)
- break;
- int i = 0;
- for (; i < itemElem->GetUltimatePiercingSize(); ++i)
- {
- if (itemElem->GetUltimatePiercingItem(i) == 0)
- break;
- }
- if (i == itemElem->GetUltimatePiercingSize())
- {
- g_WndMng.PutString("Need an item with avaliable slots!");
- break;
- }
- tickTimer = g_tmCurrent += 2000;
- g_DPlay.sendFastJewelSelect(itemElem->m_dwObjId, gemItem->m_dwObjId, gemOptions->GetItemData(gemOptions->GetCurSel()));
- if (gemItem->GetExtra() > 1)
- gemItem->SetExtra(gemItem->GetExtra() - 1);
- else
- {
- gemItem->SetExtra(0);
- gemItem = nullptr;
- setDefaultGemTexture();
- }
- break;
- }
- case WIDC_BUTTON11:
- {
- Destroy();
- break;
- }
- default:
- break;
- }
- return CWndNeuz::OnChildNotify(message, nID, pLResult);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement