Guest User

game.py

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