Guest User

Untitled

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