Guest User

Untitled

a guest
Aug 23rd, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 44.23 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", "USE_BELT_CHANGE_ATTRIBUTE", "USE_BELT_ADD_ATTRIBUTE")
  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.inventoryTab[0].Down()
  372.         self.inventoryPageIndex = 0
  373.  
  374.         self.equipmentTab[0].SetEvent(lambda arg=0: self.SetEquipmentPage(arg))
  375.         self.equipmentTab[1].SetEvent(lambda arg=1: self.SetEquipmentPage(arg))
  376.         self.equipmentTab[0].Down()
  377.         self.equipmentTab[0].Hide()
  378.         self.equipmentTab[1].Hide()
  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.Hide()
  390.             #self.DSSButton.SetEvent(ui.__mem_func__(self.ClickDSSButton))
  391.        
  392.         # Costume Button
  393.         if self.costumeButton:
  394.             self.costumeButton.SetEvent(ui.__mem_func__(self.ClickCostumeButton))
  395.  
  396.         self.wndCostume = None
  397.  
  398.         if app.ENABLE_HIGHLIGHT_SYSTEM:
  399.             self.listHighlightedSlot = []
  400.        
  401.         #####
  402.  
  403.         ## Refresh
  404.         self.SetInventoryPage(0)
  405.         self.SetEquipmentPage(0)
  406.         self.RefreshItemSlot()
  407.         self.RefreshStatus()
  408.  
  409.     def Destroy(self):
  410.         self.ClearDictionary()
  411.  
  412.         self.dlgPickMoney.Destroy()
  413.         self.dlgPickMoney = 0
  414.  
  415.         self.refineDialog.Destroy()
  416.         self.refineDialog = 0
  417.  
  418.         self.attachMetinDialog.Destroy()
  419.         self.attachMetinDialog = 0
  420.  
  421.         self.tooltipItem = None
  422.         self.wndItem = 0
  423.         self.wndEquip = 0
  424.         self.dlgPickMoney = 0
  425.         self.wndMoney = 0
  426.         self.wndMoneySlot = 0
  427.         self.questionDialog = None
  428.         self.mallButton = None
  429.         self.DSSButton = None
  430.         self.interface = None
  431.  
  432.         if self.wndCostume:
  433.             self.wndCostume.Destroy()
  434.             self.wndCostume = 0
  435.            
  436.         if self.wndBelt:
  437.             self.wndBelt.Destroy()
  438.             self.wndBelt = None
  439.            
  440.         self.inventoryTab = []
  441.         self.equipmentTab = []
  442.  
  443.     def Hide(self):
  444.         if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  445.             self.OnCloseQuestionDialog()
  446.             return
  447.         if None != self.tooltipItem:
  448.             self.tooltipItem.HideToolTip()
  449.  
  450.         if self.wndCostume:
  451.             self.isOpenedCostumeWindowWhenClosingInventory = self.wndCostume.IsShow()           # 인벤토리 창이 닫힐 때 코스츔이 열려 있었는가?
  452.             self.wndCostume.Close()
  453.  
  454.         if self.wndBelt:
  455.             self.isOpenedBeltWindowWhenClosingInventory = self.wndBelt.IsOpeningInventory()     # 인벤토리 창이 닫힐 때 벨트 인벤토리도 열려 있었는가?
  456.             print "Is Opening Belt Inven?? ", self.isOpenedBeltWindowWhenClosingInventory
  457.             self.wndBelt.Close()
  458.  
  459.         if self.dlgPickMoney:
  460.             self.dlgPickMoney.Close()
  461.        
  462.         wndMgr.Hide(self.hWnd)
  463.        
  464.    
  465.     def Close(self):
  466.         self.Hide()
  467.  
  468.     if app.ENABLE_HIGHLIGHT_SYSTEM:
  469.         def HighlightSlot(self, slot):
  470.             if not slot in self.listHighlightedSlot:
  471.                 self.listHighlightedSlot.append(slot)
  472.  
  473.     def SetInventoryPage(self, page):
  474.         self.inventoryTab[self.inventoryPageIndex].SetUp()
  475.         self.inventoryPageIndex = page
  476.         self.inventoryTab[self.inventoryPageIndex].Down()
  477.         self.RefreshBagSlotWindow()
  478.  
  479.     def SetEquipmentPage(self, page):
  480.         self.equipmentPageIndex = page
  481.         self.equipmentTab[1-page].SetUp()
  482.         self.RefreshEquipSlotWindow()
  483.  
  484.     def ClickMallButton(self):
  485.         print "click_mall_button"
  486.         net.SendChatPacket("/click_mall")
  487.  
  488.     # DSSButton
  489.     def ClickDSSButton(self):
  490.         print "click_dss_button"
  491.         self.interface.ToggleDragonSoulWindow()
  492.  
  493.     def ClickCostumeButton(self):
  494.         print "Click Costume Button"
  495.         if self.wndCostume:
  496.             if self.wndCostume.IsShow():
  497.                 self.wndCostume.Hide()
  498.             else:
  499.                 self.wndCostume.Show()
  500.         else:
  501.             self.wndCostume = CostumeWindow(self)
  502.             self.wndCostume.Show()
  503.  
  504.     def OpenPickMoneyDialog(self):
  505.  
  506.         if mouseModule.mouseController.isAttached():
  507.  
  508.             attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  509.             if player.SLOT_TYPE_SAFEBOX == mouseModule.mouseController.GetAttachedType():
  510.  
  511.                 if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
  512.                     net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  513.                     snd.PlaySound("sound/ui/money.wav")
  514.  
  515.             mouseModule.mouseController.DeattachObject()
  516.  
  517.         else:
  518.             curMoney = player.GetElk()
  519.  
  520.             if curMoney <= 0:
  521.                 return
  522.  
  523.             self.dlgPickMoney.SetTitleName(localeInfo.PICK_MONEY_TITLE)
  524.             self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
  525.             self.dlgPickMoney.Open(curMoney)
  526.             self.dlgPickMoney.SetMax(7) # 인벤토리 990000 제한 버그 수정
  527.  
  528.     def OnPickMoney(self, money):
  529.         mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_INVENTORY, money)
  530.  
  531.     def OnPickItem(self, count):
  532.         itemSlotIndex = self.dlgPickMoney.itemGlobalSlotIndex
  533.         selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  534.         mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, count)
  535.  
  536.     def __InventoryLocalSlotPosToGlobalSlotPos(self, local):
  537.         if player.IsEquipmentSlot(local) or player.IsCostumeSlot(local) or (app.ENABLE_NEW_EQUIPMENT_SYSTEM and player.IsBeltInventorySlot(local)):
  538.             return local
  539.  
  540.         return self.inventoryPageIndex*player.INVENTORY_PAGE_SIZE + local
  541.  
  542.     def RefreshBagSlotWindow(self):
  543.         is_activated = 0
  544.         getItemVNum=player.GetItemIndex
  545.         getItemCount=player.GetItemCount
  546.         setItemVNum=self.wndItem.SetItemSlot
  547.         for i in xrange(player.INVENTORY_PAGE_SIZE*2):
  548.             slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  549.             itemCount = getItemCount(slotNumber)
  550.             if 0 == itemCount:
  551.                 self.wndItem.ClearSlot(i)
  552.                 continue
  553.             elif 1 == itemCount:
  554.                 itemCount = 0
  555.            
  556.             itemVnum = getItemVNum(slotNumber)
  557.             setItemVNum(i, itemVnum, itemCount)
  558.             if constInfo.IS_AUTO_POTION(itemVnum):
  559.                 metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  560.                 if slotNumber >= player.INVENTORY_PAGE_SIZE:
  561.                     slotNumber -= player.INVENTORY_PAGE_SIZE
  562.                
  563.                 isActivated = 0 != metinSocket[0]
  564.                 if isActivated:
  565.                     self.wndItem.ActivateSlot(i)
  566.                     potionType = 0;
  567.                     if constInfo.IS_AUTO_POTION_HP(itemVnum):
  568.                         potionType = player.AUTO_POTION_TYPE_HP
  569.                     elif constInfo.IS_AUTO_POTION_SP(itemVnum):
  570.                         potionType = player.AUTO_POTION_TYPE_SP
  571.                    
  572.                     usedAmount = int(metinSocket[1])
  573.                     totalAmount = int(metinSocket[2])
  574.                     player.SetAutoPotionInfo(potionType, isActivated, (totalAmount - usedAmount), totalAmount, self.__InventoryLocalSlotPosToGlobalSlotPos(i))
  575.                 else:
  576.                     self.wndItem.DeactivateSlot(i)
  577.             elif app.ENABLE_HIGHLIGHT_SYSTEM:
  578.                 if slotNumber in self.listHighlightedSlot:
  579.                     self.wndItem.ActivateSlot(i)
  580.             elif constInfo.IS_ACCE_ITEM(itemVnum, 1) == TRUE:
  581.                 metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  582.                 isActivated = metinSocket[0]
  583.                 if isActivated == 1:
  584.                     player.SetAcceInfo(isActivated, i)
  585.                     self.wndItem.ActivateAcceSlot(i)
  586.                 else:
  587.                     self.wndItem.DeactivateAcceSlot(i)
  588.        
  589.         self.wndItem.RefreshSlot()
  590.         if self.wndBelt:
  591.             self.wndBelt.RefreshSlot()
  592.  
  593.     def RefreshEquipSlotWindow(self):
  594.         getItemVNum=player.GetItemIndex
  595.         getItemCount=player.GetItemCount
  596.         setItemVNum=self.wndEquip.SetItemSlot
  597.         for i in xrange(player.EQUIPMENT_PAGE_COUNT):
  598.             slotNumber = player.EQUIPMENT_SLOT_START + i
  599.             itemCount = getItemCount(slotNumber)
  600.             if itemCount <= 1:
  601.                 itemCount = 0
  602.             setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  603.  
  604.         if app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  605.             for i in xrange(player.NEW_EQUIPMENT_SLOT_COUNT):
  606.                 slotNumber = player.NEW_EQUIPMENT_SLOT_START + i
  607.                 itemCount = getItemCount(slotNumber)
  608.                 if itemCount <= 1:
  609.                     itemCount = 0
  610.                 setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  611.                 print "ENABLE_NEW_EQUIPMENT_SYSTEM", slotNumber, itemCount, getItemVNum(slotNumber)
  612.                
  613.  
  614.  
  615.         self.wndEquip.RefreshSlot()
  616.        
  617.         if self.wndCostume:
  618.             self.wndCostume.RefreshCostumeSlot()
  619.  
  620.     def RefreshItemSlot(self):
  621.         self.RefreshBagSlotWindow()
  622.         self.RefreshEquipSlotWindow()
  623.  
  624.     def  RefreshStatus ( self ):
  625.         money = player . GetElk ()
  626.         if money <=  100000000 :
  627.             self . wndMoney . SetFontColor ( 1.0 ,  0.2 ,  0.2 )
  628.         elif money >=  100000001  and money <=  1000000000 :
  629.             self . wndMoney . SetFontColor ( 1.0 ,  0.6 ,  0.2 )
  630.         elif money >=  1000000001  and money <=  1500000000 :
  631.             self . wndMoney . SetFontColor ( 1.0 ,  1.0 ,  0.2 )
  632.         elif money >=  1500000001 :
  633.             self . wndMoney . SetFontColor ( 0.6 ,  1.0 ,  0.2 )
  634.         self . wndMoney . SetText ( localeInfo . NumberToMoneyString ( money ))
  635.  
  636.     def SetItemToolTip(self, tooltipItem):
  637.         self.tooltipItem = tooltipItem
  638.  
  639.     def SellItem(self):
  640.         if self.sellingSlotitemIndex == player.GetItemIndex(self.sellingSlotNumber):
  641.             if self.sellingSlotitemCount == player.GetItemCount(self.sellingSlotNumber):
  642.                 ## 용혼석도 팔리게 하는 기능 추가하면서 인자 type 추가
  643.                 net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count, player.INVENTORY)
  644.                 snd.PlaySound("sound/ui/money.wav")
  645.         self.OnCloseQuestionDialog()
  646.  
  647.     def OnDetachMetinFromItem(self):
  648.         if None == self.questionDialog:
  649.             return
  650.            
  651.         #net.SendItemUseToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)     
  652.         self.__SendUseItemToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  653.         self.OnCloseQuestionDialog()
  654.  
  655.     def OnCloseQuestionDialog(self):
  656.         if not self.questionDialog:
  657.             return
  658.        
  659.         self.questionDialog.Close()
  660.         self.questionDialog = None
  661.         constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  662.  
  663.     ## Slot Event
  664.     def SelectEmptySlot(self, selectedSlotPos):
  665.         if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  666.             return
  667.  
  668.         selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos)
  669.  
  670.         if mouseModule.mouseController.isAttached():
  671.  
  672.             attachedSlotType = mouseModule.mouseController.GetAttachedType()
  673.             attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  674.             attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
  675.             attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  676.  
  677.             if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  678.                 itemCount = player.GetItemCount(attachedSlotPos)
  679.                 attachedCount = mouseModule.mouseController.GetAttachedItemCount()
  680.                 self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
  681.  
  682.                 if item.IsRefineScroll(attachedItemIndex):
  683.                     self.wndItem.SetUseMode(False)
  684.  
  685.             elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
  686.                 mouseModule.mouseController.RunCallBack("INVENTORY")
  687.  
  688.             elif player.SLOT_TYPE_SHOP == attachedSlotType:
  689.                 net.SendShopBuyPacket(attachedSlotPos)
  690.  
  691.             elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:
  692.  
  693.                 if player.ITEM_MONEY == attachedItemIndex:
  694.                     net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  695.                     snd.PlaySound("sound/ui/money.wav")
  696.  
  697.                 else:
  698.                     net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos)
  699.  
  700.             elif player.SLOT_TYPE_MALL == attachedSlotType:
  701.                 net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos)
  702.  
  703.             mouseModule.mouseController.DeattachObject()
  704.  
  705.     def SelectItemSlot(self, itemSlotIndex):
  706.         if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  707.             return
  708.  
  709.         itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(itemSlotIndex)
  710.  
  711.         if mouseModule.mouseController.isAttached():
  712.             attachedSlotType = mouseModule.mouseController.GetAttachedType()
  713.             attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  714.             attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex()
  715.  
  716.             if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  717.                 self.__DropSrcItemToDestItemInInventory(attachedItemVID, attachedSlotPos, itemSlotIndex)
  718.  
  719.             mouseModule.mouseController.DeattachObject()
  720.  
  721.         else:
  722.  
  723.             curCursorNum = app.GetCursor()
  724.             if app.SELL == curCursorNum:
  725.                 self.__SellItem(itemSlotIndex)
  726.                
  727.             elif app.BUY == curCursorNum:
  728.                 chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
  729.  
  730.             elif app.IsPressed(app.DIK_LALT):
  731.                 link = player.GetItemLink(itemSlotIndex)
  732.                 ime.PasteString(link)
  733.  
  734.             elif app.IsPressed(app.DIK_LSHIFT):
  735.                 itemCount = player.GetItemCount(itemSlotIndex)
  736.                
  737.                 if itemCount > 1:
  738.                     self.dlgPickMoney.SetTitleName(localeInfo.PICK_ITEM_TITLE)
  739.                     self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickItem))
  740.                     self.dlgPickMoney.Open(itemCount)
  741.                     self.dlgPickMoney.itemGlobalSlotIndex = itemSlotIndex
  742.                 #else:
  743.                     #selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  744.                     #mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum)
  745.  
  746.             elif app.IsPressed(app.DIK_LCONTROL):
  747.                 itemIndex = player.GetItemIndex(itemSlotIndex)
  748.  
  749.                 if True == item.CanAddToQuickSlotItem(itemIndex):
  750.                     player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_INVENTORY, itemSlotIndex)
  751.                 else:
  752.                     chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.QUICKSLOT_REGISTER_DISABLE_ITEM)
  753.  
  754.             else:
  755.                 selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  756.                 itemCount = player.GetItemCount(itemSlotIndex)
  757.                 mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, itemCount)
  758.                
  759.                 if self.__IsUsableItemToItem(selectedItemVNum, itemSlotIndex):             
  760.                     self.wndItem.SetUseMode(True)
  761.                 else:                  
  762.                     self.wndItem.SetUseMode(False)
  763.  
  764.                 snd.PlaySound("sound/ui/pick.wav")
  765.  
  766.     def UseTransportBox(self):
  767.         self.__SendUseItemToItemPacket(self.questionDialog.src, self.questionDialog.dst)
  768.         self.OnCloseQuestionDialog()
  769.    
  770.     def UseProtein(self):
  771.         self.__SendUseItemToItemPacket(self.questionDialog.src, self.questionDialog.dst)
  772.         self.OnCloseQuestionDialog()
  773.  
  774.     def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos):
  775.         if srcItemSlotPos == dstItemSlotPos:
  776.             return
  777.  
  778.         if srcItemVID >= 55701 and srcItemVID <= 55704 and player.GetItemIndex(dstItemSlotPos) == 55002:
  779.             self.questionDialog = uiCommon.QuestionDialog()
  780.             self.questionDialog.SetText("Vrei sa adaugi insotitorul in cutia de transport?")
  781.             self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.UseTransportBox))
  782.             self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  783.             self.questionDialog.Open()
  784.             self.questionDialog.src = srcItemSlotPos
  785.             self.questionDialog.dst = dstItemSlotPos
  786.            
  787.         if srcItemVID == 55001 and player.GetItemIndex(dstItemSlotPos) >= 55701 and player.GetItemIndex(dstItemSlotPos) <= 55704:
  788.             self.questionDialog = uiCommon.QuestionDialog()
  789.             self.questionDialog.SetText("Vrei sa hranesti insotitorul?")
  790.             self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.UseProtein))
  791.             self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  792.             self.questionDialog.Open()
  793.             self.questionDialog.src = srcItemSlotPos
  794.             self.questionDialog.dst = dstItemSlotPos
  795.                
  796.         elif item.IsRefineScroll(srcItemVID):
  797.             self.RefineItem(srcItemSlotPos, dstItemSlotPos)
  798.             self.wndItem.SetUseMode(False)
  799.  
  800.         elif item.IsMetin(srcItemVID):
  801.             self.AttachMetinToItem(srcItemSlotPos, dstItemSlotPos)
  802.  
  803.         elif item.IsDetachScroll(srcItemVID):
  804.             self.DetachMetinFromItem(srcItemSlotPos, dstItemSlotPos)
  805.  
  806.         elif item.IsKey(srcItemVID):
  807.             self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)         
  808.  
  809.         elif (player.GetItemFlags(srcItemSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  810.             self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  811.  
  812.         elif item.GetUseType(srcItemVID) in self.USE_TYPE_TUPLE:
  813.             self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)         
  814.  
  815.         else:
  816.             #snd.PlaySound("sound/ui/drop.wav")
  817.  
  818.             ## 이동시킨 곳이 장착 슬롯일 경우 아이템을 사용해서 장착 시킨다 - [levites]
  819.             if player.IsEquipmentSlot(dstItemSlotPos):
  820.  
  821.                 ## 들고 있는 아이템이 장비일때만
  822.                 if item.IsEquipmentVID(srcItemVID):
  823.                     self.__UseItem(srcItemSlotPos)
  824.  
  825.             else:
  826.                 self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0)
  827.                 #net.SendItemMovePacket(srcItemSlotPos, dstItemSlotPos, 0)
  828.  
  829.     def __SellItem(self, itemSlotPos):
  830.         if not player.IsEquipmentSlot(itemSlotPos):
  831.             self.sellingSlotNumber = itemSlotPos
  832.             itemIndex = player.GetItemIndex(itemSlotPos)
  833.             itemCount = player.GetItemCount(itemSlotPos)
  834.            
  835.            
  836.             self.sellingSlotitemIndex = itemIndex
  837.             self.sellingSlotitemCount = itemCount
  838.  
  839.             item.SelectItem(itemIndex)
  840.             ## 안티 플레그 검사 빠져서 추가
  841.             ## 20140220
  842.             if item.IsAntiFlag(item.ANTIFLAG_SELL):
  843.                 popup = uiCommon.PopupDialog()
  844.                 popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
  845.                 popup.SetAcceptEvent(self.__OnClosePopupDialog)
  846.                 popup.Open()
  847.                 self.popup = popup
  848.                 return
  849.  
  850.             itemPrice = item.GetISellItemPrice()
  851.  
  852.             if item.Is1GoldItem():
  853.                 itemPrice = itemCount / itemPrice / 5
  854.             else:
  855.                 itemPrice = itemPrice * itemCount / 5
  856.  
  857.             item.GetItemName(itemIndex)
  858.             itemName = item.GetItemName()
  859.  
  860.             self.questionDialog = uiCommon.QuestionDialog()
  861.             self.questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice))
  862.             self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem))
  863.             self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  864.             self.questionDialog.Open()
  865.             self.questionDialog.count = itemCount
  866.        
  867.             constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  868.  
  869.     def __OnClosePopupDialog(self):
  870.         self.pop = None
  871.  
  872.     def RefineItem(self, scrollSlotPos, targetSlotPos):
  873.  
  874.         scrollIndex = player.GetItemIndex(scrollSlotPos)
  875.         targetIndex = player.GetItemIndex(targetSlotPos)
  876.  
  877.         if player.REFINE_OK != player.CanRefine(scrollIndex, targetSlotPos):
  878.             return
  879.  
  880.         ###########################################################
  881.         self.__SendUseItemToItemPacket(scrollSlotPos, targetSlotPos)
  882.         #net.SendItemUseToItemPacket(scrollSlotPos, targetSlotPos)
  883.         return
  884.         ###########################################################
  885.  
  886.         ###########################################################
  887.         #net.SendRequestRefineInfoPacket(targetSlotPos)
  888.         #return
  889.         ###########################################################
  890.  
  891.         result = player.CanRefine(scrollIndex, targetSlotPos)
  892.  
  893.         if player.REFINE_ALREADY_MAX_SOCKET_COUNT == result:
  894.             #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  895.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_MORE_SOCKET)
  896.  
  897.         elif player.REFINE_NEED_MORE_GOOD_SCROLL == result:
  898.             #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  899.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NEED_BETTER_SCROLL)
  900.  
  901.         elif player.REFINE_CANT_MAKE_SOCKET_ITEM == result:
  902.             #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  903.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_SOCKET_DISABLE_ITEM)
  904.  
  905.         elif player.REFINE_NOT_NEXT_GRADE_ITEM == result:
  906.             #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  907.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_UPGRADE_DISABLE_ITEM)
  908.  
  909.         elif player.REFINE_CANT_REFINE_METIN_TO_EQUIPMENT == result:
  910.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  911.  
  912.         if player.REFINE_OK != result:
  913.             return
  914.  
  915.         self.refineDialog.Open(scrollSlotPos, targetSlotPos)
  916.  
  917.     def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos): ## Resetting Sash Stats Fix - Galet - 11/11/2015 - 17h45 - Tribute to the victims of the war
  918.         scrollIndex = player.GetItemIndex(scrollSlotPos)
  919.         targetIndex = player.GetItemIndex(targetSlotPos)
  920.         for i in xrange(player.INVENTORY_PAGE_SIZE*4):
  921.             slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  922.             getItemVNum=player.GetItemIndex
  923.             itemVnum = getItemVNum(slotNumber)
  924.             if 85009 == itemVnum:
  925.                 item.SelectItem(targetIndex)
  926.                 if item.GetItemSubType() == item.COSTUME_TYPE_ACCE:
  927.                     if self.GetAcceAttribute(targetSlotPos) == 0:
  928.                         return
  929.                    
  930.                     self.questionDialog = uiCommon.QuestionDialog()
  931.                     self.questionDialog.SetText("Would you like to reset your sash shoulder stats?")
  932.                     self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  933.                     self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  934.                     self.questionDialog.Open()
  935.                     self.questionDialog.sourcePos = scrollSlotPos
  936.                     self.questionDialog.targetPos = targetSlotPos
  937.                 else:
  938.                     return
  939.             else:
  940.                 if not player.CanDetach(scrollIndex, targetSlotPos):
  941.                     chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  942.                     return
  943.            
  944.                 self.questionDialog = uiCommon.QuestionDialog()
  945.                 self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN)
  946.                 self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  947.                 self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  948.                 self.questionDialog.Open()
  949.                 self.questionDialog.sourcePos = scrollSlotPos
  950.                 self.questionDialog.targetPos = targetSlotPos
  951.  
  952.     def AttachMetinToItem(self, metinSlotPos, targetSlotPos):
  953.         metinIndex = player.GetItemIndex(metinSlotPos)
  954.         targetIndex = player.GetItemIndex(targetSlotPos)
  955.  
  956.         item.SelectItem(metinIndex)
  957.         itemName = item.GetItemName()
  958.  
  959.         result = player.CanAttachMetin(metinIndex, targetSlotPos)
  960.  
  961.         if player.ATTACH_METIN_NOT_MATCHABLE_ITEM == result:
  962.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_CAN_NOT_ATTACH(itemName))
  963.  
  964.         if player.ATTACH_METIN_NO_MATCHABLE_SOCKET == result:
  965.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_SOCKET(itemName))
  966.  
  967.         elif player.ATTACH_METIN_NOT_EXIST_GOLD_SOCKET == result:
  968.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_GOLD_SOCKET(itemName))
  969.  
  970.         elif player.ATTACH_METIN_CANT_ATTACH_TO_EQUIPMENT == result:
  971.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  972.  
  973.         if player.ATTACH_METIN_OK != result:
  974.             return
  975.  
  976.         self.attachMetinDialog.Open(metinSlotPos, targetSlotPos)
  977.  
  978.  
  979.        
  980.     def OverOutItem(self):
  981.         self.wndItem.SetUsableItem(False)
  982.         if None != self.tooltipItem:
  983.             self.tooltipItem.HideToolTip()
  984.  
  985.     def OverInItem(self, overSlotPos):
  986.         if app.ENABLE_HIGHLIGHT_SYSTEM:
  987.             stat = 0
  988.             slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos)
  989.             itemVnum = player.GetItemIndex(slotNumber)
  990.             if constInfo.IS_AUTO_POTION(itemVnum):
  991.                 metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  992.                 if slotNumber >= player.INVENTORY_PAGE_SIZE:
  993.                     slotNumber -= player.INVENTORY_PAGE_SIZE
  994.                
  995.                 isActivated = 0 != metinSocket[0]
  996.                 if isActivated:
  997.                     stat = 1
  998.             elif constInfo.IS_ACCE_ITEM(itemVnum, 1) == TRUE:
  999.                 metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  1000.                 isActivated = metinSocket[0]
  1001.                 if isActivated == 1:
  1002.                     stat = 1
  1003.            
  1004.             if not stat:
  1005.                 self.wndItem.DeactivateSlot(overSlotPos)
  1006.                 try:
  1007.                     self.listHighlightedSlot.remove(slotNumber)
  1008.                 except:
  1009.                     pass
  1010.         overSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos)
  1011.         self.wndItem.SetUsableItem(False)
  1012.  
  1013.         if mouseModule.mouseController.isAttached():
  1014.             attachedItemType = mouseModule.mouseController.GetAttachedType()
  1015.             if player.SLOT_TYPE_INVENTORY == attachedItemType:
  1016.  
  1017.                 attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  1018.                 attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex()
  1019.                
  1020.                 if self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overSlotPos):
  1021.                     self.wndItem.SetUsableItem(True)
  1022.                     self.ShowToolTip(overSlotPos)
  1023.                     return
  1024.                
  1025.         self.ShowToolTip(overSlotPos)
  1026.  
  1027.  
  1028.     def __IsUsableItemToItem(self, srcItemVNum, srcSlotPos):
  1029.         "다른 아이템에 사용할 수 있는 아이템인가?"
  1030.  
  1031.         if srcItemVNum >= 55701 and srcItemVNum <= 55704:
  1032.             return True
  1033.        
  1034.         if srcItemVNum == 55001:
  1035.             return True
  1036.  
  1037.         if item.IsRefineScroll(srcItemVNum):
  1038.             return True
  1039.         elif item.IsMetin(srcItemVNum):
  1040.             return True
  1041.         elif item.IsDetachScroll(srcItemVNum):
  1042.             return True
  1043.         elif item.IsKey(srcItemVNum):
  1044.             return True
  1045.         elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  1046.             return True
  1047.         else:
  1048.             if item.GetUseType(srcItemVNum) in self.USE_TYPE_TUPLE:
  1049.                 return True
  1050.            
  1051.         return False
  1052.  
  1053.     def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos):
  1054.         "대상 아이템에 사용할 수 있는가?"
  1055.  
  1056.         if srcSlotPos == dstSlotPos:
  1057.             return False
  1058.  
  1059.         if srcItemVNum >= 55701 and  srcItemVNum <= 55704 and player.GetItemIndex(dstSlotPos) == 55002:        
  1060.             return True    
  1061.        
  1062.         if srcItemVNum == 55001 and player.GetItemIndex(dstSlotPos) >= 55701 and player.GetItemIndex(dstSlotPos) <= 55704:         
  1063.             return True
  1064.  
  1065.         if item.IsRefineScroll(srcItemVNum):
  1066.             if player.REFINE_OK == player.CanRefine(srcItemVNum, dstSlotPos):
  1067.                 return True
  1068.         elif item.IsMetin(srcItemVNum):
  1069.             if player.ATTACH_METIN_OK == player.CanAttachMetin(srcItemVNum, dstSlotPos):
  1070.                 return True
  1071.         elif item.IsDetachScroll(srcItemVNum):
  1072.             if player.DETACH_METIN_OK == player.CanDetach(srcItemVNum, dstSlotPos):
  1073.                 return True
  1074.         elif item.IsKey(srcItemVNum):
  1075.             if player.CanUnlock(srcItemVNum, dstSlotPos):
  1076.                 return True
  1077.  
  1078.         elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  1079.             return True
  1080.  
  1081.         else:
  1082.             useType=item.GetUseType(srcItemVNum)
  1083.  
  1084.             if "USE_CLEAN_SOCKET" == useType:
  1085.                 if self.__CanCleanBrokenMetinStone(dstSlotPos):
  1086.                     return True
  1087.             elif "USE_CHANGE_ATTRIBUTE" == useType:
  1088.                 if self.__CanChangeItemAttrList(dstSlotPos):
  1089.                     return True
  1090.             elif "USE_ADD_ATTRIBUTE" == useType:
  1091.                 if self.__CanAddItemAttr(dstSlotPos):
  1092.                     return True
  1093.             elif "USE_ADD_ATTRIBUTE2" == useType:
  1094.                 if self.__CanAddItemAttr(dstSlotPos):
  1095.                     return True
  1096.             elif "USE_ADD_ACCESSORY_SOCKET" == useType:
  1097.                 if self.__CanAddAccessorySocket(dstSlotPos):
  1098.                     return True
  1099.             elif "USE_PUT_INTO_ACCESSORY_SOCKET" == useType:                               
  1100.                 if self.__CanPutAccessorySocket(dstSlotPos, srcItemVNum):
  1101.                     return True;
  1102.             elif "USE_BELT_ADD_ATTRIBUTE" == useType:                              
  1103.                 if self.__CanAddBeltAttr(dstSlotPos):
  1104.                     return True
  1105.             elif "USE_BELT_CHANGE_ATTRIBUTE" == useType:                               
  1106.                 if self.__CanChangeBeltAttrList(dstSlotPos):
  1107.                     return True
  1108.             elif "USE_PUT_INTO_BELT_SOCKET" == useType:                            
  1109.                 dstItemVNum = player.GetItemIndex(dstSlotPos)
  1110.                 print "USE_PUT_INTO_BELT_SOCKET", srcItemVNum, dstItemVNum
  1111.  
  1112.                 item.SelectItem(dstItemVNum)
  1113.        
  1114.                 if item.ITEM_TYPE_BELT == item.GetItemType():
  1115.                     return True
  1116.  
  1117.         return False
  1118.  
  1119.     def __CanCleanBrokenMetinStone(self, dstSlotPos):
  1120.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1121.         if dstItemVNum == 0:
  1122.             return False
  1123.  
  1124.         item.SelectItem(dstItemVNum)
  1125.        
  1126.         if item.ITEM_TYPE_WEAPON != item.GetItemType():
  1127.             return False
  1128.  
  1129.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1130.             if player.GetItemMetinSocket(dstSlotPos, i) == constInfo.ERROR_METIN_STONE:
  1131.                 return True
  1132.  
  1133.         return False
  1134.  
  1135.     def __CanChangeBeltAttrList(self, dstSlotPos):
  1136.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1137.         if dstItemVNum == 0:
  1138.             return False
  1139.  
  1140.         item.SelectItem(dstItemVNum)
  1141.  
  1142.         if item.GetItemType() == item.ITEM_TYPE_BELT:
  1143.             return True
  1144.  
  1145.         return False
  1146.  
  1147.     def __CanChangeItemAttrList(self, dstSlotPos):
  1148.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1149.         if dstItemVNum == 0:
  1150.             return False
  1151.  
  1152.         item.SelectItem(dstItemVNum)
  1153.        
  1154.         if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):  
  1155.             return False
  1156.  
  1157.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1158.             if player.GetItemAttribute(dstSlotPos, i) != 0:
  1159.                 return True
  1160.  
  1161.         return False
  1162.  
  1163.     def __CanPutAccessorySocket(self, dstSlotPos, mtrlVnum):
  1164.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1165.         if dstItemVNum == 0:
  1166.             return False
  1167.  
  1168.         item.SelectItem(dstItemVNum)
  1169.  
  1170.         if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1171.             return False
  1172.  
  1173.         if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1174.             return False
  1175.  
  1176.         curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1177.         maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1178.  
  1179.         if mtrlVnum != constInfo.GET_ACCESSORY_MATERIAL_VNUM(dstItemVNum, item.GetItemSubType()):
  1180.             return False
  1181.        
  1182.         if curCount>=maxCount:
  1183.             return False
  1184.  
  1185.         return True
  1186.  
  1187.     def __CanAddAccessorySocket(self, dstSlotPos):
  1188.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1189.         if dstItemVNum == 0:
  1190.             return False
  1191.  
  1192.         item.SelectItem(dstItemVNum)
  1193.  
  1194.         if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1195.             return False
  1196.  
  1197.         if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1198.             return False
  1199.  
  1200.         curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1201.         maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1202.        
  1203.         ACCESSORY_SOCKET_MAX_SIZE = 3
  1204.         if maxCount >= ACCESSORY_SOCKET_MAX_SIZE:
  1205.             return False
  1206.  
  1207.         return True
  1208.  
  1209.     def __CanAddBeltAttr(self, dstSlotPos):
  1210.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1211.         if dstItemVNum == 0:
  1212.             return False
  1213.  
  1214.         item.SelectItem(dstItemVNum)
  1215.        
  1216.         if item.GetItemType() == item.ITEM_TYPE_BELT:
  1217.             return True
  1218.            
  1219.         attrCount = 0
  1220.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1221.             if player.GetItemAttribute(dstSlotPos, i) != 0:
  1222.                 attrCount += 1
  1223.  
  1224.         if attrCount<4:
  1225.             return True
  1226.                                
  1227.         return False
  1228.  
  1229.     def __CanAddItemAttr(self, dstSlotPos):
  1230.         dstItemVNum = player.GetItemIndex(dstSlotPos)
  1231.         if dstItemVNum == 0:
  1232.             return False
  1233.  
  1234.         item.SelectItem(dstItemVNum)
  1235.        
  1236.         if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):  
  1237.             return False
  1238.            
  1239.         attrCount = 0
  1240.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1241.             if player.GetItemAttribute(dstSlotPos, i) != 0:
  1242.                 attrCount += 1
  1243.  
  1244.         if attrCount<4:
  1245.             return True
  1246.                                
  1247.         return False
  1248.  
  1249.     def ShowToolTip(self, slotIndex):
  1250.         if None != self.tooltipItem:
  1251.             self.tooltipItem.SetInventoryItem(slotIndex)
  1252.  
  1253.     def OnTop(self):
  1254.         if None != self.tooltipItem:
  1255.             self.tooltipItem.SetTop()
  1256.  
  1257.     def OnPressEscapeKey(self):
  1258.         self.Close()
  1259.         return True
  1260.  
  1261.     def UseItemSlot(self, slotIndex):
  1262.         curCursorNum = app.GetCursor()
  1263.         if app.SELL == curCursorNum:
  1264.             return
  1265.  
  1266.         if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  1267.             return
  1268.  
  1269.         slotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(slotIndex)
  1270.  
  1271.         if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1272.             if self.wndDragonSoulRefine.IsShow():
  1273.                 self.wndDragonSoulRefine.AutoSetItem((player.INVENTORY, slotIndex), 1)
  1274.                 return
  1275.  
  1276.         self.__UseItem(slotIndex)
  1277.         mouseModule.mouseController.DeattachObject()
  1278.         self.OverOutItem()
  1279.  
  1280.     def __UseItem(self, slotIndex):
  1281.         ItemVNum = player.GetItemIndex(slotIndex)
  1282.         item.SelectItem(ItemVNum)
  1283.         if item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE):
  1284.             self.questionDialog = uiCommon.QuestionDialog()
  1285.             self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_ITEM)
  1286.             self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnAccept))
  1287.             self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnCancel))
  1288.             self.questionDialog.Open()
  1289.             self.questionDialog.slotIndex = slotIndex
  1290.        
  1291.             constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  1292.  
  1293.         else:
  1294.             self.__SendUseItemPacket(slotIndex)
  1295.             #net.SendItemUsePacket(slotIndex)  
  1296.  
  1297.     def __UseItemQuestionDialog_OnCancel(self):
  1298.         self.OnCloseQuestionDialog()
  1299.  
  1300.     def __UseItemQuestionDialog_OnAccept(self):
  1301.         self.__SendUseItemPacket(self.questionDialog.slotIndex)
  1302.         self.OnCloseQuestionDialog()       
  1303.  
  1304.     def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos):
  1305.         # 개인상점 열고 있는 동안 아이템 사용 방지
  1306.         if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1307.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1308.             return
  1309.  
  1310.         net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos)
  1311.  
  1312.     def __SendUseItemPacket(self, slotPos):
  1313.         # 개인상점 열고 있는 동안 아이템 사용 방지
  1314.         if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1315.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1316.             return
  1317.  
  1318.         net.SendItemUsePacket(slotPos)
  1319.    
  1320.     def __SendMoveItemPacket(self, srcSlotPos, dstSlotPos, srcItemCount):
  1321.         # 개인상점 열고 있는 동안 아이템 사용 방지
  1322.         if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1323.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP)
  1324.             return
  1325.  
  1326.         net.SendItemMovePacket(srcSlotPos, dstSlotPos, srcItemCount)
  1327.    
  1328.     def SetDragonSoulRefineWindow(self, wndDragonSoulRefine):
  1329.         if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1330.             self.wndDragonSoulRefine = wndDragonSoulRefine
  1331.            
  1332.     def OnMoveWindow(self, x, y):
  1333. #       print "Inventory Global Pos : ", self.GetGlobalPosition()
  1334.         if self.wndBelt:
  1335. #           print "Belt Global Pos : ", self.wndBelt.GetGlobalPosition()
  1336.             self.wndBelt.AdjustPositionAndSize()
  1337.  
  1338.     def GetAcceAttribute(self, srcSlotPos):
  1339.         result = 0
  1340.         attrSlot = []
  1341.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  1342.             attrSlot.append(player.GetItemAttribute(srcSlotPos, i))
  1343.            
  1344.         if 0 != attrSlot:
  1345.             for c in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  1346.                 type = attrSlot[c][0]
  1347.                 if type != 0:
  1348.                     result = result + 1
  1349.        
  1350.         return result
Advertisement
Add Comment
Please, Sign In to add comment