Advertisement
Guest User

uiinventory.py

a guest
Dec 11th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 38.53 KB | None | 0 0
  1. import ui
  2. import player
  3. import mouseModule
  4. import net
  5. import app
  6. import snd
  7. import item
  8. import player
  9. import chat
  10. import grp
  11. import uiScriptLocale
  12. import uiRefine
  13. import uiAttachMetin
  14. import uiPickMoney
  15. import uiCommon
  16. import uiPrivateShopBuilder # 개인상점 열동안 ItemMove 방지
  17. import localeInfo
  18. import constInfo
  19. import ime
  20. import wndMgr
  21.  
  22. ITEM_MALL_BUTTON_ENABLE = True
  23.  
  24.  
  25.  
  26. ITEM_FLAG_APPLICABLE = 1 << 14
  27.  
  28. class CostumeWindow(ui.ScriptWindow):
  29.  
  30.     def __init__(self, wndInventory):
  31.         import exception
  32.        
  33.         if not app.ENABLE_COSTUME_SYSTEM:          
  34.             exception.Abort("What do you do?")
  35.             return
  36.  
  37.         if not wndInventory:
  38.             exception.Abort("wndInventory parameter must be set to InventoryWindow")
  39.             return                     
  40.                  
  41.         ui.ScriptWindow.__init__(self)
  42.  
  43.         self.isLoaded = 0
  44.         self.wndInventory = wndInventory;
  45.  
  46.         self.__LoadWindow()
  47.  
  48.     def __del__(self):
  49.         ui.ScriptWindow.__del__(self)
  50.  
  51.     def Show(self):
  52.         self.__LoadWindow()
  53.         self.RefreshCostumeSlot()
  54.  
  55.         ui.ScriptWindow.Show(self)
  56.  
  57.     def Close(self):
  58.         self.Hide()
  59.  
  60.     def __LoadWindow(self):
  61.         if self.isLoaded == 1:
  62.             return
  63.  
  64.         self.isLoaded = 1
  65.  
  66.         try:
  67.             pyScrLoader = ui.PythonScriptLoader()
  68.             pyScrLoader.LoadScriptFile(self, "UIScript/CostumeWindow.py")
  69.         except:
  70.             import exception
  71.             exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  72.  
  73.         try:
  74.             wndEquip = self.GetChild("CostumeSlot")
  75.             self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
  76.            
  77.         except:
  78.             import exception
  79.             exception.Abort("CostumeWindow.LoadWindow.BindObject")
  80.  
  81.         ## Equipment
  82.         wndEquip.SetOverInItemEvent(ui.__mem_func__(self.wndInventory.OverInItem))
  83.         wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.wndInventory.OverOutItem))
  84.         wndEquip.SetUnselectItemSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  85.         wndEquip.SetUseSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))                       
  86.         wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.wndInventory.SelectEmptySlot))
  87.         wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.wndInventory.SelectItemSlot))
  88.  
  89.         self.wndEquip = wndEquip
  90.  
  91.     def RefreshCostumeSlot(self):
  92.         getItemVNum=player.GetItemIndex
  93.        
  94.         for i in xrange(item.COSTUME_SLOT_COUNT):
  95.             slotNumber = item.COSTUME_SLOT_START + i
  96.             self.wndEquip.SetItemSlot(slotNumber, getItemVNum(slotNumber), 0)
  97.  
  98.         self.wndEquip.RefreshSlot()
  99.        
  100. class BeltInventoryWindow(ui.ScriptWindow):
  101.  
  102.     def __init__(self, wndInventory):
  103.         import exception
  104.        
  105.         if not app.ENABLE_NEW_EQUIPMENT_SYSTEM:        
  106.             exception.Abort("What do you do?")
  107.             return
  108.  
  109.         if not wndInventory:
  110.             exception.Abort("wndInventory parameter must be set to InventoryWindow")
  111.             return                     
  112.                  
  113.         ui.ScriptWindow.__init__(self)
  114.  
  115.         self.isLoaded = 0
  116.         self.wndInventory = wndInventory;
  117.        
  118.         self.wndBeltInventoryLayer = None
  119.         self.wndBeltInventorySlot = None
  120.         self.expandBtn = None
  121.         self.minBtn = None
  122.  
  123.         self.__LoadWindow()
  124.  
  125.     def __del__(self):
  126.         ui.ScriptWindow.__del__(self)
  127.  
  128.     def Show(self, openBeltSlot = FALSE):
  129.         self.__LoadWindow()
  130.         self.RefreshSlot()
  131.  
  132.         ui.ScriptWindow.Show(self)
  133.        
  134.         if openBeltSlot:
  135.             self.OpenInventory()
  136.         else:
  137.             self.CloseInventory()
  138.  
  139.     def Close(self):
  140.         self.Hide()
  141.  
  142.     def IsOpeningInventory(self):
  143.         return self.wndBeltInventoryLayer.IsShow()
  144.        
  145.     def OpenInventory(self):
  146.         self.wndBeltInventoryLayer.Show()
  147.         self.expandBtn.Hide()
  148.  
  149.         if localeInfo.IsARABIC() == 0:
  150.             self.AdjustPositionAndSize()
  151.                
  152.     def CloseInventory(self):
  153.         self.wndBeltInventoryLayer.Hide()
  154.         self.expandBtn.Show()
  155.        
  156.         if localeInfo.IsARABIC() == 0:
  157.             self.AdjustPositionAndSize()
  158.  
  159.     ## 현재 인벤토리 위치를 기준으로 BASE 위치를 계산, 리턴.. 숫자 하드코딩하기 정말 싫지만 방법이 없다..
  160.     def GetBasePosition(self):
  161.         x, y = self.wndInventory.GetGlobalPosition()
  162.         return x - 148, y + 241
  163.        
  164.     def AdjustPositionAndSize(self):
  165.         bx, by = self.GetBasePosition()
  166.        
  167.         if self.IsOpeningInventory():          
  168.             self.SetPosition(bx, by)
  169.             self.SetSize(self.ORIGINAL_WIDTH, self.GetHeight())
  170.            
  171.         else:
  172.             self.SetPosition(bx + 138, by);
  173.             self.SetSize(10, self.GetHeight())
  174.  
  175.     def __LoadWindow(self):
  176.         if self.isLoaded == 1:
  177.             return
  178.  
  179.         self.isLoaded = 1
  180.  
  181.         try:
  182.             pyScrLoader = ui.PythonScriptLoader()
  183.             pyScrLoader.LoadScriptFile(self, "UIScript/BeltInventoryWindow.py")
  184.         except:
  185.             import exception
  186.             exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  187.  
  188.         try:
  189.             self.ORIGINAL_WIDTH = self.GetWidth()
  190.             wndBeltInventorySlot = self.GetChild("BeltInventorySlot")
  191.             self.wndBeltInventoryLayer = self.GetChild("BeltInventoryLayer")
  192.             self.expandBtn = self.GetChild("ExpandBtn")
  193.             self.minBtn = self.GetChild("MinimizeBtn")
  194.            
  195.             self.expandBtn.SetEvent(ui.__mem_func__(self.OpenInventory))
  196.             self.minBtn.SetEvent(ui.__mem_func__(self.CloseInventory))
  197.            
  198.             if localeInfo.IsARABIC() :
  199.                 self.expandBtn.SetPosition(self.expandBtn.GetWidth() - 2, 15)
  200.                 self.wndBeltInventoryLayer.SetPosition(self.wndBeltInventoryLayer.GetWidth() - 5, 0)
  201.                 self.minBtn.SetPosition(self.minBtn.GetWidth() + 3, 15)        
  202.    
  203.             for i in xrange(item.BELT_INVENTORY_SLOT_COUNT):
  204.                 slotNumber = item.BELT_INVENTORY_SLOT_START + i                        
  205.                 wndBeltInventorySlot.SetCoverButton(slotNumber, "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  206.                                                 "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  207.                                                 "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  208.                                                 "d:/ymir work/ui/game/belt_inventory/slot_disabled.tga", FALSE, FALSE)                                 
  209.            
  210.         except:
  211.             import exception
  212.             exception.Abort("CostumeWindow.LoadWindow.BindObject")
  213.  
  214.         ## Equipment
  215.         wndBeltInventorySlot.SetOverInItemEvent(ui.__mem_func__(self.wndInventory.OverInItem))
  216.         wndBeltInventorySlot.SetOverOutItemEvent(ui.__mem_func__(self.wndInventory.OverOutItem))
  217.         wndBeltInventorySlot.SetUnselectItemSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  218.         wndBeltInventorySlot.SetUseSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))                       
  219.         wndBeltInventorySlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.wndInventory.SelectEmptySlot))
  220.         wndBeltInventorySlot.SetSelectItemSlotEvent(ui.__mem_func__(self.wndInventory.SelectItemSlot))
  221.  
  222.         self.wndBeltInventorySlot = wndBeltInventorySlot
  223.  
  224.     def RefreshSlot(self):
  225.         getItemVNum=player.GetItemIndex
  226.        
  227.         for i in xrange(item.BELT_INVENTORY_SLOT_COUNT):
  228.             slotNumber = item.BELT_INVENTORY_SLOT_START + i
  229.             self.wndBeltInventorySlot.SetItemSlot(slotNumber, getItemVNum(slotNumber), player.GetItemCount(slotNumber))
  230.             self.wndBeltInventorySlot.SetAlwaysRenderCoverButton(slotNumber, TRUE)
  231.            
  232.             avail = "0"
  233.            
  234.             if player.IsAvailableBeltInventoryCell(slotNumber):
  235.                 self.wndBeltInventorySlot.EnableCoverButton(slotNumber)            
  236.             else:
  237.                 self.wndBeltInventorySlot.DisableCoverButton(slotNumber)               
  238.  
  239.         self.wndBeltInventorySlot.RefreshSlot()
  240.  
  241.        
  242. class InventoryWindow(ui.ScriptWindow):
  243.  
  244.     USE_TYPE_TUPLE = ("USE_CLEAN_SOCKET", "USE_CHANGE_ATTRIBUTE", "USE_ADD_ATTRIBUTE", "USE_ADD_ATTRIBUTE2", "USE_ADD_ACCESSORY_SOCKET", "USE_PUT_INTO_ACCESSORY_SOCKET", "USE_PUT_INTO_BELT_SOCKET", "USE_PUT_INTO_RING_SOCKET")
  245.  
  246.     questionDialog = None
  247.     tooltipItem = None
  248.     wndCostume = None
  249.     wndBelt = None
  250.     dlgPickMoney = None
  251.    
  252.     sellingSlotNumber = -1
  253.     isLoaded = 0
  254.     isOpenedCostumeWindowWhenClosingInventory = 0       # 인벤토리 닫을 때 코스츔이 열려있었는지 여부-_-; 네이밍 ㅈㅅ
  255.     isOpenedBeltWindowWhenClosingInventory = 0      # 인벤토리 닫을 때 벨트 인벤토리가 열려있었는지 여부-_-; 네이밍 ㅈㅅ
  256.  
  257.     def __init__(self):
  258.         ui.ScriptWindow.__init__(self)
  259.  
  260.         self.isOpenedBeltWindowWhenClosingInventory = 0     # 인벤토리 닫을 때 벨트 인벤토리가 열려있었는지 여부-_-; 네이밍 ㅈㅅ
  261.  
  262.         self.__LoadWindow()
  263.  
  264.     def __del__(self):
  265.         ui.ScriptWindow.__del__(self)
  266.  
  267.     def Show(self):
  268.         self.__LoadWindow()
  269.  
  270.         ui.ScriptWindow.Show(self)
  271.  
  272.         # 인벤토리를 닫을 때 코스츔이 열려있었다면 인벤토리를 열 때 코스츔도 같이 열도록 함.
  273.         if self.isOpenedCostumeWindowWhenClosingInventory and self.wndCostume:
  274.             self.wndCostume.Show()
  275.  
  276.         # 인벤토리를 닫을 때 벨트 인벤토리가 열려있었다면 같이 열도록 함.
  277.         if self.wndBelt:
  278.             self.wndBelt.Show(self.isOpenedBeltWindowWhenClosingInventory)
  279.  
  280.     def BindInterfaceClass(self, interface):
  281.         self.interface = interface
  282.        
  283.     def __LoadWindow(self):
  284.         if self.isLoaded == 1:
  285.             return
  286.  
  287.         self.isLoaded = 1
  288.  
  289.         try:
  290.             pyScrLoader = ui.PythonScriptLoader()
  291.  
  292.             if ITEM_MALL_BUTTON_ENABLE:
  293.                 pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "InventoryWindow.py")
  294.             else:
  295.                 pyScrLoader.LoadScriptFile(self, "UIScript/InventoryWindow.py")
  296.         except:
  297.             import exception
  298.             exception.Abort("InventoryWindow.LoadWindow.LoadObject")
  299.  
  300.         try:
  301.             wndItem = self.GetChild("ItemSlot")
  302.             wndEquip = self.GetChild("EquipmentSlot")
  303.             self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
  304.             self.wndMoney = self.GetChild("Money")
  305.             self.wndMoneySlot = self.GetChild("Money_Slot")
  306.             self.mallButton = self.GetChild2("MallButton")
  307.             self.DSSButton = self.GetChild2("DSSButton")
  308.             self.costumeButton = self.GetChild2("CostumeButton")
  309.            
  310.             self.inventoryTab = []
  311.             self.inventoryTab.append(self.GetChild("Inventory_Tab_01"))
  312.             self.inventoryTab.append(self.GetChild("Inventory_Tab_02"))
  313.             self.inventoryTab.append(self.GetChild("Inventory_Tab_03"))
  314.             self.inventoryTab.append(self.GetChild("Inventory_Tab_04"))
  315.  
  316.             self.equipmentTab = []
  317.             self.equipmentTab.append(self.GetChild("Equipment_Tab_01"))
  318.             self.equipmentTab.append(self.GetChild("Equipment_Tab_02"))
  319.  
  320.             if self.costumeButton and not app.ENABLE_COSTUME_SYSTEM:
  321.                 self.costumeButton.Hide()
  322.                 self.costumeButton.Destroy()
  323.                 self.costumeButton = 0
  324.  
  325.             # Belt Inventory Window
  326.             self.wndBelt = None
  327.            
  328.             if app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  329.                 self.wndBelt = BeltInventoryWindow(self)
  330.            
  331.         except:
  332.             import exception
  333.             exception.Abort("InventoryWindow.LoadWindow.BindObject")
  334.  
  335.         ## Item
  336.         wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  337.         wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  338.         wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
  339.         wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
  340.         wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  341.         wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  342.  
  343.         ## Equipment
  344.         wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  345.         wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  346.         wndEquip.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
  347.         wndEquip.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
  348.         wndEquip.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  349.         wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  350.  
  351.         ## PickMoneyDialog
  352.         dlgPickMoney = uiPickMoney.PickMoneyDialog()
  353.         dlgPickMoney.LoadDialog()
  354.         dlgPickMoney.Hide()
  355.  
  356.         ## RefineDialog
  357.         self.refineDialog = uiRefine.RefineDialog()
  358.         self.refineDialog.Hide()
  359.  
  360.         ## AttachMetinDialog
  361.         self.attachMetinDialog = uiAttachMetin.AttachMetinDialog()
  362.         self.attachMetinDialog.Hide()
  363.  
  364.         ## MoneySlot
  365.         self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog))
  366.  
  367.         self.inventoryTab[0].SetEvent(lambda arg=0: self.SetInventoryPage(arg))
  368.         self.inventoryTab[1].SetEvent(lambda arg=1: self.SetInventoryPage(arg))
  369.         self.inventoryTab[2].SetEvent(lambda arg=2: self.SetInventoryPage(arg))
  370.         self.inventoryTab[3].SetEvent(lambda arg=3: self.SetInventoryPage(arg))
  371.         self.inventoryPageIndex = 0
  372.  
  373.         self.equipmentTab[0].SetEvent(lambda arg=0: self.SetEquipmentPage(arg))
  374.         self.equipmentTab[1].SetEvent(lambda arg=1: self.SetEquipmentPage(arg))
  375.         self.equipmentTab[0].Down()
  376.         self.equipmentTab[0].Hide()
  377.         self.equipmentTab[1].Hide()
  378.        
  379.  
  380.         self.wndItem = wndItem
  381.         self.wndEquip = wndEquip
  382.         self.dlgPickMoney = dlgPickMoney
  383.  
  384.         # MallButton
  385.         if self.mallButton:
  386.             self.mallButton.SetEvent(ui.__mem_func__(self.ClickMallButton))
  387.  
  388.         if self.DSSButton:
  389.             self.DSSButton.SetEvent(ui.__mem_func__(self.ClickDSSButton))
  390.        
  391.         # Costume Button
  392.         if self.costumeButton:
  393.             self.costumeButton.SetEvent(ui.__mem_func__(self.ClickCostumeButton))
  394.  
  395.         self.wndCostume = None
  396.        
  397.         #####
  398.  
  399.         ## Refresh
  400.         self.SetInventoryPage(0)
  401.         self.SetEquipmentPage(0)
  402.         self.RefreshItemSlot()
  403.         self.RefreshStatus()
  404.  
  405.     def Destroy(self):
  406.         self.ClearDictionary()
  407.  
  408.         self.dlgPickMoney.Destroy()
  409.         self.dlgPickMoney = 0
  410.  
  411.         self.refineDialog.Destroy()
  412.         self.refineDialog = 0
  413.  
  414.         self.attachMetinDialog.Destroy()
  415.         self.attachMetinDialog = 0
  416.  
  417.         self.tooltipItem = None
  418.         self.wndItem = 0
  419.         self.wndEquip = 0
  420.         self.dlgPickMoney = 0
  421.         self.wndMoney = 0
  422.         self.wndMoneySlot = 0
  423.         self.questionDialog = None
  424.         self.mallButton = None
  425.         self.DSSButton = None
  426.         self.interface = None
  427.  
  428.         if self.wndCostume:
  429.             self.wndCostume.Destroy()
  430.             self.wndCostume = 0
  431.            
  432.         if self.wndBelt:
  433.             self.wndBelt.Destroy()
  434.             self.wndBelt = None
  435.            
  436.         self.inventoryTab = []
  437.         self.equipmentTab = []
  438.  
  439.     def Hide(self):
  440.         if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  441.             self.OnCloseQuestionDialog()
  442.             return
  443.         if None != self.tooltipItem:
  444.             self.tooltipItem.HideToolTip()
  445.  
  446.         if self.wndCostume:
  447.             self.isOpenedCostumeWindowWhenClosingInventory = self.wndCostume.IsShow()           # 인벤토리 창이 닫힐 때 코스츔이 열려 있었는가?
  448.             self.wndCostume.Close()
  449.  
  450.         if self.wndBelt:
  451.             self.isOpenedBeltWindowWhenClosingInventory = self.wndBelt.IsOpeningInventory()     # 인벤토리 창이 닫힐 때 벨트 인벤토리도 열려 있었는가?
  452.             print "Is Opening Belt Inven?? ", self.isOpenedBeltWindowWhenClosingInventory
  453.             self.wndBelt.Close()
  454.  
  455.         if self.dlgPickMoney:
  456.             self.dlgPickMoney.Close()
  457.        
  458.         wndMgr.Hide(self.hWnd)
  459.        
  460.    
  461.     def Close(self):
  462.         self.Hide()
  463.  
  464.     def SetInventoryPage(self, page):
  465.         self.inventoryTab[self.inventoryPageIndex].SetUp()
  466.         self.inventoryPageIndex = page
  467.         self.RefreshBagSlotWindow()
  468.  
  469.     def SetEquipmentPage(self, page):
  470.         self.equipmentPageIndex = page
  471.         self.equipmentTab[1-page].SetUp()
  472.         self.RefreshEquipSlotWindow()
  473.  
  474.     def ClickMallButton(self):
  475.         print "click_mall_button"
  476.         net.SendChatPacket("/click_mall")
  477.  
  478.     # DSSButton
  479.     def ClickDSSButton(self):
  480.         print "click_dss_button"
  481.         self.interface.ToggleDragonSoulWindow()
  482.  
  483.     def ClickCostumeButton(self):
  484.         print "Click Costume Button"
  485.         if self.wndCostume:
  486.             if self.wndCostume.IsShow():
  487.                 self.wndCostume.Hide()
  488.             else:
  489.                 self.wndCostume.Show()
  490.         else:
  491.             self.wndCostume = CostumeWindow(self)
  492.             self.wndCostume.Show()
  493.  
  494.     def OpenPickMoneyDialog(self):
  495.  
  496.         if mouseModule.mouseController.isAttached():
  497.  
  498.             attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  499.             if player.SLOT_TYPE_SAFEBOX == mouseModule.mouseController.GetAttachedType():
  500.  
  501.                 if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
  502.                     net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  503.                     snd.PlaySound("sound/ui/money.wav")
  504.  
  505.             mouseModule.mouseController.DeattachObject()
  506.  
  507.         else:
  508.             curMoney = player.GetElk()
  509.  
  510.             if curMoney <= 0:
  511.                 return
  512.  
  513.             self.dlgPickMoney.SetTitleName(localeInfo.PICK_MONEY_TITLE)
  514.             self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
  515.             self.dlgPickMoney.Open(curMoney)
  516.             self.dlgPickMoney.SetMax(7) # 인벤토리 990000 제한 버그 수정
  517.  
  518.     def OnPickMoney(self, money):
  519.         mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_INVENTORY, money)
  520.  
  521.     def OnPickItem(self, count):
  522.         itemSlotIndex = self.dlgPickMoney.itemGlobalSlotIndex
  523.         selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  524.         mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, count)
  525.  
  526.     def __InventoryLocalSlotPosToGlobalSlotPos(self, local):
  527.         if player.IsEquipmentSlot(local) or player.IsCostumeSlot(local) or (app.ENABLE_NEW_EQUIPMENT_SYSTEM and player.IsBeltInventorySlot(local)):
  528.             return local
  529.  
  530.         return self.inventoryPageIndex*player.INVENTORY_PAGE_SIZE + local
  531.  
  532.     def RefreshBagSlotWindow(self):
  533.         getItemVNum=player.GetItemIndex
  534.         getItemCount=player.GetItemCount
  535.         setItemVNum=self.wndItem.SetItemSlot
  536.        
  537.         for i in xrange(player.INVENTORY_PAGE_SIZE):
  538.             slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  539.            
  540.             itemCount = getItemCount(slotNumber)
  541.             # itemCount == 0이면 소켓을 비운다.
  542.             if 0 == itemCount:
  543.                 self.wndItem.ClearSlot(i)
  544.                 continue
  545.             elif 1 == itemCount:
  546.                 itemCount = 0
  547.                
  548.             itemVnum = getItemVNum(slotNumber)
  549.             setItemVNum(i, itemVnum, itemCount)
  550.            
  551.             ## 자동물약 (HP: #72723 ~ #72726, SP: #72727 ~ #72730) 특수처리 - 아이템인데도 슬롯에 활성화/비활성화 표시를 위한 작업임 - [hyo]
  552.             if constInfo.IS_AUTO_POTION(itemVnum):
  553.                 # metinSocket - [0] : 활성화 여부, [1] : 사용한 양, [2] : 최대 용량
  554.                 metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]  
  555.                
  556.                 if slotNumber >= player.INVENTORY_PAGE_SIZE:
  557.                     slotNumber -= player.INVENTORY_PAGE_SIZE
  558.                    
  559.                 isActivated = 0 != metinSocket[0]
  560.                
  561.                 if isActivated:
  562.                     self.wndItem.ActivateSlot(slotNumber)
  563.                     potionType = 0;
  564.                     if constInfo.IS_AUTO_POTION_HP(itemVnum):
  565.                         potionType = player.AUTO_POTION_TYPE_HP
  566.                     elif constInfo.IS_AUTO_POTION_SP(itemVnum):
  567.                         potionType = player.AUTO_POTION_TYPE_SP                    
  568.                    
  569.                     usedAmount = int(metinSocket[1])
  570.                     totalAmount = int(metinSocket[2])                  
  571.                     player.SetAutoPotionInfo(potionType, isActivated, (totalAmount - usedAmount), totalAmount, self.__InventoryLocalSlotPosToGlobalSlotPos(i))
  572.                    
  573.                 else:
  574.                     self.wndItem.DeactivateSlot(slotNumber)        
  575.                    
  576.         self.wndItem.RefreshSlot()
  577.  
  578.         if self.wndBelt:
  579.             self.wndBelt.RefreshSlot()
  580.  
  581.     def RefreshEquipSlotWindow(self):
  582.         getItemVNum=player.GetItemIndex
  583.         getItemCount=player.GetItemCount
  584.         setItemVNum=self.wndEquip.SetItemSlot
  585.         for i in xrange(player.EQUIPMENT_PAGE_COUNT):
  586.             slotNumber = player.EQUIPMENT_SLOT_START + i
  587.             itemCount = getItemCount(slotNumber)
  588.             if itemCount <= 1:
  589.                 itemCount = 0
  590.             setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  591.  
  592.         if app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  593.             for i in xrange(player.NEW_EQUIPMENT_SLOT_COUNT):
  594.                 slotNumber = player.NEW_EQUIPMENT_SLOT_START + i
  595.                 itemCount = getItemCount(slotNumber)
  596.                 if itemCount <= 1:
  597.                     itemCount = 0
  598.                 setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  599.                 print "ENABLE_NEW_EQUIPMENT_SYSTEM", slotNumber, itemCount, getItemVNum(slotNumber)
  600.                
  601.  
  602.  
  603.         self.wndEquip.RefreshSlot()
  604.        
  605.         if self.wndCostume:
  606.             self.wndCostume.RefreshCostumeSlot()
  607.  
  608.     def RefreshItemSlot(self):
  609.         self.RefreshBagSlotWindow()
  610.         self.RefreshEquipSlotWindow()
  611.  
  612.     def RefreshStatus(self):
  613.         money = player.GetElk()
  614.         self.wndMoney.SetText(localeInfo.NumberToMoneyString(money))
  615.  
  616.     def SetItemToolTip(self, tooltipItem):
  617.         self.tooltipItem = tooltipItem
  618.  
  619.     def SellItem(self):
  620.         if self.sellingSlotitemIndex == player.GetItemIndex(self.sellingSlotNumber):
  621.             if self.sellingSlotitemCount == player.GetItemCount(self.sellingSlotNumber):
  622.                 ## 용혼석도 팔리게 하는 기능 추가하면서 인자 type 추가
  623.                 net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count, player.INVENTORY)
  624.                 snd.PlaySound("sound/ui/money.wav")
  625.         self.OnCloseQuestionDialog()
  626.  
  627.     def OnDetachMetinFromItem(self):
  628.         if None == self.questionDialog:
  629.             return
  630.            
  631.         #net.SendItemUseToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)     
  632.         self.__SendUseItemToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  633.         self.OnCloseQuestionDialog()
  634.  
  635.     def OnCloseQuestionDialog(self):
  636.         if not self.questionDialog:
  637.             return
  638.        
  639.         self.questionDialog.Close()
  640.         self.questionDialog = None
  641.         constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  642.  
  643.     ## Slot Event
  644.     def SelectEmptySlot(self, selectedSlotPos):
  645.         if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  646.             return
  647.  
  648.         selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos)
  649.  
  650.         if mouseModule.mouseController.isAttached():
  651.  
  652.             attachedSlotType = mouseModule.mouseController.GetAttachedType()
  653.             attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  654.             attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
  655.             attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  656.  
  657.             if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  658.                 itemCount = player.GetItemCount(attachedSlotPos)
  659.                 attachedCount = mouseModule.mouseController.GetAttachedItemCount()
  660.                 self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
  661.  
  662.                 if item.IsRefineScroll(attachedItemIndex):
  663.                     self.wndItem.SetUseMode(False)
  664.  
  665.             elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
  666.                 mouseModule.mouseController.RunCallBack("INVENTORY")
  667.  
  668.             elif player.SLOT_TYPE_SHOP == attachedSlotType:
  669.                 net.SendShopBuyPacket(attachedSlotPos)
  670.  
  671.             elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:
  672.  
  673.                 if player.ITEM_MONEY == attachedItemIndex:
  674.                     net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  675.                     snd.PlaySound("sound/ui/money.wav")
  676.  
  677.                 else:
  678.                     net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos)
  679.  
  680.             elif player.SLOT_TYPE_MALL == attachedSlotType:
  681.                 net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos)
  682.  
  683.             mouseModule.mouseController.DeattachObject()
  684.  
  685.     def SelectItemSlot(self, itemSlotIndex):
  686.         if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  687.             return
  688.  
  689.         itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(itemSlotIndex)
  690.  
  691.         if mouseModule.mouseController.isAttached():
  692.             attachedSlotType = mouseModule.mouseController.GetAttachedType()
  693.             attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  694.             attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex()
  695.  
  696.             if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  697.                 self.__DropSrcItemToDestItemInInventory(attachedItemVID, attachedSlotPos, itemSlotIndex)
  698.  
  699.             mouseModule.mouseController.DeattachObject()
  700.  
  701.         else:
  702.  
  703.             curCursorNum = app.GetCursor()
  704.             if app.SELL == curCursorNum:
  705.                 self.__SellItem(itemSlotIndex)
  706.                
  707.             elif app.BUY == curCursorNum:
  708.                 chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
  709.  
  710.             elif app.IsPressed(app.DIK_LALT):
  711.                 link = player.GetItemLink(itemSlotIndex)
  712.                 ime.PasteString(link)
  713.  
  714.             elif app.IsPressed(app.DIK_LSHIFT):
  715.                 itemCount = player.GetItemCount(itemSlotIndex)
  716.                
  717.                 if itemCount > 1:
  718.                     self.dlgPickMoney.SetTitleName(localeInfo.PICK_ITEM_TITLE)
  719.                     self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickItem))
  720.                     self.dlgPickMoney.Open(itemCount)
  721.                     self.dlgPickMoney.itemGlobalSlotIndex = itemSlotIndex
  722.                 #else:
  723.                     #selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  724.                     #mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum)
  725.  
  726.             elif app.IsPressed(app.DIK_LCONTROL):
  727.                 itemIndex = player.GetItemIndex(itemSlotIndex)
  728.  
  729.                 if True == item.CanAddToQuickSlotItem(itemIndex):
  730.                     player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_INVENTORY, itemSlotIndex)
  731.                 else:
  732.                     chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.QUICKSLOT_REGISTER_DISABLE_ITEM)
  733.  
  734.             else:
  735.                 selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  736.                 itemCount = player.GetItemCount(itemSlotIndex)
  737.                 mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, itemCount)
  738.                
  739.                 if self.__IsUsableItemToItem(selectedItemVNum, itemSlotIndex):             
  740.                     self.wndItem.SetUseMode(True)
  741.                 else:                  
  742.                     self.wndItem.SetUseMode(False)
  743.  
  744.                 snd.PlaySound("sound/ui/pick.wav")
  745.  
  746.     def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos):
  747.         if srcItemSlotPos == dstItemSlotPos:
  748.             return
  749.                
  750.         elif item.IsRefineScroll(srcItemVID):
  751.             self.RefineItem(srcItemSlotPos, dstItemSlotPos)
  752.             self.wndItem.SetUseMode(False)
  753.  
  754.         elif item.IsMetin(srcItemVID):
  755.             self.AttachMetinToItem(srcItemSlotPos, dstItemSlotPos)
  756.  
  757.         elif item.IsDetachScroll(srcItemVID):
  758.             self.DetachMetinFromItem(srcItemSlotPos, dstItemSlotPos)
  759.  
  760.         elif item.IsKey(srcItemVID):
  761.             self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)         
  762.  
  763.         elif (player.GetItemFlags(srcItemSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  764.             self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  765.  
  766.         elif item.GetUseType(srcItemVID) in self.USE_TYPE_TUPLE:
  767.             self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)         
  768.  
  769.         else:
  770.             #snd.PlaySound("sound/ui/drop.wav")
  771.  
  772.             ## 이동시킨 곳이 장착 슬롯일 경우 아이템을 사용해서 장착 시킨다 - [levites]
  773.             if player.IsEquipmentSlot(dstItemSlotPos):
  774.  
  775.                 ## 들고 있는 아이템이 장비일때만
  776.                 if item.IsEquipmentVID(srcItemVID):
  777.                     self.__UseItem(srcItemSlotPos)
  778.  
  779.             else:
  780.                 self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0)
  781.                 #net.SendItemMovePacket(srcItemSlotPos, dstItemSlotPos, 0)
  782.  
  783.     def __SellItem(self, itemSlotPos):
  784.         if not player.IsEquipmentSlot(itemSlotPos):
  785.             self.sellingSlotNumber = itemSlotPos
  786.             itemIndex = player.GetItemIndex(itemSlotPos)
  787.             itemCount = player.GetItemCount(itemSlotPos)
  788.            
  789.            
  790.             self.sellingSlotitemIndex = itemIndex
  791.             self.sellingSlotitemCount = itemCount
  792.  
  793.             item.SelectItem(itemIndex)
  794.             ## 안티 플레그 검사 빠져서 추가
  795.             ## 20140220
  796.             if item.IsAntiFlag(item.ANTIFLAG_SELL):
  797.                 popup = uiCommon.PopupDialog()
  798.                 popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
  799.                 popup.SetAcceptEvent(self.__OnClosePopupDialog)
  800.                 popup.Open()
  801.                 self.popup = popup
  802.                 return
  803.  
  804.             itemPrice = item.GetISellItemPrice()
  805.  
  806.             if item.Is1GoldItem():
  807.                 itemPrice = itemCount / itemPrice / 5
  808.             else:
  809.                 itemPrice = itemPrice * itemCount / 5
  810.  
  811.             item.GetItemName(itemIndex)
  812.             itemName = item.GetItemName()
  813.  
  814.             self.questionDialog = uiCommon.QuestionDialog()
  815.             self.questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice))
  816.             self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem))
  817.             self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  818.             self.questionDialog.Open()
  819.             self.questionDialog.count = itemCount
  820.        
  821.             constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  822.  
  823.     def __OnClosePopupDialog(self):
  824.         self.pop = None
  825.  
  826.     def RefineItem(self, scrollSlotPos, targetSlotPos):
  827.  
  828.         scrollIndex = player.GetItemIndex(scrollSlotPos)
  829.         targetIndex = player.GetItemIndex(targetSlotPos)
  830.  
  831.         if player.REFINE_OK != player.CanRefine(scrollIndex, targetSlotPos):
  832.             return
  833.  
  834.         ###########################################################
  835.         self.__SendUseItemToItemPacket(scrollSlotPos, targetSlotPos)
  836.         #net.SendItemUseToItemPacket(scrollSlotPos, targetSlotPos)
  837.         return
  838.         ###########################################################
  839.  
  840.         ###########################################################
  841.         #net.SendRequestRefineInfoPacket(targetSlotPos)
  842.         #return
  843.         ###########################################################
  844.  
  845.         result = player.CanRefine(scrollIndex, targetSlotPos)
  846.  
  847.         if player.REFINE_ALREADY_MAX_SOCKET_COUNT == result:
  848.             #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  849.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_MORE_SOCKET)
  850.  
  851.         elif player.REFINE_NEED_MORE_GOOD_SCROLL == result:
  852.             #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  853.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NEED_BETTER_SCROLL)
  854.  
  855.         elif player.REFINE_CANT_MAKE_SOCKET_ITEM == result:
  856.             #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  857.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_SOCKET_DISABLE_ITEM)
  858.  
  859.         elif player.REFINE_NOT_NEXT_GRADE_ITEM == result:
  860.             #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  861.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_UPGRADE_DISABLE_ITEM)
  862.  
  863.         elif player.REFINE_CANT_REFINE_METIN_TO_EQUIPMENT == result:
  864.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  865.  
  866.         if player.REFINE_OK != result:
  867.             return
  868.  
  869.         self.refineDialog.Open(scrollSlotPos, targetSlotPos)
  870.  
  871.     def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos):
  872.         scrollIndex = player.GetItemIndex(scrollSlotPos)
  873.         targetIndex = player.GetItemIndex(targetSlotPos)
  874.  
  875.         if not player.CanDetach(scrollIndex, targetSlotPos):
  876.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  877.             return
  878.  
  879.         self.questionDialog = uiCommon.QuestionDialog()
  880.         self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN)
  881.         self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  882.         self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  883.         self.questionDialog.Open()
  884.         self.questionDialog.sourcePos = scrollSlotPos
  885.         self.questionDialog.targetPos = targetSlotPos
  886.  
  887.     def AttachMetinToItem(self, metinSlotPos, targetSlotPos):
  888.         metinIndex = player.GetItemIndex(metinSlotPos)
  889.         targetIndex = player.GetItemIndex(targetSlotPos)
  890.  
  891.         item.SelectItem(metinIndex)
  892.         itemName = item.GetItemName()
  893.  
  894.         result = player.CanAttachMetin(metinIndex, targetSlotPos)
  895.  
  896.         if player.ATTACH_METIN_NOT_MATCHABLE_ITEM == result:
  897.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_CAN_NOT_ATTACH(itemName))
  898.  
  899.         if player.ATTACH_METIN_NO_MATCHABLE_SOCKET == result:
  900.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_SOCKET(itemName))
  901.  
  902.         elif player.ATTACH_METIN_NOT_EXIST_GOLD_SOCKET == result:
  903.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_GOLD_SOCKET(itemName))
  904.  
  905.         elif player.ATTACH_METIN_CANT_ATTACH_TO_EQUIPMENT == result:
  906.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  907.  
  908.         if player.ATTACH_METIN_OK != result:
  909.             return
  910.  
  911.         self.attachMetinDialog.Open(metinSlotPos, targetSlotPos)
  912.  
  913.  
  914.        
  915.     def OverOutItem(self):
  916.         self.wndItem.SetUsableItem(False)
  917.         if None != self.tooltipItem:
  918.             self.tooltipItem.HideToolTip()
  919.  
  920.     def OverInItem(self, overSlotPos):
  921.         overSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos)
  922.         self.wndItem.SetUsableItem(False)
  923.  
  924.         if mouseModule.mouseController.isAttached():
  925.             attachedItemType = mouseModule.mouseController.GetAttachedType()
  926.             if player.SLOT_TYPE_INVENTORY == attachedItemType:
  927.  
  928.                 attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  929.                 attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex()
  930.                
  931.                 if self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overSlotPos):
  932.                     self.wndItem.SetUsableItem(True)
  933.                     self.ShowToolTip(overSlotPos)
  934.                     return
  935.                
  936.         self.ShowToolTip(overSlotPos)
  937.  
  938.  
  939.     def __IsUsableItemToItem(self, srcItemVNum, srcSlotPos):
  940.         "다른 아이템에 사용할 수 있는 아이템인가?"
  941.  
  942.         if item.IsRefineScroll(srcItemVNum):
  943.             return True
  944.         elif item.IsMetin(srcItemVNum):
  945.             return True
  946.         elif item.IsDetachScroll(srcItemVNum):
  947.             return True
  948.         elif item.IsKey(srcItemVNum):
  949.             return True
  950.         elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  951.             return True
  952.         else:
  953.             if item.GetUseType(srcItemVNum) in self.USE_TYPE_TUPLE:
  954.                 return True
  955.            
  956.         return False
  957.  
  958.     def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos):
  959.         "대상 아이템에 사용할 수 있는가?"
  960.  
  961.         if srcSlotPos == dstSlotPos:
  962.             return False
  963.  
  964.         if item.IsRefineScroll(srcItemVNum):
  965.             if player.REFINE_OK == player.CanRefine(srcItemVNum, dstSlotPos):
  966.                 return True
  967.         elif item.IsMetin(srcItemVNum):
  968.             if player.ATTACH_METIN_OK == player.CanAttachMetin(srcItemVNum, dstSlotPos):
  969.                 return True
  970.         elif item.IsDetachScroll(srcItemVNum):
  971.             if player.DETACH_METIN_OK == player.CanDetach(srcItemVNum, dstSlotPos):
  972.                 return True
  973.         elif item.IsKey(srcItemVNum):
  974.             if player.CanUnlock(srcItemVNum, dstSlotPos):
  975.                 return True
  976.  
  977.         elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  978.             return True
  979.  
  980.         else:
  981.             useType=item.GetUseType(srcItemVNum)
  982.  
  983.             if "USE_CLEAN_SOCKET" == useType:
  984.                 if self.__CanCleanBrokenMetinStone(dstSlotPos):
  985.                     return True
  986.             elif "USE_CHANGE_ATTRIBUTE" == useType:
  987.                 if self.__CanChangeItemAttrList(dstSlotPos):
  988.                     return True
  989.             elif "USE_ADD_ATTRIBUTE" == useType:
  990.                 if self.__CanAddItemAttr(dstSlotPos):
  991.                     return True
  992.             elif "USE_ADD_ATTRIBUTE2" == useType:
  993.                 if self.__CanAddItemAttr(dstSlotPos):
  994.                     return True
  995.             elif "USE_ADD_ACCESSORY_SOCKET" == useType:
  996.                 if self.__CanAddAccessorySocket(dstSlotPos):
  997.                     return True
  998.             elif "USE_PUT_INTO_ACCESSORY_SOCKET" == useType:                               
  999.                 if self.__CanPutAccessorySocket(dstSlotPos, srcItemVNum):
  1000.                     return TRUE;
  1001.             elif "USE_PUT_INTO_BELT_SOCKET" == useType:                            
  1002.                 dstItemVNum = player.GetItemIndex(dstSlotPos)
  1003.                 print "USE_PUT_INTO_BELT_SOCKET", srcItemVNum, dstItemVNum
  1004.  
  1005.                 item.SelectItem(dstItemVNum)
  1006.        
  1007.                 if item.ITEM_TYPE_BELT == item.GetItemType():
  1008.                     return True
  1009.  
  1010.         return False
  1011.  
  1012.     def __CanCleanBrokenMetinStone(self, dstSlotPos):
  1013.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1014.         if dstItemVNum == 0:
  1015.             return False
  1016.  
  1017.         item.SelectItem(dstItemVNum)
  1018.        
  1019.         if item.ITEM_TYPE_WEAPON != item.GetItemType():
  1020.             return False
  1021.  
  1022.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1023.             if player.GetItemMetinSocket(dstSlotPos, i) == constInfo.ERROR_METIN_STONE:
  1024.                 return True
  1025.  
  1026.         return False
  1027.  
  1028.     def __CanChangeItemAttrList(self, dstSlotPos):
  1029.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1030.         if dstItemVNum == 0:
  1031.             return False
  1032.  
  1033.         item.SelectItem(dstItemVNum)
  1034.        
  1035.         if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):  
  1036.             return False
  1037.  
  1038.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1039.             if player.GetItemAttribute(dstSlotPos, i) != 0:
  1040.                 return True
  1041.  
  1042.         return False
  1043.  
  1044.     def __CanPutAccessorySocket(self, dstSlotPos, mtrlVnum):
  1045.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1046.         if dstItemVNum == 0:
  1047.             return False
  1048.  
  1049.         item.SelectItem(dstItemVNum)
  1050.  
  1051.         if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1052.             return False
  1053.  
  1054.         if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1055.             return False
  1056.  
  1057.         curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1058.         maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1059.  
  1060.         if mtrlVnum != constInfo.GET_ACCESSORY_MATERIAL_VNUM(dstItemVNum, item.GetItemSubType()):
  1061.             return False
  1062.        
  1063.         if curCount>=maxCount:
  1064.             return False
  1065.  
  1066.         return True
  1067.  
  1068.     def __CanAddAccessorySocket(self, dstSlotPos):
  1069.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1070.         if dstItemVNum == 0:
  1071.             return False
  1072.  
  1073.         item.SelectItem(dstItemVNum)
  1074.  
  1075.         if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1076.             return False
  1077.  
  1078.         if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1079.             return False
  1080.  
  1081.         curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1082.         maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1083.        
  1084.         ACCESSORY_SOCKET_MAX_SIZE = 3
  1085.         if maxCount >= ACCESSORY_SOCKET_MAX_SIZE:
  1086.             return False
  1087.  
  1088.         return True
  1089.  
  1090.     def __CanAddItemAttr(self, dstSlotPos):
  1091.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1092.         if dstItemVNum == 0:
  1093.             return False
  1094.  
  1095.         item.SelectItem(dstItemVNum)
  1096.        
  1097.         if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):  
  1098.             return False
  1099.            
  1100.         attrCount = 0
  1101.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1102.             if player.GetItemAttribute(dstSlotPos, i) != 0:
  1103.                 attrCount += 1
  1104.  
  1105.         if attrCount<4:
  1106.             return True
  1107.                                
  1108.         return False
  1109.  
  1110.     def ShowToolTip(self, slotIndex):
  1111.         if None != self.tooltipItem:
  1112.             self.tooltipItem.SetInventoryItem(slotIndex)
  1113.  
  1114.     def OnTop(self):
  1115.         if None != self.tooltipItem:
  1116.             self.tooltipItem.SetTop()
  1117.  
  1118.     def OnPressEscapeKey(self):
  1119.         self.Close()
  1120.         return True
  1121.  
  1122.     def UseItemSlot(self, slotIndex):
  1123.         curCursorNum = app.GetCursor()
  1124.         if app.SELL == curCursorNum:
  1125.             return
  1126.  
  1127.         if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  1128.             return
  1129.  
  1130.         slotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(slotIndex)
  1131.  
  1132.         if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1133.             if self.wndDragonSoulRefine.IsShow():
  1134.                 self.wndDragonSoulRefine.AutoSetItem((player.INVENTORY, slotIndex), 1)
  1135.                 return
  1136.  
  1137.         self.__UseItem(slotIndex)
  1138.         mouseModule.mouseController.DeattachObject()
  1139.         self.OverOutItem()
  1140.  
  1141.     def __UseItem(self, slotIndex):
  1142.         ItemVNum = player.GetItemIndex(slotIndex)
  1143.         item.SelectItem(ItemVNum)
  1144.         if item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE):
  1145.             self.questionDialog = uiCommon.QuestionDialog()
  1146.             self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_ITEM)
  1147.             self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnAccept))
  1148.             self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnCancel))
  1149.             self.questionDialog.Open()
  1150.             self.questionDialog.slotIndex = slotIndex
  1151.        
  1152.             constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  1153.  
  1154.         else:
  1155.             self.__SendUseItemPacket(slotIndex)
  1156.             #net.SendItemUsePacket(slotIndex)  
  1157.  
  1158.     def __UseItemQuestionDialog_OnCancel(self):
  1159.         self.OnCloseQuestionDialog()
  1160.  
  1161.     def __UseItemQuestionDialog_OnAccept(self):
  1162.         self.__SendUseItemPacket(self.questionDialog.slotIndex)
  1163.         self.OnCloseQuestionDialog()       
  1164.  
  1165.     def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos):
  1166.         # 개인상점 열고 있는 동안 아이템 사용 방지
  1167.         if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1168.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1169.             return
  1170.  
  1171.         net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos)
  1172.  
  1173.     def __SendUseItemPacket(self, slotPos):
  1174.         # 개인상점 열고 있는 동안 아이템 사용 방지
  1175.         if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1176.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1177.             return
  1178.  
  1179.         net.SendItemUsePacket(slotPos)
  1180.    
  1181.     def __SendMoveItemPacket(self, srcSlotPos, dstSlotPos, srcItemCount):
  1182.         # 개인상점 열고 있는 동안 아이템 사용 방지
  1183.         if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1184.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP)
  1185.             return
  1186.  
  1187.         net.SendItemMovePacket(srcSlotPos, dstSlotPos, srcItemCount)
  1188.    
  1189.     def SetDragonSoulRefineWindow(self, wndDragonSoulRefine):
  1190.         if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1191.             self.wndDragonSoulRefine = wndDragonSoulRefine
  1192.            
  1193.     def OnMoveWindow(self, x, y):
  1194. #       print "Inventory Global Pos : ", self.GetGlobalPosition()
  1195.         if self.wndBelt:
  1196. #           print "Belt Global Pos : ", self.wndBelt.GetGlobalPosition()
  1197.             self.wndBelt.AdjustPositionAndSize()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement