Advertisement
Guest User

Untitled

a guest
Oct 12th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 36.49 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. #ifdef ENABLE_ACCE_SYSTEM
  222.     for (int i = 0; i < 3; ++i)
  223.     {
  224.         Slot.pActiveSlotEffect[i] = NULL;
  225.     }
  226. #endif
  227.  
  228.     ClearSlot(&Slot);
  229.     Slot.dwSlotNumber = dwIndex;
  230.     Slot.dwCenterSlotNumber = dwIndex;
  231.     Slot.ixPosition = ixPosition;
  232.     Slot.iyPosition = iyPosition;
  233.     Slot.ixCellSize = ixCellSize;
  234.     Slot.iyCellSize = iyCellSize;
  235.     m_SlotList.push_back(Slot);
  236. }
  237.  
  238. 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)
  239. {
  240.     TSlot * pSlot;
  241.     if (!GetSlotPointer(dwIndex, &pSlot))
  242.         return;
  243.  
  244.     CCoverButton *& rpCoverButton = pSlot->pCoverButton;
  245.  
  246.     if (!rpCoverButton)
  247.     {
  248.         rpCoverButton = new CCoverButton(CSlotButton::SLOT_BUTTON_TYPE_COVER, pSlot->dwSlotNumber, this);
  249.         CWindowManager::Instance().SetParent(rpCoverButton, this);
  250.     }
  251.  
  252.     rpCoverButton->SetLeftButtonEnable(bLeftButtonEnable);
  253.     rpCoverButton->SetRightButtonEnable(bRightButtonEnable);
  254.     rpCoverButton->SetUpVisual(c_szUpImageName);
  255.     rpCoverButton->SetOverVisual(c_szOverImageName);
  256.     rpCoverButton->SetDownVisual(c_szDownImageName);
  257.     rpCoverButton->SetDisableVisual(c_szDisableImageName);
  258.     rpCoverButton->Enable();
  259.     rpCoverButton->Show();
  260.  
  261.     // NOTE : Cover 버튼이 Plus 버튼을 가려버려서 임시 코드를..
  262.     if (pSlot->pSlotButton)
  263.     {
  264.         SetTop(pSlot->pSlotButton);
  265.     }
  266. }
  267.  
  268. void CSlotWindow::EnableCoverButton(DWORD dwIndex)
  269. {
  270.     TSlot * pSlot;
  271.     if (!GetSlotPointer(dwIndex, &pSlot))
  272.         return;
  273.  
  274.     if (!pSlot->pCoverButton)
  275.         return;
  276.  
  277.     pSlot->pCoverButton->Enable();
  278. }
  279.  
  280. void CSlotWindow::DisableCoverButton(DWORD dwIndex)
  281. {
  282.     TSlot * pSlot;
  283.     if (!GetSlotPointer(dwIndex, &pSlot))
  284.         return;
  285.  
  286.     if (!pSlot->pCoverButton)
  287.         return;
  288.  
  289.     pSlot->pCoverButton->Disable();
  290. }
  291.  
  292. void CSlotWindow::SetAlwaysRenderCoverButton(DWORD dwIndex, bool bAlwaysRender)
  293. {
  294.     TSlot * pSlot;
  295.     if (!GetSlotPointer(dwIndex, &pSlot))
  296.         return;
  297.  
  298.     if (bAlwaysRender)
  299.         SET_BIT(pSlot->dwState, SLOT_STATE_ALWAYS_RENDER_COVER);
  300.     else
  301.         REMOVE_BIT(pSlot->dwState, SLOT_STATE_ALWAYS_RENDER_COVER);
  302. }
  303.  
  304. void CSlotWindow::ShowSlotBaseImage(DWORD dwIndex)
  305. {
  306.     TSlot * pSlot;
  307.     if (!GetSlotPointer(dwIndex, &pSlot))
  308.         return;
  309.  
  310.     pSlot->bRenderBaseSlotImage = true;
  311. }
  312.  
  313. void CSlotWindow::HideSlotBaseImage(DWORD dwIndex)
  314. {
  315.     TSlot * pSlot;
  316.     if (!GetSlotPointer(dwIndex, &pSlot))
  317.         return;
  318.  
  319.     pSlot->bRenderBaseSlotImage = false;
  320. }
  321.  
  322. BOOL CSlotWindow::IsDisableCoverButton(DWORD dwIndex)
  323. {
  324.     TSlot * pSlot;
  325.     if (!GetSlotPointer(dwIndex, &pSlot))
  326.         return FALSE;
  327.  
  328.     if (!pSlot->pCoverButton)
  329.         return FALSE;
  330.  
  331.     return pSlot->pCoverButton->IsDisable();
  332. }
  333.  
  334. void CSlotWindow::SetSlotBaseImage(const char * c_szFileName, float fr, float fg, float fb, float fa)
  335. {
  336.     __CreateBaseImage(c_szFileName, fr, fg, fb, fa);
  337. }
  338.  
  339. void CSlotWindow::AppendSlotButton(const char * c_szUpImageName, const char * c_szOverImageName, const char * c_szDownImageName)
  340. {
  341.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  342.     {
  343.         TSlot & rSlot = *itor;
  344.         CSlotButton *& rpSlotButton = rSlot.pSlotButton;
  345.  
  346.         if (!rpSlotButton)
  347.         {
  348.             rpSlotButton = new CSlotButton(CSlotButton::SLOT_BUTTON_TYPE_PLUS, rSlot.dwSlotNumber, this);
  349.             rpSlotButton->AddFlag(FLAG_FLOAT);
  350.             CWindowManager::Instance().SetParent(rpSlotButton, this);
  351.         }
  352.  
  353.         rpSlotButton->SetUpVisual(c_szUpImageName);
  354.         rpSlotButton->SetOverVisual(c_szOverImageName);
  355.         rpSlotButton->SetDownVisual(c_szDownImageName);
  356.         rpSlotButton->SetPosition(rSlot.ixPosition + 1, rSlot.iyPosition + 19);
  357.         rpSlotButton->Hide();
  358.     }
  359. }
  360.  
  361. void CSlotWindow::AppendRequirementSignImage(const char * c_szImageName)
  362. {
  363.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  364.     {
  365.         TSlot & rSlot = *itor;
  366.         CImageBox *& rpSignImage = rSlot.pSignImage;
  367.  
  368.         if (!rpSignImage)
  369.         {
  370.             rpSignImage = new CImageBox(NULL);
  371.             CWindowManager::Instance().SetParent(rpSignImage, this);
  372.         }
  373.  
  374.         rpSignImage->LoadImage(c_szImageName);
  375.         rpSignImage->Hide();
  376.     }
  377. }
  378.  
  379. BOOL CSlotWindow::HasSlot(DWORD dwIndex)
  380. {
  381.     TSlot * pSlot;
  382.     if (!GetSlotPointer(dwIndex, &pSlot))
  383.         return FALSE;
  384.  
  385.     return TRUE;
  386. }
  387.  
  388. void CSlotWindow::SetSlot(DWORD dwIndex, DWORD dwVirtualNumber, BYTE byWidth, BYTE byHeight, CGraphicImage * pImage, D3DXCOLOR& diffuseColor)
  389. {
  390.     TSlot * pSlot;
  391.     if (!GetSlotPointer(dwIndex, &pSlot))
  392.         return;
  393.  
  394.     if (pSlot->isItem)
  395.     if (pSlot->dwItemIndex == dwVirtualNumber)
  396.     {
  397.         pSlot->dwState = 0;
  398.         pSlot->isItem = TRUE;
  399.         if (pImage && pSlot->pInstance)
  400.         {
  401.             pSlot->pInstance->SetImagePointer(pImage);
  402.         }
  403.         return;
  404.     }
  405.  
  406.     ClearSlot(pSlot);
  407.     pSlot->dwState = 0;
  408.     pSlot->isItem = TRUE;
  409.     pSlot->dwItemIndex = dwVirtualNumber;
  410.  
  411.     if (pImage)
  412.     {
  413.         assert(NULL == pSlot->pInstance);
  414.         pSlot->pInstance = CGraphicImageInstance::New();
  415.         pSlot->pInstance->SetDiffuseColor(diffuseColor.r, diffuseColor.g, diffuseColor.b, diffuseColor.a);
  416.         pSlot->pInstance->SetImagePointer(pImage);
  417.     }
  418.  
  419.     pSlot->byxPlacedItemSize = byWidth;
  420.     pSlot->byyPlacedItemSize = byHeight;
  421.  
  422.     if (pSlot->pCoverButton)
  423.     {
  424.         pSlot->pCoverButton->Show();
  425.     }
  426. }
  427.  
  428. void CSlotWindow::SetSlotCount(DWORD dwIndex, DWORD dwCount)
  429. {
  430.     TSlot * pSlot;
  431.     if (!GetSlotPointer(dwIndex, &pSlot))
  432.         return;
  433.  
  434.     if (dwCount <= 0)
  435.     {
  436.         if (pSlot->pNumberLine)
  437.         {
  438.             delete pSlot->pNumberLine;
  439.             pSlot->pNumberLine = NULL;
  440.         }
  441.     }
  442.     else
  443.     {
  444.         char szCount[16+1];
  445.         _snprintf(szCount, sizeof(szCount), "%d", dwCount);
  446.  
  447.         if (!pSlot->pNumberLine)
  448.         {
  449.             CNumberLine * pNumberLine = new UI::CNumberLine(this);
  450.             pNumberLine->SetHorizontalAlign(CNumberLine::HORIZONTAL_ALIGN_RIGHT);
  451.             pNumberLine->Show();
  452.             pSlot->pNumberLine = pNumberLine;
  453.         }
  454.  
  455.         pSlot->pNumberLine->SetNumber(szCount);
  456.     }
  457. }
  458.  
  459. void CSlotWindow::SetSlotCountNew(DWORD dwIndex, DWORD dwGrade, DWORD dwCount)
  460. {
  461.     TSlot * pSlot;
  462.     if (!GetSlotPointer(dwIndex, &pSlot))
  463.         return;
  464.  
  465.     if (dwCount <= 0)
  466.     {
  467.         if (pSlot->pNumberLine)
  468.         {
  469.             delete pSlot->pNumberLine;
  470.             pSlot->pNumberLine = NULL;
  471.         }
  472.     }
  473.     else
  474.     {
  475.         char szCount[16+1];
  476.  
  477.         switch (dwGrade)
  478.         {
  479.             case 0:
  480.                 _snprintf(szCount, sizeof(szCount), "%d", dwCount);
  481.                 break;
  482.             case 1:
  483.                 _snprintf(szCount, sizeof(szCount), "m%d", dwCount);
  484.                 break;
  485.             case 2:
  486.                 _snprintf(szCount, sizeof(szCount), "g%d", dwCount);
  487.                 break;
  488.             case 3:
  489.                 _snprintf(szCount, sizeof(szCount), "p");
  490.                 break;
  491.         }
  492.  
  493.         if (!pSlot->pNumberLine)
  494.         {
  495.             CNumberLine * pNumberLine = new UI::CNumberLine(this);
  496.             pNumberLine->SetHorizontalAlign(CNumberLine::HORIZONTAL_ALIGN_RIGHT);
  497.             pNumberLine->Show();
  498.             pSlot->pNumberLine = pNumberLine;
  499.         }
  500.  
  501.         pSlot->pNumberLine->SetNumber(szCount);
  502.     }
  503. }
  504.  
  505. void CSlotWindow::SetSlotCoolTime(DWORD dwIndex, float fCoolTime, float fElapsedTime)
  506. {
  507.     TSlot * pSlot;
  508.     if (!GetSlotPointer(dwIndex, &pSlot))
  509.         return;
  510.  
  511.     pSlot->fCoolTime = fCoolTime;
  512.     pSlot->fStartCoolTime = CTimer::Instance().GetCurrentSecond() - fElapsedTime;
  513. }
  514.  
  515. void CSlotWindow::ActivateSlot(DWORD dwIndex)
  516. {
  517.     TSlot * pSlot;
  518.     if (!GetSlotPointer(dwIndex, &pSlot))
  519.         return;
  520.  
  521.     pSlot->bActive = TRUE;
  522.  
  523.     if (!m_pSlotActiveEffect)
  524.     {
  525.         __CreateSlotEnableEffect();
  526.     }
  527. }
  528.  
  529. void CSlotWindow::DeactivateSlot(DWORD dwIndex)
  530. {
  531.     TSlot * pSlot;
  532.     if (!GetSlotPointer(dwIndex, &pSlot))
  533.         return;
  534.  
  535.     pSlot->bActive = FALSE;
  536. }
  537.  
  538. void CSlotWindow::ClearSlot(DWORD dwIndex)
  539. {
  540.     TSlot * pSlot;
  541.     if (!GetSlotPointer(dwIndex, &pSlot))
  542.         return;
  543.  
  544.     ClearSlot(pSlot);
  545. }
  546.  
  547. void CSlotWindow::ClearSlot(TSlot * pSlot)
  548. {
  549.     pSlot->bActive = FALSE;
  550.     pSlot->byxPlacedItemSize = 1;
  551.     pSlot->byyPlacedItemSize = 1;
  552.  
  553.     pSlot->isItem = FALSE;
  554.     pSlot->dwState = 0;
  555.     pSlot->fCoolTime = 0.0f;
  556.     pSlot->fStartCoolTime = 0.0f;
  557.     pSlot->dwCenterSlotNumber = 0xffffffff;
  558.  
  559.     pSlot->dwItemIndex = 0;
  560.     pSlot->bRenderBaseSlotImage = true;
  561.  
  562.     if (pSlot->pInstance)
  563.     {
  564.         CGraphicImageInstance::Delete(pSlot->pInstance);
  565.         pSlot->pInstance = NULL;
  566.     }
  567.     if (pSlot->pCoverButton)
  568.     {
  569.         pSlot->pCoverButton->Hide();
  570.     }
  571.     if (pSlot->pSlotButton)
  572.     {
  573.         pSlot->pSlotButton->Hide();
  574.     }
  575.     if (pSlot->pSignImage)
  576.     {
  577.         pSlot->pSignImage->Hide();
  578.     }
  579.     if (pSlot->pFinishCoolTimeEffect)
  580.     {
  581.         pSlot->pFinishCoolTimeEffect->Hide();
  582.     }
  583. #ifdef ENABLE_ACCE_SYSTEM
  584.     for (int i = 0; i < 3; ++i)
  585.     {
  586.         if (pSlot->pActiveSlotEffect[i])
  587.             pSlot->pActiveSlotEffect[i]->Hide();
  588.     }
  589. #endif
  590. }
  591.  
  592. void CSlotWindow::ClearAllSlot()
  593. {
  594.     Destroy();
  595. }
  596.  
  597. void CSlotWindow::RefreshSlot()
  598. {
  599.     OnRefreshSlot();
  600.  
  601.     // NOTE : Refresh 될때 ToolTip 도 갱신 합니다 - [levites]
  602.     if (IsRendering())
  603.     {
  604.         TSlot * pSlot;
  605.         if (GetPickedSlotPointer(&pSlot))
  606.         {
  607.             OnOverOutItem();
  608.             OnOverInItem(pSlot->dwSlotNumber);
  609.         }
  610.     }
  611. }
  612.  
  613. void CSlotWindow::OnRefreshSlot()
  614. {
  615. }
  616.  
  617. DWORD CSlotWindow::GetSlotCount()
  618. {
  619.     return m_SlotList.size();
  620. }
  621.  
  622. void CSlotWindow::LockSlot(DWORD dwIndex)
  623. {
  624.     TSlot * pSlot;
  625.     if (!GetSlotPointer(dwIndex, &pSlot))
  626.         return;
  627.  
  628.     pSlot->dwState |= SLOT_STATE_LOCK;
  629. }
  630. void CSlotWindow::UnlockSlot(DWORD dwIndex)
  631. {
  632.     TSlot * pSlot;
  633.     if (!GetSlotPointer(dwIndex, &pSlot))
  634.         return;
  635.  
  636.     pSlot->dwState ^= SLOT_STATE_LOCK;
  637. }
  638. void CSlotWindow::SetCantUseSlot(DWORD dwIndex)
  639. {
  640.     TSlot * pSlot;
  641.     if (!GetSlotPointer(dwIndex, &pSlot))
  642.         return;
  643.  
  644.     pSlot->dwState |= SLOT_STATE_CANT_USE;
  645. }
  646. void CSlotWindow::SetUseSlot(DWORD dwIndex)
  647. {
  648.     TSlot * pSlot;
  649.     if (!GetSlotPointer(dwIndex, &pSlot))
  650.         return;
  651.  
  652.     pSlot->dwState ^= SLOT_STATE_CANT_USE;
  653. }
  654. void CSlotWindow::EnableSlot(DWORD dwIndex)
  655. {
  656.     TSlot * pSlot;
  657.     if (!GetSlotPointer(dwIndex, &pSlot))
  658.         return;
  659.  
  660.     REMOVE_BIT(pSlot->dwState, SLOT_STATE_DISABLE);
  661.     //pSlot->dwState |= SLOT_STATE_DISABLE;
  662. }
  663. void CSlotWindow::DisableSlot(DWORD dwIndex)
  664. {
  665.     TSlot * pSlot;
  666.     if (!GetSlotPointer(dwIndex, &pSlot))
  667.         return;
  668.     SET_BIT(pSlot->dwState, SLOT_STATE_DISABLE);
  669.     //pSlot->dwState ^= SLOT_STATE_DISABLE;
  670. }
  671.  
  672. // Select
  673.  
  674. void CSlotWindow::SelectSlot(DWORD dwSelectingIndex)
  675. {
  676.     std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  677.     for (; itor != m_dwSelectedSlotIndexList.end();)
  678.     {
  679.         if (dwSelectingIndex == *itor)
  680.         {
  681.             itor = m_dwSelectedSlotIndexList.erase(itor);
  682.             return;
  683.         }
  684.         else
  685.         {
  686.             ++itor;
  687.         }
  688.     }
  689.  
  690.     TSlot * pSlot;
  691.     if (GetSlotPointer(dwSelectingIndex, &pSlot))
  692.     {
  693.         if (!pSlot->isItem)
  694.             return;
  695.  
  696.         m_dwSelectedSlotIndexList.push_back(dwSelectingIndex);
  697.     }
  698. }
  699.  
  700. BOOL CSlotWindow::isSelectedSlot(DWORD dwIndex)
  701. {
  702.     std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  703.     for (; itor != m_dwSelectedSlotIndexList.end(); ++itor)
  704.     {
  705.         if (dwIndex == *itor)
  706.             return TRUE;
  707.     }
  708.  
  709.     return FALSE;
  710. }
  711.  
  712. void CSlotWindow::ClearSelected()
  713. {
  714.     m_dwSelectedSlotIndexList.clear();
  715. }
  716.  
  717. DWORD CSlotWindow::GetSelectedSlotCount()
  718. {
  719.     return m_dwSelectedSlotIndexList.size();
  720. }
  721.  
  722. DWORD CSlotWindow::GetSelectedSlotNumber(DWORD dwIndex)
  723. {
  724.     if (dwIndex >= m_dwSelectedSlotIndexList.size())
  725.         return DWORD(-1);
  726.  
  727.     DWORD dwCount = 0;
  728.     std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  729.     for (; itor != m_dwSelectedSlotIndexList.end(); ++itor)
  730.     {
  731.         if (dwIndex == dwCount)
  732.             break;
  733.  
  734.         ++dwCount;
  735.     }
  736.  
  737.     return *itor;
  738. }
  739.  
  740. void CSlotWindow::ShowSlotButton(DWORD dwSlotNumber)
  741. {
  742.     TSlot * pSlot;
  743.     if (!GetSlotPointer(dwSlotNumber, &pSlot))
  744.         return;
  745.  
  746.     if (pSlot->pSlotButton)
  747.     {
  748.         pSlot->pSlotButton->Show();
  749.     }
  750. }
  751.  
  752. void CSlotWindow::HideAllSlotButton()
  753. {
  754.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  755.     {
  756.         TSlot & rSlot = *itor;
  757.  
  758.         if (rSlot.pSlotButton)
  759.         {
  760.             rSlot.pSlotButton->Hide();
  761.         }
  762.     }
  763. }
  764.  
  765. void CSlotWindow::ShowRequirementSign(DWORD dwSlotNumber)
  766. {
  767.     TSlot * pSlot;
  768.     if (!GetSlotPointer(dwSlotNumber, &pSlot))
  769.         return;
  770.  
  771.     if (!pSlot->pSignImage)
  772.         return;
  773.  
  774.     pSlot->pSignImage->Show();
  775. }
  776.  
  777. void CSlotWindow::HideRequirementSign(DWORD dwSlotNumber)
  778. {
  779.     TSlot * pSlot;
  780.     if (!GetSlotPointer(dwSlotNumber, &pSlot))
  781.         return;
  782.  
  783.     if (!pSlot->pSignImage)
  784.         return;
  785.  
  786.     pSlot->pSignImage->Hide();
  787. }
  788.  
  789. // Event
  790.  
  791. BOOL CSlotWindow::OnMouseLeftButtonDown()
  792. {
  793.     TSlot * pSlot;
  794.     if (!GetPickedSlotPointer(&pSlot))
  795.     {
  796.         UI::CWindowManager::Instance().DeattachIcon();
  797.         return TRUE;
  798.     }
  799.  
  800.     if (pSlot->isItem && !(pSlot->dwState & SLOT_STATE_LOCK))
  801.     {
  802.         OnSelectItemSlot(pSlot->dwSlotNumber);
  803.     }
  804.     else
  805.     {
  806.         OnSelectEmptySlot(pSlot->dwSlotNumber);
  807.     }
  808.  
  809.     return TRUE;
  810. }
  811.  
  812. BOOL CSlotWindow::OnMouseLeftButtonUp()
  813. {
  814.     if (UI::CWindowManager::Instance().IsAttaching())
  815.     if (UI::CWindowManager::Instance().IsDragging())
  816.     if (IsIn())
  817.     {
  818.         UI::CWindow * pWin = UI::CWindowManager::Instance().GetPointWindow();
  819.  
  820.         if (pWin)
  821.         if (pWin->IsType(UI::CSlotWindow::Type()))
  822.         {
  823.             UI::CSlotWindow * pSlotWin = (UI::CSlotWindow *)pWin;
  824.  
  825.             TSlot * pSlot;
  826.             if (!pSlotWin->GetPickedSlotPointer(&pSlot))
  827.             {
  828.                 UI::CWindowManager::Instance().DeattachIcon();
  829.                 return TRUE;
  830.             }
  831.  
  832.             if (pSlot->isItem)
  833.                 pSlotWin->OnSelectItemSlot(pSlot->dwSlotNumber);
  834.             else
  835.                 pSlotWin->OnSelectEmptySlot(pSlot->dwSlotNumber);
  836.  
  837.             return TRUE;
  838.         }
  839.  
  840.         return FALSE;
  841.     }
  842.  
  843.     return FALSE;
  844. }
  845.  
  846. BOOL CSlotWindow::OnMouseRightButtonDown()
  847. {
  848.     TSlot * pSlot;
  849.     if (!GetPickedSlotPointer(&pSlot))
  850.         return TRUE;
  851.  
  852.     if (pSlot->isItem)
  853.     {
  854.         OnUnselectItemSlot(pSlot->dwSlotNumber);
  855.     }
  856.     else
  857.     {
  858.         OnUnselectEmptySlot(pSlot->dwSlotNumber);
  859.     }
  860.  
  861.     return TRUE;
  862. }
  863.  
  864. BOOL CSlotWindow::OnMouseLeftButtonDoubleClick()
  865. {
  866.     OnUseSlot();
  867.  
  868.     return TRUE;
  869. }
  870.  
  871. void CSlotWindow::OnMouseOverOut()
  872. {
  873.     OnOverOutItem();
  874. }
  875.  
  876. void CSlotWindow::OnMouseOver()
  877. {
  878.     // FIXME : 윈도우를 드래깅 하는 도중에 SetTop이 되어버리면 Capture가 풀어져 버린다. 그것의 방지 코드.
  879.     //         좀 더 근본적인 해결책을 찾아야 할 듯 - [levites]
  880. //  if (UI::CWindowManager::Instance().IsCapture())
  881. //  if (!UI::CWindowManager::Instance().IsAttaching())
  882. //      return;
  883.  
  884.     CWindow * pPointWindow = UI::CWindowManager::Instance().GetPointWindow();
  885.     if (this == pPointWindow)
  886.     {
  887.         TSlot * pSlot;
  888.         if (GetPickedSlotPointer(&pSlot))
  889.         {
  890.             if (OnOverInItem(pSlot->dwSlotNumber))
  891.                 return;
  892.         }
  893.     }
  894.  
  895.     OnOverOutItem();
  896. }
  897.  
  898. void CSlotWindow::OnSelectEmptySlot(int iSlotNumber)
  899. {
  900.     PyCallClassMemberFunc(m_poHandler, "OnSelectEmptySlot", Py_BuildValue("(i)", iSlotNumber));
  901. }
  902. void CSlotWindow::OnSelectItemSlot(int iSlotNumber)
  903. {
  904. //  OnOverOutItem();
  905.     PyCallClassMemberFunc(m_poHandler, "OnSelectItemSlot", Py_BuildValue("(i)", iSlotNumber));
  906.  
  907.     if (UI::CWindowManager::Instance().IsAttaching())
  908.         OnOverOutItem();
  909. }
  910. void CSlotWindow::OnUnselectEmptySlot(int iSlotNumber)
  911. {
  912.     PyCallClassMemberFunc(m_poHandler, "OnUnselectEmptySlot", Py_BuildValue("(i)", iSlotNumber));
  913. }
  914. void CSlotWindow::OnUnselectItemSlot(int iSlotNumber)
  915. {
  916.     PyCallClassMemberFunc(m_poHandler, "OnUnselectItemSlot", Py_BuildValue("(i)", iSlotNumber));
  917. }
  918. void CSlotWindow::OnUseSlot()
  919. {
  920.     TSlot * pSlot;
  921.     if (GetPickedSlotPointer(&pSlot))
  922.     if (pSlot->isItem)
  923.     {
  924.         PyCallClassMemberFunc(m_poHandler, "OnUseSlot", Py_BuildValue("(i)", pSlot->dwSlotNumber));
  925.     }
  926. }
  927.  
  928. BOOL CSlotWindow::OnOverInItem(DWORD dwSlotNumber)
  929. {
  930.     TSlot * pSlot;
  931.     if (!GetSlotPointer(dwSlotNumber, &pSlot))
  932.         return FALSE;
  933.  
  934.     if (!pSlot->isItem)
  935.         return FALSE;
  936.  
  937.     if (pSlot->dwSlotNumber == m_dwToolTipSlotNumber)
  938.         return TRUE;
  939.  
  940.     m_dwToolTipSlotNumber = dwSlotNumber;
  941.     PyCallClassMemberFunc(m_poHandler, "OnOverInItem", Py_BuildValue("(i)", dwSlotNumber));
  942.  
  943.     return TRUE;
  944. }
  945.  
  946. void CSlotWindow::OnOverOutItem()
  947. {
  948.     if (SLOT_NUMBER_NONE == m_dwToolTipSlotNumber)
  949.         return;
  950.  
  951.     m_dwToolTipSlotNumber = SLOT_NUMBER_NONE;
  952.     PyCallClassMemberFunc(m_poHandler, "OnOverOutItem", Py_BuildValue("()"));
  953. }
  954.  
  955. void CSlotWindow::OnPressedSlotButton(DWORD dwType, DWORD dwSlotNumber, BOOL isLeft)
  956. {
  957.     if (CSlotButton::SLOT_BUTTON_TYPE_PLUS == dwType)
  958.     {
  959.         PyCallClassMemberFunc(m_poHandler, "OnPressedSlotButton", Py_BuildValue("(i)", dwSlotNumber));
  960.     }
  961.     else if (CSlotButton::SLOT_BUTTON_TYPE_COVER == dwType)
  962.     {
  963.         if (isLeft)
  964.         {
  965.             OnMouseLeftButtonDown();
  966.         }
  967.     }
  968. }
  969.  
  970. void CSlotWindow::OnUpdate()
  971. {
  972.     for (std::deque<DWORD>::iterator itor = m_ReserveDestroyEffectDeque.begin(); itor != m_ReserveDestroyEffectDeque.end(); ++itor)
  973.     {
  974.         DWORD dwSlotIndex = *itor;
  975.         TSlot * pSlot;
  976.         if (!GetSlotPointer(dwSlotIndex, &pSlot))
  977.             continue;
  978.        
  979.         __DestroyFinishCoolTimeEffect(pSlot);
  980.         #ifdef ENABLE_ACCE_SYSTEM
  981.         for (int i = 0; i < 3; ++i)
  982.         {
  983.             if (pSlot->pActiveSlotEffect[i])
  984.             {
  985.                 delete pSlot->pActiveSlotEffect[i];
  986.                 pSlot->pActiveSlotEffect[i] = NULL;
  987.             }
  988.         }
  989.         #endif
  990.     }
  991.  
  992. void CSlotWindow::OnRender()
  993. {
  994.     RenderSlotBaseImage();
  995.  
  996.     switch (m_dwSlotStyle)
  997.     {
  998.         case SLOT_STYLE_PICK_UP:
  999.             OnRenderPickingSlot();
  1000.             break;
  1001.         case SLOT_STYLE_SELECT:
  1002.             OnRenderSelectedSlot();
  1003.             break;
  1004.     }
  1005.  
  1006.     std::for_each(m_pChildList.begin(), m_pChildList.end(), std::void_mem_fun(&CWindow::OnRender));
  1007.  
  1008.     TSlotListIterator itor;
  1009.  
  1010.     //
  1011.     // 모든 슬롯 상자 그리기
  1012.     //////////////////////////////////////////////////////////////////////////
  1013. #ifdef __RENDER_SLOT_AREA__
  1014.     CPythonGraphic::Instance().SetDiffuseColor(0.5f, 0.5f, 0.5f);
  1015.     for (itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1016.     {
  1017.         TSlot & rSlot = *itor;
  1018.         CPythonGraphic::Instance().RenderBox2d(m_rect.left + rSlot.ixPosition,
  1019.                                                m_rect.top + rSlot.iyPosition,
  1020.                                                m_rect.left + rSlot.ixPosition + rSlot.ixCellSize,
  1021.                                                m_rect.top + rSlot.iyPosition + rSlot.iyCellSize);
  1022.     }
  1023.     CPythonGraphic::Instance().SetDiffuseColor(1.0f, 0.0f, 0.0f, 1.0f);
  1024.     CPythonGraphic::Instance().RenderBox2d(m_rect.left, m_rect.top, m_rect.right, m_rect.bottom);
  1025. #endif
  1026.     //////////////////////////////////////////////////////////////////////////
  1027.  
  1028.     for (itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1029.     {
  1030.         TSlot & rSlot = *itor;
  1031.  
  1032.         if (rSlot.pSlotButton)
  1033.         {
  1034.             rSlot.pSlotButton->SetPosition(rSlot.ixPosition + 1, rSlot.iyPosition + 19);
  1035.         }
  1036.         if (rSlot.pSignImage)
  1037.         {
  1038.             rSlot.pSignImage->SetPosition(rSlot.ixPosition - 7, rSlot.iyPosition + 10);
  1039.         }
  1040.  
  1041.         if (rSlot.pInstance)
  1042.         {
  1043.             rSlot.pInstance->SetPosition(m_rect.left + rSlot.ixPosition, m_rect.top + rSlot.iyPosition);
  1044.             rSlot.pInstance->Render();
  1045.         }
  1046.  
  1047.         if (!rSlot.isItem)
  1048.         {
  1049.             if (IS_SET(rSlot.dwState, SLOT_STATE_ALWAYS_RENDER_COVER))
  1050.             {
  1051.                 rSlot.pCoverButton->Show();
  1052.                 rSlot.pCoverButton->SetPosition(rSlot.ixPosition, rSlot.iyPosition);
  1053.                 rSlot.pCoverButton->RenderButton();
  1054.             }
  1055.  
  1056.             continue;
  1057.         }
  1058.  
  1059.         if (IS_SET(rSlot.dwState, SLOT_STATE_DISABLE))
  1060.         {
  1061.             CPythonGraphic::Instance().SetDiffuseColor(1.0f, 0.0f, 0.0f, 0.3f);
  1062.             CPythonGraphic::Instance().RenderBar2d(m_rect.left + rSlot.ixPosition,
  1063.                 m_rect.top + rSlot.iyPosition,
  1064.                 m_rect.left + rSlot.ixPosition + rSlot.ixCellSize,
  1065.                 m_rect.top + rSlot.iyPosition + rSlot.iyCellSize);
  1066.         }
  1067.  
  1068.         if (rSlot.fCoolTime != 0.0f)
  1069.         {
  1070.             float fcurTime = CTimer::Instance().GetCurrentSecond();
  1071.             float fPercentage = (fcurTime - rSlot.fStartCoolTime) / rSlot.fCoolTime;
  1072.             CPythonGraphic::Instance().RenderCoolTimeBox(m_rect.left + rSlot.ixPosition + 16.0f, m_rect.top + rSlot.iyPosition + 16.0f, 16.0f, fPercentage);
  1073.  
  1074.             if (fcurTime - rSlot.fStartCoolTime >= rSlot.fCoolTime)
  1075.             {
  1076.                 // 쿨타임이 끝난지 1초 이내라면..
  1077.                 if ((fcurTime - rSlot.fStartCoolTime) - rSlot.fCoolTime < 1.0f)
  1078.                     __CreateFinishCoolTimeEffect(&rSlot);
  1079.  
  1080.                 rSlot.fCoolTime = 0.0f;
  1081.                 rSlot.fStartCoolTime = 0.0f;
  1082.             }
  1083.         }
  1084.  
  1085.         if (rSlot.pCoverButton)
  1086.         {
  1087.             rSlot.pCoverButton->SetPosition(rSlot.ixPosition, rSlot.iyPosition);
  1088.             rSlot.pCoverButton->RenderButton();
  1089.         }
  1090.  
  1091.         if (rSlot.pNumberLine)
  1092.         {
  1093.             int ix = rSlot.byxPlacedItemSize*ITEM_WIDTH + rSlot.ixPosition - 4;
  1094.             int iy = rSlot.iyPosition + rSlot.byyPlacedItemSize*ITEM_HEIGHT - 12 + 2;
  1095.             rSlot.pNumberLine->SetPosition(ix, iy);
  1096.             rSlot.pNumberLine->Update();
  1097.             rSlot.pNumberLine->Render();
  1098.         }
  1099.  
  1100.         if (rSlot.pFinishCoolTimeEffect)
  1101.         {
  1102.             rSlot.pFinishCoolTimeEffect->SetPosition(rSlot.ixPosition, rSlot.iyPosition);
  1103.             rSlot.pFinishCoolTimeEffect->Update();
  1104.             rSlot.pFinishCoolTimeEffect->Render();
  1105.         }
  1106.        
  1107. #ifdef ENABLE_ACCE_SYSTEM
  1108.         {
  1109.             int iX = m_rect.left + rSlot.ixPosition, iY = m_rect.top + rSlot.iyPosition, iItemYSize = rSlot.byyPlacedItemSize;
  1110.             for (int i = 0; i < 3; ++i)
  1111.             {
  1112.                 if ((rSlot.pActiveSlotEffect[i]) && (iItemYSize == i + 1))
  1113.                 {
  1114.                     rSlot.pActiveSlotEffect[i]->Show();
  1115.                     rSlot.pActiveSlotEffect[i]->SetPosition(iX, iY);
  1116.                     rSlot.pActiveSlotEffect[i]->Update();
  1117.                     rSlot.pActiveSlotEffect[i]->Render();
  1118.                 }
  1119.             }
  1120.         }
  1121. #endif
  1122.  
  1123.         if (rSlot.bActive)
  1124.         if (m_pSlotActiveEffect)
  1125.         {
  1126.             int ix = m_rect.left + rSlot.ixPosition;
  1127.             int iy = m_rect.top + rSlot.iyPosition;
  1128.             m_pSlotActiveEffect->SetPosition(ix, iy);
  1129.             m_pSlotActiveEffect->Render();
  1130.         }
  1131.     }
  1132.  
  1133.     RenderLockedSlot();
  1134. }
  1135.  
  1136. void CSlotWindow::RenderSlotBaseImage()
  1137. {
  1138.     if (!m_pBaseImageInstance)
  1139.         return;
  1140.  
  1141.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1142.     {
  1143.         TSlot & rSlot = *itor;
  1144.  
  1145.         if (!rSlot.bRenderBaseSlotImage)
  1146.             continue;
  1147.  
  1148.         m_pBaseImageInstance->SetPosition(m_rect.left + rSlot.ixPosition, m_rect.top + rSlot.iyPosition);
  1149.         m_pBaseImageInstance->Render();
  1150.     }
  1151. }
  1152.  
  1153. void CSlotWindow::OnRenderPickingSlot()
  1154. {
  1155.     if (!UI::CWindowManager::Instance().IsAttaching())
  1156.         return;
  1157.  
  1158.     TSlot * pSlot;
  1159.     if (!GetSelectedSlotPointer(&pSlot))
  1160.         return;
  1161.  
  1162.     CPythonGraphic::Instance().SetDiffuseColor(1.0f, 1.0f, 1.0f, 0.5f);
  1163.     CPythonGraphic::Instance().RenderBar2d(m_rect.left + pSlot->ixPosition,
  1164.                                             m_rect.top + pSlot->iyPosition,
  1165.                                             m_rect.left + pSlot->ixPosition + pSlot->ixCellSize,
  1166.                                             m_rect.top + pSlot->iyPosition + pSlot->iyCellSize);
  1167. }
  1168.  
  1169. void CSlotWindow::OnRenderSelectedSlot()
  1170. {
  1171.     std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  1172.     for (; itor != m_dwSelectedSlotIndexList.end(); ++itor)
  1173.     {
  1174.         TSlot * pSlot;
  1175.         if (!GetSlotPointer(*itor, &pSlot))
  1176.             continue;
  1177.  
  1178.         CPythonGraphic::Instance().SetDiffuseColor(1.0f, 1.0f, 1.0f, 0.5f);
  1179.         CPythonGraphic::Instance().RenderBar2d(m_rect.left + pSlot->ixPosition,
  1180.                                                 m_rect.top + pSlot->iyPosition,
  1181.                                                 m_rect.left + pSlot->ixPosition + pSlot->ixCellSize,
  1182.                                                 m_rect.top + pSlot->iyPosition + pSlot->iyCellSize);
  1183.     }
  1184. }
  1185.  
  1186. void CSlotWindow::RenderLockedSlot()
  1187. {
  1188.     CPythonGraphic::Instance().SetDiffuseColor(0.0f, 0.0f, 0.0f, 0.5f);
  1189.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1190.     {
  1191.         TSlot & rSlot = *itor;
  1192.  
  1193.         if (!rSlot.isItem)
  1194.             continue;
  1195.  
  1196.         if (rSlot.dwState & SLOT_STATE_LOCK)
  1197.         {
  1198.             CPythonGraphic::Instance().RenderBar2d(m_rect.left + rSlot.ixPosition,
  1199.                                                    m_rect.top  + rSlot.iyPosition,
  1200.                                                    m_rect.left + rSlot.ixPosition + rSlot.ixCellSize,
  1201.                                                    m_rect.top  + rSlot.iyPosition + rSlot.iyCellSize);
  1202.         }
  1203.     }
  1204. }
  1205.  
  1206. // Check Slot
  1207.  
  1208. BOOL CSlotWindow::GetSlotPointer(DWORD dwIndex, TSlot ** ppSlot)
  1209. {
  1210.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1211.     {
  1212.         TSlot & rSlot = *itor;
  1213.  
  1214.         if (dwIndex == rSlot.dwSlotNumber)
  1215.         {
  1216.             *ppSlot = &rSlot;
  1217.             return TRUE;
  1218.         }
  1219.     }
  1220.  
  1221.     return FALSE;
  1222. }
  1223.  
  1224. BOOL CSlotWindow::GetSelectedSlotPointer(TSlot ** ppSlot)
  1225. {
  1226.     long lx, ly;
  1227.     GetMouseLocalPosition(lx, ly);
  1228.  
  1229.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1230.     {
  1231.         TSlot & rSlot = *itor;
  1232.  
  1233.         if (lx >= rSlot.ixPosition)
  1234.         if (ly >= rSlot.iyPosition)
  1235.         if (lx <= rSlot.ixPosition + rSlot.ixCellSize)
  1236.         if (ly <= rSlot.iyPosition + rSlot.iyCellSize)
  1237.         {
  1238.             *ppSlot = &rSlot;
  1239.             return TRUE;
  1240.         }
  1241.     }
  1242.  
  1243.     return FALSE;
  1244. }
  1245.  
  1246. BOOL CSlotWindow::GetPickedSlotPointer(TSlot ** ppSlot)
  1247. {
  1248.     long lx, ly;
  1249.     CWindowManager::Instance().GetMousePosition(lx, ly);
  1250.  
  1251.     int ixLocal = lx - m_rect.left;
  1252.     int iyLocal = ly - m_rect.top;
  1253.  
  1254.     // NOTE : 왼쪽 맨위 상단 한곳이 기준 이라는 점을 이용해 왼쪽 위에서부터 오른쪽 아래로
  1255.     //        차례로 검색해 감으로써 덮혀 있는 Slot은 자동 무시 된다는 특성을 이용한다. - [levites]
  1256.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1257.     {
  1258.         TSlot & rSlot = *itor;
  1259.  
  1260.         int ixCellSize = rSlot.ixCellSize;
  1261.         int iyCellSize = rSlot.iyCellSize;
  1262.  
  1263.         // NOTE : Item이 Hide 되어있을 경우를 위한..
  1264.         if (rSlot.isItem)
  1265.         {
  1266.             ixCellSize = max(rSlot.ixCellSize, int(rSlot.byxPlacedItemSize * ITEM_WIDTH));
  1267.             iyCellSize = max(rSlot.iyCellSize, int(rSlot.byyPlacedItemSize * ITEM_HEIGHT));
  1268.         }
  1269.  
  1270.         if (ixLocal >= rSlot.ixPosition)
  1271.         if (iyLocal >= rSlot.iyPosition)
  1272.         if (ixLocal <= rSlot.ixPosition + ixCellSize)
  1273.         if (iyLocal <= rSlot.iyPosition + iyCellSize)
  1274.         {
  1275.             *ppSlot = &rSlot;
  1276.             return TRUE;
  1277.         }
  1278.     }
  1279.  
  1280.     return FALSE;
  1281. }
  1282.  
  1283. void CSlotWindow::SetUseMode(BOOL bFlag)
  1284. {
  1285.     m_isUseMode = bFlag;
  1286. }
  1287.  
  1288. void CSlotWindow::SetUsableItem(BOOL bFlag)
  1289. {
  1290.     m_isUsableItem = bFlag;
  1291. }
  1292.  
  1293. void CSlotWindow::ReserveDestroyCoolTimeFinishEffect(DWORD dwSlotIndex)
  1294. {
  1295.     m_ReserveDestroyEffectDeque.push_back(dwSlotIndex);
  1296. }
  1297.  
  1298. #ifdef ENABLE_ACCE_SYSTEM
  1299. void CSlotWindow::ActivateEffect(DWORD dwSlotIndex, float r, float g, float b, float a)
  1300. {
  1301.     TSlot * pSlot;
  1302.     if (!GetSlotPointer(dwSlotIndex, &pSlot))
  1303.         return;
  1304.    
  1305.     for (int i = 0; i < 3; ++i)
  1306.     {
  1307.         if (pSlot->pActiveSlotEffect[i])
  1308.         {
  1309.             delete pSlot->pActiveSlotEffect[i];
  1310.             pSlot->pActiveSlotEffect[i] = NULL;
  1311.         }
  1312.        
  1313.         CAniImageBox * pEff = new CAniImageBox(NULL);
  1314.         for (int j = 0; j <= 12; ++j)
  1315.         {
  1316.             char cBuf[72];
  1317.             sprintf_s(cBuf, "d:/ymir work/ui/public/slotactiveeffect/slot%d/%02d.sub", (i + 1), j);
  1318.             pEff->AppendImage(cBuf, r, g, b, a);
  1319.         }
  1320.        
  1321.         pEff->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN);
  1322.         pSlot->pActiveSlotEffect[i] = pEff;
  1323.     }
  1324. }
  1325.  
  1326. void CSlotWindow::DeactivateEffect(DWORD dwSlotIndex)
  1327. {
  1328.     TSlot * pSlot;
  1329.     if (!GetSlotPointer(dwSlotIndex, &pSlot))
  1330.         return;
  1331.    
  1332.     for (int i = 0; i < 3; ++i)
  1333.     {
  1334.         if (pSlot->pActiveSlotEffect[i])
  1335.         {
  1336.             delete pSlot->pActiveSlotEffect[i];
  1337.             pSlot->pActiveSlotEffect[i] = NULL;
  1338.         }
  1339.     }
  1340. }
  1341. #endif
  1342.  
  1343. DWORD CSlotWindow::Type()
  1344. {
  1345.     static int s_Type = GetCRC32("CSlotWindow", strlen("CSlotWindow"));
  1346.     return s_Type;
  1347. }
  1348.  
  1349. BOOL CSlotWindow::OnIsType(DWORD dwType)
  1350. {
  1351.     if (CSlotWindow::Type() == dwType)
  1352.         return TRUE;
  1353.  
  1354.     return CWindow::OnIsType(dwType);
  1355. }
  1356.  
  1357. void CSlotWindow::__CreateToggleSlotImage()
  1358. {
  1359.     __DestroyToggleSlotImage();
  1360.  
  1361.     m_pToggleSlotImage = new CImageBox(NULL);
  1362.     m_pToggleSlotImage->LoadImage("d:/ymir work/ui/public/slot_toggle.sub");
  1363.     m_pToggleSlotImage->Show();
  1364. }
  1365.  
  1366. void CSlotWindow::__CreateSlotEnableEffect()
  1367. {
  1368.     __DestroySlotEnableEffect();
  1369.  
  1370.     m_pSlotActiveEffect = new CAniImageBox(NULL);
  1371.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/00.sub");
  1372.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/01.sub");
  1373.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/02.sub");
  1374.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/03.sub");
  1375.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/04.sub");
  1376.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/05.sub");
  1377.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/06.sub");
  1378.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/07.sub");
  1379.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/08.sub");
  1380.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/09.sub");
  1381.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/10.sub");
  1382.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/11.sub");
  1383.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/12.sub");
  1384.     m_pSlotActiveEffect->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN);
  1385.     m_pSlotActiveEffect->Show();
  1386. }
  1387.  
  1388. void CSlotWindow::__CreateFinishCoolTimeEffect(TSlot * pSlot)
  1389. {
  1390.     __DestroyFinishCoolTimeEffect(pSlot);
  1391.  
  1392.     CAniImageBox * pFinishCoolTimeEffect = new CCoolTimeFinishEffect(this, pSlot->dwSlotNumber);
  1393.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/00.sub");
  1394.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/01.sub");
  1395.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/02.sub");
  1396.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/03.sub");
  1397.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/04.sub");
  1398.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/05.sub");
  1399.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/06.sub");
  1400.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/07.sub");
  1401.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/08.sub");
  1402.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/09.sub");
  1403.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/10.sub");
  1404.     pFinishCoolTimeEffect->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN);
  1405.     pFinishCoolTimeEffect->ResetFrame();
  1406.     pFinishCoolTimeEffect->SetDelay(2);
  1407.     pFinishCoolTimeEffect->Show();
  1408.  
  1409.     pSlot->pFinishCoolTimeEffect = pFinishCoolTimeEffect;
  1410. }
  1411.  
  1412. void CSlotWindow::__CreateBaseImage(const char * c_szFileName, float fr, float fg, float fb, float fa)
  1413. {
  1414.     __DestroyBaseImage();
  1415.  
  1416.     CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(c_szFileName);
  1417.     m_pBaseImageInstance = CGraphicImageInstance::New();
  1418.     m_pBaseImageInstance->SetImagePointer(pImage);
  1419.     m_pBaseImageInstance->SetDiffuseColor(fr, fg, fb, fa);
  1420. }
  1421.  
  1422. void CSlotWindow::__DestroyToggleSlotImage()
  1423. {
  1424.     if (m_pToggleSlotImage)
  1425.     {
  1426.         delete m_pToggleSlotImage;
  1427.         m_pToggleSlotImage = NULL;
  1428.     }
  1429. }
  1430.  
  1431. void CSlotWindow::__DestroySlotEnableEffect()
  1432. {
  1433.     if (m_pSlotActiveEffect)
  1434.     {
  1435.         delete m_pSlotActiveEffect;
  1436.         m_pSlotActiveEffect = NULL;
  1437.     }
  1438. }
  1439.  
  1440. void CSlotWindow::__DestroyFinishCoolTimeEffect(TSlot * pSlot)
  1441. {
  1442.     if (pSlot->pFinishCoolTimeEffect)
  1443.     {
  1444.         delete pSlot->pFinishCoolTimeEffect;
  1445.         pSlot->pFinishCoolTimeEffect = NULL;
  1446.     }
  1447. }
  1448.  
  1449. void CSlotWindow::__DestroyBaseImage()
  1450. {
  1451.     if (m_pBaseImageInstance)
  1452.     {
  1453.         CGraphicImageInstance::Delete(m_pBaseImageInstance);
  1454.         m_pBaseImageInstance = NULL;
  1455.     }
  1456. }
  1457.  
  1458. void CSlotWindow::__Initialize()
  1459. {
  1460.     m_dwSlotType = 0;
  1461.     m_dwSlotStyle = SLOT_STYLE_PICK_UP;
  1462.     m_dwToolTipSlotNumber = SLOT_NUMBER_NONE;
  1463.  
  1464.     m_isUseMode = FALSE;
  1465.     m_isUsableItem = FALSE;
  1466.  
  1467.     m_pToggleSlotImage = NULL;
  1468.     m_pSlotActiveEffect = NULL;
  1469.     m_pBaseImageInstance = NULL;
  1470. }
  1471.  
  1472. void CSlotWindow::Destroy()
  1473. {
  1474.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1475.     {
  1476.         TSlot & rSlot = *itor;
  1477.  
  1478.         ClearSlot(&rSlot);
  1479.  
  1480.         if (rSlot.pNumberLine)
  1481.         {
  1482.             delete rSlot.pNumberLine;
  1483.             rSlot.pNumberLine = NULL;
  1484.         }
  1485.         if (rSlot.pCoverButton)
  1486.         {
  1487.             CWindowManager::Instance().DestroyWindow(rSlot.pCoverButton);
  1488.         }
  1489.         if (rSlot.pSlotButton)
  1490.         {
  1491.             CWindowManager::Instance().DestroyWindow(rSlot.pSlotButton);
  1492.         }
  1493.         if (rSlot.pSignImage)
  1494.         {
  1495.             CWindowManager::Instance().DestroyWindow(rSlot.pSignImage);
  1496.         }
  1497.         if (rSlot.pFinishCoolTimeEffect)
  1498.         {
  1499.             CWindowManager::Instance().DestroyWindow(rSlot.pFinishCoolTimeEffect);
  1500.         }
  1501. #ifdef ENABLE_ACCE_SYSTEM
  1502.         for (int i = 0; i < 3; ++i)
  1503.         {
  1504.             if (rSlot.pActiveSlotEffect[i])
  1505.                 CWindowManager::Instance().DestroyWindow(rSlot.pActiveSlotEffect[i]);
  1506.         }
  1507. #endif
  1508.     }
  1509.  
  1510.     m_SlotList.clear();
  1511.  
  1512.     __DestroyToggleSlotImage();
  1513.     __DestroySlotEnableEffect();
  1514.     __DestroyBaseImage();
  1515.  
  1516.     __Initialize();
  1517. }
  1518.  
  1519. CSlotWindow::CSlotWindow(PyObject * ppyObject) : CWindow(ppyObject)
  1520. {
  1521.     __Initialize();
  1522. }
  1523.  
  1524. CSlotWindow::~CSlotWindow()
  1525. {
  1526.     Destroy();
  1527. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement