Advertisement
Guest User

Untitled

a guest
Feb 10th, 2023
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 46.71 KB | None | 0 0
  1. import ui
  2. import net
  3. import item
  4. import skill
  5. import localeInfo
  6. import wndMgr
  7. import player
  8. import constInfo
  9. import mouseModule
  10. import uiScriptLocale
  11. import app
  12. import chat
  13. import math
  14.  
  15. MOUSE_SETTINGS = [0, 0]
  16.  
  17. def InitMouseButtonSettings(left, right):
  18.     global MOUSE_SETTINGS
  19.     MOUSE_SETTINGS = [left, right]
  20.  
  21. def SetMouseButtonSetting(dir, event):
  22.     global MOUSE_SETTINGS
  23.     MOUSE_SETTINGS[dir] = event
  24.    
  25. def GetMouseButtonSettings():
  26.     global MOUSE_SETTINGS
  27.     return MOUSE_SETTINGS
  28.  
  29. def SaveMouseButtonSettings():
  30.     global MOUSE_SETTINGS
  31.     open("mouse.cfg", "w").write("%s\t%s" % tuple(MOUSE_SETTINGS))
  32.  
  33. def LoadMouseButtonSettings():
  34.     global MOUSE_SETTINGS
  35.     tokens = open("mouse.cfg", "r").read().split()
  36.  
  37.     if len(tokens) != 2:
  38.         raise RuntimeError, "MOUSE_SETTINGS_FILE_ERROR"
  39.  
  40.     MOUSE_SETTINGS[0] = int(tokens[0])
  41.     MOUSE_SETTINGS[1] = int(tokens[1])
  42.  
  43. def unsigned32(n):
  44.     return n & 0xFFFFFFFFL
  45.  
  46. #-------------------Giftbox Begin------------------------------
  47.  
  48. class GiftBox(ui.ScriptWindow):
  49.     class TextToolTip(ui.Window):
  50.         def __init__(self):
  51.             ui.Window.__init__(self, "TOP_MOST")
  52.             self.SetWindowName("GiftBox")
  53.             textLine = ui.TextLine()
  54.             textLine.SetParent(self)
  55.             textLine.SetHorizontalAlignCenter()
  56.             textLine.SetOutline()
  57.             textLine.Show()
  58.             self.textLine = textLine
  59.  
  60.         def __del__(self):
  61.             ui.Window.__del__(self)
  62.  
  63.         def SetText(self, text):
  64.             self.textLine.SetText(text)
  65.  
  66.         def OnRender(self):
  67.             (mouseX, mouseY) = wndMgr.GetMousePosition()
  68.             self.textLine.SetPosition(mouseX, mouseY - 15)
  69.  
  70.     def __init__(self):
  71.         #print "NEW TASKBAR  ----------------------------------------------------------------------------"
  72.         ui.ScriptWindow.__init__(self)
  73.         self.tooltipGift = self.TextToolTip()
  74.         self.tooltipGift.Show()
  75.        
  76.     def __del__(self):
  77.         #print "---------------------------------------------------------------------------- DELETE TASKBAR"
  78.         ui.ScriptWindow.__del__(self)
  79.  
  80.     def LoadWindow(self):
  81.         try:
  82.             pyScrLoader = ui.PythonScriptLoader()
  83.             pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "giftbox.py")
  84.         except:
  85.             import exception
  86.             exception.Abort("GiftBox.LoadWindow.LoadObject")       
  87.  
  88.         self.giftBoxIcon = self.GetChild("GiftBox_Icon")
  89.         self.giftBoxToolTip = self.GetChild("GiftBox_ToolTip")
  90.    
  91.     def Destroy(self):     
  92.         self.giftBoxIcon = 0
  93.         self.giftBoxToolTip = 0    
  94.            
  95. #-------------------Giftbox End------------------------------
  96.  
  97. class EnergyBar(ui.ScriptWindow):
  98.     class TextToolTip(ui.Window):
  99.         def __init__(self):
  100.             ui.Window.__init__(self, "TOP_MOST")
  101.             self.SetWindowName("EnergyBar")
  102.             textLine = ui.TextLine()
  103.             textLine.SetParent(self)
  104.             textLine.SetHorizontalAlignCenter()
  105.             textLine.SetOutline()
  106.             textLine.Show()
  107.             self.textLine = textLine
  108.  
  109.         def __del__(self):
  110.             ui.Window.__del__(self)
  111.  
  112.         def SetText(self, text):
  113.             self.textLine.SetText(text)
  114.  
  115.         def OnRender(self):
  116.             (mouseX, mouseY) = wndMgr.GetMousePosition()
  117.             self.textLine.SetPosition(mouseX, mouseY - 15)
  118.  
  119.     def __init__(self):
  120.         #print "NEW TASKBAR  ----------------------------------------------------------------------------"
  121.         ui.ScriptWindow.__init__(self)
  122.         self.tooltipEnergy = self.TextToolTip()
  123.         self.tooltipEnergy.Show()
  124.        
  125.     def __del__(self):
  126.         #print "---------------------------------------------------------------------------- DELETE TASKBAR"
  127.         ui.ScriptWindow.__del__(self)
  128.  
  129.     def LoadWindow(self):
  130.         try:
  131.             pyScrLoader = ui.PythonScriptLoader()
  132.             pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "EnergyBar.py")
  133.         except:
  134.             import exception
  135.             exception.Abort("EnergyBar.LoadWindow.LoadObject")
  136.  
  137.         self.energyEmpty = self.GetChild("EnergyGauge_Empty")
  138.         self.energyHungry = self.GetChild("EnergyGauge_Hungry")
  139.         self.energyFull = self.GetChild("EnergyGauge_Full")
  140.  
  141.         self.energyGaugeBoard = self.GetChild("EnergyGauge_Board")
  142.         self.energyGaugeToolTip = self.GetChild("EnergyGauge_ToolTip")
  143.  
  144.        
  145.     def Destroy(self):     
  146.         self.energyEmpty = None
  147.         self.energyHungry = None
  148.         self.energyFull = None
  149.         self.energyGaugeBoard = 0
  150.         self.energyGaugeToolTip = 0
  151.         self.tooltipEnergy = 0
  152.  
  153.     ## Gauge
  154.     def RefreshStatus(self):
  155.         pointEnergy = player.GetStatus (player.ENERGY)
  156.         leftTimeEnergy = player.GetStatus (player.ENERGY_END_TIME) - app.GetGlobalTimeStamp()
  157.         ##this for game.py
  158.            
  159.     def SetEnergy (self, point, leftTime, maxTime):
  160.         leftTime = max (leftTime, 0)
  161.         maxTime = max (maxTime, 0)
  162.            
  163.         self.energyEmpty.Hide()
  164.         self.energyHungry.Hide()
  165.         self.energyFull.Hide()
  166.    
  167.         if leftTime == 0:
  168.             self.energyEmpty.Show()
  169.         elif ((leftTime * 100) / maxTime) < 15:
  170.             self.energyHungry.Show()
  171.         else:
  172.             self.energyFull.Show()
  173.            
  174.         self.tooltipEnergy.SetText("%s" % (localeInfo.TOOLTIP_ENERGY(point)))
  175.  
  176.     def OnUpdate(self):
  177.         if True == self.energyGaugeToolTip.IsIn():
  178.             self.RefreshStatus()
  179.             self.tooltipEnergy.Show()
  180.         else:
  181.             self.tooltipEnergy.Hide()
  182.  
  183. class ExpandedTaskBar(ui.ScriptWindow):
  184.     BUTTON_DRAGON_SOUL = 0
  185.     def __init__(self):
  186.         ui.Window.__init__(self)
  187.         self.SetWindowName("ExpandedTaskBar")
  188.    
  189.     def LoadWindow(self):
  190.         try:
  191.             pyScrLoader = ui.PythonScriptLoader()
  192.             pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "ExpandedTaskBar.py")
  193.         except:
  194.             import exception
  195.             exception.Abort("ExpandedTaskBar.LoadWindow.LoadObject")
  196.  
  197.         self.expandedTaskBarBoard = self.GetChild("ExpanedTaskBar_Board")
  198.  
  199.         self.toggleButtonDict = {}
  200.         self.toggleButtonDict[ExpandedTaskBar.BUTTON_DRAGON_SOUL] = self.GetChild("DragonSoulButton")
  201.         self.toggleButtonDict[ExpandedTaskBar.BUTTON_DRAGON_SOUL].SetParent(self)
  202.    
  203.     def SetTop(self):
  204.         super(ExpandedTaskBar, self).SetTop()  
  205.         for button in self.toggleButtonDict.values():
  206.             button.SetTop()
  207.    
  208.     def Show(self):
  209.         ui.ScriptWindow.Show(self)
  210.    
  211.     def Close(self):
  212.         self.Hide()
  213.    
  214.     def SetToolTipText(self, eButton, text):
  215.         self.toggleButtonDict[eButton].SetToolTipText(text)
  216.        
  217.     def SetToggleButtonEvent(self, eButton, kEventFunc):
  218.         self.toggleButtonDict[eButton].SetEvent(kEventFunc)
  219.  
  220.     def OnPressEscapeKey(self):
  221.         self.Close()
  222.         return True
  223.    
  224. class TaskBar(ui.ScriptWindow):
  225.  
  226.     BUTTON_CHARACTER = 0
  227.     BUTTON_INVENTORY = 1
  228.     BUTTON_MESSENGER = 2
  229.     BUTTON_SYSTEM = 3
  230.     BUTTON_CHAT = 4
  231.     BUTTON_EXPAND = 4
  232.     IS_EXPANDED = False
  233.  
  234.     MOUSE_BUTTON_LEFT = 0
  235.     MOUSE_BUTTON_RIGHT = 1
  236.     NONE = 255
  237.  
  238.     EVENT_MOVE = 0
  239.     EVENT_ATTACK = 1
  240.     EVENT_MOVE_AND_ATTACK = 2
  241.     EVENT_CAMERA = 3
  242.     EVENT_SKILL = 4
  243.     EVENT_AUTO = 5
  244.  
  245.     GAUGE_WIDTH = 95
  246.     GAUGE_HEIGHT = 13
  247.  
  248.     QUICKPAGE_NUMBER_FILENAME = [
  249.         "button/quickslot_page1.tga",
  250.         "button/quickslot_page2.tga",
  251.         "button/quickslot_page3.tga",
  252.         "button/quickslot_page4.tga",
  253.     ]
  254.  
  255.     #gift icon show and hide
  256.     def ShowGift(self):
  257.         if not localeInfo.IsBRAZIL():
  258.             self.wndGiftBox.Show()
  259.    
  260.     def HideGift(self):
  261.         self.wndGiftBox.Hide()
  262.  
  263.     class TextToolTip(ui.Window):
  264.  
  265.         def __init__(self):
  266.             ui.ScriptWindow.__init__(self, "TOP_MOST")
  267.             self.rightTaskBar = ui.ScriptWindow("TOP_MOST")
  268.             self.quickPageNumImageBox = None
  269.             self.tooltipItem = 0
  270.             self.tooltipSkill = 0
  271.             self.mouseModeButtonList = [ ui.ScriptWindow("TOP_MOST"), ui.ScriptWindow("TOP_MOST") ]
  272.             self.skillCategoryNameList = [ "ACTIVE_1", "ACTIVE_2", "ACTIVE_3" ]
  273.             self.skillPageStartSlotIndexDict = {
  274.                 "ACTIVE_1" : 1,
  275.                 "ACTIVE_2" : 21,
  276.                 "ACTIVE_3" : 41,
  277.         }
  278.  
  279.             self.selectSkillButtonList = []
  280.        
  281.             self.lastUpdateQuickSlot = 0
  282.             self.SetWindowName("TaskBar")
  283.  
  284.         def __del__(self):
  285.             ui.Window.__del__(self)
  286.  
  287.         def SetText(self, text):
  288.             self.textLine.SetText(text)
  289.  
  290.         def OnRender(self):
  291.             (mouseX, mouseY) = wndMgr.GetMousePosition()
  292.             self.textLine.SetPosition(mouseX, mouseY - 15)
  293.  
  294.     class SkillButton(ui.SlotWindow):
  295.  
  296.         def __init__(self):
  297.             ui.SlotWindow.__init__(self)
  298.  
  299.             self.event = 0
  300.             self.arg = 0
  301.  
  302.             self.slotIndex = 0
  303.             self.skillIndex = 0
  304.  
  305.             slotIndex = 0
  306.             wndMgr.SetSlotBaseImage(self.hWnd, "d:/ymir work/ui/public/slot_base.sub", 1.0, 1.0, 1.0, 1.0)
  307.             wndMgr.AppendSlot(self.hWnd, slotIndex, 0, 0, 32, 32)
  308.             self.SetCoverButton(slotIndex,  "d:/ymir work/ui/public/slot_cover_button_01.sub",\
  309.                                             "d:/ymir work/ui/public/slot_cover_button_02.sub",\
  310.                                             "d:/ymir work/ui/public/slot_cover_button_03.sub",\
  311.                                             "d:/ymir work/ui/public/slot_cover_button_04.sub", True, False)
  312.             self.SetSize(32, 32)
  313.  
  314.         def __del__(self):
  315.             ui.SlotWindow.__del__(self)
  316.  
  317.         def Destroy(self):
  318.             if 0 != self.tooltipSkill:
  319.                 self.tooltipSkill.HideToolTip()
  320.  
  321.         def RefreshSkill(self):
  322.             if 0 != self.slotIndex:
  323.                 self.SetSkill(self.slotIndex)
  324.  
  325.         def SetSkillToolTip(self, tooltip):
  326.             self.tooltipSkill = tooltip
  327.  
  328.         def SetSkill(self, skillSlotNumber):
  329.             slotNumber = 0
  330.             skillIndex = player.GetSkillIndex(skillSlotNumber)
  331.             skillGrade = player.GetSkillGrade(skillSlotNumber)
  332.             skillLevel = player.GetSkillLevel(skillSlotNumber)
  333.             skillType = skill.GetSkillType(skillIndex)
  334.  
  335.             self.skillIndex = skillIndex
  336.             if 0 == self.skillIndex:
  337.                 self.ClearSlot(slotNumber)
  338.                 return
  339.  
  340.             self.slotIndex = skillSlotNumber
  341.  
  342.             self.SetSkillSlotNew(slotNumber, skillIndex, skillGrade, skillLevel)
  343.             self.SetSlotCountNew(slotNumber, skillGrade, skillLevel)
  344.  
  345.             ## NOTE : CoolTime üũ
  346.             if player.IsSkillCoolTime(skillSlotNumber):
  347.                 (coolTime, elapsedTime) = player.GetSkillCoolTime(skillSlotNumber)
  348.                 self.SetSlotCoolTime(slotNumber, coolTime, elapsedTime)
  349.  
  350.             ## NOTE : Activate µÇ¾î ÀÖ´Ù¸é ¾ÆÀÌÄܵµ ¾÷µ¥ÀÌÆ®
  351.             if player.IsSkillActive(skillSlotNumber):
  352.                 self.ActivateSlot(slotNumber)
  353.  
  354.         def SetSkillEvent(self, event, arg=0):
  355.             self.event = event
  356.             self.arg = arg
  357.  
  358.         def GetSkillIndex(self):
  359.             return self.skillIndex
  360.  
  361.         def GetSlotIndex(self):
  362.             return self.slotIndex
  363.  
  364.         def Activate(self, coolTime):
  365.             self.SetSlotCoolTime(0, coolTime)
  366.  
  367.             if skill.IsToggleSkill(self.skillIndex):
  368.                 self.ActivateSlot(0)
  369.  
  370.         def Deactivate(self):
  371.             if skill.IsToggleSkill(self.skillIndex):
  372.                 self.DeactivateSlot(0)
  373.  
  374.         def OnOverInItem(self, dummy):
  375.             self.tooltipSkill.SetSkill(self.skillIndex)
  376.  
  377.         def OnOverOutItem(self):
  378.             self.tooltipSkill.HideToolTip()
  379.  
  380.         def OnSelectItemSlot(self, dummy):
  381.             if 0 != self.event:
  382.                 if 0 != self.arg:
  383.                     self.event(self.arg)
  384.                 else:
  385.                     self.event()
  386.  
  387.     def __init__(self):
  388.  
  389.         ui.ScriptWindow.__init__(self, "TOP_MOST")
  390.         self.quickPageNumImageBox = None
  391.         self.tooltipItem = 0
  392.         self.tooltipSkill = 0
  393.         self.mouseModeButtonList = [ ui.ScriptWindow("TOP_MOST"), ui.ScriptWindow("TOP_MOST") ]
  394.  
  395.         self.tooltipHP = self.TextToolTip()
  396.         self.tooltipHP.Show()
  397.         self.tooltipSP = self.TextToolTip()
  398.         self.tooltipSP.Show()
  399.         self.tooltipST = self.TextToolTip()
  400.         self.tooltipST.Show()
  401.         self.tooltipEXP = self.TextToolTip()
  402.         self.tooltipEXP.Show()
  403.         self.skillCategoryNameList = [ "ACTIVE_1", "ACTIVE_2", "ACTIVE_3" ]
  404.         self.skillPageStartSlotIndexDict = {
  405.             "ACTIVE_1" : 1,
  406.             "ACTIVE_2" : 21,
  407.             "ACTIVE_3" : 41,
  408.     }
  409.  
  410.         self.selectSkillButtonList = []
  411.        
  412.         self.lastUpdateQuickSlot = 0
  413.         self.SetWindowName("TaskBar")
  414.  
  415.     def __del__(self):
  416.         #print "---------------------------------------------------------------------------- DELETE TASKBAR"
  417.         ui.ScriptWindow.__del__(self)
  418.  
  419.     def LoadWindow(self):
  420.         try:
  421.             pyScrLoader = ui.PythonScriptLoader()
  422.  
  423.             pyScrLoader.LoadScriptFile(self, "UIScript/TaskBar.py")
  424.             pyScrLoader.LoadScriptFile(self.mouseModeButtonList[self.MOUSE_BUTTON_LEFT], "UIScript/MouseButtonWindow.py")
  425.             pyScrLoader.LoadScriptFile(self.mouseModeButtonList[self.MOUSE_BUTTON_RIGHT], "UIScript/RightMouseButtonWindow.py")
  426.             pyScrLoader.LoadScriptFile(self.rightTaskBar, "UIScript/RightTaskBar.py")
  427.         except:
  428.             import exception
  429.             exception.Abort("TaskBar.LoadWindow.LoadObject")
  430.  
  431.         self.quickslot = []
  432.         self.quickslot.append(self.GetChild("quick_slot_1"))
  433.         self.quickslot.append(self.GetChild("quick_slot_2"))
  434.         for slot in self.quickslot:
  435.             slot.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
  436.             slot.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptyQuickSlot))
  437.             slot.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemQuickSlot))
  438.             slot.SetUnselectItemSlotEvent(ui.__mem_func__(self.UnselectItemQuickSlot))
  439.             slot.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  440.             slot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  441.  
  442.         toggleButtonDict = {}
  443.         toggleButtonDict[TaskBar.BUTTON_CHARACTER]=self.GetChild("CharacterButton")
  444.         toggleButtonDict[TaskBar.BUTTON_INVENTORY]=self.rightTaskBar.GetChild("InventoryButton")
  445.         toggleButtonDict[TaskBar.BUTTON_MESSENGER]=self.rightTaskBar.GetChild("MessengerButton")
  446.         toggleButtonDict[TaskBar.BUTTON_SYSTEM]=self.rightTaskBar.GetChild("SystemButton")
  447.        
  448.         # ChatButton, ExpandButton µÑ Áß Çϳª´Â ¹Ýµå½Ã Á¸ÀçÇÑ´Ù.
  449.         try:
  450.             toggleButtonDict[TaskBar.BUTTON_CHAT]=self.GetChild("ChatButton")
  451.         except:
  452.             toggleButtonDict[TaskBar.BUTTON_EXPAND]=self.GetChild("ExpandButton")
  453.             TaskBar.IS_EXPANDED = TRUE
  454.        
  455.  
  456.         if localeInfo.IsARABIC():
  457.             systemButton = toggleButtonDict[TaskBar.BUTTON_SYSTEM]
  458.             if systemButton.ToolTipText:
  459.                 tx, ty = systemButton.ToolTipText.GetLocalPosition()
  460.                 tw = systemButton.ToolTipText.GetWidth()
  461.                 systemButton.ToolTipText.SetPosition(-tw/2, ty)
  462.  
  463.         self.quickPageNumImageBox=self.GetChild("QuickPageNumber")
  464.         self.BlackImage = self.GetChild("Black_Window")
  465.         self.BlackImage.Hide()
  466.         self.BlackShow = 0
  467.         self.GetChild("QuickPageUpButton").SetEvent(ui.__mem_func__(self.__OnClickQuickPageUpButton))
  468.         self.GetChild("QuickPageDownButton").SetEvent(ui.__mem_func__(self.__OnClickQuickPageDownButton))
  469.        
  470.         mouseLeftButtonModeButton = self.GetChild("LeftMouseButton")
  471.         mouseRightButtonModeButton = self.GetChild("RightMouseButton")
  472.         mouseLeftButtonModeButton.SetEvent(ui.__mem_func__(self.ToggleLeftMouseButtonModeWindow))      
  473.         mouseRightButtonModeButton.SetEvent(ui.__mem_func__(self.ToggleRightMouseButtonModeWindow))
  474.         self.curMouseModeButton = [ mouseLeftButtonModeButton, mouseRightButtonModeButton ]
  475.        
  476.         (xLocalRight, yLocalRight) = mouseRightButtonModeButton.GetLocalPosition()
  477.         self.curSkillButton = self.SkillButton()
  478.         self.curSkillButton.SetParent(self)
  479.         self.curSkillButton.SetPosition(xLocalRight, 3)
  480.         self.curSkillButton.SetSkillEvent(ui.__mem_func__(self.ToggleRightMouseButtonModeWindow))
  481.         self.curSkillButton.Hide()
  482.  
  483.         (xLeft, yLeft) = mouseLeftButtonModeButton.GetGlobalPosition()
  484.         (xRight, yRight) = mouseRightButtonModeButton.GetGlobalPosition()
  485.         leftModeButtonList = self.mouseModeButtonList[self.MOUSE_BUTTON_LEFT]
  486.         leftModeButtonList.SetPosition(xLeft, yLeft - leftModeButtonList.GetHeight()-5)
  487.         rightModeButtonList = self.mouseModeButtonList[self.MOUSE_BUTTON_RIGHT]
  488.         rightModeButtonList.SetPosition(xRight - rightModeButtonList.GetWidth() + 32, yRight - rightModeButtonList.GetHeight()-5)
  489.         rightModeButtonList.GetChild("button_skill").SetEvent(lambda adir=self.MOUSE_BUTTON_RIGHT, aevent=self.EVENT_SKILL: self.SelectMouseButtonEvent(adir, aevent))
  490.         rightModeButtonList.GetChild("button_skill").Hide()
  491.  
  492.         mouseImage = ui.ImageBox("TOP_MOST")
  493.         mouseImage.AddFlag("float")
  494.         mouseImage.LoadImage("d:/ymir work/ui/game/taskbar/mouse_button_camera_01.sub")
  495.         mouseImage.SetPosition(xRight, wndMgr.GetScreenHeight() - 34)
  496.         mouseImage.Hide()
  497.         self.mouseImage = mouseImage
  498.  
  499.         dir = self.MOUSE_BUTTON_LEFT
  500.         wnd = self.mouseModeButtonList[dir]
  501.         wnd.GetChild("button_move_and_attack").SetEvent(lambda adir=dir, aevent=self.EVENT_MOVE_AND_ATTACK: self.SelectMouseButtonEvent(adir, aevent))
  502.         wnd.GetChild("button_auto_attack").SetEvent(lambda adir=dir, aevent=self.EVENT_AUTO: self.SelectMouseButtonEvent(adir, aevent))
  503.         wnd.GetChild("button_camera").SetEvent(lambda adir=dir, aevent=self.EVENT_CAMERA: self.SelectMouseButtonEvent(adir, aevent))
  504.  
  505.         dir = self.MOUSE_BUTTON_RIGHT
  506.         wnd = self.mouseModeButtonList[dir]
  507.         wnd.GetChild("button_move_and_attack").SetEvent(lambda adir=dir, aevent=self.EVENT_MOVE_AND_ATTACK: self.SelectMouseButtonEvent(adir, aevent))
  508.         wnd.GetChild("button_camera").SetEvent(lambda adir=dir, aevent=self.EVENT_CAMERA: self.SelectMouseButtonEvent(adir, aevent))
  509.  
  510.         self.toggleButtonDict = toggleButtonDict
  511.        
  512.         ##Exp Bubble ----------------------------------------
  513.         self.ExpBubbleAnimation = self.GetChild("ExpAnimation")
  514.         self.ExpBubbleFull = self.GetChild("ExpFull")
  515.         self.SetCenterBubble()
  516.         self.ExpToolTip = self.TextToolTip()
  517.         ###### end bubble -----------------------------------
  518.         self.LoadRightTaskBar()
  519.         ###begin mp and hp bar----------------------------------
  520.         self.HpCenter = self.GetChild("HpCenter")
  521.         self.HpHead = self.GetChild("HpHead")
  522.         self.HpRecoveryCenter = self.GetChild("HpRecoveryCenter")
  523.         self.HpRecoveryCenter.SetAlpha(0.2)
  524.         self.HpRecoveryHead = self.GetChild("HpRecoveryHead")
  525.         self.HpRecoveryHead.SetAlpha(0.2)
  526.         self.HpStatus = 0
  527.         self.HpRecoveryStatus = 0
  528.         self.MpStatus = 0
  529.         self.MpRecoveryStatus = 0
  530.         self.MpCenter = self.GetChild("MpCenter")
  531.         self.MpHead = self.GetChild("MpHead")
  532.         self.MpRecoveryCenter = self.GetChild("MpRecoveryCenter")
  533.         self.MpRecoveryHead = self.GetChild("MpRecoveryHead")
  534.         self.HpEmptyBar = self.GetChild("HpEmpty")
  535.         self.MpEmptyBar = self.GetChild("MpEmpty")
  536.         self.SetParameters()
  537.                 #tooltip
  538.         self.HPToolTip = self.TextToolTip()
  539.         self.MPToolTip = self.TextToolTip()
  540.         ###end mp and hp bar ------------------------------------
  541.        
  542.        
  543.         ##begin race image and text set
  544.         self.RaceImage = []
  545.         self.race = net.GetMainActorRace()
  546.         print"Race = %s "%str(self.race)
  547.        
  548.         for num_race in xrange(0,9):
  549.             image_name = "race_0"+str(num_race)
  550.             self.RaceImage.append(self.GetChild(image_name))
  551.             if self.race != num_race:
  552.                 self.RaceImage[num_race].Hide()
  553.        
  554.         self.array_race_name = ["Guerriero","Ninja","Sura","Shamana","Guerriera","Ninja","Sura","Shamano","Lycan"]
  555.         self.Race = self.GetChild("RaceText")
  556.         self.Race.SetText(self.array_race_name[self.race])
  557.         self.level_string = "Lv" + str(player.GetStatus(player.LEVEL))
  558.         self.Level = self.GetChild("LvText")
  559.         self.Level.SetText(self.level_string)
  560.        
  561.         ##end race image
  562.        
  563.         #giftbox object
  564.         wndGiftBox = GiftBox()
  565.         wndGiftBox.LoadWindow()
  566.         self.wndGiftBox = wndGiftBox
  567.    
  568.         self.__LoadMouseSettings()
  569.         self.RefreshQuickSlot()
  570.         mouseRightButtonModeButton.Hide()
  571.        
  572.        
  573.     def LoadRightTaskBar(self):
  574.         right_task = self.rightTaskBar
  575.         self.rampageGauge1  = right_task.GetChild("RampageGauge")
  576.         self.rampageGauge1.Show()
  577.         self.rampageGauge1.SetTop()
  578.         self.ItemShopIsAlreadyInside = False
  579.         right_task.Show()
  580.         right_task.GetChild("ItemShopButton").Hide()
  581.         right_task.GetChild("ItemShopButton").SetEvent(ui.__mem_func__(self.OnClickButtonItemShop))
  582.         self.EnergyImage = []
  583.         for j in xrange(1,18):
  584.             name = "EnergyBar_" + str(j)
  585.             self.EnergyImage.append(right_task.GetChild(name))
  586.             self.EnergyImage[j-1].Hide()
  587.         self.EnergyActualImage = 0
  588.         self.EnergyStatus = 2
  589.         self.EnergyToolTip = self.TextToolTip()
  590.  
  591.     def Destroy(self):     
  592.         SaveMouseButtonSettings()
  593.         self.ClearDictionary()
  594.         self.mouseModeButtonList[0].ClearDictionary()
  595.         self.mouseModeButtonList[1].ClearDictionary()
  596.         self.mouseModeButtonList = 0
  597.         self.curMouseModeButton = 0
  598.         self.curSkillButton = 0
  599.         self.selectSkillButtonList = 0
  600.         self.tooltipItem = 0
  601.         self.tooltipSkill = 0
  602.         self.quickslot = 0
  603.         self.toggleButtonDict = 0
  604.         self.mouseImage = None
  605.         #removed all gauge
  606.  
  607.     def __OnClickQuickPageUpButton(self):
  608.         player.SetQuickPage(player.GetQuickPage()-1)
  609.  
  610.     def __OnClickQuickPageDownButton(self):
  611.         player.SetQuickPage(player.GetQuickPage()+1)
  612.  
  613.     def SetToggleButtonEvent(self, eButton, kEventFunc):
  614.         self.toggleButtonDict[eButton].SetEvent(kEventFunc)
  615.  
  616.     def OnClickButtonItemShop(self):
  617.         print "rampage_up"
  618.         net.SendChatPacket("/in_game_mall")
  619.  
  620.     def SetItemToolTip(self, tooltipItem):
  621.         self.tooltipItem = tooltipItem
  622.  
  623.     def SetSkillToolTip(self, tooltipSkill):
  624.         self.tooltipSkill = tooltipSkill
  625.         self.curSkillButton.SetSkillToolTip(self.tooltipSkill)
  626.  
  627.     ## Mouse Image
  628.     def ShowMouseImage(self):
  629.         #self.mouseImage.SetTop()
  630.         self.mouseImage.Hide()
  631.  
  632.     def HideMouseImage(self):
  633.         player.SetQuickCameraMode(False)
  634.         self.mouseImage.Hide()
  635.  
  636.     ## Gauge
  637.     def RefreshStatus(self):
  638.         self.UpdateLevelAndRace()
  639.         self.RefreshEnergy()
  640.        
  641.     def RefreshStamina(self):
  642.         curST = player.GetStatus(player.STAMINA)
  643.         maxST = player.GetStatus(player.MAX_STAMINA)
  644.  
  645.     def RefreshSkill(self):
  646.         self.curSkillButton.RefreshSkill()
  647.         for button in self.selectSkillButtonList:
  648.             button.RefreshSkill()
  649.        
  650.     ## QuickSlot
  651.     def RefreshQuickSlot(self):
  652.  
  653.         pageNum = player.GetQuickPage()
  654.  
  655.         try:
  656.             self.quickPageNumImageBox.LoadImage(TaskBar.QUICKPAGE_NUMBER_FILENAME[pageNum])
  657.         except:
  658.             pass
  659.  
  660.         startNumber = 0
  661.         for slot in self.quickslot:
  662.  
  663.             for i in xrange(4):
  664.  
  665.                 slotNumber = i+startNumber
  666.  
  667.                 (Type, Position) = player.GetLocalQuickSlot(slotNumber)
  668.  
  669.                 if player.SLOT_TYPE_NONE == Type:
  670.                     slot.ClearSlot(slotNumber)
  671.                     continue
  672.  
  673.                 if player.SLOT_TYPE_INVENTORY == Type:
  674.  
  675.                     itemIndex = player.GetItemIndex(Position)
  676.                     itemCount = player.GetItemCount(Position)
  677.                     if itemCount <= 1:
  678.                         itemCount = 0
  679.                    
  680.                     ## ÀÚµ¿¹°¾à (#72723, #72724) Ư¼öó¸® - ¾ÆÀÌÅÛÀε¥µµ ½½·Ô¿¡ È°¼ºÈ­/ºñÈ°¼ºÈ­ Ç¥½Ã¸¦ À§ÇÑ ÀÛ¾÷ÀÓ - [hyo]
  681.                     if constInfo.IS_AUTO_POTION(itemIndex):
  682.                         # metinSocket - [0] : È°¼ºÈ­ ¿©ºÎ, [1] : »ç¿ëÇÑ ¾ç, [2] : ÃÖ´ë ¿ë·®
  683.                         metinSocket = [player.GetItemMetinSocket(Position, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  684.                        
  685.                         if 0 != int(metinSocket[0]):
  686.                             slot.ActivateSlot(slotNumber)
  687.                         else:
  688.                             slot.DeactivateSlot(slotNumber)
  689.                    
  690.                     slot.SetItemSlot(slotNumber, itemIndex, itemCount)
  691.  
  692.                 elif player.SLOT_TYPE_SKILL == Type:
  693.  
  694.                     skillIndex = player.GetSkillIndex(Position)
  695.                     if 0 == skillIndex:
  696.                         slot.ClearSlot(slotNumber)
  697.                         continue
  698.  
  699.                     skillType = skill.GetSkillType(skillIndex)
  700.                     if skill.SKILL_TYPE_GUILD == skillType:
  701.                         import guild
  702.                         skillGrade = 0
  703.                         skillLevel = guild.GetSkillLevel(Position)
  704.  
  705.                     else:
  706.                         skillGrade = player.GetSkillGrade(Position)
  707.                         skillLevel = player.GetSkillLevel(Position)
  708.  
  709.                     slot.SetSkillSlotNew(slotNumber, skillIndex, skillGrade, skillLevel)
  710.                     slot.SetSlotCountNew(slotNumber, skillGrade, skillLevel)
  711.                     slot.SetCoverButton(slotNumber)
  712.  
  713.                     ## NOTE : CoolTime üũ
  714.                     if player.IsSkillCoolTime(Position):
  715.                         (coolTime, elapsedTime) = player.GetSkillCoolTime(Position)
  716.                         slot.SetSlotCoolTime(slotNumber, coolTime, elapsedTime)
  717.  
  718.                     ## NOTE : Activate µÇ¾î ÀÖ´Ù¸é ¾ÆÀÌÄܵµ ¾÷µ¥ÀÌÆ®
  719.                     if player.IsSkillActive(Position):
  720.                         slot.ActivateSlot(slotNumber)
  721.  
  722.                 elif player.SLOT_TYPE_EMOTION == Type:
  723.  
  724.                     emotionIndex = Position
  725.                     slot.SetEmotionSlot(slotNumber, emotionIndex)
  726.                     slot.SetCoverButton(slotNumber)
  727.                     slot.SetSlotCount(slotNumber, 0)
  728.  
  729.             slot.RefreshSlot()
  730.             startNumber += 4
  731.  
  732.     def canAddQuickSlot(self, Type, slotNumber):
  733.  
  734.         if player.SLOT_TYPE_INVENTORY == Type:
  735.  
  736.             itemIndex = player.GetItemIndex(slotNumber)
  737.             return item.CanAddToQuickSlotItem(itemIndex)
  738.  
  739.         return True
  740.  
  741.     def AddQuickSlot(self, localSlotIndex):
  742.         AttachedSlotType = mouseModule.mouseController.GetAttachedType()
  743.         AttachedSlotNumber = mouseModule.mouseController.GetAttachedSlotNumber()
  744.         AttachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  745.  
  746.         if player.SLOT_TYPE_QUICK_SLOT == AttachedSlotType:
  747.             player.RequestMoveGlobalQuickSlotToLocalQuickSlot(AttachedSlotNumber, localSlotIndex)
  748.  
  749.         elif player.SLOT_TYPE_EMOTION == AttachedSlotType:
  750.  
  751.             player.RequestAddLocalQuickSlot(localSlotIndex, AttachedSlotType, AttachedItemIndex)
  752.  
  753.         elif True == self.canAddQuickSlot(AttachedSlotType, AttachedSlotNumber):
  754.  
  755.             ## Online Code
  756.             player.RequestAddLocalQuickSlot(localSlotIndex, AttachedSlotType, AttachedSlotNumber)
  757.        
  758.         mouseModule.mouseController.DeattachObject()
  759.         self.RefreshQuickSlot()
  760.  
  761.     def SelectEmptyQuickSlot(self, slotIndex):
  762.  
  763.         if True == mouseModule.mouseController.isAttached():
  764.             self.AddQuickSlot(slotIndex)
  765.  
  766.     def SelectItemQuickSlot(self, localQuickSlotIndex):
  767.  
  768.         if True == mouseModule.mouseController.isAttached():
  769.             self.AddQuickSlot(localQuickSlotIndex)
  770.  
  771.         else:
  772.             globalQuickSlotIndex=player.LocalQuickSlotIndexToGlobalQuickSlotIndex(localQuickSlotIndex)
  773.             mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_QUICK_SLOT, globalQuickSlotIndex, globalQuickSlotIndex)
  774.  
  775.     def UnselectItemQuickSlot(self, localSlotIndex):
  776.  
  777.         if False == mouseModule.mouseController.isAttached():
  778.             player.RequestUseLocalQuickSlot(localSlotIndex)
  779.             return
  780.  
  781.         elif mouseModule.mouseController.isAttached():
  782.             mouseModule.mouseController.DeattachObject()
  783.             return
  784.  
  785.  
  786.     def OnUseSkill(self, usedSlotIndex, coolTime):
  787.  
  788.         QUICK_SLOT_SLOT_COUNT = 4
  789.         slotIndex = 0
  790.  
  791.         ## Current Skill Button
  792.         if usedSlotIndex == self.curSkillButton.GetSlotIndex():
  793.             self.curSkillButton.Activate(coolTime)
  794.  
  795.         ## Quick Slot
  796.         for slotWindow in self.quickslot:
  797.  
  798.             for i in xrange(QUICK_SLOT_SLOT_COUNT):
  799.  
  800.                 (Type, Position) = player.GetLocalQuickSlot(slotIndex)
  801.  
  802.                 if Type == player.SLOT_TYPE_SKILL:
  803.                     if usedSlotIndex == Position:
  804.                         slotWindow.SetSlotCoolTime(slotIndex, coolTime)
  805.                         return
  806.  
  807.                 slotIndex += 1
  808.  
  809.     def OnActivateSkill(self, usedSlotIndex):
  810.         slotIndex = 0
  811.  
  812.         ## Current Skill Button
  813.         if usedSlotIndex == self.curSkillButton.GetSlotIndex():
  814.             self.curSkillButton.Deactivate()
  815.  
  816.         ## Quick Slot
  817.         for slotWindow in self.quickslot:
  818.  
  819.             for i in xrange(4):
  820.  
  821.                 (Type, Position) = player.GetLocalQuickSlot(slotIndex)
  822.  
  823.                 if Type == player.SLOT_TYPE_SKILL:
  824.                     if usedSlotIndex == Position:
  825.                         slotWindow.ActivateSlot(slotIndex)
  826.                         return
  827.  
  828.                 slotIndex += 1
  829.  
  830.     def OnDeactivateSkill(self, usedSlotIndex):
  831.         slotIndex = 0
  832.  
  833.         ## Current Skill Button
  834.         if usedSlotIndex == self.curSkillButton.GetSlotIndex():
  835.             self.curSkillButton.Deactivate()
  836.  
  837.         ## Quick Slot
  838.         for slotWindow in self.quickslot:
  839.  
  840.             for i in xrange(4):
  841.  
  842.                 (Type, Position) = player.GetLocalQuickSlot(slotIndex)
  843.  
  844.                 if Type == player.SLOT_TYPE_SKILL:
  845.                     if usedSlotIndex == Position:
  846.                         slotWindow.DeactivateSlot(slotIndex)
  847.                         return
  848.  
  849.                 slotIndex += 1
  850.  
  851.     ## ToolTip
  852.     def OverInItem(self, slotNumber):
  853.         if mouseModule.mouseController.isAttached():
  854.             return
  855.  
  856.         (Type, Position) = player.GetLocalQuickSlot(slotNumber)
  857.  
  858.         if player.SLOT_TYPE_INVENTORY == Type:
  859.             self.tooltipItem.SetInventoryItem(Position)
  860.             self.tooltipSkill.HideToolTip()
  861.  
  862.         elif player.SLOT_TYPE_SKILL == Type:
  863.  
  864.             skillIndex = player.GetSkillIndex(Position)
  865.             skillType = skill.GetSkillType(skillIndex)
  866.  
  867.             if skill.SKILL_TYPE_GUILD == skillType:
  868.                 import guild
  869.                 skillGrade = 0
  870.                 skillLevel = guild.GetSkillLevel(Position)
  871.  
  872.             else:
  873.                 skillGrade = player.GetSkillGrade(Position)
  874.                 skillLevel = player.GetSkillLevel(Position)
  875.  
  876.             self.tooltipSkill.SetSkillNew(Position, skillIndex, skillGrade, skillLevel)
  877.             self.tooltipItem.HideToolTip()
  878.  
  879.     def OverOutItem(self):
  880.         if 0 != self.tooltipItem:
  881.             self.tooltipItem.HideToolTip()
  882.         if 0 != self.tooltipSkill:
  883.             self.tooltipSkill.HideToolTip()
  884.  
  885.     def OnUpdate(self):
  886.         if app.GetGlobalTime() - self.lastUpdateQuickSlot > 500:
  887.             self.lastUpdateQuickSlot = app.GetGlobalTime()
  888.             self.RefreshQuickSlot()
  889.         self.Mouse_x , self.Mouse_y = wndMgr.GetMousePosition()
  890.         self.SetVerticalBarHp()
  891.         self.SetVerticalBarMp()
  892.         self.SetVerticalBarHpRecovery()
  893.         self.SetVerticalBarMpRecovery()
  894.         self.SetExpirience()
  895.         self.SetToolTipPoint()
  896.         self.IsOnItemShopTag()
  897.         self.SetEnergyToolTip()
  898.  
  899.     def UpdateLevelAndRace(self):
  900.         race = net.GetMainActorRace()
  901.         level = "Lv" + str(player.GetStatus(player.LEVEL))
  902.         if level == self.level_string and race == self.race:
  903.             print"Ritorno"
  904.             return
  905.         else:
  906.             self.Race.SetText(self.array_race_name[race])
  907.             self.Level.SetText(level)
  908.             self.race = race
  909.             self.level_string = level
  910.             print"Nuovo livello rilevato!"
  911.             for a in xrange(0,9):
  912.                 if race != a:
  913.                     self.RaceImage[a].Hide()
  914.                 else:
  915.                     self.RaceImage[a].Show()   
  916.        
  917.     #exp refresh
  918.        
  919.     def SetCenterBubble(self):
  920.         exp_x , exp_y = self.ExpBubbleFull.GetGlobalPosition()
  921.         self.CenterBubble_x = exp_x + (self.ExpBubbleFull.GetWidth()/2)
  922.         self.CenterBubble_y = exp_y + (self.ExpBubbleFull.GetHeight()/2)
  923.            
  924.     def SetExpirience(self):
  925.         PointExp = max(0,unsigned32(player.GetStatus(player.EXP)))
  926.         NextExp = max(0,unsigned32(player.GetStatus(player.NEXT_EXP)))
  927.         self.ExpBubbleAnimation.SetPercentageVerticalTop(PointExp,NextExp)
  928.         self.ExpBubbleFull.SetPercentageVerticalTop(PointExp,NextExp)
  929.         if self.MouseIsInExpBubble():
  930.             self.ExpToolTip.SetText("%s : %.2f%%" % (localeInfo.TASKBAR_EXP, float(PointExp) / max(1, float(NextExp)) * 100))
  931.             self.ExpToolTip.Show()
  932.         else:
  933.             self.ExpToolTip.Hide()
  934.        
  935.    
  936.     def MouseIsInExpBubble(self):
  937.         #if mouse is out of the square circumscribed of the circle
  938.         if self.Mouse_x < self.CenterBubble_x - (self.ExpBubbleFull.GetWidth()/2) or self.Mouse_x > self.CenterBubble_x + (self.ExpBubbleFull.GetWidth()/2):
  939.             return False
  940.         elif self.Mouse_y < self.CenterBubble_y - (self.ExpBubbleFull.GetHeight()/2) or self.Mouse_y > self.CenterBubble_y + (self.ExpBubbleFull.GetHeight()/2):
  941.             return False
  942.        
  943.         #if mouse is out of the circle
  944.         distance_of_center_x = max(self.CenterBubble_x - self.Mouse_x , self.Mouse_x - self.CenterBubble_x)
  945.         distance_of_center_y = max(self.CenterBubble_y - self.Mouse_y , self.Mouse_y - self.CenterBubble_y)
  946.         distance_of_center_absolute = math.sqrt((distance_of_center_y*distance_of_center_y)+(distance_of_center_x*distance_of_center_x))
  947.         if distance_of_center_absolute > (self.ExpBubbleFull.GetWidth()/2) -4 : ##-4 because the image of bubble isn't Perfectly cropped
  948.             return False
  949.        
  950.         #else
  951.         return True
  952.    
  953.     ##end of exp refresh
  954.    
  955.    
  956.     ###item scioppp
  957.     def IsOnItemShopTag(self):
  958.         b_is_in_rampage = self.IsInImageSquare(self.rampageGauge1)
  959.         if b_is_in_rampage and not self.ItemShopIsAlreadyInside :
  960.             if self.rampageGauge1.IsShow():
  961.                 self.rampageGauge1.Hide()
  962.                 self.rightTaskBar.GetChild("ItemShopButton").Show()
  963.                 self.rightTaskBar.GetChild("ItemShopButton").SetTop()
  964.             else:
  965.                 self.rightTaskBar.GetChild("ItemShopButton").Hide()
  966.                 self.rampageGauge1.Show()
  967.             self.ItemShopIsAlreadyInside = True
  968.             print"ItemShopIsAlreadyInside Settato su True"
  969.        
  970.         else:
  971.             if not b_is_in_rampage and self.ItemShopIsAlreadyInside:
  972.                 print"ItemShopIsAlreadyInside settato su false"
  973.                 self.ItemShopIsAlreadyInside = False
  974.                 self.rightTaskBar.GetChild("ItemShopButton").Hide()
  975.                 self.rampageGauge1.Show()
  976.    
  977.     ###HP and MP gauge refresh ---------------------------------------------------------------------
  978.    
  979.    
  980.     def SetParameters(self):
  981.         MpBase_x,MpBase_y = self.MpEmptyBar.GetGlobalPosition()
  982.         HpBase_x,HpBase_y = self.HpEmptyBar.GetGlobalPosition()
  983.         self.HpHeightCenter = self.HpCenter.GetHeight()
  984.         self.MpHeightCenter = self.MpCenter.GetHeight()
  985.         self.MpHeightHead = self.MpHead.GetHeight()
  986.         self.HpHeightHead = self.HpHead.GetHeight()
  987.         HpCenter_xpos,CenterHp_y = self.HpCenter.GetGlobalPosition()
  988.         HpHead_xpos , HeadHp_y = self.HpHead.GetGlobalPosition()
  989.         MpCenter_xpos,CenterMp_y = self.MpCenter.GetGlobalPosition()
  990.         MpHead_xpos , HeadMp_y = self.MpHead.GetGlobalPosition()
  991.         self.HpTotalHeight =  self.HpHeightCenter + self.HpHeightHead
  992.         self.MpTotalHeight =  self.MpHeightCenter + self.MpHeightHead
  993.         self.HpCenter_y = CenterHp_y - HpBase_y
  994.         self.HpHead_y = HeadHp_y - HpBase_y
  995.         self.MpCenter_y = CenterMp_y - MpBase_y
  996.         self.MpHead_y = HeadMp_y - MpBase_y
  997.         self.HpCenter_x = HpCenter_xpos - HpBase_x
  998.         self.HpHead_x = HpHead_xpos-HpBase_x
  999.         self.MpCenter_x = MpCenter_xpos - MpBase_x
  1000.         self.MpHead_x = MpHead_xpos - MpBase_x
  1001.         cord_x_energy , cord_y_energy = self.EnergyImage[0].GetGlobalPosition()
  1002.         cord_x_energy += 6 #this operation adjust the wrong position of bar in image
  1003.         cord_y_energy += 6 #idem for this operation
  1004.         self.RadiusEnergy = 81  ##This is the radius of the circle
  1005.         self.CenterOfEnergyCircle_x = cord_x_energy + self.RadiusEnergy
  1006.         self.CenterOfEnergyCircle_y = cord_y_energy + self.RadiusEnergy
  1007.         self.CircleThicknessEnergy = 19 ##the thickness of the circle in image
  1008.        
  1009.        
  1010.     def SetFullBar(self,bar):
  1011.         if bar == 1 :
  1012.             self.HpCenter.SetPosition(self.HpCenter_x,self.HpCenter_y)
  1013.             self.HpHead.SetPosition(self.HpHead_x,self.HpHead_y)
  1014.             self.HpCenter.SetRenderingRect(0.0,0.0,0.0,0.0)
  1015.             self.HpHead.SetRenderingRect(0.0,0.0,0.0,0.0)
  1016.             self.HpCenter.Show()
  1017.             self.HpHead.Show()
  1018.             self.HpStatus = 3
  1019.            
  1020.         elif bar == 2 :
  1021.             self.MpCenter.SetPosition(self.MpCenter_x,self.MpCenter_y)
  1022.             self.MpHead.SetPosition(self.MpHead_x,self.MpHead_y)
  1023.             self.MpCenter.SetRenderingRect(0.0,0.0,0.0,0.0)
  1024.             self.MpHead.SetRenderingRect(0.0,0.0,0.0,0.0)
  1025.             self.MpCenter.Show()
  1026.             self.MpHead.Show()
  1027.             self.MpStatus = 3
  1028.            
  1029.         elif bar == 3 :
  1030.             self.HpRecoveryCenter.SetPosition(self.HpCenter_x,self.HpCenter_y)
  1031.             self.HpRecoveryHead.SetPosition(self.HpHead_x,self.HpHead_y)
  1032.             self.HpRecoveryCenter.SetRenderingRect(0.0,0.0,0.0,0.0)
  1033.             self.HpRecoveryHead.SetRenderingRect(0.0,0.0,0.0,0.0)
  1034.             self.HpRecoveryCenter.Show()
  1035.             self.HpRecoveryHead.Show()
  1036.             self.HpRecoveryStatus = 3
  1037.            
  1038.         elif bar == 4 :
  1039.             self.MpRecoveryCenter.SetPosition(self.MpCenter_x,self.MpCenter_y)
  1040.             self.MpRecoveryHead.SetPosition(self.MpHead_x,self.MpHead_y)
  1041.             self.MpRecoveryCenter.SetRenderingRect(0.0,0.0,0.0,0.0)
  1042.             self.MpRecoveryHead.SetRenderingRect(0.0,0.0,0.0,0.0)
  1043.             self.MpRecoveryCenter.Show()
  1044.             self.MpRecoveryHead.Show()
  1045.             self.MpRecoveryStatus = 3
  1046.            
  1047.    
  1048.     def SetEmptyBar(self,bar):
  1049.        
  1050.         if bar == 1 :
  1051.             self.HpHead.Hide()
  1052.             self.HpCenter.Hide()
  1053.             self.HpStatus = 0
  1054.        
  1055.         elif bar == 2 :
  1056.             self.MpHead.Hide()
  1057.             self.MpCenter.Hide()
  1058.             self.MpStatus = 0
  1059.            
  1060.         elif bar == 3 :
  1061.             self.HpRecoveryHead.Hide()
  1062.             self.HpRecoveryCenter.Hide()
  1063.             self.HpRecoveryStatus = 0
  1064.        
  1065.         elif bar == 4 :
  1066.             self.MpRecoveryHead.Hide()
  1067.             self.MpRecoveryCenter.Hide()
  1068.             self.MpRecoveryStatus = 0
  1069.    
  1070.     def SetVerticalBarHp(self):
  1071.         self.hp_have = max(0,player.GetStatus(player.HP))
  1072.         self.hp_max = max(1,player.GetStatus(player.MAX_HP))
  1073.        
  1074.         if self.hp_have >= self.hp_max:
  1075.             if self.HpStatus == 3:
  1076.                 return
  1077.             else:
  1078.                 self.SetFullBar(1)
  1079.                 return
  1080.        
  1081.         if self.hp_have <= 0 :
  1082.             if self.HpStatus == 0:
  1083.                 return
  1084.             else:
  1085.                 self.SetEmptyBar(1)
  1086.                 return
  1087.        
  1088.         self.HpHead.Show()
  1089.         self.HpCenter.Show()
  1090.        
  1091.         percentageHP = float(self.hp_have)/float(self.hp_max) ##percentage of bar to show.
  1092.         percentageHpHead = (float(self.HpHeightHead)/float(self.HpTotalHeight))
  1093.         pixel = self.HpTotalHeight*(1.0-percentageHP)
  1094.        
  1095.         if percentageHP < percentageHpHead :
  1096.             self.HpHead.SetPercentageVerticalBottom(1 * percentageHP,1 * percentageHpHead)
  1097.             self.HpHead.SetPosition(self.HpHead_x , self.HpHead_y + pixel )
  1098.             self.HpCenter.Hide()
  1099.         else :
  1100.             self.HpHead.SetPosition(self.HpHead_x,self.HpHead_y + pixel)
  1101.             self.HpCenter.SetPosition(self.HpCenter_x , self.HpCenter_y+pixel)
  1102.             self.HpCenter.SetPercentageVerticalBottom(self.HpHeightCenter - pixel , self.HpHeightCenter)
  1103.             self.HpHead.SetPercentageVerticalBottom(10 , 10)
  1104.            
  1105.         self.HpStatus = 2
  1106.            
  1107.     def SetVerticalBarHpRecovery(self):
  1108.         self.hp_recovery = max(0, player.GetStatus(player.HP_RECOVERY))
  1109.         self.hp_recovery = min(self.hp_recovery + self.hp_have , self.hp_max)
  1110.        
  1111.         if self.hp_recovery >= self.hp_max:
  1112.             if self.HpRecoveryStatus == 3:
  1113.                 return
  1114.             else:
  1115.                 self.SetFullBar(3)
  1116.                 return
  1117.        
  1118.         if self.hp_recovery <= 0 :
  1119.             if self.HpRecoveryStatus == 0:
  1120.                 return
  1121.             else:
  1122.                 self.SetEmptyBar(3)
  1123.                 return
  1124.        
  1125.         self.HpRecoveryHead.Show()
  1126.         self.HpRecoveryCenter.Show()
  1127.        
  1128.         percentageHP = float(self.hp_recovery)/float(self.hp_max) ##percentage of bar to show.
  1129.         percentageHpHead = (float(self.HpHeightHead)/float(self.HpTotalHeight))
  1130.         pixel = self.HpTotalHeight*(1.0-percentageHP)
  1131.        
  1132.         if percentageHP < percentageHpHead :
  1133.             self.HpRecoveryHead.SetPercentageVerticalBottom(1 * percentageHP,1 * percentageHpHead)
  1134.             self.HpRecoveryHead.SetPosition(self.HpHead_x , self.HpHead_y + pixel )
  1135.             self.HpRecoveryCenter.Hide()
  1136.         else :
  1137.             self.HpRecoveryHead.SetPosition(self.HpHead_x,self.HpHead_y + pixel)
  1138.             self.HpRecoveryCenter.SetPosition(self.HpCenter_x , self.HpCenter_y+pixel)
  1139.             self.HpRecoveryCenter.SetPercentageVerticalBottom(self.HpHeightCenter - pixel , self.HpHeightCenter)
  1140.             self.HpRecoveryHead.SetPercentageVerticalBottom(10 , 10)
  1141.            
  1142.         self.HpRecoveryStatus = 2
  1143.        
  1144.     def SetVerticalBarMp(self):
  1145.         self.mp_have = max(0,player.GetStatus(player.SP))
  1146.         self.mp_max = max(1,player.GetStatus(player.MAX_SP))
  1147.        
  1148.        
  1149.         if self.mp_have >= self.mp_max:
  1150.             if self.MpStatus == 3:
  1151.                 return
  1152.             else:
  1153.                 self.SetFullBar(2)
  1154.                 return
  1155.        
  1156.         if self.mp_have <= 0 :
  1157.             if self.MpStatus == 0:
  1158.                 return
  1159.             else:
  1160.                 self.SetEmptyBar(2)
  1161.                 return
  1162.        
  1163.         self.MpHead.Show()
  1164.         self.MpCenter.Show()
  1165.        
  1166.         percentageMP = float(self.mp_have)/float(self.mp_max) ##percentage of bar to show.
  1167.         percentageMpHead = (float(self.MpHeightHead)/float(self.MpTotalHeight))
  1168.         pixel = self.MpTotalHeight*(1.0-percentageMP)
  1169.        
  1170.         if percentageMP < percentageMpHead :
  1171.             self.MpHead.SetPercentageVerticalBottom(1 * percentageMP,1 * percentageMpHead)
  1172.             self.MpHead.SetPosition(self.MpHead_x , self.MpHead_y + pixel )
  1173.             self.MpCenter.Hide()
  1174.         else :
  1175.             self.MpHead.SetPercentageVerticalBottom(10 , 10)
  1176.             self.MpHead.SetPosition(self.MpHead_x,self.MpHead_y + pixel)
  1177.             self.MpCenter.SetPosition(self.MpCenter_x , self.MpCenter_y+pixel)
  1178.             self.MpCenter.SetPercentageVerticalBottom(self.MpHeightCenter - pixel , self.MpHeightCenter)
  1179.             self.MpHead.SetPercentageVerticalBottom(10 , 10)
  1180.            
  1181.         self.MpStatus = 2
  1182.        
  1183.     def SetVerticalBarMpRecovery(self):
  1184.         self.mp_recovery = max(0,player.GetStatus(player.SP_RECOVERY))
  1185.        
  1186.         self.mp_recovery = min(self.mp_recovery + self.mp_have , self.mp_max)
  1187.        
  1188.         if self.mp_recovery >= self.mp_max:
  1189.             if self.MpRecoveryStatus == 3:
  1190.                 return
  1191.             else:
  1192.                 self.SetFullBar(4)
  1193.                 return
  1194.        
  1195.         if self.mp_recovery <= 0 :
  1196.             if self.MpRecoveryStatus == 0:
  1197.                 return
  1198.             else:
  1199.                 self.SetEmptyBar(4)
  1200.                 return
  1201.        
  1202.         self.MpRecoveryHead.Show()
  1203.         self.MpRecoveryCenter.Show()
  1204.        
  1205.         percentageMP = float(self.mp_recovery)/float(self.mp_max) ##percentage of bar to show.
  1206.         percentageMpHead = (float(self.MpHeightHead)/float(self.MpTotalHeight))
  1207.         pixel = self.MpTotalHeight*(1.0-percentageMP)
  1208.        
  1209.         if percentageMP < percentageMpHead :
  1210.             self.MpRecoveryHead.SetPercentageVerticalBottom(1 * percentageMP,1 * percentageMpHead)
  1211.             self.MpRecoveryHead.SetPosition(self.MpHead_x , self.MpHead_y + pixel )
  1212.             self.MpRecoveryCenter.Hide()
  1213.         else :
  1214.             self.MpRecoveryHead.SetPercentageVerticalBottom(10 , 10)
  1215.             self.MpRecoveryHead.SetPosition(self.MpHead_x,self.MpHead_y + pixel)
  1216.             self.MpRecoveryCenter.SetPosition(self.MpCenter_x , self.MpCenter_y+pixel)
  1217.             self.MpRecoveryCenter.SetPercentageVerticalBottom(self.MpHeightCenter - pixel , self.MpHeightCenter)
  1218.             self.MpRecoveryHead.SetPercentageVerticalBottom(10 , 10)
  1219.            
  1220.         self.MpRecoveryStatus = 2
  1221.        
  1222.  
  1223.     def IsInImageSquare(self,image):
  1224.         pos_x,pos_y = image.GetGlobalPosition()
  1225.         if image == self.rampageGauge1:
  1226.             pos_x += 2
  1227.             pos_y += 2
  1228.         if self.Mouse_x < pos_x or self.Mouse_y < pos_y:
  1229.             return False
  1230.         widthImage = image.GetWidth()
  1231.         heightImage = image.GetHeight()
  1232.        
  1233.         if self.Mouse_x > pos_x+widthImage or self.Mouse_y > pos_y + heightImage:
  1234.             return False
  1235.        
  1236.         return True
  1237.    
  1238.     def SetToolTipPoint(self):
  1239.         if True == self.IsInImageSquare(self.HpEmptyBar):
  1240.             self.HPToolTip.SetText("                      %s : %d / %d" % (localeInfo.TASKBAR_HP, self.hp_have, self.hp_max))
  1241.             self.HPToolTip.Show()
  1242.         else:
  1243.             self.HPToolTip.Hide()
  1244.            
  1245.         if True == self.IsInImageSquare(self.MpEmptyBar):
  1246.             self.MPToolTip.SetText("                 %s : %d / %d" % (localeInfo.TASKBAR_SP, self.mp_have, self.mp_max))
  1247.             self.MPToolTip.Show()
  1248.         else:
  1249.             self.MPToolTip.Hide()
  1250.    
  1251.     ####end of hp and mp gauge -------------------------------------------------------
  1252.     ###tooltip ENERGY
  1253.     def IsInEnergyGauge(self):
  1254.         if self.EnergyImage[self.EnergyActualImage].IsIn() or self.rightTaskBar.GetChild("EnergyBarEmpty").IsIn():
  1255.             x_cord = self.Mouse_x
  1256.             y_cord = self.Mouse_y
  1257.             distance_x = max(x_cord - self.CenterOfEnergyCircle_x , self.CenterOfEnergyCircle_x - x_cord)
  1258.             distance_y = max(y_cord - self.CenterOfEnergyCircle_y , self.CenterOfEnergyCircle_y - y_cord)
  1259.             distance_absolute_energy = math.sqrt((distance_x * distance_x) + (distance_y * distance_y))
  1260.             if distance_absolute_energy < self.RadiusEnergy - self.CircleThicknessEnergy or distance_absolute_energy > self.RadiusEnergy:
  1261.                 return False
  1262.             else:
  1263.                 return True
  1264.         else:
  1265.             return False
  1266.            
  1267.     def SetEnergyToolTip(self):
  1268.         if self.IsInEnergyGauge():
  1269.             self.EnergyToolTip.Show()
  1270.         else:
  1271.             self.EnergyToolTip.Hide()
  1272.            
  1273.            
  1274.     #end tooltip energy
  1275.    
  1276.     ####energy refresh
  1277.    
  1278.     def RefreshEnergy(self):
  1279.         leftTimeEnergy = max(0,player.GetStatus(player.ENERGY_END_TIME) - app.GetGlobalTimeStamp())
  1280.         if leftTimeEnergy == 0 and self.EnergyStatus == 0:
  1281.             return
  1282.         elif leftTimeEnergy == 0 and self.EnergyStatus != 0:
  1283.             if self.EnergyActualImage != 0:
  1284.                 self.EnergyImage[self.EnergyActualImage].Hide()
  1285.             pointEnergy = max(0,player.GetStatus(player.ENERGY))
  1286.             self.EnergyToolTip.SetText(localeInfo.SecondToHM(leftTimeEnergy) + " - Energia +" + str(pointEnergy) + "%")
  1287.             self.EnergyStatus = 0
  1288.         else:
  1289.             totalTimeEnergy = 7200  ###Usually this value is 7200, if your game is different, change it
  1290.             timeToImage = max(1,int(float(leftTimeEnergy)/float(totalTimeEnergy) * 17.0))
  1291.             if timeToImage != self.EnergyActualImage:
  1292.                 if self.EnergyStatus == 0:
  1293.                     self.EnergyImage[timeToImage-1].Show()
  1294.                     self.EnergyActualImage = timeToImage-1
  1295.                     pointEnergy = max(0,player.GetStatus(player.ENERGY))
  1296.                     self.EnergyToolTip.SetText(localeInfo.SecondToHM(leftTimeEnergy) + " - Energia +" + str(pointEnergy) + "%")
  1297.                     self.EnergyStatus = 1
  1298.                 else:
  1299.                     self.EnergyImage[self.EnergyActualImage].Hide()
  1300.                     self.EnergyImage[timeToImage-1].Show()
  1301.                     self.EnergyActualImage = timeToImage-1
  1302.                     pointEnergy = max(0,player.GetStatus(player.ENERGY))
  1303.                     self.EnergyToolTip.SetText(localeInfo.SecondToHM(leftTimeEnergy) + " - Energia +" + str(pointEnergy) + "%")
  1304.                     self.EnergyStatus = 1
  1305.        
  1306.     ## Skill
  1307.     def ToggleLeftMouseButtonModeWindow(self):
  1308.  
  1309.         wndMouseButtonMode = self.mouseModeButtonList[self.MOUSE_BUTTON_LEFT]
  1310.  
  1311.         if TRUE == wndMouseButtonMode.IsShow():
  1312.  
  1313.             wndMouseButtonMode.Hide()
  1314.  
  1315.         else:
  1316.             wndMouseButtonMode.Show()
  1317.         self.GetChild("RightMouseButton").Hide()
  1318.  
  1319.     def ToggleRightMouseButtonModeWindow(self):
  1320.  
  1321.         wndMouseButtonMode = self.mouseModeButtonList[self.MOUSE_BUTTON_RIGHT]
  1322.  
  1323.         if True == wndMouseButtonMode.IsShow():
  1324.  
  1325.             wndMouseButtonMode.Hide()
  1326.             self.CloseSelectSkill()
  1327.  
  1328.         else:
  1329.             wndMouseButtonMode.Show()
  1330.             self.OpenSelectSkill()
  1331.  
  1332.     def OpenSelectSkill(self):
  1333.  
  1334.         PAGE_SLOT_COUNT = 6
  1335.  
  1336.         (xSkillButton, y) = self.curSkillButton.GetGlobalPosition()
  1337.         y -= (37 + 32 + 1)
  1338.  
  1339.         for key in self.skillCategoryNameList:
  1340.  
  1341.             appendCount = 0
  1342.             startNumber = self.skillPageStartSlotIndexDict[key]
  1343.             x = xSkillButton
  1344.  
  1345.             getSkillIndex=player.GetSkillIndex
  1346.             getSkillLevel=player.GetSkillLevel
  1347.             for i in xrange(PAGE_SLOT_COUNT):
  1348.  
  1349.                 skillIndex = getSkillIndex(startNumber+i)
  1350.                 skillLevel = getSkillLevel(startNumber+i)
  1351.  
  1352.                 if 0 == skillIndex:
  1353.                     continue
  1354.                 if 0 == skillLevel:
  1355.                     continue
  1356.                 if skill.IsStandingSkill(skillIndex):
  1357.                     continue
  1358.  
  1359.                 ## FIXME : ½ºÅ³ Çϳª´ç ½½·Ô Çϳª¾¿ ÇÒ´çÇÏ´Â°Ç ¾Æ¹«¸® ºÁµµ ºÎÇÏ°¡ Å©´Ù.
  1360.                 ##       ÀÌ ºÎºÐÀº ½Ã°£À» ³ª¸é °íÄ¡µµ·Ï. - [levites]
  1361.                 skillButton = self.SkillButton()
  1362.                 skillButton.SetSkill(startNumber+i)
  1363.                 skillButton.SetPosition(x, y)
  1364.                 skillButton.SetSkillEvent(ui.__mem_func__(self.CloseSelectSkill), startNumber+i+1)
  1365.                 skillButton.SetSkillToolTip(self.tooltipSkill)
  1366.                 skillButton.SetTop()
  1367.                 skillButton.Show()
  1368.                 self.selectSkillButtonList.append(skillButton)
  1369.  
  1370.                 appendCount += 1
  1371.                 x -= 32
  1372.  
  1373.             if appendCount > 0:
  1374.                 y -= 32
  1375.  
  1376.     def CloseSelectSkill(self, slotIndex=-1):
  1377.  
  1378.         self.mouseModeButtonList[self.MOUSE_BUTTON_RIGHT].Hide()
  1379.         for button in self.selectSkillButtonList:
  1380.             button.Destroy()
  1381.  
  1382.         self.selectSkillButtonList = []
  1383.  
  1384.         if -1 != slotIndex:
  1385.             self.curSkillButton.Show()
  1386.             self.curMouseModeButton[self.MOUSE_BUTTON_RIGHT].Hide()
  1387.             player.SetMouseFunc(player.MBT_RIGHT, player.MBF_SKILL)
  1388.             player.ChangeCurrentSkillNumberOnly(slotIndex-1)
  1389.         else:
  1390.             self.curSkillButton.Hide()
  1391.             self.curMouseModeButton[self.MOUSE_BUTTON_RIGHT].Show()
  1392.  
  1393.     def SelectMouseButtonEvent(self, dir, event):
  1394.         SetMouseButtonSetting(dir, event)
  1395.  
  1396.         self.CloseSelectSkill()
  1397.         self.mouseModeButtonList[dir].Hide()
  1398.  
  1399.         btn = 0
  1400.         type = self.NONE
  1401.         func = self.NONE
  1402.         tooltip_text = ""      
  1403.        
  1404.         if self.MOUSE_BUTTON_LEFT == dir:
  1405.             type = player.MBT_LEFT
  1406.  
  1407.         elif self.MOUSE_BUTTON_RIGHT == dir:
  1408.             type = player.MBT_RIGHT
  1409.  
  1410.         if self.EVENT_MOVE == event:
  1411.             btn = self.mouseModeButtonList[dir].GetChild("button_move")
  1412.             func = player.MBF_MOVE
  1413.             tooltip_text = localeInfo.TASKBAR_MOVE
  1414.         elif self.EVENT_ATTACK == event:
  1415.             btn = self.mouseModeButtonList[dir].GetChild("button_attack")
  1416.             func = player.MBF_ATTACK
  1417.             tooltip_text = localeInfo.TASKBAR_ATTACK
  1418.         elif self.EVENT_AUTO == event:
  1419.             btn = self.mouseModeButtonList[dir].GetChild("button_auto_attack")
  1420.             func = player.MBF_AUTO
  1421.             tooltip_text = localeInfo.TASKBAR_AUTO
  1422.         elif self.EVENT_MOVE_AND_ATTACK == event:
  1423.             btn = self.mouseModeButtonList[dir].GetChild("button_move_and_attack")
  1424.             func = player.MBF_SMART
  1425.             tooltip_text = localeInfo.TASKBAR_ATTACK
  1426.         elif self.EVENT_CAMERA == event:
  1427.             btn = self.mouseModeButtonList[dir].GetChild("button_camera")
  1428.             func = player.MBF_CAMERA
  1429.             tooltip_text = localeInfo.TASKBAR_CAMERA
  1430.         elif self.EVENT_SKILL == event:
  1431.             btn = self.mouseModeButtonList[dir].GetChild("button_skill")
  1432.             func = player.MBF_SKILL
  1433.             tooltip_text = localeInfo.TASKBAR_SKILL
  1434.  
  1435.         if 0 != btn:
  1436.             self.curMouseModeButton[dir].SetToolTipText(tooltip_text, 0, -18)
  1437.             self.curMouseModeButton[dir].SetUpVisual(btn.GetUpVisualFileName())
  1438.             self.curMouseModeButton[dir].SetOverVisual(btn.GetOverVisualFileName())
  1439.             self.curMouseModeButton[dir].SetDownVisual(btn.GetDownVisualFileName())
  1440.             self.curMouseModeButton[dir].Show()
  1441.  
  1442.         player.SetMouseFunc(type, func)
  1443.         self.GetChild("RightMouseButton").Hide()#to do not show rightmousebutton
  1444.  
  1445.     def OnChangeCurrentSkill(self, skillSlotNumber):
  1446.         self.curSkillButton.SetSkill(skillSlotNumber)
  1447.         self.curSkillButton.Show()
  1448.         self.curMouseModeButton[self.MOUSE_BUTTON_RIGHT].Hide()
  1449.  
  1450.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement