Advertisement
Guest User

Untitled

a guest
Nov 28th, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 38.53 KB | Gaming | 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_SASH_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::StoreSlotCoolTime(DWORD dwKey, DWORD dwSlotIndex, float fCoolTime, float fElapsedTime)
  516. {
  517.     std::map<DWORD, SStoreCoolDown>::iterator it = m_CoolDownStore[dwKey].find(dwSlotIndex);
  518.     if (it != m_CoolDownStore[dwKey].end())
  519.     {
  520.         it->second.fCoolTime = fCoolTime;
  521.         it->second.fElapsedTime = CTimer::Instance().GetCurrentSecond() - fElapsedTime;
  522.         it->second.bActive = false;
  523.     }
  524.     else
  525.     {
  526.         SStoreCoolDown m_storeCoolDown;
  527.         m_storeCoolDown.fCoolTime = fCoolTime;
  528.         m_storeCoolDown.fElapsedTime = CTimer::Instance().GetCurrentSecond() - fElapsedTime;
  529.         m_storeCoolDown.bActive = false;
  530.         m_CoolDownStore[dwKey].insert(std::map<DWORD, SStoreCoolDown>::value_type(dwSlotIndex, m_storeCoolDown));
  531.     }
  532. }
  533.  
  534. void CSlotWindow::RestoreSlotCoolTime(DWORD dwKey)
  535. {
  536.     for (std::map<DWORD, SStoreCoolDown>::iterator it = m_CoolDownStore[dwKey].begin(); it != m_CoolDownStore[dwKey].end(); it++)
  537.     {
  538.         TSlot* pSlot;
  539.         if (!GetSlotPointer(it->first, &pSlot))
  540.             return;
  541.  
  542.         pSlot->fCoolTime = it->second.fCoolTime;
  543.         pSlot->fStartCoolTime = it->second.fElapsedTime;
  544.         if (it->second.bActive)
  545.             ActivateSlot(it->first);
  546.         else
  547.             DeactivateSlot(it->first);
  548.     }
  549. }
  550.  
  551. void CSlotWindow::ActivateSlot(DWORD dwIndex)
  552. {
  553.     TSlot * pSlot;
  554.     if (!GetSlotPointer(dwIndex, &pSlot))
  555.         return;
  556.  
  557.     if (pSlot->bActive)
  558.         return;
  559.  
  560.     pSlot->bActive = TRUE;
  561.  
  562.     if (!m_pSlotActiveEffect)
  563.     {
  564.         __CreateSlotEnableEffect();
  565.     }
  566.  
  567.     std::map<DWORD, SStoreCoolDown>::iterator it = m_CoolDownStore[1].find(dwIndex);
  568.  
  569.     if (it != m_CoolDownStore[1].end())
  570.         it->second.bActive = true;
  571. }
  572.  
  573. void CSlotWindow::DeactivateSlot(DWORD dwIndex)
  574. {
  575.     TSlot * pSlot;
  576.     if (!GetSlotPointer(dwIndex, &pSlot))
  577.         return;
  578.  
  579.     pSlot->bActive = FALSE;
  580.  
  581.     std::map<DWORD, SStoreCoolDown>::iterator it = m_CoolDownStore[1].find(dwIndex);
  582.     if (it != m_CoolDownStore[1].end())
  583.         it->second.bActive = false;
  584. }
  585.  
  586. void CSlotWindow::ClearSlot(DWORD dwIndex)
  587. {
  588.     TSlot * pSlot;
  589.     if (!GetSlotPointer(dwIndex, &pSlot))
  590.         return;
  591.  
  592.     ClearSlot(pSlot);
  593. }
  594.  
  595. void CSlotWindow::ClearSlot(TSlot * pSlot)
  596. {
  597.     pSlot->bActive = FALSE;
  598.     pSlot->byxPlacedItemSize = 1;
  599.     pSlot->byyPlacedItemSize = 1;
  600.  
  601.     pSlot->isItem = FALSE;
  602.     pSlot->dwState = 0;
  603.     pSlot->fCoolTime = 0.0f;
  604.     pSlot->fStartCoolTime = 0.0f;
  605.     pSlot->dwCenterSlotNumber = 0xffffffff;
  606.  
  607.     pSlot->dwItemIndex = 0;
  608.     pSlot->bRenderBaseSlotImage = true;
  609.  
  610.     if (pSlot->pInstance)
  611.     {
  612.         CGraphicImageInstance::Delete(pSlot->pInstance);
  613.         pSlot->pInstance = NULL;
  614.     }
  615.     if (pSlot->pCoverButton)
  616.     {
  617.         pSlot->pCoverButton->Hide();
  618.     }
  619.     if (pSlot->pSlotButton)
  620.     {
  621.         pSlot->pSlotButton->Hide();
  622.     }
  623.     if (pSlot->pSignImage)
  624.     {
  625.         pSlot->pSignImage->Hide();
  626.     }
  627.     if (pSlot->pFinishCoolTimeEffect)
  628.     {
  629.         pSlot->pFinishCoolTimeEffect->Hide();
  630.     }
  631. #ifdef ENABLE_SASH_SYSTEM
  632.     for (int i = 0; i < 3; ++i)
  633.     {
  634.         if (pSlot->pActiveSlotEffect[i])
  635.             pSlot->pActiveSlotEffect[i]->Hide();
  636.     }
  637. #endif
  638. }
  639.  
  640. void CSlotWindow::ClearAllSlot()
  641. {
  642.     Destroy();
  643. }
  644.  
  645. void CSlotWindow::RefreshSlot()
  646. {
  647.     OnRefreshSlot();
  648.  
  649.     // NOTE : Refresh µΙ¶§ ToolTip µµ °»½Ε ΗΥ΄Ο΄Ω - [levites]
  650.     if (IsRendering())
  651.     {
  652.         TSlot * pSlot;
  653.         if (GetPickedSlotPointer(&pSlot))
  654.         {
  655.             OnOverOutItem();
  656.             OnOverInItem(pSlot->dwSlotNumber);
  657.         }
  658.     }
  659. }
  660.  
  661. void CSlotWindow::OnRefreshSlot()
  662. {
  663. }
  664.  
  665. DWORD CSlotWindow::GetSlotCount()
  666. {
  667.     return m_SlotList.size();
  668. }
  669.  
  670. void CSlotWindow::LockSlot(DWORD dwIndex)
  671. {
  672.     TSlot * pSlot;
  673.     if (!GetSlotPointer(dwIndex, &pSlot))
  674.         return;
  675.  
  676.     pSlot->dwState |= SLOT_STATE_LOCK;
  677. }
  678. void CSlotWindow::UnlockSlot(DWORD dwIndex)
  679. {
  680.     TSlot * pSlot;
  681.     if (!GetSlotPointer(dwIndex, &pSlot))
  682.         return;
  683.  
  684.     pSlot->dwState ^= SLOT_STATE_LOCK;
  685. }
  686. void CSlotWindow::SetCantUseSlot(DWORD dwIndex)
  687. {
  688.     TSlot * pSlot;
  689.     if (!GetSlotPointer(dwIndex, &pSlot))
  690.         return;
  691.  
  692.     pSlot->dwState |= SLOT_STATE_CANT_USE;
  693. }
  694. void CSlotWindow::SetUseSlot(DWORD dwIndex)
  695. {
  696.     TSlot * pSlot;
  697.     if (!GetSlotPointer(dwIndex, &pSlot))
  698.         return;
  699.  
  700.     pSlot->dwState ^= SLOT_STATE_CANT_USE;
  701. }
  702. void CSlotWindow::EnableSlot(DWORD dwIndex)
  703. {
  704.     TSlot * pSlot;
  705.     if (!GetSlotPointer(dwIndex, &pSlot))
  706.         return;
  707.  
  708.     REMOVE_BIT(pSlot->dwState, SLOT_STATE_DISABLE);
  709.     //pSlot->dwState |= SLOT_STATE_DISABLE;
  710. }
  711. void CSlotWindow::DisableSlot(DWORD dwIndex)
  712. {
  713.     TSlot * pSlot;
  714.     if (!GetSlotPointer(dwIndex, &pSlot))
  715.         return;
  716.     SET_BIT(pSlot->dwState, SLOT_STATE_DISABLE);
  717.     //pSlot->dwState ^= SLOT_STATE_DISABLE;
  718. }
  719.  
  720. // Select
  721.  
  722. void CSlotWindow::SelectSlot(DWORD dwSelectingIndex)
  723. {
  724.     std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  725.     for (; itor != m_dwSelectedSlotIndexList.end();)
  726.     {
  727.         if (dwSelectingIndex == *itor)
  728.         {
  729.             itor = m_dwSelectedSlotIndexList.erase(itor);
  730.             return;
  731.         }
  732.         else
  733.         {
  734.             ++itor;
  735.         }
  736.     }
  737.  
  738.     TSlot * pSlot;
  739.     if (GetSlotPointer(dwSelectingIndex, &pSlot))
  740.     {
  741.         if (!pSlot->isItem)
  742.             return;
  743.  
  744.         m_dwSelectedSlotIndexList.push_back(dwSelectingIndex);
  745.     }
  746. }
  747.  
  748. BOOL CSlotWindow::isSelectedSlot(DWORD dwIndex)
  749. {
  750.     std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  751.     for (; itor != m_dwSelectedSlotIndexList.end(); ++itor)
  752.     {
  753.         if (dwIndex == *itor)
  754.             return TRUE;
  755.     }
  756.  
  757.     return FALSE;
  758. }
  759.  
  760. void CSlotWindow::ClearSelected()
  761. {
  762.     m_dwSelectedSlotIndexList.clear();
  763. }
  764.  
  765. DWORD CSlotWindow::GetSelectedSlotCount()
  766. {
  767.     return m_dwSelectedSlotIndexList.size();
  768. }
  769.  
  770. DWORD CSlotWindow::GetSelectedSlotNumber(DWORD dwIndex)
  771. {
  772.     if (dwIndex >= m_dwSelectedSlotIndexList.size())
  773.         return DWORD(-1);
  774.  
  775.     DWORD dwCount = 0;
  776.     std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  777.     for (; itor != m_dwSelectedSlotIndexList.end(); ++itor)
  778.     {
  779.         if (dwIndex == dwCount)
  780.             break;
  781.  
  782.         ++dwCount;
  783.     }
  784.  
  785.     return *itor;
  786. }
  787.  
  788. void CSlotWindow::ShowSlotButton(DWORD dwSlotNumber)
  789. {
  790.     TSlot * pSlot;
  791.     if (!GetSlotPointer(dwSlotNumber, &pSlot))
  792.         return;
  793.  
  794.     if (pSlot->pSlotButton)
  795.     {
  796.         pSlot->pSlotButton->Show();
  797.     }
  798. }
  799.  
  800. void CSlotWindow::HideAllSlotButton()
  801. {
  802.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  803.     {
  804.         TSlot & rSlot = *itor;
  805.  
  806.         if (rSlot.pSlotButton)
  807.         {
  808.             rSlot.pSlotButton->Hide();
  809.         }
  810.     }
  811. }
  812.  
  813. void CSlotWindow::ShowRequirementSign(DWORD dwSlotNumber)
  814. {
  815.     TSlot * pSlot;
  816.     if (!GetSlotPointer(dwSlotNumber, &pSlot))
  817.         return;
  818.  
  819.     if (!pSlot->pSignImage)
  820.         return;
  821.  
  822.     pSlot->pSignImage->Show();
  823. }
  824.  
  825. void CSlotWindow::HideRequirementSign(DWORD dwSlotNumber)
  826. {
  827.     TSlot * pSlot;
  828.     if (!GetSlotPointer(dwSlotNumber, &pSlot))
  829.         return;
  830.  
  831.     if (!pSlot->pSignImage)
  832.         return;
  833.  
  834.     pSlot->pSignImage->Hide();
  835. }
  836.  
  837. // Event
  838.  
  839. BOOL CSlotWindow::OnMouseLeftButtonDown()
  840. {
  841.     TSlot * pSlot;
  842.     if (!GetPickedSlotPointer(&pSlot))
  843.     {
  844.         UI::CWindowManager::Instance().DeattachIcon();
  845.         return TRUE;
  846.     }
  847.  
  848.     if (pSlot->isItem && !(pSlot->dwState & SLOT_STATE_LOCK))
  849.     {
  850.         OnSelectItemSlot(pSlot->dwSlotNumber);
  851.     }
  852.     else
  853.     {
  854.         OnSelectEmptySlot(pSlot->dwSlotNumber);
  855.     }
  856.  
  857.     return TRUE;
  858. }
  859.  
  860. BOOL CSlotWindow::OnMouseLeftButtonUp()
  861. {
  862.     if (UI::CWindowManager::Instance().IsAttaching())
  863.     if (UI::CWindowManager::Instance().IsDragging())
  864.     if (IsIn())
  865.     {
  866.         UI::CWindow * pWin = UI::CWindowManager::Instance().GetPointWindow();
  867.  
  868.         if (pWin)
  869.         if (pWin->IsType(UI::CSlotWindow::Type()))
  870.         {
  871.             UI::CSlotWindow * pSlotWin = (UI::CSlotWindow *)pWin;
  872.  
  873.             TSlot * pSlot;
  874.             if (!pSlotWin->GetPickedSlotPointer(&pSlot))
  875.             {
  876.                 UI::CWindowManager::Instance().DeattachIcon();
  877.                 return TRUE;
  878.             }
  879.  
  880.             if (pSlot->isItem)
  881.                 pSlotWin->OnSelectItemSlot(pSlot->dwSlotNumber);
  882.             else
  883.                 pSlotWin->OnSelectEmptySlot(pSlot->dwSlotNumber);
  884.  
  885.             return TRUE;
  886.         }
  887.  
  888.         return FALSE;
  889.     }
  890.  
  891.     return FALSE;
  892. }
  893.  
  894. void CSlotWindow::SetSlotID(DWORD dwIndex, DWORD dwID)
  895. {
  896.     TSlot * pSlot;
  897.     if (!GetSlotPointer(dwIndex, &pSlot))
  898.         return;
  899.  
  900.     if (dwID <= 0)
  901.     {
  902.         return;
  903.     }
  904.     else
  905.     {
  906.        
  907.         pSlot->dwItemID=dwID;
  908.     }
  909. }
  910.  
  911. BOOL CSlotWindow::OnMouseRightButtonDown()
  912. {
  913.     TSlot * pSlot;
  914.     if (!GetPickedSlotPointer(&pSlot))
  915.         return TRUE;
  916.  
  917.     if (pSlot->isItem)
  918.     {
  919.         OnUnselectItemSlot(pSlot->dwSlotNumber);
  920.     }
  921.     else
  922.     {
  923.         OnUnselectEmptySlot(pSlot->dwSlotNumber);
  924.     }
  925.  
  926.     return TRUE;
  927. }
  928.  
  929. BOOL CSlotWindow::OnMouseLeftButtonDoubleClick()
  930. {
  931.     OnUseSlot();
  932.  
  933.     return TRUE;
  934. }
  935.  
  936. void CSlotWindow::OnMouseOverOut()
  937. {
  938.     OnOverOutItem();
  939. }
  940.  
  941. void CSlotWindow::OnMouseOver()
  942. {
  943.     // FIXME : ΐ©µµΏμΈ¦ µε·΅±λ Ηϴ µµΑίΏ΅ SetTopΐΜ µΗΎξΉφΈ®Έι Capture°΅ Η®ΎξΑ® ΉφΈ°΄Ω. ±Χ°ΝΐΗ ΉζΑφ ΔΪµε.
  944.     //         Α» ΄υ ±ΩΊ»ΐϋΐΞ ΗΨ°αΓ¥ΐ» Γ£ΎΖΎί Η µν - [levites]
  945. //  if (UI::CWindowManager::Instance().IsCapture())
  946. //  if (!UI::CWindowManager::Instance().IsAttaching())
  947. //      return;
  948.  
  949.     CWindow * pPointWindow = UI::CWindowManager::Instance().GetPointWindow();
  950.     if (this == pPointWindow)
  951.     {
  952.         TSlot * pSlot;
  953.         if (GetPickedSlotPointer(&pSlot))
  954.         {
  955.             if (OnOverInItem(pSlot->dwSlotNumber))
  956.                 return;
  957.         }
  958.     }
  959.  
  960.     OnOverOutItem();
  961. }
  962.  
  963. void CSlotWindow::OnSelectEmptySlot(int iSlotNumber)
  964. {
  965.     PyCallClassMemberFunc(m_poHandler, "OnSelectEmptySlot", Py_BuildValue("(i)", iSlotNumber));
  966. }
  967. void CSlotWindow::OnSelectItemSlot(int iSlotNumber)
  968. {
  969. //  OnOverOutItem();
  970.     PyCallClassMemberFunc(m_poHandler, "OnSelectItemSlot", Py_BuildValue("(i)", iSlotNumber));
  971.  
  972.     if (UI::CWindowManager::Instance().IsAttaching())
  973.         OnOverOutItem();
  974. }
  975. void CSlotWindow::OnUnselectEmptySlot(int iSlotNumber)
  976. {
  977.     PyCallClassMemberFunc(m_poHandler, "OnUnselectEmptySlot", Py_BuildValue("(i)", iSlotNumber));
  978. }
  979. void CSlotWindow::OnUnselectItemSlot(int iSlotNumber)
  980. {
  981.     PyCallClassMemberFunc(m_poHandler, "OnUnselectItemSlot", Py_BuildValue("(i)", iSlotNumber));
  982. }
  983. void CSlotWindow::OnUseSlot()
  984. {
  985.     TSlot * pSlot;
  986.     if (GetPickedSlotPointer(&pSlot))
  987.     if (pSlot->isItem)
  988.     {
  989.         PyCallClassMemberFunc(m_poHandler, "OnUseSlot", Py_BuildValue("(i)", pSlot->dwSlotNumber));
  990.     }
  991. }
  992.  
  993. BOOL CSlotWindow::OnOverInItem(DWORD dwSlotNumber)
  994. {
  995.     TSlot * pSlot;
  996.     if (!GetSlotPointer(dwSlotNumber, &pSlot))
  997.         return FALSE;
  998.  
  999.     if (!pSlot->isItem)
  1000.         return FALSE;
  1001.  
  1002.     if (pSlot->dwSlotNumber == m_dwToolTipSlotNumber)
  1003.         return TRUE;
  1004.  
  1005.     m_dwToolTipSlotNumber = dwSlotNumber;
  1006.     PyCallClassMemberFunc(m_poHandler, "OnOverInItem", Py_BuildValue("(iii)", dwSlotNumber,pSlot->dwItemIndex,pSlot->dwItemID));
  1007.  
  1008.     return TRUE;
  1009. }
  1010.  
  1011. void CSlotWindow::OnOverOutItem()
  1012. {
  1013.     if (SLOT_NUMBER_NONE == m_dwToolTipSlotNumber)
  1014.         return;
  1015.  
  1016.     m_dwToolTipSlotNumber = SLOT_NUMBER_NONE;
  1017.     PyCallClassMemberFunc(m_poHandler, "OnOverOutItem", Py_BuildValue("()"));
  1018. }
  1019.  
  1020. void CSlotWindow::OnPressedSlotButton(DWORD dwType, DWORD dwSlotNumber, BOOL isLeft)
  1021. {
  1022.     if (CSlotButton::SLOT_BUTTON_TYPE_PLUS == dwType)
  1023.     {
  1024.         PyCallClassMemberFunc(m_poHandler, "OnPressedSlotButton", Py_BuildValue("(i)", dwSlotNumber));
  1025.     }
  1026.     else if (CSlotButton::SLOT_BUTTON_TYPE_COVER == dwType)
  1027.     {
  1028.         if (isLeft)
  1029.         {
  1030.             OnMouseLeftButtonDown();
  1031.         }
  1032.     }
  1033. }
  1034.  
  1035. void CSlotWindow::OnUpdate()
  1036. {
  1037.     for (std::deque<DWORD>::iterator itor = m_ReserveDestroyEffectDeque.begin(); itor != m_ReserveDestroyEffectDeque.end(); ++itor)
  1038.     {
  1039.         DWORD dwSlotIndex = *itor;
  1040.         TSlot * pSlot;
  1041.         if (!GetSlotPointer(dwSlotIndex, &pSlot))
  1042.             continue;
  1043.        
  1044.         __DestroyFinishCoolTimeEffect(pSlot);
  1045.         #ifdef ENABLE_SASH_SYSTEM
  1046.         for (int i = 0; i < 3; ++i)
  1047.         {
  1048.             if (pSlot->pActiveSlotEffect[i])
  1049.             {
  1050.                 delete pSlot->pActiveSlotEffect[i];
  1051.                 pSlot->pActiveSlotEffect[i] = NULL;
  1052.             }
  1053.         }
  1054.         #endif
  1055.     }
  1056.     m_ReserveDestroyEffectDeque.clear();
  1057.  
  1058.     if (m_pSlotActiveEffect)
  1059.         m_pSlotActiveEffect->Update();
  1060. }
  1061.  
  1062. void CSlotWindow::OnRender()
  1063. {
  1064.     RenderSlotBaseImage();
  1065.  
  1066.     switch (m_dwSlotStyle)
  1067.     {
  1068.         case SLOT_STYLE_PICK_UP:
  1069.             OnRenderPickingSlot();
  1070.             break;
  1071.         case SLOT_STYLE_SELECT:
  1072.             OnRenderSelectedSlot();
  1073.             break;
  1074.     }
  1075.  
  1076.     std::for_each(m_pChildList.begin(), m_pChildList.end(), std::mem_fn(&CWindow::OnRender));
  1077.  
  1078.     TSlotListIterator itor;
  1079.  
  1080.     //
  1081.     // Έπµη ½½·Τ »σΐΪ ±ΧΈ®±β
  1082.     //////////////////////////////////////////////////////////////////////////
  1083. #ifdef __RENDER_SLOT_AREA__
  1084.     CPythonGraphic::Instance().SetDiffuseColor(0.5f, 0.5f, 0.5f);
  1085.     for (itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1086.     {
  1087.         TSlot & rSlot = *itor;
  1088.         CPythonGraphic::Instance().RenderBox2d(m_rect.left + rSlot.ixPosition,
  1089.                                                m_rect.top + rSlot.iyPosition,
  1090.                                                m_rect.left + rSlot.ixPosition + rSlot.ixCellSize,
  1091.                                                m_rect.top + rSlot.iyPosition + rSlot.iyCellSize);
  1092.     }
  1093.     CPythonGraphic::Instance().SetDiffuseColor(1.0f, 0.0f, 0.0f, 1.0f);
  1094.     CPythonGraphic::Instance().RenderBox2d(m_rect.left, m_rect.top, m_rect.right, m_rect.bottom);
  1095. #endif
  1096.     //////////////////////////////////////////////////////////////////////////
  1097.  
  1098.     for (itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1099.     {
  1100.         TSlot & rSlot = *itor;
  1101.  
  1102.         if (rSlot.pSlotButton)
  1103.         {
  1104.             rSlot.pSlotButton->SetPosition(rSlot.ixPosition + 1, rSlot.iyPosition + 19);
  1105.         }
  1106.         if (rSlot.pSignImage)
  1107.         {
  1108.             rSlot.pSignImage->SetPosition(rSlot.ixPosition - 7, rSlot.iyPosition + 10);
  1109.         }
  1110.  
  1111.         if (rSlot.pInstance)
  1112.         {
  1113.             rSlot.pInstance->SetPosition(m_rect.left + rSlot.ixPosition, m_rect.top + rSlot.iyPosition);
  1114.             rSlot.pInstance->Render();
  1115.         }
  1116.  
  1117.         if (!rSlot.isItem)
  1118.         {
  1119.             if (IS_SET(rSlot.dwState, SLOT_STATE_ALWAYS_RENDER_COVER))
  1120.             {
  1121.                 rSlot.pCoverButton->Show();
  1122.                 rSlot.pCoverButton->SetPosition(rSlot.ixPosition, rSlot.iyPosition);
  1123.                 rSlot.pCoverButton->RenderButton();
  1124.             }
  1125.  
  1126.             continue;
  1127.         }
  1128.  
  1129.         if (IS_SET(rSlot.dwState, SLOT_STATE_DISABLE))
  1130.         {
  1131.             CPythonGraphic::Instance().SetDiffuseColor(1.0f, 0.0f, 0.0f, 0.3f);
  1132.             CPythonGraphic::Instance().RenderBar2d(m_rect.left + rSlot.ixPosition,
  1133.                 m_rect.top + rSlot.iyPosition,
  1134.                 m_rect.left + rSlot.ixPosition + rSlot.ixCellSize,
  1135.                 m_rect.top + rSlot.iyPosition + rSlot.iyCellSize);
  1136.         }
  1137.  
  1138.         if (rSlot.fCoolTime != 0.0f)
  1139.         {
  1140.             float fcurTime = CTimer::Instance().GetCurrentSecond();
  1141.             float fPercentage = (fcurTime - rSlot.fStartCoolTime) / rSlot.fCoolTime;
  1142.             CPythonGraphic::Instance().RenderCoolTimeBox(m_rect.left + rSlot.ixPosition + 16.0f, m_rect.top + rSlot.iyPosition + 16.0f, 16.0f, fPercentage);
  1143.  
  1144.             if (fcurTime - rSlot.fStartCoolTime >= rSlot.fCoolTime)
  1145.             {
  1146.                 // ΔπΕΈΐΣΐΜ ³΅³­Αφ 1ΓΚ ΐΜ³»¶σΈι..
  1147.                 if ((fcurTime - rSlot.fStartCoolTime) - rSlot.fCoolTime < 1.0f)
  1148.                     __CreateFinishCoolTimeEffect(&rSlot);
  1149.  
  1150.                 rSlot.fCoolTime = 0.0f;
  1151.                 rSlot.fStartCoolTime = 0.0f;
  1152.             }
  1153.         }
  1154.  
  1155.         if (rSlot.pCoverButton)
  1156.         {
  1157.             rSlot.pCoverButton->SetPosition(rSlot.ixPosition, rSlot.iyPosition);
  1158.             rSlot.pCoverButton->RenderButton();
  1159.         }
  1160.  
  1161.         if (rSlot.pNumberLine)
  1162.         {
  1163.             int ix = rSlot.byxPlacedItemSize*ITEM_WIDTH + rSlot.ixPosition - 4;
  1164.             int iy = rSlot.iyPosition + rSlot.byyPlacedItemSize*ITEM_HEIGHT - 12 + 2;
  1165.             rSlot.pNumberLine->SetPosition(ix, iy);
  1166.             rSlot.pNumberLine->Update();
  1167.             rSlot.pNumberLine->Render();
  1168.         }
  1169.  
  1170.         if (rSlot.pFinishCoolTimeEffect)
  1171.         {
  1172.             rSlot.pFinishCoolTimeEffect->SetPosition(rSlot.ixPosition, rSlot.iyPosition);
  1173.             rSlot.pFinishCoolTimeEffect->Update();
  1174.             rSlot.pFinishCoolTimeEffect->Render();
  1175.         }
  1176. #ifdef ENABLE_SASH_SYSTEM
  1177.         {
  1178.             int iX = m_rect.left + rSlot.ixPosition, iY = m_rect.top + rSlot.iyPosition, iItemYSize = rSlot.byyPlacedItemSize;
  1179.             for (int i = 0; i < 3; ++i)
  1180.             {
  1181.                 if ((rSlot.pActiveSlotEffect[i]) && (iItemYSize == i + 1))
  1182.                 {
  1183.                     rSlot.pActiveSlotEffect[i]->Show();
  1184.                     rSlot.pActiveSlotEffect[i]->SetPosition(iX, iY);
  1185.                     rSlot.pActiveSlotEffect[i]->Update();
  1186.                     rSlot.pActiveSlotEffect[i]->Render();
  1187.                 }
  1188.             }
  1189.         }
  1190.         #endif
  1191.  
  1192.         if (rSlot.bActive)
  1193.         if (m_pSlotActiveEffect)
  1194.         {
  1195.             int ix = m_rect.left + rSlot.ixPosition;
  1196.             int iy = m_rect.top + rSlot.iyPosition;
  1197.             m_pSlotActiveEffect->SetPosition(ix, iy);
  1198.             m_pSlotActiveEffect->Render();
  1199.         }
  1200.     }
  1201.  
  1202.     RenderLockedSlot();
  1203. }
  1204.  
  1205. void CSlotWindow::RenderSlotBaseImage()
  1206. {
  1207.     if (!m_pBaseImageInstance)
  1208.         return;
  1209.  
  1210.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1211.     {
  1212.         TSlot & rSlot = *itor;
  1213.  
  1214.         if (!rSlot.bRenderBaseSlotImage)
  1215.             continue;
  1216.  
  1217.         m_pBaseImageInstance->SetPosition(m_rect.left + rSlot.ixPosition, m_rect.top + rSlot.iyPosition);
  1218.         m_pBaseImageInstance->Render();
  1219.     }
  1220. }
  1221.  
  1222. void CSlotWindow::OnRenderPickingSlot()
  1223. {
  1224.     if (!UI::CWindowManager::Instance().IsAttaching())
  1225.         return;
  1226.  
  1227.     TSlot * pSlot;
  1228.     if (!GetSelectedSlotPointer(&pSlot))
  1229.         return;
  1230.  
  1231.     CPythonGraphic::Instance().SetDiffuseColor(1.0f, 1.0f, 1.0f, 0.5f);
  1232.     CPythonGraphic::Instance().RenderBar2d(m_rect.left + pSlot->ixPosition,
  1233.                                             m_rect.top + pSlot->iyPosition,
  1234.                                             m_rect.left + pSlot->ixPosition + pSlot->ixCellSize,
  1235.                                             m_rect.top + pSlot->iyPosition + pSlot->iyCellSize);
  1236. }
  1237.  
  1238. void CSlotWindow::OnRenderSelectedSlot()
  1239. {
  1240.     std::list<DWORD>::iterator itor = m_dwSelectedSlotIndexList.begin();
  1241.     for (; itor != m_dwSelectedSlotIndexList.end(); ++itor)
  1242.     {
  1243.         TSlot * pSlot;
  1244.         if (!GetSlotPointer(*itor, &pSlot))
  1245.             continue;
  1246.  
  1247.         CPythonGraphic::Instance().SetDiffuseColor(1.0f, 1.0f, 1.0f, 0.5f);
  1248.         CPythonGraphic::Instance().RenderBar2d(m_rect.left + pSlot->ixPosition,
  1249.                                                 m_rect.top + pSlot->iyPosition,
  1250.                                                 m_rect.left + pSlot->ixPosition + pSlot->ixCellSize,
  1251.                                                 m_rect.top + pSlot->iyPosition + pSlot->iyCellSize);
  1252.     }
  1253. }
  1254.  
  1255. void CSlotWindow::RenderLockedSlot()
  1256. {
  1257.     CPythonGraphic::Instance().SetDiffuseColor(0.0f, 0.0f, 0.0f, 0.5f);
  1258.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1259.     {
  1260.         TSlot & rSlot = *itor;
  1261.  
  1262.         if (!rSlot.isItem)
  1263.             continue;
  1264.  
  1265.         if (rSlot.dwState & SLOT_STATE_LOCK)
  1266.         {
  1267.             CPythonGraphic::Instance().RenderBar2d(m_rect.left + rSlot.ixPosition,
  1268.                                                    m_rect.top  + rSlot.iyPosition,
  1269.                                                    m_rect.left + rSlot.ixPosition + rSlot.ixCellSize,
  1270.                                                    m_rect.top  + rSlot.iyPosition + rSlot.iyCellSize);
  1271.         }
  1272.     }
  1273. }
  1274.  
  1275. // Check Slot
  1276.  
  1277. BOOL CSlotWindow::GetSlotPointer(DWORD dwIndex, TSlot ** ppSlot)
  1278. {
  1279.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1280.     {
  1281.         TSlot & rSlot = *itor;
  1282.  
  1283.         if (dwIndex == rSlot.dwSlotNumber)
  1284.         {
  1285.             *ppSlot = &rSlot;
  1286.             return TRUE;
  1287.         }
  1288.     }
  1289.  
  1290.     return FALSE;
  1291. }
  1292.  
  1293. BOOL CSlotWindow::GetSelectedSlotPointer(TSlot ** ppSlot)
  1294. {
  1295.     long lx, ly;
  1296.     GetMouseLocalPosition(lx, ly);
  1297.  
  1298.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1299.     {
  1300.         TSlot & rSlot = *itor;
  1301.  
  1302.         if (lx >= rSlot.ixPosition)
  1303.         if (ly >= rSlot.iyPosition)
  1304.         if (lx <= rSlot.ixPosition + rSlot.ixCellSize)
  1305.         if (ly <= rSlot.iyPosition + rSlot.iyCellSize)
  1306.         {
  1307.             *ppSlot = &rSlot;
  1308.             return TRUE;
  1309.         }
  1310.     }
  1311.  
  1312.     return FALSE;
  1313. }
  1314.  
  1315. BOOL CSlotWindow::GetPickedSlotPointer(TSlot ** ppSlot)
  1316. {
  1317.     long lx, ly;
  1318.     CWindowManager::Instance().GetMousePosition(lx, ly);
  1319.  
  1320.     int ixLocal = lx - m_rect.left;
  1321.     int iyLocal = ly - m_rect.top;
  1322.  
  1323.     // NOTE : ΏήΒΚ ΈΗΐ§ »σ΄ά ΗΡ°χΐΜ ±βΑΨ ΐΜ¶σ΄Β Α΅ΐ» ΐΜΏλΗΨ ΏήΒΚ ΐ§Ώ΅Ό­ΊΞΕΝ ΏΐΈ¥ΒΚ ΎΖ·΅·Ξ
  1324.     //        Βχ·Κ·Ξ °Λ»φΗΨ °¨ΐΈ·Ξ½α µ¤Ητ ΐΦ΄Β SlotΐΊ ΐΪµΏ Ή«½Γ µΘ΄Ω΄Β Ζ―ΌΊΐ» ΐΜΏλΗΡ΄Ω. - [levites]
  1325.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1326.     {
  1327.         TSlot & rSlot = *itor;
  1328.  
  1329.         int ixCellSize = rSlot.ixCellSize;
  1330.         int iyCellSize = rSlot.iyCellSize;
  1331.  
  1332.         // NOTE : ItemΐΜ Hide µΗΎξΐΦΐ» °ζΏμΈ¦ ΐ§ΗΡ..
  1333.         if (rSlot.isItem)
  1334.         {
  1335.             ixCellSize = max(rSlot.ixCellSize, int(rSlot.byxPlacedItemSize * ITEM_WIDTH));
  1336.             iyCellSize = max(rSlot.iyCellSize, int(rSlot.byyPlacedItemSize * ITEM_HEIGHT));
  1337.         }
  1338.  
  1339.         if (ixLocal >= rSlot.ixPosition)
  1340.         if (iyLocal >= rSlot.iyPosition)
  1341.         if (ixLocal <= rSlot.ixPosition + ixCellSize)
  1342.         if (iyLocal <= rSlot.iyPosition + iyCellSize)
  1343.         {
  1344.             *ppSlot = &rSlot;
  1345.             return TRUE;
  1346.         }
  1347.     }
  1348.  
  1349.     return FALSE;
  1350. }
  1351.  
  1352. void CSlotWindow::SetUseMode(BOOL bFlag)
  1353. {
  1354.     m_isUseMode = bFlag;
  1355. }
  1356.  
  1357. void CSlotWindow::SetUsableItem(BOOL bFlag)
  1358. {
  1359.     m_isUsableItem = bFlag;
  1360. }
  1361.  
  1362. void CSlotWindow::ReserveDestroyCoolTimeFinishEffect(DWORD dwSlotIndex)
  1363. {
  1364.     m_ReserveDestroyEffectDeque.push_back(dwSlotIndex);
  1365. }
  1366.  
  1367. #ifdef ENABLE_SASH_SYSTEM
  1368. void CSlotWindow::ActivateEffect(DWORD dwSlotIndex, float r, float g, float b, float a)
  1369. {
  1370.     TSlot * pSlot;
  1371.     if (!GetSlotPointer(dwSlotIndex, &pSlot))
  1372.         return;
  1373.    
  1374.     for (int i = 0; i < 3; ++i)
  1375.     {
  1376.         if (pSlot->pActiveSlotEffect[i])
  1377.         {
  1378.             delete pSlot->pActiveSlotEffect[i];
  1379.             pSlot->pActiveSlotEffect[i] = NULL;
  1380.         }
  1381.        
  1382.         CAniImageBox * pEff = new CAniImageBox(NULL);
  1383.         for (int j = 0; j <= 12; ++j)
  1384.         {
  1385.             char cBuf[72];
  1386.             sprintf_s(cBuf, "d:/ymir work/ui/public/slotactiveeffect/slot%d/%02d.sub", (i + 1), j);
  1387.             pEff->AppendImage(cBuf, r, g, b, a);
  1388.         }
  1389.        
  1390.         pEff->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN);
  1391.         pSlot->pActiveSlotEffect[i] = pEff;
  1392.     }
  1393. }
  1394.  
  1395. void CSlotWindow::DeactivateEffect(DWORD dwSlotIndex)
  1396. {
  1397.     TSlot * pSlot;
  1398.     if (!GetSlotPointer(dwSlotIndex, &pSlot))
  1399.         return;
  1400.    
  1401.     for (int i = 0; i < 3; ++i)
  1402.     {
  1403.         if (pSlot->pActiveSlotEffect[i])
  1404.         {
  1405.             delete pSlot->pActiveSlotEffect[i];
  1406.             pSlot->pActiveSlotEffect[i] = NULL;
  1407.         }
  1408.     }
  1409. }
  1410. #endif
  1411.  
  1412. DWORD CSlotWindow::Type()
  1413. {
  1414.     static int s_Type = GetCRC32("CSlotWindow", strlen("CSlotWindow"));
  1415.     return s_Type;
  1416. }
  1417.  
  1418. BOOL CSlotWindow::OnIsType(DWORD dwType)
  1419. {
  1420.     if (CSlotWindow::Type() == dwType)
  1421.         return TRUE;
  1422.  
  1423.     return CWindow::OnIsType(dwType);
  1424. }
  1425.  
  1426. void CSlotWindow::__CreateToggleSlotImage()
  1427. {
  1428.     __DestroyToggleSlotImage();
  1429.  
  1430.     m_pToggleSlotImage = new CImageBox(NULL);
  1431.     m_pToggleSlotImage->LoadImage("d:/ymir work/ui/public/slot_toggle.sub");
  1432.     m_pToggleSlotImage->Show();
  1433. }
  1434.  
  1435. void CSlotWindow::__CreateSlotEnableEffect()
  1436. {
  1437.     __DestroySlotEnableEffect();
  1438.  
  1439.     m_pSlotActiveEffect = new CAniImageBox(NULL);
  1440.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/00.sub");
  1441.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/01.sub");
  1442.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/02.sub");
  1443.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/03.sub");
  1444.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/04.sub");
  1445.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/05.sub");
  1446.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/06.sub");
  1447.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/07.sub");
  1448.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/08.sub");
  1449.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/09.sub");
  1450.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/10.sub");
  1451.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/11.sub");
  1452.     m_pSlotActiveEffect->AppendImage("d:/ymir work/ui/public/slotactiveeffect/12.sub");
  1453.     m_pSlotActiveEffect->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN);
  1454.     m_pSlotActiveEffect->Show();
  1455. }
  1456.  
  1457. void CSlotWindow::__CreateFinishCoolTimeEffect(TSlot * pSlot)
  1458. {
  1459.     __DestroyFinishCoolTimeEffect(pSlot);
  1460.  
  1461.     CAniImageBox * pFinishCoolTimeEffect = new CCoolTimeFinishEffect(this, pSlot->dwSlotNumber);
  1462.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/00.sub");
  1463.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/01.sub");
  1464.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/02.sub");
  1465.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/03.sub");
  1466.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/04.sub");
  1467.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/05.sub");
  1468.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/06.sub");
  1469.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/07.sub");
  1470.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/08.sub");
  1471.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/09.sub");
  1472.     pFinishCoolTimeEffect->AppendImage("d:/ymir work/ui/public/slotfinishcooltimeeffect/10.sub");
  1473.     pFinishCoolTimeEffect->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN);
  1474.     pFinishCoolTimeEffect->ResetFrame();
  1475.     pFinishCoolTimeEffect->SetDelay(2);
  1476.     pFinishCoolTimeEffect->Show();
  1477.  
  1478.     pSlot->pFinishCoolTimeEffect = pFinishCoolTimeEffect;
  1479. }
  1480.  
  1481. void CSlotWindow::__CreateBaseImage(const char * c_szFileName, float fr, float fg, float fb, float fa)
  1482. {
  1483.     __DestroyBaseImage();
  1484.  
  1485.     CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(c_szFileName);
  1486.     m_pBaseImageInstance = CGraphicImageInstance::New();
  1487.     m_pBaseImageInstance->SetImagePointer(pImage);
  1488.     m_pBaseImageInstance->SetDiffuseColor(fr, fg, fb, fa);
  1489. }
  1490.  
  1491. void CSlotWindow::__DestroyToggleSlotImage()
  1492. {
  1493.     if (m_pToggleSlotImage)
  1494.     {
  1495.         delete m_pToggleSlotImage;
  1496.         m_pToggleSlotImage = NULL;
  1497.     }
  1498. }
  1499.  
  1500. void CSlotWindow::__DestroySlotEnableEffect()
  1501. {
  1502.     if (m_pSlotActiveEffect)
  1503.     {
  1504.         delete m_pSlotActiveEffect;
  1505.         m_pSlotActiveEffect = NULL;
  1506.     }
  1507. }
  1508.  
  1509. void CSlotWindow::__DestroyFinishCoolTimeEffect(TSlot * pSlot)
  1510. {
  1511.     if (pSlot->pFinishCoolTimeEffect)
  1512.     {
  1513.         delete pSlot->pFinishCoolTimeEffect;
  1514.         pSlot->pFinishCoolTimeEffect = NULL;
  1515.     }
  1516. }
  1517.  
  1518. void CSlotWindow::__DestroyBaseImage()
  1519. {
  1520.     if (m_pBaseImageInstance)
  1521.     {
  1522.         CGraphicImageInstance::Delete(m_pBaseImageInstance);
  1523.         m_pBaseImageInstance = NULL;
  1524.     }
  1525. }
  1526.  
  1527. void CSlotWindow::__Initialize()
  1528. {
  1529.     m_dwSlotType = 0;
  1530.     m_dwSlotStyle = SLOT_STYLE_PICK_UP;
  1531.     m_dwToolTipSlotNumber = SLOT_NUMBER_NONE;
  1532.  
  1533.     m_CoolDownStore.clear();
  1534.  
  1535.     m_isUseMode = FALSE;
  1536.     m_isUsableItem = FALSE;
  1537.  
  1538.     m_pToggleSlotImage = NULL;
  1539.     m_pSlotActiveEffect = NULL;
  1540.     m_pBaseImageInstance = NULL;
  1541. }
  1542.  
  1543. void CSlotWindow::Destroy()
  1544. {
  1545.     for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
  1546.     {
  1547.         TSlot & rSlot = *itor;
  1548.  
  1549.         ClearSlot(&rSlot);
  1550.  
  1551.         if (rSlot.pNumberLine)
  1552.         {
  1553.             delete rSlot.pNumberLine;
  1554.             rSlot.pNumberLine = NULL;
  1555.         }
  1556.         if (rSlot.pCoverButton)
  1557.         {
  1558.             CWindowManager::Instance().DestroyWindow(rSlot.pCoverButton);
  1559.         }
  1560.         if (rSlot.pSlotButton)
  1561.         {
  1562.             CWindowManager::Instance().DestroyWindow(rSlot.pSlotButton);
  1563.         }
  1564.         if (rSlot.pSignImage)
  1565.         {
  1566.             CWindowManager::Instance().DestroyWindow(rSlot.pSignImage);
  1567.         }
  1568.         if (rSlot.pFinishCoolTimeEffect)
  1569.         {
  1570.             CWindowManager::Instance().DestroyWindow(rSlot.pFinishCoolTimeEffect);
  1571.         }
  1572. #ifdef ENABLE_SASH_SYSTEM
  1573.         for (int i = 0; i < 3; ++i)
  1574.         {
  1575.             if (rSlot.pActiveSlotEffect[i])
  1576.                 CWindowManager::Instance().DestroyWindow(rSlot.pActiveSlotEffect[i]);
  1577.         }
  1578.         #endif
  1579.     }
  1580.  
  1581.     m_SlotList.clear();
  1582.  
  1583.     __DestroyToggleSlotImage();
  1584.     __DestroySlotEnableEffect();
  1585.     __DestroyBaseImage();
  1586.  
  1587.     __Initialize();
  1588. }
  1589.  
  1590. CSlotWindow::CSlotWindow(PyObject * ppyObject) : CWindow(ppyObject)
  1591. {
  1592.     __Initialize();
  1593. }
  1594.  
  1595. CSlotWindow::~CSlotWindow()
  1596. {
  1597.     Destroy();
  1598. }
  1599.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement