Guest User

game.py

a guest
Jul 5th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 74.65 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 event
  10. import player
  11. import snd
  12. import chat
  13. import textTail
  14. import snd
  15. import net
  16. import effect
  17. import wndMgr
  18. import fly
  19. import systemSetting
  20. import quest
  21. import guild
  22. import skill
  23. import messenger
  24. import localeInfo
  25. import constInfo
  26. import exchange
  27. import ime
  28. import time
  29.  
  30. import ui
  31. import uiCommon
  32. import uiPhaseCurtain
  33. import uiMapNameShower
  34. import uiAffectShower
  35. import uiPlayerGauge
  36. import uiCharacter
  37. import uiTarget
  38.  
  39. # PRIVATE_SHOP_PRICE_LIST
  40. import uiPrivateShopBuilder
  41. # END_OF_PRIVATE_SHOP_PRICE_LIST
  42.  
  43. import mouseModule
  44. import consoleModule
  45. import localeInfo
  46.  
  47. import playerSettingModule
  48. import interfaceModule
  49.  
  50. import musicInfo
  51. import debugInfo
  52. import stringCommander
  53.  
  54. from _weakref import proxy
  55. from switchbot import Bot
  56. import uiprofile
  57.  
  58. if app.ENABLE_PVP_ADVANCED:
  59.     import constInfo as pvp
  60.     import uiCommon as message
  61.     import uiduel
  62.    
  63. # TEXTTAIL_LIVINGTIME_CONTROL
  64. #if localeInfo.IsJAPAN():
  65. #   app.SetTextTailLivingTime(8.0)
  66. # END_OF_TEXTTAIL_LIVINGTIME_CONTROL
  67.  
  68. # SCREENSHOT_CWDSAVE
  69. SCREENSHOT_CWDSAVE = False
  70. SCREENSHOT_DIR = None
  71.  
  72. if localeInfo.IsEUROPE():
  73.     SCREENSHOT_CWDSAVE = True
  74.  
  75. if localeInfo.IsCIBN10():
  76.     SCREENSHOT_CWDSAVE = False
  77.     SCREENSHOT_DIR = "YT2W"
  78.  
  79. cameraDistance = 1550.0
  80. cameraPitch = 27.0
  81. cameraRotation = 0.0
  82. cameraHeight = 100.0
  83.  
  84. testAlignment = 0
  85. BPisLodaded = 0
  86.  
  87. class GameWindow(ui.ScriptWindow):
  88.     def __init__(self, stream):
  89.         ui.ScriptWindow.__init__(self, "GAME")
  90.         self.SetWindowName("game")
  91.         net.SetPhaseWindow(net.PHASE_WINDOW_GAME, self)
  92.         player.SetGameWindow(self)
  93.         self.utilizareTaste = time.clock() + 4
  94.  
  95.         self.quickSlotPageIndex = 0
  96.         self.switchbot = Bot()
  97.         self.switchbot.Hide()
  98.         self.lastPKModeSendedTime = 0
  99.         self.pressNumber = None
  100.  
  101.         self.guildWarQuestionDialog = None
  102.         self.interface = None
  103.         self.targetBoard = None
  104.         self.console = None
  105.         self.mapNameShower = None
  106.         self.affectShower = None
  107.         self.playerGauge = None
  108.  
  109.         self.stream=stream
  110.         self.interface = interfaceModule.Interface()
  111.         self.interface.MakeInterface()
  112.         self.interface.ShowDefaultWindows()
  113.  
  114.         self.curtain = uiPhaseCurtain.PhaseCurtain()
  115.         self.curtain.speed = 0.03
  116.         self.curtain.Hide()
  117.  
  118.         self.targetBoard = uiTarget.TargetBoard()
  119.         self.targetBoard.SetWhisperEvent(ui.__mem_func__(self.interface.OpenWhisperDialog))
  120.         self.targetBoard.Hide()
  121.  
  122.         self.console = consoleModule.ConsoleWindow()
  123.         self.console.BindGameClass(self)
  124.         self.console.SetConsoleSize(wndMgr.GetScreenWidth(), 200)
  125.         self.console.Hide()
  126.  
  127.         self.mapNameShower = uiMapNameShower.MapNameShower()
  128.         self.affectShower = uiAffectShower.AffectShower()
  129.         if app.ENABLE_TITLE_SYSTEM:
  130.             import title_system
  131.             self.wndTitleSystem = title_system.Title_System()
  132.            
  133.         if app.ENABLE_PVP_ADVANCED:
  134.             self.wndDuelGui = uiduel.Initializate()
  135.             self.wndDuelLive = uiduel.WindowLiveInformations()
  136.  
  137.         self.playerGauge = uiPlayerGauge.PlayerGauge(self)
  138.         self.playerGauge.Hide()
  139.  
  140.         self.__SetQuickSlotMode()
  141.  
  142.         self.__ServerCommand_Build()
  143.         self.__ProcessPreservedServerCommand()
  144.         self.uiprofile = uiprofile.ProfileWindoww()
  145.  
  146.     def __del__(self):
  147.         player.SetGameWindow(0)
  148.         net.ClearPhaseWindow(net.PHASE_WINDOW_GAME, self)
  149.         ui.ScriptWindow.__del__(self)
  150.  
  151.     def Open(self):
  152.         app.SetFrameSkip(1)
  153.  
  154.         self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
  155.  
  156.  
  157.         self.quickSlotPageIndex = 0
  158.         self.PickingCharacterIndex = -1
  159.         self.PickingItemIndex = -1
  160.         self.consoleEnable = False
  161.         self.isShowDebugInfo = False
  162.         self.ShowNameFlag = False
  163.  
  164.         self.enableXMasBoom = False
  165.         self.startTimeXMasBoom = 0.0
  166.         self.indexXMasBoom = 0
  167.  
  168.         global cameraDistance, cameraPitch, cameraRotation, cameraHeight
  169.  
  170.         app.SetCamera(cameraDistance, cameraPitch, cameraRotation, cameraHeight)
  171.  
  172.         constInfo.SET_DEFAULT_CAMERA_MAX_DISTANCE()
  173.         constInfo.SET_DEFAULT_CHRNAME_COLOR()
  174.         constInfo.SET_DEFAULT_FOG_LEVEL()
  175.         constInfo.SET_DEFAULT_CONVERT_EMPIRE_LANGUAGE_ENABLE()
  176.         constInfo.SET_DEFAULT_USE_ITEM_WEAPON_TABLE_ATTACK_BONUS()
  177.         constInfo.SET_DEFAULT_USE_SKILL_EFFECT_ENABLE()
  178.  
  179.         # TWO_HANDED_WEAPON_ATTACK_SPEED_UP
  180.         constInfo.SET_TWO_HANDED_WEAPON_ATT_SPEED_DECREASE_VALUE()
  181.         # END_OF_TWO_HANDED_WEAPON_ATTACK_SPEED_UP
  182.  
  183.         import event
  184.         event.SetLeftTimeString(localeInfo.UI_LEFT_TIME)
  185.  
  186.         textTail.EnablePKTitle(constInfo.PVPMODE_ENABLE)
  187.  
  188.         if constInfo.PVPMODE_TEST_ENABLE:
  189.             self.testPKMode = ui.TextLine()
  190.             self.testPKMode.SetFontName(localeInfo.UI_DEF_FONT)
  191.             self.testPKMode.SetPosition(0, 15)
  192.             self.testPKMode.SetWindowHorizontalAlignCenter()
  193.             self.testPKMode.SetHorizontalAlignCenter()
  194.             self.testPKMode.SetFeather()
  195.             self.testPKMode.SetOutline()
  196.             self.testPKMode.Show()
  197.  
  198.             self.testAlignment = ui.TextLine()
  199.             self.testAlignment.SetFontName(localeInfo.UI_DEF_FONT)
  200.             self.testAlignment.SetPosition(0, 35)
  201.             self.testAlignment.SetWindowHorizontalAlignCenter()
  202.             self.testAlignment.SetHorizontalAlignCenter()
  203.             self.testAlignment.SetFeather()
  204.             self.testAlignment.SetOutline()
  205.             self.testAlignment.Show()
  206.  
  207.         self.__BuildKeyDict()
  208.         self.__BuildDebugInfo()
  209.  
  210.         # PRIVATE_SHOP_PRICE_LIST
  211.         uiPrivateShopBuilder.Clear()
  212.         # END_OF_PRIVATE_SHOP_PRICE_LIST
  213.  
  214.         # UNKNOWN_UPDATE
  215.         exchange.InitTrading()
  216.         # END_OF_UNKNOWN_UPDATE
  217.  
  218.         if debugInfo.IsDebugMode():
  219.             self.ToggleDebugInfo()
  220.  
  221.         ## Sound
  222.         snd.SetMusicVolume(systemSetting.GetMusicVolume()*net.GetFieldMusicVolume())
  223.         snd.SetSoundVolume(systemSetting.GetSoundVolume())
  224.  
  225.         netFieldMusicFileName = net.GetFieldMusicFileName()
  226.         if netFieldMusicFileName:
  227.             snd.FadeInMusic("BGM/" + netFieldMusicFileName)
  228.         elif musicInfo.fieldMusic != "":                       
  229.             snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  230.  
  231.         self.__SetQuickSlotMode()
  232.         self.__SelectQuickPage(self.quickSlotPageIndex)
  233.  
  234.         self.SetFocus()
  235.         self.Show()
  236.         app.ShowCursor()
  237.  
  238.         net.SendEnterGamePacket()
  239.  
  240.         # START_GAME_ERROR_EXIT
  241.         try:
  242.             self.StartGame()
  243.         except:
  244.             import exception
  245.             exception.Abort("GameWindow.Open")
  246.         # END_OF_START_GAME_ERROR_EXIT
  247.        
  248.         # NPC가 큐브시스템으로 만들 수 있는 아이템들의 목록을 캐싱
  249.         # ex) cubeInformation[20383] = [ {"rewordVNUM": 72723, "rewordCount": 1, "materialInfo": "101,1&102,2", "price": 999 }, ... ]
  250.         self.cubeInformation = {}
  251.         self.currentCubeNPC = 0
  252.         if app.ENABLE_FOG_FIX:
  253.             if systemSetting.IsFogMode():
  254.                 background.SetEnvironmentFog(True)
  255.             else:
  256.                 background.SetEnvironmentFog(False)
  257.        
  258.     def Close(self):
  259.         self.Hide()
  260.         self.uiprofile.Close()
  261.  
  262.         global cameraDistance, cameraPitch, cameraRotation, cameraHeight
  263.         (cameraDistance, cameraPitch, cameraRotation, cameraHeight) = app.GetCamera()
  264.  
  265.         if musicInfo.fieldMusic != "":
  266.             snd.FadeOutMusic("BGM/"+ musicInfo.fieldMusic)
  267.  
  268.         self.onPressKeyDict = None
  269.         self.onClickKeyDict = None
  270.  
  271.         chat.Close()
  272.         snd.StopAllSound()
  273.         grp.InitScreenEffect()
  274.         chr.Destroy()
  275.         textTail.Clear()
  276.         quest.Clear()
  277.         background.Destroy()
  278.         guild.Destroy()
  279.         messenger.Destroy()
  280.         skill.ClearSkillData()
  281.         wndMgr.Unlock()
  282.         mouseModule.mouseController.DeattachObject()
  283.  
  284.         if self.guildWarQuestionDialog:
  285.             self.guildWarQuestionDialog.Close()
  286.  
  287.         self.guildNameBoard = None
  288.         self.partyRequestQuestionDialog = None
  289.         self.partyInviteQuestionDialog = None
  290.         self.guildInviteQuestionDialog = None
  291.         self.guildWarQuestionDialog = None
  292.         self.messengerAddFriendQuestion = None
  293.  
  294.         # UNKNOWN_UPDATE
  295.         self.itemDropQuestionDialog = None
  296.         # END_OF_UNKNOWN_UPDATE
  297.  
  298.         # QUEST_CONFIRM
  299.         self.confirmDialog = None
  300.         if app.TOURNAMENT_PVP_SYSTEM:
  301.             constInfo.TOURNAMENT_WINDOW_IS_SHOWED = 0
  302.         # END_OF_QUEST_CONFIRM
  303.  
  304.         self.PrintCoord = None
  305.         self.FrameRate = None
  306.         self.Pitch = None
  307.         self.Splat = None
  308.         self.TextureNum = None
  309.         self.ObjectNum = None
  310.         self.ViewDistance = None
  311.         self.PrintMousePos = None
  312.  
  313.         self.ClearDictionary()
  314.  
  315.         self.playerGauge = None
  316.         self.mapNameShower = None
  317.         self.affectShower = None
  318.  
  319.         if self.console:
  320.             self.console.BindGameClass(0)
  321.             self.console.Close()
  322.             self.console=None
  323.        
  324.         if app.ENABLE_PVP_ADVANCED:
  325.             if self.wndDuelLive.IsShow():
  326.                 self.wndDuelLive.Hide()
  327.                
  328.         if self.targetBoard:
  329.             self.targetBoard.Destroy()
  330.             self.targetBoard = None
  331.            
  332.         if app.ENABLE_TITLE_SYSTEM:
  333.             self.wndTitleSystem.Close()
  334.            
  335.         if self.interface:
  336.             self.interface.HideAllWindows()
  337.             self.interface.Close()
  338.             self.interface=None
  339.  
  340.         player.ClearSkillDict()
  341.         player.ResetCameraRotation()
  342.  
  343.         self.KillFocus()
  344.         app.HideCursor()
  345.  
  346.         print "---------------------------------------------------------------------------- CLOSE GAME WINDOW"
  347.  
  348.     def __BuildKeyDict(self):
  349.         onPressKeyDict = {}
  350.  
  351.         ##PressKey 는 누르고 있는 동안 계속 적용되는 키이다.
  352.        
  353.         ## 숫자 단축키 퀵슬롯에 이용된다.(이후 숫자들도 퀵 슬롯용 예약)
  354.         ## F12 는 클라 디버그용 키이므로 쓰지 않는 게 좋다.
  355.         onPressKeyDict[app.DIK_1]   = lambda : self.__PressNumKey(1)
  356.         onPressKeyDict[app.DIK_2]   = lambda : self.__PressNumKey(2)
  357.         onPressKeyDict[app.DIK_3]   = lambda : self.__PressNumKey(3)
  358.         onPressKeyDict[app.DIK_4]   = lambda : self.__PressNumKey(4)
  359.         onPressKeyDict[app.DIK_5]   = lambda : self.__PressNumKey(5)
  360.         onPressKeyDict[app.DIK_6]   = lambda : self.__PressNumKey(6)
  361.         onPressKeyDict[app.DIK_7]   = lambda : self.__PressNumKey(7)
  362.         onPressKeyDict[app.DIK_8]   = lambda : self.__PressNumKey(8)
  363.         onPressKeyDict[app.DIK_9]   = lambda : self.__PressNumKey(9)
  364.         onPressKeyDict[app.DIK_F1]  = lambda : self.__PressQuickSlot(4)
  365.         onPressKeyDict[app.DIK_F2]  = lambda : self.__PressQuickSlot(5)
  366.         onPressKeyDict[app.DIK_F3]  = lambda : self.__PressQuickSlot(6)
  367.         onPressKeyDict[app.DIK_F4]  = lambda : self.__PressQuickSlot(7)
  368.     #   onPressKeyDict[app.DIK_F6]  = lambda : self.__OpenProfile()
  369.     #   if app.ENABLE_TITLE_SYSTEM:
  370.     #       onPressKeyDict[app.DIK_F5]      = lambda : self.OpenTitleSystem()
  371.            
  372.         onPressKeyDict[app.DIK_LALT]        = lambda : self.ShowName()
  373.         onPressKeyDict[app.DIK_LCONTROL]    = lambda : self.ShowMouseImage()
  374.         onPressKeyDict[app.DIK_SYSRQ]       = lambda : self.SaveScreen()
  375.         onPressKeyDict[app.DIK_SPACE]       = lambda : self.StartAttack()
  376.  
  377.         #캐릭터 이동키
  378.         onPressKeyDict[app.DIK_UP]          = lambda : self.MoveUp()
  379.         onPressKeyDict[app.DIK_DOWN]        = lambda : self.MoveDown()
  380.         onPressKeyDict[app.DIK_LEFT]        = lambda : self.MoveLeft()
  381.         onPressKeyDict[app.DIK_RIGHT]       = lambda : self.MoveRight()
  382.         onPressKeyDict[app.DIK_W]           = lambda : self.MoveUp()
  383.         onPressKeyDict[app.DIK_S]           = lambda : self.MoveDown()
  384.         onPressKeyDict[app.DIK_A]           = lambda : self.MoveLeft()
  385.         onPressKeyDict[app.DIK_D]           = lambda : self.MoveRight()
  386.  
  387.         onPressKeyDict[app.DIK_E]           = lambda: app.RotateCamera(app.CAMERA_TO_POSITIVE)
  388.         onPressKeyDict[app.DIK_R]           = lambda: app.ZoomCamera(app.CAMERA_TO_NEGATIVE)
  389.         #onPressKeyDict[app.DIK_F]          = lambda: app.ZoomCamera(app.CAMERA_TO_POSITIVE)
  390.         onPressKeyDict[app.DIK_T]           = lambda: app.PitchCamera(app.CAMERA_TO_NEGATIVE)
  391.         onPressKeyDict[app.DIK_G]           = self.__PressGKey
  392.         onPressKeyDict[app.DIK_Q]           = self.__PressQKey
  393.  
  394.         onPressKeyDict[app.DIK_NUMPAD9]     = lambda: app.MovieResetCamera()
  395.         onPressKeyDict[app.DIK_NUMPAD4]     = lambda: app.MovieRotateCamera(app.CAMERA_TO_NEGATIVE)
  396.         onPressKeyDict[app.DIK_NUMPAD6]     = lambda: app.MovieRotateCamera(app.CAMERA_TO_POSITIVE)
  397.         onPressKeyDict[app.DIK_PGUP]        = lambda: app.MovieZoomCamera(app.CAMERA_TO_NEGATIVE)
  398.         onPressKeyDict[app.DIK_PGDN]        = lambda: app.MovieZoomCamera(app.CAMERA_TO_POSITIVE)
  399.         onPressKeyDict[app.DIK_NUMPAD8]     = lambda: app.MoviePitchCamera(app.CAMERA_TO_NEGATIVE)
  400.         onPressKeyDict[app.DIK_NUMPAD2]     = lambda: app.MoviePitchCamera(app.CAMERA_TO_POSITIVE)
  401.         onPressKeyDict[app.DIK_GRAVE]       = lambda : self.PickUpItem()
  402.         onPressKeyDict[app.DIK_Z]           = lambda : self.PickUpItem()
  403.         onPressKeyDict[app.DIK_C]           = lambda state = "STATUS": self.interface.ToggleCharacterWindow(state)
  404.         onPressKeyDict[app.DIK_V]           = lambda state = "SKILL": self.interface.ToggleCharacterWindow(state)
  405.         #onPressKeyDict[app.DIK_B]          = lambda state = "EMOTICON": self.interface.ToggleCharacterWindow(state)
  406.         onPressKeyDict[app.DIK_N]           = lambda state = "QUEST": self.interface.ToggleCharacterWindow(state)
  407.         onPressKeyDict[app.DIK_I]           = lambda : self.interface.ToggleInventoryWindow()
  408.         #onPressKeyDict[app.DIK_O]          = lambda : self.interface.ToggleDragonSoulWindowWithNoInfo()
  409.         onPressKeyDict[app.DIK_M]           = lambda : self.interface.PressMKey()
  410.         #onPressKeyDict[app.DIK_H]          = lambda : self.interface.OpenHelpWindow()
  411.         onPressKeyDict[app.DIK_ADD]         = lambda : self.interface.MiniMapScaleUp()
  412.         onPressKeyDict[app.DIK_SUBTRACT]    = lambda : self.interface.MiniMapScaleDown()
  413.         onPressKeyDict[app.DIK_L]           = lambda : self.interface.ToggleChatLogWindow()
  414.         onPressKeyDict[app.DIK_COMMA]       = lambda : self.ShowConsole()       # "`" key
  415.         onPressKeyDict[app.DIK_LSHIFT]      = lambda : self.__SetQuickPageMode()
  416.  
  417.         onPressKeyDict[app.DIK_J]           = lambda : self.__PressJKey()
  418.         onPressKeyDict[app.DIK_H]           = lambda : self.__PressHKey()
  419.         onPressKeyDict[app.DIK_B]           = lambda : self.__PressBKey()
  420.         onPressKeyDict[app.DIK_F]           = lambda : self.__PressFKey()
  421.  
  422.         # CUBE_TEST
  423.         #onPressKeyDict[app.DIK_K]          = lambda : self.interface.OpenCubeWindow()
  424.         # CUBE_TEST_END
  425.  
  426.         self.onPressKeyDict = onPressKeyDict
  427.  
  428.         onClickKeyDict = {}
  429.         onClickKeyDict[app.DIK_UP] = lambda : self.StopUp()
  430.         onClickKeyDict[app.DIK_DOWN] = lambda : self.StopDown()
  431.         onClickKeyDict[app.DIK_LEFT] = lambda : self.StopLeft()
  432.         onClickKeyDict[app.DIK_RIGHT] = lambda : self.StopRight()
  433.         onClickKeyDict[app.DIK_SPACE] = lambda : self.EndAttack()
  434.  
  435.         onClickKeyDict[app.DIK_W] = lambda : self.StopUp()
  436.         onClickKeyDict[app.DIK_S] = lambda : self.StopDown()
  437.         onClickKeyDict[app.DIK_A] = lambda : self.StopLeft()
  438.         onClickKeyDict[app.DIK_D] = lambda : self.StopRight()
  439.         onClickKeyDict[app.DIK_Q] = lambda: app.RotateCamera(app.CAMERA_STOP)
  440.         onClickKeyDict[app.DIK_E] = lambda: app.RotateCamera(app.CAMERA_STOP)
  441.         onClickKeyDict[app.DIK_R] = lambda: app.ZoomCamera(app.CAMERA_STOP)
  442.         onClickKeyDict[app.DIK_F] = lambda: app.ZoomCamera(app.CAMERA_STOP)
  443.         onClickKeyDict[app.DIK_T] = lambda: app.PitchCamera(app.CAMERA_STOP)
  444.         onClickKeyDict[app.DIK_G] = lambda: self.__ReleaseGKey()
  445.         onClickKeyDict[app.DIK_NUMPAD4] = lambda: app.MovieRotateCamera(app.CAMERA_STOP)
  446.         onClickKeyDict[app.DIK_NUMPAD6] = lambda: app.MovieRotateCamera(app.CAMERA_STOP)
  447.         onClickKeyDict[app.DIK_PGUP] = lambda: app.MovieZoomCamera(app.CAMERA_STOP)
  448.         onClickKeyDict[app.DIK_PGDN] = lambda: app.MovieZoomCamera(app.CAMERA_STOP)
  449.         onClickKeyDict[app.DIK_NUMPAD8] = lambda: app.MoviePitchCamera(app.CAMERA_STOP)
  450.         onClickKeyDict[app.DIK_NUMPAD2] = lambda: app.MoviePitchCamera(app.CAMERA_STOP)
  451.         onClickKeyDict[app.DIK_LALT] = lambda: self.HideName()
  452.         onClickKeyDict[app.DIK_LCONTROL] = lambda: self.HideMouseImage()
  453.         onClickKeyDict[app.DIK_LSHIFT] = lambda: self.__SetQuickSlotMode()
  454.  
  455.         #if constInfo.PVPMODE_ACCELKEY_ENABLE:
  456.         #   onClickKeyDict[app.DIK_B] = lambda: self.ChangePKMode()
  457.  
  458.         self.onClickKeyDict=onClickKeyDict
  459.  
  460.     def __PressNumKey(self,num):
  461.         if time.clock() >= self.utilizareTaste:
  462.             if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  463.                
  464.                 if num >= 1 and num <= 9:
  465.                     if(chrmgr.IsPossibleEmoticon(-1)):             
  466.                         chrmgr.SetEmoticon(-1,int(num)-1)
  467.                         net.SendEmoticon(int(num)-1)
  468.             else:
  469.                 if num >= 1 and num <= 4:
  470.                     self.pressNumber(num-1)
  471.         else:
  472.             chat.AppendChat(chat.CHAT_TYPE_INFO, "Mai asteapta cateva secunde pentru a putea folosi comanda.")
  473.  
  474.     def __ClickBKey(self):
  475.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  476.             return
  477.         else:
  478.             if constInfo.PVPMODE_ACCELKEY_ENABLE:
  479.                 self.ChangePKMode()
  480.  
  481.  
  482.     def __PressJKey(self):
  483.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  484.             if player.IsMountingHorse():
  485.                 net.SendChatPacket("/unmount")
  486.             else:
  487.                 #net.SendChatPacket("/user_horse_ride")
  488.                 if not uiPrivateShopBuilder.IsBuildingPrivateShop():
  489.                     for i in xrange(player.INVENTORY_PAGE_SIZE):
  490.                         if player.GetItemIndex(i) in (71114, 71116, 71118, 71120):
  491.                             net.SendItemUsePacket(i)
  492.                             break
  493.     def __PressHKey(self):
  494.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  495.             net.SendChatPacket("/user_horse_ride")
  496.         else:
  497.             self.interface.OpenHelpWindow()
  498.  
  499.     def __PressBKey(self):
  500.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  501.             net.SendChatPacket("/user_horse_back")
  502.         else:
  503.             state = "EMOTICON"
  504.             self.interface.ToggleCharacterWindow(state)
  505.  
  506.     def __PressFKey(self):
  507.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  508.             net.SendChatPacket("/user_horse_feed") 
  509.         else:
  510.             app.ZoomCamera(app.CAMERA_TO_POSITIVE)
  511.  
  512.     def __PressGKey(self):
  513.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  514.             net.SendChatPacket("/ride")
  515.         else:
  516.             if self.ShowNameFlag:
  517.                 self.interface.ToggleGuildWindow()
  518.             else:
  519.                 app.PitchCamera(app.CAMERA_TO_POSITIVE)
  520.  
  521.     def __ReleaseGKey(self):
  522.         app.PitchCamera(app.CAMERA_STOP)
  523.        
  524.     if app.ENABLE_TITLE_SYSTEM:
  525.         def OpenTitleSystem(self):     
  526.             self.wndTitleSystem.OpenWindow()
  527.            
  528.     def __PressQKey(self):
  529.         if app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL):
  530.             if 0==interfaceModule.IsQBHide:
  531.                 interfaceModule.IsQBHide = 1
  532.                 self.interface.HideAllQuestButton()
  533.             else:
  534.                 interfaceModule.IsQBHide = 0
  535.                 self.interface.ShowAllQuestButton()
  536.         else:
  537.             app.RotateCamera(app.CAMERA_TO_NEGATIVE)
  538.  
  539.     def __SetQuickSlotMode(self):
  540.         self.pressNumber=ui.__mem_func__(self.__PressQuickSlot)
  541.  
  542.     def __SetQuickPageMode(self):
  543.         self.pressNumber=ui.__mem_func__(self.__SelectQuickPage)
  544.  
  545.     def __PressQuickSlot(self, localSlotIndex):
  546.         if time.clock() >= self.utilizareTaste:
  547.             player.RequestUseLocalQuickSlot(localSlotIndex)
  548.         else:
  549.             chat.AppendChat(chat.CHAT_TYPE_INFO, "Mai asteapta cateva secunde pentru a putea folosi comanda.")
  550.        
  551.  
  552.     def __SelectQuickPage(self, pageIndex):
  553.         self.quickSlotPageIndex = pageIndex
  554.         player.SetQuickPage(pageIndex)
  555.  
  556.     def ToggleDebugInfo(self):
  557.         self.isShowDebugInfo = not self.isShowDebugInfo
  558.  
  559.         if self.isShowDebugInfo:
  560.             self.PrintCoord.Show()
  561.             self.FrameRate.Show()
  562.             self.Pitch.Show()
  563.             self.Splat.Show()
  564.             self.TextureNum.Show()
  565.             self.ObjectNum.Show()
  566.             self.ViewDistance.Show()
  567.             self.PrintMousePos.Show()
  568.         else:
  569.             self.PrintCoord.Hide()
  570.             self.FrameRate.Hide()
  571.             self.Pitch.Hide()
  572.             self.Splat.Hide()
  573.             self.TextureNum.Hide()
  574.             self.ObjectNum.Hide()
  575.             self.ViewDistance.Hide()
  576.             self.PrintMousePos.Hide()
  577.  
  578.     def __BuildDebugInfo(self):
  579.         ## Character Position Coordinate
  580.         self.PrintCoord = ui.TextLine()
  581.         self.PrintCoord.SetFontName(localeInfo.UI_DEF_FONT)
  582.         self.PrintCoord.SetPosition(wndMgr.GetScreenWidth() - 270, 0)
  583.        
  584.         ## Frame Rate
  585.         self.FrameRate = ui.TextLine()
  586.         self.FrameRate.SetFontName(localeInfo.UI_DEF_FONT)
  587.         self.FrameRate.SetPosition(wndMgr.GetScreenWidth() - 270, 20)
  588.  
  589.         ## Camera Pitch
  590.         self.Pitch = ui.TextLine()
  591.         self.Pitch.SetFontName(localeInfo.UI_DEF_FONT)
  592.         self.Pitch.SetPosition(wndMgr.GetScreenWidth() - 270, 40)
  593.  
  594.         ## Splat
  595.         self.Splat = ui.TextLine()
  596.         self.Splat.SetFontName(localeInfo.UI_DEF_FONT)
  597.         self.Splat.SetPosition(wndMgr.GetScreenWidth() - 270, 60)
  598.        
  599.         ##
  600.         self.PrintMousePos = ui.TextLine()
  601.         self.PrintMousePos.SetFontName(localeInfo.UI_DEF_FONT)
  602.         self.PrintMousePos.SetPosition(wndMgr.GetScreenWidth() - 270, 80)
  603.  
  604.         # TextureNum
  605.         self.TextureNum = ui.TextLine()
  606.         self.TextureNum.SetFontName(localeInfo.UI_DEF_FONT)
  607.         self.TextureNum.SetPosition(wndMgr.GetScreenWidth() - 270, 100)
  608.  
  609.         # 오브젝트 그리는 개수
  610.         self.ObjectNum = ui.TextLine()
  611.         self.ObjectNum.SetFontName(localeInfo.UI_DEF_FONT)
  612.         self.ObjectNum.SetPosition(wndMgr.GetScreenWidth() - 270, 120)
  613.  
  614.         # 시야거리
  615.         self.ViewDistance = ui.TextLine()
  616.         self.ViewDistance.SetFontName(localeInfo.UI_DEF_FONT)
  617.         self.ViewDistance.SetPosition(0, 0)
  618.  
  619.     def __NotifyError(self, msg):
  620.         chat.AppendChat(chat.CHAT_TYPE_INFO, msg)
  621.  
  622.     def ChangePKMode(self):
  623.  
  624.         if not app.IsPressed(app.DIK_LCONTROL):
  625.             return
  626.  
  627.         if player.GetStatus(player.LEVEL)<constInfo.PVPMODE_PROTECTED_LEVEL:
  628.             self.__NotifyError(localeInfo.OPTION_PVPMODE_PROTECT % (constInfo.PVPMODE_PROTECTED_LEVEL))
  629.             return
  630.  
  631.         curTime = app.GetTime()
  632.         if curTime - self.lastPKModeSendedTime < constInfo.PVPMODE_ACCELKEY_DELAY:
  633.             return
  634.  
  635.         self.lastPKModeSendedTime = curTime
  636.  
  637.         curPKMode = player.GetPKMode()
  638.         nextPKMode = curPKMode + 1
  639.         if nextPKMode == player.PK_MODE_PROTECT:
  640.             if 0 == player.GetGuildID():
  641.                 chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_CANNOT_SET_GUILD_MODE)
  642.                 nextPKMode = 0
  643.             else:
  644.                 nextPKMode = player.PK_MODE_GUILD
  645.  
  646.         elif nextPKMode == player.PK_MODE_MAX_NUM:
  647.             nextPKMode = 0
  648.  
  649.         net.SendChatPacket("/PKMode " + str(nextPKMode))
  650.         print "/PKMode " + str(nextPKMode)
  651.  
  652.     def OnChangePKMode(self):
  653.  
  654.         self.interface.OnChangePKMode()
  655.  
  656.         try:
  657.             self.__NotifyError(localeInfo.OPTION_PVPMODE_MESSAGE_DICT[player.GetPKMode()])
  658.         except KeyError:
  659.             print "UNKNOWN PVPMode[%d]" % (player.GetPKMode())
  660.  
  661.         if constInfo.PVPMODE_TEST_ENABLE:
  662.             curPKMode = player.GetPKMode()
  663.             alignment, grade = chr.testGetPKData()
  664.             self.pkModeNameDict = { 0 : "PEACE", 1 : "REVENGE", 2 : "FREE", 3 : "PROTECT", }
  665.             self.testPKMode.SetText("Current PK Mode : " + self.pkModeNameDict.get(curPKMode, "UNKNOWN"))
  666.             self.testAlignment.SetText("Current Alignment : " + str(alignment) + " (" + localeInfo.TITLE_NAME_LIST[grade] + ")")
  667.  
  668.     ###############################################################################################
  669.     ###############################################################################################
  670.     ## Game Callback Functions
  671.  
  672.     # Start
  673.     def StartGame(self):
  674.         self.RefreshInventory()
  675.         self.RefreshEquipment()
  676.         self.RefreshCharacter()
  677.         self.RefreshSkill()
  678.  
  679.     # Refresh
  680.     def CheckGameButton(self):
  681.         if self.interface:
  682.             self.interface.CheckGameButton()
  683.  
  684.     def RefreshAlignment(self):
  685.         self.interface.RefreshAlignment()
  686.        
  687.     if app._FIX_MINIMAP_BUG:
  688.         def BINARY_OnChannelPacket(self, channel):
  689.             import net
  690.             dict = {'name' : '|cFFFF0000|hPvPMetin2'} # Replace with your server name.
  691.             net.SetServerInfo((localeInfo.TEXT_CHANNEL % (dict['name'], channel)).strip())
  692.             if self.interface:
  693.                 self.interface.wndMiniMap.serverInfo.SetText(net.GetServerInfo())
  694.  
  695.     def RefreshStatus(self):
  696.         self.CheckGameButton()
  697.  
  698.         if self.interface:
  699.             self.interface.RefreshStatus()
  700.  
  701.         if self.playerGauge:
  702.             self.playerGauge.RefreshGauge()
  703.  
  704.     def RefreshStamina(self):
  705.         self.interface.RefreshStamina()
  706.  
  707.     def RefreshSkill(self):
  708.         self.CheckGameButton()
  709.         if self.interface:
  710.             self.interface.RefreshSkill()
  711.  
  712.     def RefreshQuest(self):
  713.         self.interface.RefreshQuest()
  714.  
  715.     def RefreshMessenger(self):
  716.         self.interface.RefreshMessenger()
  717.  
  718.     def RefreshGuildInfoPage(self):
  719.         self.interface.RefreshGuildInfoPage()
  720.  
  721.     def RefreshGuildBoardPage(self):
  722.         self.interface.RefreshGuildBoardPage()
  723.  
  724.     def RefreshGuildMemberPage(self):
  725.         self.interface.RefreshGuildMemberPage()
  726.  
  727.     def RefreshGuildMemberPageGradeComboBox(self):
  728.         self.interface.RefreshGuildMemberPageGradeComboBox()
  729.  
  730.     def RefreshGuildSkillPage(self):
  731.         self.interface.RefreshGuildSkillPage()
  732.  
  733.     def RefreshGuildGradePage(self):
  734.         self.interface.RefreshGuildGradePage()
  735.  
  736.     def RefreshMobile(self):
  737.         if self.interface:
  738.             self.interface.RefreshMobile()
  739.  
  740.     def OnMobileAuthority(self):
  741.         self.interface.OnMobileAuthority()
  742.  
  743.     def OnBlockMode(self, mode):
  744.         self.interface.OnBlockMode(mode)
  745.  
  746.     def OpenQuestWindow(self, skin, idx):
  747.         self.interface.OpenQuestWindow(skin, idx)
  748.        
  749.     if app._FIX_RELOAD_Q:
  750.         def HideAllQuestWindow(self):
  751.             self.interface.HideAllQuestWindow()
  752.  
  753.     def AskGuildName(self):
  754.  
  755.         guildNameBoard = uiCommon.InputDialog()
  756.         guildNameBoard.SetTitle(localeInfo.GUILD_NAME)
  757.         guildNameBoard.SetAcceptEvent(ui.__mem_func__(self.ConfirmGuildName))
  758.         guildNameBoard.SetCancelEvent(ui.__mem_func__(self.CancelGuildName))
  759.         guildNameBoard.Open()
  760.  
  761.         self.guildNameBoard = guildNameBoard
  762.  
  763.     def ConfirmGuildName(self):
  764.         guildName = self.guildNameBoard.GetText()
  765.         if not guildName:
  766.             return
  767.  
  768.         if net.IsInsultIn(guildName):
  769.             self.PopupMessage(localeInfo.GUILD_CREATE_ERROR_INSULT_NAME)
  770.             return
  771.  
  772.         net.SendAnswerMakeGuildPacket(guildName)
  773.         self.guildNameBoard.Close()
  774.         self.guildNameBoard = None
  775.         return True
  776.  
  777.     def CancelGuildName(self):
  778.         self.guildNameBoard.Close()
  779.         self.guildNameBoard = None
  780.         return True
  781.  
  782.     ## Refine
  783.     def PopupMessage(self, msg):
  784.         self.stream.popupWindow.Close()
  785.         self.stream.popupWindow.Open(msg, 0, localeInfo.UI_OK)
  786.  
  787.     def OpenRefineDialog(self, targetItemPos, nextGradeItemVnum, cost, prob, type=0):
  788.         self.interface.OpenRefineDialog(targetItemPos, nextGradeItemVnum, cost, prob, type)
  789.  
  790.     def AppendMaterialToRefineDialog(self, vnum, count):
  791.         self.interface.AppendMaterialToRefineDialog(vnum, count)
  792.  
  793.     def RunUseSkillEvent(self, slotIndex, coolTime):
  794.         self.interface.OnUseSkill(slotIndex, coolTime)
  795.  
  796.     def ClearAffects(self):
  797.         self.affectShower.ClearAffects()
  798.  
  799.     def SetAffect(self, affect):
  800.         self.affectShower.SetAffect(affect)
  801.  
  802.     def ResetAffect(self, affect):
  803.         self.affectShower.ResetAffect(affect)
  804.  
  805.     # UNKNOWN_UPDATE
  806.     def BINARY_NEW_AddAffect(self, type, pointIdx, value, duration):
  807.         self.affectShower.BINARY_NEW_AddAffect(type, pointIdx, value, duration)
  808.         if chr.NEW_AFFECT_DRAGON_SOUL_DECK1 == type or chr.NEW_AFFECT_DRAGON_SOUL_DECK2 == type:
  809.             self.interface.DragonSoulActivate(type - chr.NEW_AFFECT_DRAGON_SOUL_DECK1)
  810.         elif chr.NEW_AFFECT_DRAGON_SOUL_QUALIFIED == type:
  811.             self.BINARY_DragonSoulGiveQuilification()
  812.  
  813.     def BINARY_NEW_RemoveAffect(self, type, pointIdx):
  814.         self.affectShower.BINARY_NEW_RemoveAffect(type, pointIdx)
  815.         if chr.NEW_AFFECT_DRAGON_SOUL_DECK1 == type or chr.NEW_AFFECT_DRAGON_SOUL_DECK2 == type:
  816.             self.interface.DragonSoulDeactivate()
  817.            
  818.     def OpenProfileDialog(self,Name,Gander,Deeanh,Age,City,Country,Fcbook,Website,Skype,Note):
  819.         self.uiprofile.OpenWindow(Name,Gander,Deeanh,Age,City,Country,Fcbook,Website,Skype,Note)
  820.    
  821.     # END_OF_UNKNOWN_UPDATE
  822.  
  823.     def ActivateSkillSlot(self, slotIndex):
  824.         if self.interface:
  825.             self.interface.OnActivateSkill(slotIndex)
  826.  
  827.     def DeactivateSkillSlot(self, slotIndex):
  828.         if self.interface:
  829.             self.interface.OnDeactivateSkill(slotIndex)
  830.  
  831.     def RefreshEquipment(self):
  832.         if self.interface:
  833.             self.interface.RefreshInventory()
  834.  
  835.     def RefreshInventory(self):
  836.         if self.interface:
  837.             self.interface.RefreshInventory()
  838.  
  839.     def RefreshCharacter(self):
  840.         if self.interface:
  841.             self.interface.RefreshCharacter()
  842.  
  843.     def OnGameOver(self):
  844.         self.CloseTargetBoard()
  845.         self.OpenRestartDialog()
  846.  
  847.     def OpenRestartDialog(self):
  848.         self.interface.OpenRestartDialog()
  849.  
  850.     def ChangeCurrentSkill(self, skillSlotNumber):
  851.         self.interface.OnChangeCurrentSkill(skillSlotNumber)
  852.  
  853.     ## TargetBoard
  854.     def SetPCTargetBoard(self, vid, name):
  855.         self.targetBoard.Open(vid, name)
  856.        
  857.         if app.IsPressed(app.DIK_LCONTROL):
  858.            
  859.             if not player.IsSameEmpire(vid):
  860.                 return
  861.  
  862.             if player.IsMainCharacterIndex(vid):
  863.                 return     
  864.             elif chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(vid):
  865.                 return
  866.  
  867.             self.interface.OpenWhisperDialog(name)
  868.            
  869.  
  870.     def RefreshTargetBoardByVID(self, vid):
  871.         self.targetBoard.RefreshByVID(vid)
  872.  
  873.     def RefreshTargetBoardByName(self, name):
  874.         self.targetBoard.RefreshByName(name)
  875.        
  876.     def __RefreshTargetBoard(self):
  877.         self.targetBoard.Refresh()
  878.        
  879.     if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  880.         def SetHPTargetBoard(self, vid, hpPercentage, iMinHP, iMaxHP):
  881.             if vid != self.targetBoard.GetTargetVID():
  882.                 self.targetBoard.ResetTargetBoard()
  883.                 self.targetBoard.SetEnemyVID(vid)
  884.            
  885.             self.targetBoard.SetHP(hpPercentage, iMinHP, iMaxHP)
  886.             self.targetBoard.Show()
  887.     else:
  888.         def SetHPTargetBoard(self, vid, hpPercentage):
  889.             if vid != self.targetBoard.GetTargetVID():
  890.                 self.targetBoard.ResetTargetBoard()
  891.                 self.targetBoard.SetEnemyVID(vid)
  892.            
  893.             self.targetBoard.SetHP(hpPercentage)
  894.             self.targetBoard.Show()
  895.  
  896.     def CloseTargetBoardIfDifferent(self, vid):
  897.         if vid != self.targetBoard.GetTargetVID():
  898.             self.targetBoard.Close()
  899.  
  900.     def CloseTargetBoard(self):
  901.         self.targetBoard.Close()
  902.  
  903.     ## View Equipment
  904.     #def OpenEquipmentDialog(self, vid):
  905.     #   self.interface.OpenEquipmentDialog(vid)
  906.    
  907.     def OpenEquipmentDialog(self, vid):
  908.         if app.ENABLE_PVP_ADVANCED:
  909.             pvp.DUEL_IS_SHOW_EQUIP = 0
  910.             pvp.DUEL_SAVE_VID = (int(vid))
  911.  
  912.         self.interface.OpenEquipmentDialog(vid)
  913.  
  914.     def SetEquipmentDialogItem(self, vid, slotIndex, vnum, count):
  915.         self.interface.SetEquipmentDialogItem(vid, slotIndex, vnum, count)
  916.  
  917.     def SetEquipmentDialogSocket(self, vid, slotIndex, socketIndex, value):
  918.         self.interface.SetEquipmentDialogSocket(vid, slotIndex, socketIndex, value)
  919.  
  920.     def SetEquipmentDialogAttr(self, vid, slotIndex, attrIndex, type, value):
  921.         self.interface.SetEquipmentDialogAttr(vid, slotIndex, attrIndex, type, value)
  922.  
  923.     # SHOW_LOCAL_MAP_NAME
  924.     def ShowMapName(self, mapName, x, y):
  925.  
  926.         if self.mapNameShower:
  927.             self.mapNameShower.ShowMapName(mapName, x, y)
  928.  
  929.         if self.interface:
  930.             self.interface.SetMapName(mapName)
  931.     # END_OF_SHOW_LOCAL_MAP_NAME   
  932.  
  933.     def BINARY_OpenAtlasWindow(self):
  934.         self.interface.BINARY_OpenAtlasWindow()
  935.  
  936.     ## Chat
  937.     def OnRecvWhisper(self, mode, name, line):
  938.         if mode == chat.WHISPER_TYPE_GM:
  939.             self.interface.RegisterGameMasterName(name)
  940.         chat.AppendWhisper(mode, name, line)
  941.         self.interface.RecvWhisper(name)
  942.  
  943.     def OnRecvWhisperSystemMessage(self, mode, name, line):
  944.         chat.AppendWhisper(chat.WHISPER_TYPE_SYSTEM, name, line)
  945.         self.interface.RecvWhisper(name)
  946.  
  947.     def OnRecvWhisperError(self, mode, name, line):
  948.         if localeInfo.WHISPER_ERROR.has_key(mode):
  949.             chat.AppendWhisper(chat.WHISPER_TYPE_SYSTEM, name, localeInfo.WHISPER_ERROR[mode](name))
  950.         else:
  951.             chat.AppendWhisper(chat.WHISPER_TYPE_SYSTEM, name, "Whisper Unknown Error(mode=%d, name=%s)" % (mode, name))
  952.         self.interface.RecvWhisper(name)
  953.  
  954.     def RecvWhisper(self, name):
  955.         self.interface.RecvWhisper(name)
  956.  
  957.     def OnPickMoney(self, money):
  958.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.GAME_PICK_MONEY % (money))
  959.  
  960.     def OnShopError(self, type):
  961.         try:
  962.             self.PopupMessage(localeInfo.SHOP_ERROR_DICT[type])
  963.         except KeyError:
  964.             self.PopupMessage(localeInfo.SHOP_ERROR_UNKNOWN % (type))
  965.  
  966.     def OnSafeBoxError(self):
  967.         self.PopupMessage(localeInfo.SAFEBOX_ERROR)
  968.  
  969.     def OnFishingSuccess(self, isFish, fishName):
  970.         chat.AppendChatWithDelay(chat.CHAT_TYPE_INFO, localeInfo.FISHING_SUCCESS(isFish, fishName), 2000)
  971.  
  972.     # ADD_FISHING_MESSAGE
  973.     def OnFishingNotifyUnknown(self):
  974.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.FISHING_UNKNOWN)
  975.  
  976.     def OnFishingWrongPlace(self):
  977.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.FISHING_WRONG_PLACE)
  978.     # END_OF_ADD_FISHING_MESSAGE
  979.  
  980.     def OnFishingNotify(self, isFish, fishName):
  981.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.FISHING_NOTIFY(isFish, fishName))
  982.  
  983.     def OnFishingFailure(self):
  984.         chat.AppendChatWithDelay(chat.CHAT_TYPE_INFO, localeInfo.FISHING_FAILURE, 2000)
  985.  
  986.     def OnCannotPickItem(self):
  987.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.GAME_CANNOT_PICK_ITEM)
  988.  
  989.     # MINING
  990.     def OnCannotMining(self):
  991.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.GAME_CANNOT_MINING)
  992.     # END_OF_MINING
  993.  
  994.     def OnCannotUseSkill(self, vid, type):
  995.         if localeInfo.USE_SKILL_ERROR_TAIL_DICT.has_key(type):
  996.             textTail.RegisterInfoTail(vid, localeInfo.USE_SKILL_ERROR_TAIL_DICT[type])
  997.  
  998.         if localeInfo.USE_SKILL_ERROR_CHAT_DICT.has_key(type):
  999.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_SKILL_ERROR_CHAT_DICT[type])
  1000.  
  1001.     def OnCannotShotError(self, vid, type):
  1002.         textTail.RegisterInfoTail(vid, localeInfo.SHOT_ERROR_TAIL_DICT.get(type, localeInfo.SHOT_ERROR_UNKNOWN % (type)))
  1003.  
  1004.     ## PointReset
  1005.     def StartPointReset(self):
  1006.         self.interface.OpenPointResetDialog()
  1007.  
  1008.     ## Shop
  1009.     def StartShop(self, vid):
  1010.         self.interface.OpenShopDialog(vid)
  1011.  
  1012.     def EndShop(self):
  1013.         self.interface.CloseShopDialog()
  1014.  
  1015.     def RefreshShop(self):
  1016.         self.interface.RefreshShopDialog()
  1017.  
  1018.     def SetShopSellingPrice(self, Price):
  1019.         pass
  1020.  
  1021.     ## Exchange
  1022.     def StartExchange(self):
  1023.         self.interface.StartExchange()
  1024.     # [ADD TOP]
  1025.        
  1026.     def EndExchange(self):
  1027.         self.interface.EndExchange()
  1028.  
  1029.     def RefreshExchange(self):
  1030.         self.interface.RefreshExchange()
  1031.  
  1032.     ## Party
  1033.     def RecvPartyInviteQuestion(self, leaderVID, leaderName):
  1034.         partyInviteQuestionDialog = uiCommon.QuestionDialog()
  1035.         partyInviteQuestionDialog.SetText(leaderName + localeInfo.PARTY_DO_YOU_JOIN)
  1036.         partyInviteQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerPartyInvite(arg))
  1037.         partyInviteQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerPartyInvite(arg))
  1038.         partyInviteQuestionDialog.Open()
  1039.         partyInviteQuestionDialog.partyLeaderVID = leaderVID
  1040.         self.partyInviteQuestionDialog = partyInviteQuestionDialog
  1041.  
  1042.     def AnswerPartyInvite(self, answer):
  1043.  
  1044.         if not self.partyInviteQuestionDialog:
  1045.             return
  1046.  
  1047.         partyLeaderVID = self.partyInviteQuestionDialog.partyLeaderVID
  1048.  
  1049.         distance = player.GetCharacterDistance(partyLeaderVID)
  1050.         if distance < 0.0 or distance > 5000:
  1051.             answer = False
  1052.  
  1053.         net.SendPartyInviteAnswerPacket(partyLeaderVID, answer)
  1054.  
  1055.         self.partyInviteQuestionDialog.Close()
  1056.         self.partyInviteQuestionDialog = None
  1057.  
  1058.     def AddPartyMember(self, pid, name):
  1059.         self.interface.AddPartyMember(pid, name)
  1060.  
  1061.     def UpdatePartyMemberInfo(self, pid):
  1062.         self.interface.UpdatePartyMemberInfo(pid)
  1063.  
  1064.     def RemovePartyMember(self, pid):
  1065.         self.interface.RemovePartyMember(pid)
  1066.         self.__RefreshTargetBoard()
  1067.  
  1068.     def LinkPartyMember(self, pid, vid):
  1069.         self.interface.LinkPartyMember(pid, vid)
  1070.  
  1071.     def UnlinkPartyMember(self, pid):
  1072.         self.interface.UnlinkPartyMember(pid)
  1073.  
  1074.     def UnlinkAllPartyMember(self):
  1075.         self.interface.UnlinkAllPartyMember()
  1076.  
  1077.     def ExitParty(self):
  1078.         self.interface.ExitParty()
  1079.         self.RefreshTargetBoardByVID(self.targetBoard.GetTargetVID())
  1080.  
  1081.     def ChangePartyParameter(self, distributionMode):
  1082.         self.interface.ChangePartyParameter(distributionMode)
  1083.  
  1084.     ## Messenger
  1085.     def OnMessengerAddFriendQuestion(self, name):
  1086.         messengerAddFriendQuestion = uiCommon.QuestionDialog2()
  1087.         messengerAddFriendQuestion.SetText1(localeInfo.MESSENGER_DO_YOU_ACCEPT_ADD_FRIEND_1 % (name))
  1088.         messengerAddFriendQuestion.SetText2(localeInfo.MESSENGER_DO_YOU_ACCEPT_ADD_FRIEND_2)
  1089.         messengerAddFriendQuestion.SetAcceptEvent(ui.__mem_func__(self.OnAcceptAddFriend))
  1090.         messengerAddFriendQuestion.SetCancelEvent(ui.__mem_func__(self.OnDenyAddFriend))
  1091.         messengerAddFriendQuestion.Open()
  1092.         messengerAddFriendQuestion.name = name
  1093.         self.messengerAddFriendQuestion = messengerAddFriendQuestion
  1094.  
  1095.     def OnAcceptAddFriend(self):
  1096.         name = self.messengerAddFriendQuestion.name
  1097.         net.SendChatPacket("/messenger_auth y " + name)
  1098.         self.OnCloseAddFriendQuestionDialog()
  1099.         return True
  1100.  
  1101.     def OnDenyAddFriend(self):
  1102.         name = self.messengerAddFriendQuestion.name
  1103.         net.SendChatPacket("/messenger_auth n " + name)
  1104.         self.OnCloseAddFriendQuestionDialog()
  1105.         return True
  1106.  
  1107.     def OnCloseAddFriendQuestionDialog(self):
  1108.         self.messengerAddFriendQuestion.Close()
  1109.         self.messengerAddFriendQuestion = None
  1110.         return True
  1111.  
  1112.     ## SafeBox
  1113.     def OpenSafeboxWindow(self, size):
  1114.         self.interface.OpenSafeboxWindow(size)
  1115.  
  1116.     def RefreshSafebox(self):
  1117.         self.interface.RefreshSafebox()
  1118.  
  1119.     def RefreshSafeboxMoney(self):
  1120.         self.interface.RefreshSafeboxMoney()
  1121.  
  1122.     # ITEM_MALL
  1123.     def OpenMallWindow(self, size):
  1124.         self.interface.OpenMallWindow(size)
  1125.  
  1126.     def RefreshMall(self):
  1127.         self.interface.RefreshMall()
  1128.     # END_OF_ITEM_MALL
  1129.  
  1130.     ## Guild
  1131.     def RecvGuildInviteQuestion(self, guildID, guildName):
  1132.         guildInviteQuestionDialog = uiCommon.QuestionDialog()
  1133.         guildInviteQuestionDialog.SetText(guildName + localeInfo.GUILD_DO_YOU_JOIN)
  1134.         guildInviteQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerGuildInvite(arg))
  1135.         guildInviteQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerGuildInvite(arg))
  1136.         guildInviteQuestionDialog.Open()
  1137.         guildInviteQuestionDialog.guildID = guildID
  1138.         self.guildInviteQuestionDialog = guildInviteQuestionDialog
  1139.  
  1140.     def AnswerGuildInvite(self, answer):
  1141.  
  1142.         if not self.guildInviteQuestionDialog:
  1143.             return
  1144.  
  1145.         guildLeaderVID = self.guildInviteQuestionDialog.guildID
  1146.         net.SendGuildInviteAnswerPacket(guildLeaderVID, answer)
  1147.  
  1148.         self.guildInviteQuestionDialog.Close()
  1149.         self.guildInviteQuestionDialog = None
  1150.  
  1151.    
  1152.     def DeleteGuild(self):
  1153.         self.interface.DeleteGuild()
  1154.  
  1155.     ## Clock
  1156.     def ShowClock(self, second):
  1157.         self.interface.ShowClock(second)
  1158.  
  1159.     def HideClock(self):
  1160.         self.interface.HideClock()
  1161.  
  1162.     ## Emotion
  1163.     def BINARY_ActEmotion(self, emotionIndex):
  1164.         if self.interface.wndCharacter:
  1165.             self.interface.wndCharacter.ActEmotion(emotionIndex)
  1166.  
  1167.     ###############################################################################################
  1168.     ###############################################################################################
  1169.     ## Keyboard Functions
  1170.  
  1171.     def CheckFocus(self):
  1172.         if False == self.IsFocus():
  1173.             if True == self.interface.IsOpenChat():
  1174.                 self.interface.ToggleChat()
  1175.  
  1176.             self.SetFocus()
  1177.  
  1178.     def SaveScreen(self):
  1179.         print "save screen"
  1180.  
  1181.         # SCREENSHOT_CWDSAVE
  1182.         if SCREENSHOT_CWDSAVE:
  1183.             if not os.path.exists(os.getcwd()+os.sep+"screenshot"):
  1184.                 os.mkdir(os.getcwd()+os.sep+"screenshot")
  1185.  
  1186.             (succeeded, name) = grp.SaveScreenShotToPath(os.getcwd()+os.sep+"screenshot"+os.sep)
  1187.         elif SCREENSHOT_DIR:
  1188.             (succeeded, name) = grp.SaveScreenShot(SCREENSHOT_DIR)
  1189.         else:
  1190.             (succeeded, name) = grp.SaveScreenShot()
  1191.         # END_OF_SCREENSHOT_CWDSAVE
  1192.  
  1193.         if succeeded:
  1194.             pass
  1195.             """
  1196.             chat.AppendChat(chat.CHAT_TYPE_INFO, name + localeInfo.SCREENSHOT_SAVE1)
  1197.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SCREENSHOT_SAVE2)
  1198.             """
  1199.         else:
  1200.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SCREENSHOT_SAVE_FAILURE)
  1201.  
  1202.     def ShowConsole(self):
  1203.         if debugInfo.IsDebugMode() or True == self.consoleEnable:
  1204.             player.EndKeyWalkingImmediately()
  1205.             self.console.OpenWindow()
  1206.  
  1207.     def ShowName(self):
  1208.         self.ShowNameFlag = True
  1209.         self.playerGauge.EnableShowAlways()
  1210.         player.SetQuickPage(self.quickSlotPageIndex+1)
  1211.  
  1212.     # ADD_ALWAYS_SHOW_NAME
  1213.     def __IsShowName(self):
  1214.  
  1215.         if systemSetting.IsAlwaysShowName():
  1216.             return True
  1217.  
  1218.         if self.ShowNameFlag:
  1219.             return True
  1220.  
  1221.         return False
  1222.     # END_OF_ADD_ALWAYS_SHOW_NAME
  1223.    
  1224.     def HideName(self):
  1225.         self.ShowNameFlag = False
  1226.         self.playerGauge.DisableShowAlways()
  1227.         player.SetQuickPage(self.quickSlotPageIndex)
  1228.  
  1229.     def ShowMouseImage(self):
  1230.         self.interface.ShowMouseImage()
  1231.  
  1232.     def HideMouseImage(self):
  1233.         self.interface.HideMouseImage()
  1234.  
  1235.     def StartAttack(self):
  1236.         player.SetAttackKeyState(True)
  1237.  
  1238.     def EndAttack(self):
  1239.         player.SetAttackKeyState(False)
  1240.  
  1241.     def MoveUp(self):
  1242.         player.SetSingleDIKKeyState(app.DIK_UP, True)
  1243.  
  1244.     def MoveDown(self):
  1245.         player.SetSingleDIKKeyState(app.DIK_DOWN, True)
  1246.  
  1247.     def MoveLeft(self):
  1248.         player.SetSingleDIKKeyState(app.DIK_LEFT, True)
  1249.  
  1250.     def MoveRight(self):
  1251.         player.SetSingleDIKKeyState(app.DIK_RIGHT, True)
  1252.  
  1253.     def StopUp(self):
  1254.         player.SetSingleDIKKeyState(app.DIK_UP, False)
  1255.  
  1256.     def StopDown(self):
  1257.         player.SetSingleDIKKeyState(app.DIK_DOWN, False)
  1258.  
  1259.     def StopLeft(self):
  1260.         player.SetSingleDIKKeyState(app.DIK_LEFT, False)
  1261.  
  1262.     def StopRight(self):
  1263.         player.SetSingleDIKKeyState(app.DIK_RIGHT, False)
  1264.  
  1265.     def PickUpItem(self):
  1266.         player.PickCloseItem()
  1267.  
  1268.     ###############################################################################################
  1269.     ###############################################################################################
  1270.     ## Event Handler
  1271.  
  1272.     def OnKeyDown(self, key):
  1273.         if self.interface.wndWeb and self.interface.wndWeb.IsShow():
  1274.             return
  1275.  
  1276.         constInfo.SET_ITEM_DROP_QUESTION_DIALOG_STATUS(0)
  1277.  
  1278.         try:
  1279.             self.onPressKeyDict[key]()
  1280.         except KeyError:
  1281.             pass
  1282.         except:
  1283.             raise
  1284.  
  1285.         return True
  1286.  
  1287.     def OnKeyUp(self, key):
  1288.         try:
  1289.             self.onClickKeyDict[key]()
  1290.         except KeyError:
  1291.             pass
  1292.         except:
  1293.             raise
  1294.  
  1295.         return True
  1296.  
  1297.     def OnMouseLeftButtonDown(self):
  1298.         if self.interface.BUILD_OnMouseLeftButtonDown():
  1299.             return
  1300.  
  1301.         if mouseModule.mouseController.isAttached():
  1302.             self.CheckFocus()
  1303.         else:
  1304.             hyperlink = ui.GetHyperlink()
  1305.             if hyperlink:
  1306.                 return
  1307.             else:
  1308.                 self.CheckFocus()
  1309.                 player.SetMouseState(player.MBT_LEFT, player.MBS_PRESS);
  1310.  
  1311.         return True
  1312.  
  1313.     def OnMouseLeftButtonUp(self):
  1314.  
  1315.         if self.interface.BUILD_OnMouseLeftButtonUp():
  1316.             return
  1317.  
  1318.         if mouseModule.mouseController.isAttached():
  1319.  
  1320.             attachedType = mouseModule.mouseController.GetAttachedType()
  1321.             attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  1322.             attachedItemSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  1323.             attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
  1324.  
  1325.             ## QuickSlot
  1326.             if player.SLOT_TYPE_QUICK_SLOT == attachedType:
  1327.                 player.RequestDeleteGlobalQuickSlot(attachedItemSlotPos)
  1328.  
  1329.             ## Inventory
  1330.             elif player.SLOT_TYPE_INVENTORY == attachedType:
  1331.  
  1332.                 if player.ITEM_MONEY == attachedItemIndex:
  1333.                     self.__PutMoney(attachedType, attachedItemCount, self.PickingCharacterIndex)
  1334.                 else:
  1335.                     self.__PutItem(attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount, self.PickingCharacterIndex)
  1336.  
  1337.             ## DragonSoul
  1338.             elif player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedType:
  1339.                 self.__PutItem(attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount, self.PickingCharacterIndex)
  1340.            
  1341.             mouseModule.mouseController.DeattachObject()
  1342.  
  1343.         else:
  1344.             hyperlink = ui.GetHyperlink()
  1345.             if hyperlink:
  1346.                 if app.IsPressed(app.DIK_LALT):
  1347.                     link = chat.GetLinkFromHyperlink(hyperlink)
  1348.                     ime.PasteString(link)
  1349.                 else:
  1350.                     self.interface.MakeHyperlinkTooltip(hyperlink)
  1351.                 return
  1352.             else:
  1353.                 player.SetMouseState(player.MBT_LEFT, player.MBS_CLICK)
  1354.  
  1355.         #player.EndMouseWalking()
  1356.         return True
  1357.  
  1358.     def __PutItem(self, attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount, dstChrID):
  1359.         if player.SLOT_TYPE_INVENTORY == attachedType or player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedType:
  1360.             attachedInvenType = player.SlotTypeToInvenType(attachedType)
  1361.             if True == chr.HasInstance(self.PickingCharacterIndex) and player.GetMainCharacterIndex() != dstChrID:
  1362.                 if player.IsEquipmentSlot(attachedItemSlotPos):
  1363.                     self.stream.popupWindow.Close()
  1364.                     self.stream.popupWindow.Open(localeInfo.EXCHANGE_FAILURE_EQUIP_ITEM, 0, localeInfo.UI_OK)
  1365.                 else:
  1366.                     if chr.IsNPC(dstChrID):
  1367.                         net.SendGiveItemPacket(dstChrID, attachedInvenType, attachedItemSlotPos, attachedItemCount)
  1368.                     else:
  1369.                         net.SendExchangeStartPacket(dstChrID)
  1370.                         net.SendExchangeItemAddPacket(attachedInvenType, attachedItemSlotPos, 0)
  1371.             else:
  1372.                 self.__DropItem(attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount)
  1373.  
  1374.     def __PutMoney(self, attachedType, attachedMoney, dstChrID):
  1375.         if True == chr.HasInstance(dstChrID) and player.GetMainCharacterIndex() != dstChrID:
  1376.             net.SendExchangeStartPacket(dstChrID)
  1377.             net.SendExchangeElkAddPacket(attachedMoney)
  1378.         else:
  1379.             self.__DropMoney(attachedType, attachedMoney)
  1380.  
  1381.     def __DropMoney(self, attachedType, attachedMoney):
  1382.         # PRIVATESHOP_DISABLE_ITEM_DROP - 개인상점 열고 있는 동안 아이템 버림 방지
  1383.         if uiPrivateShopBuilder.IsBuildingPrivateShop():           
  1384.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DROP_ITEM_FAILURE_PRIVATE_SHOP)
  1385.             return
  1386.         # END_OF_PRIVATESHOP_DISABLE_ITEM_DROP
  1387.        
  1388.         if attachedMoney>=1000:
  1389.             self.stream.popupWindow.Close()
  1390.             self.stream.popupWindow.Open(localeInfo.DROP_MONEY_FAILURE_1000_OVER, 0, localeInfo.UI_OK)
  1391.             return
  1392.  
  1393.         itemDropQuestionDialog = uiCommon.QuestionDialogItem()
  1394.         itemDropQuestionDialog.SetText(localeInfo.DO_YOU_DROP_MONEY % (attachedMoney))
  1395.         itemDropQuestionDialog.SetAcceptEvent(lambda arg=True: self.RequestDropItem(arg))
  1396.         itemDropQuestionDialog.SetDestroyEvent(lambda arg=TRUE: self.RequestDestroyItem(arg))
  1397.         itemDropQuestionDialog.SetCancelEvent(lambda arg=False: self.RequestDropItem(arg))
  1398.         itemDropQuestionDialog.Open()
  1399.         itemDropQuestionDialog.dropType = attachedType
  1400.         itemDropQuestionDialog.dropCount = attachedMoney
  1401.         itemDropQuestionDialog.dropNumber = player.ITEM_MONEY
  1402.         self.itemDropQuestionDialog = itemDropQuestionDialog
  1403.  
  1404.     def __DropItem(self, attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount):
  1405.         # PRIVATESHOP_DISABLE_ITEM_DROP - 개인상점 열고 있는 동안 아이템 버림 방지
  1406.         if uiPrivateShopBuilder.IsBuildingPrivateShop():           
  1407.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DROP_ITEM_FAILURE_PRIVATE_SHOP)
  1408.             return
  1409.         # END_OF_PRIVATESHOP_DISABLE_ITEM_DROP
  1410.        
  1411.         if player.SLOT_TYPE_INVENTORY == attachedType and player.IsEquipmentSlot(attachedItemSlotPos):
  1412.             self.stream.popupWindow.Close()
  1413.             self.stream.popupWindow.Open(localeInfo.DROP_ITEM_FAILURE_EQUIP_ITEM, 0, localeInfo.UI_OK)
  1414.  
  1415.         else:
  1416.             if player.SLOT_TYPE_INVENTORY == attachedType:
  1417.                 dropItemIndex = player.GetItemIndex(attachedItemSlotPos)
  1418.  
  1419.                 item.SelectItem(dropItemIndex)
  1420.                 dropItemName = item.GetItemName()
  1421.  
  1422.                 ## Question Text
  1423.                 questionText = localeInfo.HOW_MANY_ITEM_DO_YOU_DROP(dropItemName, attachedItemCount)
  1424.  
  1425.                 ## Dialog
  1426.                 itemDropQuestionDialog = uiCommon.QuestionDialog()
  1427.                 itemDropQuestionDialog.SetText(questionText)
  1428.                 itemDropQuestionDialog.SetAcceptEvent(lambda arg=True: self.RequestDropItem(arg))
  1429.                 itemDropQuestionDialog.SetCancelEvent(lambda arg=False: self.RequestDropItem(arg))
  1430.                 itemDropQuestionDialog.Open()
  1431.                 itemDropQuestionDialog.dropType = attachedType
  1432.                 itemDropQuestionDialog.dropNumber = attachedItemSlotPos
  1433.                 itemDropQuestionDialog.dropCount = attachedItemCount
  1434.                 self.itemDropQuestionDialog = itemDropQuestionDialog
  1435.  
  1436.                 constInfo.SET_ITEM_DROP_QUESTION_DIALOG_STATUS(1)
  1437.             elif player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedType:
  1438.                 dropItemIndex = player.GetItemIndex(player.DRAGON_SOUL_INVENTORY, attachedItemSlotPos)
  1439.  
  1440.                 item.SelectItem(dropItemIndex)
  1441.                 dropItemName = item.GetItemName()
  1442.  
  1443.                 ## Question Text
  1444.                 questionText = localeInfo.HOW_MANY_ITEM_DO_YOU_DROP(dropItemName, attachedItemCount)
  1445.  
  1446.                 ## Dialog
  1447.                 itemDropQuestionDialog = uiCommon.QuestionDialog()
  1448.                 itemDropQuestionDialog.SetText(questionText)
  1449.                 itemDropQuestionDialog.SetAcceptEvent(lambda arg=True: self.RequestDropItem(arg))
  1450.                 itemDropQuestionDialog.SetCancelEvent(lambda arg=False: self.RequestDropItem(arg))
  1451.                 itemDropQuestionDialog.Open()
  1452.                 itemDropQuestionDialog.dropType = attachedType
  1453.                 itemDropQuestionDialog.dropNumber = attachedItemSlotPos
  1454.                 itemDropQuestionDialog.dropCount = attachedItemCount
  1455.                 self.itemDropQuestionDialog = itemDropQuestionDialog
  1456.  
  1457.                 constInfo.SET_ITEM_DROP_QUESTION_DIALOG_STATUS(1)
  1458.  
  1459.     def RequestDropItem(self, answer):
  1460.         if not self.itemDropQuestionDialog:
  1461.             return
  1462.  
  1463.         if answer:
  1464.             dropType = self.itemDropQuestionDialog.dropType
  1465.             dropCount = self.itemDropQuestionDialog.dropCount
  1466.             dropNumber = self.itemDropQuestionDialog.dropNumber
  1467.  
  1468.             if player.SLOT_TYPE_INVENTORY == dropType:
  1469.                 if dropNumber == player.ITEM_MONEY:
  1470.                     net.SendGoldDropPacketNew(dropCount)
  1471.                     snd.PlaySound("sound/ui/money.wav")
  1472.                 else:
  1473.                     # PRIVATESHOP_DISABLE_ITEM_DROP
  1474.                     self.__SendDropItemPacket(dropNumber, dropCount)
  1475.                     # END_OF_PRIVATESHOP_DISABLE_ITEM_DROP
  1476.             elif player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == dropType:
  1477.                     # PRIVATESHOP_DISABLE_ITEM_DROP
  1478.                     self.__SendDropItemPacket(dropNumber, dropCount, player.DRAGON_SOUL_INVENTORY)
  1479.                     # END_OF_PRIVATESHOP_DISABLE_ITEM_DROP
  1480.  
  1481.         self.itemDropQuestionDialog.Close()
  1482.         self.itemDropQuestionDialog = None
  1483.  
  1484.         constInfo.SET_ITEM_DROP_QUESTION_DIALOG_STATUS(0)
  1485.        
  1486.     def RequestDestroyItem(self, answer):
  1487.         if not self.itemDropQuestionDialog:
  1488.             return
  1489.         if answer:
  1490.             dropType = self.itemDropQuestionDialog.dropType
  1491.             dropNumber = self.itemDropQuestionDialog.dropNumber
  1492.             if player.SLOT_TYPE_INVENTORY == dropType:
  1493.                 if dropNumber == player.ITEM_MONEY:
  1494.                     return
  1495.                 else:
  1496.                     self.__SendDestroyItemPacket(dropNumber)
  1497.    
  1498.         self.itemDropQuestionDialog.Close()
  1499.         self.itemDropQuestionDialog = None
  1500.         constInfo.SET_ITEM_DROP_QUESTION_DIALOG_STATUS(0)
  1501.     # PRIVATESHOP_DISABLE_ITEM_DROP
  1502.     def __SendDropItemPacket(self, itemVNum, itemCount, itemInvenType = player.INVENTORY):
  1503.         if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1504.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DROP_ITEM_FAILURE_PRIVATE_SHOP)
  1505.             return
  1506.  
  1507.         net.SendItemDropPacketNew(itemInvenType, itemVNum, itemCount)
  1508.     # END_OF_PRIVATESHOP_DISABLE_ITEM_DROP
  1509.     def __SendDestroyItemPacket(self, itemVNum, itemInvenType = player.INVENTORY):
  1510.         if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1511.             chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DROP_ITEM_FAILURE_PRIVATE_SHOP)
  1512.             return
  1513.         net.SendItemDestroyPacket(itemVNum)
  1514.     def OnMouseRightButtonDown(self):
  1515.  
  1516.         self.CheckFocus()
  1517.  
  1518.         if True == mouseModule.mouseController.isAttached():
  1519.             mouseModule.mouseController.DeattachObject()
  1520.  
  1521.         else:
  1522.             player.SetMouseState(player.MBT_RIGHT, player.MBS_PRESS)
  1523.  
  1524.         return True
  1525.  
  1526.     def OnMouseRightButtonUp(self):
  1527.         if True == mouseModule.mouseController.isAttached():
  1528.             return True
  1529.  
  1530.         player.SetMouseState(player.MBT_RIGHT, player.MBS_CLICK)
  1531.         return True
  1532.  
  1533.     def OnMouseMiddleButtonDown(self):
  1534.         player.SetMouseMiddleButtonState(player.MBS_PRESS)
  1535.  
  1536.     def OnMouseMiddleButtonUp(self):
  1537.         player.SetMouseMiddleButtonState(player.MBS_CLICK)
  1538.  
  1539.     def OnUpdate(self):
  1540.         app.UpdateGame()
  1541.        
  1542.         if self.mapNameShower.IsShow():
  1543.             self.mapNameShower.Update()
  1544.  
  1545.         if self.isShowDebugInfo:
  1546.             self.UpdateDebugInfo()
  1547.  
  1548.         if self.enableXMasBoom:
  1549.             self.__XMasBoom_Update()
  1550.  
  1551.         self.interface.BUILD_OnUpdate()
  1552.        
  1553.         if app.ENABLE_PVP_ADVANCED:
  1554.             if pvp.DUEL_IS_SHOW_EQUIP == int(1):
  1555.                 self.interface.CloseEquipmentDialog(int(pvp.DUEL_SAVE_VID))
  1556.                
  1557.         if app.ENABLE_TITLE_SYSTEM:    
  1558.             self.wndTitleSystem.OnUpdate() 
  1559.        
  1560.        
  1561.     def UpdateDebugInfo(self):
  1562.         #
  1563.         # 캐릭터 좌표 및 FPS 출력
  1564.         (x, y, z) = player.GetMainCharacterPosition()
  1565.         nUpdateTime = app.GetUpdateTime()
  1566.         nUpdateFPS = app.GetUpdateFPS()
  1567.         nRenderFPS = app.GetRenderFPS()
  1568.         nFaceCount = app.GetFaceCount()
  1569.         fFaceSpeed = app.GetFaceSpeed()
  1570.         nST=background.GetRenderShadowTime()
  1571.         (fAveRT, nCurRT) =  app.GetRenderTime()
  1572.         (iNum, fFogStart, fFogEnd, fFarCilp) = background.GetDistanceSetInfo()
  1573.         (iPatch, iSplat, fSplatRatio, sTextureNum) = background.GetRenderedSplatNum()
  1574.  
  1575.     def OnRender(self):
  1576.         app.RenderGame()
  1577.        
  1578.         if self.console.Console.collision:
  1579.             background.RenderCollision()
  1580.             chr.RenderCollision()
  1581.  
  1582.         (x, y) = app.GetCursorPosition()
  1583.  
  1584.         ########################
  1585.         # Picking
  1586.         ########################
  1587.         textTail.UpdateAllTextTail()
  1588.  
  1589.         if True == wndMgr.IsPickedWindow(self.hWnd):
  1590.  
  1591.             self.PickingCharacterIndex = chr.Pick()
  1592.  
  1593.             if -1 != self.PickingCharacterIndex:
  1594.                 textTail.ShowCharacterTextTail(self.PickingCharacterIndex)
  1595.             if 0 != self.targetBoard.GetTargetVID():
  1596.                 textTail.ShowCharacterTextTail(self.targetBoard.GetTargetVID())
  1597.  
  1598.             # ADD_ALWAYS_SHOW_NAME
  1599.             if not self.__IsShowName():
  1600.                 self.PickingItemIndex = item.Pick()
  1601.                 if -1 != self.PickingItemIndex:
  1602.                     textTail.ShowItemTextTail(self.PickingItemIndex)
  1603.             # END_OF_ADD_ALWAYS_SHOW_NAME
  1604.            
  1605.         ## Show all name in the range
  1606.        
  1607.         # ADD_ALWAYS_SHOW_NAME
  1608.         if self.__IsShowName():
  1609.             textTail.ShowAllTextTail()
  1610.             self.PickingItemIndex = textTail.Pick(x, y)
  1611.         # END_OF_ADD_ALWAYS_SHOW_NAME
  1612.  
  1613.         textTail.UpdateShowingTextTail()
  1614.         textTail.ArrangeTextTail()
  1615.         if -1 != self.PickingItemIndex:
  1616.             textTail.SelectItemName(self.PickingItemIndex)
  1617.  
  1618.         grp.PopState()
  1619.         grp.SetInterfaceRenderState()
  1620.  
  1621.         textTail.Render()
  1622.         textTail.HideAllTextTail()
  1623.  
  1624.     def OnPressEscapeKey(self):
  1625.         if app.TARGET == app.GetCursor():
  1626.             app.SetCursor(app.NORMAL)
  1627.  
  1628.         elif True == mouseModule.mouseController.isAttached():
  1629.             mouseModule.mouseController.DeattachObject()
  1630.  
  1631.         else:
  1632.             self.interface.OpenSystemDialog()
  1633.  
  1634.         return True
  1635.  
  1636.     def OnIMEReturn(self):
  1637.         if app.IsPressed(app.DIK_LSHIFT):
  1638.             self.interface.OpenWhisperDialogWithoutTarget()
  1639.         else:
  1640.             self.interface.ToggleChat()
  1641.         return True
  1642.  
  1643.     def OnPressExitKey(self):
  1644.         self.interface.ToggleSystemDialog()
  1645.         return True
  1646.  
  1647.     ## BINARY CALLBACK
  1648.     ######################################################################################
  1649.    
  1650.     # WEDDING
  1651.     def BINARY_LoverInfo(self, name, lovePoint):
  1652.         if self.interface.wndMessenger:
  1653.             self.interface.wndMessenger.OnAddLover(name, lovePoint)
  1654.         if self.affectShower:
  1655.             self.affectShower.SetLoverInfo(name, lovePoint)
  1656.  
  1657.     def BINARY_UpdateLovePoint(self, lovePoint):
  1658.         if self.interface.wndMessenger:
  1659.             self.interface.wndMessenger.OnUpdateLovePoint(lovePoint)
  1660.         if self.affectShower:
  1661.             self.affectShower.OnUpdateLovePoint(lovePoint)
  1662.     # END_OF_WEDDING
  1663.        
  1664.     if app.ENABLE_SEND_TARGET_INFO:
  1665.         def BINARY_AddTargetMonsterDropInfo(self, raceNum, itemVnum, itemCount):
  1666.             if not raceNum in constInfo.MONSTER_INFO_DATA:
  1667.                 constInfo.MONSTER_INFO_DATA.update({raceNum : {}})
  1668.                 constInfo.MONSTER_INFO_DATA[raceNum].update({"items" : []})
  1669.             curList = constInfo.MONSTER_INFO_DATA[raceNum]["items"]
  1670.  
  1671.             isUpgradeable = False
  1672.             isMetin = False
  1673.             item.SelectItem(itemVnum)
  1674.             if item.GetItemType() == item.ITEM_TYPE_WEAPON or item.GetItemType() == item.ITEM_TYPE_ARMOR:
  1675.                 isUpgradeable = True
  1676.             elif item.GetItemType() == item.ITEM_TYPE_METIN:
  1677.                 isMetin = True
  1678.  
  1679.             for curItem in curList:
  1680.                 if isUpgradeable:
  1681.                     if curItem.has_key("vnum_list") and curItem["vnum_list"][0] / 10 * 10 == itemVnum / 10 * 10:
  1682.                         if not (itemVnum in curItem["vnum_list"]):
  1683.                             curItem["vnum_list"].append(itemVnum)
  1684.                         return
  1685.                 elif isMetin:
  1686.                     if curItem.has_key("vnum_list"):
  1687.                         baseVnum = curItem["vnum_list"][0]
  1688.                     if curItem.has_key("vnum_list") and (baseVnum - baseVnum%1000) == (itemVnum - itemVnum%1000):
  1689.                         if not (itemVnum in curItem["vnum_list"]):
  1690.                             curItem["vnum_list"].append(itemVnum)
  1691.                         return
  1692.                 else:
  1693.                     if curItem.has_key("vnum") and curItem["vnum"] == itemVnum and curItem["count"] == itemCount:
  1694.                         return
  1695.  
  1696.             if isUpgradeable or isMetin:
  1697.                 curList.append({"vnum_list":[itemVnum], "count":itemCount})
  1698.             else:
  1699.                 curList.append({"vnum":itemVnum, "count":itemCount})
  1700.  
  1701.         def BINARY_RefreshTargetMonsterDropInfo(self, raceNum):
  1702.             self.targetBoard.RefreshMonsterInfoBoard()
  1703.  
  1704.     # QUEST_CONFIRM
  1705.     def BINARY_OnQuestConfirm(self, msg, timeout, pid):
  1706.         confirmDialog = uiCommon.QuestionDialogWithTimeLimit()
  1707.         confirmDialog.Open(msg, timeout)
  1708.         confirmDialog.SetAcceptEvent(lambda answer=True, pid=pid: net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
  1709.         confirmDialog.SetCancelEvent(lambda answer=False, pid=pid: net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
  1710.         self.confirmDialog = confirmDialog
  1711.     # END_OF_QUEST_CONFIRM
  1712.  
  1713.     # GIFT command
  1714.     def Gift_Show(self):
  1715.         self.interface.ShowGift()
  1716.  
  1717.     # CUBE
  1718.     def BINARY_Cube_Open(self, npcVNUM):
  1719.         self.currentCubeNPC = npcVNUM
  1720.        
  1721.         self.interface.OpenCubeWindow()
  1722.  
  1723.        
  1724.         if npcVNUM not in self.cubeInformation:
  1725.             net.SendChatPacket("/cube r_info")
  1726.         else:
  1727.             cubeInfoList = self.cubeInformation[npcVNUM]
  1728.            
  1729.             i = 0
  1730.             for cubeInfo in cubeInfoList:                              
  1731.                 self.interface.wndCube.AddCubeResultItem(cubeInfo["vnum"], cubeInfo["count"])
  1732.                
  1733.                 j = 0              
  1734.                 for materialList in cubeInfo["materialList"]:
  1735.                     for materialInfo in materialList:
  1736.                         itemVnum, itemCount = materialInfo
  1737.                         self.interface.wndCube.AddMaterialInfo(i, j, itemVnum, itemCount)
  1738.                     j = j + 1                      
  1739.                        
  1740.                 i = i + 1
  1741.                
  1742.             self.interface.wndCube.Refresh()
  1743.  
  1744.     def BINARY_Cube_Close(self):
  1745.         self.interface.CloseCubeWindow()
  1746.  
  1747.     # 제작에 필요한 골드, 예상되는 완성품의 VNUM과 개수 정보 update
  1748.     def BINARY_Cube_UpdateInfo(self, gold, itemVnum, count):
  1749.         self.interface.UpdateCubeInfo(gold, itemVnum, count)
  1750.        
  1751.     def BINARY_Cube_Succeed(self, itemVnum, count):
  1752.         print "큐브 제작 성공"
  1753.         self.interface.SucceedCubeWork(itemVnum, count)
  1754.         pass
  1755.  
  1756.     def BINARY_Cube_Failed(self):
  1757.         print "큐브 제작 실패"
  1758.         self.interface.FailedCubeWork()
  1759.         pass
  1760.  
  1761.     def BINARY_Cube_ResultList(self, npcVNUM, listText):
  1762.         # ResultList Text Format : 72723,1/72725,1/72730.1/50001,5  이런식으로 "/" 문자로 구분된 리스트를 줌
  1763.         #print listText
  1764.        
  1765.         if npcVNUM == 0:
  1766.             npcVNUM = self.currentCubeNPC
  1767.        
  1768.         self.cubeInformation[npcVNUM] = []
  1769.        
  1770.         try:
  1771.             for eachInfoText in listText.split("/"):
  1772.                 eachInfo = eachInfoText.split(",")
  1773.                 itemVnum    = int(eachInfo[0])
  1774.                 itemCount   = int(eachInfo[1])
  1775.  
  1776.                 self.cubeInformation[npcVNUM].append({"vnum": itemVnum, "count": itemCount})
  1777.                 self.interface.wndCube.AddCubeResultItem(itemVnum, itemCount)
  1778.            
  1779.             resultCount = len(self.cubeInformation[npcVNUM])
  1780.             requestCount = 7
  1781.             modCount = resultCount % requestCount
  1782.             splitCount = resultCount / requestCount
  1783.             for i in xrange(splitCount):
  1784.                 #print("/cube r_info %d %d" % (i * requestCount, requestCount))
  1785.                 net.SendChatPacket("/cube r_info %d %d" % (i * requestCount, requestCount))
  1786.                
  1787.             if 0 < modCount:
  1788.                 #print("/cube r_info %d %d" % (splitCount * requestCount, modCount))               
  1789.                 net.SendChatPacket("/cube r_info %d %d" % (splitCount * requestCount, modCount))
  1790.  
  1791.         except RuntimeError, msg:
  1792.             dbg.TraceError(msg)
  1793.             return 0
  1794.            
  1795.         pass
  1796.        
  1797.     def BINARY_Cube_MaterialInfo(self, startIndex, listCount, listText):
  1798.         # Material Text Format : 125,1|126,2|127,2|123,5&555,5&555,4/120000
  1799.         try:
  1800.             #print listText
  1801.            
  1802.             if 3 > len(listText):
  1803.                 dbg.TraceError("Wrong Cube Material Infomation")
  1804.                 return 0
  1805.  
  1806.            
  1807.            
  1808.             eachResultList = listText.split("@")
  1809.  
  1810.             cubeInfo = self.cubeInformation[self.currentCubeNPC]           
  1811.            
  1812.             itemIndex = 0
  1813.             for eachResultText in eachResultList:
  1814.                 cubeInfo[startIndex + itemIndex]["materialList"] = [[], [], [], [], []]
  1815.                 materialList = cubeInfo[startIndex + itemIndex]["materialList"]
  1816.                
  1817.                 gold = 0
  1818.                 splitResult = eachResultText.split("/")
  1819.                 if 1 < len(splitResult):
  1820.                     gold = int(splitResult[1])
  1821.                    
  1822.                 #print "splitResult : ", splitResult
  1823.                 eachMaterialList = splitResult[0].split("&")
  1824.                
  1825.                 i = 0
  1826.                 for eachMaterialText in eachMaterialList:
  1827.                     complicatedList = eachMaterialText.split("|")
  1828.                    
  1829.                     if 0 < len(complicatedList):
  1830.                         for complicatedText in complicatedList:
  1831.                             (itemVnum, itemCount) = complicatedText.split(",")
  1832.                             itemVnum = int(itemVnum)
  1833.                             itemCount = int(itemCount)
  1834.                             self.interface.wndCube.AddMaterialInfo(itemIndex + startIndex, i, itemVnum, itemCount)
  1835.                            
  1836.                             materialList[i].append((itemVnum, itemCount))
  1837.                            
  1838.                     else:
  1839.                         itemVnum, itemCount = eachMaterialText.split(",")
  1840.                         itemVnum = int(itemVnum)
  1841.                         itemCount = int(itemCount)
  1842.                         self.interface.wndCube.AddMaterialInfo(itemIndex + startIndex, i, itemVnum, itemCount)
  1843.                        
  1844.                         materialList[i].append((itemVnum, itemCount))
  1845.                        
  1846.                     i = i + 1
  1847.                    
  1848.                    
  1849.                    
  1850.                 itemIndex = itemIndex + 1
  1851.                
  1852.             self.interface.wndCube.Refresh()
  1853.            
  1854.                
  1855.         except RuntimeError, msg:
  1856.             dbg.TraceError(msg)
  1857.             return 0
  1858.            
  1859.         pass
  1860.    
  1861.     # END_OF_CUBE
  1862.    
  1863.     # 용혼석
  1864.     def BINARY_Highlight_Item(self, inven_type, inven_pos):
  1865.         self.interface.Highligt_Item(inven_type, inven_pos)
  1866.    
  1867.     def BINARY_DragonSoulGiveQuilification(self):
  1868.         self.interface.DragonSoulGiveQuilification()
  1869.        
  1870.     def BINARY_DragonSoulRefineWindow_Open(self):
  1871.         self.interface.OpenDragonSoulRefineWindow()
  1872.  
  1873.     def BINARY_DragonSoulRefineWindow_RefineFail(self, reason, inven_type, inven_pos):
  1874.         self.interface.FailDragonSoulRefine(reason, inven_type, inven_pos)
  1875.  
  1876.     def BINARY_DragonSoulRefineWindow_RefineSucceed(self, inven_type, inven_pos):
  1877.         self.interface.SucceedDragonSoulRefine(inven_type, inven_pos)
  1878.    
  1879.     # END of DRAGON SOUL REFINE WINDOW
  1880.    
  1881.     def BINARY_SetBigMessage(self, message):
  1882.         self.interface.bigBoard.SetTip(message)
  1883.  
  1884.     def BINARY_SetTipMessage(self, message):
  1885.         self.interface.tipBoard.SetTip(message)    
  1886.  
  1887.     def BINARY_AppendNotifyMessage(self, type):
  1888.         if not type in localeInfo.NOTIFY_MESSAGE:
  1889.             return
  1890.         chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.NOTIFY_MESSAGE[type])
  1891.  
  1892.     def BINARY_Guild_EnterGuildArea(self, areaID):
  1893.         self.interface.BULID_EnterGuildArea(areaID)
  1894.  
  1895.     def BINARY_Guild_ExitGuildArea(self, areaID):
  1896.         self.interface.BULID_ExitGuildArea(areaID)
  1897.  
  1898.     def BINARY_GuildWar_OnSendDeclare(self, guildID):
  1899.         pass
  1900.  
  1901.     def BINARY_GuildWar_OnRecvDeclare(self, guildID, warType):
  1902.         mainCharacterName = player.GetMainCharacterName()
  1903.         masterName = guild.GetGuildMasterName()
  1904.         if mainCharacterName == masterName:
  1905.             self.__GuildWar_OpenAskDialog(guildID, warType)
  1906.  
  1907.     def BINARY_GuildWar_OnRecvPoint(self, gainGuildID, opponentGuildID, point):
  1908.         self.interface.OnRecvGuildWarPoint(gainGuildID, opponentGuildID, point)
  1909.  
  1910.     def BINARY_GuildWar_OnStart(self, guildSelf, guildOpp):
  1911.         self.interface.OnStartGuildWar(guildSelf, guildOpp)
  1912.  
  1913.     def BINARY_GuildWar_OnEnd(self, guildSelf, guildOpp):
  1914.         self.interface.OnEndGuildWar(guildSelf, guildOpp)
  1915.  
  1916.     def BINARY_BettingGuildWar_SetObserverMode(self, isEnable):
  1917.         self.interface.BINARY_SetObserverMode(isEnable)
  1918.  
  1919.     def BINARY_BettingGuildWar_UpdateObserverCount(self, observerCount):
  1920.         self.interface.wndMiniMap.UpdateObserverCount(observerCount)
  1921.  
  1922.     def __GuildWar_UpdateMemberCount(self, guildID1, memberCount1, guildID2, memberCount2, observerCount):
  1923.         guildID1 = int(guildID1)
  1924.         guildID2 = int(guildID2)
  1925.         memberCount1 = int(memberCount1)
  1926.         memberCount2 = int(memberCount2)
  1927.         observerCount = int(observerCount)
  1928.  
  1929.         self.interface.UpdateMemberCount(guildID1, memberCount1, guildID2, memberCount2)
  1930.         self.interface.wndMiniMap.UpdateObserverCount(observerCount)
  1931.  
  1932.     def __GuildWar_OpenAskDialog(self, guildID, warType):
  1933.  
  1934.         guildName = guild.GetGuildName(guildID)
  1935.  
  1936.         # REMOVED_GUILD_BUG_FIX
  1937.         if "Noname" == guildName:
  1938.             return
  1939.         # END_OF_REMOVED_GUILD_BUG_FIX
  1940.  
  1941.         import uiGuild
  1942.         questionDialog = uiGuild.AcceptGuildWarDialog()
  1943.         questionDialog.SAFE_SetAcceptEvent(self.__GuildWar_OnAccept)
  1944.         questionDialog.SAFE_SetCancelEvent(self.__GuildWar_OnDecline)
  1945.         questionDialog.Open(guildName, warType)
  1946.  
  1947.         self.guildWarQuestionDialog = questionDialog
  1948.  
  1949.     def __GuildWar_CloseAskDialog(self):
  1950.         self.guildWarQuestionDialog.Close()
  1951.         self.guildWarQuestionDialog = None
  1952.  
  1953.     def __GuildWar_OnAccept(self):
  1954.  
  1955.         guildName = self.guildWarQuestionDialog.GetGuildName()
  1956.  
  1957.         net.SendChatPacket("/war " + guildName)
  1958.         self.__GuildWar_CloseAskDialog()
  1959.  
  1960.         return 1
  1961.  
  1962.     def __GuildWar_OnDecline(self):
  1963.  
  1964.         guildName = self.guildWarQuestionDialog.GetGuildName()
  1965.  
  1966.         net.SendChatPacket("/nowar " + guildName)
  1967.         self.__GuildWar_CloseAskDialog()
  1968.  
  1969.         return 1
  1970.     ## BINARY CALLBACK
  1971.     ######################################################################################
  1972.  
  1973.     def __ServerCommand_Build(self):
  1974.         serverCommandList={
  1975.             "SetTeamOnline"         : self.__TeamLogin,
  1976.             "SetTeamOffline"        : self.__TeamLogout,
  1977.             "DiceDone"              : self.__DiceHasDone,
  1978.             "ConsoleEnable"         : self.__Console_Enable,
  1979.             "DayMode"               : self.__DayMode_Update,
  1980.             "PRESERVE_DayMode"      : self.__PRESERVE_DayMode_Update,
  1981.             "CloseRestartWindow"    : self.__RestartDialog_Close,
  1982.             "OpenPrivateShop"       : self.__PrivateShop_Open,
  1983.             "PartyHealReady"        : self.PartyHealReady,
  1984.             "ShowMeSafeboxPassword" : self.AskSafeboxPassword,
  1985.             "CloseSafebox"          : self.CommandCloseSafebox,
  1986.             "CloseMall"             : self.CommandCloseMall,
  1987.             "ShowMeMallPassword"    : self.AskMallPassword,
  1988.             "item_mall"             : self.__ItemMall_Open,
  1989.             "RefineSuceeded"        : self.RefineSuceededMessage,
  1990.             "RefineFailed"          : self.RefineFailedMessage,
  1991.             "xmas_snow"             : self.__XMasSnow_Enable,
  1992.             "xmas_boom"             : self.__XMasBoom_Enable,
  1993.             "xmas_song"             : self.__XMasSong_Enable,
  1994.             "xmas_tree"             : self.__XMasTree_Enable,
  1995.             "newyear_boom"          : self.__XMasBoom_Enable,
  1996.             "PartyRequest"          : self.__PartyRequestQuestion,
  1997.             "PartyRequestDenied"    : self.__PartyRequestDenied,
  1998.             "horse_state"           : self.__Horse_UpdateState,
  1999.             "hide_horse_state"      : self.__Horse_HideState,
  2000.             "WarUC"                 : self.__GuildWar_UpdateMemberCount,
  2001.             "test_server"           : self.__EnableTestServerFlag,
  2002.             "mall"                  : self.__InGameShop_Show,
  2003.             "lover_login"           : self.__LoginLover,
  2004.             "lover_logout"          : self.__LogoutLover,
  2005.             "lover_near"            : self.__LoverNear,
  2006.             "lover_far"             : self.__LoverFar,     
  2007.             "BINARY_Duel_GetInfo"           : self.BINARY_Duel_GetInfo,
  2008.             "BINARY_Duel_Request"           : self.BINARY_Duel_Request,
  2009.             "BINARY_Duel_LiveInterface"         : self.BINARY_Duel_LiveInterface,
  2010.             "BINARY_Duel_Delete"            : self.BINARY_Duel_Delete,
  2011.             "BINARY_Duel_SendMessage"           : self.BINARY_Duel_SendMessage,
  2012.             "lover_divorce"         : self.__LoverDivorce,
  2013.             "PlayMusic"             : self.__PlayMusic,
  2014.             "MyShopPriceList"       : self.__PrivateShop_PriceList,
  2015.             "Telep"               : self.__MakeTelep,
  2016.         }
  2017.  
  2018.         self.serverCommander=stringCommander.Analyzer()
  2019.         for serverCommandItem in serverCommandList.items():
  2020.             self.serverCommander.SAFE_RegisterCallBack(
  2021.                 serverCommandItem[0], serverCommandItem[1]
  2022.             )
  2023.  
  2024.     def BINARY_ServerCommand_Run(self, line):
  2025.         #dbg.TraceError(line)
  2026.         try:
  2027.             #print " BINARY_ServerCommand_Run", line
  2028.             return self.serverCommander.Run(line)
  2029.         except RuntimeError, msg:
  2030.             dbg.TraceError(msg)
  2031.             return 0
  2032.  
  2033.     def __ProcessPreservedServerCommand(self):
  2034.         try:
  2035.             command = net.GetPreservedServerCommand()
  2036.             while command:
  2037.                 print " __ProcessPreservedServerCommand", command
  2038.                 self.serverCommander.Run(command)
  2039.                 command = net.GetPreservedServerCommand()
  2040.         except RuntimeError, msg:
  2041.             dbg.TraceError(msg)
  2042.             return 0
  2043.  
  2044.     def PartyHealReady(self):
  2045.         self.interface.PartyHealReady()
  2046.  
  2047.     def AskSafeboxPassword(self):
  2048.         self.interface.AskSafeboxPassword()
  2049.  
  2050.     # ITEM_MALL
  2051.     def AskMallPassword(self):
  2052.         self.interface.AskMallPassword()
  2053.  
  2054.     def __ItemMall_Open(self):
  2055.         self.interface.OpenItemMall();
  2056.  
  2057.     def CommandCloseMall(self):
  2058.         self.interface.CommandCloseMall()
  2059.     # END_OF_ITEM_MALL
  2060.  
  2061.     def RefineSuceededMessage(self):
  2062.         snd.PlaySound("sound/ui/make_soket.wav")
  2063.         self.PopupMessage(localeInfo.REFINE_SUCCESS)
  2064.  
  2065.     def RefineFailedMessage(self):
  2066.         snd.PlaySound("sound/ui/jaeryun_fail.wav")
  2067.         self.PopupMessage(localeInfo.REFINE_FAILURE)
  2068.  
  2069.     def CommandCloseSafebox(self):
  2070.         self.interface.CommandCloseSafebox()
  2071.  
  2072.     # PRIVATE_SHOP_PRICE_LIST
  2073.     def __PrivateShop_PriceList(self, itemVNum, itemPrice):
  2074.         uiPrivateShopBuilder.SetPrivateShopItemPrice(itemVNum, itemPrice)  
  2075.     # END_OF_PRIVATE_SHOP_PRICE_LIST
  2076.  
  2077.     def __Horse_HideState(self):
  2078.         self.affectShower.SetHorseState(0, 0, 0)
  2079.        
  2080.     if app.ENABLE_PVP_ADVANCED:
  2081.         def BINARY_Duel_GetInfo(self, a, b, c, d, e, f, g, h):
  2082.             self.wndDuelGui.OpenDialog(a, b, c, d, e, f, g, h)
  2083.  
  2084.         def BINARY_Duel_Request(self, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q):
  2085.             self.wndDuelGui.OpenDialog(a, b, c, d, e, f, g, h)
  2086.             self.wndDuelGui.Selected([int(i), int(j), int(k), int(l), int(m), int(n), int(o), int(p), int(q)])
  2087.  
  2088.         def BINARY_Duel_Delete(self):
  2089.             self.wndDuelGui.Remove()
  2090.  
  2091.             if self.wndDuelLive.IsShow():
  2092.                 self.wndDuelLive.Hide()
  2093.  
  2094.         def BINARY_Duel_LiveInterface(self, a, b, c, d, e, f, g, h, i, j, k, l):
  2095.             self.wndDuelLive.ShowInformations([str(a), int(b), int(c), int(d), int(e), int(f), int(g), int(h), int(i), int(j), int(k), int(l)])
  2096.  
  2097.         def BINARY_Duel_SendMessage(self, textLine):
  2098.             if str(textLine) != "":
  2099.                 self.wndMsg = message.PopupDialog()
  2100.                 self.wndMsg.SetWidth(550)
  2101.                 self.wndMsg.SetText((str(textLine).replace("$"," ")))
  2102.                 self.wndMsg.Show()
  2103.             else:
  2104.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Error, i could not initialize message from server!")
  2105.  
  2106.     def __Horse_UpdateState(self, level, health, battery):
  2107.         self.affectShower.SetHorseState(int(level), int(health), int(battery))
  2108.  
  2109.     def __IsXMasMap(self):
  2110.         mapDict = ( "metin2_map_n_flame_01",
  2111.                     "metin2_map_n_desert_01",
  2112.                     "metin2_map_spiderdungeon",
  2113.                     "metin2_map_deviltower1", )
  2114.  
  2115.         if background.GetCurrentMapName() in mapDict:
  2116.             return False
  2117.  
  2118.         return True
  2119.  
  2120.     def __XMasSnow_Enable(self, mode):
  2121.  
  2122.         self.__XMasSong_Enable(mode)
  2123.  
  2124.         if "1"==mode:
  2125.  
  2126.             if not self.__IsXMasMap():
  2127.                 return
  2128.  
  2129.             print "XMAS_SNOW ON"
  2130.             background.EnableSnow(1)
  2131.  
  2132.         else:
  2133.             print "XMAS_SNOW OFF"
  2134.             background.EnableSnow(0)
  2135.  
  2136.     def __XMasBoom_Enable(self, mode):
  2137.         if "1"==mode:
  2138.  
  2139.             if not self.__IsXMasMap():
  2140.                 return
  2141.  
  2142.             print "XMAS_BOOM ON"
  2143.             self.__DayMode_Update("dark")
  2144.             self.enableXMasBoom = True
  2145.             self.startTimeXMasBoom = app.GetTime()
  2146.         else:
  2147.             print "XMAS_BOOM OFF"
  2148.             self.__DayMode_Update("light")
  2149.             self.enableXMasBoom = False
  2150.  
  2151.     def __XMasTree_Enable(self, grade):
  2152.  
  2153.         print "XMAS_TREE ", grade
  2154.         background.SetXMasTree(int(grade))
  2155.  
  2156.     def __XMasSong_Enable(self, mode):
  2157.         if "1"==mode:
  2158.             print "XMAS_SONG ON"
  2159.  
  2160.             XMAS_BGM = "xmas.mp3"
  2161.  
  2162.             if app.IsExistFile("BGM/" + XMAS_BGM)==1:
  2163.                 if musicInfo.fieldMusic != "":
  2164.                     snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  2165.  
  2166.                 musicInfo.fieldMusic=XMAS_BGM
  2167.                 snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  2168.  
  2169.         else:
  2170.             print "XMAS_SONG OFF"
  2171.  
  2172.             if musicInfo.fieldMusic != "":
  2173.                 snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  2174.  
  2175.             musicInfo.fieldMusic=musicInfo.METIN2THEMA
  2176.             snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  2177.  
  2178.     def __RestartDialog_Close(self):
  2179.         self.interface.CloseRestartDialog()
  2180.  
  2181.     def __Console_Enable(self):
  2182.         constInfo.CONSOLE_ENABLE = True
  2183.         self.consoleEnable = True
  2184.         app.EnableSpecialCameraMode()
  2185.         ui.EnablePaste(True)
  2186.  
  2187.     ## PrivateShop
  2188.     def __PrivateShop_Open(self):
  2189.         self.interface.OpenPrivateShopInputNameDialog()
  2190.  
  2191.     def BINARY_PrivateShop_Appear(self, vid, text):
  2192.         self.interface.AppearPrivateShop(vid, text)
  2193.  
  2194.     def BINARY_PrivateShop_Disappear(self, vid):
  2195.         self.interface.DisappearPrivateShop(vid)
  2196.  
  2197.     ## DayMode
  2198.     def __PRESERVE_DayMode_Update(self, mode):
  2199.         if "light"==mode:
  2200.             background.SetEnvironmentData(0)
  2201.         elif "dark"==mode:
  2202.  
  2203.             if not self.__IsXMasMap():
  2204.                 return
  2205.  
  2206.             background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)
  2207.             background.SetEnvironmentData(1)
  2208.  
  2209.     def __DayMode_Update(self, mode):
  2210.         if "light"==mode:
  2211.             self.curtain.SAFE_FadeOut(self.__DayMode_OnCompleteChangeToLight)
  2212.         elif "dark"==mode:
  2213.  
  2214.             if not self.__IsXMasMap():
  2215.                 return
  2216.  
  2217.             self.curtain.SAFE_FadeOut(self.__DayMode_OnCompleteChangeToDark)
  2218.  
  2219.     def __DayMode_OnCompleteChangeToLight(self):
  2220.         background.SetEnvironmentData(0)
  2221.         self.curtain.FadeIn()
  2222.  
  2223.     def __DayMode_OnCompleteChangeToDark(self):
  2224.         background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)
  2225.         background.SetEnvironmentData(1)
  2226.         self.curtain.FadeIn()
  2227.  
  2228.     ## XMasBoom
  2229.     def __XMasBoom_Update(self):
  2230.  
  2231.         self.BOOM_DATA_LIST = ( (2, 5), (5, 2), (7, 3), (10, 3), (20, 5) )
  2232.         if self.indexXMasBoom >= len(self.BOOM_DATA_LIST):
  2233.             return
  2234.  
  2235.         boomTime = self.BOOM_DATA_LIST[self.indexXMasBoom][0]
  2236.         boomCount = self.BOOM_DATA_LIST[self.indexXMasBoom][1]
  2237.  
  2238.         if app.GetTime() - self.startTimeXMasBoom > boomTime:
  2239.  
  2240.             self.indexXMasBoom += 1
  2241.  
  2242.             for i in xrange(boomCount):
  2243.                 self.__XMasBoom_Boom()
  2244.  
  2245.     def __XMasBoom_Boom(self):
  2246.         x, y, z = player.GetMainCharacterPosition()
  2247.         randX = app.GetRandom(-150, 150)
  2248.         randY = app.GetRandom(-150, 150)
  2249.  
  2250.         snd.PlaySound3D(x+randX, -y+randY, z, "sound/common/etc/salute.mp3")
  2251.  
  2252.     def __PartyRequestQuestion(self, vid):
  2253.         vid = int(vid)
  2254.         partyRequestQuestionDialog = uiCommon.QuestionDialog()
  2255.         partyRequestQuestionDialog.SetText(chr.GetNameByVID(vid) + localeInfo.PARTY_DO_YOU_ACCEPT)
  2256.         partyRequestQuestionDialog.SetAcceptText(localeInfo.UI_ACCEPT)
  2257.         partyRequestQuestionDialog.SetCancelText(localeInfo.UI_DENY)
  2258.         partyRequestQuestionDialog.SetAcceptEvent(lambda arg=True: self.__AnswerPartyRequest(arg))
  2259.         partyRequestQuestionDialog.SetCancelEvent(lambda arg=False: self.__AnswerPartyRequest(arg))
  2260.         partyRequestQuestionDialog.Open()
  2261.         partyRequestQuestionDialog.vid = vid
  2262.         self.partyRequestQuestionDialog = partyRequestQuestionDialog
  2263.  
  2264.     def __AnswerPartyRequest(self, answer):
  2265.         if not self.partyRequestQuestionDialog:
  2266.             return
  2267.  
  2268.         vid = self.partyRequestQuestionDialog.vid
  2269.  
  2270.         if answer:
  2271.             net.SendChatPacket("/party_request_accept " + str(vid))
  2272.         else:
  2273.             net.SendChatPacket("/party_request_deny " + str(vid))
  2274.  
  2275.         self.partyRequestQuestionDialog.Close()
  2276.         self.partyRequestQuestionDialog = None
  2277.  
  2278.     def __PartyRequestDenied(self):
  2279.         self.PopupMessage(localeInfo.PARTY_REQUEST_DENIED)
  2280.        
  2281.     if app.TOURNAMENT_PVP_SYSTEM:
  2282.         def BINARY_Tournament_OnRecvData(self, leftTime, membersOnline_A, membersOnline_B, membersDead_A, membersDead_B, memberLives):
  2283.             self.interface.AddTournamentResultWindow(leftTime, membersOnline_A, membersOnline_B, membersDead_A, membersDead_B, memberLives)
  2284.            
  2285.     def __EnableTestServerFlag(self):
  2286.         app.EnableTestServerFlag()
  2287.  
  2288.     def __InGameShop_Show(self, url):
  2289.         if constInfo.IN_GAME_SHOP_ENABLE:
  2290.             self.interface.OpenWebWindow(url)
  2291.  
  2292.     # WEDDING
  2293.     def __LoginLover(self):
  2294.         if self.interface.wndMessenger:
  2295.             self.interface.wndMessenger.OnLoginLover()
  2296.  
  2297.     def __LogoutLover(self):
  2298.         if self.interface.wndMessenger:
  2299.             self.interface.wndMessenger.OnLogoutLover()
  2300.         if self.affectShower:
  2301.             self.affectShower.HideLoverState()
  2302.  
  2303.     def __LoverNear(self):
  2304.         if self.affectShower:
  2305.             self.affectShower.ShowLoverState()
  2306.  
  2307.     def __LoverFar(self):
  2308.         if self.affectShower:
  2309.             self.affectShower.HideLoverState()
  2310.  
  2311.     def __LoverDivorce(self):
  2312.         if self.interface.wndMessenger:
  2313.             self.interface.wndMessenger.ClearLoverInfo()
  2314.         if self.affectShower:
  2315.             self.affectShower.ClearLoverState()
  2316.  
  2317.     def __PlayMusic(self, flag, filename):
  2318.         flag = int(flag)
  2319.         if flag:
  2320.             snd.FadeOutAllMusic()
  2321.             musicInfo.SaveLastPlayFieldMusic()
  2322.             snd.FadeInMusic("BGM/" + filename)
  2323.         else:
  2324.             snd.FadeOutAllMusic()
  2325.             musicInfo.LoadLastPlayFieldMusic()
  2326.             snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  2327.  
  2328.     # END_OF_WEDDING
  2329. # END_switchbot
  2330.         # TEAM_LIST
  2331.     def __TeamLogin(self, name):
  2332.         if self.interface.wndMessenger:
  2333.             self.interface.wndMessenger.OnLogin(2, name)
  2334.     def __TeamLogout(self, name):
  2335.         if self.interface.wndMessenger:
  2336.             self.interface.wndMessenger.OnLogout(2, name)
  2337.         # END_OF_TEAM_LIST
  2338.  
  2339.     if app.ENABLE_MAINTENANCE_SYSTEM:
  2340.         def BINARY_ShowMaintenanceSign(self, timeLeft, duration):
  2341.             self.interface.ShowMaintenanceSign(timeLeft, duration)
  2342.  
  2343.         def BINARY_HideMaintenanceSign(self):
  2344.             self.interface.HideMaintenanceSign()
  2345.            
  2346.     def __OpenProfile(self):
  2347.         name = player.GetName()
  2348.         net.SendChatPacket("/view_profile " + str(name))
  2349.        
  2350.     def __MakeTelep(self, qid):
  2351.         constInfo.Telepqin= int(qid)
  2352.        
  2353.     if app.ENABLE_INVENTORY_PROTECT_SYSTEM:
  2354.         def BINARY_Inventory_State(self, case):
  2355.             self.interface.AskInventoryPassword(case)
  2356.        
  2357.         def BINARY_Inventory_Lock(self):
  2358.             self.interface.InventoryLock()
  2359.  
  2360.         def BINARY_Inventory_Unlock(self):
  2361.             self.interface.InventoryUnlock()
  2362.        
  2363.     def __DiceHasDone(self, myNumber, targetNumber):
  2364.         self.interface.AddDiceNumber(myNumber, targetNumber)
  2365.        
  2366.     def StartDice(self):
  2367.         self.interface.StartDice()
  2368.  
  2369.     def EndDice(self):
  2370.         self.interface.EndDice()
  2371.  
  2372.     def RefreshDice(self):
  2373.         self.interface.RefreshDice()
Advertisement
Add Comment
Please, Sign In to add comment