Advertisement
Guest User

Untitled

a guest
May 20th, 2022
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.72 KB | None | 0 0
  1. #include "StdAfx.h"
  2. #include "../eterBase/CRC32.h"
  3. #include "../eterBase/Filename.h"
  4. #include "PythonWindow.h"
  5. #include "PythonSlotWindow.h"
  6.  
  7. //#define __RENDER_SLOT_AREA__
  8.  
  9. using namespace UI;
  10.  
  11. class UI::CSlotWindow::CSlotButton : public CButton
  12. {
  13. public:
  14. enum ESlotButtonType
  15. {
  16. SLOT_BUTTON_TYPE_PLUS,
  17. SLOT_BUTTON_TYPE_COVER,
  18. };
  19.  
  20. public:
  21. CSlotButton(ESlotButtonType dwType, DWORD dwSlotNumber, CSlotWindow* pParent) : CButton(NULL)
  22. {
  23. m_dwSlotButtonType = dwType;
  24. m_dwSlotNumber = dwSlotNumber;
  25. m_pParent = pParent;
  26. }
  27. virtual ~CSlotButton()
  28. {
  29. }
  30.  
  31. BOOL OnMouseLeftButtonDown()
  32. {
  33. if (!IsEnable())
  34. return TRUE;
  35. if (UI::CWindowManager::Instance().IsAttaching())
  36. return TRUE;
  37.  
  38. m_isPressed = TRUE;
  39. Down();
  40.  
  41. return TRUE;
  42. }
  43. BOOL OnMouseLeftButtonUp()
  44. {
  45. if (!IsEnable())
  46. return TRUE;
  47. if (!IsPressed())
  48. return TRUE;
  49.  
  50. if (IsIn())
  51. SetCurrentVisual(&m_overVisual);
  52. else
  53. SetCurrentVisual(&m_upVisual);
  54.  
  55. m_pParent->OnPressedSlotButton(m_dwSlotButtonType, m_dwSlotNumber);
  56.  
  57. return TRUE;
  58. }
  59.  
  60. void OnMouseOverIn()
  61. {
  62. if (IsEnable())
  63. {
  64. SetCurrentVisual(&m_overVisual);
  65. }
  66. m_pParent->OnOverInItem(m_dwSlotNumber);
  67. }
  68. void OnMouseOverOut()
  69. {
  70. if (IsEnable())
  71. {
  72. SetUp();
  73. SetCurrentVisual(&m_upVisual);
  74. }
  75. m_pParent->OnOverOutItem();
  76. }
  77.  
  78. protected:
  79. ESlotButtonType m_dwSlotButtonType;
  80. DWORD m_dwSlotNumber;
  81. CSlotWindow* m_pParent;
  82. };
  83.  
  84. ///////////////////////////////////////////////////////////////////////////////////////////////////
  85. ///////////////////////////////////////////////////////////////////////////////////////////////////
  86. ///////////////////////////////////////////////////////////////////////////////////////////////////
  87.  
  88. class UI::CSlotWindow::CCoverButton : public CSlotButton
  89. {
  90. public:
  91. CCoverButton(ESlotButtonType dwType, DWORD dwSlotNumber, CSlotWindow* pParent) : CSlotButton(dwType, dwSlotNumber, pParent)
  92. {
  93. m_bLeftButtonEnable = TRUE;
  94. m_bRightButtonEnable = TRUE;
  95. }
  96. virtual ~CCoverButton()
  97. {
  98. }
  99.  
  100. void SetLeftButtonEnable(BOOL bEnable)
  101. {
  102. m_bLeftButtonEnable = bEnable;
  103. }
  104. void SetRightButtonEnable(BOOL bEnable)
  105. {
  106. m_bRightButtonEnable = bEnable;
  107. }
  108.  
  109. void OnRender()
  110. {
  111. }
  112.  
  113. void RenderButton()
  114. {
  115. CButton::OnRender();
  116. }
  117.  
  118. BOOL OnMouseLeftButtonDown()
  119. {
  120. if (!IsEnable())
  121. return TRUE;
  122. if (m_bLeftButtonEnable)
  123. {
  124. CButton::OnMouseLeftButtonDown();
  125. }
  126. else
  127. {
  128. m_pParent->OnMouseLeftButtonDown();
  129. }
  130. return TRUE;
  131. }
  132. BOOL OnMouseLeftButtonUp()
  133. {
  134. if (!IsEnable())
  135. return TRUE;
  136. if (m_bLeftButtonEnable)
  137. {
  138. CButton::OnMouseLeftButtonUp();
  139. m_pParent->OnMouseLeftButtonDown();
  140. }
  141. else
  142. {
  143. m_pParent->OnMouseLeftButtonUp();
  144. }
  145. return TRUE;
  146. }
  147.  
  148. BOOL OnMouseRightButtonDown()
  149. {
  150. if (!IsEnable())
  151. return TRUE;
  152. if (m_bRightButtonEnable)
  153. CButton::OnMouseLeftButtonDown();
  154. return TRUE;
  155. }
  156. BOOL OnMouseRightButtonUp()
  157. {
  158. if (!IsEnable())
  159. return TRUE;
  160. m_pParent->OnMouseRightButtonDown();
  161. if (m_bRightButtonEnable)
  162. CButton::OnMouseLeftButtonUp();
  163. return TRUE;
  164. }
  165.  
  166. protected:
  167. BOOL m_bLeftButtonEnable;
  168. BOOL m_bRightButtonEnable;
  169. };
  170.  
  171. ///////////////////////////////////////////////////////////////////////////////////////////////////
  172. ///////////////////////////////////////////////////////////////////////////////////////////////////
  173. ///////////////////////////////////////////////////////////////////////////////////////////////////
  174.  
  175. class UI::CSlotWindow::CCoolTimeFinishEffect : public CAniImageBox
  176. {
  177. public:
  178. CCoolTimeFinishEffect(CSlotWindow* pParent, DWORD dwSlotIndex) : CAniImageBox(NULL)
  179. {
  180. m_pParent = pParent;
  181. m_dwSlotIndex = dwSlotIndex;
  182. }
  183. virtual ~CCoolTimeFinishEffect()
  184. {
  185. }
  186.  
  187. void OnEndFrame()
  188. {
  189. ((CSlotWindow*)m_pParent)->ReserveDestroyCoolTimeFinishEffect(m_dwSlotIndex);
  190. }
  191.  
  192. protected:
  193. DWORD m_dwSlotIndex;
  194. };
  195.  
  196. ///////////////////////////////////////////////////////////////////////////////////////////////////
  197. ///////////////////////////////////////////////////////////////////////////////////////////////////
  198. ///////////////////////////////////////////////////////////////////////////////////////////////////
  199.  
  200. // Set & Append
  201.  
  202. void CSlotWindow::SetSlotType(DWORD dwType)
  203. {
  204. m_dwSlotType = dwType;
  205. }
  206.  
  207. void CSlotWindow::SetSlotStyle(DWORD dwStyle)
  208. {
  209. m_dwSlotStyle = dwStyle;
  210. }
  211.  
  212. void CSlotWindow::AppendSlot(DWORD dwIndex, int ixPosition, int iyPosition, int ixCellSize, int iyCellSize)
  213. {
  214. TSlot Slot;
  215. Slot.pInstance = NULL;
  216. Slot.pNumberLine = NULL;
  217. Slot.pCoverButton = NULL;
  218. Slot.pSlotButton = NULL;
  219. Slot.pSignImage = NULL;
  220. Slot.pFinishCoolTimeEffect = NULL;
  221. #if defined(__BL_ENABLE_PICKUP_ITEM_EFFECT__)
  222. Slot.pNewSlotEffect.fill(nullptr);
  223. Slot.bFlashEffect = false;
  224. #endif
  225.  
  226. ClearSlot(&Slot);
  227. Slot.dwSlotNumber = dwIndex;
  228. Slot.dwCenterSlotNumber = dwIndex;
  229. Slot.ixPosition = ixPosition;
  230. Slot.iyPosition = iyPosition;
  231. Slot.ixCellSize = ixCellSize;
  232. Slot.iyCellSize = iyCellSize;
  233. m_SlotList.push_back(Slot);
  234. }
  235.  
  236. void CSlotWindow::SetCoverButton(DWORD dwIndex, const char* c_szUpImageName, const char* c_szOverImageName, const char* c_szDownImageName, const char* c_szDisableImageName, BOOL bLeftButtonEnable, BOOL bRightButtonEnable)
  237. {
  238. TSlot* pSlot;
  239. if (!GetSlotPointer(dwIndex, &pSlot))
  240. return;
  241.  
  242. CCoverButton*& rpCoverButton = pSlot->pCoverButton;
  243.  
  244. if (!rpCoverButton)
  245. {
  246. rpCoverButton = new CCoverButton(CSlotButton::SLOT_BUTTON_TYPE_COVER, pSlot->dwSlotNumber, this);
  247. CWindowManager::Instance().SetParent(rpCoverButton, this);
  248. }
  249.  
  250. rpCoverButton->SetLeftButtonEnable(bLeftButtonEnable);
  251. rpCoverButton->SetRightButtonEnable(bRightButtonEnable);
  252. rpCoverButton->SetUpVisual(c_szUpImageName);
  253. rpCoverButton->SetOverVisual(c_szOverImageName);
  254. rpCoverButton->SetDownVisual(c_szDownImageName);
  255. rpCoverButton->SetDisableVisual(c_szDisableImageName);
  256. rpCoverButton->Enable();
  257. rpCoverButton->Show();
  258.  
  259. // NOTE : Cover ąöĆ°ŔĚ Plus ąöĆ°Ŕ» °ˇ·Áąö·ÁĽ­ Ŕӽà Äڵ带..
  260. if (pSlot->pSlotButton)
  261. {
  262. SetTop(pSlot->pSlotButton);
  263. }
  264. }
  265.  
  266. void CSlotWindow::EnableCoverButton(DWORD dwIndex)
  267. {
  268. TSlot* pSlot;
  269. if (!GetSlotPointer(dwIndex, &pSlot))
  270. return;
  271.  
  272. if (!pSlot->pCoverButton)
  273. return;
  274.  
  275. pSlot->pCoverButton->Enable();
  276. }
  277.  
  278. void CSlotWindow::DisableCoverButton(DWORD dwIndex)
  279. {
  280. TSlot* pSlot;
  281. if (!GetSlotPointer(dwIndex, &pSlot))
  282. return;
  283.  
  284. if (!pSlot->pCoverButton)
  285. return;
  286.  
  287. pSlot->pCoverButton->Disable();
  288. }
  289.  
  290. void CSlotWindow::SetAlwaysRenderCoverButton(DWORD dwIndex, bool bAlwaysRender)
  291. {
  292. TSlot* pSlot;
  293. if (!GetSlotPointer(dwIndex, &pSlot))
  294. return;
  295.  
  296. if (bAlwaysRender)
  297. SET_BIT(pSlot->dwState, SLOT_STATE_ALWAYS_RENDER_COVER);
  298. else
  299. REMOVE_BIT(pSlot->dwState, SLOT_STATE_ALWAYS_RENDER_COVER);
  300. }
  301.  
  302. void CSlotWindow::ShowSlotBaseImage(DWORD dwIndex)
  303. {
  304. TSlot* pSlot;
  305. if (!GetSlotPointer(dwIndex, &pSlot))
  306. return;
  307.  
  308. pSlot->bRenderBaseSlotImage = true;
  309. }
  310.  
  311. void CSlotWindow::HideSlotBaseImage(DWORD dwIndex)
  312. {
  313. TSlot* pSlot;
  314. if (!GetSlotPointer(dwIndex, &pSlot))
  315. return;
  316.  
  317. pSlot->bRenderBaseSlotImage = false;
  318. }
  319.  
  320. BOOL CSlotWindow::IsDisableCoverButton(DWORD dwIndex)
  321. {
  322. TSlot* pSlot;
  323. if (!GetSlotPointer(dwIndex, &pSlot))
  324. return FALSE;
  325.  
  326. if (!pSlot->pCoverButton)
  327. return FALSE;
  328.  
  329. return pSlot->pCoverButton->IsDisable();
  330. }
  331.  
  332. void CSlotWindow::SetSlotBaseImage(const char* c_szFileName, float fr, float fg, float fb, float fa)
  333. {
  334. __CreateBaseImage(c_szFileName, fr, fg, fb, fa);
  335. }
  336.  
  337. void CSlotWindow::AppendSlotButton(const char* c_szUpImageName, const char* c_szOverImageName, const char* c_szDownImageName)
  338. {
  339. for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  340. {
  341. TSlot& rSlot = *itor;
  342. CSlotButton*& rpSlotButton = rSlot.pSlotButton;
  343.  
  344. if (!rpSlotButton)
  345. {
  346. rpSlotButton = new CSlotButton(CSlotButton::SLOT_BUTTON_TYPE_PLUS, rSlot.dwSlotNumber, this);
  347. rpSlotButton->AddFlag(FLAG_FLOAT);
  348. CWindowManager::Instance().SetParent(rpSlotButton, this);
  349. }
  350.  
  351. rpSlotButton->SetUpVisual(c_szUpImageName);
  352. rpSlotButton->SetOverVisual(c_szOverImageName);
  353. rpSlotButton->SetDownVisual(c_szDownImageName);
  354. rpSlotButton->SetPosition(rSlot.ixPosition + 1, rSlot.iyPosition + 19);
  355. rpSlotButton->Hide();
  356. }
  357. }
  358.  
  359. void CSlotWindow::AppendRequirementSignImage(const char* c_szImageName)
  360. {
  361. for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  362. {
  363. TSlot& rSlot = *itor;
  364. CImageBox*& rpSignImage = rSlot.pSignImage;
  365.  
  366. if (!rpSignImage)
  367. {
  368. rpSignImage = new CImageBox(NULL);
  369. CWindowManager::Instance().SetParent(rpSignImage, this);
  370. }
  371.  
  372. rpSignImage->LoadImage(c_szImageName);
  373. rpSignImage->Hide();
  374. }
  375. }
  376.  
  377. BOOL CSlotWindow::HasSlot(DWORD dwIndex)
  378. {
  379. TSlot* pSlot;
  380. if (!GetSlotPointer(dwIndex, &pSlot))
  381. return FALSE;
  382.  
  383. return TRUE;
  384. }
  385.  
  386. void CSlotWindow::SetSlot(DWORD dwIndex, DWORD dwVirtualNumber, BYTE byWidth, BYTE byHeight, CGraphicImage* pImage, D3DXCOLOR& diffuseColor)
  387. {
  388. TSlot* pSlot;
  389. if (!GetSlotPointer(dwIndex, &pSlot))
  390. return;
  391.  
  392. if (pSlot->isItem)
  393. if (pSlot->dwItemIndex == dwVirtualNumber)
  394. {
  395. pSlot->dwState = 0;
  396. pSlot->isItem = TRUE;
  397. if (pImage && pSlot->pInstance)
  398. {
  399. pSlot->pInstance->SetImagePointer(pImage);
  400. }
  401. return;
  402. }
  403.  
  404. ClearSlot(pSlot);
  405. pSlot->dwState = 0;
  406. pSlot->isItem = TRUE;
  407. pSlot->dwItemIndex = dwVirtualNumber;
  408.  
  409. if (pImage)
  410. {
  411. assert(NULL == pSlot->pInstance);
  412. pSlot->pInstance = CGraphicImageInstance::New();
  413. pSlot->pInstance->SetDiffuseColor(diffuseColor.r, diffuseColor.g, diffuseColor.b, diffuseColor.a);
  414. pSlot->pInstance->SetImagePointer(pImage);
  415. }
  416.  
  417. pSlot->byxPlacedItemSize = byWidth;
  418. pSlot->byyPlacedItemSize = byHeight;
  419.  
  420. if (pSlot->pCoverButton)
  421. {
  422. pSlot->pCoverButton->Show();
  423. }
  424. }
  425.  
  426. void CSlotWindow::SetSlotCount(DWORD dwIndex, DWORD dwCount)
  427. {
  428. TSlot* pSlot;
  429. if (!GetSlotPointer(dwIndex, &pSlot))
  430. return;
  431.  
  432. if (dwCount <= 0)
  433. {
  434. if (pSlot->pNumberLine)
  435. {
  436. delete pSlot->pNumberLine;
  437. pSlot->pNumberLine = NULL;
  438. }
  439. }
  440. else
  441. {
  442. char szCount[16 + 1];
  443. _snprintf(szCount, sizeof(szCount), "%d", dwCount);
  444.  
  445. if (!pSlot->pNumberLine)
  446. {
  447. CNumberLine* pNumberLine = new UI::CNumberLine(this);
  448. pNumberLine->SetHorizontalAlign(CNumberLine::HORIZONTAL_ALIGN_RIGHT);
  449. pNumberLine->Show();
  450. pSlot->pNumberLine = pNumberLine;
  451. }
  452.  
  453. pSlot->pNumberLine->SetNumber(szCount);
  454. }
  455. }
  456.  
  457. void CSlotWindow::SetSlotCountNew(DWORD dwIndex, DWORD dwGrade, DWORD dwCount)
  458. {
  459. TSlot* pSlot;
  460. if (!GetSlotPointer(dwIndex, &pSlot))
  461. return;
  462.  
  463. if (dwCount <= 0)
  464. {
  465. if (pSlot->pNumberLine)
  466. {
  467. delete pSlot->pNumberLine;
  468. pSlot->pNumberLine = NULL;
  469. }
  470. }
  471. else
  472. {
  473. char szCount[16 + 1];
  474.  
  475. switch (dwGrade)
  476. {
  477. case 0:
  478. _snprintf(szCount, sizeof(szCount), "%d", dwCount);
  479. break;
  480. case 1:
  481. _snprintf(szCount, sizeof(szCount), "m%d", dwCount);
  482. break;
  483. case 2:
  484. _snprintf(szCount, sizeof(szCount), "g%d", dwCount);
  485. break;
  486. case 3:
  487. _snprintf(szCount, sizeof(szCount), "p");
  488. break;
  489. }
  490.  
  491. if (!pSlot->pNumberLine)
  492. {
  493. CNumberLine* pNumberLine = new UI::CNumberLine(this);
  494. pNumberLine->SetHorizontalAlign(CNumberLine::HORIZONTAL_ALIGN_RIGHT);
  495. pNumberLine->Show();
  496. pSlot->pNumberLine = pNumberLine;
  497. }
  498.  
  499. pSlot->pNumberLine->SetNumber(szCount);
  500. }
  501. }
  502.  
  503. void CSlotWindow::SetSlotCoolTime(DWORD dwIndex, float fCoolTime, float fElapsedTime)
  504. {
  505. TSlot* pSlot;
  506. if (!GetSlotPointer(dwIndex, &pSlot))
  507. return;
  508.  
  509. pSlot->fCoolTime = fCoolTime;
  510. pSlot->fStartCoolTime = CTimer::Instance().GetCurrentSecond() - fElapsedTime;
  511. }
  512.  
  513. #if defined(__BL_ENABLE_PICKUP_ITEM_EFFECT__)
  514. D3DXCOLOR CSlotWindow::GetNewSlotColor(const BYTE blType) const
  515. {
  516. switch (blType)
  517. {
  518. case ESlotColor::COLOR_TYPE_ORANGE:
  519. return D3DXCOLOR(0xFFA500);
  520. case ESlotColor::COLOR_TYPE_WHITE:
  521. return D3DXCOLOR(0xFFFFFF);
  522. case ESlotColor::COLOR_TYPE_RED:
  523. return D3DXCOLOR(0xFF0000);
  524. case ESlotColor::COLOR_TYPE_GREEN:
  525. return D3DXCOLOR(0x008000);
  526. case ESlotColor::COLOR_TYPE_YELLOW:
  527. return D3DXCOLOR(0xFFFF00);
  528. case ESlotColor::COLOR_TYPE_SKY:
  529. return D3DXCOLOR(0x87CEFA);
  530. case ESlotColor::COLOR_TYPE_PINK:
  531. return D3DXCOLOR(0xFFC0CB);
  532. case ESlotColor::COLOR_TYPE_BLUE:
  533. return D3DXCOLOR(0x0000FF);
  534. case ESlotColor::COLOR_TYPE_DARK_BLUE:
  535. return D3DXCOLOR(0x00008B);
  536. case ESlotColor::COLOR_TYPE_PURPLE:
  537. return D3DXCOLOR(0x800080);
  538. case ESlotColor::COLOR_TYPE_GRAY:
  539. return D3DXCOLOR(0x800080);
  540. case ESlotColor::COLOR_TYPE_SILVER:
  541. return D3DXCOLOR(0xC0C0C0);
  542. }
  543.  
  544. return D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
  545. }
  546.  
  547. void CSlotWindow::SetNewSlotDiffuseColor(const DWORD dwIndex, const BYTE blType)
  548. {
  549. TSlot* pSlot;
  550. if (!GetSlotPointer(dwIndex, &pSlot))
  551. return;
  552.  
  553. const D3DXCOLOR color{ GetNewSlotColor(blType) };
  554. for (auto& NewSlotEffect : pSlot->pNewSlotEffect)
  555. {
  556. if (NewSlotEffect == nullptr)
  557. continue;
  558.  
  559. const auto& vecImage = NewSlotEffect->GetImageVector();
  560. if (vecImage.empty())
  561. continue;
  562.  
  563. for (CGraphicExpandedImageInstance* SlotImage : vecImage)
  564. {
  565. if (SlotImage == nullptr || SlotImage->IsEmpty())
  566. continue;
  567.  
  568. SlotImage->SetDiffuseColor(color.r, color.g, color.b, color.a);
  569. }
  570. }
  571. }
  572.  
  573. void CSlotWindow::ActivateNewSlot(const DWORD dwSlotIndex)
  574. {
  575. TSlot* pSlot;
  576. if (!GetSlotPointer(dwSlotIndex, &pSlot))
  577. return;
  578.  
  579. for (size_t i = 0; i < pSlot->pNewSlotEffect.size(); i++)
  580. {
  581. auto& NewSlotEffect = pSlot->pNewSlotEffect.at(i);
  582. if (NewSlotEffect == nullptr)
  583. {
  584. char buf[128];
  585. NewSlotEffect = std::make_shared< CAniImageBox >(nullptr);
  586.  
  587. for (BYTE j = 0; j < 13; j++)
  588. {
  589. if (i == 0)
  590. snprintf(buf, sizeof(buf), "d:/ymir work/ui/public/slotactiveeffect/%02d.sub", j);
  591. else
  592. snprintf(buf, sizeof(buf), "d:/ymir work/ui/public/slotactiveeffect/slot%d/%02d.sub", (i + 1), j);
  593.  
  594. NewSlotEffect->AppendImage(buf);
  595. NewSlotEffect->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN);
  596. }
  597. }
  598.  
  599. if (i == (pSlot->byyPlacedItemSize - 1))
  600. NewSlotEffect->Show();
  601. else
  602. NewSlotEffect->Hide();
  603. }
  604. }
  605.  
  606. void CSlotWindow::DeactivateNewSlot(const DWORD dwSlotIndex)
  607. {
  608. TSlot* pSlot;
  609. if (!GetSlotPointer(dwSlotIndex, &pSlot))
  610. return;
  611.  
  612. for (const auto& NewSlotEffect : pSlot->pNewSlotEffect)
  613. if (NewSlotEffect)
  614. NewSlotEffect->Hide();
  615.  
  616. /*Clear*/
  617. SetNewSlotDiffuseColor(dwSlotIndex, ESlotColor::COLOR_TYPE_MAX);
  618. SetNewSlotFlashEffect(dwSlotIndex, false);
  619. }
  620.  
  621. void CSlotWindow::SetNewSlotFlashEffect(const DWORD dwSlotIndex, const bool bActive)
  622. {
  623. TSlot* pSlot;
  624. if (!GetSlotPointer(dwSlotIndex, &pSlot))
  625. return;
  626.  
  627. pSlot->bFlashEffect = bActive;
  628. }
  629. #endif
  630.  
  631. void CSlotWindow::ActivateSlot(DWORD dwIndex)
  632. {
  633. TSlot* pSlot;
  634. if (!GetSlotPointer(dwIndex, &pSlot))
  635. return;
  636.  
  637. pSlot->bActive = TRUE;
  638.  
  639. if (!m_pSlotActiveEffect)
  640. {
  641. __CreateSlotEnableEffect();
  642. }
  643. }
  644.  
  645. void CSlotWindow::DeactivateSlot(DWORD dwIndex)
  646. {
  647. TSlot* pSlot;
  648. if (!GetSlotPointer(dwIndex, &pSlot))
  649. return;
  650.  
  651. pSlot->bActive = FALSE;
  652. }
  653.  
  654. void CSlotWindow::ClearSlot(DWORD dwIndex)
  655. {
  656. TSlot* pSlot;
  657. if (!GetSlotPointer(dwIndex, &pSlot))
  658. return;
  659.  
  660. ClearSlot(pSlot);
  661. }
  662.  
  663. void CSlotWindow::ClearSlot(TSlot* pSlot)
  664. {
  665. pSlot->bActive = FALSE;
  666. pSlot->byxPlacedItemSize = 1;
  667. pSlot->byyPlacedItemSize = 1;
  668.  
  669. pSlot->isItem = FALSE;
  670. pSlot->dwState = 0;
  671. pSlot->fCoolTime = 0.0f;
  672. pSlot->fStartCoolTime = 0.0f;
  673. pSlot->dwCenterSlotNumber = 0xffffffff;
  674.  
  675. pSlot->dwItemIndex = 0;
  676. pSlot->bRenderBaseSlotImage = true;
  677.  
  678. if (pSlot->pInstance)
  679. {
  680. CGraphicImageInstance::Delete(pSlot->pInstance);
  681. pSlot->pInstance = NULL;
  682. }
  683. if (pSlot->pCoverButton)
  684. {
  685. pSlot->pCoverButton->Hide();
  686. }
  687. if (pSlot->pSlotButton)
  688. {
  689. pSlot->pSlotButton->Hide();
  690. }
  691. if (pSlot->pSignImage)
  692. {
  693. pSlot->pSignImage->Hide();
  694. }
  695.  
  696. #if defined(__BL_ENABLE_PICKUP_ITEM_EFFECT__)
  697. for (const auto& NewSlotEffect : pSlot->pNewSlotEffect)
  698. {
  699. if (NewSlotEffect)
  700. NewSlotEffect->Hide();
  701. }
  702.  
  703. pSlot->bFlashEffect = false;
  704. #endif
  705.  
  706. if (pSlot->pFinishCoolTimeEffect)
  707. {
  708. pSlot->pFinishCoolTimeEffect->Hide();
  709. }
  710. }
  711.  
  712. void CSlotWindow::ClearAllSlot()
  713. {
  714. Destroy();
  715. }
  716.  
  717. void CSlotWindow::RefreshSlot()
  718. {
  719. OnRefreshSlot();
  720.  
  721. // NOTE : Refresh µÉ¶§ ToolTip µµ °»˝Ĺ ÇŐ´Ď´Ů - [levites]
  722. if (IsRendering())
  723. {
  724. TSlot* pSlot;
  725. if (GetPickedSlotPointer(&pSlot))
  726. {
  727. OnOverOutItem();
  728. OnOverInItem(pSlot->dwSlotNumber);
  729. }
  730. }
  731. }
  732.  
  733. void CSlotWindow::OnRefreshSlot()
  734. {
  735. }
  736.  
  737. DWORD CSlotWindow::GetSlotCount()
  738. {
  739. return m_SlotList.size();
  740. }
  741.  
  742. void CSlotWindow::LockSlot(DWORD dwIndex)
  743. {
  744. TSlot* pSlot;
  745. if (!GetSlotPointer(dwIndex, &pSlot))
  746. return;
  747.  
  748. pSlot->dwState |= SLOT_STATE_LOCK;
  749. }
  750. void CSlotWindow::UnlockSlot(DWORD dwIndex)
  751. {
  752. TSlot* pSlot;
  753. if (!GetSlotPointer(dwIndex, &pSlot))
  754. return;
  755.  
  756. pSlot->dwState ^= SLOT_STATE_LOCK;
  757. }
  758. void CSlotWindow::SetCantUseSlot(DWORD dwIndex)
  759. {
  760. TSlot* pSlot;
  761. if (!GetSlotPointer(dwIndex, &pSlot))
  762. return;
  763.  
  764. pSlot->dwState |= SLOT_STATE_CANT_USE;
  765. }
  766. void CSlotWindow::SetUseSlot(DWORD dwIndex)
  767. {
  768. TSlot* pSlot;
  769. if (!GetSlotPointer(dwIndex, &pSlot))
  770. return;
  771.  
  772. pSlot->dwState ^= SLOT_STATE_CANT_USE;
  773. }
  774. void CSlotWindow::EnableSlot(DWORD dwIndex)
  775. {
  776. TSlot* pSlot;
  777. if (!GetSlotPointer(dwIndex, &pSlot))
  778. return;
  779.  
  780. REMOVE_BIT(pSlot->dwState, SLOT_STATE_DISABLE);
  781. //pSlot->dwState |= SLOT_STATE_DISABLE;
  782. }
  783. void CSlotWindow::DisableSlot(DWORD dwIndex)
  784. {
  785. TSlot* pSlot;
  786. if (!GetSlotPointer(dwIndex, &pSlot))
  787. return;
  788. SET_BIT(pSlot->dwState, SLOT_STATE_DISABLE);
  789. //pSlot->dwState ^= SLOT_STATE_DISABLE;
  790. }
  791.  
  792. // Select
  793.  
  794. void CSlotWindow::SelectSlot(DWORD dwSelectingIndex)
  795. {
  796. std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  797. for (; itor != m_dwSelectedSlotIndexList.end();)
  798. {
  799. if (dwSelectingIndex == *itor)
  800. {
  801. itor = m_dwSelectedSlotIndexList.erase(itor);
  802. return;
  803. }
  804. else
  805. {
  806. ++itor;
  807. }
  808. }
  809.  
  810. TSlot* pSlot;
  811. if (GetSlotPointer(dwSelectingIndex, &pSlot))
  812. {
  813. if (!pSlot->isItem)
  814. return;
  815.  
  816. m_dwSelectedSlotIndexList.push_back(dwSelectingIndex);
  817. }
  818. }
  819.  
  820. BOOL CSlotWindow::isSelectedSlot(DWORD dwIndex)
  821. {
  822. std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  823. for (; itor != m_dwSelectedSlotIndexList.end(); ++itor)
  824. {
  825. if (dwIndex == *itor)
  826. return TRUE;
  827. }
  828.  
  829. return FALSE;
  830. }
  831.  
  832. void CSlotWindow::ClearSelected()
  833. {
  834. m_dwSelectedSlotIndexList.clear();
  835. }
  836.  
  837. DWORD CSlotWindow::GetSelectedSlotCount()
  838. {
  839. return m_dwSelectedSlotIndexList.size();
  840. }
  841.  
  842. DWORD CSlotWindow::GetSelectedSlotNumber(DWORD dwIndex)
  843. {
  844. if (dwIndex >= m_dwSelectedSlotIndexList.size())
  845. return DWORD(-1);
  846.  
  847. DWORD dwCount = 0;
  848. std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  849. for (; itor != m_dwSelectedSlotIndexList.end(); ++itor)
  850. {
  851. if (dwIndex == dwCount)
  852. break;
  853.  
  854. ++dwCount;
  855. }
  856.  
  857. return *itor;
  858. }
  859.  
  860. void CSlotWindow::ShowSlotButton(DWORD dwSlotNumber)
  861. {
  862. TSlot* pSlot;
  863. if (!GetSlotPointer(dwSlotNumber, &pSlot))
  864. return;
  865.  
  866. if (pSlot->pSlotButton)
  867. {
  868. pSlot->pSlotButton->Show();
  869. }
  870. }
  871.  
  872. void CSlotWindow::HideAllSlotButton()
  873. {
  874. for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  875. {
  876. TSlot& rSlot = *itor;
  877.  
  878. if (rSlot.pSlotButton)
  879. {
  880. rSlot.pSlotButton->Hide();
  881. }
  882. }
  883. }
  884.  
  885. void CSlotWindow::ShowRequirementSign(DWORD dwSlotNumber)
  886. {
  887. TSlot* pSlot;
  888. if (!GetSlotPointer(dwSlotNumber, &pSlot))
  889. return;
  890.  
  891. if (!pSlot->pSignImage)
  892. return;
  893.  
  894. pSlot->pSignImage->Show();
  895. }
  896.  
  897. void CSlotWindow::HideRequirementSign(DWORD dwSlotNumber)
  898. {
  899. TSlot* pSlot;
  900. if (!GetSlotPointer(dwSlotNumber, &pSlot))
  901. return;
  902.  
  903. if (!pSlot->pSignImage)
  904. return;
  905.  
  906. pSlot->pSignImage->Hide();
  907. }
  908.  
  909. // Event
  910.  
  911. BOOL CSlotWindow::OnMouseLeftButtonDown()
  912. {
  913. TSlot* pSlot;
  914. if (!GetPickedSlotPointer(&pSlot))
  915. {
  916. UI::CWindowManager::Instance().DeattachIcon();
  917. return TRUE;
  918. }
  919.  
  920. if (pSlot->isItem && !(pSlot->dwState & SLOT_STATE_LOCK))
  921. {
  922. OnSelectItemSlot(pSlot->dwSlotNumber);
  923. }
  924. else
  925. {
  926. OnSelectEmptySlot(pSlot->dwSlotNumber);
  927. }
  928.  
  929. return TRUE;
  930. }
  931.  
  932. BOOL CSlotWindow::OnMouseLeftButtonUp()
  933. {
  934. if (UI::CWindowManager::Instance().IsAttaching())
  935. if (UI::CWindowManager::Instance().IsDragging())
  936. if (IsIn())
  937. {
  938. UI::CWindow* pWin = UI::CWindowManager::Instance().GetPointWindow();
  939.  
  940. if (pWin)
  941. if (pWin->IsType(UI::CSlotWindow::Type()))
  942. {
  943. UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWin;
  944.  
  945. TSlot* pSlot;
  946. if (!pSlotWin->GetPickedSlotPointer(&pSlot))
  947. {
  948. UI::CWindowManager::Instance().DeattachIcon();
  949. return TRUE;
  950. }
  951.  
  952. if (pSlot->isItem)
  953. pSlotWin->OnSelectItemSlot(pSlot->dwSlotNumber);
  954. else
  955. pSlotWin->OnSelectEmptySlot(pSlot->dwSlotNumber);
  956.  
  957. return TRUE;
  958. }
  959.  
  960. return FALSE;
  961. }
  962.  
  963. return FALSE;
  964. }
  965.  
  966. BOOL CSlotWindow::OnMouseRightButtonDown()
  967. {
  968. TSlot* pSlot;
  969. if (!GetPickedSlotPointer(&pSlot))
  970. return TRUE;
  971.  
  972. if (pSlot->isItem)
  973. {
  974. OnUnselectItemSlot(pSlot->dwSlotNumber);
  975. }
  976. else
  977. {
  978. OnUnselectEmptySlot(pSlot->dwSlotNumber);
  979. }
  980.  
  981. return TRUE;
  982. }
  983.  
  984. BOOL CSlotWindow::OnMouseLeftButtonDoubleClick()
  985. {
  986. OnUseSlot();
  987.  
  988. return TRUE;
  989. }
  990.  
  991. void CSlotWindow::OnMouseOverOut()
  992. {
  993. OnOverOutItem();
  994. }
  995.  
  996. void CSlotWindow::OnMouseOver()
  997. {
  998. // FIXME : Ŕ©µµżě¸¦ µĺ·ˇ±ë ÇĎ´Â µµÁßżˇ SetTopŔĚ µÇľîąö¸®¸é Capture°ˇ Ç®ľîÁ® ąö¸°´Ů. ±×°ÍŔÇ ąćÁö ÄÚµĺ.
  999. // Á» ´ő ±Ůş»ŔűŔÎ ÇŘ°áĂĄŔ» ĂŁľĆľß ÇŇ µí - [levites]
  1000. // if (UI::CWindowManager::Instance().IsCapture())
  1001. // if (!UI::CWindowManager::Instance().IsAttaching())
  1002. // return;
  1003.  
  1004. CWindow* pPointWindow = UI::CWindowManager::Instance().GetPointWindow();
  1005. if (this == pPointWindow)
  1006. {
  1007. TSlot* pSlot;
  1008. if (GetPickedSlotPointer(&pSlot))
  1009. {
  1010. if (OnOverInItem(pSlot->dwSlotNumber))
  1011. return;
  1012. }
  1013. }
  1014.  
  1015. OnOverOutItem();
  1016. }
  1017.  
  1018. void CSlotWindow::OnSelectEmptySlot(int iSlotNumber)
  1019. {
  1020. PyCallClassMemberFunc(m_poHandler, "OnSelectEmptySlot", Py_BuildValue("(i)", iSlotNumber));
  1021. }
  1022. void CSlotWindow::OnSelectItemSlot(int iSlotNumber)
  1023. {
  1024. // OnOverOutItem();
  1025. PyCallClassMemberFunc(m_poHandler, "OnSelectItemSlot", Py_BuildValue("(i)", iSlotNumber));
  1026.  
  1027. if (UI::CWindowManager::Instance().IsAttaching())
  1028. OnOverOutItem();
  1029. }
  1030. void CSlotWindow::OnUnselectEmptySlot(int iSlotNumber)
  1031. {
  1032. PyCallClassMemberFunc(m_poHandler, "OnUnselectEmptySlot", Py_BuildValue("(i)", iSlotNumber));
  1033. }
  1034. void CSlotWindow::OnUnselectItemSlot(int iSlotNumber)
  1035. {
  1036. PyCallClassMemberFunc(m_poHandler, "OnUnselectItemSlot", Py_BuildValue("(i)", iSlotNumber));
  1037. }
  1038. void CSlotWindow::OnUseSlot()
  1039. {
  1040. TSlot* pSlot;
  1041. if (GetPickedSlotPointer(&pSlot))
  1042. if (pSlot->isItem)
  1043. {
  1044. PyCallClassMemberFunc(m_poHandler, "OnUseSlot", Py_BuildValue("(i)", pSlot->dwSlotNumber));
  1045. }
  1046. }
  1047.  
  1048. BOOL CSlotWindow::OnOverInItem(DWORD dwSlotNumber)
  1049. {
  1050. TSlot* pSlot;
  1051. if (!GetSlotPointer(dwSlotNumber, &pSlot))
  1052. return FALSE;
  1053.  
  1054. if (!pSlot->isItem)
  1055. return FALSE;
  1056.  
  1057. if (pSlot->dwSlotNumber == m_dwToolTipSlotNumber)
  1058. return TRUE;
  1059.  
  1060. m_dwToolTipSlotNumber = dwSlotNumber;
  1061. PyCallClassMemberFunc(m_poHandler, "OnOverInItem", Py_BuildValue("(i)", dwSlotNumber));
  1062.  
  1063. return TRUE;
  1064. }
  1065.  
  1066. void CSlotWindow::OnOverOutItem()
  1067. {
  1068. if (SLOT_NUMBER_NONE == m_dwToolTipSlotNumber)
  1069. return;
  1070.  
  1071. m_dwToolTipSlotNumber = SLOT_NUMBER_NONE;
  1072. PyCallClassMemberFunc(m_poHandler, "OnOverOutItem", Py_BuildValue("()"));
  1073. }
  1074.  
  1075. void CSlotWindow::OnPressedSlotButton(DWORD dwType, DWORD dwSlotNumber, BOOL isLeft)
  1076. {
  1077. if (CSlotButton::SLOT_BUTTON_TYPE_PLUS == dwType)
  1078. {
  1079. PyCallClassMemberFunc(m_poHandler, "OnPressedSlotButton", Py_BuildValue("(i)", dwSlotNumber));
  1080. }
  1081. else if (CSlotButton::SLOT_BUTTON_TYPE_COVER == dwType)
  1082. {
  1083. if (isLeft)
  1084. {
  1085. OnMouseLeftButtonDown();
  1086. }
  1087. }
  1088. }
  1089.  
  1090. void CSlotWindow::OnUpdate()
  1091. {
  1092. for (std::deque<DWORD>::iterator itor = m_ReserveDestroyEffectDeque.begin(); itor != m_ReserveDestroyEffectDeque.end(); ++itor)
  1093. {
  1094. DWORD dwSlotIndex = *itor;
  1095.  
  1096. TSlot* pSlot;
  1097. if (!GetSlotPointer(dwSlotIndex, &pSlot))
  1098. continue;
  1099.  
  1100. __DestroyFinishCoolTimeEffect(pSlot);
  1101. }
  1102. m_ReserveDestroyEffectDeque.clear();
  1103.  
  1104. if (m_pSlotActiveEffect)
  1105. m_pSlotActiveEffect->Update();
  1106. }
  1107.  
  1108. void CSlotWindow::OnRender()
  1109. {
  1110. RenderSlotBaseImage();
  1111.  
  1112. switch (m_dwSlotStyle)
  1113. {
  1114. case SLOT_STYLE_PICK_UP:
  1115. OnRenderPickingSlot();
  1116. break;
  1117. case SLOT_STYLE_SELECT:
  1118. OnRenderSelectedSlot();
  1119. break;
  1120. }
  1121.  
  1122. std::for_each(m_pChildList.begin(), m_pChildList.end(), std::void_mem_fun(&CWindow::OnRender));
  1123.  
  1124. TSlotListIterator itor;
  1125.  
  1126. //
  1127. // ¸đµç ˝˝·Ô »óŔÚ ±×¸®±â
  1128. //////////////////////////////////////////////////////////////////////////
  1129. #ifdef __RENDER_SLOT_AREA__
  1130. CPythonGraphic::Instance().SetDiffuseColor(0.5f, 0.5f, 0.5f);
  1131. for (itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1132. {
  1133. TSlot& rSlot = *itor;
  1134. CPythonGraphic::Instance().RenderBox2d(m_rect.left + rSlot.ixPosition,
  1135. m_rect.top + rSlot.iyPosition,
  1136. m_rect.left + rSlot.ixPosition + rSlot.ixCellSize,
  1137. m_rect.top + rSlot.iyPosition + rSlot.iyCellSize);
  1138. }
  1139. CPythonGraphic::Instance().SetDiffuseColor(1.0f, 0.0f, 0.0f, 1.0f);
  1140. CPythonGraphic::Instance().RenderBox2d(m_rect.left, m_rect.top, m_rect.right, m_rect.bottom);
  1141. #endif
  1142. //////////////////////////////////////////////////////////////////////////
  1143.  
  1144. for (itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1145. {
  1146. TSlot& rSlot = *itor;
  1147.  
  1148. if (rSlot.pSlotButton)
  1149. {
  1150. rSlot.pSlotButton->SetPosition(rSlot.ixPosition + 1, rSlot.iyPosition + 19);
  1151. }
  1152. if (rSlot.pSignImage)
  1153. {
  1154. rSlot.pSignImage->SetPosition(rSlot.ixPosition - 7, rSlot.iyPosition + 10);
  1155. }
  1156.  
  1157. #if defined(__BL_ENABLE_PICKUP_ITEM_EFFECT__)
  1158. static bool __bGrowing = false;
  1159. static float __fAlpha = 1.0f;
  1160. __fAlpha += 0.0003f * (__bGrowing ? 1.0f : -1.0f);
  1161.  
  1162. if (__fAlpha >= 1.0f || __fAlpha <= 0.0f)
  1163. __bGrowing = !__bGrowing;
  1164. #endif
  1165. if (rSlot.pInstance)
  1166. {
  1167. rSlot.pInstance->SetPosition(m_rect.left + rSlot.ixPosition, m_rect.top + rSlot.iyPosition);
  1168. #if defined(__BL_ENABLE_PICKUP_ITEM_EFFECT__)
  1169. rSlot.pInstance->GetDiffuseColor().a = rSlot.bFlashEffect ? __fAlpha : 1.0f;
  1170. #endif
  1171. rSlot.pInstance->Render();
  1172. }
  1173.  
  1174. if (!rSlot.isItem)
  1175. {
  1176. if (IS_SET(rSlot.dwState, SLOT_STATE_ALWAYS_RENDER_COVER))
  1177. {
  1178. rSlot.pCoverButton->Show();
  1179. rSlot.pCoverButton->SetPosition(rSlot.ixPosition, rSlot.iyPosition);
  1180. rSlot.pCoverButton->RenderButton();
  1181. }
  1182.  
  1183. continue;
  1184. }
  1185.  
  1186. if (IS_SET(rSlot.dwState, SLOT_STATE_DISABLE))
  1187. {
  1188. CPythonGraphic::Instance().SetDiffuseColor(1.0f, 0.0f, 0.0f, 0.3f);
  1189. CPythonGraphic::Instance().RenderBar2d(m_rect.left + rSlot.ixPosition,
  1190. m_rect.top + rSlot.iyPosition,
  1191. m_rect.left + rSlot.ixPosition + rSlot.ixCellSize,
  1192. m_rect.top + rSlot.iyPosition + rSlot.iyCellSize);
  1193. }
  1194.  
  1195. if (rSlot.fCoolTime != 0.0f)
  1196. {
  1197. float fcurTime = CTimer::Instance().GetCurrentSecond();
  1198. float fPercentage = (fcurTime - rSlot.fStartCoolTime) / rSlot.fCoolTime;
  1199. CPythonGraphic::Instance().RenderCoolTimeBox(m_rect.left + rSlot.ixPosition + 16.0f, m_rect.top + rSlot.iyPosition + 16.0f, 16.0f, fPercentage);
  1200.  
  1201. if (fcurTime - rSlot.fStartCoolTime >= rSlot.fCoolTime)
  1202. {
  1203. // ÄđŸŔÓŔĚ łˇł­Áö 1ĂĘ ŔĚł»¶ó¸é..
  1204. if ((fcurTime - rSlot.fStartCoolTime) - rSlot.fCoolTime < 1.0f)
  1205. __CreateFinishCoolTimeEffect(&rSlot);
  1206.  
  1207. rSlot.fCoolTime = 0.0f;
  1208. rSlot.fStartCoolTime = 0.0f;
  1209. }
  1210. }
  1211.  
  1212. if (rSlot.pCoverButton)
  1213. {
  1214. rSlot.pCoverButton->SetPosition(rSlot.ixPosition, rSlot.iyPosition);
  1215. rSlot.pCoverButton->RenderButton();
  1216. }
  1217.  
  1218. if (rSlot.pNumberLine)
  1219. {
  1220. int ix = rSlot.byxPlacedItemSize * ITEM_WIDTH + rSlot.ixPosition - 4;
  1221. int iy = rSlot.iyPosition + rSlot.byyPlacedItemSize * ITEM_HEIGHT - 12 + 2;
  1222.  
  1223. #if defined(__BL_ENABLE_PICKUP_ITEM_EFFECT__)
  1224. for (const auto& NumberImage : rSlot.pNumberLine->GetImageVector())
  1225. {
  1226. if (NumberImage)
  1227. NumberImage->GetDiffuseColor().a = rSlot.bFlashEffect ? __fAlpha : 1.0f;
  1228. }
  1229. #endif
  1230.  
  1231. rSlot.pNumberLine->SetPosition(ix, iy);
  1232. rSlot.pNumberLine->Update();
  1233. rSlot.pNumberLine->Render();
  1234. }
  1235.  
  1236. if (rSlot.pFinishCoolTimeEffect)
  1237. {
  1238. rSlot.pFinishCoolTimeEffect->SetPosition(rSlot.ixPosition, rSlot.iyPosition);
  1239. rSlot.pFinishCoolTimeEffect->Update();
  1240. rSlot.pFinishCoolTimeEffect->Render();
  1241. }
  1242.  
  1243. if (rSlot.bActive)
  1244. if (m_pSlotActiveEffect)
  1245. {
  1246. int ix = m_rect.left + rSlot.ixPosition;
  1247. int iy = m_rect.top + rSlot.iyPosition;
  1248. m_pSlotActiveEffect->SetPosition(ix, iy);
  1249. m_pSlotActiveEffect->Render();
  1250. }
  1251. }
  1252.  
  1253. #if defined(__BL_ENABLE_PICKUP_ITEM_EFFECT__)
  1254. for (const auto& NewSlotEffect : rSlot.pNewSlotEffect)
  1255. {
  1256. if (NewSlotEffect == nullptr || NewSlotEffect->IsShow() == false)
  1257. continue;
  1258.  
  1259. NewSlotEffect->SetPosition(m_rect.left + rSlot.ixPosition, m_rect.top + rSlot.iyPosition);
  1260. NewSlotEffect->Update();
  1261. NewSlotEffect->Render();
  1262. }
  1263. #endif
  1264.  
  1265. RenderLockedSlot();
  1266. }
  1267.  
  1268. void CSlotWindow::RenderSlotBaseImage()
  1269. {
  1270. if (!m_pBaseImageInstance)
  1271. return;
  1272.  
  1273. for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1274. {
  1275. TSlot& rSlot = *itor;
  1276.  
  1277. if (!rSlot.bRenderBaseSlotImage)
  1278. continue;
  1279.  
  1280. m_pBaseImageInstance->SetPosition(m_rect.left + rSlot.ixPosition, m_rect.top + rSlot.iyPosition);
  1281. m_pBaseImageInstance->Render();
  1282. }
  1283. }
  1284.  
  1285. void CSlotWindow::OnRenderPickingSlot()
  1286. {
  1287. if (!UI::CWindowManager::Instance().IsAttaching())
  1288. return;
  1289.  
  1290. TSlot* pSlot;
  1291. if (!GetSelectedSlotPointer(&pSlot))
  1292. return;
  1293.  
  1294. CPythonGraphic::Instance().SetDiffuseColor(1.0f, 1.0f, 1.0f, 0.5f);
  1295. CPythonGraphic::Instance().RenderBar2d(m_rect.left + pSlot->ixPosition,
  1296. m_rect.top + pSlot->iyPosition,
  1297. m_rect.left + pSlot->ixPosition + pSlot->ixCellSize,
  1298. m_rect.top + pSlot->iyPosition + pSlot->iyCellSize);
  1299. }
  1300.  
  1301. void CSlotWindow::OnRenderSelectedSlot()
  1302. {
  1303. std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  1304. for (; itor != m_dwSelectedSlotIndexList.end(); ++itor)
  1305. {
  1306. TSlot* pSlot;
  1307. if (!GetSlotPointer(*itor, &pSlot))
  1308. continue;
  1309.  
  1310. CPythonGraphic::Instance().SetDiffuseColor(1.0f, 1.0f, 1.0f, 0.5f);
  1311. CPythonGraphic::Instance().RenderBar2d(m_rect.left + pSlot->ixPosition,
  1312. m_rect.top + pSlot->iyPosition,
  1313. m_rect.left + pSlot->ixPosition + pSlot->ixCellSize,
  1314. m_rect.top + pSlot->iyPosition + pSlot->iyCellSize);
  1315. }
  1316. }
  1317.  
  1318. void CSlotWindow::RenderLockedSlot()
  1319. {
  1320. CPythonGraphic::Instance().SetDiffuseColor(0.0f, 0.0f, 0.0f, 0.5f);
  1321. for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1322. {
  1323. TSlot& rSlot = *itor;
  1324.  
  1325. if (!rSlot.isItem)
  1326. continue;
  1327.  
  1328. if (rSlot.dwState & SLOT_STATE_LOCK)
  1329. {
  1330. CPythonGraphic::Instance().RenderBar2d(m_rect.left + rSlot.ixPosition,
  1331. m_rect.top + rSlot.iyPosition,
  1332. m_rect.left + rSlot.ixPosition + rSlot.ixCellSize,
  1333. m_rect.top + rSlot.iyPosition + rSlot.iyCellSize);
  1334. }
  1335. }
  1336. }
  1337.  
  1338. // Check Slot
  1339.  
  1340. BOOL CSlotWindow::GetSlotPointer(DWORD dwIndex, TSlot** ppSlot)
  1341. {
  1342. for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1343. {
  1344. TSlot& rSlot = *itor;
  1345.  
  1346. if (dwIndex == rSlot.dwSlotNumber)
  1347. {
  1348. *ppSlot = &rSlot;
  1349. return TRUE;
  1350. }
  1351. }
  1352.  
  1353. return FALSE;
  1354. }
  1355.  
  1356. BOOL CSlotWindow::GetSelectedSlotPointer(TSlot** ppSlot)
  1357. {
  1358. long lx, ly;
  1359. GetMouseLocalPosition(lx, ly);
  1360.  
  1361. for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1362. {
  1363. TSlot& rSlot = *itor;
  1364.  
  1365. if (lx >= rSlot.ixPosition)
  1366. if (ly >= rSlot.iyPosition)
  1367. if (lx <= rSlot.ixPosition + rSlot.ixCellSize)
  1368. if (ly <= rSlot.iyPosition + rSlot.iyCellSize)
  1369. {
  1370. *ppSlot = &rSlot;
  1371. return TRUE;
  1372. }
  1373. }
  1374.  
  1375. return FALSE;
  1376. }
  1377.  
  1378. BOOL CSlotWindow::GetPickedSlotPointer(TSlot** ppSlot)
  1379. {
  1380. long lx, ly;
  1381. CWindowManager::Instance().GetMousePosition(lx, ly);
  1382.  
  1383. int ixLocal = lx - m_rect.left;
  1384. int iyLocal = ly - m_rect.top;
  1385.  
  1386. // NOTE : żŢÂĘ ¸ÇŔ§ »ó´Ü ÇŃ°÷ŔĚ ±âÁŘ Ŕ̶ó´Â ÁˇŔ» ŔĚżëÇŘ żŢÂĘ Ŕ§żˇĽ­şÎĹÍ żŔ¸ĄÂĘ ľĆ·ˇ·Î
  1387. // Â÷·Ę·Î °Ë»öÇŘ °¨Ŕ¸·Î˝á µ¤Çô ŔÖ´Â SlotŔş ŔÚµż ą«˝Ă µČ´Ů´Â ĆŻĽşŔ» ŔĚżëÇŃ´Ů. - [levites]
  1388. for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1389. {
  1390. TSlot& rSlot = *itor;
  1391.  
  1392. int ixCellSize = rSlot.ixCellSize;
  1393. int iyCellSize = rSlot.iyCellSize;
  1394.  
  1395. // NOTE : ItemŔĚ Hide µÇľîŔÖŔ» °ćżě¸¦ Ŕ§ÇŃ..
  1396. if (rSlot.isItem)
  1397. {
  1398. ixCellSize = max(rSlot.ixCellSize, int(rSlot.byxPlacedItemSize * ITEM_WIDTH));
  1399. iyCellSize = max(rSlot.iyCellSize, int(rSlot.byyPlacedItemSize * ITEM_HEIGHT));
  1400. }
  1401.  
  1402. if (ixLocal >= rSlot.ixPosition)
  1403. if (iyLocal >= rSlot.iyPosition)
  1404. if (ixLocal <= rSlot.ixPosition + ixCellSize)
  1405. if (iyLocal <= rSlot.iyPosition + iyCellSize)
  1406. {
  1407. *ppSlot = &rSlot;
  1408. return TRUE;
  1409. }
  1410. }
  1411.  
  1412. return FALSE;
  1413. }
  1414.  
  1415. void CSlotWindow::SetUseMode(BOOL bFlag)
  1416. {
  1417. m_isUseMode = bFlag;
  1418. }
  1419.  
  1420. void CSlotWindow::SetUsableItem(BOOL bFlag)
  1421. {
  1422. m_isUsableItem = bFlag;
  1423. }
  1424.  
  1425. void CSlotWindow::ReserveDestroyCoolTimeFinishEffect(DWORD dwSlotIndex)
  1426. {
  1427. m_ReserveDestroyEffectDeque.push_back(dwSlotIndex);
  1428. }
  1429.  
  1430. DWORD CSlotWindow::Type()
  1431. {
  1432. static int s_Type = GetCRC32("CSlotWindow", strlen("CSlotWindow"));
  1433. return s_Type;
  1434. }
  1435.  
  1436. BOOL CSlotWindow::OnIsType(DWORD dwType)
  1437. {
  1438. if (CSlotWindow::Type() == dwType)
  1439. return TRUE;
  1440.  
  1441. return CWindow::OnIsType(dwType);
  1442. }
  1443.  
  1444. void CSlotWindow::__CreateToggleSlotImage()
  1445. {
  1446. __DestroyToggleSlotImage();
  1447.  
  1448. m_pToggleSlotImage = new CImageBox(NULL);
  1449. m_pToggleSlotImage->LoadImage("d:/ymir work/ui/public/slot_toggle.sub");
  1450. m_pToggleSlotImage->Show();
  1451. }
  1452.  
  1453. void CSlotWindow::__CreateSlotEnableEffect()
  1454. {
  1455. __DestroySlotEnableEffect();
  1456.  
  1457. m_pSlotActiveEffect = new CAniImageBox(NULL);
  1458. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/00.sub");
  1459. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/01.sub");
  1460. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/02.sub");
  1461. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/03.sub");
  1462. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/04.sub");
  1463. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/05.sub");
  1464. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/06.sub");
  1465. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/07.sub");
  1466. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/08.sub");
  1467. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/09.sub");
  1468. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/10.sub");
  1469. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/11.sub");
  1470. m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/12.sub");
  1471. m_pSlotActiveEffect->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN);
  1472. m_pSlotActiveEffect->Show();
  1473. }
  1474.  
  1475. void CSlotWindow::__CreateFinishCoolTimeEffect(TSlot* pSlot)
  1476. {
  1477. __DestroyFinishCoolTimeEffect(pSlot);
  1478.  
  1479. CAniImageBox* pFinishCoolTimeEffect = new CCoolTimeFinishEffect(this, pSlot->dwSlotNumber);
  1480. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/00.sub");
  1481. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/01.sub");
  1482. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/02.sub");
  1483. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/03.sub");
  1484. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/04.sub");
  1485. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/05.sub");
  1486. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/06.sub");
  1487. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/07.sub");
  1488. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/08.sub");
  1489. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/09.sub");
  1490. pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/10.sub");
  1491. pFinishCoolTimeEffect->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN);
  1492. pFinishCoolTimeEffect->ResetFrame();
  1493. pFinishCoolTimeEffect->SetDelay(2);
  1494. pFinishCoolTimeEffect->Show();
  1495.  
  1496. pSlot->pFinishCoolTimeEffect = pFinishCoolTimeEffect;
  1497. }
  1498.  
  1499. void CSlotWindow::__CreateBaseImage(const char* c_szFileName, float fr, float fg, float fb, float fa)
  1500. {
  1501. __DestroyBaseImage();
  1502.  
  1503. CGraphicImage* pImage = (CGraphicImage*)CResourceManager::Instance().GetResourcePointer(c_szFileName);
  1504. m_pBaseImageInstance = CGraphicImageInstance::New();
  1505. m_pBaseImageInstance->SetImagePointer(pImage);
  1506. m_pBaseImageInstance->SetDiffuseColor(fr, fg, fb, fa);
  1507. }
  1508.  
  1509. void CSlotWindow::__DestroyToggleSlotImage()
  1510. {
  1511. if (m_pToggleSlotImage)
  1512. {
  1513. delete m_pToggleSlotImage;
  1514. m_pToggleSlotImage = NULL;
  1515. }
  1516. }
  1517.  
  1518. void CSlotWindow::__DestroySlotEnableEffect()
  1519. {
  1520. if (m_pSlotActiveEffect)
  1521. {
  1522. delete m_pSlotActiveEffect;
  1523. m_pSlotActiveEffect = NULL;
  1524. }
  1525. }
  1526.  
  1527. void CSlotWindow::__DestroyFinishCoolTimeEffect(TSlot* pSlot)
  1528. {
  1529. if (pSlot->pFinishCoolTimeEffect)
  1530. {
  1531. delete pSlot->pFinishCoolTimeEffect;
  1532. pSlot->pFinishCoolTimeEffect = NULL;
  1533. }
  1534. }
  1535.  
  1536. void CSlotWindow::__DestroyBaseImage()
  1537. {
  1538. if (m_pBaseImageInstance)
  1539. {
  1540. CGraphicImageInstance::Delete(m_pBaseImageInstance);
  1541. m_pBaseImageInstance = NULL;
  1542. }
  1543. }
  1544.  
  1545. void CSlotWindow::__Initialize()
  1546. {
  1547. m_dwSlotType = 0;
  1548. m_dwSlotStyle = SLOT_STYLE_PICK_UP;
  1549. m_dwToolTipSlotNumber = SLOT_NUMBER_NONE;
  1550.  
  1551. m_isUseMode = FALSE;
  1552. m_isUsableItem = FALSE;
  1553.  
  1554. m_pToggleSlotImage = NULL;
  1555. m_pSlotActiveEffect = NULL;
  1556. m_pBaseImageInstance = NULL;
  1557. }
  1558.  
  1559. void CSlotWindow::Destroy()
  1560. {
  1561. for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1562. {
  1563. TSlot& rSlot = *itor;
  1564.  
  1565. ClearSlot(&rSlot);
  1566.  
  1567. if (rSlot.pNumberLine)
  1568. {
  1569. delete rSlot.pNumberLine;
  1570. rSlot.pNumberLine = NULL;
  1571. }
  1572. if (rSlot.pCoverButton)
  1573. {
  1574. CWindowManager::Instance().DestroyWindow(rSlot.pCoverButton);
  1575. }
  1576. if (rSlot.pSlotButton)
  1577. {
  1578. CWindowManager::Instance().DestroyWindow(rSlot.pSlotButton);
  1579. }
  1580. if (rSlot.pSignImage)
  1581. {
  1582. CWindowManager::Instance().DestroyWindow(rSlot.pSignImage);
  1583. }
  1584. if (rSlot.pFinishCoolTimeEffect)
  1585. {
  1586. CWindowManager::Instance().DestroyWindow(rSlot.pFinishCoolTimeEffect);
  1587. }
  1588. }
  1589.  
  1590. m_SlotList.clear();
  1591.  
  1592. __DestroyToggleSlotImage();
  1593. __DestroySlotEnableEffect();
  1594. __DestroyBaseImage();
  1595.  
  1596. __Initialize();
  1597. }
  1598.  
  1599. CSlotWindow::CSlotWindow(PyObject* ppyObject) : CWindow(ppyObject)
  1600. {
  1601. __Initialize();
  1602. }
  1603.  
  1604. CSlotWindow::~CSlotWindow()
  1605. {
  1606. Destroy();
  1607. }
  1608.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement