Guest User

game.py

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