1. import app
  2. import ui
  3. import guild
  4. import net
  5. import wndMgr
  6. import grp
  7. import grpText
  8. import uiPickMoney
  9. import localeInfo
  10. import player
  11. import skill
  12. import mouseModule
  13. import uiUploadMark
  14. import uiCommon
  15. import uiToolTip
  16. import playerSettingModule
  17. import constInfo
  18. import background
  19. import miniMap
  20. import chr
  21. import uiScriptLocale
  22. from _weakref import proxy
  23. DISABLE_GUILD_SKILL = False
  24. DISABLE_DECLARE_WAR = False
  25. def NumberToMoneyString(n):
  26. if n <= 0 :
  27. return "0"
  28. return "%s" % (','.join([ i-3<0 and str(n)[:i] or str(n)[i-3:i] for i in range(len(str(n))%3, len(str(n))+1, 3) if i ]))
  29. MATERIAL_STONE_INDEX = 0
  30. MATERIAL_LOG_INDEX = 1
  31. MATERIAL_PLYWOOD_INDEX = 2
  32. MATERIAL_STONE_ID = 90010
  33. MATERIAL_LOG_ID = 90011
  34. MATERIAL_PLYWOOD_ID = 90012
  35. BUILDING_DATA_LIST = []
  36. def GetGVGKey(srcGuildID, dstGuildID):
  37. minID = min(srcGuildID, dstGuildID)
  38. maxID = max(srcGuildID, dstGuildID)
  39. return minID*1000 + maxID
  40. def unsigned32(n):
  41. return n & 0xFFFFFFFFL
  42. class DeclareGuildWarDialog(ui.ScriptWindow):
  43. def __init__(self):
  44. ui.ScriptWindow.__init__(self)
  45. self.type=0
  46. self.__CreateDialog()
  47. def __del__(self):
  48. ui.ScriptWindow.__del__(self)
  49. def Open(self):
  50. self.inputValue.SetFocus()
  51. self.SetCenterPosition()
  52. self.SetTop()
  53. self.Show()
  54. def Close(self):
  55. self.ClearDictionary()
  56. self.board = None
  57. self.acceptButton = None
  58. self.cancelButton = None
  59. self.inputSlot = None
  60. self.inputValue = None
  61. self.Hide()
  62. def __CreateDialog(self):
  63. try:
  64. pyScrLoader = ui.PythonScriptLoader()
  65. pyScrLoader.LoadScriptFile(self, "uiscript/declareguildwardialog.py")
  66. except:
  67. import exception
  68. exception.Abort("DeclareGuildWarWindow.__CreateDialog - LoadScript")
  69. try:
  70. getObject = self.GetChild
  71. self.board = getObject("Board")
  72. self.typeButtonList=[]
  73. self.typeButtonList.append(getObject("NormalButton"))
  74. self.typeButtonList.append(getObject("WarpButton"))
  75. self.typeButtonList.append(getObject("CTFButton"))
  76. self.acceptButton = getObject("AcceptButton")
  77. self.cancelButton = getObject("CancelButton")
  78. self.inputSlot = getObject("InputSlot")
  79. self.inputValue = getObject("InputValue")
  80. gameType=getObject("GameType")
  81. except:
  82. import exception
  83. exception.Abort("DeclareGuildWarWindow.__CreateDialog - BindObject")
  84. if constInfo.GUILD_WAR_TYPE_SELECT_ENABLE==0:
  85. gameType.Hide()
  86. self.typeButtonList[0].SAFE_SetEvent(self.__OnClickTypeButtonNormal)
  87. self.typeButtonList[1].SAFE_SetEvent(self.__OnClickTypeButtonWarp)
  88. self.typeButtonList[2].SAFE_SetEvent(self.__OnClickTypeButtonCTF)
  89. self.typeButtonList[0].SetToolTipWindow(self.__CreateGameTypeToolTip(localeInfo.GUILDWAR_NORMAL_TITLE, localeInfo.GUILDWAR_NORMAL_DESCLIST))
  90. self.typeButtonList[1].SetToolTipWindow(self.__CreateGameTypeToolTip(localeInfo.GUILDWAR_WARP_TITLE, localeInfo.GUILDWAR_WARP_DESCLIST))
  91. self.typeButtonList[2].SetToolTipWindow(self.__CreateGameTypeToolTip(localeInfo.GUILDWAR_CTF_TITLE, localeInfo.GUILDWAR_CTF_DESCLIST))
  92. self.__ClickRadioButton(self.typeButtonList, 0)
  93. self.SetAcceptEvent(ui.__mem_func__(self.__OnOK))
  94. self.SetCancelEvent(ui.__mem_func__(self.__OnCancel))
  95. def __OnOK(self):
  96. text = self.GetText()
  97. type = self.GetType()
  98. if ""==text:
  99. return
  100. net.SendChatPacket("/war %s %d" % (text, type))
  101. self.Close()
  102. return 1
  103. def __OnCancel(self):
  104. self.Close()
  105. return 1
  106. def __OnClickTypeButtonNormal(self):
  107. self.__ClickTypeRadioButton(0)
  108. def __OnClickTypeButtonWarp(self):
  109. self.__ClickTypeRadioButton(1)
  110. def __OnClickTypeButtonCTF(self):
  111. self.__ClickTypeRadioButton(2)
  112. def __ClickTypeRadioButton(self, type):
  113. self.__ClickRadioButton(self.typeButtonList, type)
  114. self.type=type
  115. def __ClickRadioButton(self, buttonList, buttonIndex):
  116. try:
  117. selButton=buttonList[buttonIndex]
  118. except IndexError:
  119. return
  120. for eachButton in buttonList:
  121. eachButton.SetUp()
  122. selButton.Down()
  123. def SetTitle(self, name):
  124. self.board.SetTitleName(name)
  125. def SetNumberMode(self):
  126. self.inputValue.SetNumberMode()
  127. def SetSecretMode(self):
  128. self.inputValue.SetSecret()
  129. def SetFocus(self):
  130. self.inputValue.SetFocus()
  131. def SetMaxLength(self, length):
  132. width = length * 6 + 10
  133. self.inputValue.SetMax(length)
  134. self.SetSlotWidth(width)
  135. self.SetBoardWidth(max(width + 50, 160))
  136. def SetSlotWidth(self, width):
  137. self.inputSlot.SetSize(width, self.inputSlot.GetHeight())
  138. self.inputValue.SetSize(width, self.inputValue.GetHeight())
  139. def SetBoardWidth(self, width):
  140. self.board.SetSize(max(width + 50, 160), self.GetHeight())
  141. self.SetSize(max(width + 50, 160), self.GetHeight())
  142. self.UpdateRect()
  143. def SetAcceptEvent(self, event):
  144. self.acceptButton.SetEvent(event)
  145. self.inputValue.OnIMEReturn = event
  146. def SetCancelEvent(self, event):
  147. self.board.SetCloseEvent(event)
  148. self.cancelButton.SetEvent(event)
  149. self.inputValue.OnPressEscapeKey = event
  150. def GetType(self):
  151. return self.type
  152. def GetText(self):
  153. return self.inputValue.GetText()
  154. def __CreateGameTypeToolTip(self, title, descList):
  155. toolTip = uiToolTip.ToolTip()
  156. toolTip.SetTitle(title)
  157. toolTip.AppendSpace(5)
  158. for desc in descList:
  159. toolTip.AutoAppendTextLine(desc)
  160. toolTip.AlignHorizonalCenter()
  161. return toolTip
  162. class AcceptGuildWarDialog(ui.ScriptWindow):
  163. def __init__(self):
  164. ui.ScriptWindow.__init__(self)
  165. self.type=0
  166. self.__CreateDialog()
  167. def __del__(self):
  168. print "---------------------------------------------------------------------------- DELETE AcceptGuildWarDialog"
  169. ui.ScriptWindow.__del__(self)
  170. def Open(self, guildName, warType):
  171. self.guildName=guildName
  172. self.warType=warType
  173. self.__ClickSelectedTypeRadioButton()
  174. self.inputValue.SetText(guildName)
  175. self.SetCenterPosition()
  176. self.SetTop()
  177. self.Show()
  178. def GetGuildName(self):
  179. return self.guildName
  180. def Close(self):
  181. self.ClearDictionary()
  182. self.board = None
  183. self.acceptButton = None
  184. self.cancelButton = None
  185. self.inputSlot = None
  186. self.inputValue = None
  187. self.Hide()
  188. def __ClickSelectedTypeRadioButton(self):
  189. self.__ClickTypeRadioButton(self.warType)
  190. def __CreateDialog(self):
  191. try:
  192. pyScrLoader = ui.PythonScriptLoader()
  193. pyScrLoader.LoadScriptFile(self, "uiscript/acceptguildwardialog.py")
  194. except:
  195. import exception
  196. exception.Abort("DeclareGuildWarWindow.__CreateDialog - LoadScript")
  197. try:
  198. getObject = self.GetChild
  199. self.board = getObject("Board")
  200. self.typeButtonList=[]
  201. self.typeButtonList.append(getObject("NormalButton"))
  202. self.typeButtonList.append(getObject("WarpButton"))
  203. self.typeButtonList.append(getObject("CTFButton"))
  204. self.acceptButton = getObject("AcceptButton")
  205. self.cancelButton = getObject("CancelButton")
  206. self.inputSlot = getObject("InputSlot")
  207. self.inputValue = getObject("InputValue")
  208. gameType=getObject("GameType")
  209. except:
  210. import exception
  211. exception.Abort("DeclareGuildWarWindow.__CreateDialog - BindObject")
  212. if constInfo.GUILD_WAR_TYPE_SELECT_ENABLE==0:
  213. gameType.Hide()
  214. self.typeButtonList[0].SAFE_SetEvent(self.__OnClickTypeButtonNormal)
  215. self.typeButtonList[1].SAFE_SetEvent(self.__OnClickTypeButtonWarp)
  216. self.typeButtonList[2].SAFE_SetEvent(self.__OnClickTypeButtonCTF)
  217. self.typeButtonList[0].SetToolTipWindow(self.__CreateGameTypeToolTip(localeInfo.GUILDWAR_NORMAL_TITLE, localeInfo.GUILDWAR_NORMAL_DESCLIST))
  218. self.typeButtonList[1].SetToolTipWindow(self.__CreateGameTypeToolTip(localeInfo.GUILDWAR_WARP_TITLE, localeInfo.GUILDWAR_WARP_DESCLIST))
  219. self.typeButtonList[2].SetToolTipWindow(self.__CreateGameTypeToolTip(localeInfo.GUILDWAR_CTF_TITLE, localeInfo.GUILDWAR_CTF_DESCLIST))
  220. self.__ClickRadioButton(self.typeButtonList, 0)
  221. def __OnClickTypeButtonNormal(self):
  222. self.__ClickSelectedTypeRadioButton()
  223. def __OnClickTypeButtonWarp(self):
  224. self.__ClickSelectedTypeRadioButton()
  225. def __OnClickTypeButtonCTF(self):
  226. self.__ClickSelectedTypeRadioButton()
  227. def __ClickTypeRadioButton(self, type):
  228. self.__ClickRadioButton(self.typeButtonList, type)
  229. self.type=type
  230. def __ClickRadioButton(self, buttonList, buttonIndex):
  231. try:
  232. selButton=buttonList[buttonIndex]
  233. except IndexError:
  234. return
  235. for eachButton in buttonList:
  236. eachButton.SetUp()
  237. selButton.Down()
  238. def SetTitle(self, name):
  239. self.board.SetTitleName(name)
  240. def SetNumberMode(self):
  241. self.inputValue.SetNumberMode()
  242. def SetSecretMode(self):
  243. self.inputValue.SetSecret()
  244. def SetFocus(self):
  245. self.inputValue.SetFocus()
  246. def SetMaxLength(self, length):
  247. width = length * 6 + 10
  248. self.inputValue.SetMax(length)
  249. self.SetSlotWidth(width)
  250. self.SetBoardWidth(max(width + 50, 160))
  251. def SetSlotWidth(self, width):
  252. self.inputSlot.SetSize(width, self.inputSlot.GetHeight())
  253. self.inputValue.SetSize(width, self.inputValue.GetHeight())
  254. def SetBoardWidth(self, width):
  255. self.board.SetSize(max(width + 50, 160), self.GetHeight())
  256. self.SetSize(max(width + 50, 160), self.GetHeight())
  257. self.UpdateRect()
  258. def SAFE_SetAcceptEvent(self, event):
  259. self.SetAcceptEvent(ui.__mem_func__(event))
  260. def SAFE_SetCancelEvent(self, event):
  261. self.SetCancelEvent(ui.__mem_func__(event))
  262. def SetAcceptEvent(self, event):
  263. self.acceptButton.SetEvent(event)
  264. self.inputValue.OnIMEReturn = event
  265. def SetCancelEvent(self, event):
  266. self.board.SetCloseEvent(event)
  267. self.cancelButton.SetEvent(event)
  268. self.inputValue.OnPressEscapeKey = event
  269. def GetType(self):
  270. return self.type
  271. def GetText(self):
  272. return self.inputValue.GetText()
  273. def __CreateGameTypeToolTip(self, title, descList):
  274. toolTip = uiToolTip.ToolTip()
  275. toolTip.SetTitle(title)
  276. toolTip.AppendSpace(5)
  277. for desc in descList:
  278. toolTip.AutoAppendTextLine(desc)
  279. toolTip.AlignHorizonalCenter()
  280. return toolTip
  281. class GuildWarScoreBoard(ui.ThinBoard):
  282. def __init__(self):
  283. ui.ThinBoard.__init__(self)
  284. self.Initialize()
  285. def __del__(self):
  286. ui.ThinBoard.__del__(self)
  287. def Initialize(self):
  288. self.allyGuildID = 0
  289. self.enemyGuildID = 0
  290. self.allyDataDict = {}
  291. self.enemyDataDict = {}
  292. def Open(self, allyGuildID, enemyGuildID):
  293. self.allyGuildID = allyGuildID
  294. self.enemyGuildID = enemyGuildID
  295. self.SetPosition(10, wndMgr.GetScreenHeight() - 100)
  296. mark = ui.MarkBox()
  297. mark.SetParent(self)
  298. mark.SetIndex(allyGuildID)
  299. mark.SetPosition(10, 10 + 18*0)
  300. mark.Show()
  301. scoreText = ui.TextLine()
  302. scoreText.SetParent(self)
  303. scoreText.SetPosition(30, 10 + 18*0)
  304. scoreText.SetHorizontalAlignLeft()
  305. scoreText.Show()
  306. self.allyDataDict["NAME"] = guild.GetGuildName(allyGuildID)
  307. self.allyDataDict["SCORE"] = 0
  308. self.allyDataDict["MEMBER_COUNT"] = -1
  309. self.allyDataDict["MARK"] = mark
  310. self.allyDataDict["TEXT"] = scoreText
  311. mark = ui.MarkBox()
  312. mark.SetParent(self)
  313. mark.SetIndex(enemyGuildID)
  314. mark.SetPosition(10, 10 + 18*1)
  315. mark.Show()
  316. scoreText = ui.TextLine()
  317. scoreText.SetParent(self)
  318. scoreText.SetPosition(30, 10 + 18*1)
  319. scoreText.SetHorizontalAlignLeft()
  320. scoreText.Show()
  321. self.enemyDataDict["NAME"] = guild.GetGuildName(enemyGuildID)
  322. self.enemyDataDict["SCORE"] = 0
  323. self.enemyDataDict["MEMBER_COUNT"] = -1
  324. self.enemyDataDict["MARK"] = mark
  325. self.enemyDataDict["TEXT"] = scoreText
  326. self.__RefreshName()
  327. self.Show()
  328. def __GetDataDict(self, ID):
  329. if self.allyGuildID == ID:
  330. return self.allyDataDict
  331. if self.enemyGuildID == ID:
  332. return self.enemyDataDict
  333. return None
  334. def SetScore(self, gainGuildID, opponetGuildID, point):
  335. dataDict = self.__GetDataDict(gainGuildID)
  336. if not dataDict:
  337. return
  338. dataDict["SCORE"] = point
  339. self.__RefreshName()
  340. def UpdateMemberCount(self, guildID1, memberCount1, guildID2, memberCount2):
  341. dataDict1 = self.__GetDataDict(guildID1)
  342. dataDict2 = self.__GetDataDict(guildID2)
  343. if dataDict1:
  344. dataDict1["MEMBER_COUNT"] = memberCount1
  345. if dataDict2:
  346. dataDict2["MEMBER_COUNT"] = memberCount2
  347. self.__RefreshName()
  348. def __RefreshName(self):
  349. nameMaxLen = max(len(self.allyDataDict["NAME"]), len(self.enemyDataDict["NAME"]))
  350. if -1 == self.allyDataDict["MEMBER_COUNT"] or -1 == self.enemyDataDict["MEMBER_COUNT"]:
  351. self.SetSize(30+nameMaxLen*6+8*5, 50)
  352. self.allyDataDict["TEXT"].SetText("%s %d" % (self.allyDataDict["NAME"], self.allyDataDict["SCORE"]))
  353. self.enemyDataDict["TEXT"].SetText("%s %d" % (self.enemyDataDict["NAME"], self.enemyDataDict["SCORE"]))
  354. else:
  355. self.SetSize(30+nameMaxLen*6+8*5+15, 50)
  356. self.allyDataDict["TEXT"].SetText("%s(%d) %d" % (self.allyDataDict["NAME"], self.allyDataDict["MEMBER_COUNT"], self.allyDataDict["SCORE"]))
  357. self.enemyDataDict["TEXT"].SetText("%s(%d) %d" % (self.enemyDataDict["NAME"], self.enemyDataDict["MEMBER_COUNT"], self.enemyDataDict["SCORE"]))
  358. class MouseReflector(ui.Window):
  359. def __init__(self, parent):
  360. ui.Window.__init__(self)
  361. self.SetParent(parent)
  362. self.AddFlag("not_pick")
  363. self.width = self.height = 0
  364. self.isDown = False
  365. def Down(self):
  366. self.isDown = True
  367. def Up(self):
  368. self.isDown = False
  369. def OnRender(self):
  370. if self.isDown:
  371. grp.SetColor(ui.WHITE_COLOR)
  372. else:
  373. grp.SetColor(ui.HALF_WHITE_COLOR)
  374. x, y = self.GetGlobalPosition()
  375. grp.RenderBar(x+2, y+2, self.GetWidth()-4, self.GetHeight()-4)
  376. class EditableTextSlot(ui.ImageBox):
  377. def __init__(self, parent, x, y):
  378. ui.ImageBox.__init__(self)
  379. self.SetParent(parent)
  380. self.SetPosition(x, y)
  381. self.LoadImage("d:/ymir work/ui/public/Parameter_Slot_02.sub")
  382. self.mouseReflector = MouseReflector(self)
  383. self.mouseReflector.SetSize(self.GetWidth(), self.GetHeight())
  384. self.Enable = True
  385. self.textLine = ui.MakeTextLine(self)
  386. self.event = lambda *arg: None
  387. self.arg = 0
  388. self.Show()
  389. self.mouseReflector.UpdateRect()
  390. def __del__(self):
  391. ui.ImageBox.__del__(self)
  392. def SetText(self, text):
  393. self.textLine.SetText(text)
  394. def SetEvent(self, event, arg):
  395. self.event = event
  396. self.arg = arg
  397. def Disable(self):
  398. self.Enable = False
  399. def OnMouseOverIn(self):
  400. if not self.Enable:
  401. return
  402. self.mouseReflector.Show()
  403. def OnMouseOverOut(self):
  404. if not self.Enable:
  405. return
  406. self.mouseReflector.Hide()
  407. def OnMouseLeftButtonDown(self):
  408. if not self.Enable:
  409. return
  410. self.mouseReflector.Down()
  411. def OnMouseLeftButtonUp(self):
  412. if not self.Enable:
  413. return
  414. self.mouseReflector.Up()
  415. self.event(self.arg)
  416. class CheckBox(ui.ImageBox):
  417. def __init__(self, parent, x, y, event, filename = "d:/ymir work/ui/public/Parameter_Slot_01.sub"):
  418. ui.ImageBox.__init__(self)
  419. self.SetParent(parent)
  420. self.SetPosition(x, y)
  421. self.LoadImage(filename)
  422. self.mouseReflector = MouseReflector(self)
  423. self.mouseReflector.SetSize(self.GetWidth(), self.GetHeight())
  424. image = ui.MakeImageBox(self, "d:/ymir work/ui/public/check_image.sub", 0, 0)
  425. image.AddFlag("not_pick")
  426. image.SetWindowHorizontalAlignCenter()
  427. image.SetWindowVerticalAlignCenter()
  428. image.Hide()
  429. self.Enable = True
  430. self.image = image
  431. self.event = event
  432. self.Show()
  433. self.mouseReflector.UpdateRect()
  434. def __del__(self):
  435. ui.ImageBox.__del__(self)
  436. def SetCheck(self, flag):
  437. if flag:
  438. self.image.Show()
  439. else:
  440. self.image.Hide()
  441. def Disable(self):
  442. self.Enable = False
  443. def OnMouseOverIn(self):
  444. if not self.Enable:
  445. return
  446. self.mouseReflector.Show()
  447. def OnMouseOverOut(self):
  448. if not self.Enable:
  449. return
  450. self.mouseReflector.Hide()
  451. def OnMouseLeftButtonDown(self):
  452. if not self.Enable:
  453. return
  454. self.mouseReflector.Down()
  455. def OnMouseLeftButtonUp(self):
  456. if not self.Enable:
  457. return
  458. self.mouseReflector.Up()
  459. self.event()
  460. class ChangeGradeNameDialog(ui.ScriptWindow):
  461. def __init__(self):
  462. ui.ScriptWindow.__init__(self)
  463. def Open(self):
  464. self.gradeNameSlot.SetText("")
  465. self.gradeNameSlot.SetFocus()
  466. xMouse, yMouse = wndMgr.GetMousePosition()
  467. self.SetPosition(xMouse - self.GetWidth()/2, yMouse + 50)
  468. self.SetTop()
  469. self.Show()
  470. def Close(self):
  471. self.gradeNameSlot.KillFocus()
  472. self.Hide()
  473. return True
  474. def SetGradeNumber(self, gradeNumber):
  475. self.gradeNumber = gradeNumber
  476. def GetGradeNumber(self):
  477. return self.gradeNumber
  478. def GetGradeName(self):
  479. return self.gradeNameSlot.GetText()
  480. def OnPressEscapeKey(self):
  481. self.Close()
  482. return True
  483. class CommentSlot(ui.Window):
  484. TEXT_LIMIT = 35
  485. def __init__(self):
  486. ui.Window.__init__(self)
  487. self.slotImage = ui.MakeImageBox(self, "d:/ymir work/ui/public/Parameter_Slot_06.sub", 0, 0)
  488. self.slotImage.AddFlag("not_pick")
  489. self.slotSimpleText = ui.MakeTextLine(self)
  490. self.slotSimpleText.SetPosition(2, 0)
  491. self.slotSimpleText.SetWindowHorizontalAlignLeft()
  492. self.slotSimpleText.SetHorizontalAlignLeft()
  493. self.bar = ui.SlotBar()
  494. self.bar.SetParent(self)
  495. self.bar.AddFlag("not_pick")
  496. self.bar.Hide()
  497. self.slotFullText = ui.MakeTextLine(self)
  498. self.slotFullText.SetPosition(2, 0)
  499. self.slotFullText.SetWindowHorizontalAlignLeft()
  500. self.slotFullText.SetHorizontalAlignLeft()
  501. self.SetSize(self.slotImage.GetWidth(), self.slotImage.GetHeight())
  502. self.len = 0
  503. def SetText(self, text):
  504. self.len = len(text)
  505. if len(text) > self.TEXT_LIMIT:
  506. limitText = grpText.GetSplitingTextLine(text, self.TEXT_LIMIT-3, 0)
  507. self.slotSimpleText.SetText(limitText + "...")
  508. self.bar.SetSize(self.len * 6 + 5, 17)
  509. else:
  510. self.slotSimpleText.SetText(text)
  511. self.slotFullText.SetText(text)
  512. self.slotFullText.SetPosition(2, 0)
  513. self.slotFullText.Hide()
  514. def OnMouseOverIn(self):
  515. if self.len > self.TEXT_LIMIT:
  516. self.bar.Show()
  517. self.slotFullText.Show()
  518. def OnMouseOverOut(self):
  519. if self.len > self.TEXT_LIMIT:
  520. self.bar.Hide()
  521. self.slotFullText.Hide()
  522. class GuildWindow(ui.ScriptWindow):
  523. JOB_NAME = { 0 : localeInfo.JOB_WARRIOR,
  524. 1 : localeInfo.JOB_ASSASSIN,
  525. 2 : localeInfo.JOB_SURA,
  526. 3 : localeInfo.JOB_SHAMAN, }
  527. GUILD_SKILL_PASSIVE_SLOT = 0
  528. GUILD_SKILL_ACTIVE_SLOT = 1
  529. GUILD_SKILL_AFFECT_SLOT = 2
  530. GRADE_SLOT_NAME = 0
  531. GRADE_ADD_MEMBER_AUTHORITY = 1
  532. GRADE_REMOVE_MEMBER_AUTHORITY = 2
  533. GRADE_NOTICE_AUTHORITY = 3
  534. GRADE_SKILL_AUTHORITY = 4
  535. MEMBER_LINE_COUNT = 13
  536. class PageWindow(ui.ScriptWindow):
  537. def __init__(self, parent, filename):
  538. ui.ScriptWindow.__init__(self)
  539. self.SetParent(parent)
  540. self.filename = filename
  541. def GetScriptFileName(self):
  542. return self.filename
  543. def __init__(self):
  544. ui.ScriptWindow.__init__(self)
  545. self.isLoaded=0
  546. self.__Initialize()
  547. def __del__(self):
  548. ui.ScriptWindow.__del__(self)
  549. print " ==================================== DESTROIED GUILD WINDOW"
  550. def __Initialize(self):
  551. self.board = None
  552. self.pageName = None
  553. self.tabDict = None
  554. self.tabButtonDict = None
  555. self.pickDialog = None
  556. self.questionDialog = None
  557. self.offerDialog = None
  558. self.popupDialog = None
  559. self.moneyDialog = None
  560. self.changeGradeNameDialog = None
  561. self.popup = None
  562. self.popupMessage = None
  563. self.commentSlot = None
  564. self.pageWindow = None
  565. self.tooltipSkill = None
  566. self.memberLinePos = 0
  567. self.enemyGuildNameList = []
  568. def Open(self):
  569. self.Show()
  570. self.SetTop()
  571. guildID = net.GetGuildID()
  572. self.largeMarkBox.SetIndex(guildID)
  573. self.largeMarkBox.SetScale(3)
  574. def Close(self):
  575. self.__CloseAllGuildMemberPageGradeComboBox()
  576. self.offerDialog.Close()
  577. self.popupDialog.Hide()
  578. self.changeGradeNameDialog.Hide()
  579. self.tooltipSkill.Hide()
  580. self.Hide()
  581. self.pickDialog = None
  582. self.questionDialog = None
  583. self.popup = None
  584. def Destroy(self):
  585. self.ClearDictionary()
  586. if self.offerDialog:
  587. self.offerDialog.Destroy()
  588. if self.popupDialog:
  589. self.popupDialog.ClearDictionary()
  590. if self.changeGradeNameDialog:
  591. self.changeGradeNameDialog.ClearDictionary()
  592. if self.pageWindow:
  593. for window in self.pageWindow.values():
  594. window.ClearDictionary()
  595. self.__Initialize()
  596. def Show(self):
  597. if self.isLoaded==0:
  598. self.isLoaded=1
  599. self.__LoadWindow()
  600. self.RefreshGuildInfoPage()
  601. self.RefreshGuildBoardPage()
  602. self.RefreshGuildMemberPage()
  603. self.RefreshGuildSkillPage()
  604. self.RefreshGuildGradePage()
  605. ui.ScriptWindow.Show(self)
  606. def __LoadWindow(self):
  607. global DISABLE_GUILD_SKILL
  608. try:
  609. pyScrLoader = ui.PythonScriptLoader()
  610. pyScrLoader.LoadScriptFile(self, "uiscript/guildwindow.py")
  611. self.popupDialog = ui.ScriptWindow()
  612. pyScrLoader.LoadScriptFile(self.popupDialog, "UIScript/PopupDialog.py")
  613. self.changeGradeNameDialog = ChangeGradeNameDialog()
  614. pyScrLoader.LoadScriptFile(self.changeGradeNameDialog, "uiscript/changegradenamedialog.py")
  615. self.pageWindow = {
  616. "GUILD_INFO" : self.PageWindow(self, "uiscript/guildwindow_guildinfopage_eu.py"),
  617. "BOARD" : self.PageWindow(self, "uiscript/guildwindow_boardpage.py"),
  618. "MEMBER" : self.PageWindow(self, "uiscript/guildwindow_memberpage.py"),
  619. "BASE_INFO" : self.PageWindow(self, "uiscript/guildwindow_baseinfopage.py"),
  620. "SKILL" : self.PageWindow(self, "uiscript/guildwindow_guildskillpage.py"),
  621. "GRADE" : self.PageWindow(self, "uiscript/guildwindow_gradepage.py"),
  622. }
  623. for window in self.pageWindow.values():
  624. pyScrLoader.LoadScriptFile(window, window.GetScriptFileName())
  625. except:
  626. import exception
  627. exception.Abort("GuildWindow.__LoadWindow.LoadScript")
  628. try:
  629. getObject = self.GetChild
  630. self.board = getObject("Board")
  631. self.pageName = {
  632. "GUILD_INFO" : localeInfo.GUILD_TILE_INFO,
  633. "BOARD" : localeInfo.GUILD_TILE_BOARD,
  634. "MEMBER" : localeInfo.GUILD_TILE_MEMBER,
  635. "BASE_INFO" : localeInfo.GUILD_TILE_BASEINFO,
  636. "SKILL" : localeInfo.GUILD_TILE_SKILL,
  637. "GRADE" : localeInfo.GUILD_TILE_GRADE,
  638. }
  639. self.tabDict = {
  640. "GUILD_INFO" : getObject("Tab_01"),
  641. "BOARD" : getObject("Tab_02"),
  642. "MEMBER" : getObject("Tab_03"),
  643. "BASE_INFO" : getObject("Tab_04"),
  644. "SKILL" : getObject("Tab_05"),
  645. "GRADE" : getObject("Tab_06"),
  646. }
  647. self.tabButtonDict = {
  648. "GUILD_INFO" : getObject("Tab_Button_01"),
  649. "BOARD" : getObject("Tab_Button_02"),
  650. "MEMBER" : getObject("Tab_Button_03"),
  651. "BASE_INFO" : getObject("Tab_Button_04"),
  652. "SKILL" : getObject("Tab_Button_05"),
  653. "GRADE" : getObject("Tab_Button_06"),
  654. }
  655. ## QuestionDialog
  656. self.popupMessage = self.popupDialog.GetChild("message")
  657. self.popupDialog.GetChild("accept").SetEvent(ui.__mem_func__(self.popupDialog.Hide))
  658. ## ChangeGradeName
  659. self.changeGradeNameDialog.GetChild("AcceptButton").SetEvent(ui.__mem_func__(self.OnChangeGradeName))
  660. self.changeGradeNameDialog.GetChild("CancelButton").SetEvent(ui.__mem_func__(self.changeGradeNameDialog.Hide))
  661. self.changeGradeNameDialog.GetChild("Board").SetCloseEvent(ui.__mem_func__(self.changeGradeNameDialog.Hide))
  662. self.changeGradeNameDialog.gradeNameSlot = self.changeGradeNameDialog.GetChild("GradeNameValue")
  663. self.changeGradeNameDialog.gradeNameSlot.OnIMEReturn = ui.__mem_func__(self.OnChangeGradeName)
  664. self.changeGradeNameDialog.gradeNameSlot.OnPressEscapeKey = ui.__mem_func__(self.changeGradeNameDialog.Close)
  665. ## Comment
  666. self.commentSlot = self.pageWindow["BOARD"].GetChild("CommentValue")
  667. self.commentSlot.OnIMEReturn = ui.__mem_func__(self.OnPostComment)
  668. #self.commentSlot.OnKeyDown = ui.__mem_func__(self.OnKeyDownInBoardPage)
  669. self.commentSlot.OnKeyDown = lambda key, argSelf=self: argSelf.OnKeyDownInBoardPage(key)
  670. ## RefreshButton
  671. self.pageWindow["BOARD"].GetChild("RefreshButton").SetEvent(ui.__mem_func__(self.OnRefreshComments))
  672. ## ScrollBar
  673. scrollBar = self.pageWindow["MEMBER"].GetChild("ScrollBar")
  674. scrollBar.SetScrollEvent(ui.__mem_func__(self.OnScrollMemberLine))
  675. self.pageWindow["MEMBER"].scrollBar = scrollBar
  676. except:
  677. import exception
  678. exception.Abort("GuildWindow.__LoadWindow.BindObject")
  679. self.__MakeInfoPage()
  680. self.__MakeBoardPage()
  681. self.__MakeMemberPage()
  682. self.__MakeBaseInfoPage()
  683. self.__MakeSkillPage()
  684. self.__MakeGradePage()
  685. for page in self.pageWindow.values():
  686. page.UpdateRect()
  687. for key, btn in self.tabButtonDict.items():
  688. btn.SetEvent(self.SelectPage, key)
  689. self.tabButtonDict["BASE_INFO"].Disable()
  690. if DISABLE_GUILD_SKILL:
  691. self.tabButtonDict["SKILL"].Disable()
  692. self.board.SetCloseEvent(ui.__mem_func__(self.Close))
  693. self.board.SetTitleColor(0xffffffff)
  694. self.SelectPage("GUILD_INFO")
  695. self.offerDialog = uiPickMoney.PickMoneyDialog()
  696. self.offerDialog.LoadDialog()
  697. self.offerDialog.SetMax(9)
  698. self.offerDialog.SetTitleName(localeInfo.GUILD_OFFER_EXP)
  699. self.offerDialog.SetAcceptEvent(ui.__mem_func__(self.OnOffer))
  700. def __MakeInfoPage(self):
  701. page = self.pageWindow["GUILD_INFO"]
  702. try:
  703. page.nameSlot = page.GetChild("GuildNameValue")
  704. page.masterNameSlot = page.GetChild("GuildMasterNameValue")
  705. page.guildLevelSlot = page.GetChild("GuildLevelValue")
  706. page.curExpSlot = page.GetChild("CurrentExperienceValue")
  707. page.lastExpSlot = page.GetChild("LastExperienceValue")
  708. page.memberCountSlot = page.GetChild("GuildMemberCountValue")
  709. page.levelAverageSlot = page.GetChild("GuildMemberLevelAverageValue")
  710. page.uploadMarkButton = page.GetChild("UploadGuildMarkButton")
  711. page.uploadSymbolButton = page.GetChild("UploadGuildSymbolButton")
  712. page.declareWarButton = page.GetChild("DeclareWarButton")
  713. try:
  714. page.guildMoneySlot = page.GetChild("GuildMoneyValue")
  715. except KeyError:
  716. page.guildMoneySlot = None
  717. try:
  718. page.GetChild("DepositButton").SetEvent(ui.__mem_func__(self.__OnClickDepositButton))
  719. page.GetChild("WithdrawButton").SetEvent(ui.__mem_func__(self.__OnClickWithdrawButton))
  720. except KeyError:
  721. pass
  722. page.uploadMarkButton.SetEvent(ui.__mem_func__(self.__OnClickSelectGuildMarkButton))
  723. page.uploadSymbolButton.SetEvent(ui.__mem_func__(self.__OnClickSelectGuildSymbolButton))
  724. page.declareWarButton.SetEvent(ui.__mem_func__(self.__OnClickDeclareWarButton))
  725. page.GetChild("OfferButton").SetEvent(ui.__mem_func__(self.__OnClickOfferButton))
  726. page.GetChild("EnemyGuildCancel1").Hide()
  727. page.GetChild("EnemyGuildCancel2").Hide()
  728. page.GetChild("EnemyGuildCancel3").Hide()
  729. page.GetChild("EnemyGuildCancel4").Hide()
  730. page.GetChild("EnemyGuildCancel5").Hide()
  731. page.GetChild("EnemyGuildCancel6").Hide()
  732. self.enemyGuildNameList.append(page.GetChild("EnemyGuildName1"))
  733. self.enemyGuildNameList.append(page.GetChild("EnemyGuildName2"))
  734. self.enemyGuildNameList.append(page.GetChild("EnemyGuildName3"))
  735. self.enemyGuildNameList.append(page.GetChild("EnemyGuildName4"))
  736. self.enemyGuildNameList.append(page.GetChild("EnemyGuildName5"))
  737. self.enemyGuildNameList.append(page.GetChild("EnemyGuildName6"))
  738. self.largeMarkBox = page.GetChild("LargeGuildMark")
  739. except:
  740. import exception
  741. exception.Abort("GuildWindow.__MakeInfoPage")
  742. self.largeMarkBox.AddFlag("not_pick")
  743. self.markSelectDialog=uiUploadMark.MarkSelectDialog()
  744. self.markSelectDialog.SAFE_SetSelectEvent(self.__OnSelectMark)
  745. self.symbolSelectDialog=uiUploadMark.SymbolSelectDialog()
  746. self.symbolSelectDialog.SAFE_SetSelectEvent(self.__OnSelectSymbol)
  747. def __MakeBoardPage(self):
  748. i = 0
  749. lineStep = 20
  750. page = self.pageWindow["BOARD"]
  751. page.boardDict = {}
  752. for i in xrange(12):
  753. yPos = 25 + i * lineStep
  754. noticeMarkImage = ui.MakeImageBox(page, "d:/ymir work/ui/game/guild/notice_mark.sub", 5, yPos+3)
  755. noticeMarkImage.Hide()
  756. page.Children.append(noticeMarkImage)
  757. ## Name
  758. ## 13.12.02 ¾Æ¶ø¼öÁ¤
  759. nameSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_03.sub", 15, yPos)
  760. nameSlot = ui.MakeTextLine(nameSlotImage)
  761. page.Children.append(nameSlotImage)
  762. page.Children.append(nameSlot)
  763. ## Delete Button
  764. deleteButton = ui.MakeButton(page, 340, yPos + 3, localeInfo.GUILD_DELETE, "d:/ymir work/ui/public/", "close_button_01.sub", "close_button_02.sub", "close_button_03.sub")
  765. deleteButton.SetEvent(ui.__mem_func__(self.OnDeleteComment), i)
  766. page.Children.append(deleteButton)
  767. ## Comment
  768. ## 13.12.02 ¾Æ¶ø¼öÁ¤
  769. commentSlot = CommentSlot()
  770. commentSlot.SetParent(page)
  771. commentSlot.SetPosition(114, yPos)
  772. commentSlot.Show()
  773. page.Children.append(commentSlot)
  774. boardSlotList = []
  775. boardSlotList.append(noticeMarkImage)
  776. boardSlotList.append(nameSlot)
  777. boardSlotList.append(commentSlot)
  778. page.boardDict[i] = boardSlotList
  779. ## PostComment - Have to make this here for that fit tooltip's position.
  780. ## 13.12.02 ¾Æ¶ø¼öÁ¤
  781. postCommentButton = ui.MakeButton(page, 337, 273, localeInfo.GUILD_COMMENT, "d:/ymir work/ui/game/taskbar/", "Send_Chat_Button_01.sub", "Send_Chat_Button_02.sub", "Send_Chat_Button_03.sub")
  782. postCommentButton.SetEvent(ui.__mem_func__(self.OnPostComment))
  783. page.Children.append(postCommentButton)
  784. def __MakeMemberPage(self):
  785. page = self.pageWindow["MEMBER"]
  786. lineStep = 20
  787. page.memberDict = {}
  788. for i in xrange(self.MEMBER_LINE_COUNT):
  789. inverseLineIndex = self.MEMBER_LINE_COUNT - i - 1
  790. yPos = 28 + inverseLineIndex*lineStep
  791. ## 13.12.02 ¾Æ¶ø ¼öÁ¤
  792. ## Name
  793. nameSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_03.sub", 10, yPos)
  794. nameSlot = ui.MakeTextLine(nameSlotImage)
  795. page.Children.append(nameSlotImage)
  796. page.Children.append(nameSlot)
  797. ## Grade
  798. gradeSlot = ui.ComboBox()
  799. gradeSlot.SetParent(page)
  800. gradeSlot.SetPosition(101, yPos-1)
  801. gradeSlot.SetSize(61, 18)
  802. gradeSlot.SetEvent(lambda gradeNumber, lineIndex=inverseLineIndex, argSelf=proxy(self): argSelf.OnChangeMemberGrade(lineIndex, gradeNumber))
  803. gradeSlot.Show()
  804. page.Children.append(gradeSlot)
  805. ## Job
  806. jobSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_00.sub", 170, yPos)
  807. jobSlot = ui.MakeTextLine(jobSlotImage)
  808. page.Children.append(jobSlotImage)
  809. page.Children.append(jobSlot)
  810. ## Level
  811. levelSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_00.sub", 210, yPos)
  812. levelSlot = ui.MakeTextLine(levelSlotImage)
  813. page.Children.append(levelSlotImage)
  814. page.Children.append(levelSlot)
  815. ## Offer
  816. offerSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_00.sub", 250, yPos)
  817. offerSlot = ui.MakeTextLine(offerSlotImage)
  818. page.Children.append(offerSlotImage)
  819. page.Children.append(offerSlot)
  820. ## General Enable
  821. event = lambda argSelf=proxy(self), argIndex=inverseLineIndex: apply(argSelf.OnEnableGeneral, (argIndex,))
  822. generalEnableCheckBox = CheckBox(page, 297, yPos, event, "d:/ymir work/ui/public/Parameter_Slot_00.sub")
  823. page.Children.append(generalEnableCheckBox)
  824. memberSlotList = []
  825. memberSlotList.append(nameSlot)
  826. memberSlotList.append(gradeSlot)
  827. memberSlotList.append(jobSlot)
  828. memberSlotList.append(levelSlot)
  829. memberSlotList.append(offerSlot)
  830. memberSlotList.append(generalEnableCheckBox)
  831. page.memberDict[inverseLineIndex] = memberSlotList
  832. def __MakeBaseInfoPage(self):
  833. page = self.pageWindow["BASE_INFO"]
  834. page.buildingDataDict = {}
  835. lineStep = 20
  836. GUILD_BUILDING_MAX_NUM = 7
  837. yPos = 95 + 35
  838. for i in xrange(GUILD_BUILDING_MAX_NUM):
  839. nameSlotImage = ui.MakeSlotBar(page, 15, yPos, 78, 17)
  840. nameSlot = ui.MakeTextLine(nameSlotImage)
  841. page.Children.append(nameSlotImage)
  842. page.Children.append(nameSlot)
  843. nameSlot.SetText(localeInfo.GUILD_BUILDING_NAME)
  844. gradeSlotImage = ui.MakeSlotBar(page, 99, yPos, 26, 17)
  845. gradeSlot = ui.MakeTextLine(gradeSlotImage)
  846. page.Children.append(gradeSlotImage)
  847. page.Children.append(gradeSlot)
  848. gradeSlot.SetText(localeInfo.GUILD_BUILDING_GRADE)
  849. RESOURCE_MAX_NUM = 6
  850. for j in xrange(RESOURCE_MAX_NUM):
  851. resourceSlotImage = ui.MakeSlotBar(page, 131 + 29*j, yPos, 26, 17)
  852. resourceSlot = ui.MakeTextLine(resourceSlotImage)
  853. page.Children.append(resourceSlotImage)
  854. page.Children.append(resourceSlot)
  855. resourceSlot.SetText(localeInfo.GUILD_GEM)
  856. event = lambda *arg: None
  857. powerSlot = CheckBox(page, 308, yPos, event, "d:/ymir work/ui/public/Parameter_Slot_00.sub")
  858. page.Children.append(powerSlot)
  859. yPos += lineStep
  860. def __MakeSkillPage(self):
  861. page = self.pageWindow["SKILL"]
  862. page.skillPoint = page.GetChild("Skill_Plus_Value")
  863. page.passiveSlot = page.GetChild("Passive_Skill_Slot_Table")
  864. page.activeSlot = page.GetChild("Active_Skill_Slot_Table")
  865. page.affectSlot = page.GetChild("Affect_Slot_Table")
  866. page.gpGauge = page.GetChild("Dragon_God_Power_Gauge")
  867. page.gpValue = page.GetChild("Dragon_God_Power_Value")
  868. page.btnHealGSP = page.GetChild("Heal_GSP_Button")
  869. page.activeSlot.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
  870. page.activeSlot.SetOverInItemEvent(lambda slotNumber, type=self.GUILD_SKILL_ACTIVE_SLOT: self.OverInItem(slotNumber, type))
  871. page.activeSlot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  872. page.activeSlot.SetSelectItemSlotEvent(lambda slotNumber, type=self.GUILD_SKILL_ACTIVE_SLOT: self.OnPickUpGuildSkill(slotNumber, type))
  873. page.activeSlot.SetUnselectItemSlotEvent(lambda slotNumber, type=self.GUILD_SKILL_ACTIVE_SLOT: self.OnUseGuildSkill(slotNumber, type))
  874. page.activeSlot.SetPressedSlotButtonEvent(lambda slotNumber, type=self.GUILD_SKILL_ACTIVE_SLOT: self.OnUpGuildSkill(slotNumber, type))
  875. page.activeSlot.AppendSlotButton("d:/ymir work/ui/game/windows/btn_plus_up.sub",\
  876. "d:/ymir work/ui/game/windows/btn_plus_over.sub",\
  877. "d:/ymir work/ui/game/windows/btn_plus_down.sub")
  878. page.passiveSlot.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
  879. page.passiveSlot.SetOverInItemEvent(lambda slotNumber, type=self.GUILD_SKILL_PASSIVE_SLOT: self.OverInItem(slotNumber, type))
  880. page.passiveSlot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  881. page.passiveSlot.SetPressedSlotButtonEvent(lambda slotNumber, type=self.GUILD_SKILL_PASSIVE_SLOT: self.OnUpGuildSkill(slotNumber, type))
  882. page.passiveSlot.AppendSlotButton("d:/ymir work/ui/game/windows/btn_plus_up.sub",\
  883. "d:/ymir work/ui/game/windows/btn_plus_over.sub",\
  884. "d:/ymir work/ui/game/windows/btn_plus_down.sub")
  885. page.affectSlot.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
  886. page.affectSlot.SetOverInItemEvent(lambda slotNumber, type=self.GUILD_SKILL_AFFECT_SLOT: self.OverInItem(slotNumber, type))
  887. page.affectSlot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  888. page.btnHealGSP.SetEvent(ui.__mem_func__(self.__OnOpenHealGSPBoard))
  889. ## Passive
  890. """
  891. for i in xrange(len(playerSettingModule.PASSIVE_GUILD_SKILL_INDEX_LIST)):
  892. slotIndex = page.passiveSlot.GetStartIndex()+i
  893. skillIndex = playerSettingModule.PASSIVE_GUILD_SKILL_INDEX_LIST[i]
  894. page.passiveSlot.SetSkillSlot(slotIndex, skillIndex, 0)
  895. page.passiveSlot.RefreshSlot()
  896. guild.SetSkillIndex(slotIndex, i)
  897. """
  898. ## Active
  899. for i in xrange(len(playerSettingModule.ACTIVE_GUILD_SKILL_INDEX_LIST)):
  900. slotIndex = page.activeSlot.GetStartIndex()+i
  901. skillIndex = playerSettingModule.ACTIVE_GUILD_SKILL_INDEX_LIST[i]
  902. page.activeSlot.SetSkillSlot(slotIndex, skillIndex, 0)
  903. page.activeSlot.SetCoverButton(slotIndex)
  904. page.activeSlot.RefreshSlot()
  905. guild.SetSkillIndex(slotIndex, len(playerSettingModule.PASSIVE_GUILD_SKILL_INDEX_LIST)+i)
  906. def __MakeGradePage(self):
  907. lineStep = 18
  908. page = self.pageWindow["GRADE"]
  909. page.gradeDict = {}
  910. for i in xrange(15):
  911. yPos = 22 + i*lineStep
  912. index = i+1
  913. ## 13.12.02 ¾Æ¶ø ¼öÁ¤
  914. ## GradeNumber
  915. gradeNumberSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_00.sub", 14, yPos)
  916. gradeNumberSlot = ui.MakeTextLine(gradeNumberSlotImage)
  917. gradeNumberSlot.SetText(str(i+1))
  918. page.Children.append(gradeNumberSlotImage)
  919. page.Children.append(gradeNumberSlot)
  920. ## GradeName
  921. gradeNameSlot = EditableTextSlot(page, 58, yPos)
  922. gradeNameSlot.SetEvent(ui.__mem_func__(self.OnOpenChangeGradeName), index)
  923. page.Children.append(gradeNameSlot)
  924. ## Invite Authority
  925. event = lambda argSelf=proxy(self), argIndex=index, argAuthority=1<<0: apply(argSelf.OnCheckAuthority, (argIndex,argAuthority))
  926. inviteAuthorityCheckBox = CheckBox(page, 124, yPos, event)
  927. page.Children.append(inviteAuthorityCheckBox)
  928. ## DriveOut Authority
  929. event = lambda argSelf=proxy(self), argIndex=index, argAuthority=1<<1: apply(argSelf.OnCheckAuthority, (argIndex,argAuthority))
  930. driveoutAuthorityCheckBox = CheckBox(page, 181, yPos, event)
  931. page.Children.append(driveoutAuthorityCheckBox)
  932. ## Notice Authority
  933. event = lambda argSelf=proxy(self), argIndex=index, argAuthority=1<<2: apply(argSelf.OnCheckAuthority, (argIndex,argAuthority))
  934. noticeAuthorityCheckBox = CheckBox(page, 238, yPos, event)
  935. page.Children.append(noticeAuthorityCheckBox)
  936. ## Skill Authority
  937. event = lambda argSelf=proxy(self), argIndex=index, argAuthority=1<<3: apply(argSelf.OnCheckAuthority, (argIndex,argAuthority))
  938. skillAuthorityCheckBox = CheckBox(page, 295, yPos, event)
  939. page.Children.append(skillAuthorityCheckBox)
  940. gradeSlotList = []
  941. gradeSlotList.append(gradeNameSlot)
  942. gradeSlotList.append(inviteAuthorityCheckBox)
  943. gradeSlotList.append(driveoutAuthorityCheckBox)
  944. gradeSlotList.append(noticeAuthorityCheckBox)
  945. gradeSlotList.append(skillAuthorityCheckBox)
  946. page.gradeDict[index] = gradeSlotList
  947. masterSlotList = page.gradeDict[1]
  948. for slot in masterSlotList:
  949. slot.Disable()
  950. def CanOpen(self):
  951. return guild.IsGuildEnable()
  952. def Open(self):
  953. self.Show()
  954. self.SetTop()
  955. guildID = net.GetGuildID()
  956. self.largeMarkBox.SetIndex(guildID)
  957. self.largeMarkBox.SetScale(3)
  958. def Close(self):
  959. self.__CloseAllGuildMemberPageGradeComboBox()
  960. self.offerDialog.Close()
  961. self.popupDialog.Hide()
  962. self.changeGradeNameDialog.Hide()
  963. self.Hide()
  964. if self.tooltipSkill:
  965. self.tooltipSkill.Hide()
  966. self.pickDialog = None
  967. self.questionDialog = None
  968. self.moneyDialog = None
  969. def Destroy(self):
  970. self.ClearDictionary()
  971. self.board = None
  972. self.pageName = None
  973. self.tabDict = None
  974. self.tabButtonDict = None
  975. self.pickDialog = None
  976. self.questionDialog = None
  977. self.markSelectDialog = None
  978. self.symbolSelectDialog = None
  979. if self.offerDialog:
  980. self.offerDialog.Destroy()
  981. self.offerDialog = None
  982. if self.popupDialog:
  983. self.popupDialog.ClearDictionary()
  984. self.popupDialog = None
  985. if self.changeGradeNameDialog:
  986. self.changeGradeNameDialog.ClearDictionary()
  987. self.changeGradeNameDialog = None
  988. self.popupMessage = None
  989. self.commentSlot = None
  990. if self.pageWindow:
  991. for window in self.pageWindow.values():
  992. window.ClearDictionary()
  993. self.pageWindow = None
  994. self.tooltipSkill = None
  995. self.moneyDialog = None
  996. self.enemyGuildNameList = []
  997. def DeleteGuild(self):
  998. self.RefreshGuildInfoPage()
  999. self.RefreshGuildBoardPage()
  1000. self.RefreshGuildMemberPage()
  1001. self.RefreshGuildSkillPage()
  1002. self.RefreshGuildGradePage()
  1003. self.Hide()
  1004. def SetSkillToolTip(self, tooltipSkill):
  1005. self.tooltipSkill = tooltipSkill
  1006. def SelectPage(self, arg):
  1007. if "BOARD" == arg:
  1008. self.OnRefreshComments()
  1009. for key, btn in self.tabButtonDict.items():
  1010. if arg != key:
  1011. btn.SetUp()
  1012. for key, img in self.tabDict.items():
  1013. if arg == key:
  1014. img.Show()
  1015. else:
  1016. img.Hide()
  1017. for key, page in self.pageWindow.items():
  1018. if arg == key:
  1019. page.Show()
  1020. else:
  1021. page.Hide()
  1022. self.board.SetTitleName(self.pageName[arg])
  1023. self.__CloseAllGuildMemberPageGradeComboBox()
  1024. def __CloseAllGuildMemberPageGradeComboBox(self):
  1025. page = self.pageWindow["MEMBER"]
  1026. for key, slotList in page.memberDict.items():
  1027. slotList[1].CloseListBox()
  1028. def RefreshGuildInfoPage(self):
  1029. if self.isLoaded==0:
  1030. return
  1031. global DISABLE_DECLARE_WAR
  1032. page = self.pageWindow["GUILD_INFO"]
  1033. page.nameSlot.SetText(guild.GetGuildName())
  1034. page.masterNameSlot.SetText(guild.GetGuildMasterName())
  1035. page.guildLevelSlot.SetText(str(guild.GetGuildLevel()))
  1036. if page.guildMoneySlot:
  1037. page.guildMoneySlot.SetText(str(guild.GetGuildMoney()))
  1038. curExp, lastExp = guild.GetGuildExperience()
  1039. curExp *= 100
  1040. lastExp *= 100
  1041. page.curExpSlot.SetText(str(curExp))
  1042. page.lastExpSlot.SetText(str(lastExp))
  1043. curMemberCount, maxMemberCount = guild.GetGuildMemberCount()
  1044. if maxMemberCount== 0xffff:
  1045. page.memberCountSlot.SetText("%d / %s " % (curMemberCount, localeInfo.GUILD_MEMBER_COUNT_INFINITY))
  1046. else:
  1047. page.memberCountSlot.SetText("%d / %d" % (curMemberCount, maxMemberCount))
  1048. page.levelAverageSlot.SetText(str(guild.GetGuildMemberLevelAverage()))
  1049. ## ±æµåÀ常 ±æµå ¸¶Å©¿Í ±æµåÀü ½Åû ¹öÆ°À» º¼ ¼ö ÀÖÀ½
  1050. mainCharacterName = player.GetMainCharacterName()
  1051. masterName = guild.GetGuildMasterName()
  1052. if mainCharacterName == masterName:
  1053. page.uploadMarkButton.Show()
  1054. if DISABLE_DECLARE_WAR:
  1055. page.declareWarButton.Hide()
  1056. else:
  1057. page.declareWarButton.Show()
  1058. if guild.HasGuildLand():
  1059. page.uploadSymbolButton.Show()
  1060. else:
  1061. page.uploadSymbolButton.Hide()
  1062. else:
  1063. page.uploadMarkButton.Hide()
  1064. page.declareWarButton.Hide()
  1065. page.uploadSymbolButton.Hide()
  1066. ## Refresh ½Ã¿¡ ±æµåÀü Á¤º¸ ¾÷µ¥ÀÌÆ®
  1067. for i in xrange(guild.ENEMY_GUILD_SLOT_MAX_COUNT):
  1068. name = guild.GetEnemyGuildName(i)
  1069. nameTextLine = self.enemyGuildNameList[i]
  1070. if name:
  1071. nameTextLine.SetText(name)
  1072. else:
  1073. nameTextLine.SetText(localeInfo.GUILD_INFO_ENEMY_GUILD_EMPTY)
  1074. def __GetGuildBoardCommentData(self, index):
  1075. commentID, chrName, comment = guild.GetGuildBoardCommentData(index)
  1076. if 0==commentID:
  1077. if ""==chrName:
  1078. chrName=localeInfo.UI_NONAME
  1079. if ""==comment:
  1080. comment=localeInfo.UI_NOCONTENTS
  1081. return commentID, chrName, comment
  1082. def RefreshGuildBoardPage(self):
  1083. if self.isLoaded==0:
  1084. return
  1085. page = self.pageWindow["BOARD"]
  1086. self.BOARD_LINE_MAX_NUM = 12
  1087. lineIndex = 0
  1088. commentCount = guild.GetGuildBoardCommentCount()
  1089. for i in xrange(commentCount):
  1090. commentID, chrName, comment = self.__GetGuildBoardCommentData(i)
  1091. if not comment:
  1092. continue
  1093. slotList = page.boardDict[lineIndex]
  1094. if "!" == comment[0]:
  1095. slotList[0].Show()
  1096. slotList[1].SetText(chrName)
  1097. slotList[2].SetText(comment[1:])
  1098. else:
  1099. slotList[0].Hide()
  1100. slotList[1].SetText(chrName)
  1101. slotList[2].SetText(comment)
  1102. lineIndex += 1
  1103. for i in xrange(self.BOARD_LINE_MAX_NUM - lineIndex):
  1104. slotList = page.boardDict[lineIndex+i]
  1105. slotList[0].Hide()
  1106. slotList[1].SetText("")
  1107. slotList[2].SetText("")
  1108. def RefreshGuildMemberPage(self):
  1109. if self.isLoaded==0:
  1110. return
  1111. page = self.pageWindow["MEMBER"]
  1112. ## ScrollBar
  1113. count = guild.GetMemberCount()
  1114. if count > self.MEMBER_LINE_COUNT:
  1115. page.scrollBar.SetMiddleBarSize(float(self.MEMBER_LINE_COUNT) / float(count))
  1116. page.scrollBar.Show()
  1117. else:
  1118. page.scrollBar.Hide()
  1119. self.RefreshGuildMemberPageGradeComboBox()
  1120. self.RefreshGuildMemberPageMemberList()
  1121. def RefreshGuildMemberPageMemberList(self):
  1122. if self.isLoaded==0:
  1123. return
  1124. page = self.pageWindow["MEMBER"]
  1125. for line, slotList in page.memberDict.items():
  1126. gradeComboBox = slotList[1]
  1127. gradeComboBox.Disable()
  1128. if not guild.IsMember(line):
  1129. slotList[0].SetText("")
  1130. slotList[2].SetText("")
  1131. slotList[3].SetText("")
  1132. slotList[4].SetText("")
  1133. slotList[5].SetCheck(False)
  1134. continue
  1135. pid, name, grade, race, level, offer, general = self.GetMemberData(line)
  1136. if pid < 0:
  1137. continue
  1138. job = chr.RaceToJob(race)
  1139. guildExperienceSummary = guild.GetGuildExperienceSummary()
  1140. offerPercentage = 0
  1141. if guildExperienceSummary > 0:
  1142. offerPercentage = int(float(offer) / float(guildExperienceSummary) * 100.0)
  1143. slotList[0].SetText(name)
  1144. slotList[2].SetText(self.JOB_NAME.get(job, "?"))
  1145. slotList[3].SetText(str(level))
  1146. slotList[4].SetText(str(offerPercentage) + "%")
  1147. slotList[5].SetCheck(general)
  1148. gradeComboBox.SetCurrentItem(guild.GetGradeName(grade))
  1149. if 1 != grade:
  1150. gradeComboBox.Enable()
  1151. def RefreshGuildMemberPageGradeComboBox(self):
  1152. if self.isLoaded==0:
  1153. return
  1154. page = self.pageWindow["MEMBER"]
  1155. self.CAN_CHANGE_GRADE_COUNT = 15 - 1
  1156. for key, slotList in page.memberDict.items():
  1157. gradeComboBox = slotList[1]
  1158. gradeComboBox.Disable()
  1159. if not guild.IsMember(key):
  1160. continue
  1161. pid, name, grade, job, level, offer, general = self.GetMemberData(key)
  1162. if pid < 0:
  1163. continue
  1164. gradeComboBox.ClearItem()
  1165. for i in xrange(self.CAN_CHANGE_GRADE_COUNT):
  1166. gradeComboBox.InsertItem(i+2, guild.GetGradeName(i+2))
  1167. gradeComboBox.SetCurrentItem(guild.GetGradeName(grade))
  1168. if 1 != grade:
  1169. gradeComboBox.Enable()
  1170. def RefreshGuildSkillPage(self):
  1171. if self.isLoaded==0:
  1172. return
  1173. page = self.pageWindow["SKILL"]
  1174. curPoint, maxPoint = guild.GetDragonPowerPoint()
  1175. maxPoint = max(maxPoint, 1)
  1176. page.gpValue.SetText(str(curPoint) + " / " + str(maxPoint))
  1177. percentage = (float(curPoint) / float(maxPoint) * 100) * (float(173) / float(95))
  1178. page.gpGauge.SetPercentage(int(percentage), 100)
  1179. skillPoint = guild.GetGuildSkillPoint()
  1180. page.skillPoint.SetText(str(skillPoint))
  1181. page.passiveSlot.HideAllSlotButton()
  1182. page.activeSlot.HideAllSlotButton()
  1183. ## Passive
  1184. """
  1185. for i in xrange(len(playerSettingModule.PASSIVE_GUILD_SKILL_INDEX_LIST)):
  1186. slotIndex = page.passiveSlot.GetStartIndex()+i
  1187. skillIndex = playerSettingModule.PASSIVE_GUILD_SKILL_INDEX_LIST[i]
  1188. skillLevel = guild.GetSkillLevel(slotIndex)
  1189. skillMaxLevel = skill.GetSkillMaxLevel(skillIndex)
  1190. page.passiveSlot.SetSlotCount(slotIndex, skillLevel)
  1191. if skillPoint > 0:
  1192. if skillLevel < skillMaxLevel:
  1193. page.passiveSlot.ShowSlotButton(slotIndex)
  1194. """
  1195. ## Active
  1196. for i in xrange(len(playerSettingModule.ACTIVE_GUILD_SKILL_INDEX_LIST)):
  1197. slotIndex = page.activeSlot.GetStartIndex()+i
  1198. skillIndex = playerSettingModule.ACTIVE_GUILD_SKILL_INDEX_LIST[i]
  1199. skillLevel = guild.GetSkillLevel(slotIndex)
  1200. skillMaxLevel = skill.GetSkillMaxLevel(skillIndex)
  1201. page.activeSlot.SetSlotCount(slotIndex, skillLevel)
  1202. if skillLevel <= 0:
  1203. page.activeSlot.DisableCoverButton(slotIndex)
  1204. else:
  1205. page.activeSlot.EnableCoverButton(slotIndex)
  1206. if skillPoint > 0:
  1207. if skillLevel < skillMaxLevel:
  1208. page.activeSlot.ShowSlotButton(slotIndex)
  1209. def RefreshGuildGradePage(self):
  1210. if self.isLoaded==0:
  1211. return
  1212. page = self.pageWindow["GRADE"]
  1213. for key, slotList in page.gradeDict.items():
  1214. name, authority = guild.GetGradeData(int(key))
  1215. slotList[self.GRADE_SLOT_NAME].SetText(name)
  1216. slotList[self.GRADE_ADD_MEMBER_AUTHORITY].SetCheck(authority & guild.AUTH_ADD_MEMBER)
  1217. slotList[self.GRADE_REMOVE_MEMBER_AUTHORITY].SetCheck(authority & guild.AUTH_REMOVE_MEMBER)
  1218. slotList[self.GRADE_NOTICE_AUTHORITY].SetCheck(authority & guild.AUTH_NOTICE)
  1219. slotList[self.GRADE_SKILL_AUTHORITY].SetCheck(authority & guild.AUTH_SKILL)
  1220. ## GuildInfo
  1221. def __PopupMessage(self, msg):
  1222. self.popupMessage.SetText(msg)
  1223. self.popupDialog.SetTop()
  1224. self.popupDialog.Show()
  1225. def __OnClickSelectGuildMarkButton(self):
  1226. if guild.GetGuildLevel() < int(localeInfo.GUILD_MARK_MIN_LEVEL):
  1227. self.__PopupMessage(localeInfo.GUILD_MARK_NOT_ENOUGH_LEVEL)
  1228. elif not guild.MainPlayerHasAuthority(guild.AUTH_NOTICE):
  1229. self.__PopupMessage(localeInfo.GUILD_NO_NOTICE_PERMISSION)
  1230. else:
  1231. self.markSelectDialog.Open()
  1232. def __OnClickSelectGuildSymbolButton(self):
  1233. if guild.MainPlayerHasAuthority(guild.AUTH_NOTICE):
  1234. self.symbolSelectDialog.Open()
  1235. else:
  1236. self.__PopupMessage(localeInfo.GUILD_NO_NOTICE_PERMISSION)
  1237. def __OnClickDeclareWarButton(self):
  1238. inputDialog = DeclareGuildWarDialog()
  1239. inputDialog.Open()
  1240. self.inputDialog = inputDialog
  1241. def __OnSelectMark(self, markFileName):
  1242. ret = net.UploadMark("upload/"+markFileName)
  1243. # MARK_BUG_FIX
  1244. if net.ERROR_MARK_UPLOAD_NEED_RECONNECT == ret:
  1245. self.__PopupMessage(localeInfo.UPLOAD_MARK_UPLOAD_NEED_RECONNECT);
  1246. return ret
  1247. # END_OF_MARK_BUG_FIX
  1248. def __OnSelectSymbol(self, symbolFileName):
  1249. net.UploadSymbol("upload/"+symbolFileName)
  1250. def __OnClickOfferButton(self):
  1251. curEXP = unsigned32(player.GetStatus(player.EXP))
  1252. if curEXP <= 100:
  1253. self.__PopupMessage(localeInfo.GUILD_SHORT_EXP);
  1254. return
  1255. self.offerDialog.Open(curEXP, 100)
  1256. def __OnClickDepositButton(self):
  1257. moneyDialog = uiPickMoney.PickMoneyDialog()
  1258. moneyDialog.LoadDialog()
  1259. moneyDialog.SetMax(6)
  1260. moneyDialog.SetTitleName(localeInfo.GUILD_DEPOSIT)
  1261. moneyDialog.SetAcceptEvent(ui.__mem_func__(self.OnDeposit))
  1262. moneyDialog.Open(player.GetMoney())
  1263. self.moneyDialog = moneyDialog
  1264. def __OnClickWithdrawButton(self):
  1265. moneyDialog = uiPickMoney.PickMoneyDialog()
  1266. moneyDialog.LoadDialog()
  1267. moneyDialog.SetMax(6)
  1268. moneyDialog.SetTitleName(localeInfo.GUILD_WITHDRAW)
  1269. moneyDialog.SetAcceptEvent(ui.__mem_func__(self.OnWithdraw))
  1270. moneyDialog.Open(guild.GetGuildMoney())
  1271. self.moneyDialog = moneyDialog
  1272. def __OnBlock(self):
  1273. popup = uiCommon.PopupDialog()
  1274. popup.SetText(localeInfo.NOT_YET_SUPPORT)
  1275. popup.SetAcceptEvent(self.__OnClosePopupDialog)
  1276. popup.Open()
  1277. self.popup = popup
  1278. def __OnClosePopupDialog(self):
  1279. self.popup = None
  1280. def OnDeposit(self, money):
  1281. net.SendGuildDepositMoneyPacket(money)
  1282. def OnWithdraw(self, money):
  1283. net.SendGuildWithdrawMoneyPacket(money)
  1284. def OnOffer(self, exp):
  1285. net.SendGuildOfferPacket(exp)
  1286. ## Board
  1287. def OnPostComment(self):
  1288. text = self.commentSlot.GetText()
  1289. if not text:
  1290. return False
  1291. net.SendGuildPostCommentPacket(text[:50])
  1292. self.commentSlot.SetText("")
  1293. return True
  1294. def OnDeleteComment(self, index):
  1295. commentID, chrName, comment = self.__GetGuildBoardCommentData(index)
  1296. net.SendGuildDeleteCommentPacket(commentID)
  1297. def OnRefreshComments(self):
  1298. net.SendGuildRefreshCommentsPacket(0)
  1299. def OnKeyDownInBoardPage(self, key):
  1300. if key == 63:
  1301. self.OnRefreshComments()
  1302. return True
  1303. ## Member
  1304. ## OnEnableGeneral
  1305. def OnChangeMemberGrade(self, lineIndex, gradeNumber):
  1306. PID = guild.MemberIndexToPID(lineIndex + self.memberLinePos)
  1307. net.SendGuildChangeMemberGradePacket(PID, gradeNumber)
  1308. def OnEnableGeneral(self, lineIndex):
  1309. if not guild.IsMember(lineIndex):
  1310. return
  1311. pid, name, grade, job, level, offer, general = self.GetMemberData(lineIndex)
  1312. if pid < 0:
  1313. return
  1314. net.SendGuildChangeMemberGeneralPacket(pid, 1 - general)
  1315. ## Grade
  1316. def OnOpenChangeGradeName(self, arg):
  1317. self.changeGradeNameDialog.SetGradeNumber(arg)
  1318. self.changeGradeNameDialog.Open()
  1319. def OnChangeGradeName(self):
  1320. self.changeGradeNameDialog.Hide()
  1321. gradeNumber = self.changeGradeNameDialog.GetGradeNumber()
  1322. gradeName = self.changeGradeNameDialog.GetGradeName()
  1323. if len(gradeName) == 0:
  1324. gradeName = localeInfo.GUILD_DEFAULT_GRADE
  1325. net.SendGuildChangeGradeNamePacket(gradeNumber, gradeName)
  1326. return True
  1327. def OnCheckAuthority(self, argIndex, argAuthority):
  1328. name, authority = guild.GetGradeData(argIndex)
  1329. net.SendGuildChangeGradeAuthorityPacket(argIndex, authority ^ argAuthority)
  1330. def OnScrollMemberLine(self):
  1331. scrollBar = self.pageWindow["MEMBER"].scrollBar
  1332. pos = scrollBar.GetPos()
  1333. count = guild.GetMemberCount()
  1334. newLinePos = int(float(count - self.MEMBER_LINE_COUNT) * pos)
  1335. if newLinePos != self.memberLinePos:
  1336. self.memberLinePos = newLinePos
  1337. self.RefreshGuildMemberPageMemberList()
  1338. self.__CloseAllGuildMemberPageGradeComboBox()
  1339. def GetMemberData(self, localPos):
  1340. return guild.GetMemberData(localPos + self.memberLinePos)
  1341. ## Guild Skill
  1342. def __OnOpenHealGSPBoard(self):
  1343. curPoint, maxPoint = guild.GetDragonPowerPoint()
  1344. if maxPoint - curPoint <= 0:
  1345. self.__PopupMessage(localeInfo.GUILD_CANNOT_HEAL_GSP_ANYMORE)
  1346. return
  1347. pickDialog = uiPickMoney.PickMoneyDialog()
  1348. pickDialog.LoadDialog()
  1349. pickDialog.SetMax(9)
  1350. pickDialog.SetTitleName(localeInfo.GUILD_HEAL_GSP)
  1351. pickDialog.SetAcceptEvent(ui.__mem_func__(self.__OnOpenHealGSPQuestionDialog))
  1352. pickDialog.Open(maxPoint - curPoint, 1)
  1353. self.pickDialog = pickDialog
  1354. def __OnOpenHealGSPQuestionDialog(self, healGSP):
  1355. money = healGSP * constInfo.GUILD_MONEY_PER_GSP
  1356. questionDialog = uiCommon.QuestionDialog()
  1357. questionDialog.SetText(localeInfo.GUILD_DO_YOU_HEAL_GSP % (money, healGSP))
  1358. questionDialog.SetAcceptEvent(ui.__mem_func__(self.__OnHealGSP))
  1359. questionDialog.SetCancelEvent(ui.__mem_func__(self.__OnCloseQuestionDialog))
  1360. questionDialog.SetWidth(400)
  1361. questionDialog.Open()
  1362. questionDialog.healGSP = healGSP
  1363. self.questionDialog = questionDialog
  1364. def __OnHealGSP(self):
  1365. net.SendGuildChargeGSPPacket(self.questionDialog.healGSP)
  1366. self.__OnCloseQuestionDialog()
  1367. def __OnCloseQuestionDialog(self):
  1368. if self.questionDialog:
  1369. self.questionDialog.Close()
  1370. self.questionDialog = None
  1371. def OnPickUpGuildSkill(self, skillSlotIndex, type):
  1372. mouseController = mouseModule.mouseController
  1373. if False == mouseController.isAttached():
  1374. skillIndex = player.GetSkillIndex(skillSlotIndex)
  1375. skillLevel = guild.GetSkillLevel(skillSlotIndex)
  1376. if skill.CanUseSkill(skillIndex) and skillLevel > 0:
  1377. if app.IsPressed(app.DIK_LCONTROL):
  1378. player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_SKILL, skillSlotIndex)
  1379. return
  1380. mouseController.AttachObject(self, player.SLOT_TYPE_SKILL, skillSlotIndex, skillIndex)
  1381. else:
  1382. mouseController.DeattachObject()
  1383. def OnUseGuildSkill(self, slotNumber, type):
  1384. skillIndex = player.GetSkillIndex(slotNumber)
  1385. skillLevel = guild.GetSkillLevel(slotNumber)
  1386. if skillLevel <= 0:
  1387. return
  1388. player.UseGuildSkill(slotNumber)
  1389. def OnUpGuildSkill(self, slotNumber, type):
  1390. skillIndex = player.GetSkillIndex(slotNumber)
  1391. net.SendChatPacket("/gskillup " + str(skillIndex))
  1392. def OnUseSkill(self, slotNumber, coolTime):
  1393. if self.isLoaded==0:
  1394. return
  1395. page = self.pageWindow["SKILL"]
  1396. if page.activeSlot.HasSlot(slotNumber):
  1397. page.activeSlot.SetSlotCoolTime(slotNumber, coolTime)
  1398. def OnStartGuildWar(self, guildSelf, guildOpp):
  1399. if self.isLoaded==0:
  1400. return
  1401. if guild.GetGuildID() != guildSelf:
  1402. return
  1403. guildName = guild.GetGuildName(guildOpp)
  1404. for guildNameTextLine in self.enemyGuildNameList:
  1405. if localeInfo.GUILD_INFO_ENEMY_GUILD_EMPTY == guildNameTextLine.GetText():
  1406. guildNameTextLine.SetText(guildName)
  1407. return
  1408. def OnEndGuildWar(self, guildSelf, guildOpp):
  1409. if self.isLoaded==0:
  1410. return
  1411. if guild.GetGuildID() != guildSelf:
  1412. return
  1413. guildName = guild.GetGuildName(guildOpp)
  1414. for guildNameTextLine in self.enemyGuildNameList:
  1415. if guildName == guildNameTextLine.GetText():
  1416. guildNameTextLine.SetText(localeInfo.GUILD_INFO_ENEMY_GUILD_EMPTY)
  1417. return
  1418. ## ToolTip
  1419. def OverInItem(self, slotNumber, type):
  1420. if mouseModule.mouseController.isAttached():
  1421. return
  1422. if None != self.tooltipSkill:
  1423. skillIndex = player.GetSkillIndex(slotNumber)
  1424. skillLevel = guild.GetSkillLevel(slotNumber)
  1425. self.tooltipSkill.SetSkill(skillIndex, skillLevel)
  1426. def OverOutItem(self):
  1427. if None != self.tooltipSkill:
  1428. self.tooltipSkill.HideToolTip()
  1429. def OnPressEscapeKey(self):
  1430. self.Close()
  1431. return True
  1432. class BuildGuildBuildingWindow(ui.ScriptWindow):
  1433. GUILD_CATEGORY_LIST = (
  1434. ("HEADQUARTER", localeInfo.GUILD_HEADQUARTER),
  1435. ("FACILITY", localeInfo.GUILD_FACILITY),
  1436. ("OBJECT", localeInfo.GUILD_OBJECT),
  1437. )
  1438. MODE_VIEW = 0
  1439. MODE_POSITIONING = 1
  1440. MODE_PREVIEW = 2
  1441. BUILDING_ALPHA = 0.55
  1442. ENABLE_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
  1443. DISABLE_COLOR = grp.GenerateColor(0.9, 0.4745, 0.4627, 1.0)
  1444. START_INSTANCE_INDEX = 123450
  1445. #WALL_SET_INSTANCE = 14105
  1446. def __init__(self):
  1447. ui.ScriptWindow.__init__(self)
  1448. self.__LoadWindow()
  1449. self.closeEvent = None
  1450. self.popup = None
  1451. self.mode = self.MODE_VIEW
  1452. self.race = 0
  1453. self.type = None
  1454. self.x = 0
  1455. self.y = 0
  1456. self.z = 0
  1457. self.rot_x = 0
  1458. self.rot_y = 0
  1459. self.rot_z = 0
  1460. self.rot_x_limit = 0
  1461. self.rot_y_limit = 0
  1462. self.rot_z_limit = 0
  1463. self.needMoney = 0
  1464. self.needStoneCount = 0
  1465. self.needLogCount = 0
  1466. self.needPlywoodCount = 0
  1467. #self.index = 0
  1468. self.indexList = []
  1469. self.raceList = []
  1470. self.posList = []
  1471. self.rotList = []
  1472. index = 0
  1473. for category in self.GUILD_CATEGORY_LIST:
  1474. self.categoryList.InsertItem(index, category[1])
  1475. index += 1
  1476. def __del__(self):
  1477. ui.ScriptWindow.__del__(self)
  1478. def __LoadWindow(self):
  1479. try:
  1480. pyScrLoader = ui.PythonScriptLoader()
  1481. pyScrLoader.LoadScriptFile(self, "uiscript/buildguildbuildingwindow.py")
  1482. except:
  1483. import exception
  1484. exception.Abort("DeclareGuildWarWindow.__CreateDialog - LoadScript")
  1485. try:
  1486. getObject = self.GetChild
  1487. self.board = getObject("Board")
  1488. self.categoryList = getObject("CategoryList")
  1489. self.buildingList = getObject("BuildingList")
  1490. self.listScrollBar = getObject("ListScrollBar")
  1491. self.positionButton = getObject("PositionButton")
  1492. self.previewButton = getObject("PreviewButton")
  1493. self.posValueX = getObject("BuildingPositionXValue")
  1494. self.posValueY = getObject("BuildingPositionYValue")
  1495. self.ctrlRotationX = getObject("BuildingRotationX")
  1496. self.ctrlRotationY = getObject("BuildingRotationY")
  1497. self.ctrlRotationZ = getObject("BuildingRotationZ")
  1498. self.buildingPriceValue = getObject("BuildingPriceValue")
  1499. self.buildingMaterialStoneValue = getObject("BuildingMaterialStoneValue")
  1500. self.buildingMaterialLogValue = getObject("BuildingMaterialLogValue")
  1501. self.buildingMaterialPlywoodValue = getObject("BuildingMaterialPlywoodValue")
  1502. self.positionButton.SetEvent(ui.__mem_func__(self.__OnSelectPositioningMode))
  1503. self.previewButton.SetToggleDownEvent(ui.__mem_func__(self.__OnEnterPreviewMode))
  1504. self.previewButton.SetToggleUpEvent(ui.__mem_func__(self.__OnLeavePreviewMode))
  1505. self.ctrlRotationX.SetEvent(ui.__mem_func__(self.__OnChangeRotation))
  1506. self.ctrlRotationY.SetEvent(ui.__mem_func__(self.__OnChangeRotation))
  1507. self.ctrlRotationZ.SetEvent(ui.__mem_func__(self.__OnChangeRotation))
  1508. self.listScrollBar.SetScrollEvent(ui.__mem_func__(self.__OnScrollBuildingList))
  1509. getObject("CategoryList").SetEvent(ui.__mem_func__(self.__OnSelectCategory))
  1510. getObject("BuildingList").SetEvent(ui.__mem_func__(self.__OnSelectBuilding))
  1511. getObject("AcceptButton").SetEvent(ui.__mem_func__(self.Build))
  1512. getObject("CancelButton").SetEvent(ui.__mem_func__(self.Close))
  1513. self.board.SetCloseEvent(ui.__mem_func__(self.Close))
  1514. except:
  1515. import exception
  1516. exception.Abort("BuildGuildBuildingWindow.__LoadWindow - BindObject")
  1517. def __CreateWallBlock(self, race, x, y, rot=0.0 ):
  1518. idx = self.START_INSTANCE_INDEX + len(self.indexList)
  1519. self.indexList.append(idx)
  1520. self.raceList.append(race)
  1521. self.posList.append((x, y))
  1522. self.rotList.append(rot)
  1523. chr.CreateInstance(idx)
  1524. chr.SelectInstance(idx)
  1525. chr.SetVirtualID(idx)
  1526. chr.SetInstanceType(chr.INSTANCE_TYPE_OBJECT)
  1527. chr.SetRace(race)
  1528. chr.SetArmor(0)
  1529. chr.Refresh()
  1530. chr.SetLoopMotion(chr.MOTION_WAIT)
  1531. chr.SetBlendRenderMode(idx, self.BUILDING_ALPHA)
  1532. chr.SetRotationAll(0.0, 0.0, rot)
  1533. self.ctrlRotationX.SetSliderPos(0.5)
  1534. self.ctrlRotationY.SetSliderPos(0.5)
  1535. self.ctrlRotationZ.SetSliderPos(0.5)
  1536. def __GetObjectSize(self, race):
  1537. idx = self.START_INSTANCE_INDEX + 1000
  1538. chr.CreateInstance(idx)
  1539. chr.SelectInstance(idx)
  1540. chr.SetVirtualID(idx)
  1541. chr.SetInstanceType(chr.INSTANCE_TYPE_OBJECT)
  1542. chr.SetRace(race)
  1543. chr.SetArmor(0)
  1544. chr.Refresh()
  1545. chr.SetLoopMotion(chr.MOTION_WAIT)
  1546. sx, sy, ex, ey = chr.GetBoundBoxOnlyXY(idx)
  1547. chr.DeleteInstance(idx)
  1548. return sx, sy, ex, ey
  1549. def __GetBuildInPosition(self):
  1550. zList = []
  1551. zList.append( background.GetHeight(self.x+self.sxPos, self.y+self.syPos) )
  1552. zList.append( background.GetHeight(self.x+self.sxPos, self.y+self.eyPos) )
  1553. zList.append( background.GetHeight(self.x+self.exPos, self.y+self.syPos) )
  1554. zList.append( background.GetHeight(self.x+self.exPos, self.y+self.eyPos) )
  1555. zList.append( background.GetHeight(self.x+(self.exPos+self.sxPos)/2, self.y+(self.eyPos+self.syPos)/2) )
  1556. zList.sort()
  1557. return zList[3]
  1558. def __CreateBuildInInstance(self,race):
  1559. self.__DeleteInstance()
  1560. object_base = race - race%10
  1561. door_minX, door_minY, door_maxX, door_maxY = self.__GetObjectSize(object_base+4)
  1562. corner_minX, corner_minY, corner_maxX, corner_maxY = self.__GetObjectSize(object_base+1)
  1563. line_minX, line_minY, line_maxX, line_maxY = self.__GetObjectSize(object_base+2)
  1564. line_width = line_maxX - line_minX
  1565. line_width_half = line_width / 2
  1566. X_SIZE_STEP = 2 * 2 ## 2ÀÇ ´ÜÀ§·Î¸¸ Áõ°¡ÇØ¾ß ÇÔ
  1567. Y_SIZE_STEP = 8
  1568. sxPos = door_maxX - corner_minX + (line_width_half*X_SIZE_STEP)
  1569. exPos = -sxPos
  1570. syPos = 0
  1571. eyPos = -(corner_maxY*2 + line_width*Y_SIZE_STEP)
  1572. self.sxPos = sxPos
  1573. self.syPos = syPos
  1574. self.exPos = exPos
  1575. self.eyPos = eyPos
  1576. z = self.__GetBuildInPosition()
  1577. ## Door
  1578. self.__CreateWallBlock(object_base+4, 0.0, syPos)
  1579. ## Corner
  1580. self.__CreateWallBlock(object_base+1, sxPos, syPos)
  1581. self.__CreateWallBlock(object_base+1, exPos, syPos, 270.0)
  1582. self.__CreateWallBlock(object_base+1, sxPos, eyPos, 90.0)
  1583. self.__CreateWallBlock(object_base+1, exPos, eyPos,180.0 )
  1584. ## Line
  1585. lineBlock = object_base+2
  1586. line_startX = -door_maxX - line_minX - (line_width_half*X_SIZE_STEP)
  1587. self.__CreateWallBlock(lineBlock, line_startX, eyPos)
  1588. self.__CreateWallBlock(lineBlock, line_startX+line_width*1, eyPos)
  1589. self.__CreateWallBlock(lineBlock, line_startX+line_width*2, eyPos)
  1590. self.__CreateWallBlock(lineBlock, line_startX+line_width*3, eyPos)
  1591. for i in xrange(X_SIZE_STEP):
  1592. self.__CreateWallBlock(lineBlock, line_startX+line_width*(3+i+1), eyPos)
  1593. for i in xrange(X_SIZE_STEP/2):
  1594. self.__CreateWallBlock(lineBlock, door_minX - line_maxX - line_width*i, syPos)
  1595. self.__CreateWallBlock(lineBlock, door_maxX - line_minX + line_width*i, syPos)
  1596. for i in xrange(Y_SIZE_STEP):
  1597. self.__CreateWallBlock(lineBlock, sxPos, line_minX + corner_minX - line_width*i, 90.0)
  1598. self.__CreateWallBlock(lineBlock, exPos, line_minX + corner_minX - line_width*i, 90.0)
  1599. self.SetBuildingPosition(int(self.x), int(self.y), self.__GetBuildInPosition())
  1600. def __DeleteInstance(self):
  1601. if not self.indexList:
  1602. return
  1603. for index in self.indexList:
  1604. chr.DeleteInstance(index)
  1605. self.indexList = []
  1606. self.raceList = []
  1607. self.posList = []
  1608. self.rotList = []
  1609. def __CreateInstance(self, race):
  1610. self.__DeleteInstance()
  1611. self.race = race
  1612. idx = self.START_INSTANCE_INDEX
  1613. self.indexList.append(idx)
  1614. self.posList.append((0, 0))
  1615. self.rotList.append(0)
  1616. chr.CreateInstance(idx)
  1617. chr.SelectInstance(idx)
  1618. chr.SetVirtualID(idx)
  1619. chr.SetInstanceType(chr.INSTANCE_TYPE_OBJECT)
  1620. chr.SetRace(race)
  1621. chr.SetArmor(0)
  1622. chr.Refresh()
  1623. chr.SetLoopMotion(chr.MOTION_WAIT)
  1624. chr.SetBlendRenderMode(idx, self.BUILDING_ALPHA)
  1625. self.SetBuildingPosition(int(self.x), int(self.y), 0)
  1626. self.ctrlRotationX.SetSliderPos(0.5)
  1627. self.ctrlRotationY.SetSliderPos(0.5)
  1628. self.ctrlRotationZ.SetSliderPos(0.5)
  1629. def Build(self):
  1630. if not self.__IsEnoughMoney():
  1631. self.__PopupDialog(localeInfo.GUILD_NOT_ENOUGH_MONEY)
  1632. return
  1633. if not self.__IsEnoughMaterialStone():
  1634. self.__PopupDialog(localeInfo.GUILD_NOT_ENOUGH_MATERIAL)
  1635. return
  1636. if not self.__IsEnoughMaterialLog():
  1637. self.__PopupDialog(localeInfo.GUILD_NOT_ENOUGH_MATERIAL)
  1638. return
  1639. if not self.__IsEnoughMaterialPlywood():
  1640. self.__PopupDialog(localeInfo.GUILD_NOT_ENOUGH_MATERIAL)
  1641. return
  1642. ## /build c vnum x y x_rot y_rot z_rot
  1643. ## /build d vnum
  1644. if "BUILDIN" == self.type:
  1645. for i in xrange(len(self.raceList)):
  1646. race = self.raceList[i]
  1647. xPos, yPos = self.posList[i]
  1648. rot = self.rotList[i]
  1649. net.SendChatPacket("/build c %d %d %d %d %d %d" % (race, int(self.x+xPos), int(self.y+yPos), self.rot_x, self.rot_y, rot))
  1650. else:
  1651. net.SendChatPacket("/build c %d %d %d %d %d %d" % (self.race, int(self.x), int(self.y), self.rot_x, self.rot_y, self.rot_z))
  1652. self.Close()
  1653. def Open(self):
  1654. x, y, z = player.GetMainCharacterPosition()
  1655. app.SetCameraSetting(int(x), int(-y), int(z), 3000, 0, 30)
  1656. background.VisibleGuildArea()
  1657. self.x = x
  1658. self.y = y
  1659. self.z = z
  1660. self.categoryList.SelectItem(0)
  1661. self.buildingList.SelectItem(0)
  1662. self.SetTop()
  1663. self.Show()
  1664. self.__DisablePCBlocker()
  1665. import debugInfo
  1666. if debugInfo.IsDebugMode():
  1667. self.categoryList.SelectItem(2)
  1668. self.buildingList.SelectItem(0)
  1669. def Close(self):
  1670. self.__DeleteInstance()
  1671. background.DisableGuildArea()
  1672. self.Hide()
  1673. self.__OnClosePopupDialog()
  1674. self.__EnablePCBlocker()
  1675. self.__UnlockCameraMoving()
  1676. if self.closeEvent:
  1677. self.closeEvent()
  1678. def Destory(self):
  1679. self.Close()
  1680. self.ClearDictionary()
  1681. self.board = None
  1682. self.categoryList = None
  1683. self.buildingList = None
  1684. self.listScrollBar = None
  1685. self.positionButton = None
  1686. self.previewButton = None
  1687. self.posValueX = None
  1688. self.posValueY = None
  1689. self.ctrlRotationX = None
  1690. self.ctrlRotationY = None
  1691. self.ctrlRotationZ = None
  1692. self.buildingPriceValue = None
  1693. self.buildingMaterialStoneValue = None
  1694. self.buildingMaterialLogValue = None
  1695. self.buildingMaterialPlywoodValue = None
  1696. self.closeEvent = None
  1697. def SetCloseEvent(self, event):
  1698. self.closeEvent = event
  1699. def __PopupDialog(self, text):
  1700. popup = uiCommon.PopupDialog()
  1701. popup.SetText(text)
  1702. popup.SetAcceptEvent(self.__OnClosePopupDialog)
  1703. popup.Open()
  1704. self.popup = popup
  1705. def __OnClosePopupDialog(self):
  1706. self.popup = None
  1707. def __EnablePCBlocker(self):
  1708. ## PC Blocker 󸮸¦ ÄÒ´Ù. (Åõ¸íÇØÁü)
  1709. chr.SetInstanceType(chr.INSTANCE_TYPE_BUILDING)
  1710. for idx in self.indexList:
  1711. chr.SetBlendRenderMode(idx, 1.0)
  1712. def __DisablePCBlocker(self):
  1713. ## PC Blocker 󸮸¦ ²ö´Ù. (¾ÈÅõ¸íÇØÁü)
  1714. chr.SetInstanceType(chr.INSTANCE_TYPE_OBJECT)
  1715. for idx in self.indexList:
  1716. chr.SetBlendRenderMode(idx, self.BUILDING_ALPHA)
  1717. def __OnSelectPositioningMode(self):
  1718. if self.MODE_PREVIEW == self.mode:
  1719. self.positionButton.SetUp()
  1720. return
  1721. self.mode = self.MODE_POSITIONING
  1722. self.Hide()
  1723. def __OnEnterPreviewMode(self):
  1724. if self.MODE_POSITIONING == self.mode:
  1725. self.previewButton.SetUp()
  1726. return
  1727. self.mode = self.MODE_PREVIEW
  1728. self.positionButton.SetUp()
  1729. self.__UnlockCameraMoving()
  1730. self.__EnablePCBlocker()
  1731. def __OnLeavePreviewMode(self):
  1732. self.__RestoreViewMode()
  1733. def __RestoreViewMode(self):
  1734. self.__DisablePCBlocker()
  1735. self.__LockCameraMoving()
  1736. self.mode = self.MODE_VIEW
  1737. self.positionButton.SetUp()
  1738. self.previewButton.SetUp()
  1739. def __IsEnoughMoney(self):
  1740. if app.IsEnableTestServerFlag():
  1741. return True
  1742. curMoney = player.GetMoney()
  1743. if curMoney < self.needMoney:
  1744. return False
  1745. return True
  1746. def __IsEnoughMaterialStone(self):
  1747. if app.IsEnableTestServerFlag():
  1748. return True
  1749. curStoneCount = player.GetItemCountByVnum(MATERIAL_STONE_ID)
  1750. if curStoneCount < self.needStoneCount:
  1751. return False
  1752. return True
  1753. def __IsEnoughMaterialLog(self):
  1754. if app.IsEnableTestServerFlag():
  1755. return True
  1756. curLogCount = player.GetItemCountByVnum(MATERIAL_LOG_ID)
  1757. if curLogCount < self.needLogCount:
  1758. return False
  1759. return True
  1760. def __IsEnoughMaterialPlywood(self):
  1761. if app.IsEnableTestServerFlag():
  1762. return True
  1763. curPlywoodCount = player.GetItemCountByVnum(MATERIAL_PLYWOOD_ID)
  1764. if curPlywoodCount < self.needPlywoodCount:
  1765. return False
  1766. return True
  1767. def __OnSelectCategory(self):
  1768. self.listScrollBar.SetPos(0.0)
  1769. self.__RefreshItem()
  1770. def __SetBuildingData(self, data):
  1771. self.buildingPriceValue.SetText(NumberToMoneyString(data["PRICE"]))
  1772. self.needMoney = int(data["PRICE"])
  1773. materialList = data["MATERIAL"]
  1774. self.needStoneCount = int(materialList[MATERIAL_STONE_INDEX])
  1775. self.needLogCount = int(materialList[MATERIAL_LOG_INDEX])
  1776. self.needPlywoodCount = int(materialList[MATERIAL_PLYWOOD_INDEX])
  1777. self.buildingMaterialStoneValue.SetText(materialList[MATERIAL_STONE_INDEX])
  1778. self.buildingMaterialLogValue.SetText(materialList[MATERIAL_LOG_INDEX] )
  1779. self.buildingMaterialPlywoodValue.SetText(materialList[MATERIAL_PLYWOOD_INDEX])
  1780. if self.__IsEnoughMoney():
  1781. self.buildingPriceValue.SetPackedFontColor(self.ENABLE_COLOR)
  1782. else:
  1783. self.buildingPriceValue.SetPackedFontColor(self.DISABLE_COLOR)
  1784. if self.__IsEnoughMaterialStone():
  1785. self.buildingMaterialStoneValue.SetPackedFontColor(self.ENABLE_COLOR)
  1786. else:
  1787. self.buildingMaterialStoneValue.SetPackedFontColor(self.DISABLE_COLOR)
  1788. if self.__IsEnoughMaterialLog():
  1789. self.buildingMaterialLogValue.SetPackedFontColor(self.ENABLE_COLOR)
  1790. else:
  1791. self.buildingMaterialLogValue.SetPackedFontColor(self.DISABLE_COLOR)
  1792. if self.__IsEnoughMaterialPlywood():
  1793. self.buildingMaterialPlywoodValue.SetPackedFontColor(self.ENABLE_COLOR)
  1794. else:
  1795. self.buildingMaterialPlywoodValue.SetPackedFontColor(self.DISABLE_COLOR)
  1796. self.rot_x_limit = data["X_ROT_LIMIT"]
  1797. self.rot_y_limit = data["Y_ROT_LIMIT"]
  1798. self.rot_z_limit = data["Z_ROT_LIMIT"]
  1799. self.ctrlRotationX.Enable()
  1800. self.ctrlRotationY.Enable()
  1801. self.ctrlRotationZ.Enable()
  1802. if 0 == self.rot_x_limit:
  1803. self.ctrlRotationX.Disable()
  1804. if 0 == self.rot_y_limit:
  1805. self.ctrlRotationY.Disable()
  1806. if 0 == self.rot_z_limit:
  1807. self.ctrlRotationZ.Disable()
  1808. def __OnSelectBuilding(self):
  1809. buildingIndex = self.buildingList.GetSelectedItem()
  1810. if buildingIndex >= len(BUILDING_DATA_LIST):
  1811. return
  1812. categoryIndex = self.categoryList.GetSelectedItem()
  1813. if categoryIndex >= len(self.GUILD_CATEGORY_LIST):
  1814. return
  1815. selectedType = self.GUILD_CATEGORY_LIST[categoryIndex][0]
  1816. index = 0
  1817. for data in BUILDING_DATA_LIST:
  1818. type = data["TYPE"]
  1819. vnum = data["VNUM"]
  1820. if selectedType != type:
  1821. continue
  1822. if index == buildingIndex:
  1823. self.type = type
  1824. if "BUILDIN" == self.type:
  1825. self.__CreateBuildInInstance(vnum)
  1826. else:
  1827. self.__CreateInstance(vnum)
  1828. self.__SetBuildingData(data)
  1829. index += 1
  1830. def __OnScrollBuildingList(self):
  1831. viewItemCount = self.buildingList.GetViewItemCount()
  1832. itemCount = self.buildingList.GetItemCount()
  1833. pos = self.listScrollBar.GetPos() * (itemCount-viewItemCount)
  1834. self.buildingList.SetBasePos(int(pos))
  1835. def __OnChangeRotation(self):
  1836. self.rot_x = self.ctrlRotationX.GetSliderPos() * self.rot_x_limit - self.rot_x_limit/2
  1837. self.rot_y = self.ctrlRotationY.GetSliderPos() * self.rot_y_limit - self.rot_y_limit/2
  1838. self.rot_z = (self.ctrlRotationZ.GetSliderPos() * 360 + 180) % 360
  1839. if "BUILDIN" == self.type:
  1840. chr.SetRotationAll(self.rot_x, self.rot_y, self.rot_z)
  1841. else:
  1842. chr.SetRotationAll(self.rot_x, self.rot_y, self.rot_z)
  1843. def __LockCameraMoving(self):
  1844. app.SetCameraSetting(int(self.x), int(-self.y), int(self.z), 3000, 0, 30)
  1845. def __UnlockCameraMoving(self):
  1846. app.SetDefaultCamera()
  1847. def __RefreshItem(self):
  1848. self.buildingList.ClearItem()
  1849. categoryIndex = self.categoryList.GetSelectedItem()
  1850. if categoryIndex >= len(self.GUILD_CATEGORY_LIST):
  1851. return
  1852. selectedType = self.GUILD_CATEGORY_LIST[categoryIndex][0]
  1853. index = 0
  1854. for data in BUILDING_DATA_LIST:
  1855. if selectedType != data["TYPE"]:
  1856. continue
  1857. if data["SHOW"]:
  1858. self.buildingList.InsertItem(index, data["LOCAL_NAME"])
  1859. index += 1
  1860. self.buildingList.SelectItem(0)
  1861. if self.buildingList.GetItemCount() < self.buildingList.GetViewItemCount():
  1862. self.buildingList.SetSize(120, self.buildingList.GetHeight())
  1863. self.buildingList.LocateItem()
  1864. self.listScrollBar.Hide()
  1865. else:
  1866. self.buildingList.SetSize(105, self.buildingList.GetHeight())
  1867. self.buildingList.LocateItem()
  1868. self.listScrollBar.Show()
  1869. def SettleCurrentPosition(self):
  1870. guildID = miniMap.GetGuildAreaID(self.x, self.y)
  1871. import debugInfo
  1872. if debugInfo.IsDebugMode():
  1873. guildID = player.GetGuildID()
  1874. if guildID != player.GetGuildID():
  1875. return
  1876. self.__RestoreViewMode()
  1877. self.__LockCameraMoving()
  1878. self.Show()
  1879. def SetBuildingPosition(self, x, y, z):
  1880. self.x = x
  1881. self.y = y
  1882. self.posValueX.SetText(str(int(x)))
  1883. self.posValueY.SetText(str(int(y)))
  1884. for i in xrange(len(self.indexList)):
  1885. idx = self.indexList[i]
  1886. xPos, yPos = self.posList[i]
  1887. chr.SelectInstance(idx)
  1888. if 0 != z:
  1889. self.z = z
  1890. chr.SetPixelPosition(int(x+xPos), int(y+yPos), int(z))
  1891. else:
  1892. chr.SetPixelPosition(int(x+xPos), int(y+yPos))
  1893. def IsPositioningMode(self):
  1894. if self.MODE_POSITIONING == self.mode:
  1895. return True
  1896. return False
  1897. def IsPreviewMode(self):
  1898. if self.MODE_PREVIEW == self.mode:
  1899. return True
  1900. return False
  1901. def OnPressEscapeKey(self):
  1902. self.Close()
  1903. return True
  1904. """
  1905. - ÇÁ·ÎÅäÄİ
  1906. °ÔÀÓµ¹ÀÔ½Ã:
  1907. RecvLandPacket:
  1908. CPythonMiniMap::RegisterGuildArea
  1909. °ÔÀÓÀ̵¿Áß:
  1910. PythonPlayer::Update()
  1911. CPythonPlayer::__Update_NotifyGuildAreaEvent()
  1912. game.py.BINARY_Guild_EnterGuildArea
  1913. uigameButton.GameButtonWindow.ShowBuildButton()
  1914. game.py.BINARY_Guild_ExitGuildArea
  1915. uigameButton.GameButtonWindow.HideBuildButton()
  1916. BuildButton:
  1917. !±æµåÀåÀÎÁö ó¸® ¾øÀ½
  1918. !°Ç¹°ÀÌ À־ Áş±â ¹öÆ°Àº ÀÖÀ½
  1919. !°Ç¹°ÀÌ Àӽ÷Π»ç¿ëÇÏ´Â VID ´Â ¼­¹ö°¡ º¸³»ÁÖ´Â °Í°ú È¥µ¿µÉ ¿°·Á°¡ ÀÖÀ½
  1920. !°Ç¹° VNUM Àº BuildGuildBuildingWindow.BUILDING_VNUM_LIST ¸¦ ÀÌ¿ëÇØ º¯È¯
  1921. !°Ç¹° ÁöÀ»¶§´Â /build c(reate)
  1922. !°Ç¹° ºÎ¼ú¶§´Â /build d(estroy)
  1923. !rotation ÀÇ ´ÜÀ§´Â degree
  1924. interfaceModule.interface.__OnClickBuildButton:
  1925. interfaceModule.interface.BUILD_OpenWindow:
  1926. AcceptButton:
  1927. BuildGuildBuildingWindow.Build:
  1928. net.SendChatPacket("/build c vnum x y x_rot y_rot z_rot")
  1929. PreviewButton:
  1930. __OnPreviewMode:
  1931. __RestoreViewMode:
  1932. °Ç¹° ºÎ¼ö±â:
  1933. uiTarget.TargetBoard.__OnDestroyBuilding
  1934. net.SendChatPacket("/build d vid")
  1935. """
  1936. if __name__ == "__main__":
  1937. import app
  1938. import wndMgr
  1939. import systemSetting
  1940. import mouseModule
  1941. import grp
  1942. import ui
  1943. #wndMgr.SetOutlineFlag(True)
  1944. app.SetMouseHandler(mouseModule.mouseController)
  1945. app.SetHairColorEnable(True)
  1946. wndMgr.SetMouseHandler(mouseModule.mouseController)
  1947. wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
  1948. app.Create("METIN2 CLOSED BETA", systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
  1949. mouseModule.mouseController.Create()
  1950. import chrmgr
  1951. chrmgr.CreateRace(0)
  1952. chrmgr.SelectRace(0)
  1953. chrmgr.SetPathName("d:/ymir Work/pc/warrior/")
  1954. chrmgr.LoadRaceData("warrior.msm")
  1955. chrmgr.SetPathName("d:/ymir work/pc/warrior/general/")
  1956. chrmgr.RegisterMotionMode(chr.MOTION_MODE_GENERAL)
  1957. chrmgr.RegisterMotionData(chr.MOTION_MODE_GENERAL, chr.MOTION_WAIT, "wait.msa")
  1958. chrmgr.RegisterMotionData(chr.MOTION_MODE_GENERAL, chr.MOTION_RUN, "run.msa")
  1959. def LoadGuildBuildingList(filename):
  1960. handle = app.OpenTextFile(filename)
  1961. count = app.GetTextFileLineCount(handle)
  1962. for i in xrange(count):
  1963. line = app.GetTextFileLine(handle, i)
  1964. tokens = line.split("\t")
  1965. TOKEN_VNUM = 0
  1966. TOKEN_TYPE = 1
  1967. TOKEN_NAME = 2
  1968. TOKEN_LOCAL_NAME = 3
  1969. NO_USE_TOKEN_SIZE_1 = 4
  1970. NO_USE_TOKEN_SIZE_2 = 5
  1971. NO_USE_TOKEN_SIZE_3 = 6
  1972. NO_USE_TOKEN_SIZE_4 = 7
  1973. TOKEN_X_ROT_LIMIT = 8
  1974. TOKEN_Y_ROT_LIMIT = 9
  1975. TOKEN_Z_ROT_LIMIT = 10
  1976. TOKEN_PRICE = 11
  1977. TOKEN_MATERIAL = 12
  1978. TOKEN_NPC = 13
  1979. TOKEN_GROUP = 14
  1980. TOKEN_DEPEND_GROUP = 15
  1981. TOKEN_ENABLE_FLAG = 16
  1982. LIMIT_TOKEN_COUNT = 17
  1983. if not tokens[TOKEN_VNUM].isdigit():
  1984. continue
  1985. if not int(tokens[TOKEN_ENABLE_FLAG]):
  1986. continue
  1987. if len(tokens) < LIMIT_TOKEN_COUNT:
  1988. import dbg
  1989. dbg.TraceError("Strange token count [%d/%d] [%s]" % (len(tokens), LIMIT_TOKEN_COUNT, line))
  1990. continue
  1991. ENABLE_FLAG_TYPE_NOT_USE = False
  1992. ENABLE_FLAG_TYPE_USE = True
  1993. ENABLE_FLAG_TYPE_USE_BUT_HIDE = 2
  1994. if ENABLE_FLAG_TYPE_NOT_USE == int(tokens[TOKEN_ENABLE_FLAG]):
  1995. continue
  1996. vnum = int(tokens[TOKEN_VNUM])
  1997. type = tokens[TOKEN_TYPE]
  1998. name = tokens[TOKEN_NAME]
  1999. localName = tokens[TOKEN_LOCAL_NAME]
  2000. xRotLimit = int(tokens[TOKEN_X_ROT_LIMIT])
  2001. yRotLimit = int(tokens[TOKEN_Y_ROT_LIMIT])
  2002. zRotLimit = int(tokens[TOKEN_Z_ROT_LIMIT])
  2003. price = tokens[TOKEN_PRICE]
  2004. material = tokens[TOKEN_MATERIAL]
  2005. folderName = ""
  2006. if "HEADQUARTER" == type:
  2007. folderName = "headquarter"
  2008. elif "FACILITY" == type:
  2009. folderName = "facility"
  2010. elif "OBJECT" == type:
  2011. folderName = "object"
  2012. ##"BuildIn" Is made by exist instance.
  2013. materialList = ["0", "0", "0"]
  2014. if material[0] == "\"":
  2015. material = material[1:]
  2016. if material[-1] == "\"":
  2017. material = material[:-1]
  2018. for one in material.split("/"):
  2019. data = one.split(",")
  2020. if 2 != len(data):
  2021. continue
  2022. itemID = int(data[0])
  2023. count = data[1]
  2024. if itemID == MATERIAL_STONE_ID:
  2025. materialList[MATERIAL_STONE_INDEX] = count
  2026. elif itemID == MATERIAL_LOG_ID:
  2027. materialList[MATERIAL_LOG_INDEX] = count
  2028. elif itemID == MATERIAL_PLYWOOD_ID:
  2029. materialList[MATERIAL_PLYWOOD_INDEX] = count
  2030. import chrmgr
  2031. chrmgr.RegisterRaceSrcName(name, folderName)
  2032. chrmgr.RegisterRaceName(vnum, name)
  2033. appendingData = { "VNUM":vnum,
  2034. "TYPE":type,
  2035. "NAME":name,
  2036. "LOCAL_NAME":localName,
  2037. "X_ROT_LIMIT":xRotLimit,
  2038. "Y_ROT_LIMIT":yRotLimit,
  2039. "Z_ROT_LIMIT":zRotLimit,
  2040. "PRICE":price,
  2041. "MATERIAL":materialList,
  2042. "SHOW" : True }
  2043. if ENABLE_FLAG_TYPE_USE_BUT_HIDE == int(tokens[TOKEN_ENABLE_FLAG]):
  2044. appendingData["SHOW"] = False
  2045. BUILDING_DATA_LIST.append(appendingData)
  2046. app.CloseTextFile(handle)
  2047. LoadGuildBuildingList(app.GetLocalePath()+"/GuildBuildingList.txt")
  2048. class TestGame(ui.Window):
  2049. def __init__(self):
  2050. ui.Window.__init__(self)
  2051. x = 30000
  2052. y = 40000
  2053. self.wndGuildBuilding = None
  2054. self.onClickKeyDict = {}
  2055. self.onClickKeyDict[app.DIK_SPACE] = lambda: self.OpenBuildGuildBuildingWindow()
  2056. background.Initialize()
  2057. background.LoadMap("metin2_map_a1", x, y, 0)
  2058. background.SetShadowLevel(background.SHADOW_ALL)
  2059. self.MakeCharacter(1, 0, x, y)
  2060. player.SetMainCharacterIndex(1)
  2061. chr.SelectInstance(1)
  2062. def __del__(self):
  2063. ui.Window.__del__(self)
  2064. def MakeCharacter(self, index, race, x, y):
  2065. chr.CreateInstance(index)
  2066. chr.SelectInstance(index)
  2067. chr.SetVirtualID(index)
  2068. chr.SetInstanceType(chr.INSTANCE_TYPE_PLAYER)
  2069. chr.SetRace(race)
  2070. chr.SetArmor(0)
  2071. chr.SetHair(0)
  2072. chr.Refresh()
  2073. chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
  2074. chr.SetLoopMotion(chr.MOTION_WAIT)
  2075. chr.SetPixelPosition(x, y)
  2076. chr.SetDirection(chr.DIR_NORTH)
  2077. def OpenBuildGuildBuildingWindow(self):
  2078. self.wndGuildBuilding = BuildGuildBuildingWindow()
  2079. self.wndGuildBuilding.Open()
  2080. self.wndGuildBuilding.SetParent(self)
  2081. self.wndGuildBuilding.SetTop()
  2082. def OnKeyUp(self, key):
  2083. if key in self.onClickKeyDict:
  2084. self.onClickKeyDict[key]()
  2085. return True
  2086. def OnMouseLeftButtonDown(self):
  2087. if self.wndGuildBuilding:
  2088. if self.wndGuildBuilding.IsPositioningMode():
  2089. self.wndGuildBuilding.SettleCurrentPosition()
  2090. return
  2091. player.SetMouseState(player.MBT_LEFT, player.MBS_PRESS);
  2092. return True
  2093. def OnMouseLeftButtonUp(self):
  2094. if self.wndGuildBuilding:
  2095. return
  2096. player.SetMouseState(player.MBT_LEFT, player.MBS_CLICK)
  2097. return True
  2098. def OnMouseRightButtonDown(self):
  2099. player.SetMouseState(player.MBT_RIGHT, player.MBS_PRESS);
  2100. return True
  2101. def OnMouseRightButtonUp(self):
  2102. player.SetMouseState(player.MBT_RIGHT, player.MBS_CLICK);
  2103. return True
  2104. def OnMouseMiddleButtonDown(self):
  2105. player.SetMouseMiddleButtonState(player.MBS_PRESS)
  2106. def OnMouseMiddleButtonUp(self):
  2107. player.SetMouseMiddleButtonState(player.MBS_CLICK)
  2108. def OnUpdate(self):
  2109. app.UpdateGame()
  2110. if self.wndGuildBuilding:
  2111. if self.wndGuildBuilding.IsPositioningMode():
  2112. x, y, z = background.GetPickingPoint()
  2113. self.wndGuildBuilding.SetBuildingPosition(x, y, z)
  2114. def OnRender(self):
  2115. app.RenderGame()
  2116. grp.PopState()
  2117. grp.SetInterfaceRenderState()
  2118. game = TestGame()
  2119. game.SetSize(systemSetting.GetWidth(), systemSetting.GetHeight())
  2120. game.Show()
  2121. wndGuildBuilding = BuildGuildBuildingWindow()
  2122. wndGuildBuilding.Open()
  2123. wndGuildBuilding.SetTop()
  2124. app.Loop()
  2125. """
  2126. - ÇÁ·ÎÅäÄİ
  2127. °ÔÀÓµ¹ÀÔ½Ã:
  2128. RecvLandPacket:
  2129. CPythonMiniMap::RegisterGuildArea
  2130. °ÔÀÓÀ̵¿Áß:
  2131. PythonPlayer::Update()
  2132. CPythonPlayer::__Update_NotifyGuildAreaEvent()
  2133. game.py.BINARY_Guild_EnterGuildArea
  2134. uigameButton.GameButtonWindow.ShowBuildButton()
  2135. game.py.BINARY_Guild_ExitGuildArea
  2136. uigameButton.GameButtonWindow.HideBuildButton()
  2137. BuildButton:
  2138. !±æµåÀåÀÎÁö ó¸® ¾øÀ½
  2139. !°Ç¹°ÀÌ À־ Áş±â ¹öÆ°Àº ÀÖÀ½
  2140. !°Ç¹°ÀÌ Àӽ÷Π»ç¿ëÇÏ´Â VID ´Â ¼­¹ö°¡ º¸³»ÁÖ´Â °Í°ú È¥µ¿µÉ ¿°·Á°¡ ÀÖÀ½
  2141. !°Ç¹° VNUM Àº BuildGuildBuildingWindow.BUILDING_VNUM_LIST ¸¦ ÀÌ¿ëÇØ º¯È¯
  2142. !°Ç¹° ÁöÀ»¶§´Â /build c(reate)
  2143. !°Ç¹° ºÎ¼ú¶§´Â /build d(estroy)
  2144. !rotation ÀÇ ´ÜÀ§´Â degree
  2145. interfaceModule.interface.__OnClickBuildButton:
  2146. interfaceModule.interface.BUILD_OpenWindow:
  2147. AcceptButton:
  2148. BuildGuildBuildingWindow.Build:
  2149. net.SendChatPacket("/build c vnum x y x_rot y_rot z_rot")
  2150. x_rot, y_rot ´Â AffectContainer¿¡ ÀúÀå
  2151. PreviewButton:
  2152. __OnPreviewMode:
  2153. __RestoreViewMode:
  2154. °Ç¹° ºÎ¼ö±â:
  2155. uiTarget.TargetBoard.__OnDestroyBuilding
  2156. net.SendChatPacket("/build d vid")
  2157. """