Advertisement
Guest User

Untitled

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