Advertisement
Guest User

GAME

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