Ulthar_1337

Untitled

Jun 3rd, 2022
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 42.82 KB | None | 0 0
  1. import ui
  2. import uiScriptLocale
  3. import app
  4. import net
  5. import dbg
  6. import snd
  7. import player
  8. import mouseModule
  9. import wndMgr
  10. import skill
  11. import playerSettingModule
  12. import quest
  13. import localeInfo
  14. import uiToolTip
  15. import constInfo
  16. import emotion
  17. import chr
  18.  
  19. if app.ENABLE_SKILL_COLOR_SYSTEM:
  20.     import uiSkillColor
  21. if app.ENABLE_KILL_STATISTICS:
  22.     import uikillstatistics
  23.  
  24.  
  25.  
  26. SHOW_ONLY_ACTIVE_SKILL = False
  27. SHOW_LIMIT_SUPPORT_SKILL_LIST = []
  28. HIDE_SUPPORT_SKILL_POINT = False
  29.  
  30. if localeInfo.IsYMIR():
  31.     SHOW_LIMIT_SUPPORT_SKILL_LIST = [122, 123, 121, 124, 0, 129, 164, 165, 166, 130, 131, 132,]
  32.     if not localeInfo.IsCHEONMA():
  33.         HIDE_SUPPORT_SKILL_POINT = True
  34.         SHOW_LIMIT_SUPPORT_SKILL_LIST = [121, 122, 123, 124, 126, 127, 129, 128, 131, 132, 137, 138, 139, 140,141,142]
  35. elif localeInfo.IsJAPAN() or   (localeInfo.IsEUROPE() and app.GetLocalePath() != "locale/ca") and (localeInfo.IsEUROPE() and app.GetLocalePath() != "locale/br"):
  36.     HIDE_SUPPORT_SKILL_POINT = True
  37.     SHOW_LIMIT_SUPPORT_SKILL_LIST = [121, 122, 123, 124, 126, 127, 129, 128, 131, 137, 138, 139, 140]
  38. else:
  39.     HIDE_SUPPORT_SKILL_POINT = True
  40.  
  41. FACE_IMAGE_DICT = {
  42.     playerSettingModule.RACE_WARRIOR_M  : "icon/face/warrior_m.tga",
  43.     playerSettingModule.RACE_WARRIOR_W  : "icon/face/warrior_w.tga",
  44.     playerSettingModule.RACE_ASSASSIN_M : "icon/face/assassin_m.tga",
  45.     playerSettingModule.RACE_ASSASSIN_W : "icon/face/assassin_w.tga",
  46.     playerSettingModule.RACE_SURA_M     : "icon/face/sura_m.tga",
  47.     playerSettingModule.RACE_SURA_W     : "icon/face/sura_w.tga",
  48.     playerSettingModule.RACE_SHAMAN_M   : "icon/face/shaman_m.tga",
  49.     playerSettingModule.RACE_SHAMAN_W   : "icon/face/shaman_w.tga",
  50. }
  51. def unsigned32(n):
  52.     return n & 0xFFFFFFFFL
  53.    
  54. class CharacterWindow(ui.ScriptWindow):
  55.  
  56.     ACTIVE_PAGE_SLOT_COUNT = 8
  57.     SUPPORT_PAGE_SLOT_COUNT = 12
  58.  
  59.     PAGE_SLOT_COUNT = 12
  60.     PAGE_HORSE = 2
  61.  
  62.     SKILL_GROUP_NAME_DICT = {
  63.         playerSettingModule.JOB_WARRIOR : { 1 : localeInfo.SKILL_GROUP_WARRIOR_1,   2 : localeInfo.SKILL_GROUP_WARRIOR_2, },
  64.         playerSettingModule.JOB_ASSASSIN    : { 1 : localeInfo.SKILL_GROUP_ASSASSIN_1,  2 : localeInfo.SKILL_GROUP_ASSASSIN_2, },
  65.         playerSettingModule.JOB_SURA        : { 1 : localeInfo.SKILL_GROUP_SURA_1,      2 : localeInfo.SKILL_GROUP_SURA_2, },
  66.         playerSettingModule.JOB_SHAMAN      : { 1 : localeInfo.SKILL_GROUP_SHAMAN_1,    2 : localeInfo.SKILL_GROUP_SHAMAN_2, },
  67.     }
  68.  
  69.     STAT_DESCRIPTION =  {
  70.         "HTH" : localeInfo.STAT_TOOLTIP_CON,
  71.         "INT" : localeInfo.STAT_TOOLTIP_INT,
  72.         "STR" : localeInfo.STAT_TOOLTIP_STR,
  73.         "DEX" : localeInfo.STAT_TOOLTIP_DEX,
  74.     }
  75.  
  76.  
  77.     STAT_MINUS_DESCRIPTION = localeInfo.STAT_MINUS_DESCRIPTION
  78.  
  79.     def __init__(self):
  80.         if app.ENABLE_SKILL_COLOR_SYSTEM:
  81.             self.skillColorWnd = None
  82.             self.skillColorButton = []
  83.         if app.ENABLE_KILL_STATISTICS:
  84.             self.KillStatisticsWnd = None
  85.             self.isOpenedKillStatisticsWnd = False 
  86.         ui.ScriptWindow.__init__(self)
  87.         self.state = "STATUS"
  88.         self.isLoaded = 0
  89.  
  90.         self.toolTipSkill = 0
  91.                
  92.         self.__Initialize()
  93.         self.__LoadWindow()
  94.  
  95.         self.statusPlusCommandDict={
  96.             "HTH" : "/stat_val ht ",
  97.             "INT" : "/stat_val iq ",
  98.             "STR" : "/stat_val st ",
  99.             "DEX" : "/stat_val dx ",
  100.         }
  101.  
  102.         self.statusMinusCommandDict={
  103.             "HTH-" : "/stat- ht",
  104.             "INT-" : "/stat- iq",
  105.             "STR-" : "/stat- st",
  106.             "DEX-" : "/stat- dx",
  107.         }
  108.  
  109.     def __del__(self):
  110.         ui.ScriptWindow.__del__(self)
  111.  
  112.     def __Initialize(self):
  113.         self.refreshToolTip = 0
  114.         self.curSelectedSkillGroup = 0
  115.         self.canUseHorseSkill = -1
  116.  
  117.         self.toolTip = None
  118.         self.toolTipJob = None
  119.         self.toolTipAlignment = None
  120.         self.toolTipSkill = None
  121.  
  122.         self.faceImage = None
  123.         self.statusPlusLabel = None
  124.         self.statusPlusValue = None
  125.         self.activeSlot = None
  126.         self.tabDict = None
  127.         self.tabButtonDict = None
  128.         self.pageDict = None
  129.         self.titleBarDict = None
  130.         self.statusPlusButtonDict = None
  131.         self.statusMinusButtonDict = None
  132.  
  133.         self.skillPageDict = None
  134.         self.questShowingStartIndex = 0
  135.         self.questScrollBar = None
  136.         self.questSlot = None
  137.         self.questNameList = None
  138.         self.questLastTimeList = None
  139.         self.questLastCountList = None
  140.         self.skillGroupButton = ()
  141.  
  142.         self.activeSlot = None
  143.         self.activeSkillPointValue = None
  144.         self.supportSkillPointValue = None
  145.         self.skillGroupButton1 = None
  146.         self.skillGroupButton2 = None
  147.         self.activeSkillGroupName = None
  148.  
  149.         self.guildNameSlot = None
  150.         self.guildNameValue = None
  151.         self.characterNameSlot = None
  152.         self.characterNameValue = None
  153.  
  154.         self.emotionToolTip = None
  155.         self.soloEmotionSlot = None
  156.         self.dualEmotionSlot = None
  157.  
  158.     def Show(self):
  159.         self.__LoadWindow()
  160.  
  161.         if app.ENABLE_KILL_STATISTICS:
  162.             self.__InitKillStatisticsUIButton()
  163.             if self.KillStatisticsWnd and self.isOpenedKillStatisticsWnd:
  164.                 self.KillStatisticsWnd.Show()
  165.  
  166.         ui.ScriptWindow.Show(self)
  167.  
  168.     if app.ENABLE_KILL_STATISTICS:
  169.         def OnTop(self):
  170.             if self.KillStatisticsWnd:
  171.                 self.KillStatisticsWnd.SetTop()
  172.  
  173.         def Hide(self):
  174.             if self.KillStatisticsWnd:
  175.                 self.isOpenedKillStatisticsWnd = self.KillStatisticsWnd.IsShow()
  176.                 self.KillStatisticsWnd.Close()
  177.                
  178.             wndMgr.Hide(self.hWnd)
  179.  
  180.     def __LoadScript(self, fileName):
  181.         pyScrLoader = ui.PythonScriptLoader()
  182.         pyScrLoader.LoadScriptFile(self, fileName) 
  183.        
  184.     def __BindObject(self):
  185.         self.toolTip = uiToolTip.ToolTip()
  186.         self.toolTipJob = uiToolTip.ToolTip()
  187.         self.toolTipAlignment = uiToolTip.ToolTip(130)     
  188.  
  189.         self.faceImage = self.GetChild("Face_Image")
  190.  
  191.         faceSlot=self.GetChild("Face_Slot")
  192.         if 949 == app.GetDefaultCodePage():
  193.             faceSlot.SAFE_SetStringEvent("MOUSE_OVER_IN", self.__ShowJobToolTip)
  194.             faceSlot.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.__HideJobToolTip)
  195.  
  196.         self.statusPlusLabel = self.GetChild("Status_Plus_Label")
  197.         self.statusPlusValue = self.GetChild("Status_Plus_Value")      
  198.  
  199.         self.characterNameSlot = self.GetChild("Character_Name_Slot")          
  200.         self.characterNameValue = self.GetChild("Character_Name")
  201.         self.guildNameSlot = self.GetChild("Guild_Name_Slot")
  202.         self.guildNameValue = self.GetChild("Guild_Name")
  203.         self.characterNameSlot.SAFE_SetStringEvent("MOUSE_OVER_IN", self.__ShowAlignmentToolTip)
  204.         self.characterNameSlot.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.__HideAlignmentToolTip)
  205.  
  206.         self.activeSlot = self.GetChild("Skill_Active_Slot")
  207.         self.activeSkillPointValue = self.GetChild("Active_Skill_Point_Value")
  208.         self.supportSkillPointValue = self.GetChild("Support_Skill_Point_Value")
  209.         self.skillGroupButton1 = self.GetChild("Skill_Group_Button_1")
  210.         self.skillGroupButton2 = self.GetChild("Skill_Group_Button_2")
  211.         self.activeSkillGroupName = self.GetChild("Active_Skill_Group_Name")
  212.  
  213.         self.tabDict = {
  214.             "STATUS"    : self.GetChild("Tab_01"),
  215.             "SKILL"     : self.GetChild("Tab_02"),
  216.             "EMOTICON"  : self.GetChild("Tab_03"),
  217.             "QUEST"     : self.GetChild("Tab_04"),
  218.         }
  219.  
  220.         self.tabButtonDict = {
  221.             "STATUS"    : self.GetChild("Tab_Button_01"),
  222.             "SKILL"     : self.GetChild("Tab_Button_02"),
  223.             "EMOTICON"  : self.GetChild("Tab_Button_03"),
  224.             "QUEST"     : self.GetChild("Tab_Button_04")
  225.         }
  226.  
  227.         self.pageDict = {
  228.             "STATUS"    : self.GetChild("Character_Page"),
  229.             "SKILL"     : self.GetChild("Skill_Page"),
  230.             "EMOTICON"  : self.GetChild("Emoticon_Page"),
  231.             "QUEST"     : self.GetChild("Quest_Page")
  232.         }
  233.  
  234.         self.titleBarDict = {
  235.             "STATUS"    : self.GetChild("Character_TitleBar"),
  236.             "SKILL"     : self.GetChild("Skill_TitleBar"),
  237.             "EMOTICON"  : self.GetChild("Emoticon_TitleBar"),
  238.             "QUEST"     : self.GetChild("Quest_TitleBar")
  239.         }
  240.  
  241.         self.statusPlusButtonDict = {
  242.             "HTH"       : self.GetChild("HTH_Plus"),
  243.             "INT"       : self.GetChild("INT_Plus"),
  244.             "STR"       : self.GetChild("STR_Plus"),
  245.             "DEX"       : self.GetChild("DEX_Plus"),
  246.         }
  247.  
  248.         self.statusMinusButtonDict = {
  249.             "HTH-"      : self.GetChild("HTH_Minus"),
  250.             "INT-"      : self.GetChild("INT_Minus"),
  251.             "STR-"      : self.GetChild("STR_Minus"),
  252.             "DEX-"      : self.GetChild("DEX_Minus"),
  253.         }
  254.  
  255.         self.skillPageDict = {
  256.             "ACTIVE" : self.GetChild("Skill_Active_Slot"),
  257.             "SUPPORT" : self.GetChild("Skill_ETC_Slot"),
  258.             "HORSE" : self.GetChild("Skill_Active_Slot"),
  259.         }
  260.  
  261.         self.skillPageStatDict = {
  262.             "SUPPORT"   : player.SKILL_SUPPORT,
  263.             "ACTIVE"    : player.SKILL_ACTIVE,
  264.             "HORSE"     : player.SKILL_HORSE,
  265.         }
  266.  
  267.         self.skillGroupButton = (
  268.             self.GetChild("Skill_Group_Button_1"),
  269.             self.GetChild("Skill_Group_Button_2"),
  270.         )
  271.  
  272.        
  273.         global SHOW_ONLY_ACTIVE_SKILL
  274.         global HIDE_SUPPORT_SKILL_POINT
  275.         if SHOW_ONLY_ACTIVE_SKILL or HIDE_SUPPORT_SKILL_POINT: 
  276.             self.GetChild("Support_Skill_Point_Label").Hide()
  277.  
  278.         self.soloEmotionSlot = self.GetChild("SoloEmotionSlot")
  279.         self.dualEmotionSlot = self.GetChild("DualEmotionSlot")
  280.         self.__SetEmotionSlot()
  281.  
  282.         self.questShowingStartIndex = 0
  283.         self.questScrollBar = self.GetChild("Quest_ScrollBar")
  284.         self.questScrollBar.SetScrollEvent(ui.__mem_func__(self.OnQuestScroll))
  285.         self.questSlot = self.GetChild("Quest_Slot")
  286.         for i in xrange(quest.QUEST_MAX_NUM):
  287.             self.questSlot.HideSlotBaseImage(i)
  288.             self.questSlot.SetCoverButton(i,\
  289.                                             "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  290.                                             "d:/ymir work/ui/game/quest/slot_button_02.sub",\
  291.                                             "d:/ymir work/ui/game/quest/slot_button_03.sub",\
  292.                                             "d:/ymir work/ui/game/quest/slot_button_03.sub", True)
  293.  
  294.         self.questNameList = []
  295.         self.questLastTimeList = []
  296.         self.questLastCountList = []
  297.         for i in xrange(quest.QUEST_MAX_NUM):
  298.             self.questNameList.append(self.GetChild("Quest_Name_0" + str(i)))
  299.             self.questLastTimeList.append(self.GetChild("Quest_LastTime_0" + str(i)))
  300.             self.questLastCountList.append(self.GetChild("Quest_LastCount_0" + str(i)))
  301.  
  302.         if app.ENABLE_KILL_STATISTICS:
  303.             self.MainBoard = self.GetChild("board")
  304.             self.ExpandBtn = ui.MakeButton(self.MainBoard, 240, 120, "", "d:/ymir work/ui/game/belt_inventory/", "btn_minimize_normal.tga", "btn_minimize_over.tga", "btn_minimize_down.tga")
  305.             self.ExpandBtn.SetEvent(ui.__mem_func__(self.__ClickExpandButton))
  306.             self.MinimizeBtn = ui.MakeButton(self.MainBoard, 240, 120, "", "d:/ymir work/ui/game/belt_inventory/", "btn_expand_normal.tga", "btn_expand_over.tga", "btn_expand_down.tga")
  307.             self.MinimizeBtn.SetEvent(ui.__mem_func__(self.__ClickMinimizeButton))
  308.  
  309.     if app.ENABLE_KILL_STATISTICS:
  310.         def __InitKillStatisticsUIButton(self):
  311.             self.ExpandBtn.Show()
  312.             self.MinimizeBtn.Hide()
  313.  
  314.         def __ClickExpandButton(self):
  315.             if not self.KillStatisticsWnd:
  316.                 self.KillStatisticsWnd = uikillstatistics.KillStatisticsUI(self)
  317.                 self.KillStatisticsWnd.Show()
  318.             else:
  319.                 self.KillStatisticsWnd.Show()
  320.                
  321.             x, y = self.GetGlobalPosition()
  322.             self.KillStatisticsWnd.AdjustPosition(x, y)
  323.  
  324.             self.ExpandBtn.Hide()
  325.             self.MinimizeBtn.Show()
  326.  
  327.         def __ClickMinimizeButton(self):
  328.             self.KillStatisticsWnd.Hide()
  329.             self.MinimizeBtn.Hide()
  330.             self.ExpandBtn.Show()
  331.  
  332.         def OnMoveWindow(self, x, y):
  333.             if self.KillStatisticsWnd:
  334.                 self.KillStatisticsWnd.AdjustPosition(x, y)
  335.  
  336.     def __SetSkillSlotEvent(self):
  337.         for skillPageValue in self.skillPageDict.itervalues():
  338.             skillPageValue.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
  339.             skillPageValue.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectSkill))
  340.             skillPageValue.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  341.             skillPageValue.SetUnselectItemSlotEvent(ui.__mem_func__(self.ClickSkillSlot))
  342.             skillPageValue.SetUseSlotEvent(ui.__mem_func__(self.ClickSkillSlot))
  343.             skillPageValue.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  344.             skillPageValue.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  345.             skillPageValue.SetPressedSlotButtonEvent(ui.__mem_func__(self.OnPressedSlotButton))
  346.             skillPageValue.AppendSlotButton("d:/ymir work/ui/game/windows/btn_plus_up.sub",\
  347.                                             "d:/ymir work/ui/game/windows/btn_plus_over.sub",\
  348.                                             "d:/ymir work/ui/game/windows/btn_plus_down.sub")
  349.  
  350.     def __SetEmotionSlot(self):
  351.  
  352.         self.emotionToolTip = uiToolTip.ToolTip()
  353.  
  354.         for slot in (self.soloEmotionSlot, self.dualEmotionSlot):
  355.             slot.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
  356.             slot.SetSelectItemSlotEvent(ui.__mem_func__(self.__SelectEmotion))
  357.             slot.SetUnselectItemSlotEvent(ui.__mem_func__(self.__ClickEmotionSlot))
  358.             slot.SetUseSlotEvent(ui.__mem_func__(self.__ClickEmotionSlot))
  359.             slot.SetOverInItemEvent(ui.__mem_func__(self.__OverInEmotion))
  360.             slot.SetOverOutItemEvent(ui.__mem_func__(self.__OverOutEmotion))
  361.             slot.AppendSlotButton("d:/ymir work/ui/game/windows/btn_plus_up.sub",\
  362.                                             "d:/ymir work/ui/game/windows/btn_plus_over.sub",\
  363.                                             "d:/ymir work/ui/game/windows/btn_plus_down.sub")
  364.  
  365.         for slotIdx, datadict in emotion.EMOTION_DICT.items():
  366.             emotionIdx = slotIdx
  367.  
  368.             slot = self.soloEmotionSlot
  369.             if slotIdx > 50:
  370.                 slot = self.dualEmotionSlot
  371.  
  372.             slot.SetEmotionSlot(slotIdx, emotionIdx)
  373.             slot.SetCoverButton(slotIdx)
  374.  
  375.     def __SelectEmotion(self, slotIndex):
  376.         if not slotIndex in emotion.EMOTION_DICT:
  377.             return
  378.  
  379.         if app.IsPressed(app.DIK_LCONTROL):
  380.             player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_EMOTION, slotIndex)
  381.             return
  382.  
  383.         mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_EMOTION, slotIndex, slotIndex)
  384.  
  385.     def __ClickEmotionSlot(self, slotIndex):
  386.         print "click emotion"
  387.         if not slotIndex in emotion.EMOTION_DICT:
  388.             return
  389.  
  390.         print "check acting"
  391.         if player.IsActingEmotion():
  392.             return
  393.  
  394.         command = emotion.EMOTION_DICT[slotIndex]["command"]
  395.         print "command", command
  396.  
  397.         if slotIndex > 50:
  398.             vid = player.GetTargetVID()
  399.  
  400.             if 0 == vid or vid == player.GetMainCharacterIndex() or chr.IsNPC(vid) or chr.IsEnemy(vid):
  401.                 import chat
  402.                 chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.EMOTION_CHOOSE_ONE)
  403.                 return
  404.  
  405.             command += " " + chr.GetNameByVID(vid)
  406.  
  407.         print "send_command", command
  408.         net.SendChatPacket(command)
  409.  
  410.     def ActEmotion(self, emotionIndex):
  411.         self.__ClickEmotionSlot(emotionIndex)
  412.  
  413.     def __OverInEmotion(self, slotIndex):
  414.         if self.emotionToolTip:
  415.  
  416.             if not slotIndex in emotion.EMOTION_DICT:
  417.                 return
  418.  
  419.             self.emotionToolTip.ClearToolTip()
  420.             self.emotionToolTip.SetTitle(emotion.EMOTION_DICT[slotIndex]["name"])
  421.             self.emotionToolTip.AlignHorizonalCenter()
  422.             self.emotionToolTip.ShowToolTip()
  423.  
  424.     def __OverOutEmotion(self):
  425.         if self.emotionToolTip:
  426.             self.emotionToolTip.HideToolTip()
  427.  
  428.     def __BindEvent(self):
  429.         for i in xrange(len(self.skillGroupButton)):
  430.             self.skillGroupButton[i].SetEvent(lambda arg=i: self.__SelectSkillGroup(arg))
  431.  
  432.         self.RefreshQuest()
  433.         self.__HideJobToolTip()
  434.  
  435.         for (tabKey, tabButton) in self.tabButtonDict.items():
  436.             tabButton.SetEvent(ui.__mem_func__(self.__OnClickTabButton), tabKey)
  437.  
  438.         for (statusPlusKey, statusPlusButton) in self.statusPlusButtonDict.items():
  439.             statusPlusButton.SAFE_SetEvent(self.__OnClickStatusPlusButton, statusPlusKey)
  440.             statusPlusButton.ShowToolTip = lambda arg=statusPlusKey: self.__OverInStatButton(arg)
  441.             statusPlusButton.HideToolTip = lambda arg=statusPlusKey: self.__OverOutStatButton()
  442.  
  443.         for (statusMinusKey, statusMinusButton) in self.statusMinusButtonDict.items():
  444.             statusMinusButton.SAFE_SetEvent(self.__OnClickStatusMinusButton, statusMinusKey)
  445.             statusMinusButton.ShowToolTip = lambda arg=statusMinusKey: self.__OverInStatMinusButton(arg)
  446.             statusMinusButton.HideToolTip = lambda arg=statusMinusKey: self.__OverOutStatMinusButton()
  447.  
  448.         for titleBarValue in self.titleBarDict.itervalues():
  449.             if app.ENABLE_KILL_STATISTICS:
  450.                 titleBarValue.SetCloseEvent(ui.__mem_func__(self.Close))
  451.             else:
  452.                 titleBarValue.SetCloseEvent(ui.__mem_func__(self.Hide))
  453.  
  454.         self.questSlot.SetSelectItemSlotEvent(ui.__mem_func__(self.__SelectQuest))
  455.  
  456.     def __LoadWindow(self):
  457.         if self.isLoaded == 1:
  458.             return
  459.  
  460.         self.isLoaded = 1
  461.  
  462.         try:
  463.             if localeInfo.IsARABIC() or localeInfo.IsVIETNAM() or localeInfo.IsJAPAN():
  464.                 self.__LoadScript(uiScriptLocale.LOCALE_UISCRIPT_PATH + "CharacterWindow.py")
  465.             else:
  466.                 self.__LoadScript("UIScript/CharacterWindow.py")
  467.                
  468.             self.__BindObject()
  469.             self.__BindEvent()
  470.         except:
  471.             import exception
  472.             exception.Abort("CharacterWindow.__LoadWindow")
  473.  
  474.         #self.tabButtonDict["EMOTICON"].Disable()
  475.         self.SetState("STATUS")
  476.  
  477.     def Destroy(self):
  478.         self.ClearDictionary()
  479.  
  480.         self.__Initialize()
  481.  
  482.     def Close(self):
  483.         if 0 != self.toolTipSkill:
  484.             self.toolTipSkill.Hide()
  485.  
  486.         if app.ENABLE_SKILL_COLOR_SYSTEM:
  487.             if self.skillColorWnd and self.skillColorWnd.IsShow():
  488.                 self.skillColorWnd.Hide()
  489.  
  490.         if app.ENABLE_KILL_STATISTICS:
  491.             if self.KillStatisticsWnd and self.KillStatisticsWnd.IsShow():
  492.                 self.KillStatisticsWnd.Hide()
  493.  
  494.         self.Hide()
  495.  
  496.     def SetSkillToolTip(self, toolTipSkill):
  497.         self.toolTipSkill = toolTipSkill
  498.  
  499.     def __OnClickStatusPlusButton(self, statusKey):
  500.         cmd = self.statusPlusCommandDict[statusKey]
  501.  
  502.         if app.IsPressed(app.DIK_LCONTROL):
  503.             cmd = cmd + "10"
  504.         else:
  505.             cmd = cmd + "1"
  506.            
  507.         net.SendChatPacket(cmd)
  508.  
  509.     def __OnClickStatusMinusButton(self, statusKey):
  510.         try:
  511.             statusMinusCommand=self.statusMinusCommandDict[statusKey]
  512.             net.SendChatPacket(statusMinusCommand)
  513.         except KeyError, msg:
  514.             dbg.TraceError("CharacterWindow.__OnClickStatusMinusButton KeyError: %s", msg)
  515.  
  516.  
  517.     def __OnClickTabButton(self, stateKey):
  518.         self.SetState(stateKey)
  519.  
  520.     def SetState(self, stateKey):
  521.        
  522.         self.state = stateKey
  523.  
  524.         for (tabKey, tabButton) in self.tabButtonDict.items():
  525.             if stateKey!=tabKey:
  526.                 tabButton.SetUp()
  527.  
  528.         for tabValue in self.tabDict.itervalues():
  529.             tabValue.Hide()
  530.  
  531.         for pageValue in self.pageDict.itervalues():
  532.             pageValue.Hide()
  533.  
  534.         for titleBarValue in self.titleBarDict.itervalues():
  535.             titleBarValue.Hide()
  536.  
  537.         self.titleBarDict[stateKey].Show()
  538.         self.tabDict[stateKey].Show()
  539.         self.pageDict[stateKey].Show()
  540.        
  541.  
  542.     def GetState(self):
  543.         return self.state
  544.  
  545.     def __GetTotalAtkText(self):
  546.         minAtk=player.GetStatus(player.ATT_MIN)
  547.         maxAtk=player.GetStatus(player.ATT_MAX)
  548.         atkBonus=player.GetStatus(player.ATT_BONUS)
  549.         attackerBonus=player.GetStatus(player.ATTACKER_BONUS)
  550.  
  551.         if minAtk==maxAtk:
  552.             return "%d" % (minAtk+atkBonus+attackerBonus)
  553.         else:
  554.             return "%d-%d" % (minAtk+atkBonus+attackerBonus, maxAtk+atkBonus+attackerBonus)
  555.  
  556.     def __GetTotalMagAtkText(self):
  557.         minMagAtk=player.GetStatus(player.MAG_ATT)+player.GetStatus(player.MIN_MAGIC_WEP)
  558.         maxMagAtk=player.GetStatus(player.MAG_ATT)+player.GetStatus(player.MAX_MAGIC_WEP)
  559.  
  560.         if minMagAtk==maxMagAtk:
  561.             return "%d" % (minMagAtk)
  562.         else:
  563.             return "%d-%d" % (minMagAtk, maxMagAtk)
  564.  
  565.     def __GetTotalDefText(self):
  566.         defValue=player.GetStatus(player.DEF_GRADE)
  567.         if constInfo.ADD_DEF_BONUS_ENABLE:
  568.             defValue+=player.GetStatus(player.DEF_BONUS)
  569.         return "%d" % (defValue)
  570.    
  571.     def RefreshStatus(self):
  572.         if self.isLoaded==0:
  573.             return
  574.  
  575.         try:
  576.             self.GetChild("Level_Value").SetText(str(player.GetStatus(player.LEVEL)))
  577.             self.GetChild("Exp_Value").SetText(str(unsigned32(player.GetEXP())))
  578.             self.GetChild("RestExp_Value").SetText(str(unsigned32(player.GetStatus(player.NEXT_EXP)) - unsigned32(player.GetStatus(player.EXP))))
  579.             self.GetChild("HP_Value").SetText(str(player.GetStatus(player.HP)) + '/' + str(player.GetStatus(player.MAX_HP)))
  580.             self.GetChild("SP_Value").SetText(str(player.GetStatus(player.SP)) + '/' + str(player.GetStatus(player.MAX_SP)))
  581.  
  582.             self.GetChild("STR_Value").SetText(str(player.GetStatus(player.ST)))
  583.             self.GetChild("DEX_Value").SetText(str(player.GetStatus(player.DX)))
  584.             self.GetChild("HTH_Value").SetText(str(player.GetStatus(player.HT)))
  585.             self.GetChild("INT_Value").SetText(str(player.GetStatus(player.IQ)))
  586.  
  587.             self.GetChild("ATT_Value").SetText(self.__GetTotalAtkText())
  588.             self.GetChild("DEF_Value").SetText(self.__GetTotalDefText())
  589.  
  590.             self.GetChild("MATT_Value").SetText(self.__GetTotalMagAtkText())
  591.             #self.GetChild("MATT_Value").SetText(str(player.GetStatus(player.MAG_ATT)))
  592.  
  593.             self.GetChild("MDEF_Value").SetText(str(player.GetStatus(player.MAG_DEF)))
  594.             self.GetChild("ASPD_Value").SetText(str(player.GetStatus(player.ATT_SPEED)))
  595.             self.GetChild("MSPD_Value").SetText(str(player.GetStatus(player.MOVING_SPEED)))
  596.             self.GetChild("CSPD_Value").SetText(str(player.GetStatus(player.CASTING_SPEED)))
  597.             self.GetChild("ER_Value").SetText(str(player.GetStatus(player.EVADE_RATE)))
  598.  
  599.         except:
  600.             #import exception
  601.             #exception.Abort("CharacterWindow.RefreshStatus.BindObject")
  602.             ## °ÔŔÓŔĚ Ć¨°Ü ąö¸˛
  603.             pass
  604.  
  605.         self.__RefreshStatusPlusButtonList()
  606.         self.__RefreshStatusMinusButtonList()
  607.         self.RefreshAlignment()
  608.  
  609.         if self.refreshToolTip:
  610.             self.refreshToolTip()
  611.  
  612.     def __RefreshStatusPlusButtonList(self):
  613.         if self.isLoaded==0:
  614.             return
  615.  
  616.         statusPlusPoint=player.GetStatus(player.STAT)
  617.  
  618.         if statusPlusPoint>0:
  619.             self.statusPlusValue.SetText(str(statusPlusPoint))
  620.             self.statusPlusLabel.Show()
  621.             self.ShowStatusPlusButtonList()
  622.         else:
  623.             self.statusPlusValue.SetText(str(0))
  624.             self.statusPlusLabel.Hide()
  625.             self.HideStatusPlusButtonList()
  626.  
  627.     def __RefreshStatusMinusButtonList(self):
  628.         if self.isLoaded==0:
  629.             return
  630.  
  631.         statusMinusPoint=self.__GetStatMinusPoint()
  632.  
  633.         if statusMinusPoint>0:
  634.             self.__ShowStatusMinusButtonList()
  635.         else:
  636.             self.__HideStatusMinusButtonList()
  637.  
  638.     def RefreshAlignment(self):
  639.         point, grade = player.GetAlignmentData()
  640.  
  641.         import colorInfo
  642.         COLOR_DICT = {  0 : colorInfo.TITLE_RGB_GOOD_4,
  643.                         1 : colorInfo.TITLE_RGB_GOOD_3,
  644.                         2 : colorInfo.TITLE_RGB_GOOD_2,
  645.                         3 : colorInfo.TITLE_RGB_GOOD_1,
  646.                         4 : colorInfo.TITLE_RGB_NORMAL,
  647.                         5 : colorInfo.TITLE_RGB_EVIL_1,
  648.                         6 : colorInfo.TITLE_RGB_EVIL_2,
  649.                         7 : colorInfo.TITLE_RGB_EVIL_3,
  650.                         8 : colorInfo.TITLE_RGB_EVIL_4, }
  651.         colorList = COLOR_DICT.get(grade, colorInfo.TITLE_RGB_NORMAL)
  652.         gradeColor = ui.GenerateColor(colorList[0], colorList[1], colorList[2])
  653.  
  654.         self.toolTipAlignment.ClearToolTip()
  655.         self.toolTipAlignment.AutoAppendTextLine(localeInfo.TITLE_NAME_LIST[grade], gradeColor)
  656.         self.toolTipAlignment.AutoAppendTextLine(localeInfo.ALIGNMENT_NAME + str(point))
  657.         self.toolTipAlignment.AlignHorizonalCenter()
  658.  
  659.     def __ShowStatusMinusButtonList(self):
  660.         for (stateMinusKey, statusMinusButton) in self.statusMinusButtonDict.items():
  661.             statusMinusButton.Show()
  662.  
  663.     def __HideStatusMinusButtonList(self):
  664.         for (stateMinusKey, statusMinusButton) in self.statusMinusButtonDict.items():
  665.             statusMinusButton.Hide()
  666.  
  667.     def ShowStatusPlusButtonList(self):
  668.         for (statePlusKey, statusPlusButton) in self.statusPlusButtonDict.items():
  669.             statusPlusButton.Show()
  670.  
  671.     def HideStatusPlusButtonList(self):
  672.         for (statePlusKey, statusPlusButton) in self.statusPlusButtonDict.items():
  673.             statusPlusButton.Hide()
  674.  
  675.     def SelectSkill(self, skillSlotIndex):
  676.  
  677.         mouseController = mouseModule.mouseController
  678.  
  679.         if False == mouseController.isAttached():
  680.  
  681.             srcSlotIndex = self.__RealSkillSlotToSourceSlot(skillSlotIndex)
  682.             selectedSkillIndex = player.GetSkillIndex(srcSlotIndex)
  683.  
  684.             if skill.CanUseSkill(selectedSkillIndex):
  685.  
  686.                 if app.IsPressed(app.DIK_LCONTROL):
  687.  
  688.                     player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_SKILL, srcSlotIndex)
  689.                     return
  690.  
  691.                 mouseController.AttachObject(self, player.SLOT_TYPE_SKILL, srcSlotIndex, selectedSkillIndex)
  692.  
  693.         else:
  694.  
  695.             mouseController.DeattachObject()
  696.  
  697.     def SelectEmptySlot(self, SlotIndex):
  698.         mouseModule.mouseController.DeattachObject()
  699.  
  700.     ## ToolTip
  701.     def OverInItem(self, slotNumber):
  702.  
  703.         if mouseModule.mouseController.isAttached():
  704.             return
  705.  
  706.         if 0 == self.toolTipSkill:
  707.             return
  708.  
  709.         srcSlotIndex = self.__RealSkillSlotToSourceSlot(slotNumber)
  710.         skillIndex = player.GetSkillIndex(srcSlotIndex)
  711.         skillLevel = player.GetSkillLevel(srcSlotIndex)
  712.         skillGrade = player.GetSkillGrade(srcSlotIndex)
  713.         skillType = skill.GetSkillType(skillIndex)
  714.  
  715.         ## ACTIVE
  716.         if skill.SKILL_TYPE_ACTIVE == skillType:
  717.             overInSkillGrade = self.__GetSkillGradeFromSlot(slotNumber)
  718.  
  719.             if overInSkillGrade == skill.SKILL_GRADE_COUNT-1 and skillGrade == skill.SKILL_GRADE_COUNT:
  720.                 self.toolTipSkill.SetSkillNew(srcSlotIndex, skillIndex, skillGrade, skillLevel)
  721.             elif overInSkillGrade == skillGrade:
  722.                 self.toolTipSkill.SetSkillNew(srcSlotIndex, skillIndex, overInSkillGrade, skillLevel)
  723.             else:
  724.                 self.toolTipSkill.SetSkillOnlyName(srcSlotIndex, skillIndex, overInSkillGrade)
  725.  
  726.         else:
  727.             self.toolTipSkill.SetSkillNew(srcSlotIndex, skillIndex, skillGrade, skillLevel)
  728.  
  729.     def OverOutItem(self):
  730.         if 0 != self.toolTipSkill:
  731.             self.toolTipSkill.HideToolTip()
  732.  
  733.     ## Quest
  734.     def __SelectQuest(self, slotIndex):
  735.         questIndex = quest.GetQuestIndex(self.questShowingStartIndex+slotIndex)
  736.  
  737.         import event
  738.         event.QuestButtonClick(-2147483648 + questIndex)
  739.  
  740.     def RefreshQuest(self):
  741.  
  742.         if self.isLoaded==0:
  743.             return
  744.  
  745.         questCount = quest.GetQuestCount()
  746.         questRange = range(quest.QUEST_MAX_NUM)
  747.  
  748.         if questCount > quest.QUEST_MAX_NUM:
  749.             self.questScrollBar.Show()
  750.         else:
  751.             self.questScrollBar.Hide()
  752.  
  753.         for i in questRange[:questCount]:
  754.             (questName, questIcon, questCounterName, questCounterValue) = quest.GetQuestData(self.questShowingStartIndex+i)
  755.  
  756.             self.questNameList[i].SetText(questName)
  757.             self.questNameList[i].Show()
  758.             self.questLastCountList[i].Show()
  759.             self.questLastTimeList[i].Show()
  760.  
  761.             if len(questCounterName) > 0:
  762.                 self.questLastCountList[i].SetText("%s : %d" % (questCounterName, questCounterValue))
  763.             else:
  764.                 self.questLastCountList[i].SetText("")
  765.  
  766.             ## Icon
  767.             self.questSlot.SetSlot(i, i, 1, 1, questIcon)
  768.  
  769.         for i in questRange[questCount:]:
  770.             self.questNameList[i].Hide()
  771.             self.questLastTimeList[i].Hide()
  772.             self.questLastCountList[i].Hide()
  773.             self.questSlot.ClearSlot(i)
  774.             self.questSlot.HideSlotBaseImage(i)
  775.  
  776.         self.__UpdateQuestClock()
  777.  
  778.     def __UpdateQuestClock(self):
  779.         if "QUEST" == self.state:
  780.             # QUEST_LIMIT_COUNT_BUG_FIX
  781.             for i in xrange(min(quest.GetQuestCount(), quest.QUEST_MAX_NUM)):
  782.             # END_OF_QUEST_LIMIT_COUNT_BUG_FIX
  783.                 (lastName, lastTime) = quest.GetQuestLastTime(i)
  784.  
  785.                 clockText = localeInfo.QUEST_UNLIMITED_TIME
  786.                 if len(lastName) > 0:
  787.  
  788.                     if lastTime <= 0:
  789.                         clockText = localeInfo.QUEST_TIMEOVER
  790.  
  791.                     else:
  792.                         questLastMinute = lastTime / 60
  793.                         questLastSecond = lastTime % 60
  794.  
  795.                         clockText = lastName + " : "
  796.  
  797.                         if questLastMinute > 0:
  798.                             clockText += str(questLastMinute) + localeInfo.QUEST_MIN
  799.                             if questLastSecond > 0:
  800.                                 clockText += " "
  801.  
  802.                         if questLastSecond > 0:
  803.                             clockText += str(questLastSecond) + localeInfo.QUEST_SEC
  804.  
  805.                 self.questLastTimeList[i].SetText(clockText)
  806.  
  807.     def __GetStatMinusPoint(self):
  808.         POINT_STAT_RESET_COUNT = 112
  809.         return player.GetStatus(POINT_STAT_RESET_COUNT)
  810.  
  811.     def __OverInStatMinusButton(self, stat):
  812.         try:
  813.             self.__ShowStatToolTip(self.STAT_MINUS_DESCRIPTION[stat] % self.__GetStatMinusPoint())
  814.         except KeyError:
  815.             pass
  816.  
  817.         self.refreshToolTip = lambda arg=stat: self.__OverInStatMinusButton(arg)
  818.  
  819.     def __OverOutStatMinusButton(self):
  820.         self.__HideStatToolTip()
  821.         self.refreshToolTip = 0
  822.  
  823.     def __OverInStatButton(self, stat):
  824.         try:
  825.             self.__ShowStatToolTip(self.STAT_DESCRIPTION[stat], localeInfo.EMOJI_CHARACTER_STATS_ADD, True)
  826.         except KeyError:
  827.             pass
  828.  
  829.     def __OverOutStatButton(self):
  830.         self.__HideStatToolTip()
  831.  
  832.     def __ShowStatToolTip(self, statDesc, statDesc2 = False, arg2 = False):
  833.         self.toolTip.ClearToolTip()
  834.         self.toolTip.AppendTextLine(statDesc)
  835.        
  836.         if arg2 == True:
  837.             self.toolTip.AppendTextLine(statDesc2)
  838.            
  839.         self.toolTip.Show()
  840.  
  841.     def __HideStatToolTip(self):
  842.         self.toolTip.Hide()
  843.  
  844.     def OnPressEscapeKey(self):
  845.         self.Close()
  846.         return True
  847.  
  848.     def OnUpdate(self):
  849.         self.__UpdateQuestClock()
  850.         if app.ENABLE_SKILL_COLOR_SYSTEM:
  851.             if self.skillColorWnd:
  852.                 self.__UpdateSkillColorPosition()
  853.  
  854.     ## Skill Process
  855.     def __RefreshSkillPage(self, name, slotCount):
  856.         global SHOW_LIMIT_SUPPORT_SKILL_LIST
  857.  
  858.         skillPage = self.skillPageDict[name]
  859.  
  860.         startSlotIndex = skillPage.GetStartIndex()
  861.         if "ACTIVE" == name:
  862.             if self.PAGE_HORSE == self.curSelectedSkillGroup:
  863.                 startSlotIndex += slotCount
  864.  
  865.         getSkillType=skill.GetSkillType
  866.         getSkillIndex=player.GetSkillIndex
  867.         getSkillGrade=player.GetSkillGrade
  868.         getSkillLevel=player.GetSkillLevel
  869.         getSkillLevelUpPoint=skill.GetSkillLevelUpPoint
  870.         getSkillMaxLevel=skill.GetSkillMaxLevel
  871.         for i in xrange(slotCount+1):
  872.  
  873.             slotIndex = i + startSlotIndex
  874.             skillIndex = getSkillIndex(slotIndex)
  875.  
  876.             for j in xrange(skill.SKILL_GRADE_COUNT):
  877.                 skillPage.ClearSlot(self.__GetRealSkillSlot(j, i))
  878.  
  879.             if 0 == skillIndex:
  880.                 continue
  881.  
  882.             skillGrade = getSkillGrade(slotIndex)
  883.             skillLevel = getSkillLevel(slotIndex)
  884.             skillType = getSkillType(skillIndex)
  885.  
  886.             ## ˝Â¸¶ ˝şĹł żążÜ Ăł¸®
  887.             if player.SKILL_INDEX_RIDING == skillIndex:
  888.                 if 1 == skillGrade:
  889.                     skillLevel += 19
  890.                 elif 2 == skillGrade:
  891.                     skillLevel += 29
  892.                 elif 3 == skillGrade:
  893.                     skillLevel = 40
  894.  
  895.                 skillPage.SetSkillSlotNew(slotIndex, skillIndex, max(skillLevel-1, 0), skillLevel)
  896.                 skillPage.SetSlotCount(slotIndex, skillLevel)
  897.  
  898.             ## ACTIVE
  899.             elif skill.SKILL_TYPE_ACTIVE == skillType:
  900.                 for j in xrange(skill.SKILL_GRADE_COUNT):
  901.                     realSlotIndex = self.__GetRealSkillSlot(j, slotIndex)
  902.                     skillPage.SetSkillSlotNew(realSlotIndex, skillIndex, j, skillLevel)
  903.                     skillPage.SetCoverButton(realSlotIndex)
  904.  
  905.                     if (skillGrade == skill.SKILL_GRADE_COUNT) and j == (skill.SKILL_GRADE_COUNT-1):
  906.                         skillPage.SetSlotCountNew(realSlotIndex, skillGrade, skillLevel)
  907.                     elif (not self.__CanUseSkillNow()) or (skillGrade != j):
  908.                         skillPage.SetSlotCount(realSlotIndex, 0)
  909.                         skillPage.DisableCoverButton(realSlotIndex)
  910.                     else:
  911.                         skillPage.SetSlotCountNew(realSlotIndex, skillGrade, skillLevel)
  912.  
  913.             ## ±×żÜ
  914.             else:
  915.                 if not SHOW_LIMIT_SUPPORT_SKILL_LIST or skillIndex in SHOW_LIMIT_SUPPORT_SKILL_LIST:
  916.                     realSlotIndex = self.__GetETCSkillRealSlotIndex(slotIndex)
  917.                     skillPage.SetSkillSlot(realSlotIndex, skillIndex, skillLevel)
  918.                     skillPage.SetSlotCountNew(realSlotIndex, skillGrade, skillLevel)
  919.  
  920.                     if skill.CanUseSkill(skillIndex):
  921.                         skillPage.SetCoverButton(realSlotIndex)
  922.  
  923.             skillPage.RefreshSlot()
  924.  
  925.         if app.ENABLE_SKILL_COLOR_SYSTEM:
  926.             if "ACTIVE" == name:
  927.                 if self.PAGE_HORSE != self.curSelectedSkillGroup:
  928.                     self.__CreateSkillColorButton(skillPage)
  929.                 else:
  930.                     self.skillColorButton = []
  931.  
  932.  
  933.     def RefreshSkill(self):
  934.  
  935.         if self.isLoaded==0:
  936.             return
  937.  
  938.         if self.__IsChangedHorseRidingSkillLevel():
  939.             self.RefreshCharacter()
  940.             return
  941.  
  942.  
  943.         global SHOW_ONLY_ACTIVE_SKILL
  944.         if SHOW_ONLY_ACTIVE_SKILL:
  945.             self.__RefreshSkillPage("ACTIVE", self.ACTIVE_PAGE_SLOT_COUNT)
  946.         else:
  947.             self.__RefreshSkillPage("ACTIVE", self.ACTIVE_PAGE_SLOT_COUNT)
  948.             self.__RefreshSkillPage("SUPPORT", self.SUPPORT_PAGE_SLOT_COUNT)
  949.  
  950.         self.RefreshSkillPlusButtonList()
  951.  
  952.     def CanShowPlusButton(self, skillIndex, skillLevel, curStatPoint):
  953.  
  954.         ## ˝şĹłŔĚ ŔÖŔ¸¸é
  955.         if 0 == skillIndex:
  956.             return False
  957.  
  958.         ## ·ąş§ľ÷ Á¶°ÇŔ» ¸¸Á·ÇѴٸé
  959.         if not skill.CanLevelUpSkill(skillIndex, skillLevel):
  960.             return False
  961.  
  962.         return True
  963.  
  964.     def __RefreshSkillPlusButton(self, name):
  965.         global HIDE_SUPPORT_SKILL_POINT
  966.         if HIDE_SUPPORT_SKILL_POINT and "SUPPORT" == name:
  967.             return
  968.  
  969.         slotWindow = self.skillPageDict[name]
  970.         slotWindow.HideAllSlotButton()
  971.  
  972.         slotStatType = self.skillPageStatDict[name]
  973.         if 0 == slotStatType:
  974.             return
  975.  
  976.         statPoint = player.GetStatus(slotStatType)
  977.         startSlotIndex = slotWindow.GetStartIndex()
  978.         if "HORSE" == name:
  979.             startSlotIndex += self.ACTIVE_PAGE_SLOT_COUNT
  980.  
  981.         if statPoint > 0:
  982.             for i in xrange(self.PAGE_SLOT_COUNT):
  983.                 slotIndex = i + startSlotIndex
  984.                 skillIndex = player.GetSkillIndex(slotIndex)
  985.                 skillGrade = player.GetSkillGrade(slotIndex)
  986.                 skillLevel = player.GetSkillLevel(slotIndex)
  987.  
  988.                 if skillIndex == 0:
  989.                     continue
  990.                 if skillGrade != 0:
  991.                     continue
  992.  
  993.                 if name == "HORSE":
  994.                     if player.GetStatus(player.LEVEL) >= skill.GetSkillLevelLimit(skillIndex):
  995.                         if skillLevel < 20:
  996.                             slotWindow.ShowSlotButton(self.__GetETCSkillRealSlotIndex(slotIndex))
  997.  
  998.                 else:
  999.                     if "SUPPORT" == name:                      
  1000.                         if not SHOW_LIMIT_SUPPORT_SKILL_LIST or skillIndex in SHOW_LIMIT_SUPPORT_SKILL_LIST:
  1001.                             if self.CanShowPlusButton(skillIndex, skillLevel, statPoint):
  1002.                                 slotWindow.ShowSlotButton(slotIndex)
  1003.                     else:
  1004.                         if self.CanShowPlusButton(skillIndex, skillLevel, statPoint):
  1005.                             slotWindow.ShowSlotButton(slotIndex)
  1006.                    
  1007.  
  1008.     if app.ENABLE_SKILL_COLOR_SYSTEM:
  1009.         def __CreateSkillColorButton(self, parent):
  1010.             self.skillColorButton = []
  1011.  
  1012.             xPos, yPos = 0, 0
  1013.             for idx in xrange(self.PAGE_SLOT_COUNT):
  1014.                 skillSlot = idx
  1015.                 if skillSlot < 6:
  1016.                     if (skillSlot % 2) == 0:
  1017.                         xPos = 75
  1018.                         yPos = 4 + (skillSlot / 2 * 36)
  1019.                     else:
  1020.                         xPos = 187
  1021.                         yPos = 4 + (skillSlot / 2 * 36)
  1022.  
  1023.                     skillIndex = player.GetSkillIndex(skillSlot + 1)
  1024.                     skillMaxGrade = 3
  1025.  
  1026.                     if len(self.skillColorButton) == skillSlot:
  1027.                         self.skillColorButton.append([])
  1028.                         self.skillColorButton[skillSlot] = ui.Button()
  1029.                         self.skillColorButton[skillSlot].SetParent(parent)
  1030.                         #self.skillColorButton[skillSlot].SetUpVisual("d:/ymir work/ui/skillcolor/skill_color_button_default.tga")
  1031.                         #self.skillColorButton[skillSlot].SetOverVisual("d:/ymir work/ui/skillcolor/skill_color_button_over.tga")
  1032.                         #self.skillColorButton[skillSlot].SetDownVisual("d:/ymir work/ui/skillcolor/skill_color_button_down.tga")
  1033.                         self.skillColorButton[skillSlot].SetPosition(xPos, yPos)
  1034.                         self.skillColorButton[skillSlot].SetEvent(lambda arg = skillSlot, arg2 = skillIndex: self.__OnPressSkillColorButton(arg, arg2))
  1035.                         if player.GetSkillGrade(skillSlot + 1) >= skillMaxGrade:
  1036.                             self.skillColorButton[skillSlot].Show()
  1037.                         else:
  1038.                             self.skillColorButton[skillSlot].Hide()
  1039.                     else:
  1040.                         self.skillColorButton[skillSlot].SetPosition(xPos, yPos)
  1041.  
  1042.         def __UpdateSkillColorPosition(self):
  1043.             x, y = self.GetGlobalPosition()
  1044.             self.skillColorWnd.SetPosition(x + 250, y)
  1045.  
  1046.         def __OnPressSkillColorButton(self, skillSlot, skillIndex):
  1047.             self.skillColorWnd = uiSkillColor.SkillColorWindow(skillSlot, skillIndex)
  1048.             if self.skillColorWnd and not self.skillColorWnd.IsShow():
  1049.                 self.skillColorWnd.Show()
  1050.  
  1051.     def RefreshSkillPlusButtonList(self):
  1052.  
  1053.         if self.isLoaded==0:
  1054.             return
  1055.  
  1056.         self.RefreshSkillPlusPointLabel()
  1057.  
  1058.         if not self.__CanUseSkillNow():
  1059.             return
  1060.  
  1061.         try:
  1062.             if self.PAGE_HORSE == self.curSelectedSkillGroup:
  1063.                 self.__RefreshSkillPlusButton("HORSE")
  1064.             else:
  1065.                 self.__RefreshSkillPlusButton("ACTIVE")
  1066.  
  1067.             self.__RefreshSkillPlusButton("SUPPORT")
  1068.  
  1069.         except:
  1070.             import exception
  1071.             exception.Abort("CharacterWindow.RefreshSkillPlusButtonList.BindObject")
  1072.  
  1073.     def RefreshSkillPlusPointLabel(self):
  1074.         if self.isLoaded==0:
  1075.             return
  1076.  
  1077.         if self.PAGE_HORSE == self.curSelectedSkillGroup:
  1078.             activeStatPoint = player.GetStatus(player.SKILL_HORSE)
  1079.             self.activeSkillPointValue.SetText(str(activeStatPoint))
  1080.  
  1081.         else:
  1082.             activeStatPoint = player.GetStatus(player.SKILL_ACTIVE)
  1083.             self.activeSkillPointValue.SetText(str(activeStatPoint))
  1084.  
  1085.         supportStatPoint = max(0, player.GetStatus(player.SKILL_SUPPORT))
  1086.         self.supportSkillPointValue.SetText(str(supportStatPoint))
  1087.  
  1088.     ## Skill Level Up Button
  1089.     def OnPressedSlotButton(self, slotNumber):
  1090.         srcSlotIndex = self.__RealSkillSlotToSourceSlot(slotNumber)
  1091.  
  1092.         skillIndex = player.GetSkillIndex(srcSlotIndex)
  1093.         curLevel = player.GetSkillLevel(srcSlotIndex)
  1094.         maxLevel = skill.GetSkillMaxLevel(skillIndex)
  1095.  
  1096.         net.SendChatPacket("/skillup " + str(skillIndex))
  1097.  
  1098.     ## Use Skill
  1099.     def ClickSkillSlot(self, slotIndex):
  1100.  
  1101.         srcSlotIndex = self.__RealSkillSlotToSourceSlot(slotIndex)
  1102.         skillIndex = player.GetSkillIndex(srcSlotIndex)
  1103.         skillType = skill.GetSkillType(skillIndex)
  1104.  
  1105.         if not self.__CanUseSkillNow():
  1106.             if skill.SKILL_TYPE_ACTIVE == skillType:
  1107.                 return
  1108.  
  1109.         for slotWindow in self.skillPageDict.values():
  1110.             if slotWindow.HasSlot(slotIndex):
  1111.                 if skill.CanUseSkill(skillIndex):
  1112.                     player.ClickSkillSlot(srcSlotIndex)
  1113.                     return
  1114.  
  1115.         mouseModule.mouseController.DeattachObject()
  1116.  
  1117.     ## FIXME : ˝şĹłŔ» »çżëÇßŔ»¶§ ˝˝·Ô ąřČŁ¸¦ °ˇÁö°í ÇŘ´ç ˝˝·ÔŔ» ĂŁľĆĽ­ ľ÷µĄŔĚĆ® ÇŃ´Ů.
  1118.     ##         ¸Ĺżě şŇÇŐ¸®. ±¸Á¶ ŔÚĂĽ¸¦ °łĽ±ÇŘľß Çҵí.
  1119.     def OnUseSkill(self, slotIndex, coolTime):
  1120.  
  1121.         skillIndex = player.GetSkillIndex(slotIndex)
  1122.         skillType = skill.GetSkillType(skillIndex)
  1123.  
  1124.         ## ACTIVE
  1125.         if skill.SKILL_TYPE_ACTIVE == skillType:
  1126.             skillGrade = player.GetSkillGrade(slotIndex)
  1127.             slotIndex = self.__GetRealSkillSlot(skillGrade, slotIndex)
  1128.         ## ETC
  1129.         else:
  1130.             slotIndex = self.__GetETCSkillRealSlotIndex(slotIndex)
  1131.  
  1132.         for slotWindow in self.skillPageDict.values():
  1133.             if slotWindow.HasSlot(slotIndex):
  1134.                 slotWindow.SetSlotCoolTime(slotIndex, coolTime)
  1135.                 return
  1136.  
  1137.     def OnActivateSkill(self, slotIndex):
  1138.         skillGrade = player.GetSkillGrade(slotIndex)
  1139.         slotIndex = self.__GetRealSkillSlot(skillGrade, slotIndex)
  1140.         for slotWindow in self.skillPageDict.values():
  1141.             if slotWindow.HasSlot(slotIndex):
  1142.                 if app.ENABLE_SASH_SYSTEM:
  1143.                     slotWindow.ActivateSlotOld(slotIndex)
  1144.                 else:
  1145.                     slotWindow.ActivateSlot(slotIndex)
  1146.                
  1147.                 return
  1148.  
  1149.     def OnDeactivateSkill(self, slotIndex):
  1150.         skillGrade = player.GetSkillGrade(slotIndex)
  1151.         slotIndex = self.__GetRealSkillSlot(skillGrade, slotIndex)
  1152.         for slotWindow in self.skillPageDict.values():
  1153.             if slotWindow.HasSlot(slotIndex):
  1154.                 if app.ENABLE_SASH_SYSTEM:
  1155.                     slotWindow.DeactivateSlotOld(slotIndex)
  1156.                 else:
  1157.                     slotWindow.DeactivateSlot(slotIndex)
  1158.                
  1159.                 return
  1160.  
  1161.     def __ShowJobToolTip(self):
  1162.         self.toolTipJob.ShowToolTip()
  1163.  
  1164.     def __HideJobToolTip(self):
  1165.         self.toolTipJob.HideToolTip()
  1166.  
  1167.     def __SetJobText(self, mainJob, subJob):
  1168.         if player.GetStatus(player.LEVEL)<5:
  1169.             subJob=0
  1170.  
  1171.         if 949 == app.GetDefaultCodePage():
  1172.             self.toolTipJob.ClearToolTip()
  1173.  
  1174.             try:
  1175.                 jobInfoTitle=localeInfo.JOBINFO_TITLE[mainJob][subJob]
  1176.                 jobInfoData=localeInfo.JOBINFO_DATA_LIST[mainJob][subJob]
  1177.             except IndexError:
  1178.                 print "uiCharacter.CharacterWindow.__SetJobText(mainJob=%d, subJob=%d)" % (mainJob, subJob)
  1179.                 return
  1180.  
  1181.             self.toolTipJob.AutoAppendTextLine(jobInfoTitle)
  1182.             self.toolTipJob.AppendSpace(5)
  1183.  
  1184.             for jobInfoDataLine in jobInfoData:
  1185.                 self.toolTipJob.AutoAppendTextLine(jobInfoDataLine)
  1186.  
  1187.             self.toolTipJob.AlignHorizonalCenter()
  1188.  
  1189.     def __ShowAlignmentToolTip(self):
  1190.         self.toolTipAlignment.ShowToolTip()
  1191.  
  1192.     def __HideAlignmentToolTip(self):
  1193.         self.toolTipAlignment.HideToolTip()
  1194.  
  1195.     def RefreshCharacter(self):
  1196.  
  1197.         if self.isLoaded==0:
  1198.             return
  1199.  
  1200.         ## Name
  1201.         try:
  1202.             characterName = player.GetName()
  1203.             guildName = player.GetGuildName()
  1204.             self.characterNameValue.SetText(characterName)
  1205.             self.guildNameValue.SetText(guildName)
  1206.             if not guildName:
  1207.                 if localeInfo.IsARABIC():
  1208.                     self.characterNameSlot.SetPosition(190, 34)
  1209.                 else:
  1210.                     self.characterNameSlot.SetPosition(109, 34)
  1211.  
  1212.                 self.guildNameSlot.Hide()
  1213.             else:
  1214.                 if localeInfo.IsJAPAN():
  1215.                     self.characterNameSlot.SetPosition(143, 34)
  1216.                 else:
  1217.                     self.characterNameSlot.SetPosition(153, 34)
  1218.                 self.guildNameSlot.Show()
  1219.         except:
  1220.             import exception
  1221.             exception.Abort("CharacterWindow.RefreshCharacter.BindObject")
  1222.  
  1223.         race = net.GetMainActorRace()
  1224.         group = net.GetMainActorSkillGroup()
  1225.         empire = net.GetMainActorEmpire()
  1226.  
  1227.         ## Job Text
  1228.         job = chr.RaceToJob(race)
  1229.         self.__SetJobText(job, group)
  1230.  
  1231.         ## FaceImage
  1232.         try:
  1233.             faceImageName = FACE_IMAGE_DICT[race]
  1234.  
  1235.             try:
  1236.                 self.faceImage.LoadImage(faceImageName)
  1237.             except:
  1238.                 print "CharacterWindow.RefreshCharacter(race=%d, faceImageName=%s)" % (race, faceImageName)
  1239.                 self.faceImage.Hide()
  1240.  
  1241.         except KeyError:
  1242.             self.faceImage.Hide()
  1243.  
  1244.         ## GroupName
  1245.         self.__SetSkillGroupName(race, group)
  1246.  
  1247.         ## Skill
  1248.         if 0 == group:
  1249.             self.__SelectSkillGroup(0)
  1250.  
  1251.         else:
  1252.             self.__SetSkillSlotData(race, group, empire)
  1253.  
  1254.             if self.__CanUseHorseSkill():
  1255.                 self.__SelectSkillGroup(0)
  1256.  
  1257.     def __SetSkillGroupName(self, race, group):
  1258.  
  1259.         job = chr.RaceToJob(race)
  1260.  
  1261.         if not self.SKILL_GROUP_NAME_DICT.has_key(job):
  1262.             return
  1263.  
  1264.         nameList = self.SKILL_GROUP_NAME_DICT[job]
  1265.  
  1266.         if 0 == group:
  1267.             self.skillGroupButton1.SetText(nameList[1])
  1268.             self.skillGroupButton2.SetText(nameList[2])
  1269.             self.skillGroupButton1.Show()
  1270.             self.skillGroupButton2.Show()
  1271.             self.activeSkillGroupName.Hide()
  1272.  
  1273.         else:
  1274.  
  1275.             if self.__CanUseHorseSkill():
  1276.                 self.activeSkillGroupName.Hide()
  1277.                 self.skillGroupButton1.SetText(nameList.get(group, "Noname"))
  1278.                 self.skillGroupButton2.SetText(localeInfo.SKILL_GROUP_HORSE)
  1279.                 self.skillGroupButton1.Show()
  1280.                 self.skillGroupButton2.Show()
  1281.  
  1282.             else:
  1283.                 self.activeSkillGroupName.SetText(nameList.get(group, "Noname"))
  1284.                 self.activeSkillGroupName.Show()
  1285.                 self.skillGroupButton1.Hide()
  1286.                 self.skillGroupButton2.Hide()
  1287.  
  1288.     def __SetSkillSlotData(self, race, group, empire=0):
  1289.  
  1290.         ## SkillIndex
  1291.         playerSettingModule.RegisterSkill(race, group, empire)
  1292.  
  1293.         ## Event
  1294.         self.__SetSkillSlotEvent()
  1295.  
  1296.         ## Refresh
  1297.         self.RefreshSkill()
  1298.  
  1299.     def __SelectSkillGroup(self, index):
  1300.         for btn in self.skillGroupButton:
  1301.             btn.SetUp()
  1302.         self.skillGroupButton[index].Down()
  1303.  
  1304.         if self.__CanUseHorseSkill():
  1305.             if 0 == index:
  1306.                 index = net.GetMainActorSkillGroup()-1
  1307.             elif 1 == index:
  1308.                 index = self.PAGE_HORSE
  1309.  
  1310.         self.curSelectedSkillGroup = index
  1311.         self.__SetSkillSlotData(net.GetMainActorRace(), index+1, net.GetMainActorEmpire())
  1312.  
  1313.     def __CanUseSkillNow(self):
  1314.         if 0 == net.GetMainActorSkillGroup():
  1315.             return False
  1316.  
  1317.         return True
  1318.  
  1319.     def __CanUseHorseSkill(self):
  1320.  
  1321.         slotIndex = player.GetSkillSlotIndex(player.SKILL_INDEX_RIDING)
  1322.  
  1323.         if not slotIndex:
  1324.             return False
  1325.  
  1326.         grade = player.GetSkillGrade(slotIndex)
  1327.         level = player.GetSkillLevel(slotIndex)
  1328.         if level < 0:
  1329.             level *= -1
  1330.         if grade >= 1 and level >= 1:
  1331.             return True
  1332.  
  1333.         return False
  1334.  
  1335.     def __IsChangedHorseRidingSkillLevel(self):
  1336.         ret = False
  1337.  
  1338.         if -1 == self.canUseHorseSkill:
  1339.             self.canUseHorseSkill = self.__CanUseHorseSkill()
  1340.  
  1341.         if self.canUseHorseSkill != self.__CanUseHorseSkill():
  1342.             ret = True
  1343.  
  1344.         self.canUseHorseSkill = self.__CanUseHorseSkill()
  1345.         return ret
  1346.  
  1347.     def __GetRealSkillSlot(self, skillGrade, skillSlot):
  1348.         return skillSlot + min(skill.SKILL_GRADE_COUNT-1, skillGrade)*skill.SKILL_GRADE_STEP_COUNT
  1349.  
  1350.     def __GetETCSkillRealSlotIndex(self, skillSlot):
  1351.         if skillSlot > 100:
  1352.             return skillSlot
  1353.         return skillSlot % self.ACTIVE_PAGE_SLOT_COUNT
  1354.  
  1355.     def __RealSkillSlotToSourceSlot(self, realSkillSlot):
  1356.         if realSkillSlot > 100:
  1357.             return realSkillSlot
  1358.         if self.PAGE_HORSE == self.curSelectedSkillGroup:
  1359.             return realSkillSlot + self.ACTIVE_PAGE_SLOT_COUNT
  1360.         return realSkillSlot % skill.SKILL_GRADE_STEP_COUNT
  1361.  
  1362.     def __GetSkillGradeFromSlot(self, skillSlot):
  1363.         return int(skillSlot / skill.SKILL_GRADE_STEP_COUNT)
  1364.  
  1365.     def SelectSkillGroup(self, index):
  1366.         self.__SelectSkillGroup(index)
  1367.  
  1368.     def OnQuestScroll(self):
  1369.         questCount = quest.GetQuestCount()
  1370.         scrollLineCount = max(0, questCount - quest.QUEST_MAX_NUM)
  1371.         startIndex = int(scrollLineCount * self.questScrollBar.GetPos())
  1372.  
  1373.         if startIndex != self.questShowingStartIndex:
  1374.             self.questShowingStartIndex = startIndex
  1375.             self.RefreshQuest()
  1376.  
Advertisement
Add Comment
Please, Sign In to add comment