Guest User

Untitled

a guest
Mar 2nd, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 59.25 KB | None | 0 0
  1. import os
  2. import app
  3. import dbg
  4. import grp
  5. import item
  6. import background
  7. import chr
  8. import chrmgr
  9. import player
  10. import snd
  11. import chat
  12. import textTail
  13. import snd
  14. import net
  15. import effect
  16. import wndMgr
  17. import fly
  18. import systemSetting
  19. import quest
  20. import guild
  21. import skill
  22. import messenger
  23. import localeInfo
  24. import constInfo
  25. import exchange
  26. import ime
  27.  
  28. import ui
  29. import uiCommon
  30. import uiPhaseCurtain
  31. import uiMapNameShower
  32. import uiAffectShower
  33. import uiPlayerGauge
  34. import uiCharacter
  35. import uiTarget
  36. import uiPrivateShopBuilder
  37.  
  38. import mouseModule
  39. import playerSettingModule
  40. import interfaceModule
  41.  
  42. import musicInfo
  43. import debugInfo
  44. import stringCommander
  45. from _weakref import proxy
  46.  
  47. SCREENSHOT_CWDSAVE = True
  48. SCREENSHOT_DIR = None
  49.  
  50. cameraDistance = 1550.0
  51. cameraPitch = 27.0
  52. cameraRotation = 0.0
  53. cameraHeight = 100.0
  54.  
  55. class GameWindow(ui.ScriptWindow):
  56.     def __init__(self, stream):
  57.         ui.ScriptWindow.__init__(self, "GAME")
  58.         self.SetWindowName("game")
  59.         net.SetPhaseWindow(net.PHASE_WINDOW_GAME, self)
  60.         player.SetGameWindow(self)
  61.  
  62.         self.quickSlotPageIndex = 0
  63.         self.lastPKModeSendedTime = 0
  64.         self.pressNumber = None
  65.  
  66.         self.guildWarQuestionDialog = None
  67.         self.interface = None
  68.         self.targetBoard = None
  69.         self.mapNameShower = None
  70.         self.affectShower = None
  71.         self.playerGauge = None
  72.  
  73.         self.stream=stream
  74.         self.interface = interfaceModule.Interface()
  75.         self.interface.MakeInterface()
  76.         self.interface.ShowDefaultWindows()
  77.  
  78.         self.curtain = uiPhaseCurtain.PhaseCurtain()
  79.         self.curtain.speed = 0.03
  80.         self.curtain.Hide()
  81.  
  82.         self.targetBoard = uiTarget.TargetBoard()
  83.         self.targetBoard.SetWhisperEvent(ui.__mem_func__(self.interface.OpenWhisperDialog))
  84.         self.targetBoard.Hide()
  85.  
  86.         self.mapNameShower = uiMapNameShower.MapNameShower()
  87.         self.affectShower = uiAffectShower.AffectShower()
  88.  
  89.         self.playerGauge = uiPlayerGauge.PlayerGauge(self)
  90.         self.playerGauge.Hide()
  91.  
  92.         self.__SetQuickSlotMode()
  93.  
  94.         self.__ServerCommand_Build()
  95.         self.__ProcessPreservedServerCommand()
  96.  
  97.     def __del__(self):
  98.         player.SetGameWindow(0)
  99.         net.ClearPhaseWindow(net.PHASE_WINDOW_GAME, self)
  100.         ui.ScriptWindow.__del__(self)
  101.  
  102.     def Open(self):
  103.         app.SetFrameSkip(1)
  104.  
  105.         self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
  106.  
  107.         self.quickSlotPageIndex = 0
  108.         self.PickingCharacterIndex = -1
  109.         self.PickingItemIndex = -1
  110.         self.isShowDebugInfo = False
  111.         self.ShowNameFlag = False
  112.  
  113.         self.enableXMasBoom = False
  114.         self.startTimeXMasBoom = 0.0
  115.         self.indexXMasBoom = 0
  116.  
  117.         global cameraDistance, cameraPitch, cameraRotation, cameraHeight
  118.  
  119.         app.SetCamera(cameraDistance, cameraPitch, cameraRotation, cameraHeight)
  120.  
  121.         constInfo.SET_DEFAULT_CAMERA_MAX_DISTANCE()
  122.         constInfo.SET_DEFAULT_CHRNAME_COLOR()
  123.         constInfo.SET_DEFAULT_FOG_LEVEL()
  124.         constInfo.SET_DEFAULT_CONVERT_EMPIRE_LANGUAGE_ENABLE()
  125.         constInfo.SET_DEFAULT_USE_ITEM_WEAPON_TABLE_ATTACK_BONUS()
  126.         constInfo.SET_DEFAULT_USE_SKILL_EFFECT_ENABLE()
  127.         constInfo.SET_TWO_HANDED_WEAPON_ATT_SPEED_DECREASE_VALUE()
  128.  
  129.         import event
  130.         event.SetLeftTimeString(localeInfo.UI_LEFT_TIME)
  131.  
  132.         textTail.EnablePKTitle(constInfo.PVPMODE_ENABLE)
  133.  
  134.         self.__BuildKeyDict()
  135.         self.__BuildDebugInfo()
  136.         uiPrivateShopBuilder.Clear()
  137.         exchange.InitTrading()
  138.  
  139.         if debugInfo.IsDebugMode():
  140.             self.ToggleDebugInfo()
  141.  
  142.         snd.SetMusicVolume(systemSetting.GetMusicVolume()*net.GetFieldMusicVolume())
  143.         snd.SetSoundVolume(systemSetting.GetSoundVolume())
  144.  
  145.         netFieldMusicFileName = net.GetFieldMusicFileName()
  146.         if netFieldMusicFileName:
  147.             snd.FadeInMusic("BGM/" + netFieldMusicFileName)
  148.         elif musicInfo.fieldMusic != "":                       
  149.             snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  150.  
  151.         self.__SetQuickSlotMode()
  152.         self.__SelectQuickPage(self.quickSlotPageIndex)
  153.  
  154.         self.SetFocus()
  155.         self.Show()
  156.         app.ShowCursor()
  157.  
  158.         net.SendEnterGamePacket()
  159.         try:
  160.             self.StartGame()
  161.         except:
  162.             import exception
  163.             exception.Abort("GameWindow.Open")
  164.        
  165.         self.cubeInformation = {}
  166.         self.currentCubeNPC = 0
  167.        
  168.     def Close(self):
  169.         self.Hide()
  170.  
  171.         global cameraDistance, cameraPitch, cameraRotation, cameraHeight
  172.         (cameraDistance, cameraPitch, cameraRotation, cameraHeight) = app.GetCamera()
  173.  
  174.         if musicInfo.fieldMusic != "":
  175.             snd.FadeOutMusic("BGM/"+ musicInfo.fieldMusic)
  176.  
  177.         self.onPressKeyDict = None
  178.         self.onClickKeyDict = None
  179.  
  180.         chat.Close()
  181.         snd.StopAllSound()
  182.         grp.InitScreenEffect()
  183.         chr.Destroy()
  184.         textTail.Clear()
  185.         quest.Clear()
  186.         background.Destroy()
  187.         guild.Destroy()
  188.         messenger.Destroy()
  189.         skill.ClearSkillData()
  190.         wndMgr.Unlock()
  191.         mouseModule.mouseController.DeattachObject()
  192.  
  193.         if self.guildWarQuestionDialog:
  194.             self.guildWarQuestionDialog.Close()
  195.  
  196.         self.guildNameBoard = None
  197.         self.partyRequestQuestionDialog = None
  198.         self.partyInviteQuestionDialog = None
  199.         self.guildInviteQuestionDialog = None
  200.         self.guildWarQuestionDialog = None
  201.         self.messengerAddFriendQuestion = None
  202.         self.itemDropQuestionDialog = None
  203.         self.confirmDialog = None
  204.  
  205.         self.PrintCoord = None
  206.         self.FrameRate = None
  207.         self.Pitch = None
  208.         self.Splat = None
  209.         self.TextureNum = None
  210.         self.ObjectNum = None
  211.         self.ViewDistance = None
  212.         self.PrintMousePos = None
  213.  
  214.         self.ClearDictionary()
  215.  
  216.         self.playerGauge = None
  217.         self.mapNameShower = None
  218.         self.affectShower = None
  219.        
  220.         if self.targetBoard:
  221.             self.targetBoard.Destroy()
  222.             self.targetBoard = None
  223.    
  224.         if self.interface:
  225.             self.interface.HideAllWindows()
  226.             self.interface.Close()
  227.             self.interface=None
  228.  
  229.         player.ClearSkillDict()
  230.         player.ResetCameraRotation()
  231.  
  232.         self.KillFocus()
  233.         app.HideCursor()
  234.  
  235.         print "---------------------------------------------------------------------------- CLOSE GAME WINDOW"
  236.  
  237.     def __BuildKeyDict(self):
  238.         onPressKeyDict = {}
  239.         onPressKeyDict[app.DIK_1]   = lambda : self.__PressNumKey(1)
  240.         onPressKeyDict[app.DIK_2]   = lambda : self.__PressNumKey(2)
  241.         onPressKeyDict[app.DIK_3]   = lambda : self.__PressNumKey(3)
  242.         onPressKeyDict[app.DIK_4]   = lambda : self.__PressNumKey(4)
  243.         onPressKeyDict[app.DIK_5]   = lambda : self.__PressNumKey(5)
  244.         onPressKeyDict[app.DIK_6]   = lambda : self.__PressNumKey(6)
  245.         onPressKeyDict[app.DIK_7]   = lambda : self.__PressNumKey(7)
  246.         onPressKeyDict[app.DIK_8]   = lambda : self.__PressNumKey(8)
  247.         onPressKeyDict[app.DIK_9]   = lambda : self.__PressNumKey(9)
  248.         onPressKeyDict[app.DIK_F1]  = lambda : self.__PressQuickSlot(4)
  249.         onPressKeyDict[app.DIK_F2]  = lambda : self.__PressQuickSlot(5)
  250.         onPressKeyDict[app.DIK_F3]  = lambda : self.__PressQuickSlot(6)
  251.         onPressKeyDict[app.DIK_F4]  = lambda : self.__PressQuickSlot(7)
  252.  
  253.         onPressKeyDict[app.DIK_LALT]        = lambda : self.ShowName()
  254.         onPressKeyDict[app.DIK_LCONTROL]    = lambda : self.ShowMouseImage()
  255.         onPressKeyDict[app.DIK_SYSRQ]       = lambda : self.SaveScreen()
  256.         onPressKeyDict[app.DIK_SPACE]       = lambda : self.StartAttack()
  257.  
  258.         onPressKeyDict[app.DIK_UP]          = lambda : self.MoveUp()
  259.         onPressKeyDict[app.DIK_DOWN]        = lambda : self.MoveDown()
  260.         onPressKeyDict[app.DIK_LEFT]        = lambda : self.MoveLeft()
  261.         onPressKeyDict[app.DIK_RIGHT]       = lambda : self.MoveRight()
  262.         onPressKeyDict[app.DIK_W]           = lambda : self.MoveUp()
  263.         onPressKeyDict[app.DIK_S]           = lambda : self.MoveDown()
  264.         onPressKeyDict[app.DIK_A]           = lambda : self.MoveLeft()
  265.         onPressKeyDict[app.DIK_D]           = lambda : self.MoveRight()
  266.  
  267.         onPressKeyDict[app.DIK_E]           = lambda: app.RotateCamera(app.CAMERA_TO_POSITIVE)
  268.         onPressKeyDict[app.DIK_R]           = lambda: app.ZoomCamera(app.CAMERA_TO_NEGATIVE)
  269.         onPressKeyDict[app.DIK_T]           = lambda: app.PitchCamera(app.CAMERA_TO_NEGATIVE)
  270.         onPressKeyDict[app.DIK_G]           = self.__PressGKey
  271.         onPressKeyDict[app.DIK_Q]           = self.__PressQKey
  272.  
  273.         onPressKeyDict[app.DIK_NUMPAD9]     = lambda: app.MovieResetCamera()
  274.         onPressKeyDict[app.DIK_NUMPAD4]     = lambda: app.MovieRotateCamera(app.CAMERA_TO_NEGATIVE)
  275.         onPressKeyDict[app.DIK_NUMPAD6]     = lambda: app.MovieRotateCamera(app.CAMERA_TO_POSITIVE)
  276.         onPressKeyDict[app.DIK_PGUP]        = lambda: app.MovieZoomCamera(app.CAMERA_TO_NEGATIVE)
  277.         onPressKeyDict[app.DIK_PGDN]        = lambda: app.MovieZoomCamera(app.CAMERA_TO_POSITIVE)
  278.         onPressKeyDict[app.DIK_NUMPAD8]     = lambda: app.MoviePitchCamera(app.CAMERA_TO_NEGATIVE)
  279.         onPressKeyDict[app.DIK_NUMPAD2]     = lambda: app.MoviePitchCamera(app.CAMERA_TO_POSITIVE)
  280.         onPressKeyDict[app.DIK_GRAVE]       = lambda : self.PickUpItem()
  281.         onPressKeyDict[app.DIK_Z]           = lambda : self.PickUpItem()
  282.         onPressKeyDict[app.DIK_C]           = lambda state = "STATUS": self.interface.ToggleCharacterWindow(state)
  283.         onPressKeyDict[app.DIK_V]           = lambda state = "SKILL": self.interface.ToggleCharacterWindow(state)
  284.         onPressKeyDict[app.DIK_N]           = lambda state = "QUEST": self.interface.ToggleCharacterWindow(state)
  285.         onPressKeyDict[app.DIK_I]           = lambda : self.interface.ToggleInventoryWindow()
  286.         onPressKeyDict[app.DIK_O]           = lambda : self.interface.ToggleDragonSoulWindowWithNoInfo()
  287.         onPressKeyDict[app.DIK_M]           = lambda : self.interface.PressMKey()
  288.         onPressKeyDict[app.DIK_ADD]         = lambda : self.interface.MiniMapScaleUp()
  289.         onPressKeyDict[app.DIK_SUBTRACT]    = lambda : self.interface.MiniMapScaleDown()
  290.         onPressKeyDict[app.DIK_L]           = lambda : self.interface.ToggleChatLogWindow()
  291.         onPressKeyDict[app.DIK_LSHIFT]      = lambda : self.__SetQuickPageMode()
  292.  
  293.         onPressKeyDict[app.DIK_J]           = lambda : self.__PressJKey()
  294.         onPressKeyDict[app.DIK_H]           = lambda : self.__PressHKey()
  295.         onPressKeyDict[app.DIK_B]           = lambda : self.__PressBKey()
  296.         onPressKeyDict[app.DIK_F]           = lambda : self.__PressFKey()
  297.  
  298.         self.onPressKeyDict                 = onPressKeyDict
  299.  
  300.         onClickKeyDict = {}
  301.         onClickKeyDict[app.DIK_UP] = lambda : self.StopUp()
  302.         onClickKeyDict[app.DIK_DOWN] = lambda : self.StopDown()
  303.         onClickKeyDict[app.DIK_LEFT] = lambda : self.StopLeft()
  304.         onClickKeyDict[app.DIK_RIGHT] = lambda : self.StopRight()
  305.         onClickKeyDict[app.DIK_SPACE] = lambda : self.EndAttack()
  306.  
  307.         onClickKeyDict[app.DIK_W] = lambda : self.StopUp()
  308.         onClickKeyDict[app.DIK_S] = lambda : self.StopDown()
  309.         onClickKeyDict[app.DIK_A] = lambda : self.StopLeft()
  310.         onClickKeyDict[app.DIK_D] = lambda : self.StopRight()
  311.         onClickKeyDict[app.DIK_Q] = lambda: app.RotateCamera(app.CAMERA_STOP)
  312.         onClickKeyDict[app.DIK_E] = lambda: app.RotateCamera(app.CAMERA_STOP)
  313.         onClickKeyDict[app.DIK_R] = lambda: app.ZoomCamera(app.CAMERA_STOP)
  314.         onClickKeyDict[app.DIK_F] = lambda: app.ZoomCamera(app.CAMERA_STOP)
  315.         onClickKeyDict[app.DIK_T] = lambda: app.PitchCamera(app.CAMERA_STOP)
  316.         onClickKeyDict[app.DIK_G] = lambda: self.__ReleaseGKey()
  317.         onClickKeyDict[app.DIK_NUMPAD4] = lambda: app.MovieRotateCamera(app.CAMERA_STOP)
  318.         onClickKeyDict[app.DIK_NUMPAD6] = lambda: app.MovieRotateCamera(app.CAMERA_STOP)
  319.         onClickKeyDict[app.DIK_PGUP] = lambda: app.MovieZoomCamera(app.CAMERA_STOP)
  320.         onClickKeyDict[app.DIK_PGDN] = lambda: app.MovieZoomCamera(app.CAMERA_STOP)
  321.         onClickKeyDict[app.DIK_NUMPAD8] = lambda: app.MoviePitchCamera(app.CAMERA_STOP)
  322.         onClickKeyDict[app.DIK_NUMPAD2] = lambda: app.MoviePitchCamera(app.CAMERA_STOP)
  323.         onClickKeyDict[app.DIK_LALT] = lambda: self.HideName()
  324.         onClickKeyDict[app.DIK_LCONTROL] = lambda: self.HideMouseImage()
  325.         onClickKeyDict[app.DIK_LSHIFT] = lambda: self.__SetQuickSlotMode()
  326.         self.onClickKeyDict=onClickKeyDict
  327.  
  328.     def __PressNumKey(self,num):
  329.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  330.             if num >= 1 and num <= 9:
  331.                 if(chrmgr.IsPossibleEmoticon(-1)):             
  332.                     chrmgr.SetEmoticon(-1,int(num)-1)
  333.                     net.SendEmoticon(int(num)-1)
  334.         else:
  335.             if num >= 1 and num <= 4:
  336.                 self.pressNumber(num-1)
  337.  
  338.     def __ClickBKey(self):
  339.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  340.             return
  341.         else:
  342.             if constInfo.PVPMODE_ACCELKEY_ENABLE:
  343.                 self.ChangePKMode()
  344.  
  345.  
  346.     def __PressJKey(self):
  347.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  348.             if player.IsMountingHorse():
  349.                 net.SendChatPacket("/unmount")
  350.             else:
  351.                 if not uiPrivateShopBuilder.IsBuildingPrivateShop():
  352.                     for i in xrange(player.INVENTORY_PAGE_SIZE):
  353.                         if player.GetItemIndex(i) in (71114, 71116, 71118, 71120):
  354.                             net.SendItemUsePacket(i)
  355.                             break
  356.     def __PressHKey(self):
  357.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  358.             net.SendChatPacket("/user_horse_ride")
  359.         else:
  360.             self.interface.OpenHelpWindow()
  361.  
  362.     def __PressBKey(self):
  363.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  364.             net.SendChatPacket("/user_horse_back")
  365.         else:
  366.             state = "EMOTICON"
  367.             self.interface.ToggleCharacterWindow(state)
  368.  
  369.     def __PressFKey(self):
  370.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  371.             net.SendChatPacket("/user_horse_feed") 
  372.         else:
  373.             app.ZoomCamera(app.CAMERA_TO_POSITIVE)
  374.  
  375.     def __PressGKey(self):
  376.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  377.             net.SendChatPacket("/ride")
  378.         else:
  379.             if self.ShowNameFlag:
  380.                 self.interface.ToggleGuildWindow()
  381.             else:
  382.                 app.PitchCamera(app.CAMERA_TO_POSITIVE)
  383.  
  384.     def __ReleaseGKey(self):
  385.         app.PitchCamera(app.CAMERA_STOP)
  386.  
  387.     def __PressQKey(self):
  388.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  389.             if 0==interfaceModule.IsQBHide:
  390.                 interfaceModule.IsQBHide = 1
  391.                 self.interface.HideAllQuestButton()
  392.             else:
  393.                 interfaceModule.IsQBHide = 0
  394.                 self.interface.ShowAllQuestButton()
  395.         else:
  396.             app.RotateCamera(app.CAMERA_TO_NEGATIVE)
  397.  
  398.     def __SetQuickSlotMode(self):
  399.         self.pressNumber=ui.__mem_func__(self.__PressQuickSlot)
  400.  
  401.     def __SetQuickPageMode(self):
  402.         self.pressNumber=ui.__mem_func__(self.__SelectQuickPage)
  403.  
  404.     def __PressQuickSlot(self, localSlotIndex):
  405.         if 0 <= localSlotIndex and localSlotIndex < 4:
  406.             player.RequestUseLocalQuickSlot(3-localSlotIndex)
  407.         else:
  408.             player.RequestUseLocalQuickSlot(11-localSlotIndex) 
  409.  
  410.     def __SelectQuickPage(self, pageIndex):
  411.         self.quickSlotPageIndex = pageIndex
  412.         player.SetQuickPage(pageIndex)
  413.  
  414.     def ToggleDebugInfo(self):
  415.         self.isShowDebugInfo = not self.isShowDebugInfo
  416.  
  417.         if self.isShowDebugInfo:
  418.             self.PrintCoord.Show()
  419.             self.FrameRate.Show()
  420.             self.Pitch.Show()
  421.             self.Splat.Show()
  422.             self.TextureNum.Show()
  423.             self.ObjectNum.Show()
  424.             self.ViewDistance.Show()
  425.             self.PrintMousePos.Show()
  426.         else:
  427.             self.PrintCoord.Hide()
  428.             self.FrameRate.Hide()
  429.             self.Pitch.Hide()
  430.             self.Splat.Hide()
  431.             self.TextureNum.Hide()
  432.             self.ObjectNum.Hide()
  433.             self.ViewDistance.Hide()
  434.             self.PrintMousePos.Hide()
  435.  
  436.     def __BuildDebugInfo(self):
  437.         self.PrintCoord = ui.TextLine()
  438.         self.PrintCoord.SetFontName(localeInfo.UI_DEF_FONT)
  439.         self.PrintCoord.SetPosition(wndMgr.GetScreenWidth() - 270, 0)
  440.        
  441.         self.FrameRate = ui.TextLine()
  442.         self.FrameRate.SetFontName(localeInfo.UI_DEF_FONT)
  443.         self.FrameRate.SetPosition(wndMgr.GetScreenWidth() - 270, 20)
  444.  
  445.         self.Pitch = ui.TextLine()
  446.         self.Pitch.SetFontName(localeInfo.UI_DEF_FONT)
  447.         self.Pitch.SetPosition(wndMgr.GetScreenWidth() - 270, 40)
  448.  
  449.         self.Splat = ui.TextLine()
  450.         self.Splat.SetFontName(localeInfo.UI_DEF_FONT)
  451.         self.Splat.SetPosition(wndMgr.GetScreenWidth() - 270, 60)
  452.        
  453.         self.PrintMousePos = ui.TextLine()
  454.         self.PrintMousePos.SetFontName(localeInfo.UI_DEF_FONT)
  455.         self.PrintMousePos.SetPosition(wndMgr.GetScreenWidth() - 270, 80)
  456.  
  457.         self.TextureNum = ui.TextLine()
  458.         self.TextureNum.SetFontName(localeInfo.UI_DEF_FONT)
  459.         self.TextureNum.SetPosition(wndMgr.GetScreenWidth() - 270, 100)
  460.  
  461.         self.ObjectNum = ui.TextLine()
  462.         self.ObjectNum.SetFontName(localeInfo.UI_DEF_FONT)
  463.         self.ObjectNum.SetPosition(wndMgr.GetScreenWidth() - 270, 120)
  464.  
  465.         self.ViewDistance = ui.TextLine()
  466.         self.ViewDistance.SetFontName(localeInfo.UI_DEF_FONT)
  467.         self.ViewDistance.SetPosition(0, 0)
  468.  
  469.     def __NotifyError(self, msg):
  470.         chat.AppendChat(chat.CHAT_TYPE_INFO, msg)
  471.  
  472.     def ChangePKMode(self):
  473.         if not app.IsPressed(app.DIK_LCONTROL):
  474.             return
  475.  
  476.         if player.GetStatus(player.LEVEL)<constInfo.PVPMODE_PROTECTED_LEVEL:
  477.             self.__NotifyError(localeInfo.OPTION_PVPMODE_PROTECT % (constInfo.PVPMODE_PROTECTED_LEVEL))
  478.             return
  479.  
  480.         curTime = app.GetTime()
  481.         if curTime - self.lastPKModeSendedTime < constInfo.PVPMODE_ACCELKEY_DELAY:
  482.             return
  483.  
  484.         self.lastPKModeSendedTime = curTime
  485.         curPKMode = player.GetPKMode()
  486.         nextPKMode = curPKMode + 1
  487.  
  488.         if nextPKMode == player.PK_MODE_PROTECT:
  489.             if 0 == player.GetGuildID():
  490.                 chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_CANNOT_SET_GUILD_MODE)
  491.                 nextPKMode = 0
  492.             else:
  493.                 nextPKMode = player.PK_MODE_GUILD
  494.  
  495.         elif nextPKMode == player.PK_MODE_MAX_NUM:
  496.             nextPKMode = 0
  497.  
  498.         net.SendChatPacket("/PKMode " + str(nextPKMode))
  499.         print "/PKMode " + str(nextPKMode)
  500.  
  501.     def OnChangePKMode(self):
  502.         self.interface.OnChangePKMode()
  503.         try:
  504.             self.__NotifyError(localeInfo.OPTION_PVPMODE_MESSAGE_DICT[player.GetPKMode()])
  505.         except KeyError:
  506.             print "UNKNOWN PVPMode[%d]" % (player.GetPKMode())
  507.  
  508.     def StartGame(self):
  509.         self.RefreshInventory()
  510.         self.RefreshEquipment()
  511.         self.RefreshCharacter()
  512.         self.RefreshSkill()
  513.  
  514.     def CheckGameButton(self):
  515.         if self.interface:
  516.             self.interface.CheckGameButton()
  517.  
  518.     def RefreshAlignment(self):
  519.         self.interface.RefreshAlignment()
  520.  
  521.     def RefreshStatus(self):
  522.         self.CheckGameButton()
  523.  
  524.         if self.interface:
  525.             self.interface.RefreshStatus()
  526.  
  527.         if self.playerGauge:
  528.             self.playerGauge.RefreshGauge()
  529.  
  530.     def RefreshStamina(self):
  531.         self.interface.RefreshStamina()
  532.  
  533.     def RefreshSkill(self):
  534.         self.CheckGameButton()
  535.         if self.interface:
  536.             self.interface.RefreshSkill()
  537.  
  538.     def RefreshQuest(self):
  539.         self.interface.RefreshQuest()
  540.  
  541.     def RefreshMessenger(self):
  542.         self.interface.RefreshMessenger()
  543.  
  544.     def RefreshGuildInfoPage(self):
  545.         self.interface.RefreshGuildInfoPage()
  546.  
  547.     def RefreshGuildBoardPage(self):
  548.         self.interface.RefreshGuildBoardPage()
  549.  
  550.     def RefreshGuildMemberPage(self):
  551.         self.interface.RefreshGuildMemberPage()
  552.  
  553.     def RefreshGuildMemberPageGradeComboBox(self):
  554.         self.interface.RefreshGuildMemberPageGradeComboBox()
  555.  
  556.     def RefreshGuildSkillPage(self):
  557.         self.interface.RefreshGuildSkillPage()
  558.  
  559.     def RefreshGuildGradePage(self):
  560.         self.interface.RefreshGuildGradePage()
  561.  
  562.     def OnBlockMode(self, mode):
  563.         self.interface.OnBlockMode(mode)
  564.  
  565.     def OpenQuestWindow(self, skin, idx):
  566.         self.interface.OpenQuestWindow(skin, idx)
  567.  
  568.     def AskGuildName(self):
  569.         guildNameBoard = uiCommon.InputDialog()
  570.         guildNameBoard.SetTitle(localeInfo.GUILD_NAME)
  571.         guildNameBoard.SetAcceptEvent(ui.__mem_func__(self.ConfirmGuildName))
  572.         guildNameBoard.SetCancelEvent(ui.__mem_func__(self.CancelGuildName))
  573.         guildNameBoard.Open()
  574.  
  575.         self.guildNameBoard = guildNameBoard
  576.  
  577.     def ConfirmGuildName(self):
  578.         guildName = self.guildNameBoard.GetText()
  579.         if not guildName:
  580.             return
  581.  
  582.         if net.IsInsultIn(guildName):
  583.             self.PopupMessage(localeInfo.GUILD_CREATE_ERROR_INSULT_NAME)
  584.             return
  585.  
  586.         net.SendAnswerMakeGuildPacket(guildName)
  587.         self.guildNameBoard.Close()
  588.         self.guildNameBoard = None
  589.         return True
  590.  
  591.     def CancelGuildName(self):
  592.         self.guildNameBoard.Close()
  593.         self.guildNameBoard = None
  594.         return True
  595.  
  596.     def PopupMessage(self, msg):
  597.         self.stream.popupWindow.Close()
  598.         self.stream.popupWindow.Open(msg, 0, localeInfo.UI_OK)
  599.  
  600.     def OpenRefineDialog(self, targetItemPos, nextGradeItemVnum, cost, prob, type=0):
  601.         self.interface.OpenRefineDialog(targetItemPos, nextGradeItemVnum, cost, prob, type)
  602.  
  603.     def AppendMaterialToRefineDialog(self, vnum, count):
  604.         self.interface.AppendMaterialToRefineDialog(vnum, count)
  605.  
  606.     def RunUseSkillEvent(self, slotIndex, coolTime):
  607.         self.interface.OnUseSkill(slotIndex, coolTime)
  608.  
  609.     def ClearAffects(self):
  610.         self.affectShower.ClearAffects()
  611.  
  612.     def SetAffect(self, affect):
  613.         self.affectShower.SetAffect(affect)
  614.  
  615.     def ResetAffect(self, affect):
  616.         self.affectShower.ResetAffect(affect)
  617.  
  618.     def BINARY_NEW_AddAffect(self, type, pointIdx, value, duration):
  619.         self.affectShower.BINARY_NEW_AddAffect(type, pointIdx, value, duration)
  620.         if chr.NEW_AFFECT_DRAGON_SOUL_DECK1 == type or chr.NEW_AFFECT_DRAGON_SOUL_DECK2 == type:
  621.             self.interface.DragonSoulActivate(type - chr.NEW_AFFECT_DRAGON_SOUL_DECK1)
  622.         elif chr.NEW_AFFECT_DRAGON_SOUL_QUALIFIED == type:
  623.             self.BINARY_DragonSoulGiveQuilification()
  624.  
  625.     def BINARY_NEW_RemoveAffect(self, type, pointIdx):
  626.         self.affectShower.BINARY_NEW_RemoveAffect(type, pointIdx)
  627.         if chr.NEW_AFFECT_DRAGON_SOUL_DECK1 == type or chr.NEW_AFFECT_DRAGON_SOUL_DECK2 == type:
  628.             self.interface.DragonSoulDeactivate()
  629.  
  630.     def ActivateSkillSlot(self, slotIndex):
  631.         if self.interface:
  632.             self.interface.OnActivateSkill(slotIndex)
  633.  
  634.     def DeactivateSkillSlot(self, slotIndex):
  635.         if self.interface:
  636.             self.interface.OnDeactivateSkill(slotIndex)
  637.  
  638.     def RefreshEquipment(self):
  639.         if self.interface:
  640.             self.interface.RefreshInventory()
  641.  
  642.     def RefreshInventory(self):
  643.         if self.interface:
  644.             self.interface.RefreshInventory()
  645.  
  646.     def RefreshCharacter(self):
  647.         if self.interface:
  648.             self.interface.RefreshCharacter()
  649.  
  650.     def OnGameOver(self):
  651.         self.CloseTargetBoard()
  652.         self.OpenRestartDialog()
  653.  
  654.     def OpenRestartDialog(self):
  655.         self.interface.OpenRestartDialog()
  656.  
  657.     def ChangeCurrentSkill(self, skillSlotNumber):
  658.         self.interface.OnChangeCurrentSkill(skillSlotNumber)
  659.  
  660.     def SetPCTargetBoard(self, vid, name):
  661.         self.targetBoard.Open(vid, name)
  662.         if app.IsPressed(app.DIK_LCONTROL):
  663.             if not player.IsSameEmpire(vid):
  664.                 return
  665.  
  666.             if player.IsMainCharacterIndex(vid):
  667.                 return     
  668.             elif chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(vid):
  669.                 return
  670.  
  671.             self.interface.OpenWhisperDialog(name)
  672.  
  673.     def RefreshTargetBoardByVID(self, vid):
  674.         self.targetBoard.RefreshByVID(vid)
  675.  
  676.     def RefreshTargetBoardByName(self, name):
  677.         self.targetBoard.RefreshByName(name)
  678.        
  679.     def __RefreshTargetBoard(self):
  680.         self.targetBoard.Refresh()
  681.        
  682.     def SetHPTargetBoard(self, vid, hpPercentage):
  683.         if vid != self.targetBoard.GetTargetVID():
  684.             self.targetBoard.ResetTargetBoard()
  685.             self.targetBoard.SetEnemyVID(vid)
  686.  
  687.         self.targetBoard.SetHP(hpPercentage)
  688.         self.targetBoard.Show()
  689.  
  690.     def CloseTargetBoardIfDifferent(self, vid):
  691.         if vid != self.targetBoard.GetTargetVID():
  692.             self.targetBoard.Close()
  693.  
  694.     def CloseTargetBoard(self):
  695.         self.targetBoard.Close()
  696.  
  697.     def OpenEquipmentDialog(self, vid):
  698.         self.interface.OpenEquipmentDialog(vid)
  699.  
  700.     def SetEquipmentDialogItem(self, vid, slotIndex, vnum, count):
  701.         self.interface.SetEquipmentDialogItem(vid, slotIndex, vnum, count)
  702.  
  703.     def SetEquipmentDialogSocket(self, vid, slotIndex, socketIndex, value):
  704.         self.interface.SetEquipmentDialogSocket(vid, slotIndex, socketIndex, value)
  705.  
  706.     def SetEquipmentDialogAttr(self, vid, slotIndex, attrIndex, type, value):
  707.         self.interface.SetEquipmentDialogAttr(vid, slotIndex, attrIndex, type, value)
  708.  
  709.     def ShowMapName(self, mapName, x, y):
  710.         if self.mapNameShower:
  711.             self.mapNameShower.ShowMapName(mapName, x, y)
  712.  
  713.         if self.interface:
  714.             self.interface.SetMapName(mapName)
  715.  
  716.     def BINARY_OpenAtlasWindow(self):
  717.         self.interface.BINARY_OpenAtlasWindow()
  718.  
  719.     def OnRecvWhisper(self, mode, name, line):
  720.         if mode == chat.WHISPER_TYPE_GM:
  721.             self.interface.RegisterGameMasterName(name)
  722.         chat.AppendWhisper(mode, name, line)
  723.         self.interface.RecvWhisper(name)
  724.  
  725.     def OnRecvWhisperSystemMessage(self, mode, name, line):
  726.         chat.AppendWhisper(chat.WHISPER_TYPE_SYSTEM, name, line)
  727.         self.interface.RecvWhisper(name)
  728.  
  729.     def OnRecvWhisperError(self, mode, name, line):
  730.         if localeInfo.WHISPER_ERROR.has_key(mode):
  731.             chat.AppendWhisper(chat.WHISPER_TYPE_SYSTEM, name, localeInfo.WHISPER_ERROR[mode](name))
  732.         else:
  733.             chat.AppendWhisper(chat.WHISPER_TYPE_SYSTEM, name, "Whisper Unknown Error(mode=%d, name=%s)" % (mode, name))
  734.         self.interface.RecvWhisper(name)
  735.  
  736.     def RecvWhisper(self, name):
  737.         self.interface.RecvWhisper(name)
  738.  
  739.     def OnPickMoney(self, money):
  740.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.GAME_PICK_MONEY % (money))
  741.  
  742.     def OnShopError(self, type):
  743.         try:
  744.             self.PopupMessage(localeInfo.SHOP_ERROR_DICT[type])
  745.         except KeyError:
  746.             self.PopupMessage(localeInfo.SHOP_ERROR_UNKNOWN % (type))
  747.  
  748.     def OnSafeBoxError(self):
  749.         self.PopupMessage(localeInfo.SAFEBOX_ERROR)
  750.  
  751.     def OnFishingSuccess(self, isFish, fishName):
  752.         chat.AppendChatWithDelay(chat.CHAT_TYPE_INFO, localeInfo.FISHING_SUCCESS(isFish, fishName), 2000)
  753.  
  754.     def OnFishingNotifyUnknown(self):
  755.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.FISHING_UNKNOWN)
  756.  
  757.     def OnFishingWrongPlace(self):
  758.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.FISHING_WRONG_PLACE)
  759.  
  760.     def OnFishingNotify(self, isFish, fishName):
  761.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.FISHING_NOTIFY(isFish, fishName))
  762.  
  763.     def OnFishingFailure(self):
  764.         chat.AppendChatWithDelay(chat.CHAT_TYPE_INFO, localeInfo.FISHING_FAILURE, 2000)
  765.  
  766.     def OnCannotPickItem(self):
  767.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.GAME_CANNOT_PICK_ITEM)
  768.  
  769.     def OnCannotMining(self):
  770.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.GAME_CANNOT_MINING)
  771.  
  772.     def OnCannotUseSkill(self, vid, type):
  773.         textTail.RegisterInfoTail(vid, localeInfo.USE_SKILL_ERROR_TAIL_DICT[type])
  774.  
  775.     def OnCannotShotError(self, vid, type):
  776.         textTail.RegisterInfoTail(vid, localeInfo.SHOT_ERROR_TAIL_DICT.get(type, localeInfo.SHOT_ERROR_UNKNOWN % (type)))
  777.  
  778.     def StartPointReset(self):
  779.         self.interface.OpenPointResetDialog()
  780.  
  781.     def StartShop(self, vid):
  782.         self.interface.OpenShopDialog(vid)
  783.  
  784.     def EndShop(self):
  785.         self.interface.CloseShopDialog()
  786.  
  787.     def RefreshShop(self):
  788.         self.interface.RefreshShopDialog()
  789.  
  790.     def SetShopSellingPrice(self, Price):
  791.         pass
  792.  
  793.     def StartExchange(self):
  794.         self.interface.StartExchange()
  795.  
  796.     def EndExchange(self):
  797.         self.interface.EndExchange()
  798.  
  799.     def RefreshExchange(self):
  800.         self.interface.RefreshExchange()
  801.  
  802.     def RecvPartyInviteQuestion(self, leaderVID, leaderName):
  803.         partyInviteQuestionDialog = uiCommon.QuestionDialog()
  804.         partyInviteQuestionDialog.SetText(leaderName + localeInfo.PARTY_DO_YOU_JOIN)
  805.         partyInviteQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerPartyInvite(arg))
  806.         partyInviteQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerPartyInvite(arg))
  807.         partyInviteQuestionDialog.Open()
  808.         partyInviteQuestionDialog.partyLeaderVID = leaderVID
  809.         self.partyInviteQuestionDialog = partyInviteQuestionDialog
  810.  
  811.     def AnswerPartyInvite(self, answer):
  812.         if not self.partyInviteQuestionDialog:
  813.             return
  814.  
  815.         partyLeaderVID = self.partyInviteQuestionDialog.partyLeaderVID
  816.  
  817.         distance = player.GetCharacterDistance(partyLeaderVID)
  818.         if distance < 0.0 or distance > 5000:
  819.             answer = False
  820.  
  821.         net.SendPartyInviteAnswerPacket(partyLeaderVID, answer)
  822.  
  823.         self.partyInviteQuestionDialog.Close()
  824.         self.partyInviteQuestionDialog = None
  825.  
  826.     def AddPartyMember(self, pid, name):
  827.         self.interface.AddPartyMember(pid, name)
  828.  
  829.     def UpdatePartyMemberInfo(self, pid):
  830.         self.interface.UpdatePartyMemberInfo(pid)
  831.  
  832.     def RemovePartyMember(self, pid):
  833.         self.interface.RemovePartyMember(pid)
  834.         self.__RefreshTargetBoard()
  835.  
  836.     def LinkPartyMember(self, pid, vid):
  837.         self.interface.LinkPartyMember(pid, vid)
  838.  
  839.     def UnlinkPartyMember(self, pid):
  840.         self.interface.UnlinkPartyMember(pid)
  841.  
  842.     def UnlinkAllPartyMember(self):
  843.         self.interface.UnlinkAllPartyMember()
  844.  
  845.     def ExitParty(self):
  846.         self.interface.ExitParty()
  847.         self.RefreshTargetBoardByVID(self.targetBoard.GetTargetVID())
  848.  
  849.     def ChangePartyParameter(self, distributionMode):
  850.         self.interface.ChangePartyParameter(distributionMode)
  851.  
  852.     def OnMessengerAddFriendQuestion(self, name):
  853.         messengerAddFriendQuestion = uiCommon.QuestionDialog2()
  854.         messengerAddFriendQuestion.SetText1(localeInfo.MESSENGER_DO_YOU_ACCEPT_ADD_FRIEND_1 % (name))
  855.         messengerAddFriendQuestion.SetText2(localeInfo.MESSENGER_DO_YOU_ACCEPT_ADD_FRIEND_2)
  856.         messengerAddFriendQuestion.SetAcceptEvent(ui.__mem_func__(self.OnAcceptAddFriend))
  857.         messengerAddFriendQuestion.SetCancelEvent(ui.__mem_func__(self.OnDenyAddFriend))
  858.         messengerAddFriendQuestion.Open()
  859.         messengerAddFriendQuestion.name = name
  860.         self.messengerAddFriendQuestion = messengerAddFriendQuestion
  861.  
  862.     def OnAcceptAddFriend(self):
  863.         name = self.messengerAddFriendQuestion.name
  864.         net.SendChatPacket("/messenger_auth y " + name)
  865.         self.OnCloseAddFriendQuestionDialog()
  866.         return True
  867.  
  868.     def OnDenyAddFriend(self):
  869.         name = self.messengerAddFriendQuestion.name
  870.         net.SendChatPacket("/messenger_auth n " + name)
  871.         self.OnCloseAddFriendQuestionDialog()
  872.         return True
  873.  
  874.     def OnCloseAddFriendQuestionDialog(self):
  875.         self.messengerAddFriendQuestion.Close()
  876.         self.messengerAddFriendQuestion = None
  877.         return True
  878.  
  879.     def OpenSafeboxWindow(self, size):
  880.         self.interface.OpenSafeboxWindow(size)
  881.  
  882.     def RefreshSafebox(self):
  883.         self.interface.RefreshSafebox()
  884.  
  885.     def RefreshSafeboxMoney(self):
  886.         self.interface.RefreshSafeboxMoney()
  887.  
  888.     def OpenMallWindow(self, size):
  889.         self.interface.OpenMallWindow(size)
  890.  
  891.     def RefreshMall(self):
  892.         self.interface.RefreshMall()
  893.  
  894.     def RecvGuildInviteQuestion(self, guildID, guildName):
  895.         guildInviteQuestionDialog = uiCommon.QuestionDialog()
  896.         guildInviteQuestionDialog.SetText(guildName + localeInfo.GUILD_DO_YOU_JOIN)
  897.         guildInviteQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerGuildInvite(arg))
  898.         guildInviteQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerGuildInvite(arg))
  899.         guildInviteQuestionDialog.Open()
  900.         guildInviteQuestionDialog.guildID = guildID
  901.         self.guildInviteQuestionDialog = guildInviteQuestionDialog
  902.  
  903.     def AnswerGuildInvite(self, answer):
  904.  
  905.         if not self.guildInviteQuestionDialog:
  906.             return
  907.  
  908.         guildLeaderVID = self.guildInviteQuestionDialog.guildID
  909.         net.SendGuildInviteAnswerPacket(guildLeaderVID, answer)
  910.  
  911.         self.guildInviteQuestionDialog.Close()
  912.         self.guildInviteQuestionDialog = None
  913.  
  914.    
  915.     def DeleteGuild(self):
  916.         self.interface.DeleteGuild()
  917.  
  918.     def ShowClock(self, second):
  919.         self.interface.ShowClock(second)
  920.  
  921.     def HideClock(self):
  922.         self.interface.HideClock()
  923.  
  924.     def BINARY_ActEmotion(self, emotionIndex):
  925.         if self.interface.wndCharacter:
  926.             self.interface.wndCharacter.ActEmotion(emotionIndex)
  927.  
  928.     def CheckFocus(self):
  929.         if False == self.IsFocus():
  930.             if True == self.interface.IsOpenChat():
  931.                 self.interface.ToggleChat()
  932.  
  933.             self.SetFocus()
  934.  
  935.     def SaveScreen(self):
  936.         print "save screen"
  937.         if SCREENSHOT_CWDSAVE:
  938.             if not os.path.exists(os.getcwd()+os.sep+"screenshot"):
  939.                 os.mkdir(os.getcwd()+os.sep+"screenshot")
  940.  
  941.             (succeeded, name) = grp.SaveScreenShotToPath(os.getcwd()+os.sep+"screenshot"+os.sep)
  942.         elif SCREENSHOT_DIR:
  943.             (succeeded, name) = grp.SaveScreenShot(SCREENSHOT_DIR)
  944.         else:
  945.             (succeeded, name) = grp.SaveScreenShot()
  946.  
  947.         if succeeded:
  948.             pass
  949.         else:
  950.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SCREENSHOT_SAVE_FAILURE)
  951.  
  952.     def ShowName(self):
  953.         self.ShowNameFlag = True
  954.         self.playerGauge.EnableShowAlways()
  955.         player.SetQuickPage(self.quickSlotPageIndex+1)
  956.  
  957.     def __IsShowName(self):
  958.         if systemSetting.IsAlwaysShowName():
  959.             return True
  960.  
  961.         if self.ShowNameFlag:
  962.             return True
  963.  
  964.         return False
  965.    
  966.     def HideName(self):
  967.         self.ShowNameFlag = False
  968.         self.playerGauge.DisableShowAlways()
  969.         player.SetQuickPage(self.quickSlotPageIndex)
  970.  
  971.     def ShowMouseImage(self):
  972.         self.interface.ShowMouseImage()
  973.  
  974.     def HideMouseImage(self):
  975.         self.interface.HideMouseImage()
  976.  
  977.     def StartAttack(self):
  978.         player.SetAttackKeyState(True)
  979.  
  980.     def EndAttack(self):
  981.         player.SetAttackKeyState(False)
  982.  
  983.     def MoveUp(self):
  984.         player.SetSingleDIKKeyState(app.DIK_UP, True)
  985.  
  986.     def MoveDown(self):
  987.         player.SetSingleDIKKeyState(app.DIK_DOWN, True)
  988.  
  989.     def MoveLeft(self):
  990.         player.SetSingleDIKKeyState(app.DIK_LEFT, True)
  991.  
  992.     def MoveRight(self):
  993.         player.SetSingleDIKKeyState(app.DIK_RIGHT, True)
  994.  
  995.     def StopUp(self):
  996.         player.SetSingleDIKKeyState(app.DIK_UP, False)
  997.  
  998.     def StopDown(self):
  999.         player.SetSingleDIKKeyState(app.DIK_DOWN, False)
  1000.  
  1001.     def StopLeft(self):
  1002.         player.SetSingleDIKKeyState(app.DIK_LEFT, False)
  1003.  
  1004.     def StopRight(self):
  1005.         player.SetSingleDIKKeyState(app.DIK_RIGHT, False)
  1006.  
  1007.     def PickUpItem(self):
  1008.         player.PickCloseItem()
  1009.  
  1010.     def OnKeyDown(self, key):
  1011.         if self.interface.wndWeb and self.interface.wndWeb.IsShow():
  1012.             return
  1013.  
  1014.         constInfo.SET_ITEM_DROP_QUESTION_DIALOG_STATUS(0)
  1015.  
  1016.         try:
  1017.             self.onPressKeyDict[key]()
  1018.         except KeyError:
  1019.             pass
  1020.         except:
  1021.             raise
  1022.  
  1023.         return True
  1024.  
  1025.     def OnKeyUp(self, key):
  1026.         try:
  1027.             self.onClickKeyDict[key]()
  1028.         except KeyError:
  1029.             pass
  1030.         except:
  1031.             raise
  1032.  
  1033.         return True
  1034.  
  1035.     def OnMouseLeftButtonDown(self):
  1036.         if self.interface.BUILD_OnMouseLeftButtonDown():
  1037.             return
  1038.  
  1039.         if mouseModule.mouseController.isAttached():
  1040.             self.CheckFocus()
  1041.         else:
  1042.             hyperlink = ui.GetHyperlink()
  1043.             if hyperlink:
  1044.                 return
  1045.             else:
  1046.                 self.CheckFocus()
  1047.                 player.SetMouseState(player.MBT_LEFT, player.MBS_PRESS);
  1048.  
  1049.         return True
  1050.  
  1051.     def OnMouseLeftButtonUp(self):
  1052.         if self.interface.BUILD_OnMouseLeftButtonUp():
  1053.             return
  1054.  
  1055.         if mouseModule.mouseController.isAttached():
  1056.             attachedType = mouseModule.mouseController.GetAttachedType()
  1057.             attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  1058.             attachedItemSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  1059.             attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
  1060.  
  1061.             if player.SLOT_TYPE_QUICK_SLOT == attachedType:
  1062.                 player.RequestDeleteGlobalQuickSlot(attachedItemSlotPos)
  1063.  
  1064.             elif player.SLOT_TYPE_INVENTORY == attachedType:
  1065.  
  1066.                 if player.ITEM_MONEY == attachedItemIndex:
  1067.                     self.__PutMoney(attachedType, attachedItemCount, self.PickingCharacterIndex)
  1068.                 else:
  1069.                     self.__PutItem(attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount, self.PickingCharacterIndex)
  1070.  
  1071.             elif player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedType:
  1072.                 self.__PutItem(attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount, self.PickingCharacterIndex)
  1073.            
  1074.             mouseModule.mouseController.DeattachObject()
  1075.  
  1076.         else:
  1077.             hyperlink = ui.GetHyperlink()
  1078.             if hyperlink:
  1079.                 if app.IsPressed(app.DIK_LALT):
  1080.                     link = chat.GetLinkFromHyperlink(hyperlink)
  1081.                     ime.PasteString(link)
  1082.                 else:
  1083.                     self.interface.MakeHyperlinkTooltip(hyperlink)
  1084.                 return
  1085.             else:
  1086.                 player.SetMouseState(player.MBT_LEFT, player.MBS_CLICK)
  1087.         return True
  1088.  
  1089.     def __PutItem(self, attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount, dstChrID):
  1090.         if player.SLOT_TYPE_INVENTORY == attachedType or player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedType:
  1091.             attachedInvenType = player.SlotTypeToInvenType(attachedType)
  1092.             if True == chr.HasInstance(self.PickingCharacterIndex) and player.GetMainCharacterIndex() != dstChrID:
  1093.                 if player.IsEquipmentSlot(attachedItemSlotPos):
  1094.                     self.stream.popupWindow.Close()
  1095.                     self.stream.popupWindow.Open(localeInfo.EXCHANGE_FAILURE_EQUIP_ITEM, 0, localeInfo.UI_OK)
  1096.                 else:
  1097.                     if chr.IsNPC(dstChrID):
  1098.                         net.SendGiveItemPacket(dstChrID, attachedInvenType, attachedItemSlotPos, attachedItemCount)
  1099.                     else:
  1100.                         net.SendExchangeStartPacket(dstChrID)
  1101.                         net.SendExchangeItemAddPacket(attachedInvenType, attachedItemSlotPos, 0)
  1102.             else:
  1103.                 self.__DropItem(attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount)
  1104.  
  1105.     def __PutMoney(self, attachedType, attachedMoney, dstChrID):
  1106.         if True == chr.HasInstance(dstChrID) and player.GetMainCharacterIndex() != dstChrID:
  1107.             net.SendExchangeStartPacket(dstChrID)
  1108.             net.SendExchangeElkAddPacket(attachedMoney)
  1109.         else:
  1110.             self.__DropMoney(attachedType, attachedMoney)
  1111.  
  1112.     def __DropMoney(self, attachedType, attachedMoney):
  1113.         if uiPrivateShopBuilder.IsBuildingPrivateShop():           
  1114.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DROP_ITEM_FAILURE_PRIVATE_SHOP)
  1115.             return
  1116.        
  1117.         if attachedMoney>=1000:
  1118.             self.stream.popupWindow.Close()
  1119.             self.stream.popupWindow.Open(localeInfo.DROP_MONEY_FAILURE_1000_OVER, 0, localeInfo.UI_OK)
  1120.             return
  1121.  
  1122.         itemDropQuestionDialog = uiCommon.QuestionDialog()
  1123.         itemDropQuestionDialog.SetText(localeInfo.DO_YOU_DROP_MONEY % (attachedMoney))
  1124.         itemDropQuestionDialog.SetAcceptEvent(lambda arg=True: self.RequestDropItem(arg))
  1125.         itemDropQuestionDialog.SetCancelEvent(lambda arg=False: self.RequestDropItem(arg))
  1126.         itemDropQuestionDialog.Open()
  1127.         itemDropQuestionDialog.dropType = attachedType
  1128.         itemDropQuestionDialog.dropCount = attachedMoney
  1129.         itemDropQuestionDialog.dropNumber = player.ITEM_MONEY
  1130.         self.itemDropQuestionDialog = itemDropQuestionDialog
  1131.  
  1132.     def __DropItem(self, attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount):
  1133.         if uiPrivateShopBuilder.IsBuildingPrivateShop():           
  1134.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DROP_ITEM_FAILURE_PRIVATE_SHOP)
  1135.             return
  1136.        
  1137.         if player.SLOT_TYPE_INVENTORY == attachedType and player.IsEquipmentSlot(attachedItemSlotPos):
  1138.             self.stream.popupWindow.Close()
  1139.             self.stream.popupWindow.Open(localeInfo.DROP_ITEM_FAILURE_EQUIP_ITEM, 0, localeInfo.UI_OK)
  1140.  
  1141.         else:
  1142.             if player.SLOT_TYPE_INVENTORY == attachedType:
  1143.                 dropItemIndex = player.GetItemIndex(attachedItemSlotPos)
  1144.  
  1145.                 item.SelectItem(dropItemIndex)
  1146.                 dropItemName = item.GetItemName()
  1147.                 questionText = localeInfo.HOW_MANY_ITEM_DO_YOU_DROP(dropItemName, attachedItemCount)
  1148.                 itemDropQuestionDialog = uiCommon.QuestionDialog()
  1149.                 itemDropQuestionDialog.SetText(questionText)
  1150.                 itemDropQuestionDialog.SetAcceptEvent(lambda arg=True: self.RequestDropItem(arg))
  1151.                 itemDropQuestionDialog.SetCancelEvent(lambda arg=False: self.RequestDropItem(arg))
  1152.                 itemDropQuestionDialog.Open()
  1153.                 itemDropQuestionDialog.dropType = attachedType
  1154.                 itemDropQuestionDialog.dropNumber = attachedItemSlotPos
  1155.                 itemDropQuestionDialog.dropCount = attachedItemCount
  1156.                 self.itemDropQuestionDialog = itemDropQuestionDialog
  1157.  
  1158.                 constInfo.SET_ITEM_DROP_QUESTION_DIALOG_STATUS(1)
  1159.             elif player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedType:
  1160.                 dropItemIndex = player.GetItemIndex(player.DRAGON_SOUL_INVENTORY, attachedItemSlotPos)
  1161.  
  1162.                 item.SelectItem(dropItemIndex)
  1163.                 dropItemName = item.GetItemName()
  1164.                 questionText = localeInfo.HOW_MANY_ITEM_DO_YOU_DROP(dropItemName, attachedItemCount)
  1165.                 itemDropQuestionDialog = uiCommon.QuestionDialog()
  1166.                 itemDropQuestionDialog.SetText(questionText)
  1167.                 itemDropQuestionDialog.SetAcceptEvent(lambda arg=True: self.RequestDropItem(arg))
  1168.                 itemDropQuestionDialog.SetCancelEvent(lambda arg=False: self.RequestDropItem(arg))
  1169.                 itemDropQuestionDialog.Open()
  1170.                 itemDropQuestionDialog.dropType = attachedType
  1171.                 itemDropQuestionDialog.dropNumber = attachedItemSlotPos
  1172.                 itemDropQuestionDialog.dropCount = attachedItemCount
  1173.                 self.itemDropQuestionDialog = itemDropQuestionDialog
  1174.                 constInfo.SET_ITEM_DROP_QUESTION_DIALOG_STATUS(1)
  1175.  
  1176.     def RequestDropItem(self, answer):
  1177.         if not self.itemDropQuestionDialog:
  1178.             return
  1179.  
  1180.         if answer:
  1181.             dropType = self.itemDropQuestionDialog.dropType
  1182.             dropCount = self.itemDropQuestionDialog.dropCount
  1183.             dropNumber = self.itemDropQuestionDialog.dropNumber
  1184.  
  1185.             if player.SLOT_TYPE_INVENTORY == dropType:
  1186.                 if dropNumber == player.ITEM_MONEY:
  1187.                     net.SendGoldDropPacket(dropCount)
  1188.                     snd.PlaySound("sound/ui/money.wav")
  1189.                 else:
  1190.                     self.__SendDropItemPacket(dropNumber, dropCount)
  1191.             elif player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == dropType:
  1192.                     self.__SendDropItemPacket(dropNumber, dropCount, player.DRAGON_SOUL_INVENTORY)
  1193.  
  1194.         self.itemDropQuestionDialog.Close()
  1195.         self.itemDropQuestionDialog = None
  1196.  
  1197.         constInfo.SET_ITEM_DROP_QUESTION_DIALOG_STATUS(0)
  1198.  
  1199.     def __SendDropItemPacket(self, itemVNum, itemCount, itemInvenType = player.INVENTORY):
  1200.         if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1201.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DROP_ITEM_FAILURE_PRIVATE_SHOP)
  1202.             return
  1203.  
  1204.         net.SendItemDropPacket(itemInvenType, itemVNum, itemCount)
  1205.  
  1206.     def OnMouseRightButtonDown(self):
  1207.  
  1208.         self.CheckFocus()
  1209.  
  1210.         if True == mouseModule.mouseController.isAttached():
  1211.             mouseModule.mouseController.DeattachObject()
  1212.  
  1213.         else:
  1214.             player.SetMouseState(player.MBT_RIGHT, player.MBS_PRESS)
  1215.  
  1216.         return True
  1217.  
  1218.     def OnMouseRightButtonUp(self):
  1219.         if True == mouseModule.mouseController.isAttached():
  1220.             return True
  1221.  
  1222.         player.SetMouseState(player.MBT_RIGHT, player.MBS_CLICK)
  1223.         return True
  1224.  
  1225.     def OnMouseMiddleButtonDown(self):
  1226.         player.SetMouseMiddleButtonState(player.MBS_PRESS)
  1227.  
  1228.     def OnMouseMiddleButtonUp(self):
  1229.         player.SetMouseMiddleButtonState(player.MBS_CLICK)
  1230.  
  1231.     def OnUpdate(self):
  1232.         app.UpdateGame()
  1233.        
  1234.         if self.mapNameShower.IsShow():
  1235.             self.mapNameShower.Update()
  1236.  
  1237.         if self.isShowDebugInfo:
  1238.             self.UpdateDebugInfo()
  1239.  
  1240.         if self.enableXMasBoom:
  1241.             self.__XMasBoom_Update()
  1242.  
  1243.         self.interface.BUILD_OnUpdate()
  1244.        
  1245.        
  1246.     def UpdateDebugInfo(self):
  1247.         (x, y, z) = player.GetMainCharacterPosition()
  1248.         nUpdateTime = app.GetUpdateTime()
  1249.         nUpdateFPS = app.GetUpdateFPS()
  1250.         nRenderFPS = app.GetRenderFPS()
  1251.         nFaceCount = app.GetFaceCount()
  1252.         fFaceSpeed = app.GetFaceSpeed()
  1253.         nST=background.GetRenderShadowTime()
  1254.         (fAveRT, nCurRT) =  app.GetRenderTime()
  1255.         (iNum, fFogStart, fFogEnd, fFarCilp) = background.GetDistanceSetInfo()
  1256.         (iPatch, iSplat, fSplatRatio, sTextureNum) = background.GetRenderedSplatNum()
  1257.        
  1258.         if iPatch == 0:
  1259.             iPatch = 1
  1260.  
  1261.         self.PrintCoord.SetText("Coordinate: %.2f %.2f %.2f ATM: %d" % (x, y, z, app.GetAvailableTextureMemory()/(1024*1024)))
  1262.         xMouse, yMouse = wndMgr.GetMousePosition()
  1263.         self.PrintMousePos.SetText("MousePosition: %d %d" % (xMouse, yMouse))          
  1264.  
  1265.         self.FrameRate.SetText("UFPS: %3d UT: %3d FS %.2f" % (nUpdateFPS, nUpdateTime, fFaceSpeed))
  1266.  
  1267.         if fAveRT>1.0:
  1268.             self.Pitch.SetText("RFPS: %3d RT:%.2f(%3d) FC: %d(%.2f) " % (nRenderFPS, fAveRT, nCurRT, nFaceCount, nFaceCount/fAveRT))
  1269.  
  1270.         self.Splat.SetText("PATCH: %d SPLAT: %d BAD(%.2f)" % (iPatch, iSplat, fSplatRatio))
  1271.         self.ViewDistance.SetText("Num : %d, FS : %f, FE : %f, FC : %f" % (iNum, fFogStart, fFogEnd, fFarCilp))
  1272.  
  1273.     def OnRender(self):
  1274.         app.RenderGame()
  1275.         (x, y) = app.GetCursorPosition()
  1276.         textTail.UpdateAllTextTail()
  1277.  
  1278.         if True == wndMgr.IsPickedWindow(self.hWnd):
  1279.  
  1280.             self.PickingCharacterIndex = chr.Pick()
  1281.  
  1282.             if -1 != self.PickingCharacterIndex:
  1283.                 textTail.ShowCharacterTextTail(self.PickingCharacterIndex)
  1284.             if 0 != self.targetBoard.GetTargetVID():
  1285.                 textTail.ShowCharacterTextTail(self.targetBoard.GetTargetVID())
  1286.  
  1287.             if not self.__IsShowName():
  1288.                 self.PickingItemIndex = item.Pick()
  1289.                 if -1 != self.PickingItemIndex:
  1290.                     textTail.ShowItemTextTail(self.PickingItemIndex)
  1291.  
  1292.         if self.__IsShowName():
  1293.             textTail.ShowAllTextTail()
  1294.             self.PickingItemIndex = textTail.Pick(x, y)
  1295.  
  1296.         textTail.UpdateShowingTextTail()
  1297.         textTail.ArrangeTextTail()
  1298.         if -1 != self.PickingItemIndex:
  1299.             textTail.SelectItemName(self.PickingItemIndex)
  1300.  
  1301.         grp.PopState()
  1302.         grp.SetInterfaceRenderState()
  1303.  
  1304.         textTail.Render()
  1305.         textTail.HideAllTextTail()
  1306.  
  1307.     def OnPressEscapeKey(self):
  1308.         if app.TARGET == app.GetCursor():
  1309.             app.SetCursor(app.NORMAL)
  1310.  
  1311.         elif True == mouseModule.mouseController.isAttached():
  1312.             mouseModule.mouseController.DeattachObject()
  1313.  
  1314.         else:
  1315.             self.interface.OpenSystemDialog()
  1316.  
  1317.         return True
  1318.  
  1319.     def OnIMEReturn(self):
  1320.         if app.IsPressed(app.DIK_LSHIFT):
  1321.             self.interface.OpenWhisperDialogWithoutTarget()
  1322.         else:
  1323.             self.interface.ToggleChat()
  1324.         return True
  1325.  
  1326.     def OnPressExitKey(self):
  1327.         self.interface.ToggleSystemDialog()
  1328.         return True
  1329.  
  1330.     def BINARY_LoverInfo(self, name, lovePoint):
  1331.         if self.interface.wndMessenger:
  1332.             self.interface.wndMessenger.OnAddLover(name, lovePoint)
  1333.         if self.affectShower:
  1334.             self.affectShower.SetLoverInfo(name, lovePoint)
  1335.  
  1336.     def BINARY_UpdateLovePoint(self, lovePoint):
  1337.         if self.interface.wndMessenger:
  1338.             self.interface.wndMessenger.OnUpdateLovePoint(lovePoint)
  1339.         if self.affectShower:
  1340.             self.affectShower.OnUpdateLovePoint(lovePoint)
  1341.    
  1342.     def BINARY_OnQuestConfirm(self, msg, timeout, pid):
  1343.         confirmDialog = uiCommon.QuestionDialogWithTimeLimit()
  1344.         confirmDialog.Open(msg, timeout)
  1345.         confirmDialog.SetAcceptEvent(lambda answer=True, pid=pid: net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
  1346.         confirmDialog.SetCancelEvent(lambda answer=False, pid=pid: net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
  1347.         self.confirmDialog = confirmDialog
  1348.  
  1349.     def Gift_Show(self):
  1350.         self.interface.ShowGift()
  1351.  
  1352.     def BINARY_Cube_Open(self, npcVNUM):
  1353.         self.currentCubeNPC = npcVNUM
  1354.        
  1355.         self.interface.OpenCubeWindow()
  1356.  
  1357.        
  1358.         if npcVNUM not in self.cubeInformation:
  1359.             net.SendChatPacket("/cube r_info")
  1360.         else:
  1361.             cubeInfoList = self.cubeInformation[npcVNUM]
  1362.            
  1363.             i = 0
  1364.             for cubeInfo in cubeInfoList:                              
  1365.                 self.interface.wndCube.AddCubeResultItem(cubeInfo["vnum"], cubeInfo["count"])
  1366.                
  1367.                 j = 0              
  1368.                 for materialList in cubeInfo["materialList"]:
  1369.                     for materialInfo in materialList:
  1370.                         itemVnum, itemCount = materialInfo
  1371.                         self.interface.wndCube.AddMaterialInfo(i, j, itemVnum, itemCount)
  1372.                     j = j + 1                      
  1373.                        
  1374.                 i = i + 1
  1375.                
  1376.             self.interface.wndCube.Refresh()
  1377.  
  1378.     def BINARY_Cube_Close(self):
  1379.         self.interface.CloseCubeWindow()
  1380.  
  1381.     def BINARY_Cube_UpdateInfo(self, gold, itemVnum, count):
  1382.         self.interface.UpdateCubeInfo(gold, itemVnum, count)
  1383.        
  1384.     def BINARY_Cube_Succeed(self, itemVnum, count):
  1385.         print "Cube making success"
  1386.         self.interface.SucceedCubeWork(itemVnum, count)
  1387.         pass
  1388.  
  1389.     def BINARY_Cube_Failed(self):
  1390.         print "Cube production failures"
  1391.         self.interface.FailedCubeWork()
  1392.         pass
  1393.  
  1394.     def BINARY_Cube_ResultList(self, npcVNUM, listText):       
  1395.         if npcVNUM == 0:
  1396.             npcVNUM = self.currentCubeNPC
  1397.        
  1398.         self.cubeInformation[npcVNUM] = []
  1399.        
  1400.         try:
  1401.             for eachInfoText in listText.split("/"):
  1402.                 eachInfo = eachInfoText.split(",")
  1403.                 itemVnum    = int(eachInfo[0])
  1404.                 itemCount   = int(eachInfo[1])
  1405.  
  1406.                 self.cubeInformation[npcVNUM].append({"vnum": itemVnum, "count": itemCount})
  1407.                 self.interface.wndCube.AddCubeResultItem(itemVnum, itemCount)
  1408.            
  1409.             resultCount = len(self.cubeInformation[npcVNUM])
  1410.             requestCount = 7
  1411.             modCount = resultCount % requestCount
  1412.             splitCount = resultCount / requestCount
  1413.             for i in xrange(splitCount):
  1414.                 net.SendChatPacket("/cube r_info %d %d" % (i * requestCount, requestCount))
  1415.                
  1416.             if 0 < modCount:
  1417.                 net.SendChatPacket("/cube r_info %d %d" % (splitCount * requestCount, modCount))
  1418.  
  1419.         except RuntimeError, msg:
  1420.             dbg.TraceError(msg)
  1421.             return 0
  1422.            
  1423.         pass
  1424.        
  1425.     def BINARY_Cube_MaterialInfo(self, startIndex, listCount, listText):
  1426.         try:           
  1427.             if 3 > len(listText):
  1428.                 dbg.TraceError("Wrong Cube Material Infomation")
  1429.                 return 0
  1430.  
  1431.            
  1432.            
  1433.             eachResultList = listText.split("@")
  1434.  
  1435.             cubeInfo = self.cubeInformation[self.currentCubeNPC]           
  1436.            
  1437.             itemIndex = 0
  1438.             for eachResultText in eachResultList:
  1439.                 cubeInfo[startIndex + itemIndex]["materialList"] = [[], [], [], [], []]
  1440.                 materialList = cubeInfo[startIndex + itemIndex]["materialList"]
  1441.                
  1442.                 gold = 0
  1443.                 splitResult = eachResultText.split("/")
  1444.                 if 1 < len(splitResult):
  1445.                     gold = int(splitResult[1])
  1446.                    
  1447.                 eachMaterialList = splitResult[0].split("&")
  1448.                
  1449.                 i = 0
  1450.                 for eachMaterialText in eachMaterialList:
  1451.                     complicatedList = eachMaterialText.split("|")
  1452.                    
  1453.                     if 0 < len(complicatedList):
  1454.                         for complicatedText in complicatedList:
  1455.                             (itemVnum, itemCount) = complicatedText.split(",")
  1456.                             itemVnum = int(itemVnum)
  1457.                             itemCount = int(itemCount)
  1458.                             self.interface.wndCube.AddMaterialInfo(itemIndex + startIndex, i, itemVnum, itemCount)
  1459.                            
  1460.                             materialList[i].append((itemVnum, itemCount))
  1461.                            
  1462.                     else:
  1463.                         itemVnum, itemCount = eachMaterialText.split(",")
  1464.                         itemVnum = int(itemVnum)
  1465.                         itemCount = int(itemCount)
  1466.                         self.interface.wndCube.AddMaterialInfo(itemIndex + startIndex, i, itemVnum, itemCount)
  1467.                        
  1468.                         materialList[i].append((itemVnum, itemCount))
  1469.                        
  1470.                     i = i + 1
  1471.                    
  1472.                    
  1473.                    
  1474.                 itemIndex = itemIndex + 1
  1475.                
  1476.             self.interface.wndCube.Refresh()
  1477.            
  1478.                
  1479.         except RuntimeError, msg:
  1480.             dbg.TraceError(msg)
  1481.             return 0           
  1482.         pass
  1483.  
  1484.     def BINARY_Highlight_Item(self, inven_type, inven_pos):
  1485.         self.interface.Highligt_Item(inven_type, inven_pos)
  1486.    
  1487.     def BINARY_DragonSoulGiveQuilification(self):
  1488.         self.interface.DragonSoulGiveQuilification()
  1489.        
  1490.     def BINARY_DragonSoulRefineWindow_Open(self):
  1491.         self.interface.OpenDragonSoulRefineWindow()
  1492.  
  1493.     def BINARY_DragonSoulRefineWindow_RefineFail(self, reason, inven_type, inven_pos):
  1494.         self.interface.FailDragonSoulRefine(reason, inven_type, inven_pos)
  1495.  
  1496.     def BINARY_DragonSoulRefineWindow_RefineSucceed(self, inven_type, inven_pos):
  1497.         self.interface.SucceedDragonSoulRefine(inven_type, inven_pos)
  1498.    
  1499.     def BINARY_SetBigMessage(self, message):
  1500.         self.interface.bigBoard.SetTip(message)
  1501.  
  1502.     def BINARY_SetTipMessage(self, message):
  1503.         self.interface.tipBoard.SetTip(message)    
  1504.  
  1505.     def BINARY_AppendNotifyMessage(self, type):
  1506.         if not type in localeInfo.NOTIFY_MESSAGE:
  1507.             return
  1508.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.NOTIFY_MESSAGE[type])
  1509.  
  1510.     def BINARY_Guild_EnterGuildArea(self, areaID):
  1511.         self.interface.BULID_EnterGuildArea(areaID)
  1512.  
  1513.     def BINARY_Guild_ExitGuildArea(self, areaID):
  1514.         self.interface.BULID_ExitGuildArea(areaID)
  1515.  
  1516.     def BINARY_GuildWar_OnSendDeclare(self, guildID):
  1517.         pass
  1518.  
  1519.     def BINARY_GuildWar_OnRecvDeclare(self, guildID, warType):
  1520.         mainCharacterName = player.GetMainCharacterName()
  1521.         masterName = guild.GetGuildMasterName()
  1522.         if mainCharacterName == masterName:
  1523.             self.__GuildWar_OpenAskDialog(guildID, warType)
  1524.  
  1525.     def BINARY_GuildWar_OnRecvPoint(self, gainGuildID, opponentGuildID, point):
  1526.         self.interface.OnRecvGuildWarPoint(gainGuildID, opponentGuildID, point)
  1527.  
  1528.     def BINARY_GuildWar_OnStart(self, guildSelf, guildOpp):
  1529.         self.interface.OnStartGuildWar(guildSelf, guildOpp)
  1530.  
  1531.     def BINARY_GuildWar_OnEnd(self, guildSelf, guildOpp):
  1532.         self.interface.OnEndGuildWar(guildSelf, guildOpp)
  1533.  
  1534.     def BINARY_BettingGuildWar_SetObserverMode(self, isEnable):
  1535.         self.interface.BINARY_SetObserverMode(isEnable)
  1536.  
  1537.     def BINARY_BettingGuildWar_UpdateObserverCount(self, observerCount):
  1538.         self.interface.wndMiniMap.UpdateObserverCount(observerCount)
  1539.  
  1540.     def __GuildWar_UpdateMemberCount(self, guildID1, memberCount1, guildID2, memberCount2, observerCount):
  1541.         guildID1 = int(guildID1)
  1542.         guildID2 = int(guildID2)
  1543.         memberCount1 = int(memberCount1)
  1544.         memberCount2 = int(memberCount2)
  1545.         observerCount = int(observerCount)
  1546.  
  1547.         self.interface.UpdateMemberCount(guildID1, memberCount1, guildID2, memberCount2)
  1548.         self.interface.wndMiniMap.UpdateObserverCount(observerCount)
  1549.  
  1550.     def __GuildWar_OpenAskDialog(self, guildID, warType):
  1551.         guildName = guild.GetGuildName(guildID)
  1552.  
  1553.         if "Noname" == guildName:
  1554.             return
  1555.  
  1556.         import uiGuild
  1557.         questionDialog = uiGuild.AcceptGuildWarDialog()
  1558.         questionDialog.SAFE_SetAcceptEvent(self.__GuildWar_OnAccept)
  1559.         questionDialog.SAFE_SetCancelEvent(self.__GuildWar_OnDecline)
  1560.         questionDialog.Open(guildName, warType)
  1561.  
  1562.         self.guildWarQuestionDialog = questionDialog
  1563.  
  1564.     def __GuildWar_CloseAskDialog(self):
  1565.         self.guildWarQuestionDialog.Close()
  1566.         self.guildWarQuestionDialog = None
  1567.  
  1568.     def __GuildWar_OnAccept(self):
  1569.         guildName = self.guildWarQuestionDialog.GetGuildName()
  1570.  
  1571.         net.SendChatPacket("/war " + guildName)
  1572.         self.__GuildWar_CloseAskDialog()
  1573.  
  1574.         return 1
  1575.  
  1576.     def __GuildWar_OnDecline(self):
  1577.         guildName = self.guildWarQuestionDialog.GetGuildName()
  1578.         net.SendChatPacket("/nowar " + guildName)
  1579.         self.__GuildWar_CloseAskDialog()
  1580.         return 1
  1581.  
  1582.     def __ServerCommand_Build(self):
  1583.         serverCommandList={
  1584.             "DayMode"               : self.__DayMode_Update,
  1585.             "PRESERVE_DayMode"      : self.__PRESERVE_DayMode_Update,
  1586.             "CloseRestartWindow"    : self.__RestartDialog_Close,
  1587.             "OpenPrivateShop"       : self.__PrivateShop_Open,
  1588.             "PartyHealReady"        : self.PartyHealReady,
  1589.             "ShowMeSafeboxPassword" : self.AskSafeboxPassword,
  1590.             "CloseSafebox"          : self.CommandCloseSafebox,
  1591.  
  1592.             "CloseMall"             : self.CommandCloseMall,
  1593.             "ShowMeMallPassword"    : self.AskMallPassword,
  1594.             "item_mall"             : self.__ItemMall_Open,
  1595.  
  1596.             "RefineSuceeded"        : self.RefineSuceededMessage,
  1597.             "RefineFailed"          : self.RefineFailedMessage,
  1598.             "xmas_snow"             : self.__XMasSnow_Enable,
  1599.             "xmas_boom"             : self.__XMasBoom_Enable,
  1600.             "xmas_song"             : self.__XMasSong_Enable,
  1601.             "xmas_tree"             : self.__XMasTree_Enable,
  1602.             "newyear_boom"          : self.__XMasBoom_Enable,
  1603.             "PartyRequest"          : self.__PartyRequestQuestion,
  1604.             "PartyRequestDenied"    : self.__PartyRequestDenied,
  1605.             "horse_state"           : self.__Horse_UpdateState,
  1606.             "hide_horse_state"      : self.__Horse_HideState,
  1607.             "WarUC"                 : self.__GuildWar_UpdateMemberCount,
  1608.             "mall"                  : self.__InGameShop_Show,
  1609.  
  1610.             "lover_login"           : self.__LoginLover,
  1611.             "lover_logout"          : self.__LogoutLover,
  1612.             "lover_near"            : self.__LoverNear,
  1613.             "lover_far"             : self.__LoverFar,
  1614.             "lover_divorce"         : self.__LoverDivorce,
  1615.             "PlayMusic"             : self.__PlayMusic,
  1616.  
  1617.             "MyShopPriceList"       : self.__PrivateShop_PriceList,
  1618.         }
  1619.  
  1620.         self.serverCommander=stringCommander.Analyzer()
  1621.         for serverCommandItem in serverCommandList.items():
  1622.             self.serverCommander.SAFE_RegisterCallBack(serverCommandItem[0], serverCommandItem[1])
  1623.  
  1624.     def BINARY_ServerCommand_Run(self, line):
  1625.         try:
  1626.             return self.serverCommander.Run(line)
  1627.         except RuntimeError, msg:
  1628.             dbg.TraceError(msg)
  1629.             return 0
  1630.  
  1631.     def __ProcessPreservedServerCommand(self):
  1632.         try:
  1633.             command = net.GetPreservedServerCommand()
  1634.             while command:
  1635.                 print " __ProcessPreservedServerCommand", command
  1636.                 self.serverCommander.Run(command)
  1637.                 command = net.GetPreservedServerCommand()
  1638.         except RuntimeError, msg:
  1639.             dbg.TraceError(msg)
  1640.             return 0
  1641.  
  1642.     def PartyHealReady(self):
  1643.         self.interface.PartyHealReady()
  1644.  
  1645.     def AskSafeboxPassword(self):
  1646.         self.interface.AskSafeboxPassword()
  1647.  
  1648.     def AskMallPassword(self):
  1649.         self.interface.AskMallPassword()
  1650.  
  1651.     def __ItemMall_Open(self):
  1652.         self.interface.OpenItemMall();
  1653.  
  1654.     def CommandCloseMall(self):
  1655.         self.interface.CommandCloseMall()
  1656.  
  1657.     def RefineSuceededMessage(self):
  1658.         snd.PlaySound("sound/ui/make_soket.wav")
  1659.         self.PopupMessage(localeInfo.REFINE_SUCCESS)
  1660.  
  1661.     def RefineFailedMessage(self):
  1662.         snd.PlaySound("sound/ui/jaeryun_fail.wav")
  1663.         self.PopupMessage(localeInfo.REFINE_FAILURE)
  1664.  
  1665.     def CommandCloseSafebox(self):
  1666.         self.interface.CommandCloseSafebox()
  1667.  
  1668.     def __PrivateShop_PriceList(self, itemVNum, itemPrice):
  1669.         uiPrivateShopBuilder.SetPrivateShopItemPrice(itemVNum, itemPrice)  
  1670.  
  1671.     def __Horse_HideState(self):
  1672.         self.affectShower.SetHorseState(0, 0, 0)
  1673.  
  1674.     def __Horse_UpdateState(self, level, health, battery):
  1675.         self.affectShower.SetHorseState(int(level), int(health), int(battery))
  1676.  
  1677.     def __IsXMasMap(self):
  1678.         mapDict = ( "metin2_map_n_flame_01",
  1679.                     "metin2_map_n_desert_01",
  1680.                     "metin2_map_spiderdungeon",
  1681.                     "metin2_map_deviltower1", )
  1682.  
  1683.         if background.GetCurrentMapName() in mapDict:
  1684.             return False
  1685.  
  1686.         return True
  1687.  
  1688.     def __XMasSnow_Enable(self, mode):
  1689.         self.__XMasSong_Enable(mode)
  1690.         if "1"==mode:
  1691.             if not self.__IsXMasMap():
  1692.                 return
  1693.  
  1694.             print "XMAS_SNOW ON"
  1695.             background.EnableSnow(1)
  1696.  
  1697.         else:
  1698.             print "XMAS_SNOW OFF"
  1699.             background.EnableSnow(0)
  1700.  
  1701.     def __XMasBoom_Enable(self, mode):
  1702.         if "1"==mode:
  1703.             if not self.__IsXMasMap():
  1704.                 return
  1705.  
  1706.             print "XMAS_BOOM ON"
  1707.             self.__DayMode_Update("dark")
  1708.             self.enableXMasBoom = True
  1709.             self.startTimeXMasBoom = app.GetTime()
  1710.         else:
  1711.             print "XMAS_BOOM OFF"
  1712.             self.__DayMode_Update("light")
  1713.             self.enableXMasBoom = False
  1714.  
  1715.     def __XMasTree_Enable(self, grade):
  1716.  
  1717.         print "XMAS_TREE ", grade
  1718.         background.SetXMasTree(int(grade))
  1719.  
  1720.     def __XMasSong_Enable(self, mode):
  1721.         if "1"==mode:
  1722.             print "XMAS_SONG ON"
  1723.  
  1724.             XMAS_BGM = "xmas.mp3"
  1725.  
  1726.             if app.IsExistFile("BGM/" + XMAS_BGM)==1:
  1727.                 if musicInfo.fieldMusic != "":
  1728.                     snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  1729.  
  1730.                 musicInfo.fieldMusic=XMAS_BGM
  1731.                 snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  1732.  
  1733.         else:
  1734.             print "XMAS_SONG OFF"
  1735.  
  1736.             if musicInfo.fieldMusic != "":
  1737.                 snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  1738.  
  1739.             musicInfo.fieldMusic=musicInfo.METIN2THEMA
  1740.             snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  1741.  
  1742.     def __RestartDialog_Close(self):
  1743.         self.interface.CloseRestartDialog()
  1744.  
  1745.     def __PrivateShop_Open(self):
  1746.         self.interface.OpenPrivateShopInputNameDialog()
  1747.  
  1748.     def BINARY_PrivateShop_Appear(self, vid, text):
  1749.         self.interface.AppearPrivateShop(vid, text)
  1750.  
  1751.     def BINARY_PrivateShop_Disappear(self, vid):
  1752.         self.interface.DisappearPrivateShop(vid)
  1753.  
  1754.     def __PRESERVE_DayMode_Update(self, mode):
  1755.         if "light"==mode:
  1756.             background.SetEnvironmentData(0)
  1757.         elif "dark"==mode:
  1758.  
  1759.             if not self.__IsXMasMap():
  1760.                 return
  1761.  
  1762.             background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)
  1763.             background.SetEnvironmentData(1)
  1764.  
  1765.     def __DayMode_Update(self, mode):
  1766.         if "light"==mode:
  1767.             self.curtain.SAFE_FadeOut(self.__DayMode_OnCompleteChangeToLight)
  1768.         elif "dark"==mode:
  1769.  
  1770.             if not self.__IsXMasMap():
  1771.                 return
  1772.  
  1773.             self.curtain.SAFE_FadeOut(self.__DayMode_OnCompleteChangeToDark)
  1774.  
  1775.     def __DayMode_OnCompleteChangeToLight(self):
  1776.         background.SetEnvironmentData(0)
  1777.         self.curtain.FadeIn()
  1778.  
  1779.     def __DayMode_OnCompleteChangeToDark(self):
  1780.         background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)
  1781.         background.SetEnvironmentData(1)
  1782.         self.curtain.FadeIn()
  1783.  
  1784.     def __XMasBoom_Update(self):
  1785.         self.BOOM_DATA_LIST = ( (2, 5), (5, 2), (7, 3), (10, 3), (20, 5) )
  1786.         if self.indexXMasBoom >= len(self.BOOM_DATA_LIST):
  1787.             return
  1788.  
  1789.         boomTime = self.BOOM_DATA_LIST[self.indexXMasBoom][0]
  1790.         boomCount = self.BOOM_DATA_LIST[self.indexXMasBoom][1]
  1791.  
  1792.         if app.GetTime() - self.startTimeXMasBoom > boomTime:
  1793.             self.indexXMasBoom += 1
  1794.  
  1795.             for i in xrange(boomCount):
  1796.                 self.__XMasBoom_Boom()
  1797.  
  1798.     def __XMasBoom_Boom(self):
  1799.         x, y, z = player.GetMainCharacterPosition()
  1800.         randX = app.GetRandom(-150, 150)
  1801.         randY = app.GetRandom(-150, 150)
  1802.  
  1803.         snd.PlaySound3D(x+randX, -y+randY, z, "sound/common/etc/salute.mp3")
  1804.  
  1805.     def __PartyRequestQuestion(self, vid):
  1806.         vid = int(vid)
  1807.         partyRequestQuestionDialog = uiCommon.QuestionDialog()
  1808.         partyRequestQuestionDialog.SetText(chr.GetNameByVID(vid) + localeInfo.PARTY_DO_YOU_ACCEPT)
  1809.         partyRequestQuestionDialog.SetAcceptText(localeInfo.UI_ACCEPT)
  1810.         partyRequestQuestionDialog.SetCancelText(localeInfo.UI_DENY)
  1811.         partyRequestQuestionDialog.SetAcceptEvent(lambda arg=True: self.__AnswerPartyRequest(arg))
  1812.         partyRequestQuestionDialog.SetCancelEvent(lambda arg=False: self.__AnswerPartyRequest(arg))
  1813.         partyRequestQuestionDialog.Open()
  1814.         partyRequestQuestionDialog.vid = vid
  1815.         self.partyRequestQuestionDialog = partyRequestQuestionDialog
  1816.  
  1817.     def __AnswerPartyRequest(self, answer):
  1818.         if not self.partyRequestQuestionDialog:
  1819.             return
  1820.  
  1821.         vid = self.partyRequestQuestionDialog.vid
  1822.  
  1823.         if answer:
  1824.             net.SendChatPacket("/party_request_accept " + str(vid))
  1825.         else:
  1826.             net.SendChatPacket("/party_request_deny " + str(vid))
  1827.  
  1828.         self.partyRequestQuestionDialog.Close()
  1829.         self.partyRequestQuestionDialog = None
  1830.  
  1831.     def __PartyRequestDenied(self):
  1832.         self.PopupMessage(localeInfo.PARTY_REQUEST_DENIED)
  1833.  
  1834.     def __InGameShop_Show(self, url):
  1835.         if constInfo.IN_GAME_SHOP_ENABLE:
  1836.             self.interface.OpenWebWindow(url)
  1837.  
  1838.     def __LoginLover(self):
  1839.         if self.interface.wndMessenger:
  1840.             self.interface.wndMessenger.OnLoginLover()
  1841.  
  1842.     def __LogoutLover(self):
  1843.         if self.interface.wndMessenger:
  1844.             self.interface.wndMessenger.OnLogoutLover()
  1845.         if self.affectShower:
  1846.             self.affectShower.HideLoverState()
  1847.  
  1848.     def __LoverNear(self):
  1849.         if self.affectShower:
  1850.             self.affectShower.ShowLoverState()
  1851.  
  1852.     def __LoverFar(self):
  1853.         if self.affectShower:
  1854.             self.affectShower.HideLoverState()
  1855.  
  1856.     def __LoverDivorce(self):
  1857.         if self.interface.wndMessenger:
  1858.             self.interface.wndMessenger.ClearLoverInfo()
  1859.         if self.affectShower:
  1860.             self.affectShower.ClearLoverState()
  1861.  
  1862.     def __PlayMusic(self, flag, filename):
  1863.         flag = int(flag)
  1864.         if flag:
  1865.             snd.FadeOutAllMusic()
  1866.             musicInfo.SaveLastPlayFieldMusic()
  1867.             snd.FadeInMusic("BGM/" + filename)
  1868.         else:
  1869.             snd.FadeOutAllMusic()
  1870.             musicInfo.LoadLastPlayFieldMusic()
  1871.             snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
Advertisement
Add Comment
Please, Sign In to add comment