Guest User

Untitled

a guest
Feb 20th, 2025
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 128.52 KB | None | 0 0
  1. import app
  2. import ime
  3. import grp
  4. import snd
  5. import wndMgr
  6. import item
  7. import skill
  8. import localeInfo
  9. import dbg
  10. # MARK_BUG_FIX
  11. import guild
  12. # END_OF_MARK_BUG_FIX
  13.  
  14. from _weakref import proxy
  15.  
  16. BACKGROUND_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
  17. DARK_COLOR = grp.GenerateColor(0.2, 0.2, 0.2, 1.0)
  18. BRIGHT_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)
  19.  
  20. if localeInfo.IsCANADA():
  21. SELECT_COLOR = grp.GenerateColor(0.9, 0.03, 0.01, 0.4)
  22. else:
  23. SELECT_COLOR = grp.GenerateColor(0.0, 0.0, 0.5, 0.3)
  24.  
  25. WHITE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.5)
  26. HALF_WHITE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.2)
  27.  
  28. createToolTipWindowDict = {}
  29. def RegisterCandidateWindowClass(codePage, candidateWindowClass):
  30. EditLine.candidateWindowClassDict[codePage]=candidateWindowClass
  31. def RegisterToolTipWindow(type, createToolTipWindow):
  32. createToolTipWindowDict[type]=createToolTipWindow
  33.  
  34. app.SetDefaultFontName(localeInfo.UI_DEF_FONT)
  35.  
  36. ## Window Manager Event List##
  37. ##############################
  38. ## "OnMouseLeftButtonDown"
  39. ## "OnMouseLeftButtonUp"
  40. ## "OnMouseLeftButtonDoubleClick"
  41. ## "OnMouseRightButtonDown"
  42. ## "OnMouseRightButtonUp"
  43. ## "OnMouseRightButtonDoubleClick"
  44. ## "OnMouseDrag"
  45. ## "OnSetFocus"
  46. ## "OnKillFocus"
  47. ## "OnMouseOverIn"
  48. ## "OnMouseOverOut"
  49. ## "OnRender"
  50. ## "OnUpdate"
  51. ## "OnKeyDown"
  52. ## "OnKeyUp"
  53. ## "OnTop"
  54. ## "OnIMEUpdate" ## IME Only
  55. ## "OnIMETab" ## IME Only
  56. ## "OnIMEReturn" ## IME Only
  57. ##############################
  58. ## Window Manager Event List##
  59.  
  60.  
  61. class __mem_func__:
  62. class __noarg_call__:
  63. def __init__(self, cls, obj, func):
  64. self.cls=cls
  65. self.obj=proxy(obj)
  66. self.func=proxy(func)
  67.  
  68. def __call__(self, *arg):
  69. return self.func(self.obj)
  70.  
  71. class __arg_call__:
  72. def __init__(self, cls, obj, func):
  73. self.cls=cls
  74. self.obj=proxy(obj)
  75. self.func=proxy(func)
  76.  
  77. def __call__(self, *arg):
  78. return self.func(self.obj, *arg)
  79.  
  80. def __init__(self, mfunc):
  81. if mfunc.im_func.func_code.co_argcount>1:
  82. self.call=__mem_func__.__arg_call__(mfunc.im_class, mfunc.im_self, mfunc.im_func)
  83. else:
  84. self.call=__mem_func__.__noarg_call__(mfunc.im_class, mfunc.im_self, mfunc.im_func)
  85.  
  86. def __call__(self, *arg):
  87. return self.call(*arg)
  88.  
  89.  
  90. class Window(object):
  91. def NoneMethod(cls):
  92. pass
  93.  
  94. NoneMethod = classmethod(NoneMethod)
  95.  
  96. def __init__(self, layer = "UI"):
  97. self.hWnd = None
  98. self.parentWindow = 0
  99. self.onMouseLeftButtonUpEvent = None
  100. self.RegisterWindow(layer)
  101. self.Hide()
  102.  
  103. if app.ENABLE_SEND_TARGET_INFO:
  104. self.mouseLeftButtonDownEvent = None
  105. self.mouseLeftButtonDownArgs = None
  106. self.mouseLeftButtonUpEvent = None
  107. self.mouseLeftButtonUpArgs = None
  108. self.mouseLeftButtonDoubleClickEvent = None
  109. self.mouseRightButtonDownEvent = None
  110. self.mouseRightButtonDownArgs = None
  111. self.moveWindowEvent = None
  112. self.renderEvent = None
  113. self.renderArgs = None
  114.  
  115. self.overInEvent = None
  116. self.overInArgs = None
  117.  
  118. self.overOutEvent = None
  119. self.overOutArgs = None
  120.  
  121. self.baseX = 0
  122. self.baseY = 0
  123.  
  124. self.SetWindowName("NONAME_Window")
  125.  
  126. def SetMouseLeftButtonUpEvent(self, event, *args):
  127. self.mouseLeftButtonUpEvent = event
  128. self.mouseLeftButtonUpArgs = args
  129.  
  130. def SetMouseOverInEvent(self, event, *args):
  131. self.mouseOverInEvent = event
  132. self.mouseOverInArgs = args
  133.  
  134. def SetMouseOverOutEvent(self, event, *args):
  135. self.mouseOverOutEvent = event
  136. self.mouseOverOutArgs = args
  137.  
  138. def __del__(self):
  139. wndMgr.Destroy(self.hWnd)
  140.  
  141. def RegisterWindow(self, layer):
  142. self.hWnd = wndMgr.Register(self, layer)
  143.  
  144. def Destroy(self):
  145. pass
  146.  
  147. def GetWindowHandle(self):
  148. return self.hWnd
  149.  
  150. def AddFlag(self, style):
  151. wndMgr.AddFlag(self.hWnd, style)
  152.  
  153. def IsRTL(self):
  154. return wndMgr.IsRTL(self.hWnd)
  155.  
  156. def SetWindowName(self, Name):
  157. wndMgr.SetName(self.hWnd, Name)
  158.  
  159. def GetWindowName(self):
  160. return wndMgr.GetName(self.hWnd)
  161.  
  162. if app.ENABLE_SEND_TARGET_INFO:
  163. def SetParent(self, parent):
  164. if parent:
  165. wndMgr.SetParent(self.hWnd, parent.hWnd)
  166. else:
  167. wndMgr.SetParent(self.hWnd, 0)
  168.  
  169. def SetAttachParent(self, parent):
  170. wndMgr.SetAttachParent(self.hWnd, parent.hWnd)
  171. else:
  172. def SetParent(self, parent):
  173. wndMgr.SetParent(self.hWnd, parent.hWnd)
  174.  
  175. def SetParentProxy(self, parent):
  176. self.parentWindow=proxy(parent)
  177. wndMgr.SetParent(self.hWnd, parent.hWnd)
  178.  
  179.  
  180. def GetParentProxy(self):
  181. return self.parentWindow
  182.  
  183. def SetPickAlways(self):
  184. wndMgr.SetPickAlways(self.hWnd)
  185.  
  186. def SetWindowHorizontalAlignLeft(self):
  187. wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_LEFT)
  188.  
  189. def SetWindowHorizontalAlignCenter(self):
  190. wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_CENTER)
  191.  
  192. def SetWindowHorizontalAlignRight(self):
  193. wndMgr.SetWindowHorizontalAlign(self.hWnd, wndMgr.HORIZONTAL_ALIGN_RIGHT)
  194.  
  195. def SetWindowVerticalAlignTop(self):
  196. wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_TOP)
  197.  
  198. def SetWindowVerticalAlignCenter(self):
  199. wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_CENTER)
  200.  
  201. def SetWindowVerticalAlignBottom(self):
  202. wndMgr.SetWindowVerticalAlign(self.hWnd, wndMgr.VERTICAL_ALIGN_BOTTOM)
  203.  
  204. def SetTop(self):
  205. wndMgr.SetTop(self.hWnd)
  206.  
  207. def Show(self):
  208. wndMgr.Show(self.hWnd)
  209.  
  210. def Hide(self):
  211. wndMgr.Hide(self.hWnd)
  212.  
  213. if app.ENABLE_SEND_TARGET_INFO:
  214. def SetVisible(self, is_show):
  215. if is_show:
  216. self.Show()
  217. else:
  218. self.Hide()
  219.  
  220. def Lock(self):
  221. wndMgr.Lock(self.hWnd)
  222.  
  223. def Unlock(self):
  224. wndMgr.Unlock(self.hWnd)
  225.  
  226. def IsShow(self):
  227. return wndMgr.IsShow(self.hWnd)
  228.  
  229. def UpdateRect(self):
  230. wndMgr.UpdateRect(self.hWnd)
  231.  
  232. def SetSize(self, width, height):
  233. wndMgr.SetWindowSize(self.hWnd, width, height)
  234.  
  235. def GetWidth(self):
  236. return wndMgr.GetWindowWidth(self.hWnd)
  237.  
  238. def GetHeight(self):
  239. return wndMgr.GetWindowHeight(self.hWnd)
  240.  
  241. def GetLocalPosition(self):
  242. return wndMgr.GetWindowLocalPosition(self.hWnd)
  243.  
  244. if app.ENABLE_SEND_TARGET_INFO:
  245. def GetLeft(self):
  246. x, y = self.GetLocalPosition()
  247. return x
  248.  
  249. def GetGlobalLeft(self):
  250. x, y = self.GetGlobalPosition()
  251. return x
  252.  
  253. def GetTop(self):
  254. x, y = self.GetLocalPosition()
  255. return y
  256.  
  257. def GetGlobalTop(self):
  258. x, y = self.GetGlobalPosition()
  259. return y
  260.  
  261. def GetRight(self):
  262. return self.GetLeft() + self.GetWidth()
  263.  
  264. def GetBottom(self):
  265. return self.GetTop() + self.GetHeight()
  266.  
  267.  
  268. def GetGlobalPosition(self):
  269. return wndMgr.GetWindowGlobalPosition(self.hWnd)
  270.  
  271. def GetMouseLocalPosition(self):
  272. return wndMgr.GetMouseLocalPosition(self.hWnd)
  273.  
  274. def GetRect(self):
  275. return wndMgr.GetWindowRect(self.hWnd)
  276. if app.ENABLE_SEND_TARGET_INFO:
  277. def SetLeft(self, x):
  278. wndMgr.SetWindowPosition(self.hWnd, x, self.GetTop())
  279.  
  280. def SetPosition(self, x, y):
  281. wndMgr.SetWindowPosition(self.hWnd, x, y)
  282.  
  283. def SetCenterPosition(self, x = 0, y = 0):
  284. self.SetPosition((wndMgr.GetScreenWidth() - self.GetWidth()) / 2 + x, (wndMgr.GetScreenHeight() - self.GetHeight()) / 2 + y)
  285. if app.ENABLE_SEND_TARGET_INFO:
  286. def SavePosition(self):
  287. self.baseX = self.GetLeft()
  288. self.baseY = self.GetTop()
  289.  
  290. def UpdatePositionByScale(self, scale):
  291. self.SetPosition(self.baseX * scale, self.baseY * scale)
  292.  
  293. def IsFocus(self):
  294. return wndMgr.IsFocus(self.hWnd)
  295.  
  296. def SetFocus(self):
  297. wndMgr.SetFocus(self.hWnd)
  298.  
  299. def KillFocus(self):
  300. wndMgr.KillFocus(self.hWnd)
  301.  
  302. def GetChildCount(self):
  303. return wndMgr.GetChildCount(self.hWnd)
  304.  
  305. def IsIn(self):
  306. return wndMgr.IsIn(self.hWnd)
  307.  
  308. if app.ENABLE_SEND_TARGET_INFO:
  309. def SetMouseLeftButtonUpEvent(self, event, *args):
  310. self.mouseLeftButtonUpEvent = event
  311. self.mouseLeftButtonUpArgs = args
  312. else:
  313. def SetOnMouseLeftButtonUpEvent(self, event):
  314. self.onMouseLeftButtonUpEvent = ev
  315.  
  316. if app.ENABLE_SEND_TARGET_INFO:
  317. def SetMouseLeftButtonDoubleClickEvent(self, event):
  318. self.mouseLeftButtonDoubleClickEvent = event
  319.  
  320. def OnMouseLeftButtonDoubleClick(self):
  321. if self.mouseLeftButtonDoubleClickEvent:
  322. self.mouseLeftButtonDoubleClickEvent()
  323.  
  324. def SetMouseRightButtonDownEvent(self, event, *args):
  325. self.mouseRightButtonDownEvent = event
  326. self.mouseRightButtonDownArgs = args
  327.  
  328. def OnMouseRightButtonDown(self):
  329. if self.mouseRightButtonDownEvent:
  330. apply(self.mouseRightButtonDownEvent, self.mouseRightButtonDownArgs)
  331.  
  332. def SetMoveWindowEvent(self, event):
  333. self.moveWindowEvent = event
  334.  
  335. def OnMoveWindow(self, x, y):
  336. if self.moveWindowEvent:
  337. self.moveWindowEvent(x, y)
  338.  
  339. def SAFE_SetOverInEvent(self, func, *args):
  340. self.overInEvent = __mem_func__(func)
  341. self.overInArgs = args
  342.  
  343. def SetOverInEvent(self, func, *args):
  344. self.overInEvent = func
  345. self.overInArgs = args
  346.  
  347. def SAFE_SetOverOutEvent(self, func, *args):
  348. self.overOutEvent = __mem_func__(func)
  349. self.overOutArgs = args
  350.  
  351. def SetOverOutEvent(self, func, *args):
  352. self.overOutEvent = func
  353. self.overOutArgs = args
  354.  
  355. def OnMouseOverIn(self):
  356. if self.overInEvent:
  357. apply(self.overInEvent, self.overInArgs)
  358.  
  359. def OnMouseOverOut(self):
  360. if self.overOutEvent:
  361. apply(self.overOutEvent, self.overOutArgs)
  362.  
  363. def SAFE_SetRenderEvent(self, event, *args):
  364. self.renderEvent = __mem_func__(event)
  365. self.renderArgs = args
  366.  
  367. def ClearRenderEvent(self):
  368. self.renderEvent = None
  369. self.renderArgs = None
  370.  
  371. def OnRender(self):
  372. if self.renderEvent:
  373. apply(self.renderEvent, self.renderArgs)
  374.  
  375. def OnMouseLeftButtonUp(self):
  376. if self.onMouseLeftButtonUpEvent:
  377. self.onMouseLeftButtonUpEvent()
  378. if app.ENABLE_SEND_TARGET_INFO:
  379. def IsInPosition(self):
  380. xMouse, yMouse = wndMgr.GetMousePosition()
  381. x, y = self.GetGlobalPosition()
  382. return xMouse >= x and xMouse < x + self.GetWidth() and yMouse >= y and yMouse < y + self.GetHeight()
  383.  
  384. def SetMouseLeftButtonDownEvent(self, event, *args):
  385. self.mouseLeftButtonDownEvent = event
  386. self.mouseLeftButtonDownArgs = args
  387.  
  388. def OnMouseLeftButtonDown(self):
  389. if self.mouseLeftButtonDownEvent:
  390. apply(self.mouseLeftButtonDownEvent, self.mouseLeftButtonDownArgs)
  391.  
  392. class ListBoxEx(Window):
  393.  
  394. class Item(Window):
  395. def __init__(self):
  396. Window.__init__(self)
  397.  
  398. def __del__(self):
  399. Window.__del__(self)
  400.  
  401. def SetParent(self, parent):
  402. Window.SetParent(self, parent)
  403. self.parent=proxy(parent)
  404.  
  405. def OnMouseLeftButtonDown(self):
  406. self.parent.SelectItem(self)
  407.  
  408. def OnRender(self):
  409. if self.parent.GetSelectedItem()==self:
  410. self.OnSelectedRender()
  411.  
  412. def OnSelectedRender(self):
  413. x, y = self.GetGlobalPosition()
  414. grp.SetColor(grp.GenerateColor(0.0, 0.0, 0.7, 0.7))
  415. grp.RenderBar(x, y, self.GetWidth(), self.GetHeight())
  416.  
  417. def __init__(self):
  418. Window.__init__(self)
  419.  
  420. self.viewItemCount=10
  421. self.basePos=0
  422. self.itemHeight=16
  423. self.itemStep=20
  424. self.selItem=0
  425. self.itemList=[]
  426. self.onSelectItemEvent = lambda *arg: None
  427.  
  428. if localeInfo.IsARABIC():
  429. self.itemWidth=130
  430. else:
  431. self.itemWidth=100
  432.  
  433. self.scrollBar=None
  434. self.__UpdateSize()
  435.  
  436. def __del__(self):
  437. Window.__del__(self)
  438.  
  439. def __UpdateSize(self):
  440. height=self.itemStep*self.__GetViewItemCount()
  441.  
  442. self.SetSize(self.itemWidth, height)
  443.  
  444. def IsEmpty(self):
  445. if len(self.itemList)==0:
  446. return 1
  447. return 0
  448.  
  449. def SetItemStep(self, itemStep):
  450. self.itemStep=itemStep
  451. self.__UpdateSize()
  452.  
  453. def SetItemSize(self, itemWidth, itemHeight):
  454. self.itemWidth=itemWidth
  455. self.itemHeight=itemHeight
  456. self.__UpdateSize()
  457.  
  458. def SetViewItemCount(self, viewItemCount):
  459. self.viewItemCount=viewItemCount
  460.  
  461. def SetSelectEvent(self, event):
  462. self.onSelectItemEvent = event
  463.  
  464. def SetBasePos(self, basePos):
  465. for oldItem in self.itemList[self.basePos:self.basePos+self.viewItemCount]:
  466. oldItem.Hide()
  467.  
  468. self.basePos=basePos
  469.  
  470. pos=basePos
  471. for newItem in self.itemList[self.basePos:self.basePos+self.viewItemCount]:
  472. (x, y)=self.GetItemViewCoord(pos, newItem.GetWidth())
  473. newItem.SetPosition(x, y)
  474. newItem.Show()
  475. pos+=1
  476.  
  477. def GetItemIndex(self, argItem):
  478. return self.itemList.index(argItem)
  479.  
  480. def GetSelectedItem(self):
  481. return self.selItem
  482.  
  483. def SelectIndex(self, index):
  484.  
  485. if index >= len(self.itemList) or index < 0:
  486. self.selItem = None
  487. return
  488.  
  489. try:
  490. self.selItem=self.itemList[index]
  491. except:
  492. pass
  493.  
  494. def SelectItem(self, selItem):
  495. self.selItem=selItem
  496. self.onSelectItemEvent(selItem)
  497.  
  498. def RemoveAllItems(self):
  499. self.selItem=None
  500. self.itemList=[]
  501.  
  502. if self.scrollBar:
  503. self.scrollBar.SetPos(0)
  504.  
  505. def RemoveItem(self, delItem):
  506. if delItem==self.selItem:
  507. self.selItem=None
  508.  
  509. self.itemList.remove(delItem)
  510.  
  511. def AppendItem(self, newItem):
  512. newItem.SetParent(self)
  513. newItem.SetSize(self.itemWidth, self.itemHeight)
  514.  
  515. pos=len(self.itemList)
  516. if self.__IsInViewRange(pos):
  517. (x, y)=self.GetItemViewCoord(pos, newItem.GetWidth())
  518. newItem.SetPosition(x, y)
  519. newItem.Show()
  520. else:
  521. newItem.Hide()
  522.  
  523. self.itemList.append(newItem)
  524.  
  525. def SetScrollBar(self, scrollBar):
  526. scrollBar.SetScrollEvent(__mem_func__(self.__OnScroll))
  527. self.scrollBar=scrollBar
  528.  
  529. def __OnScroll(self):
  530. self.SetBasePos(int(self.scrollBar.GetPos()*self.__GetScrollLen()))
  531.  
  532. def __GetScrollLen(self):
  533. scrollLen=self.__GetItemCount()-self.__GetViewItemCount()
  534. if scrollLen<0:
  535. return 0
  536.  
  537. return scrollLen
  538.  
  539. def __GetViewItemCount(self):
  540. return self.viewItemCount
  541.  
  542. def __GetItemCount(self):
  543. return len(self.itemList)
  544.  
  545. def GetItemViewCoord(self, pos, itemWidth):
  546. if localeInfo.IsARABIC():
  547. return (self.GetWidth()-itemWidth-10, (pos-self.basePos)*self.itemStep)
  548. else:
  549. return (0, (pos-self.basePos)*self.itemStep)
  550.  
  551. def __IsInViewRange(self, pos):
  552. if pos<self.basePos:
  553. return 0
  554. if pos>=self.basePos+self.viewItemCount:
  555. return 0
  556. return 1
  557.  
  558. if app.ENABLE_SEND_TARGET_INFO:
  559. class ListBoxExNew(Window):
  560. class Item(Window):
  561. def __init__(self):
  562. Window.__init__(self)
  563.  
  564. self.realWidth = 0
  565. self.realHeight = 0
  566.  
  567. self.removeTop = 0
  568. self.removeBottom = 0
  569.  
  570. self.SetWindowName("NONAME_ListBoxExNew_Item")
  571.  
  572. def __del__(self):
  573. Window.__del__(self)
  574.  
  575. def SetParent(self, parent):
  576. Window.SetParent(self, parent)
  577. self.parent=proxy(parent)
  578.  
  579. def SetSize(self, width, height):
  580. self.realWidth = width
  581. self.realHeight = height
  582. Window.SetSize(self, width, height)
  583.  
  584. def SetRemoveTop(self, height):
  585. self.removeTop = height
  586. self.RefreshHeight()
  587.  
  588. def SetRemoveBottom(self, height):
  589. self.removeBottom = height
  590. self.RefreshHeight()
  591.  
  592. def SetCurrentHeight(self, height):
  593. Window.SetSize(self, self.GetWidth(), height)
  594.  
  595. def GetCurrentHeight(self):
  596. return Window.GetHeight(self)
  597.  
  598. def ResetCurrentHeight(self):
  599. self.removeTop = 0
  600. self.removeBottom = 0
  601. self.RefreshHeight()
  602.  
  603. def RefreshHeight(self):
  604. self.SetCurrentHeight(self.GetHeight() - self.removeTop - self.removeBottom)
  605.  
  606. def GetHeight(self):
  607. return self.realHeight
  608.  
  609. def __init__(self, stepSize, viewSteps):
  610. Window.__init__(self)
  611.  
  612. self.viewItemCount=10
  613. self.basePos=0
  614. self.baseIndex=0
  615. self.maxSteps=0
  616. self.viewSteps = viewSteps
  617. self.stepSize = stepSize
  618. self.itemList=[]
  619.  
  620. self.scrollBar=None
  621.  
  622. self.SetWindowName("NONAME_ListBoxEx")
  623.  
  624. def __del__(self):
  625. Window.__del__(self)
  626.  
  627. def IsEmpty(self):
  628. if len(self.itemList)==0:
  629. return 1
  630. return 0
  631.  
  632. def __CheckBasePos(self, pos):
  633. self.viewItemCount = 0
  634.  
  635. start_pos = pos
  636.  
  637. height = 0
  638. while height < self.GetHeight():
  639. if pos >= len(self.itemList):
  640. return start_pos == 0
  641. height += self.itemList[pos].GetHeight()
  642. pos += 1
  643. self.viewItemCount += 1
  644. return height == self.GetHeight()
  645.  
  646. def SetBasePos(self, basePos, forceRefresh = TRUE):
  647. if forceRefresh == FALSE and self.basePos == basePos:
  648. return
  649.  
  650. for oldItem in self.itemList[self.baseIndex:self.baseIndex+self.viewItemCount]:
  651. oldItem.ResetCurrentHeight()
  652. oldItem.Hide()
  653.  
  654. self.basePos=basePos
  655.  
  656. baseIndex = 0
  657. while basePos > 0:
  658. basePos -= self.itemList[baseIndex].GetHeight() / self.stepSize
  659. if basePos < 0:
  660. self.itemList[baseIndex].SetRemoveTop(self.stepSize * abs(basePos))
  661. break
  662. baseIndex += 1
  663. self.baseIndex = baseIndex
  664.  
  665. stepCount = 0
  666. self.viewItemCount = 0
  667. while baseIndex < len(self.itemList):
  668. stepCount += self.itemList[baseIndex].GetCurrentHeight() / self.stepSize
  669. self.viewItemCount += 1
  670. if stepCount > self.viewSteps:
  671. self.itemList[baseIndex].SetRemoveBottom(self.stepSize * (stepCount - self.viewSteps))
  672. break
  673. elif stepCount == self.viewSteps:
  674. break
  675. baseIndex += 1
  676.  
  677. y = 0
  678. for newItem in self.itemList[self.baseIndex:self.baseIndex+self.viewItemCount]:
  679. newItem.SetPosition(0, y)
  680. newItem.Show()
  681. y += newItem.GetCurrentHeight()
  682.  
  683. def GetItemIndex(self, argItem):
  684. return self.itemList.index(argItem)
  685.  
  686. def GetSelectedItem(self):
  687. return self.selItem
  688.  
  689. def GetSelectedItemIndex(self):
  690. return self.selItemIdx
  691.  
  692. def RemoveAllItems(self):
  693. self.itemList=[]
  694. self.maxSteps=0
  695.  
  696. if self.scrollBar:
  697. self.scrollBar.SetPos(0)
  698.  
  699. def RemoveItem(self, delItem):
  700. self.maxSteps -= delItem.GetHeight() / self.stepSize
  701. self.itemList.remove(delItem)
  702.  
  703. def AppendItem(self, newItem):
  704. if newItem.GetHeight() % self.stepSize != 0:
  705. import dbg
  706. dbg.TraceError("Invalid AppendItem height %d stepSize %d" % (newItem.GetHeight(), self.stepSize))
  707. return
  708.  
  709. self.maxSteps += newItem.GetHeight() / self.stepSize
  710. newItem.SetParent(self)
  711. self.itemList.append(newItem)
  712.  
  713. def SetScrollBar(self, scrollBar):
  714. scrollBar.SetScrollEvent(__mem_func__(self.__OnScroll))
  715. self.scrollBar=scrollBar
  716.  
  717. def __OnScroll(self):
  718. self.SetBasePos(int(self.scrollBar.GetPos()*self.__GetScrollLen()), FALSE)
  719.  
  720. def __GetScrollLen(self):
  721. scrollLen=self.maxSteps-self.viewSteps
  722. if scrollLen<0:
  723. return 0
  724.  
  725. return scrollLen
  726.  
  727. def __GetViewItemCount(self):
  728. return self.viewItemCount
  729.  
  730. def __GetItemCount(self):
  731. return len(self.itemList)
  732.  
  733. def GetViewItemCount(self):
  734. return self.viewItemCount
  735.  
  736. def GetItemCount(self):
  737. return len(self.itemList)
  738.  
  739.  
  740. class CandidateListBox(ListBoxEx):
  741.  
  742. HORIZONTAL_MODE = 0
  743. VERTICAL_MODE = 1
  744.  
  745. class Item(ListBoxEx.Item):
  746. def __init__(self, text):
  747. ListBoxEx.Item.__init__(self)
  748.  
  749. self.textBox=TextLine()
  750. self.textBox.SetParent(self)
  751. self.textBox.SetText(text)
  752. self.textBox.Show()
  753.  
  754. def __del__(self):
  755. ListBoxEx.Item.__del__(self)
  756.  
  757. def __init__(self, mode = HORIZONTAL_MODE):
  758. ListBoxEx.__init__(self)
  759. self.itemWidth=32
  760. self.itemHeight=32
  761. self.mode = mode
  762.  
  763. def __del__(self):
  764. ListBoxEx.__del__(self)
  765.  
  766. def SetMode(self, mode):
  767. self.mode = mode
  768.  
  769. def AppendItem(self, newItem):
  770. ListBoxEx.AppendItem(self, newItem)
  771.  
  772. def GetItemViewCoord(self, pos):
  773. if self.mode == self.HORIZONTAL_MODE:
  774. return ((pos-self.basePos)*self.itemStep, 0)
  775. elif self.mode == self.VERTICAL_MODE:
  776. return (0, (pos-self.basePos)*self.itemStep)
  777.  
  778.  
  779. class TextLine(Window):
  780. def __init__(self):
  781. Window.__init__(self)
  782. self.max = 0
  783. self.SetFontName(localeInfo.UI_DEF_FONT)
  784.  
  785. def __del__(self):
  786. Window.__del__(self)
  787.  
  788. def RegisterWindow(self, layer):
  789. self.hWnd = wndMgr.RegisterTextLine(self, layer)
  790.  
  791. def SetMax(self, max):
  792. wndMgr.SetMax(self.hWnd, max)
  793.  
  794. def SetLimitWidth(self, width):
  795. wndMgr.SetLimitWidth(self.hWnd, width)
  796.  
  797. def SetMultiLine(self):
  798. wndMgr.SetMultiLine(self.hWnd, True)
  799.  
  800. def SetHorizontalAlignArabic(self):
  801. wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_ARABIC)
  802.  
  803. def SetHorizontalAlignLeft(self):
  804. wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_LEFT)
  805.  
  806. def SetHorizontalAlignRight(self):
  807. wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_RIGHT)
  808.  
  809. def SetHorizontalAlignCenter(self):
  810. wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_CENTER)
  811.  
  812. def SetVerticalAlignTop(self):
  813. wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_TOP)
  814.  
  815. def SetVerticalAlignBottom(self):
  816. wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_BOTTOM)
  817.  
  818. def SetVerticalAlignCenter(self):
  819. wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_CENTER)
  820.  
  821. def SetSecret(self, Value=True):
  822. wndMgr.SetSecret(self.hWnd, Value)
  823.  
  824. def SetOutline(self, Value=True):
  825. wndMgr.SetOutline(self.hWnd, Value)
  826.  
  827. def SetFeather(self, value=True):
  828. wndMgr.SetFeather(self.hWnd, value)
  829.  
  830. def SetFontName(self, fontName):
  831. wndMgr.SetFontName(self.hWnd, fontName)
  832.  
  833. def SetDefaultFontName(self):
  834. wndMgr.SetFontName(self.hWnd, localeInfo.UI_DEF_FONT)
  835.  
  836. def SetFontColor(self, red, green, blue):
  837. wndMgr.SetFontColor(self.hWnd, red, green, blue)
  838.  
  839. def SetPackedFontColor(self, color):
  840. wndMgr.SetFontColor(self.hWnd, color)
  841.  
  842. def SetText(self, text):
  843. wndMgr.SetText(self.hWnd, text)
  844.  
  845. def GetText(self):
  846. return wndMgr.GetText(self.hWnd)
  847.  
  848. def GetTextSize(self):
  849. return wndMgr.GetTextSize(self.hWnd)
  850.  
  851. class EmptyCandidateWindow(Window):
  852. def __init__(self):
  853. Window.__init__(self)
  854.  
  855. def __del__(self):
  856. Window.__init__(self)
  857.  
  858. def Load(self):
  859. pass
  860.  
  861. def SetCandidatePosition(self, x, y, textCount):
  862. pass
  863.  
  864. def Clear(self):
  865. pass
  866.  
  867. def Append(self, text):
  868. pass
  869.  
  870. def Refresh(self):
  871. pass
  872.  
  873. def Select(self):
  874. pass
  875.  
  876. class EditLine(TextLine):
  877. candidateWindowClassDict = {}
  878.  
  879. def __init__(self):
  880. TextLine.__init__(self)
  881.  
  882. self.eventReturn = Window.NoneMethod
  883. self.eventEscape = Window.NoneMethod
  884. self.eventTab = None
  885. self.numberMode = False
  886. self.useIME = True
  887.  
  888. self.bCodePage = False
  889.  
  890. self.candidateWindowClass = None
  891. self.candidateWindow = None
  892. self.SetCodePage(app.GetDefaultCodePage())
  893.  
  894. self.readingWnd = ReadingWnd()
  895. self.readingWnd.Hide()
  896.  
  897. def __del__(self):
  898. TextLine.__del__(self)
  899.  
  900. self.eventReturn = Window.NoneMethod
  901. self.eventEscape = Window.NoneMethod
  902. self.eventTab = None
  903.  
  904.  
  905. def SetCodePage(self, codePage):
  906. candidateWindowClass=EditLine.candidateWindowClassDict.get(codePage, EmptyCandidateWindow)
  907. self.__SetCandidateClass(candidateWindowClass)
  908.  
  909. def __SetCandidateClass(self, candidateWindowClass):
  910. if self.candidateWindowClass==candidateWindowClass:
  911. return
  912.  
  913. self.candidateWindowClass = candidateWindowClass
  914. self.candidateWindow = self.candidateWindowClass()
  915. self.candidateWindow.Load()
  916. self.candidateWindow.Hide()
  917.  
  918. def RegisterWindow(self, layer):
  919. self.hWnd = wndMgr.RegisterTextLine(self, layer)
  920.  
  921. def SAFE_SetReturnEvent(self, event):
  922. self.eventReturn = __mem_func__(event)
  923.  
  924. def SetReturnEvent(self, event):
  925. self.eventReturn = event
  926.  
  927. def SetEscapeEvent(self, event):
  928. self.eventEscape = event
  929.  
  930. def SetTabEvent(self, event):
  931. self.eventTab = event
  932.  
  933. def SetMax(self, max):
  934. self.max = max
  935. wndMgr.SetMax(self.hWnd, self.max)
  936. ime.SetMax(self.max)
  937. self.SetUserMax(self.max)
  938.  
  939. def SetUserMax(self, max):
  940. self.userMax = max
  941. ime.SetUserMax(self.userMax)
  942.  
  943. def SetNumberMode(self):
  944. self.numberMode = True
  945.  
  946. #def AddExceptKey(self, key):
  947. # ime.AddExceptKey(key)
  948.  
  949. #def ClearExceptKey(self):
  950. # ime.ClearExceptKey()
  951.  
  952. def SetIMEFlag(self, flag):
  953. self.useIME = flag
  954.  
  955. def SetText(self, text):
  956. wndMgr.SetText(self.hWnd, text)
  957.  
  958. if self.IsFocus():
  959. ime.SetText(text)
  960.  
  961. def Enable(self):
  962. wndMgr.ShowCursor(self.hWnd)
  963.  
  964. def Disable(self):
  965. wndMgr.HideCursor(self.hWnd)
  966.  
  967. def SetEndPosition(self):
  968. ime.MoveEnd()
  969.  
  970. def OnSetFocus(self):
  971. Text = self.GetText()
  972. ime.SetText(Text)
  973. ime.SetMax(self.max)
  974. ime.SetUserMax(self.userMax)
  975. ime.SetCursorPosition(-1)
  976. if self.numberMode:
  977. ime.SetNumberMode()
  978. else:
  979. ime.SetStringMode()
  980. ime.EnableCaptureInput()
  981. if self.useIME:
  982. ime.EnableIME()
  983. else:
  984. ime.DisableIME()
  985. wndMgr.ShowCursor(self.hWnd, True)
  986.  
  987. def OnKillFocus(self):
  988. self.SetText(ime.GetText(self.bCodePage))
  989. self.OnIMECloseCandidateList()
  990. self.OnIMECloseReadingWnd()
  991. ime.DisableIME()
  992. ime.DisableCaptureInput()
  993. wndMgr.HideCursor(self.hWnd)
  994.  
  995. def OnIMEChangeCodePage(self):
  996. self.SetCodePage(ime.GetCodePage())
  997.  
  998. def OnIMEOpenCandidateList(self):
  999. self.candidateWindow.Show()
  1000. self.candidateWindow.Clear()
  1001. self.candidateWindow.Refresh()
  1002.  
  1003. gx, gy = self.GetGlobalPosition()
  1004. self.candidateWindow.SetCandidatePosition(gx, gy, len(self.GetText()))
  1005.  
  1006. return True
  1007.  
  1008. def OnIMECloseCandidateList(self):
  1009. self.candidateWindow.Hide()
  1010. return True
  1011.  
  1012. def OnIMEOpenReadingWnd(self):
  1013. gx, gy = self.GetGlobalPosition()
  1014. textlen = len(self.GetText())-2
  1015. reading = ime.GetReading()
  1016. readinglen = len(reading)
  1017. self.readingWnd.SetReadingPosition( gx + textlen*6-24-readinglen*6, gy )
  1018. self.readingWnd.SetText(reading)
  1019. if ime.GetReadingError() == 0:
  1020. self.readingWnd.SetTextColor(0xffffffff)
  1021. else:
  1022. self.readingWnd.SetTextColor(0xffff0000)
  1023. self.readingWnd.SetSize(readinglen * 6 + 4, 19)
  1024. self.readingWnd.Show()
  1025. return True
  1026.  
  1027. def OnIMECloseReadingWnd(self):
  1028. self.readingWnd.Hide()
  1029. return True
  1030.  
  1031. def OnIMEUpdate(self):
  1032. snd.PlaySound("sound/ui/type.wav")
  1033. TextLine.SetText(self, ime.GetText(self.bCodePage))
  1034.  
  1035. def OnIMETab(self):
  1036. if self.eventTab:
  1037. self.eventTab()
  1038. return True
  1039.  
  1040. return False
  1041.  
  1042. def OnIMEReturn(self):
  1043. snd.PlaySound("sound/ui/click.wav")
  1044. self.eventReturn()
  1045.  
  1046. return True
  1047.  
  1048. def OnPressEscapeKey(self):
  1049. self.eventEscape()
  1050. return True
  1051.  
  1052. def OnKeyDown(self, key):
  1053. if app.DIK_F1 == key:
  1054. return False
  1055. if app.DIK_F2 == key:
  1056. return False
  1057. if app.DIK_F3 == key:
  1058. return False
  1059. if app.DIK_F4 == key:
  1060. return False
  1061. if app.DIK_LALT == key:
  1062. return False
  1063. if app.DIK_SYSRQ == key:
  1064. return False
  1065. if app.DIK_LCONTROL == key:
  1066. return False
  1067. if app.DIK_V == key:
  1068. if app.IsPressed(app.DIK_LCONTROL):
  1069. ime.PasteTextFromClipBoard()
  1070.  
  1071. return True
  1072.  
  1073. def OnKeyUp(self, key):
  1074. if app.DIK_F1 == key:
  1075. return False
  1076. if app.DIK_F2 == key:
  1077. return False
  1078. if app.DIK_F3 == key:
  1079. return False
  1080. if app.DIK_F4 == key:
  1081. return False
  1082. if app.DIK_LALT == key:
  1083. return False
  1084. if app.DIK_SYSRQ == key:
  1085. return False
  1086. if app.DIK_LCONTROL == key:
  1087. return False
  1088.  
  1089. return True
  1090.  
  1091. def OnIMEKeyDown(self, key):
  1092. # Left
  1093. if app.VK_LEFT == key:
  1094. ime.MoveLeft()
  1095. return True
  1096. # Right
  1097. if app.VK_RIGHT == key:
  1098. ime.MoveRight()
  1099. return True
  1100.  
  1101. # Home
  1102. if app.VK_HOME == key:
  1103. ime.MoveHome()
  1104. return True
  1105. # End
  1106. if app.VK_END == key:
  1107. ime.MoveEnd()
  1108. return True
  1109.  
  1110. # Delete
  1111. if app.VK_DELETE == key:
  1112. ime.Delete()
  1113. TextLine.SetText(self, ime.GetText(self.bCodePage))
  1114. return True
  1115.  
  1116. return True
  1117.  
  1118. #def OnMouseLeftButtonDown(self):
  1119. # self.SetFocus()
  1120. def OnMouseLeftButtonDown(self):
  1121. if False == self.IsIn():
  1122. return False
  1123.  
  1124. self.SetFocus()
  1125. PixelPosition = wndMgr.GetCursorPosition(self.hWnd)
  1126. ime.SetCursorPosition(PixelPosition)
  1127.  
  1128. class MarkBox(Window):
  1129. def __init__(self, layer = "UI"):
  1130. Window.__init__(self, layer)
  1131.  
  1132. def __del__(self):
  1133. Window.__del__(self)
  1134.  
  1135. def RegisterWindow(self, layer):
  1136. self.hWnd = wndMgr.RegisterMarkBox(self, layer)
  1137.  
  1138. def Load(self):
  1139. wndMgr.MarkBox_Load(self.hWnd)
  1140.  
  1141. def SetScale(self, scale):
  1142. wndMgr.MarkBox_SetScale(self.hWnd, scale)
  1143.  
  1144. def SetIndex(self, guildID):
  1145. MarkID = guild.GuildIDToMarkID(guildID)
  1146. wndMgr.MarkBox_SetImageFilename(self.hWnd, guild.GetMarkImageFilenameByMarkID(MarkID))
  1147. wndMgr.MarkBox_SetIndex(self.hWnd, guild.GetMarkIndexByMarkID(MarkID))
  1148.  
  1149. def SetAlpha(self, alpha):
  1150. wndMgr.MarkBox_SetDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1151.  
  1152. class ImageBox(Window):
  1153. def __init__(self, layer = "UI"):
  1154. Window.__init__(self, layer)
  1155.  
  1156. self.eventDict={}
  1157. self.eventFunc = {"mouse_click" : None, "mouse_over_in" : None, "mouse_over_out" : None}
  1158. self.eventArgs = {"mouse_click" : None, "mouse_over_in" : None, "mouse_over_out" : None}
  1159.  
  1160.  
  1161. def __del__(self):
  1162. Window.__del__(self)
  1163. self.eventFunc = None
  1164. self.eventArgs = None
  1165.  
  1166. def RegisterWindow(self, layer):
  1167. self.hWnd = wndMgr.RegisterImageBox(self, layer)
  1168.  
  1169. def LoadImage(self, imageName):
  1170. self.name=imageName
  1171. wndMgr.LoadImage(self.hWnd, imageName)
  1172.  
  1173. if len(self.eventDict)!=0:
  1174. print "LOAD IMAGE", self, self.eventDict
  1175.  
  1176. def SetAlpha(self, alpha):
  1177. wndMgr.SetDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1178.  
  1179. def GetWidth(self):
  1180. return wndMgr.GetWidth(self.hWnd)
  1181.  
  1182. def GetHeight(self):
  1183. return wndMgr.GetHeight(self.hWnd)
  1184.  
  1185. def OnMouseOverIn(self):
  1186. try:
  1187. self.eventDict["MOUSE_OVER_IN"]()
  1188. except KeyError:
  1189. pass
  1190.  
  1191. def OnMouseOverOut(self):
  1192. try:
  1193. self.eventDict["MOUSE_OVER_OUT"]()
  1194. except KeyError:
  1195. pass
  1196.  
  1197. def SAFE_SetStringEvent(self, event, func,isa=FALSE):
  1198. if not isa:
  1199. self.eventDict[event]=__mem_func__(func)
  1200. else:
  1201. self.eventDict[event]=func
  1202.  
  1203. if app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  1204. def LeftRightReverse(self):
  1205. wndMgr.LeftRightReverseImageBox(self.hWnd)
  1206.  
  1207. def SetEvent(self, func, *args) :
  1208. result = self.eventFunc.has_key(args[0])
  1209. if result :
  1210. self.eventFunc[args[0]] = func
  1211. self.eventArgs[args[0]] = args
  1212. else :
  1213. print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
  1214.  
  1215. def OnMouseLeftButtonUp(self) :
  1216. if self.eventFunc["mouse_click"] :
  1217. apply(self.eventFunc["mouse_click"], self.eventArgs["mouse_click"])
  1218.  
  1219. def OnMouseOverIn(self) :
  1220. if self.eventFunc["mouse_over_in"] :
  1221. apply(self.eventFunc["mouse_over_in"], self.eventArgs["mouse_over_in"])
  1222. else:
  1223. try:
  1224. self.eventDict["MOUSE_OVER_IN"]()
  1225. except KeyError:
  1226. pass
  1227.  
  1228. def OnMouseOverOut(self) :
  1229. if self.eventFunc["mouse_over_out"] :
  1230. apply(self.eventFunc["mouse_over_out"], self.eventArgs["mouse_over_out"])
  1231. else :
  1232. try:
  1233. self.eventDict["MOUSE_OVER_OUT"]()
  1234. except KeyError:
  1235. pass
  1236.  
  1237. def SetOnMouseLeftButtonUpEvent(self, event, *args):
  1238. self.eventFunc["MOUSE_LEFT_BUTTON_UP"] = event
  1239. self.eventArgs["MOUSE_LEFT_BUTTON_UP"] = args
  1240.  
  1241.  
  1242. class ExpandedImageBox(ImageBox):
  1243. def __init__(self, layer = "UI"):
  1244. ImageBox.__init__(self, layer)
  1245.  
  1246. def __del__(self):
  1247. ImageBox.__del__(self)
  1248.  
  1249. def RegisterWindow(self, layer):
  1250. self.hWnd = wndMgr.RegisterExpandedImageBox(self, layer)
  1251.  
  1252. def SetScale(self, xScale, yScale):
  1253. wndMgr.SetScale(self.hWnd, xScale, yScale)
  1254.  
  1255. def SetOrigin(self, x, y):
  1256. wndMgr.SetOrigin(self.hWnd, x, y)
  1257.  
  1258. def SetRotation(self, rotation):
  1259. wndMgr.SetRotation(self.hWnd, rotation)
  1260.  
  1261. def SetRenderingMode(self, mode):
  1262. wndMgr.SetRenderingMode(self.hWnd, mode)
  1263.  
  1264. # [0.0, 1.0] 사이의 값만큼 퍼센트로 그리지 않는다.
  1265. def SetRenderingRect(self, left, top, right, bottom):
  1266. wndMgr.SetRenderingRect(self.hWnd, left, top, right, bottom)
  1267.  
  1268. def SetPercentage(self, curValue, maxValue):
  1269. if maxValue:
  1270. self.SetRenderingRect(0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)
  1271. else:
  1272. self.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  1273.  
  1274. def GetWidth(self):
  1275. return wndMgr.GetWindowWidth(self.hWnd)
  1276.  
  1277. def GetHeight(self):
  1278. return wndMgr.GetWindowHeight(self.hWnd)
  1279.  
  1280. class AniImageBox(Window):
  1281. def __init__(self, layer = "UI"):
  1282. Window.__init__(self, layer)
  1283.  
  1284. def __del__(self):
  1285. Window.__del__(self)
  1286.  
  1287. def RegisterWindow(self, layer):
  1288. self.hWnd = wndMgr.RegisterAniImageBox(self, layer)
  1289.  
  1290. def SetDelay(self, delay):
  1291. wndMgr.SetDelay(self.hWnd, delay)
  1292.  
  1293. def AppendImage(self, filename):
  1294. wndMgr.AppendImage(self.hWnd, filename)
  1295.  
  1296. def SetPercentage(self, curValue, maxValue):
  1297. wndMgr.SetRenderingRect(self.hWnd, 0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)
  1298.  
  1299. def OnEndFrame(self):
  1300. pass
  1301.  
  1302. class Button(Window):
  1303. def __init__(self, layer = "UI"):
  1304. Window.__init__(self, layer)
  1305.  
  1306. if app.ENABLE_DETAILS_UI:
  1307. self.overFunc = None
  1308. self.overArgs = None
  1309. self.overOutFunc = None
  1310. self.overOutArgs = None
  1311.  
  1312. self.eventFunc = None
  1313. self.eventArgs = None
  1314.  
  1315. self.ButtonText = None
  1316. self.ToolTipText = None
  1317.  
  1318. def __del__(self):
  1319. Window.__del__(self)
  1320.  
  1321. if app.ENABLE_DETAILS_UI:
  1322. self.overFunc = None
  1323. self.overArgs = None
  1324. self.overOutFunc = None
  1325. self.overOutArgs = None
  1326.  
  1327. self.eventFunc = None
  1328. self.eventArgs = None
  1329.  
  1330. def RegisterWindow(self, layer):
  1331. self.hWnd = wndMgr.RegisterButton(self, layer)
  1332.  
  1333. def SetUpVisual(self, filename):
  1334. wndMgr.SetUpVisual(self.hWnd, filename)
  1335.  
  1336. def SetOverVisual(self, filename):
  1337. wndMgr.SetOverVisual(self.hWnd, filename)
  1338.  
  1339. def SetDownVisual(self, filename):
  1340. wndMgr.SetDownVisual(self.hWnd, filename)
  1341.  
  1342. def SetDisableVisual(self, filename):
  1343. wndMgr.SetDisableVisual(self.hWnd, filename)
  1344.  
  1345. def GetUpVisualFileName(self):
  1346. return wndMgr.GetUpVisualFileName(self.hWnd)
  1347.  
  1348. def GetOverVisualFileName(self):
  1349. return wndMgr.GetOverVisualFileName(self.hWnd)
  1350.  
  1351. def GetDownVisualFileName(self):
  1352. return wndMgr.GetDownVisualFileName(self.hWnd)
  1353.  
  1354. def Flash(self):
  1355. wndMgr.Flash(self.hWnd)
  1356.  
  1357. def Enable(self):
  1358. wndMgr.Enable(self.hWnd)
  1359.  
  1360. def Disable(self):
  1361. wndMgr.Disable(self.hWnd)
  1362.  
  1363. def Down(self):
  1364. wndMgr.Down(self.hWnd)
  1365.  
  1366. def SetUp(self):
  1367. wndMgr.SetUp(self.hWnd)
  1368.  
  1369. def SAFE_SetEvent(self, func, *args):
  1370. self.eventFunc = __mem_func__(func)
  1371. self.eventArgs = args
  1372.  
  1373. def SetEvent(self, func, *args):
  1374. self.eventFunc = func
  1375. self.eventArgs = args
  1376.  
  1377. def SetTextColor(self, color):
  1378. if not self.ButtonText:
  1379. return
  1380. self.ButtonText.SetPackedFontColor(color)
  1381.  
  1382. def SetTextAddPos(self, text, x_add = 0, y_add = 0, height = 4):
  1383. if not self.ButtonText:
  1384. textLine = TextLine()
  1385. textLine.SetParent(self)
  1386. textLine.SetPosition(self.GetWidth() / 2 + x_add, self.GetHeight() / 2 + y_add)
  1387. textLine.SetVerticalAlignCenter()
  1388. textLine.SetHorizontalAlignCenter()
  1389. textLine.Show()
  1390. self.ButtonText = textLine
  1391. self.ButtonText.SetText(text)
  1392.  
  1393. def SetText(self, text, height = 4):
  1394.  
  1395. if not self.ButtonText:
  1396. textLine = TextLine()
  1397. textLine.SetParent(self)
  1398. textLine.SetPosition(self.GetWidth()/2, self.GetHeight()/2)
  1399. textLine.SetVerticalAlignCenter()
  1400. textLine.SetHorizontalAlignCenter()
  1401. textLine.Show()
  1402. self.ButtonText = textLine
  1403.  
  1404. self.ButtonText.SetText(text)
  1405.  
  1406. def SetFormToolTipText(self, type, text, x, y):
  1407. if not self.ToolTipText:
  1408. toolTip=createToolTipWindowDict[type]()
  1409. toolTip.SetParent(self)
  1410. toolTip.SetSize(0, 0)
  1411. toolTip.SetHorizontalAlignCenter()
  1412. toolTip.SetOutline()
  1413. toolTip.Hide()
  1414. toolTip.SetPosition(x + self.GetWidth()/2, y)
  1415. self.ToolTipText=toolTip
  1416.  
  1417. self.ToolTipText.SetText(text)
  1418.  
  1419. def SetToolTipWindow(self, toolTip):
  1420. self.ToolTipText=toolTip
  1421. self.ToolTipText.SetParentProxy(self)
  1422.  
  1423. def SetToolTipText(self, text, x=0, y = -19):
  1424. self.SetFormToolTipText("TEXT", text, x, y)
  1425.  
  1426. def CallEvent(self):
  1427. snd.PlaySound("sound/ui/click.wav")
  1428.  
  1429. if self.eventFunc:
  1430. apply(self.eventFunc, self.eventArgs)
  1431.  
  1432. def ShowToolTip(self):
  1433. if self.ToolTipText:
  1434. self.ToolTipText.Show()
  1435.  
  1436. def HideToolTip(self):
  1437. if self.ToolTipText:
  1438. self.ToolTipText.Hide()
  1439.  
  1440. def IsDown(self):
  1441. return wndMgr.IsDown(self.hWnd)
  1442.  
  1443. def GetText(self):
  1444. if not self.ButtonText:
  1445. return ""
  1446. return self.ButtonText.GetText()
  1447.  
  1448. if app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  1449. def SetAlpha(self, alpha):
  1450. wndMgr.SetButtonDiffuseColor(self.hWnd, 1.0, 1.0, 1.0, alpha)
  1451.  
  1452. def GetText(self):
  1453. if self.ButtonText:
  1454. return self.ButtonText.GetText()
  1455. else:
  1456. return ""
  1457.  
  1458. def IsDIsable(self):
  1459. return wndMgr.IsDisable(self.hWnd)
  1460.  
  1461. if app.ENABLE_DETAILS_UI:
  1462. def OnMouseOverIn(self):
  1463. if self.overFunc:
  1464. apply(self.overFunc, self.overArgs )
  1465. def OnMouseOverOut(self):
  1466. if self.overOutFunc:
  1467. apply(self.overOutFunc, self.overOutArgs )
  1468. def SetOverEvent(self, func, *args):
  1469. self.overFunc = func
  1470. self.overArgs = args
  1471. def SetOverOutEvent(self, func, *args):
  1472. self.overOutFunc = func
  1473. self.overOutArgs = args
  1474.  
  1475. class RadioButton(Button):
  1476. def __init__(self):
  1477. Button.__init__(self)
  1478.  
  1479. def __del__(self):
  1480. Button.__del__(self)
  1481.  
  1482. def RegisterWindow(self, layer):
  1483. self.hWnd = wndMgr.RegisterRadioButton(self, layer)
  1484.  
  1485. class RadioButtonGroup:
  1486. def __init__(self):
  1487. self.buttonGroup = []
  1488. self.selectedBtnIdx = -1
  1489.  
  1490. def __del__(self):
  1491. for button, ue, de in self.buttonGroup:
  1492. button.__del__()
  1493.  
  1494. def Show(self):
  1495. for (button, selectEvent, unselectEvent) in self.buttonGroup:
  1496. button.Show()
  1497.  
  1498. def Hide(self):
  1499. for (button, selectEvent, unselectEvent) in self.buttonGroup:
  1500. button.Hide()
  1501.  
  1502. def SetText(self, idx, text):
  1503. if idx >= len(self.buttonGroup):
  1504. return
  1505. (button, selectEvent, unselectEvent) = self.buttonGroup[idx]
  1506. button.SetText(text)
  1507.  
  1508. def OnClick(self, btnIdx):
  1509. if btnIdx == self.selectedBtnIdx:
  1510. return
  1511. (button, selectEvent, unselectEvent) = self.buttonGroup[self.selectedBtnIdx]
  1512. if unselectEvent:
  1513. unselectEvent()
  1514. button.SetUp()
  1515.  
  1516. self.selectedBtnIdx = btnIdx
  1517. (button, selectEvent, unselectEvent) = self.buttonGroup[btnIdx]
  1518. if selectEvent:
  1519. selectEvent()
  1520.  
  1521. button.Down()
  1522.  
  1523. def AddButton(self, button, selectEvent, unselectEvent):
  1524. i = len(self.buttonGroup)
  1525. button.SetEvent(lambda : self.OnClick(i))
  1526. self.buttonGroup.append([button, selectEvent, unselectEvent])
  1527. button.SetUp()
  1528.  
  1529. def Create(rawButtonGroup):
  1530. radioGroup = RadioButtonGroup()
  1531. for (button, selectEvent, unselectEvent) in rawButtonGroup:
  1532. radioGroup.AddButton(button, selectEvent, unselectEvent)
  1533.  
  1534. radioGroup.OnClick(0)
  1535.  
  1536. return radioGroup
  1537.  
  1538. Create=staticmethod(Create)
  1539.  
  1540. if app.__BL_PICK_FILTER__:
  1541. class ToggleButton(Button):
  1542. def __init__(self):
  1543. Button.__init__(self)
  1544.  
  1545. self.eventUp = None
  1546. self.eventDown = None
  1547.  
  1548. self.eventUpArgs = None
  1549. self.eventDownArgs = None
  1550.  
  1551. def __del__(self):
  1552. Button.__del__(self)
  1553.  
  1554. self.eventUp = None
  1555. self.eventDown = None
  1556.  
  1557. def SetToggleUpEvent(self, event, *args):
  1558. self.eventUp = event
  1559. self.eventUpArgs = args
  1560.  
  1561. def SetToggleDownEvent(self, event, *args):
  1562. self.eventDown = event
  1563. self.eventDownArgs = args
  1564.  
  1565. def RegisterWindow(self, layer):
  1566. self.hWnd = wndMgr.RegisterToggleButton(self, layer)
  1567.  
  1568. def OnToggleUp(self):
  1569. if self.eventUp:
  1570. if self.eventUpArgs:
  1571. apply(self.eventUp, self.eventUpArgs)
  1572. else:
  1573. self.eventUp()
  1574.  
  1575. def OnToggleDown(self):
  1576. if self.eventDown:
  1577. if self.eventDownArgs:
  1578. apply(self.eventDown, self.eventDownArgs)
  1579. else:
  1580. self.eventDown()
  1581. else:
  1582. class ToggleButton(Button):
  1583. def __init__(self):
  1584. Button.__init__(self)
  1585.  
  1586. self.eventUp = None
  1587. self.eventDown = None
  1588.  
  1589. def __del__(self):
  1590. Button.__del__(self)
  1591.  
  1592. self.eventUp = None
  1593. self.eventDown = None
  1594.  
  1595. def SetToggleUpEvent(self, event):
  1596. self.eventUp = event
  1597.  
  1598. def SetToggleDownEvent(self, event):
  1599. self.eventDown = event
  1600.  
  1601. def RegisterWindow(self, layer):
  1602. self.hWnd = wndMgr.RegisterToggleButton(self, layer)
  1603.  
  1604. def OnToggleUp(self):
  1605. if self.eventUp:
  1606. self.eventUp()
  1607.  
  1608. def OnToggleDown(self):
  1609. if self.eventDown:
  1610. self.eventDown()
  1611.  
  1612. class DragButton(Button):
  1613. def __init__(self):
  1614. Button.__init__(self)
  1615. self.AddFlag("movable")
  1616.  
  1617. self.callbackEnable = True
  1618. self.eventMove = lambda: None
  1619.  
  1620. def __del__(self):
  1621. Button.__del__(self)
  1622.  
  1623. self.eventMove = lambda: None
  1624.  
  1625. def RegisterWindow(self, layer):
  1626. self.hWnd = wndMgr.RegisterDragButton(self, layer)
  1627.  
  1628. def SetMoveEvent(self, event):
  1629. self.eventMove = event
  1630.  
  1631. def SetRestrictMovementArea(self, x, y, width, height):
  1632. wndMgr.SetRestrictMovementArea(self.hWnd, x, y, width, height)
  1633.  
  1634. def TurnOnCallBack(self):
  1635. self.callbackEnable = True
  1636.  
  1637. def TurnOffCallBack(self):
  1638. self.callbackEnable = False
  1639.  
  1640. def OnMove(self):
  1641. if self.callbackEnable:
  1642. self.eventMove()
  1643.  
  1644. class NumberLine(Window):
  1645.  
  1646. def __init__(self, layer = "UI"):
  1647. Window.__init__(self, layer)
  1648.  
  1649. def __del__(self):
  1650. Window.__del__(self)
  1651.  
  1652. def RegisterWindow(self, layer):
  1653. self.hWnd = wndMgr.RegisterNumberLine(self, layer)
  1654.  
  1655. def SetHorizontalAlignCenter(self):
  1656. wndMgr.SetNumberHorizontalAlignCenter(self.hWnd)
  1657.  
  1658. def SetHorizontalAlignRight(self):
  1659. wndMgr.SetNumberHorizontalAlignRight(self.hWnd)
  1660.  
  1661. def SetPath(self, path):
  1662. wndMgr.SetPath(self.hWnd, path)
  1663.  
  1664. def SetNumber(self, number):
  1665. wndMgr.SetNumber(self.hWnd, number)
  1666.  
  1667. ###################################################################################################
  1668. ## PythonScript Element
  1669. ###################################################################################################
  1670.  
  1671. class Box(Window):
  1672.  
  1673. def RegisterWindow(self, layer):
  1674. self.hWnd = wndMgr.RegisterBox(self, layer)
  1675.  
  1676. def SetColor(self, color):
  1677. wndMgr.SetColor(self.hWnd, color)
  1678.  
  1679. class Bar(Window):
  1680.  
  1681. def RegisterWindow(self, layer):
  1682. self.hWnd = wndMgr.RegisterBar(self, layer)
  1683.  
  1684. def SetColor(self, color):
  1685. wndMgr.SetColor(self.hWnd, color)
  1686.  
  1687. class Line(Window):
  1688.  
  1689. def RegisterWindow(self, layer):
  1690. self.hWnd = wndMgr.RegisterLine(self, layer)
  1691.  
  1692. def SetColor(self, color):
  1693. wndMgr.SetColor(self.hWnd, color)
  1694.  
  1695. class SlotBar(Window):
  1696.  
  1697. def __init__(self):
  1698. Window.__init__(self)
  1699.  
  1700. def RegisterWindow(self, layer):
  1701. self.hWnd = wndMgr.RegisterBar3D(self, layer)
  1702.  
  1703. ## Same with SlotBar
  1704. class Bar3D(Window):
  1705.  
  1706. def __init__(self):
  1707. Window.__init__(self)
  1708.  
  1709. def RegisterWindow(self, layer):
  1710. self.hWnd = wndMgr.RegisterBar3D(self, layer)
  1711.  
  1712. def SetColor(self, left, right, center):
  1713. wndMgr.SetColor(self.hWnd, left, right, center)
  1714.  
  1715. class SlotWindow(Window):
  1716.  
  1717. def __init__(self):
  1718. Window.__init__(self)
  1719.  
  1720. self.StartIndex = 0
  1721.  
  1722. self.eventSelectEmptySlot = None
  1723. self.eventSelectItemSlot = None
  1724. self.eventUnselectEmptySlot = None
  1725. self.eventUnselectItemSlot = None
  1726. self.eventUseSlot = None
  1727. self.eventOverInItem = None
  1728. self.eventOverOutItem = None
  1729. self.eventPressedSlotButton = None
  1730. self.eventOverInItem2 = None
  1731. self.eventOverInItem3 = None
  1732.  
  1733. def __del__(self):
  1734. Window.__del__(self)
  1735.  
  1736. self.eventSelectEmptySlot = None
  1737. self.eventSelectItemSlot = None
  1738. self.eventUnselectEmptySlot = None
  1739. self.eventUnselectItemSlot = None
  1740. self.eventUseSlot = None
  1741. self.eventOverInItem = None
  1742. self.eventOverOutItem = None
  1743. self.eventPressedSlotButton = None
  1744. self.eventOverInItem2 = None
  1745. self.eventOverInItem3 = None
  1746.  
  1747. def RegisterWindow(self, layer):
  1748. self.hWnd = wndMgr.RegisterSlotWindow(self, layer)
  1749.  
  1750. def SetSlotStyle(self, style):
  1751. wndMgr.SetSlotStyle(self.hWnd, style)
  1752.  
  1753. def HasSlot(self, slotIndex):
  1754. return wndMgr.HasSlot(self.hWnd, slotIndex)
  1755.  
  1756. def SetSlotBaseImage(self, imageFileName, r, g, b, a):
  1757. wndMgr.SetSlotBaseImage(self.hWnd, imageFileName, r, g, b, a)
  1758.  
  1759. def SetCoverButton(self,\
  1760. slotIndex,\
  1761. upName="d:/ymir work/ui/public/slot_cover_button_01.sub",\
  1762. overName="d:/ymir work/ui/public/slot_cover_button_02.sub",\
  1763. downName="d:/ymir work/ui/public/slot_cover_button_03.sub",\
  1764. disableName="d:/ymir work/ui/public/slot_cover_button_04.sub",\
  1765. LeftButtonEnable = False,\
  1766. RightButtonEnable = True):
  1767. wndMgr.SetCoverButton(self.hWnd, slotIndex, upName, overName, downName, disableName, LeftButtonEnable, RightButtonEnable)
  1768.  
  1769. def EnableCoverButton(self, slotIndex):
  1770. wndMgr.EnableCoverButton(self.hWnd, slotIndex)
  1771.  
  1772. def DisableCoverButton(self, slotIndex):
  1773. wndMgr.DisableCoverButton(self.hWnd, slotIndex)
  1774.  
  1775. def SetAlwaysRenderCoverButton(self, slotIndex, bAlwaysRender = TRUE):
  1776. wndMgr.SetAlwaysRenderCoverButton(self.hWnd, slotIndex, bAlwaysRender)
  1777.  
  1778. def AppendSlotButton(self, upName, overName, downName):
  1779. wndMgr.AppendSlotButton(self.hWnd, upName, overName, downName)
  1780.  
  1781. def ShowSlotButton(self, slotNumber):
  1782. wndMgr.ShowSlotButton(self.hWnd, slotNumber)
  1783.  
  1784. def HideAllSlotButton(self):
  1785. wndMgr.HideAllSlotButton(self.hWnd)
  1786.  
  1787. def AppendRequirementSignImage(self, filename):
  1788. wndMgr.AppendRequirementSignImage(self.hWnd, filename)
  1789.  
  1790. def ShowRequirementSign(self, slotNumber):
  1791. wndMgr.ShowRequirementSign(self.hWnd, slotNumber)
  1792.  
  1793. def HideRequirementSign(self, slotNumber):
  1794. wndMgr.HideRequirementSign(self.hWnd, slotNumber)
  1795.  
  1796. if app.ENABLE_SASH_SYSTEM:
  1797. def ActivateSlot(self, slotNumber, r = 1.0, g = 1.0, b = 1.0, a = 1.0):
  1798. wndMgr.ActivateEffect(self.hWnd, slotNumber, r, g, b, a)
  1799.  
  1800. def DeactivateSlot(self, slotNumber):
  1801. wndMgr.DeactivateEffect(self.hWnd, slotNumber)
  1802.  
  1803. def ActivateSlotOld(self, slotNumber):
  1804. wndMgr.ActivateSlot(self.hWnd, slotNumber)
  1805.  
  1806. def DeactivateSlotOld(self, slotNumber):
  1807. wndMgr.DeactivateSlot(self.hWnd, slotNumber)
  1808. else:
  1809. def ActivateSlot(self, slotNumber):
  1810. wndMgr.ActivateSlot(self.hWnd, slotNumber)
  1811.  
  1812. def DeactivateSlot(self, slotNumber):
  1813. wndMgr.DeactivateSlot(self.hWnd, slotNumber)
  1814.  
  1815. # Verific? dac? atributul BL_ENABLE_PICKUP_ITEM_EFFECT exist? in app
  1816. if hasattr(app, 'BL_ENABLE_PICKUP_ITEM_EFFECT') and app.BL_ENABLE_PICKUP_ITEM_EFFECT:
  1817. def SetSlotDiffuseColor(self, slotindex, colortype):
  1818. wndMgr.SetSlotDiffuseColor(self.hWnd, slotindex, colortype)
  1819.  
  1820. def ShowSlotBaseImage(self, slotNumber):
  1821. wndMgr.ShowSlotBaseImage(self.hWnd, slotNumber)
  1822.  
  1823. def HideSlotBaseImage(self, slotNumber):
  1824. wndMgr.HideSlotBaseImage(self.hWnd, slotNumber)
  1825.  
  1826. def SAFE_SetButtonEvent(self, button, state, event):
  1827. if "LEFT"==button:
  1828. if "EMPTY"==state:
  1829. self.eventSelectEmptySlot=__mem_func__(event)
  1830. elif "EXIST"==state:
  1831. self.eventSelectItemSlot=__mem_func__(event)
  1832. elif "ALWAYS"==state:
  1833. self.eventSelectEmptySlot=__mem_func__(event)
  1834. self.eventSelectItemSlot=__mem_func__(event)
  1835. elif "RIGHT"==button:
  1836. if "EMPTY"==state:
  1837. self.eventUnselectEmptySlot=__mem_func__(event)
  1838. elif "EXIST"==state:
  1839. self.eventUnselectItemSlot=__mem_func__(event)
  1840. elif "ALWAYS"==state:
  1841. self.eventUnselectEmptySlot=__mem_func__(event)
  1842. self.eventUnselectItemSlot=__mem_func__(event)
  1843.  
  1844. def SetSelectEmptySlotEvent(self, empty):
  1845. self.eventSelectEmptySlot = empty
  1846.  
  1847. def SetSelectItemSlotEvent(self, item):
  1848. self.eventSelectItemSlot = item
  1849.  
  1850. def SetUnselectEmptySlotEvent(self, empty):
  1851. self.eventUnselectEmptySlot = empty
  1852.  
  1853. def SetUnselectItemSlotEvent(self, item):
  1854. self.eventUnselectItemSlot = item
  1855.  
  1856. def SetUseSlotEvent(self, use):
  1857. self.eventUseSlot = use
  1858.  
  1859. def SetOverInItemEvent(self, event):
  1860. self.eventOverInItem = event
  1861.  
  1862. def SetOverOutItemEvent(self, event):
  1863. self.eventOverOutItem = event
  1864.  
  1865. def SetPressedSlotButtonEvent(self, event):
  1866. self.eventPressedSlotButton = event
  1867.  
  1868. def GetSlotCount(self):
  1869. return wndMgr.GetSlotCount(self.hWnd)
  1870.  
  1871. def SetUseMode(self, flag):
  1872. "True일때만 ItemToItem 이 가능한지 보여준다"
  1873. wndMgr.SetUseMode(self.hWnd, flag)
  1874.  
  1875. def SetUsableItem(self, flag):
  1876. "True면 현재 가리킨 아이템이 ItemToItem 적용 가능하다"
  1877. wndMgr.SetUsableItem(self.hWnd, flag)
  1878.  
  1879. ## Slot
  1880. def SetSlotCoolTime(self, slotIndex, coolTime, elapsedTime = 0.0):
  1881. wndMgr.SetSlotCoolTime(self.hWnd, slotIndex, coolTime, elapsedTime)
  1882.  
  1883. def DisableSlot(self, slotIndex):
  1884. wndMgr.DisableSlot(self.hWnd, slotIndex)
  1885.  
  1886. def EnableSlot(self, slotIndex):
  1887. wndMgr.EnableSlot(self.hWnd, slotIndex)
  1888.  
  1889. def LockSlot(self, slotIndex):
  1890. wndMgr.LockSlot(self.hWnd, slotIndex)
  1891.  
  1892. def UnlockSlot(self, slotIndex):
  1893. wndMgr.UnlockSlot(self.hWnd, slotIndex)
  1894.  
  1895. def RefreshSlot(self):
  1896. wndMgr.RefreshSlot(self.hWnd)
  1897.  
  1898. def ClearSlot(self, slotNumber):
  1899. wndMgr.ClearSlot(self.hWnd, slotNumber)
  1900.  
  1901. def ClearAllSlot(self):
  1902. wndMgr.ClearAllSlot(self.hWnd)
  1903.  
  1904. def AppendSlot(self, index, x, y, width, height):
  1905. wndMgr.AppendSlot(self.hWnd, index, x, y, width, height)
  1906.  
  1907. def SetSlot(self, slotIndex, itemIndex, width, height, icon, diffuseColor = (1.0, 1.0, 1.0, 1.0)):
  1908. wndMgr.SetSlot(self.hWnd, slotIndex, itemIndex, width, height, icon, diffuseColor)
  1909.  
  1910. def SetSlotCount(self, slotNumber, count):
  1911. wndMgr.SetSlotCount(self.hWnd, slotNumber, count)
  1912.  
  1913. def SetSlotCountNew(self, slotNumber, grade, count):
  1914. wndMgr.SetSlotCountNew(self.hWnd, slotNumber, grade, count)
  1915.  
  1916. def SetOverInItemEvent2(self, event):
  1917. self.eventOverInItem2 = event
  1918.  
  1919. def SetOverInItemEvent3(self, event):
  1920. self.eventOverInItem3 = event
  1921.  
  1922. def SetItemSlot(self, renderingSlotNumber, ItemIndex, ItemCount = 0, diffuseColor = (1.0, 1.0, 1.0, 1.0),id=0):
  1923. if 0 == ItemIndex or None == ItemIndex:
  1924. wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  1925. return
  1926.  
  1927. item.SelectItem(ItemIndex)
  1928. itemIcon = item.GetIconImage()
  1929.  
  1930. item.SelectItem(ItemIndex)
  1931. (width, height) = item.GetItemSize()
  1932. wndMgr.SetSlot(self.hWnd, renderingSlotNumber, ItemIndex, width, height, itemIcon, diffuseColor)
  1933. wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, ItemCount)
  1934. wndMgr.SetSlotID(self.hWnd, renderingSlotNumber, id)
  1935.  
  1936. def SetSkillSlot(self, renderingSlotNumber, skillIndex, skillLevel):
  1937.  
  1938. skillIcon = skill.GetIconImage(skillIndex)
  1939.  
  1940. if 0 == skillIcon:
  1941. wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  1942. return
  1943.  
  1944. wndMgr.SetSlot(self.hWnd, renderingSlotNumber, skillIndex, 1, 1, skillIcon)
  1945. wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, skillLevel)
  1946.  
  1947. def SetSkillSlotNew(self, renderingSlotNumber, skillIndex, skillGrade, skillLevel):
  1948.  
  1949. skillIcon = skill.GetIconImageNew(skillIndex, skillGrade)
  1950.  
  1951. if 0 == skillIcon:
  1952. wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  1953. return
  1954.  
  1955. wndMgr.SetSlot(self.hWnd, renderingSlotNumber, skillIndex, 1, 1, skillIcon)
  1956.  
  1957. def SetEmotionSlot(self, renderingSlotNumber, emotionIndex):
  1958. import player
  1959. icon = player.GetEmotionIconImage(emotionIndex)
  1960.  
  1961. if 0 == icon:
  1962. wndMgr.ClearSlot(self.hWnd, renderingSlotNumber)
  1963. return
  1964.  
  1965. wndMgr.SetSlot(self.hWnd, renderingSlotNumber, emotionIndex, 1, 1, icon)
  1966.  
  1967. ## Event
  1968. def OnSelectEmptySlot(self, slotNumber):
  1969. if self.eventSelectEmptySlot:
  1970. self.eventSelectEmptySlot(slotNumber)
  1971.  
  1972. def OnSelectItemSlot(self, slotNumber):
  1973. if self.eventSelectItemSlot:
  1974. self.eventSelectItemSlot(slotNumber)
  1975.  
  1976. def OnUnselectEmptySlot(self, slotNumber):
  1977. if self.eventUnselectEmptySlot:
  1978. self.eventUnselectEmptySlot(slotNumber)
  1979.  
  1980. def OnUnselectItemSlot(self, slotNumber):
  1981. if self.eventUnselectItemSlot:
  1982. self.eventUnselectItemSlot(slotNumber)
  1983.  
  1984. def OnUseSlot(self, slotNumber):
  1985. if self.eventUseSlot:
  1986. self.eventUseSlot(slotNumber)
  1987.  
  1988.  
  1989. def OnOverInItem(self, slotNumber,vnum=0,itemID=0):
  1990. if self.eventOverInItem:
  1991. self.eventOverInItem(slotNumber)
  1992. if self.eventOverInItem2 and vnum>0:
  1993. self.eventOverInItem2(vnum)
  1994. if self.eventOverInItem3 and itemID>0:
  1995. self.eventOverInItem3(itemID)
  1996.  
  1997. def OnOverOutItem(self):
  1998. if self.eventOverOutItem:
  1999. self.eventOverOutItem()
  2000.  
  2001. def OnPressedSlotButton(self, slotNumber):
  2002. if self.eventPressedSlotButton:
  2003. self.eventPressedSlotButton(slotNumber)
  2004.  
  2005. def GetStartIndex(self):
  2006. return 0
  2007.  
  2008. if app.ENABLE_DSS_ACTIVE_EFFECT_BUTTON:
  2009. def SetRenderSlot(self, renderingSlotNumber, diffuseColor = (1.0, 1.0, 1.0, 1.0)):
  2010. wndMgr.SetSlot(self.hWnd, renderingSlotNumber, 1, 1, 1, 0, diffuseColor)
  2011. wndMgr.SetSlotCount(self.hWnd, renderingSlotNumber, 0)
  2012.  
  2013. class GridSlotWindow(SlotWindow):
  2014.  
  2015. def __init__(self):
  2016. SlotWindow.__init__(self)
  2017.  
  2018. self.startIndex = 0
  2019.  
  2020. def __del__(self):
  2021. SlotWindow.__del__(self)
  2022.  
  2023. def RegisterWindow(self, layer):
  2024. self.hWnd = wndMgr.RegisterGridSlotWindow(self, layer)
  2025.  
  2026. def ArrangeSlot(self, StartIndex, xCount, yCount, xSize, ySize, xBlank, yBlank):
  2027.  
  2028. self.startIndex = StartIndex
  2029.  
  2030. wndMgr.ArrangeSlot(self.hWnd, StartIndex, xCount, yCount, xSize, ySize, xBlank, yBlank)
  2031. self.startIndex = StartIndex
  2032.  
  2033. def GetStartIndex(self):
  2034. return self.startIndex
  2035.  
  2036. class TitleBar(Window):
  2037.  
  2038. BLOCK_WIDTH = 32
  2039. BLOCK_HEIGHT = 23
  2040.  
  2041. def __init__(self):
  2042. Window.__init__(self)
  2043. self.AddFlag("attach")
  2044.  
  2045. def __del__(self):
  2046. Window.__del__(self)
  2047.  
  2048. def MakeTitleBar(self, width, color):
  2049.  
  2050. ## 현재 Color는 사용하고 있지 않음
  2051.  
  2052. width = max(64, width)
  2053.  
  2054. imgLeft = ImageBox()
  2055. imgCenter = ExpandedImageBox()
  2056. imgRight = ImageBox()
  2057. imgLeft.AddFlag("not_pick")
  2058. imgCenter.AddFlag("not_pick")
  2059. imgRight.AddFlag("not_pick")
  2060. imgLeft.SetParent(self)
  2061. imgCenter.SetParent(self)
  2062. imgRight.SetParent(self)
  2063.  
  2064. if localeInfo.IsARABIC():
  2065. imgLeft.LoadImage("locale/ae/ui/pattern/titlebar_left.tga")
  2066. imgCenter.LoadImage("locale/ae/ui/pattern/titlebar_center.tga")
  2067. imgRight.LoadImage("locale/ae/ui/pattern/titlebar_right.tga")
  2068. else:
  2069. imgLeft.LoadImage("d:/ymir work/ui/pattern/titlebar_left.tga")
  2070. imgCenter.LoadImage("d:/ymir work/ui/pattern/titlebar_center.tga")
  2071. imgRight.LoadImage("d:/ymir work/ui/pattern/titlebar_right.tga")
  2072.  
  2073. imgLeft.Show()
  2074. imgCenter.Show()
  2075. imgRight.Show()
  2076.  
  2077. btnClose = Button()
  2078. btnClose.SetParent(self)
  2079. btnClose.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  2080. btnClose.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  2081. btnClose.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  2082. btnClose.SetToolTipText(localeInfo.UI_CLOSE, 0, -23)
  2083. btnClose.Show()
  2084.  
  2085. self.imgLeft = imgLeft
  2086. self.imgCenter = imgCenter
  2087. self.imgRight = imgRight
  2088. self.btnClose = btnClose
  2089.  
  2090. self.SetWidth(width)
  2091.  
  2092. def SetWidth(self, width):
  2093. self.imgCenter.SetRenderingRect(0.0, 0.0, float((width - self.BLOCK_WIDTH*2) - self.BLOCK_WIDTH) / self.BLOCK_WIDTH, 0.0)
  2094. self.imgCenter.SetPosition(self.BLOCK_WIDTH, 0)
  2095. self.imgRight.SetPosition(width - self.BLOCK_WIDTH, 0)
  2096.  
  2097. if localeInfo.IsARABIC():
  2098. self.btnClose.SetPosition(3, 3)
  2099. else:
  2100. self.btnClose.SetPosition(width - self.btnClose.GetWidth() - 3, 3)
  2101.  
  2102. self.SetSize(width, self.BLOCK_HEIGHT)
  2103.  
  2104. def SetCloseEvent(self, event):
  2105. self.btnClose.SetEvent(event)
  2106.  
  2107. if app.ENABLE_DETAILS_UI:
  2108. def CloseButtonHide(self) :
  2109. if localeInfo.IsARABIC():
  2110. self.imgLeft.LoadImage("d:/ymir work/ui/pattern/titlebar_right_02.tga")
  2111. self.imgLeft.LeftRightReverse()
  2112. self.btnClose.Hide()
  2113. else:
  2114. self.imgRight.LoadImage("d:/ymir work/ui/pattern/titlebar_right_02.tga")
  2115. self.btnClose.Hide()
  2116.  
  2117. class HorizontalBar(Window):
  2118.  
  2119. BLOCK_WIDTH = 32
  2120. BLOCK_HEIGHT = 17
  2121.  
  2122. def __init__(self):
  2123. Window.__init__(self)
  2124. self.AddFlag("attach")
  2125.  
  2126. def __del__(self):
  2127. Window.__del__(self)
  2128.  
  2129. def Create(self, width):
  2130.  
  2131. width = max(96, width)
  2132.  
  2133. imgLeft = ImageBox()
  2134. imgLeft.SetParent(self)
  2135. imgLeft.AddFlag("not_pick")
  2136. imgLeft.LoadImage("d:/ymir work/ui/pattern/horizontalbar_left.tga")
  2137. imgLeft.Show()
  2138.  
  2139. imgCenter = ExpandedImageBox()
  2140. imgCenter.SetParent(self)
  2141. imgCenter.AddFlag("not_pick")
  2142. imgCenter.LoadImage("d:/ymir work/ui/pattern/horizontalbar_center.tga")
  2143. imgCenter.Show()
  2144.  
  2145. imgRight = ImageBox()
  2146. imgRight.SetParent(self)
  2147. imgRight.AddFlag("not_pick")
  2148. imgRight.LoadImage("d:/ymir work/ui/pattern/horizontalbar_right.tga")
  2149. imgRight.Show()
  2150.  
  2151. self.imgLeft = imgLeft
  2152. self.imgCenter = imgCenter
  2153. self.imgRight = imgRight
  2154. self.SetWidth(width)
  2155.  
  2156. def SetWidth(self, width):
  2157. self.imgCenter.SetRenderingRect(0.0, 0.0, float((width - self.BLOCK_WIDTH*2) - self.BLOCK_WIDTH) / self.BLOCK_WIDTH, 0.0)
  2158. self.imgCenter.SetPosition(self.BLOCK_WIDTH, 0)
  2159. self.imgRight.SetPosition(width - self.BLOCK_WIDTH, 0)
  2160. self.SetSize(width, self.BLOCK_HEIGHT)
  2161.  
  2162. class Gauge(Window):
  2163.  
  2164. SLOT_WIDTH = 16
  2165. SLOT_HEIGHT = 7
  2166.  
  2167. GAUGE_TEMPORARY_PLACE = 12
  2168. GAUGE_WIDTH = 16
  2169.  
  2170. def __init__(self):
  2171. Window.__init__(self)
  2172. self.width = 0
  2173. def __del__(self):
  2174. Window.__del__(self)
  2175.  
  2176. def MakeGauge(self, width, color):
  2177.  
  2178. self.width = max(48, width)
  2179.  
  2180. imgSlotLeft = ImageBox()
  2181. imgSlotLeft.SetParent(self)
  2182. imgSlotLeft.LoadImage("d:/ymir work/ui/pattern/gauge_slot_left.tga")
  2183. imgSlotLeft.Show()
  2184.  
  2185. imgSlotRight = ImageBox()
  2186. imgSlotRight.SetParent(self)
  2187. imgSlotRight.LoadImage("d:/ymir work/ui/pattern/gauge_slot_right.tga")
  2188. imgSlotRight.Show()
  2189. imgSlotRight.SetPosition(width - self.SLOT_WIDTH, 0)
  2190.  
  2191. imgSlotCenter = ExpandedImageBox()
  2192. imgSlotCenter.SetParent(self)
  2193. imgSlotCenter.LoadImage("d:/ymir work/ui/pattern/gauge_slot_center.tga")
  2194. imgSlotCenter.Show()
  2195. imgSlotCenter.SetRenderingRect(0.0, 0.0, float((width - self.SLOT_WIDTH*2) - self.SLOT_WIDTH) / self.SLOT_WIDTH, 0.0)
  2196. imgSlotCenter.SetPosition(self.SLOT_WIDTH, 0)
  2197.  
  2198. imgGauge = ExpandedImageBox()
  2199. imgGauge.SetParent(self)
  2200. imgGauge.LoadImage("d:/ymir work/ui/pattern/gauge_" + color + ".tga")
  2201. imgGauge.Show()
  2202. imgGauge.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  2203. imgGauge.SetPosition(self.GAUGE_TEMPORARY_PLACE, 0)
  2204.  
  2205. imgSlotLeft.AddFlag("attach")
  2206. imgSlotCenter.AddFlag("attach")
  2207. imgSlotRight.AddFlag("attach")
  2208.  
  2209. self.imgLeft = imgSlotLeft
  2210. self.imgCenter = imgSlotCenter
  2211. self.imgRight = imgSlotRight
  2212. self.imgGauge = imgGauge
  2213.  
  2214. self.SetSize(width, self.SLOT_HEIGHT)
  2215.  
  2216. def SetPercentage(self, curValue, maxValue):
  2217.  
  2218. # PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
  2219. if maxValue > 0.0:
  2220. percentage = min(1.0, float(curValue)/float(maxValue))
  2221. else:
  2222. percentage = 0.0
  2223. # END_OF_PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
  2224.  
  2225. gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE*2) * percentage / self.GAUGE_WIDTH
  2226. self.imgGauge.SetRenderingRect(0.0, 0.0, gaugeSize, 0.0)
  2227.  
  2228. class Board(Window):
  2229.  
  2230. CORNER_WIDTH = 32
  2231. CORNER_HEIGHT = 32
  2232. LINE_WIDTH = 128
  2233. LINE_HEIGHT = 128
  2234.  
  2235. LT = 0
  2236. LB = 1
  2237. RT = 2
  2238. RB = 3
  2239. L = 0
  2240. R = 1
  2241. T = 2
  2242. B = 3
  2243.  
  2244. def __init__(self):
  2245. Window.__init__(self)
  2246.  
  2247. self.MakeBoard("d:/ymir work/ui/pattern/Board_Corner_", "d:/ymir work/ui/pattern/Board_Line_")
  2248. self.MakeBase()
  2249.  
  2250. def MakeBoard(self, cornerPath, linePath):
  2251.  
  2252. CornerFileNames = [ cornerPath+dir+".tga" for dir in ("LeftTop", "LeftBottom", "RightTop", "RightBottom", ) ]
  2253. LineFileNames = [ linePath+dir+".tga" for dir in ("Left", "Right", "Top", "Bottom", ) ]
  2254. """
  2255. CornerFileNames = (
  2256. "d:/ymir work/ui/pattern/Board_Corner_LeftTop.tga",
  2257. "d:/ymir work/ui/pattern/Board_Corner_LeftBottom.tga",
  2258. "d:/ymir work/ui/pattern/Board_Corner_RightTop.tga",
  2259. "d:/ymir work/ui/pattern/Board_Corner_RightBottom.tga",
  2260. )
  2261. LineFileNames = (
  2262. "d:/ymir work/ui/pattern/Board_Line_Left.tga",
  2263. "d:/ymir work/ui/pattern/Board_Line_Right.tga",
  2264. "d:/ymir work/ui/pattern/Board_Line_Top.tga",
  2265. "d:/ymir work/ui/pattern/Board_Line_Bottom.tga",
  2266. )
  2267. """
  2268.  
  2269. self.Corners = []
  2270. for fileName in CornerFileNames:
  2271. Corner = ExpandedImageBox()
  2272. Corner.AddFlag("not_pick")
  2273. Corner.LoadImage(fileName)
  2274. Corner.SetParent(self)
  2275. Corner.SetPosition(0, 0)
  2276. Corner.Show()
  2277. self.Corners.append(Corner)
  2278.  
  2279. self.Lines = []
  2280. for fileName in LineFileNames:
  2281. Line = ExpandedImageBox()
  2282. Line.AddFlag("not_pick")
  2283. Line.LoadImage(fileName)
  2284. Line.SetParent(self)
  2285. Line.SetPosition(0, 0)
  2286. Line.Show()
  2287. self.Lines.append(Line)
  2288.  
  2289. self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2290. self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2291.  
  2292. def MakeBase(self):
  2293. self.Base = ExpandedImageBox()
  2294. self.Base.AddFlag("not_pick")
  2295. self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
  2296. self.Base.SetParent(self)
  2297. self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2298. self.Base.Show()
  2299.  
  2300. def __del__(self):
  2301. Window.__del__(self)
  2302.  
  2303. def SetSize(self, width, height):
  2304.  
  2305. width = max(self.CORNER_WIDTH*2, width)
  2306. height = max(self.CORNER_HEIGHT*2, height)
  2307. Window.SetSize(self, width, height)
  2308.  
  2309. self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2310. self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2311. self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2312. self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2313. self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2314.  
  2315. verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2316. horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2317. self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2318. self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2319. self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2320. self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2321.  
  2322. if self.Base:
  2323. self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)
  2324.  
  2325. class BoardWithTitleBar(Board):
  2326. def __init__(self):
  2327. Board.__init__(self)
  2328.  
  2329. titleBar = TitleBar()
  2330. titleBar.SetParent(self)
  2331. titleBar.MakeTitleBar(0, "red")
  2332. titleBar.SetPosition(8, 7)
  2333. titleBar.Show()
  2334.  
  2335. titleName = TextLine()
  2336. titleName.SetParent(titleBar)
  2337. titleName.SetPosition(0, 4)
  2338. titleName.SetWindowHorizontalAlignCenter()
  2339. titleName.SetHorizontalAlignCenter()
  2340. titleName.Show()
  2341.  
  2342. self.titleBar = titleBar
  2343. self.titleName = titleName
  2344.  
  2345. self.SetCloseEvent(self.Hide)
  2346.  
  2347. def __del__(self):
  2348. Board.__del__(self)
  2349. self.titleBar = None
  2350. self.titleName = None
  2351.  
  2352. def SetSize(self, width, height):
  2353. self.titleBar.SetWidth(width - 15)
  2354. #self.pickRestrictWindow.SetSize(width, height - 30)
  2355. Board.SetSize(self, width, height)
  2356. self.titleName.UpdateRect()
  2357.  
  2358. def SetTitleColor(self, color):
  2359. self.titleName.SetPackedFontColor(color)
  2360.  
  2361. def SetTitleName(self, name):
  2362. self.titleName.SetText(name)
  2363.  
  2364. def SetCloseEvent(self, event):
  2365. self.titleBar.SetCloseEvent(event)
  2366.  
  2367. class ThinBoard(Window):
  2368.  
  2369. CORNER_WIDTH = 16
  2370. CORNER_HEIGHT = 16
  2371. LINE_WIDTH = 16
  2372. LINE_HEIGHT = 16
  2373. BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.51)
  2374.  
  2375. LT = 0
  2376. LB = 1
  2377. RT = 2
  2378. RB = 3
  2379. L = 0
  2380. R = 1
  2381. T = 2
  2382. B = 3
  2383.  
  2384. def __init__(self, layer = "UI"):
  2385. Window.__init__(self, layer)
  2386.  
  2387. CornerFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Corner_"+dir+".tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2388. LineFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Line_"+dir+".tga" for dir in ["Left","Right","Top","Bottom"] ]
  2389.  
  2390. self.Corners = []
  2391. for fileName in CornerFileNames:
  2392. Corner = ExpandedImageBox()
  2393. Corner.AddFlag("attach")
  2394. Corner.AddFlag("not_pick")
  2395. Corner.LoadImage(fileName)
  2396. Corner.SetParent(self)
  2397. Corner.SetPosition(0, 0)
  2398. Corner.Show()
  2399. self.Corners.append(Corner)
  2400.  
  2401. self.Lines = []
  2402. for fileName in LineFileNames:
  2403. Line = ExpandedImageBox()
  2404. Line.AddFlag("attach")
  2405. Line.AddFlag("not_pick")
  2406. Line.LoadImage(fileName)
  2407. Line.SetParent(self)
  2408. Line.SetPosition(0, 0)
  2409. Line.Show()
  2410. self.Lines.append(Line)
  2411.  
  2412. Base = Bar()
  2413. Base.SetParent(self)
  2414. Base.AddFlag("attach")
  2415. Base.AddFlag("not_pick")
  2416. Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2417. Base.SetColor(self.BOARD_COLOR)
  2418. Base.Show()
  2419. self.Base = Base
  2420.  
  2421. self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2422. self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2423.  
  2424. def __del__(self):
  2425. Window.__del__(self)
  2426.  
  2427. if app.ENABLE_SEND_TARGET_INFO:
  2428. def ShowCorner(self, corner):
  2429. self.Corners[corner].Show()
  2430. self.SetSize(self.GetWidth(), self.GetHeight())
  2431.  
  2432. def HideCorners(self, corner):
  2433. self.Corners[corner].Hide()
  2434. self.SetSize(self.GetWidth(), self.GetHeight())
  2435.  
  2436. def ShowLine(self, line):
  2437. self.Lines[line].Show()
  2438. self.SetSize(self.GetWidth(), self.GetHeight())
  2439.  
  2440. def HideLine(self, line):
  2441. self.Lines[line].Hide()
  2442. self.SetSize(self.GetWidth(), self.GetHeight())
  2443.  
  2444.  
  2445. def SetSize(self, width, height):
  2446.  
  2447. width = max(self.CORNER_WIDTH*2, width)
  2448. height = max(self.CORNER_HEIGHT*2, height)
  2449. Window.SetSize(self, width, height)
  2450.  
  2451. self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2452. self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2453. self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2454. self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2455. self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2456.  
  2457. verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2458. horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2459. self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2460. self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2461. self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2462. self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2463. self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
  2464.  
  2465. def ShowInternal(self):
  2466. self.Base.Show()
  2467. for wnd in self.Lines:
  2468. wnd.Show()
  2469. for wnd in self.Corners:
  2470. wnd.Show()
  2471.  
  2472. def HideInternal(self):
  2473. self.Base.Hide()
  2474. for wnd in self.Lines:
  2475. wnd.Hide()
  2476. for wnd in self.Corners:
  2477. wnd.Hide()
  2478.  
  2479. class ThinBoardGold(Window):
  2480. CORNER_WIDTH = 16
  2481. CORNER_HEIGHT = 16
  2482. LINE_WIDTH = 16
  2483. LINE_HEIGHT = 16
  2484.  
  2485. LT = 0
  2486. LB = 1
  2487. RT = 2
  2488. RB = 3
  2489. L = 0
  2490. R = 1
  2491. T = 2
  2492. B = 3
  2493.  
  2494. def __init__(self, layer = "UI"):
  2495. Window.__init__(self, layer)
  2496.  
  2497. CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Corner_"+dir+"_Gold.tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2498. LineFileNames = [ "d:/ymir work/ui/pattern/thinboardgold/ThinBoard_Line_"+dir+"_Gold.tga" for dir in ["Left","Right","Top","Bottom"] ]
  2499.  
  2500. self.MakeBase()
  2501.  
  2502. self.Corners = []
  2503. for fileName in CornerFileNames:
  2504. Corner = ExpandedImageBox()
  2505. Corner.AddFlag("attach")
  2506. Corner.AddFlag("not_pick")
  2507. Corner.LoadImage(fileName)
  2508. Corner.SetParent(self)
  2509. Corner.SetPosition(0, 0)
  2510. Corner.Show()
  2511. self.Corners.append(Corner)
  2512.  
  2513. self.Lines = []
  2514. for fileName in LineFileNames:
  2515. Line = ExpandedImageBox()
  2516. Line.AddFlag("attach")
  2517. Line.AddFlag("not_pick")
  2518. Line.LoadImage(fileName)
  2519. Line.SetParent(self)
  2520. Line.SetPosition(0, 0)
  2521. Line.Show()
  2522. self.Lines.append(Line)
  2523.  
  2524. self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2525. self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2526.  
  2527. def __del__(self):
  2528. Window.__del__(self)
  2529.  
  2530. def SetSize(self, width, height):
  2531.  
  2532. width = max(self.CORNER_WIDTH*2, width)
  2533. height = max(self.CORNER_HEIGHT*2, height)
  2534. Window.SetSize(self, width, height)
  2535.  
  2536. self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2537. self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2538. self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2539. self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2540. self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2541.  
  2542. verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2543. horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2544.  
  2545. self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2546. self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2547. self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2548. self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2549.  
  2550. #self.Base.GetWidth()
  2551. #self.Base.GetHeight()
  2552. """
  2553. Defalt Width : 128, Height : 128
  2554. 0.0 > 128, 1.0 > 256
  2555. """
  2556. if self.Base:
  2557. self.Base.SetRenderingRect(0, 0, (float(width)-32)/float(self.Base.GetWidth()) - 1.0, (float(height)-32)/float(self.Base.GetHeight()) - 1.0)
  2558.  
  2559. def MakeBase(self):
  2560. self.Base = ExpandedImageBox()
  2561. self.Base.AddFlag("not_pick")
  2562. self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
  2563. self.Base.SetParent(self)
  2564. self.Base.SetPosition(16, 16)
  2565. self.Base.SetAlpha(0.8)
  2566. self.Base.Show()
  2567.  
  2568. def ShowInternal(self):
  2569. self.Base.Show()
  2570. for wnd in self.Lines:
  2571. wnd.Show()
  2572. for wnd in self.Corners:
  2573. wnd.Show()
  2574.  
  2575. def HideInternal(self):
  2576. self.Base.Hide()
  2577. for wnd in self.Lines:
  2578. wnd.Hide()
  2579. for wnd in self.Corners:
  2580. wnd.Hide()
  2581.  
  2582. class ThinBoardCircle(Window):
  2583. CORNER_WIDTH = 4
  2584. CORNER_HEIGHT = 4
  2585. LINE_WIDTH = 4
  2586. LINE_HEIGHT = 4
  2587. BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
  2588.  
  2589. LT = 0
  2590. LB = 1
  2591. RT = 2
  2592. RB = 3
  2593. L = 0
  2594. R = 1
  2595. T = 2
  2596. B = 3
  2597.  
  2598. def __init__(self, layer = "UI"):
  2599. Window.__init__(self, layer)
  2600.  
  2601. CornerFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Corner_"+dir+"_Circle.tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  2602. LineFileNames = [ "d:/ymir work/ui/pattern/thinboardcircle/ThinBoard_Line_"+dir+"_Circle.tga" for dir in ["Left","Right","Top","Bottom"] ]
  2603.  
  2604. self.Corners = []
  2605. for fileName in CornerFileNames:
  2606. Corner = ExpandedImageBox()
  2607. Corner.AddFlag("attach")
  2608. Corner.AddFlag("not_pick")
  2609. Corner.LoadImage(fileName)
  2610. Corner.SetParent(self)
  2611. Corner.SetPosition(0, 0)
  2612. Corner.Show()
  2613. self.Corners.append(Corner)
  2614.  
  2615. self.Lines = []
  2616. for fileName in LineFileNames:
  2617. Line = ExpandedImageBox()
  2618. Line.AddFlag("attach")
  2619. Line.AddFlag("not_pick")
  2620. Line.LoadImage(fileName)
  2621. Line.SetParent(self)
  2622. Line.SetPosition(0, 0)
  2623. Line.Show()
  2624. self.Lines.append(Line)
  2625.  
  2626. Base = Bar()
  2627. Base.SetParent(self)
  2628. Base.AddFlag("attach")
  2629. Base.AddFlag("not_pick")
  2630. Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2631. Base.SetColor(self.BOARD_COLOR)
  2632. Base.Show()
  2633. self.Base = Base
  2634.  
  2635. self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  2636. self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  2637.  
  2638. def __del__(self):
  2639. Window.__del__(self)
  2640.  
  2641. def SetSize(self, width, height):
  2642.  
  2643. width = max(self.CORNER_WIDTH*2, width)
  2644. height = max(self.CORNER_HEIGHT*2, height)
  2645. Window.SetSize(self, width, height)
  2646.  
  2647. self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  2648. self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  2649. self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  2650. self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  2651. self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  2652.  
  2653. verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  2654. horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  2655. self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2656. self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  2657. self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2658. self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  2659. self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
  2660.  
  2661. def ShowInternal(self):
  2662. self.Base.Show()
  2663. for wnd in self.Lines:
  2664. wnd.Show()
  2665. for wnd in self.Corners:
  2666. wnd.Show()
  2667.  
  2668. def HideInternal(self):
  2669. self.Base.Hide()
  2670. for wnd in self.Lines:
  2671. wnd.Hide()
  2672. for wnd in self.Corners:
  2673. wnd.Hide()
  2674.  
  2675. def SetAlpha(self, alpha):
  2676. color = grp.GenerateColor(0.0, 0.0, 0.0, alpha)
  2677. self.Base.SetColor(color)
  2678. for wnd in self.Lines:
  2679. wnd.SetAlpha(alpha)
  2680. for wnd in self.Corners:
  2681. wnd.SetAlpha(alpha)
  2682.  
  2683. class ScrollBar(Window):
  2684.  
  2685. SCROLLBAR_WIDTH = 17
  2686. SCROLLBAR_MIDDLE_HEIGHT = 9
  2687. SCROLLBAR_BUTTON_WIDTH = 17
  2688. SCROLLBAR_BUTTON_HEIGHT = 17
  2689. MIDDLE_BAR_POS = 5
  2690. MIDDLE_BAR_UPPER_PLACE = 3
  2691. MIDDLE_BAR_DOWNER_PLACE = 4
  2692. TEMP_SPACE = MIDDLE_BAR_UPPER_PLACE + MIDDLE_BAR_DOWNER_PLACE
  2693.  
  2694. class MiddleBar(DragButton):
  2695. def __init__(self):
  2696. DragButton.__init__(self)
  2697. self.AddFlag("movable")
  2698. #self.AddFlag("restrict_x")
  2699.  
  2700. def MakeImage(self):
  2701. top = ImageBox()
  2702. top.SetParent(self)
  2703. top.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Top.tga")
  2704. top.SetPosition(0, 0)
  2705. top.AddFlag("not_pick")
  2706. top.Show()
  2707. bottom = ImageBox()
  2708. bottom.SetParent(self)
  2709. bottom.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Bottom.tga")
  2710. bottom.AddFlag("not_pick")
  2711. bottom.Show()
  2712.  
  2713. middle = ExpandedImageBox()
  2714. middle.SetParent(self)
  2715. middle.LoadImage("d:/ymir work/ui/pattern/ScrollBar_Middle.tga")
  2716. middle.SetPosition(0, 4)
  2717. middle.AddFlag("not_pick")
  2718. middle.Show()
  2719.  
  2720. self.top = top
  2721. self.bottom = bottom
  2722. self.middle = middle
  2723.  
  2724. def SetSize(self, height):
  2725. height = max(12, height)
  2726. DragButton.SetSize(self, 10, height)
  2727. self.bottom.SetPosition(0, height-4)
  2728.  
  2729. height -= 4*3
  2730. self.middle.SetRenderingRect(0, 0, 0, float(height)/4.0)
  2731.  
  2732. def __init__(self):
  2733. Window.__init__(self)
  2734.  
  2735. self.pageSize = 1
  2736. self.curPos = 0.0
  2737. self.eventScroll = lambda *arg: None
  2738. self.lockFlag = False
  2739. self.scrollStep = 0.20
  2740.  
  2741.  
  2742. self.CreateScrollBar()
  2743.  
  2744. def __del__(self):
  2745. Window.__del__(self)
  2746.  
  2747. def CreateScrollBar(self):
  2748. barSlot = Bar3D()
  2749. barSlot.SetParent(self)
  2750. barSlot.AddFlag("not_pick")
  2751. barSlot.Show()
  2752.  
  2753. middleBar = self.MiddleBar()
  2754. middleBar.SetParent(self)
  2755. middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  2756. middleBar.Show()
  2757. middleBar.MakeImage()
  2758. middleBar.SetSize(12)
  2759.  
  2760. upButton = Button()
  2761. upButton.SetParent(self)
  2762. upButton.SetEvent(__mem_func__(self.OnUp))
  2763. upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_up_button_01.sub")
  2764. upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_up_button_02.sub")
  2765. upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_up_button_03.sub")
  2766. upButton.Show()
  2767.  
  2768. downButton = Button()
  2769. downButton.SetParent(self)
  2770. downButton.SetEvent(__mem_func__(self.OnDown))
  2771. downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_down_button_01.sub")
  2772. downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_down_button_02.sub")
  2773. downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_down_button_03.sub")
  2774. downButton.Show()
  2775.  
  2776. self.upButton = upButton
  2777. self.downButton = downButton
  2778. self.middleBar = middleBar
  2779. self.barSlot = barSlot
  2780.  
  2781. self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  2782. self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  2783. self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  2784. self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  2785.  
  2786. def Destroy(self):
  2787. self.middleBar = None
  2788. self.upButton = None
  2789. self.downButton = None
  2790. self.eventScroll = lambda *arg: None
  2791.  
  2792. def SetScrollEvent(self, event):
  2793. self.eventScroll = event
  2794.  
  2795. def SetMiddleBarSize(self, pageScale):
  2796. realHeight = self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2
  2797. self.SCROLLBAR_MIDDLE_HEIGHT = int(pageScale * float(realHeight))
  2798. self.middleBar.SetSize(self.SCROLLBAR_MIDDLE_HEIGHT)
  2799. self.pageSize = (self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  2800.  
  2801. def SetScrollBarSize(self, height):
  2802. self.pageSize = (height - self.SCROLLBAR_BUTTON_HEIGHT*2) - self.SCROLLBAR_MIDDLE_HEIGHT - (self.TEMP_SPACE)
  2803. self.SetSize(self.SCROLLBAR_WIDTH, height)
  2804. self.upButton.SetPosition(0, 0)
  2805. self.downButton.SetPosition(0, height - self.SCROLLBAR_BUTTON_HEIGHT)
  2806. self.middleBar.SetRestrictMovementArea(self.MIDDLE_BAR_POS, self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE, self.MIDDLE_BAR_POS+2, height - self.SCROLLBAR_BUTTON_HEIGHT*2 - self.TEMP_SPACE)
  2807. self.middleBar.SetPosition(self.MIDDLE_BAR_POS, 0)
  2808.  
  2809. self.UpdateBarSlot()
  2810.  
  2811. def UpdateBarSlot(self):
  2812. self.barSlot.SetPosition(0, self.SCROLLBAR_BUTTON_HEIGHT)
  2813. self.barSlot.SetSize(self.GetWidth() - 2, self.GetHeight() - self.SCROLLBAR_BUTTON_HEIGHT*2 - 2)
  2814.  
  2815. def GetPos(self):
  2816. return self.curPos
  2817.  
  2818. def SetPos(self, pos):
  2819. pos = max(0.0, pos)
  2820. pos = min(1.0, pos)
  2821.  
  2822. newPos = float(self.pageSize) * pos
  2823. self.middleBar.SetPosition(self.MIDDLE_BAR_POS, int(newPos) + self.SCROLLBAR_BUTTON_HEIGHT + self.MIDDLE_BAR_UPPER_PLACE)
  2824. self.OnMove()
  2825.  
  2826. def SetScrollStep(self, step):
  2827. self.scrollStep = step
  2828.  
  2829. def GetScrollStep(self):
  2830. return self.scrollStep
  2831.  
  2832. def OnUp(self):
  2833. self.SetPos(self.curPos-self.scrollStep)
  2834.  
  2835. def OnDown(self):
  2836. self.SetPos(self.curPos+self.scrollStep)
  2837.  
  2838. def OnMove(self):
  2839.  
  2840. if self.lockFlag:
  2841. return
  2842.  
  2843. if 0 == self.pageSize:
  2844. return
  2845.  
  2846. (xLocal, yLocal) = self.middleBar.GetLocalPosition()
  2847. self.curPos = float(yLocal - self.SCROLLBAR_BUTTON_HEIGHT - self.MIDDLE_BAR_UPPER_PLACE) / float(self.pageSize)
  2848.  
  2849. self.eventScroll()
  2850.  
  2851. def OnMouseLeftButtonDown(self):
  2852. (xMouseLocalPosition, yMouseLocalPosition) = self.GetMouseLocalPosition()
  2853. pickedPos = yMouseLocalPosition - self.SCROLLBAR_BUTTON_HEIGHT - self.SCROLLBAR_MIDDLE_HEIGHT/2
  2854. newPos = float(pickedPos) / float(self.pageSize)
  2855. self.SetPos(newPos)
  2856.  
  2857. def LockScroll(self):
  2858. self.lockFlag = True
  2859.  
  2860. def UnlockScroll(self):
  2861. self.lockFlag = False
  2862.  
  2863. class ThinScrollBar(ScrollBar):
  2864.  
  2865. def CreateScrollBar(self):
  2866. middleBar = self.MiddleBar()
  2867. middleBar.SetParent(self)
  2868. middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  2869. middleBar.Show()
  2870. middleBar.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_01.sub")
  2871. middleBar.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_02.sub")
  2872. middleBar.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_middle_button_03.sub")
  2873.  
  2874. upButton = Button()
  2875. upButton.SetParent(self)
  2876. upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_01.sub")
  2877. upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_02.sub")
  2878. upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_up_button_03.sub")
  2879. upButton.SetEvent(__mem_func__(self.OnUp))
  2880. upButton.Show()
  2881.  
  2882. downButton = Button()
  2883. downButton.SetParent(self)
  2884. downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_01.sub")
  2885. downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_02.sub")
  2886. downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_thin_down_button_03.sub")
  2887. downButton.SetEvent(__mem_func__(self.OnDown))
  2888. downButton.Show()
  2889.  
  2890. self.middleBar = middleBar
  2891. self.upButton = upButton
  2892. self.downButton = downButton
  2893.  
  2894. self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  2895. self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  2896. self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  2897. self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  2898. self.MIDDLE_BAR_POS = 0
  2899. self.MIDDLE_BAR_UPPER_PLACE = 0
  2900. self.MIDDLE_BAR_DOWNER_PLACE = 0
  2901. self.TEMP_SPACE = 0
  2902.  
  2903. def UpdateBarSlot(self):
  2904. pass
  2905.  
  2906. class SmallThinScrollBar(ScrollBar):
  2907.  
  2908. def CreateScrollBar(self):
  2909. middleBar = self.MiddleBar()
  2910. middleBar.SetParent(self)
  2911. middleBar.SetMoveEvent(__mem_func__(self.OnMove))
  2912. middleBar.Show()
  2913. middleBar.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  2914. middleBar.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  2915. middleBar.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_middle_button_01.sub")
  2916.  
  2917. upButton = Button()
  2918. upButton.SetParent(self)
  2919. upButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_01.sub")
  2920. upButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_02.sub")
  2921. upButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_up_button_03.sub")
  2922. upButton.SetEvent(__mem_func__(self.OnUp))
  2923. upButton.Show()
  2924.  
  2925. downButton = Button()
  2926. downButton.SetParent(self)
  2927. downButton.SetUpVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_01.sub")
  2928. downButton.SetOverVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_02.sub")
  2929. downButton.SetDownVisual("d:/ymir work/ui/public/scrollbar_small_thin_down_button_03.sub")
  2930. downButton.SetEvent(__mem_func__(self.OnDown))
  2931. downButton.Show()
  2932.  
  2933. self.middleBar = middleBar
  2934. self.upButton = upButton
  2935. self.downButton = downButton
  2936.  
  2937. self.SCROLLBAR_WIDTH = self.upButton.GetWidth()
  2938. self.SCROLLBAR_MIDDLE_HEIGHT = self.middleBar.GetHeight()
  2939. self.SCROLLBAR_BUTTON_WIDTH = self.upButton.GetWidth()
  2940. self.SCROLLBAR_BUTTON_HEIGHT = self.upButton.GetHeight()
  2941. self.MIDDLE_BAR_POS = 0
  2942. self.MIDDLE_BAR_UPPER_PLACE = 0
  2943. self.MIDDLE_BAR_DOWNER_PLACE = 0
  2944. self.TEMP_SPACE = 0
  2945.  
  2946. def UpdateBarSlot(self):
  2947. pass
  2948.  
  2949. class SliderBar(Window):
  2950.  
  2951. def __init__(self):
  2952. Window.__init__(self)
  2953.  
  2954. self.curPos = 1.0
  2955. self.pageSize = 1.0
  2956. self.eventChange = None
  2957.  
  2958. self.__CreateBackGroundImage()
  2959. self.__CreateCursor()
  2960.  
  2961. def __del__(self):
  2962. Window.__del__(self)
  2963.  
  2964. def __CreateBackGroundImage(self):
  2965. img = ImageBox()
  2966. img.SetParent(self)
  2967. img.LoadImage("d:/ymir work/ui/game/windows/sliderbar.sub")
  2968. img.Show()
  2969. self.backGroundImage = img
  2970.  
  2971. ##
  2972. self.SetSize(self.backGroundImage.GetWidth(), self.backGroundImage.GetHeight())
  2973.  
  2974. def __CreateCursor(self):
  2975. cursor = DragButton()
  2976. cursor.AddFlag("movable")
  2977. cursor.AddFlag("restrict_y")
  2978. cursor.SetParent(self)
  2979. cursor.SetMoveEvent(__mem_func__(self.__OnMove))
  2980. cursor.SetUpVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
  2981. cursor.SetOverVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
  2982. cursor.SetDownVisual("d:/ymir work/ui/game/windows/sliderbar_cursor.sub")
  2983. cursor.Show()
  2984. self.cursor = cursor
  2985.  
  2986. ##
  2987. self.cursor.SetRestrictMovementArea(0, 0, self.backGroundImage.GetWidth(), 0)
  2988. self.pageSize = self.backGroundImage.GetWidth() - self.cursor.GetWidth()
  2989.  
  2990. def __OnMove(self):
  2991. (xLocal, yLocal) = self.cursor.GetLocalPosition()
  2992. self.curPos = float(xLocal) / float(self.pageSize)
  2993.  
  2994. if self.eventChange:
  2995. self.eventChange()
  2996.  
  2997. def SetSliderPos(self, pos):
  2998. self.curPos = pos
  2999. self.cursor.SetPosition(int(self.pageSize * pos), 0)
  3000.  
  3001. def GetSliderPos(self):
  3002. return self.curPos
  3003.  
  3004. def SetEvent(self, event):
  3005. self.eventChange = event
  3006.  
  3007. def Enable(self):
  3008. self.cursor.Show()
  3009.  
  3010. def Disable(self):
  3011. self.cursor.Hide()
  3012.  
  3013. class ListBox(Window):
  3014.  
  3015. TEMPORARY_PLACE = 3
  3016.  
  3017. def __init__(self, layer = "UI"):
  3018. Window.__init__(self, layer)
  3019. self.overLine = -1
  3020. self.selectedLine = -1
  3021. self.width = 0
  3022. self.height = 0
  3023. self.stepSize = 17
  3024. self.basePos = 0
  3025. self.showLineCount = 0
  3026. self.itemCenterAlign = True
  3027. self.itemList = []
  3028. self.keyDict = {}
  3029. self.textDict = {}
  3030. self.event = lambda *arg: None
  3031. def __del__(self):
  3032. Window.__del__(self)
  3033.  
  3034. def SetWidth(self, width):
  3035. self.SetSize(width, self.height)
  3036.  
  3037. def SetSize(self, width, height):
  3038. Window.SetSize(self, width, height)
  3039. self.width = width
  3040. self.height = height
  3041.  
  3042. def SetTextCenterAlign(self, flag):
  3043. self.itemCenterAlign = flag
  3044.  
  3045. def SetBasePos(self, pos):
  3046. self.basePos = pos
  3047. self._LocateItem()
  3048.  
  3049. def ClearItem(self):
  3050. self.keyDict = {}
  3051. self.textDict = {}
  3052. self.itemList = []
  3053. self.overLine = -1
  3054. self.selectedLine = -1
  3055.  
  3056. def InsertItem(self, number, text):
  3057. self.keyDict[len(self.itemList)] = number
  3058. self.textDict[len(self.itemList)] = text
  3059.  
  3060. textLine = TextLine()
  3061. textLine.SetParent(self)
  3062. textLine.SetText(text)
  3063. textLine.Show()
  3064.  
  3065. if self.itemCenterAlign:
  3066. textLine.SetWindowHorizontalAlignCenter()
  3067. textLine.SetHorizontalAlignCenter()
  3068.  
  3069. self.itemList.append(textLine)
  3070.  
  3071. self._LocateItem()
  3072.  
  3073. def ChangeItem(self, number, text):
  3074. for key, value in self.keyDict.items():
  3075. if value == number:
  3076. self.textDict[key] = text
  3077.  
  3078. if number < len(self.itemList):
  3079. self.itemList[key].SetText(text)
  3080.  
  3081. return
  3082.  
  3083. def LocateItem(self):
  3084. self._LocateItem()
  3085.  
  3086. def _LocateItem(self):
  3087.  
  3088. skipCount = self.basePos
  3089. yPos = 0
  3090. self.showLineCount = 0
  3091.  
  3092. for textLine in self.itemList:
  3093. textLine.Hide()
  3094.  
  3095. if skipCount > 0:
  3096. skipCount -= 1
  3097. continue
  3098.  
  3099. # if localeInfo.IsARABIC():
  3100. # w, h = textLine.GetTextSize()
  3101. # textLine.SetPosition(w+10, yPos + 3)
  3102. # else:
  3103. # textLine.SetPosition(0, yPos + 3)
  3104.  
  3105. if app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  3106. textLine.SetPosition(0, yPos + 3)
  3107. else:
  3108. if localeInfo.IsARABIC():
  3109. w, h = textLine.GetTextSize()
  3110. textLine.SetPosition(w+10, yPos + 3)
  3111. else:
  3112. textLine.SetPosition(0, yPos + 3)
  3113.  
  3114. yPos += self.stepSize
  3115.  
  3116. if yPos <= self.GetHeight():
  3117. self.showLineCount += 1
  3118. textLine.Show()
  3119.  
  3120. def ArrangeItem(self):
  3121. self.SetSize(self.width, len(self.itemList) * self.stepSize)
  3122. self._LocateItem()
  3123.  
  3124. def GetViewItemCount(self):
  3125. return int(self.GetHeight() / self.stepSize)
  3126.  
  3127. def GetItemCount(self):
  3128. return len(self.itemList)
  3129.  
  3130. def SetEvent(self, event):
  3131. self.event = event
  3132.  
  3133. def SelectItem(self, line):
  3134.  
  3135. if not self.keyDict.has_key(line):
  3136. return
  3137.  
  3138. # if line == self.selectedLine:
  3139. # return
  3140. if not app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  3141. if line == self.selectedLine:
  3142. return
  3143.  
  3144. self.selectedLine = line
  3145. self.event(self.keyDict.get(line, 0), self.textDict.get(line, "None"))
  3146.  
  3147. def GetSelectedItem(self):
  3148. return self.keyDict.get(self.selectedLine, 0)
  3149.  
  3150. def OnMouseLeftButtonDown(self):
  3151. if self.overLine < 0:
  3152. return
  3153.  
  3154. def OnMouseLeftButtonUp(self):
  3155. if self.overLine >= 0:
  3156. self.SelectItem(self.overLine+self.basePos)
  3157.  
  3158. def OnUpdate(self):
  3159.  
  3160. self.overLine = -1
  3161.  
  3162. if self.IsIn():
  3163. x, y = self.GetGlobalPosition()
  3164. height = self.GetHeight()
  3165. xMouse, yMouse = wndMgr.GetMousePosition()
  3166.  
  3167. if yMouse - y < height - 1:
  3168. self.overLine = (yMouse - y) / self.stepSize
  3169.  
  3170. if self.overLine < 0:
  3171. self.overLine = -1
  3172. if self.overLine >= len(self.itemList):
  3173. self.overLine = -1
  3174.  
  3175. def OnRender(self):
  3176. xRender, yRender = self.GetGlobalPosition()
  3177. yRender -= self.TEMPORARY_PLACE
  3178. widthRender = self.width
  3179. heightRender = self.height + self.TEMPORARY_PLACE*2
  3180.  
  3181. if localeInfo.IsCIBN10:
  3182. if -1 != self.overLine and self.keyDict[self.overLine] != -1:
  3183. grp.SetColor(HALF_WHITE_COLOR)
  3184. grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)
  3185.  
  3186. if -1 != self.selectedLine and self.keyDict[self.selectedLine] != -1:
  3187. if self.selectedLine >= self.basePos:
  3188. if self.selectedLine - self.basePos < self.showLineCount:
  3189. grp.SetColor(SELECT_COLOR)
  3190. grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos)*self.stepSize + 4, self.width - 3, self.stepSize)
  3191.  
  3192. else:
  3193. if -1 != self.overLine:
  3194. grp.SetColor(HALF_WHITE_COLOR)
  3195. grp.RenderBar(xRender + 2, yRender + self.overLine*self.stepSize + 4, self.width - 3, self.stepSize)
  3196.  
  3197. if -1 != self.selectedLine:
  3198. if self.selectedLine >= self.basePos:
  3199. if self.selectedLine - self.basePos < self.showLineCount:
  3200. grp.SetColor(SELECT_COLOR)
  3201. grp.RenderBar(xRender + 2, yRender + (self.selectedLine-self.basePos)*self.stepSize + 4, self.width - 3, self.stepSize)
  3202.  
  3203.  
  3204.  
  3205. class ListBox2(ListBox):
  3206. def __init__(self, *args, **kwargs):
  3207. ListBox.__init__(self, *args, **kwargs)
  3208. self.rowCount = 10
  3209. self.barWidth = 0
  3210. self.colCount = 0
  3211.  
  3212. def SetRowCount(self, rowCount):
  3213. self.rowCount = rowCount
  3214.  
  3215. def SetSize(self, width, height):
  3216. ListBox.SetSize(self, width, height)
  3217. self._RefreshForm()
  3218.  
  3219. def ClearItem(self):
  3220. ListBox.ClearItem(self)
  3221. self._RefreshForm()
  3222.  
  3223. def InsertItem(self, *args, **kwargs):
  3224. ListBox.InsertItem(self, *args, **kwargs)
  3225. self._RefreshForm()
  3226.  
  3227. def OnUpdate(self):
  3228. mpos = wndMgr.GetMousePosition()
  3229. self.overLine = self._CalcPointIndex(mpos)
  3230.  
  3231. def OnRender(self):
  3232. x, y = self.GetGlobalPosition()
  3233. pos = (x + 2, y)
  3234.  
  3235. if -1 != self.overLine:
  3236. grp.SetColor(HALF_WHITE_COLOR)
  3237. self._RenderBar(pos, self.overLine)
  3238.  
  3239. if -1 != self.selectedLine:
  3240. if self.selectedLine >= self.basePos:
  3241. if self.selectedLine - self.basePos < self.showLineCount:
  3242. grp.SetColor(SELECT_COLOR)
  3243. self._RenderBar(pos, self.selectedLine-self.basePos)
  3244.  
  3245.  
  3246.  
  3247. def _CalcPointIndex(self, mpos):
  3248. if self.IsIn():
  3249. px, py = mpos
  3250. gx, gy = self.GetGlobalPosition()
  3251. lx, ly = px - gx, py - gy
  3252.  
  3253. col = lx / self.barWidth
  3254. row = ly / self.stepSize
  3255. idx = col * self.rowCount + row
  3256. if col >= 0 and col < self.colCount:
  3257. if row >= 0 and row < self.rowCount:
  3258. if idx >= 0 and idx < len(self.itemList):
  3259. return idx
  3260.  
  3261. return -1
  3262.  
  3263. def _CalcRenderPos(self, pos, idx):
  3264. x, y = pos
  3265. row = idx % self.rowCount
  3266. col = idx / self.rowCount
  3267. return (x + col * self.barWidth, y + row * self.stepSize)
  3268.  
  3269. def _RenderBar(self, basePos, idx):
  3270. x, y = self._CalcRenderPos(basePos, idx)
  3271. grp.RenderBar(x, y, self.barWidth - 3, self.stepSize)
  3272.  
  3273. def _LocateItem(self):
  3274. pos = (0, self.TEMPORARY_PLACE)
  3275.  
  3276. self.showLineCount = 0
  3277. for textLine in self.itemList:
  3278. x, y = self._CalcRenderPos(pos, self.showLineCount)
  3279. textLine.SetPosition(x, y)
  3280. textLine.Show()
  3281.  
  3282. self.showLineCount += 1
  3283.  
  3284. def _RefreshForm(self):
  3285. if len(self.itemList) % self.rowCount:
  3286. self.colCount = len(self.itemList) / self.rowCount + 1
  3287. else:
  3288. self.colCount = len(self.itemList) / self.rowCount
  3289.  
  3290. if self.colCount:
  3291. self.barWidth = self.width / self.colCount
  3292. else:
  3293. self.barWidth = self.width
  3294.  
  3295.  
  3296. class ComboBox(Window):
  3297.  
  3298. class ListBoxWithBoard(ListBox):
  3299.  
  3300. def __init__(self, layer):
  3301. ListBox.__init__(self, layer)
  3302.  
  3303. def OnRender(self):
  3304. xRender, yRender = self.GetGlobalPosition()
  3305. yRender -= self.TEMPORARY_PLACE
  3306. widthRender = self.width
  3307. heightRender = self.height + self.TEMPORARY_PLACE*2
  3308. grp.SetColor(BACKGROUND_COLOR)
  3309. grp.RenderBar(xRender, yRender, widthRender, heightRender)
  3310. grp.SetColor(DARK_COLOR)
  3311. grp.RenderLine(xRender, yRender, widthRender, 0)
  3312. grp.RenderLine(xRender, yRender, 0, heightRender)
  3313. grp.SetColor(BRIGHT_COLOR)
  3314. grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
  3315. grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
  3316.  
  3317. ListBox.OnRender(self)
  3318.  
  3319. def __init__(self):
  3320. Window.__init__(self)
  3321. self.x = 0
  3322. self.y = 0
  3323. self.width = 0
  3324. self.height = 0
  3325. self.isSelected = False
  3326. self.isOver = False
  3327. self.isListOpened = False
  3328. self.event = lambda *arg: None
  3329. self.enable = True
  3330.  
  3331. self.textLine = MakeTextLine(self)
  3332. self.textLine.SetText(localeInfo.UI_ITEM)
  3333.  
  3334. self.listBox = self.ListBoxWithBoard("TOP_MOST")
  3335. self.listBox.SetPickAlways()
  3336. self.listBox.SetParent(self)
  3337. self.listBox.SetEvent(__mem_func__(self.OnSelectItem))
  3338. self.listBox.Hide()
  3339.  
  3340. def __del__(self):
  3341. Window.__del__(self)
  3342.  
  3343. def Destroy(self):
  3344. self.textLine = None
  3345. self.listBox = None
  3346.  
  3347. def SetPosition(self, x, y):
  3348. Window.SetPosition(self, x, y)
  3349. self.x = x
  3350. self.y = y
  3351. self.__ArrangeListBox()
  3352.  
  3353. def SetSize(self, width, height):
  3354. Window.SetSize(self, width, height)
  3355. self.width = width
  3356. self.height = height
  3357. self.textLine.UpdateRect()
  3358. self.__ArrangeListBox()
  3359.  
  3360. def __ArrangeListBox(self):
  3361. self.listBox.SetPosition(0, self.height + 5)
  3362. self.listBox.SetWidth(self.width)
  3363.  
  3364. def Enable(self):
  3365. self.enable = True
  3366.  
  3367. def Disable(self):
  3368. self.enable = False
  3369. self.textLine.SetText("")
  3370. self.CloseListBox()
  3371.  
  3372. def SetEvent(self, event):
  3373. self.event = event
  3374.  
  3375. def ClearItem(self):
  3376. self.CloseListBox()
  3377. self.listBox.ClearItem()
  3378.  
  3379. def InsertItem(self, index, name):
  3380. self.listBox.InsertItem(index, name)
  3381. self.listBox.ArrangeItem()
  3382.  
  3383. def SetCurrentItem(self, text):
  3384. self.textLine.SetText(text)
  3385.  
  3386. def SelectItem(self, key):
  3387. self.listBox.SelectItem(key)
  3388.  
  3389. def OnSelectItem(self, index, name):
  3390.  
  3391. self.CloseListBox()
  3392. self.event(index)
  3393.  
  3394. def CloseListBox(self):
  3395. self.isListOpened = False
  3396. self.listBox.Hide()
  3397.  
  3398. def OnMouseLeftButtonDown(self):
  3399.  
  3400. if not self.enable:
  3401. return
  3402.  
  3403. self.isSelected = True
  3404.  
  3405. def OnMouseLeftButtonUp(self):
  3406.  
  3407. if not self.enable:
  3408. return
  3409.  
  3410. self.isSelected = False
  3411.  
  3412. if self.isListOpened:
  3413. self.CloseListBox()
  3414. else:
  3415. if self.listBox.GetItemCount() > 0:
  3416. self.isListOpened = True
  3417. self.listBox.Show()
  3418. self.__ArrangeListBox()
  3419.  
  3420. def OnUpdate(self):
  3421.  
  3422. if not self.enable:
  3423. return
  3424.  
  3425. if self.IsIn():
  3426. self.isOver = True
  3427. else:
  3428. self.isOver = False
  3429.  
  3430. def OnRender(self):
  3431. self.x, self.y = self.GetGlobalPosition()
  3432. xRender = self.x
  3433. yRender = self.y
  3434. widthRender = self.width
  3435. heightRender = self.height
  3436. grp.SetColor(BACKGROUND_COLOR)
  3437. grp.RenderBar(xRender, yRender, widthRender, heightRender)
  3438. grp.SetColor(DARK_COLOR)
  3439. grp.RenderLine(xRender, yRender, widthRender, 0)
  3440. grp.RenderLine(xRender, yRender, 0, heightRender)
  3441. grp.SetColor(BRIGHT_COLOR)
  3442. grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
  3443. grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
  3444.  
  3445. if self.isOver:
  3446. grp.SetColor(HALF_WHITE_COLOR)
  3447. grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3448.  
  3449. if self.isSelected:
  3450. grp.SetColor(WHITE_COLOR)
  3451. grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3452.  
  3453. ###################################################################################################
  3454. ## Python Script Loader
  3455. ###################################################################################################
  3456.  
  3457. class ScriptWindow(Window):
  3458. def __init__(self, layer = "UI"):
  3459. Window.__init__(self, layer)
  3460. self.Children = []
  3461. self.ElementDictionary = {}
  3462. def __del__(self):
  3463. Window.__del__(self)
  3464.  
  3465. def ClearDictionary(self):
  3466. self.Children = []
  3467. self.ElementDictionary = {}
  3468. def InsertChild(self, name, child):
  3469. self.ElementDictionary[name] = child
  3470.  
  3471. def IsChild(self, name):
  3472. return self.ElementDictionary.has_key(name)
  3473. def GetChild(self, name):
  3474. return self.ElementDictionary[name]
  3475.  
  3476. def GetChild2(self, name):
  3477. return self.ElementDictionary.get(name, None)
  3478.  
  3479. if app.BL_PRIVATESHOP_SEARCH_SYSTEM:
  3480. class ComboBoxImage(Window):
  3481. class ListBoxWithBoard(ListBox):
  3482.  
  3483. def __init__(self, layer):
  3484. ListBox.__init__(self, layer)
  3485.  
  3486. def OnRender(self):
  3487. xRender, yRender = self.GetGlobalPosition()
  3488. yRender -= self.TEMPORARY_PLACE
  3489. widthRender = self.width
  3490. heightRender = self.height + self.TEMPORARY_PLACE*2
  3491. grp.SetColor(BACKGROUND_COLOR)
  3492. grp.RenderBar(xRender, yRender, widthRender, heightRender)
  3493. grp.SetColor(DARK_COLOR)
  3494. grp.RenderLine(xRender, yRender, widthRender, 0)
  3495. grp.RenderLine(xRender, yRender, 0, heightRender)
  3496. ListBox.OnRender(self)
  3497.  
  3498. def __init__(self, parent, name, x ,y):
  3499. Window.__init__(self)
  3500. self.isSelected = False
  3501. self.isOver = False
  3502. self.isListOpened = False
  3503. self.event = lambda *arg: None
  3504. self.enable = True
  3505. self.imagebox = None
  3506.  
  3507. ## imagebox
  3508. image = ImageBox()
  3509. image.SetParent(parent)
  3510. image.LoadImage(name)
  3511. image.SetPosition(x, y)
  3512. image.Show()
  3513. self.imagebox = image
  3514.  
  3515. ## BaseSetting
  3516. self.x = x + 1
  3517. self.y = y + 1
  3518. self.width = self.imagebox.GetWidth() - 3
  3519. self.height = self.imagebox.GetHeight() - 3
  3520. self.SetParent(parent)
  3521.  
  3522. ## TextLine
  3523. self.textLine = MakeTextLine(self)
  3524. self.textLine.SetText(localeInfo.UI_ITEM)
  3525.  
  3526. ## ListBox
  3527. self.listBox = self.ListBoxWithBoard("TOP_MOST")
  3528. self.listBox.SetPickAlways()
  3529. self.listBox.SetParent(self)
  3530. self.listBox.SetEvent(__mem_func__(self.OnSelectItem))
  3531. self.listBox.Hide()
  3532.  
  3533. Window.SetPosition(self, self.x, self.y)
  3534. Window.SetSize(self, self.width, self.height)
  3535. self.textLine.UpdateRect()
  3536. self.__ArrangeListBox()
  3537.  
  3538. def __del__(self):
  3539. Window.__del__(self)
  3540.  
  3541. def Destroy(self):
  3542. self.textLine = None
  3543. self.listBox = None
  3544. self.imagebox = None
  3545.  
  3546. def SetPosition(self, x, y):
  3547. Window.SetPosition(self, x, y)
  3548. self.imagebox.SetPosition(x, y)
  3549. self.x = x
  3550. self.y = y
  3551. self.__ArrangeListBox()
  3552.  
  3553. def SetSize(self, width, height):
  3554. Window.SetSize(self, width, height)
  3555. self.width = width
  3556. self.height = height
  3557. self.textLine.UpdateRect()
  3558. self.__ArrangeListBox()
  3559.  
  3560. def __ArrangeListBox(self):
  3561. self.listBox.SetPosition(0, self.height + 5)
  3562. self.listBox.SetWidth(self.width)
  3563.  
  3564. def Enable(self):
  3565. self.enable = True
  3566.  
  3567. def Disable(self):
  3568. self.enable = False
  3569. self.textLine.SetText("")
  3570. self.CloseListBox()
  3571.  
  3572. def SetEvent(self, event):
  3573. self.event = event
  3574.  
  3575. def ClearItem(self):
  3576. self.CloseListBox()
  3577. self.listBox.ClearItem()
  3578.  
  3579. def InsertItem(self, index, name):
  3580. self.listBox.InsertItem(index, name)
  3581. self.listBox.ArrangeItem()
  3582.  
  3583. def SetCurrentItem(self, text):
  3584. self.textLine.SetText(text)
  3585.  
  3586. def SelectItem(self, key):
  3587. self.listBox.SelectItem(key)
  3588.  
  3589. def OnSelectItem(self, index, name):
  3590. self.CloseListBox()
  3591. self.event(index)
  3592.  
  3593. def CloseListBox(self):
  3594. self.isListOpened = False
  3595. self.listBox.Hide()
  3596.  
  3597. def OnMouseLeftButtonDown(self):
  3598.  
  3599. if not self.enable:
  3600. return
  3601.  
  3602. self.isSelected = True
  3603.  
  3604. def OnMouseLeftButtonUp(self):
  3605. if not self.enable:
  3606. return
  3607.  
  3608. self.isSelected = False
  3609.  
  3610. if self.isListOpened:
  3611. self.CloseListBox()
  3612. else:
  3613. if self.listBox.GetItemCount() > 0:
  3614. self.isListOpened = True
  3615. self.listBox.Show()
  3616. self.__ArrangeListBox()
  3617.  
  3618. def OnUpdate(self):
  3619.  
  3620. if not self.enable:
  3621. return
  3622.  
  3623. if self.IsIn():
  3624. self.isOver = True
  3625. else:
  3626. self.isOver = False
  3627.  
  3628. def OnRender(self):
  3629. self.x, self.y = self.GetGlobalPosition()
  3630. xRender = self.x
  3631. yRender = self.y
  3632. widthRender = self.width
  3633. heightRender = self.height
  3634. if self.isOver:
  3635. grp.SetColor(HALF_WHITE_COLOR)
  3636. grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3637. if self.isSelected:
  3638. grp.SetColor(WHITE_COLOR)
  3639. grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
  3640.  
  3641. class PythonScriptLoader(object):
  3642.  
  3643. BODY_KEY_LIST = ( "x", "y", "width", "height" )
  3644.  
  3645. #####
  3646.  
  3647. DEFAULT_KEY_LIST = ( "type", "x", "y", )
  3648. WINDOW_KEY_LIST = ( "width", "height", )
  3649. IMAGE_KEY_LIST = ( "image", )
  3650. EXPANDED_IMAGE_KEY_LIST = ( "image", )
  3651. ANI_IMAGE_KEY_LIST = ( "images", )
  3652. SLOT_KEY_LIST = ( "width", "height", "slot", )
  3653. CANDIDATE_LIST_KEY_LIST = ( "item_step", "item_xsize", "item_ysize", )
  3654. GRID_TABLE_KEY_LIST = ( "start_index", "x_count", "y_count", "x_step", "y_step", )
  3655. EDIT_LINE_KEY_LIST = ( "width", "height", "input_limit", )
  3656. COMBO_BOX_KEY_LIST = ( "width", "height", "item", )
  3657. TITLE_BAR_KEY_LIST = ( "width", )
  3658. HORIZONTAL_BAR_KEY_LIST = ( "width", )
  3659. BOARD_KEY_LIST = ( "width", "height", )
  3660. BOARD_WITH_TITLEBAR_KEY_LIST = ( "width", "height", "title", )
  3661. BOX_KEY_LIST = ( "width", "height", )
  3662. BAR_KEY_LIST = ( "width", "height", )
  3663. LINE_KEY_LIST = ( "width", "height", )
  3664. SLOTBAR_KEY_LIST = ( "width", "height", )
  3665. GAUGE_KEY_LIST = ( "width", "color", )
  3666. SCROLLBAR_KEY_LIST = ( "size", )
  3667. LIST_BOX_KEY_LIST = ( "width", "height", )
  3668.  
  3669. def __init__(self):
  3670. self.Clear()
  3671.  
  3672. def Clear(self):
  3673. self.ScriptDictionary = { "SCREEN_WIDTH" : wndMgr.GetScreenWidth(), "SCREEN_HEIGHT" : wndMgr.GetScreenHeight() }
  3674. self.InsertFunction = 0
  3675.  
  3676. def LoadScriptFile(self, window, FileName):
  3677. import exception
  3678. import exceptions
  3679. import os
  3680. import errno
  3681. self.Clear()
  3682.  
  3683. print "===== Load Script File : %s" % (FileName)
  3684.  
  3685. try:
  3686. # chr, player 등은 sandbox 내에서 import가 허용되지 않기 때문에,(봇이 악용할 여지가 매우 큼.)
  3687. # 미리 script dictionary에 필요한 상수를 넣어놓는다.
  3688. import chr
  3689. import player
  3690. import app
  3691. self.ScriptDictionary["PLAYER_NAME_MAX_LEN"] = chr.PLAYER_NAME_MAX_LEN
  3692. self.ScriptDictionary["DRAGON_SOUL_EQUIPMENT_SLOT_START"] = player.DRAGON_SOUL_EQUIPMENT_SLOT_START
  3693. self.ScriptDictionary["LOCALE_PATH"] = app.GetLocalePath()
  3694. execfile(FileName, self.ScriptDictionary)
  3695. except IOError, err:
  3696. import sys
  3697. import dbg
  3698. dbg.TraceError("Failed to load script file : %s" % (FileName))
  3699. dbg.TraceError("error : %s" % (err))
  3700. exception.Abort("LoadScriptFile1")
  3701. except RuntimeError,err:
  3702. import sys
  3703. import dbg
  3704. dbg.TraceError("Failed to load script file : %s" % (FileName))
  3705. dbg.TraceError("error : %s" % (err))
  3706. exception.Abort("LoadScriptFile2")
  3707. except:
  3708. import sys
  3709. import dbg
  3710. dbg.TraceError("Failed to load script file : %s" % (FileName))
  3711. exception.Abort("LoadScriptFile!!!!!!!!!!!!!!")
  3712.  
  3713. #####
  3714.  
  3715. Body = self.ScriptDictionary["window"]
  3716. self.CheckKeyList("window", Body, self.BODY_KEY_LIST)
  3717.  
  3718. window.ClearDictionary()
  3719. self.InsertFunction = window.InsertChild
  3720.  
  3721. window.SetPosition(int(Body["x"]), int(Body["y"]))
  3722.  
  3723. if localeInfo.IsARABIC():
  3724. w = wndMgr.GetScreenWidth()
  3725. h = wndMgr.GetScreenHeight()
  3726. if Body.has_key("width"):
  3727. w = int(Body["width"])
  3728. if Body.has_key("height"):
  3729. h = int(Body["height"])
  3730.  
  3731. window.SetSize(w, h)
  3732. else:
  3733. window.SetSize(int(Body["width"]), int(Body["height"]))
  3734. if True == Body.has_key("style"):
  3735. for StyleList in Body["style"]:
  3736. window.AddFlag(StyleList)
  3737.  
  3738.  
  3739. self.LoadChildren(window, Body)
  3740.  
  3741. def LoadChildren(self, parent, dicChildren):
  3742.  
  3743. if localeInfo.IsARABIC():
  3744. parent.AddFlag( "rtl" )
  3745.  
  3746. if True == dicChildren.has_key("style"):
  3747. for style in dicChildren["style"]:
  3748. parent.AddFlag(style)
  3749.  
  3750. if False == dicChildren.has_key("children"):
  3751. return False
  3752.  
  3753. Index = 0
  3754.  
  3755. ChildrenList = dicChildren["children"]
  3756. parent.Children = range(len(ChildrenList))
  3757. for ElementValue in ChildrenList:
  3758. try:
  3759. Name = ElementValue["name"]
  3760. except KeyError:
  3761. Name = ElementValue["name"] = "NONAME"
  3762.  
  3763. try:
  3764. Type = ElementValue["type"]
  3765. except KeyError:
  3766. Type = ElementValue["type"] = "window"
  3767.  
  3768. if False == self.CheckKeyList(Name, ElementValue, self.DEFAULT_KEY_LIST):
  3769. del parent.Children[Index]
  3770. continue
  3771.  
  3772. if Type == "window":
  3773. parent.Children[Index] = ScriptWindow()
  3774. parent.Children[Index].SetParent(parent)
  3775. self.LoadElementWindow(parent.Children[Index], ElementValue, parent)
  3776.  
  3777. elif Type == "button":
  3778. parent.Children[Index] = Button()
  3779. parent.Children[Index].SetParent(parent)
  3780. self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  3781.  
  3782. elif Type == "radio_button":
  3783. parent.Children[Index] = RadioButton()
  3784. parent.Children[Index].SetParent(parent)
  3785. self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  3786.  
  3787. elif Type == "toggle_button":
  3788. parent.Children[Index] = ToggleButton()
  3789. parent.Children[Index].SetParent(parent)
  3790. self.LoadElementButton(parent.Children[Index], ElementValue, parent)
  3791.  
  3792. elif Type == "mark":
  3793. parent.Children[Index] = MarkBox()
  3794. parent.Children[Index].SetParent(parent)
  3795. self.LoadElementMark(parent.Children[Index], ElementValue, parent)
  3796.  
  3797. elif Type == "image":
  3798. parent.Children[Index] = ImageBox()
  3799. parent.Children[Index].SetParent(parent)
  3800. self.LoadElementImage(parent.Children[Index], ElementValue, parent)
  3801.  
  3802. elif Type == "expanded_image":
  3803. parent.Children[Index] = ExpandedImageBox()
  3804. parent.Children[Index].SetParent(parent)
  3805. self.LoadElementExpandedImage(parent.Children[Index], ElementValue, parent)
  3806.  
  3807. elif Type == "ani_image":
  3808. parent.Children[Index] = AniImageBox()
  3809. parent.Children[Index].SetParent(parent)
  3810. self.LoadElementAniImage(parent.Children[Index], ElementValue, parent)
  3811.  
  3812. elif Type == "slot":
  3813. parent.Children[Index] = SlotWindow()
  3814. parent.Children[Index].SetParent(parent)
  3815. self.LoadElementSlot(parent.Children[Index], ElementValue, parent)
  3816.  
  3817. elif Type == "candidate_list":
  3818. parent.Children[Index] = CandidateListBox()
  3819. parent.Children[Index].SetParent(parent)
  3820. self.LoadElementCandidateList(parent.Children[Index], ElementValue, parent)
  3821.  
  3822. elif Type == "grid_table":
  3823. parent.Children[Index] = GridSlotWindow()
  3824. parent.Children[Index].SetParent(parent)
  3825. self.LoadElementGridTable(parent.Children[Index], ElementValue, parent)
  3826.  
  3827. elif Type == "text":
  3828. parent.Children[Index] = TextLine()
  3829. parent.Children[Index].SetParent(parent)
  3830. self.LoadElementText(parent.Children[Index], ElementValue, parent)
  3831.  
  3832. elif Type == "editline":
  3833. parent.Children[Index] = EditLine()
  3834. parent.Children[Index].SetParent(parent)
  3835. self.LoadElementEditLine(parent.Children[Index], ElementValue, parent)
  3836.  
  3837. elif Type == "titlebar":
  3838. parent.Children[Index] = TitleBar()
  3839. parent.Children[Index].SetParent(parent)
  3840. self.LoadElementTitleBar(parent.Children[Index], ElementValue, parent)
  3841.  
  3842. elif Type == "horizontalbar":
  3843. parent.Children[Index] = HorizontalBar()
  3844. parent.Children[Index].SetParent(parent)
  3845. self.LoadElementHorizontalBar(parent.Children[Index], ElementValue, parent)
  3846.  
  3847. elif Type == "board":
  3848. parent.Children[Index] = Board()
  3849. parent.Children[Index].SetParent(parent)
  3850. self.LoadElementBoard(parent.Children[Index], ElementValue, parent)
  3851.  
  3852. elif Type == "board_with_titlebar":
  3853. parent.Children[Index] = BoardWithTitleBar()
  3854. parent.Children[Index].SetParent(parent)
  3855. self.LoadElementBoardWithTitleBar(parent.Children[Index], ElementValue, parent)
  3856.  
  3857. elif Type == "thinboard":
  3858. parent.Children[Index] = ThinBoard()
  3859. parent.Children[Index].SetParent(parent)
  3860. self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
  3861.  
  3862. elif Type == "thinboard_gold":
  3863. parent.Children[Index] = ThinBoardGold()
  3864. parent.Children[Index].SetParent(parent)
  3865. self.LoadElementThinBoardGold(parent.Children[Index], ElementValue, parent)
  3866.  
  3867. elif Type == "thinboard_circle":
  3868. parent.Children[Index] = ThinBoardCircle()
  3869. parent.Children[Index].SetParent(parent)
  3870. self.LoadElementThinBoardCircle(parent.Children[Index], ElementValue, parent)
  3871.  
  3872. elif Type == "box":
  3873. parent.Children[Index] = Box()
  3874. parent.Children[Index].SetParent(parent)
  3875. self.LoadElementBox(parent.Children[Index], ElementValue, parent)
  3876.  
  3877. elif Type == "bar":
  3878. parent.Children[Index] = Bar()
  3879. parent.Children[Index].SetParent(parent)
  3880. self.LoadElementBar(parent.Children[Index], ElementValue, parent)
  3881.  
  3882. elif Type == "line":
  3883. parent.Children[Index] = Line()
  3884. parent.Children[Index].SetParent(parent)
  3885. self.LoadElementLine(parent.Children[Index], ElementValue, parent)
  3886.  
  3887. elif Type == "slotbar":
  3888. parent.Children[Index] = SlotBar()
  3889. parent.Children[Index].SetParent(parent)
  3890. self.LoadElementSlotBar(parent.Children[Index], ElementValue, parent)
  3891.  
  3892. elif Type == "gauge":
  3893. parent.Children[Index] = Gauge()
  3894. parent.Children[Index].SetParent(parent)
  3895. self.LoadElementGauge(parent.Children[Index], ElementValue, parent)
  3896.  
  3897. elif Type == "scrollbar":
  3898. parent.Children[Index] = ScrollBar()
  3899. parent.Children[Index].SetParent(parent)
  3900. self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  3901.  
  3902. elif Type == "thin_scrollbar":
  3903. parent.Children[Index] = ThinScrollBar()
  3904. parent.Children[Index].SetParent(parent)
  3905. self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  3906.  
  3907. elif Type == "small_thin_scrollbar":
  3908. parent.Children[Index] = SmallThinScrollBar()
  3909. parent.Children[Index].SetParent(parent)
  3910. self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
  3911.  
  3912. elif Type == "sliderbar":
  3913. parent.Children[Index] = SliderBar()
  3914. parent.Children[Index].SetParent(parent)
  3915. self.LoadElementSliderBar(parent.Children[Index], ElementValue, parent)
  3916.  
  3917. elif Type == "listbox":
  3918. parent.Children[Index] = ListBox()
  3919. parent.Children[Index].SetParent(parent)
  3920. self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
  3921.  
  3922. elif Type == "listbox2":
  3923. parent.Children[Index] = ListBox2()
  3924. parent.Children[Index].SetParent(parent)
  3925. self.LoadElementListBox2(parent.Children[Index], ElementValue, parent)
  3926. elif Type == "listboxex":
  3927. parent.Children[Index] = ListBoxEx()
  3928. parent.Children[Index].SetParent(parent)
  3929. self.LoadElementListBoxEx(parent.Children[Index], ElementValue, parent)
  3930.  
  3931. else:
  3932. Index += 1
  3933. continue
  3934.  
  3935. parent.Children[Index].SetWindowName(Name)
  3936. if 0 != self.InsertFunction:
  3937. self.InsertFunction(Name, parent.Children[Index])
  3938.  
  3939. self.LoadChildren(parent.Children[Index], ElementValue)
  3940. Index += 1
  3941.  
  3942. def CheckKeyList(self, name, value, key_list):
  3943.  
  3944. for DataKey in key_list:
  3945. if False == value.has_key(DataKey):
  3946. print "Failed to find data key", "[" + name + "/" + DataKey + "]"
  3947. return False
  3948.  
  3949. return True
  3950.  
  3951. def LoadDefaultData(self, window, value, parentWindow):
  3952. loc_x = int(value["x"])
  3953. loc_y = int(value["y"])
  3954. if value.has_key("vertical_align"):
  3955. if "center" == value["vertical_align"]:
  3956. window.SetWindowVerticalAlignCenter()
  3957. elif "bottom" == value["vertical_align"]:
  3958. window.SetWindowVerticalAlignBottom()
  3959.  
  3960. if parentWindow.IsRTL():
  3961. loc_x = int(value["x"]) + window.GetWidth()
  3962. if value.has_key("horizontal_align"):
  3963. if "center" == value["horizontal_align"]:
  3964. window.SetWindowHorizontalAlignCenter()
  3965. loc_x = - int(value["x"])
  3966. elif "right" == value["horizontal_align"]:
  3967. window.SetWindowHorizontalAlignLeft()
  3968. loc_x = int(value["x"]) - window.GetWidth()
  3969. ## loc_x = parentWindow.GetWidth() - int(value["x"]) + window.GetWidth()
  3970. else:
  3971. window.SetWindowHorizontalAlignRight()
  3972.  
  3973. if value.has_key("all_align"):
  3974. window.SetWindowVerticalAlignCenter()
  3975. window.SetWindowHorizontalAlignCenter()
  3976. loc_x = - int(value["x"])
  3977. else:
  3978. if value.has_key("horizontal_align"):
  3979. if "center" == value["horizontal_align"]:
  3980. window.SetWindowHorizontalAlignCenter()
  3981. elif "right" == value["horizontal_align"]:
  3982. window.SetWindowHorizontalAlignRight()
  3983.  
  3984. window.SetPosition(loc_x, loc_y)
  3985. window.Show()
  3986.  
  3987. ## Window
  3988. def LoadElementWindow(self, window, value, parentWindow):
  3989.  
  3990. if False == self.CheckKeyList(value["name"], value, self.WINDOW_KEY_LIST):
  3991. return False
  3992.  
  3993. window.SetSize(int(value["width"]), int(value["height"]))
  3994. self.LoadDefaultData(window, value, parentWindow)
  3995.  
  3996. return True
  3997.  
  3998. ## Button
  3999. def LoadElementButton(self, window, value, parentWindow):
  4000.  
  4001. if value.has_key("width") and value.has_key("height"):
  4002. window.SetSize(int(value["width"]), int(value["height"]))
  4003.  
  4004. if True == value.has_key("default_image"):
  4005. window.SetUpVisual(value["default_image"])
  4006. if True == value.has_key("over_image"):
  4007. window.SetOverVisual(value["over_image"])
  4008. if True == value.has_key("down_image"):
  4009. window.SetDownVisual(value["down_image"])
  4010. if True == value.has_key("disable_image"):
  4011. window.SetDisableVisual(value["disable_image"])
  4012.  
  4013. if True == value.has_key("text"):
  4014. if True == value.has_key("text_height"):
  4015. window.SetText(value["text"], value["text_height"])
  4016. else:
  4017. window.SetText(value["text"])
  4018.  
  4019. if value.has_key("text_color"):
  4020. window.SetTextColor(value["text_color"])
  4021.  
  4022. if True == value.has_key("tooltip_text"):
  4023. if True == value.has_key("tooltip_x") and True == value.has_key("tooltip_y"):
  4024. window.SetToolTipText(value["tooltip_text"], int(value["tooltip_x"]), int(value["tooltip_y"]))
  4025. else:
  4026. window.SetToolTipText(value["tooltip_text"])
  4027.  
  4028. self.LoadDefaultData(window, value, parentWindow)
  4029.  
  4030. return True
  4031.  
  4032. ## Mark
  4033. def LoadElementMark(self, window, value, parentWindow):
  4034.  
  4035. #if False == self.CheckKeyList(value["name"], value, self.MARK_KEY_LIST):
  4036. # return False
  4037.  
  4038. self.LoadDefaultData(window, value, parentWindow)
  4039.  
  4040. return True
  4041.  
  4042. ## Image
  4043. def LoadElementImage(self, window, value, parentWindow):
  4044.  
  4045. if False == self.CheckKeyList(value["name"], value, self.IMAGE_KEY_LIST):
  4046. return False
  4047.  
  4048. window.LoadImage(value["image"])
  4049. self.LoadDefaultData(window, value, parentWindow)
  4050.  
  4051. return True
  4052.  
  4053. ## AniImage
  4054. def LoadElementAniImage(self, window, value, parentWindow):
  4055.  
  4056. if False == self.CheckKeyList(value["name"], value, self.ANI_IMAGE_KEY_LIST):
  4057. return False
  4058.  
  4059. # Static delay for specific objects
  4060. ANI_IMAGE_NAME_LIST = ('RampageGauge', 'RampageGauge2', 'HPGauge', 'SPGauge', 'STGauge', 'PartyMatchEffect', 'MailBoxEffect')
  4061. ANI_IMAGE_MAX_FPS_DELAY = 13
  4062.  
  4063. if 'delay' in value:
  4064. window.SetDelay(ANI_IMAGE_MAX_FPS_DELAY if value['name'] in ANI_IMAGE_NAME_LIST else value["delay"])
  4065.  
  4066. for image in value["images"]:
  4067. window.AppendImage(image)
  4068.  
  4069. if value.has_key("width") and value.has_key("height"):
  4070. window.SetSize(value["width"], value["height"])
  4071.  
  4072. self.LoadDefaultData(window, value, parentWindow)
  4073.  
  4074. return True
  4075.  
  4076. ## Expanded Image
  4077. def LoadElementExpandedImage(self, window, value, parentWindow):
  4078.  
  4079. if False == self.CheckKeyList(value["name"], value, self.EXPANDED_IMAGE_KEY_LIST):
  4080. return False
  4081.  
  4082. window.LoadImage(value["image"])
  4083.  
  4084. if True == value.has_key("x_origin") and True == value.has_key("y_origin"):
  4085. window.SetOrigin(float(value["x_origin"]), float(value["y_origin"]))
  4086.  
  4087. if True == value.has_key("x_scale") and True == value.has_key("y_scale"):
  4088. window.SetScale(float(value["x_scale"]), float(value["y_scale"]))
  4089.  
  4090. if True == value.has_key("rect"):
  4091. RenderingRect = value["rect"]
  4092. window.SetRenderingRect(RenderingRect[0], RenderingRect[1], RenderingRect[2], RenderingRect[3])
  4093.  
  4094. if True == value.has_key("mode"):
  4095. mode = value["mode"]
  4096. if "MODULATE" == mode:
  4097. window.SetRenderingMode(wndMgr.RENDERING_MODE_MODULATE)
  4098.  
  4099. self.LoadDefaultData(window, value, parentWindow)
  4100.  
  4101. return True
  4102.  
  4103. ## Slot
  4104. def LoadElementSlot(self, window, value, parentWindow):
  4105.  
  4106. if False == self.CheckKeyList(value["name"], value, self.SLOT_KEY_LIST):
  4107. return False
  4108.  
  4109. global_x = int(value["x"])
  4110. global_y = int(value["y"])
  4111. global_width = int(value["width"])
  4112. global_height = int(value["height"])
  4113.  
  4114. window.SetPosition(global_x, global_y)
  4115. window.SetSize(global_width, global_height)
  4116. window.Show()
  4117.  
  4118. r = 1.0
  4119. g = 1.0
  4120. b = 1.0
  4121. a = 1.0
  4122.  
  4123. if True == value.has_key("image_r") and \
  4124. True == value.has_key("image_g") and \
  4125. True == value.has_key("image_b") and \
  4126. True == value.has_key("image_a"):
  4127. r = float(value["image_r"])
  4128. g = float(value["image_g"])
  4129. b = float(value["image_b"])
  4130. a = float(value["image_a"])
  4131.  
  4132. SLOT_ONE_KEY_LIST = ("index", "x", "y", "width", "height")
  4133.  
  4134. for slot in value["slot"]:
  4135. if True == self.CheckKeyList(value["name"] + " - one", slot, SLOT_ONE_KEY_LIST):
  4136. wndMgr.AppendSlot(window.hWnd,
  4137. int(slot["index"]),
  4138. int(slot["x"]),
  4139. int(slot["y"]),
  4140. int(slot["width"]),
  4141. int(slot["height"]))
  4142.  
  4143. if True == value.has_key("image"):
  4144. wndMgr.SetSlotBaseImage(window.hWnd,
  4145. value["image"],
  4146. r, g, b, a)
  4147.  
  4148. return True
  4149.  
  4150. def LoadElementCandidateList(self, window, value, parentWindow):
  4151. if False == self.CheckKeyList(value["name"], value, self.CANDIDATE_LIST_KEY_LIST):
  4152. return False
  4153.  
  4154. window.SetPosition(int(value["x"]), int(value["y"]))
  4155. window.SetItemSize(int(value["item_xsize"]), int(value["item_ysize"]))
  4156. window.SetItemStep(int(value["item_step"]))
  4157. window.Show()
  4158.  
  4159. return True
  4160.  
  4161. ## Table
  4162. def LoadElementGridTable(self, window, value, parentWindow):
  4163.  
  4164. if False == self.CheckKeyList(value["name"], value, self.GRID_TABLE_KEY_LIST):
  4165. return False
  4166.  
  4167. xBlank = 0
  4168. yBlank = 0
  4169. if True == value.has_key("x_blank"):
  4170. xBlank = int(value["x_blank"])
  4171. if True == value.has_key("y_blank"):
  4172. yBlank = int(value["y_blank"])
  4173.  
  4174. if localeInfo.IsARABIC():
  4175. pass
  4176. else:
  4177. window.SetPosition(int(value["x"]), int(value["y"]))
  4178.  
  4179. window.ArrangeSlot( int(value["start_index"]),
  4180. int(value["x_count"]),
  4181. int(value["y_count"]),
  4182. int(value["x_step"]),
  4183. int(value["y_step"]),
  4184. xBlank,
  4185. yBlank)
  4186. if True == value.has_key("image"):
  4187. r = 1.0
  4188. g = 1.0
  4189. b = 1.0
  4190. a = 1.0
  4191. if True == value.has_key("image_r") and \
  4192. True == value.has_key("image_g") and \
  4193. True == value.has_key("image_b") and \
  4194. True == value.has_key("image_a"):
  4195. r = float(value["image_r"])
  4196. g = float(value["image_g"])
  4197. b = float(value["image_b"])
  4198. a = float(value["image_a"])
  4199. wndMgr.SetSlotBaseImage(window.hWnd, value["image"], r, g, b, a)
  4200.  
  4201. if True == value.has_key("style"):
  4202. if "select" == value["style"]:
  4203. wndMgr.SetSlotStyle(window.hWnd, wndMgr.SLOT_STYLE_SELECT)
  4204. if localeInfo.IsARABIC():
  4205. self.LoadDefaultData(window, value, parentWindow)
  4206. else:
  4207. window.Show()
  4208.  
  4209. return True
  4210.  
  4211. ## Text
  4212. def LoadElementText(self, window, value, parentWindow):
  4213.  
  4214. if value.has_key("fontsize"):
  4215. fontSize = value["fontsize"]
  4216.  
  4217. if "LARGE" == fontSize:
  4218. window.SetFontName(localeInfo.UI_DEF_FONT_LARGE)
  4219.  
  4220. elif value.has_key("fontname"):
  4221. fontName = value["fontname"]
  4222. window.SetFontName(fontName)
  4223.  
  4224. if value.has_key("text_horizontal_align"):
  4225. if "left" == value["text_horizontal_align"]:
  4226. window.SetHorizontalAlignLeft()
  4227. elif "center" == value["text_horizontal_align"]:
  4228. window.SetHorizontalAlignCenter()
  4229. elif "right" == value["text_horizontal_align"]:
  4230. window.SetHorizontalAlignRight()
  4231.  
  4232. if value.has_key("text_vertical_align"):
  4233. if "top" == value["text_vertical_align"]:
  4234. window.SetVerticalAlignTop()
  4235. elif "center" == value["text_vertical_align"]:
  4236. window.SetVerticalAlignCenter()
  4237. elif "bottom" == value["text_vertical_align"]:
  4238. window.SetVerticalAlignBottom()
  4239.  
  4240. if value.has_key("all_align"):
  4241. window.SetHorizontalAlignCenter()
  4242. window.SetVerticalAlignCenter()
  4243. window.SetWindowHorizontalAlignCenter()
  4244. window.SetWindowVerticalAlignCenter()
  4245.  
  4246. if value.has_key("r") and value.has_key("g") and value.has_key("b"):
  4247. window.SetFontColor(float(value["r"]), float(value["g"]), float(value["b"]))
  4248. elif value.has_key("color"):
  4249. window.SetPackedFontColor(value["color"])
  4250. else:
  4251. window.SetFontColor(0.8549, 0.8549, 0.8549)
  4252.  
  4253. if value.has_key("outline"):
  4254. if value["outline"]:
  4255. window.SetOutline()
  4256. if True == value.has_key("text"):
  4257. window.SetText(value["text"])
  4258.  
  4259. self.LoadDefaultData(window, value, parentWindow)
  4260.  
  4261. return True
  4262.  
  4263. ## EditLine
  4264. def LoadElementEditLine(self, window, value, parentWindow):
  4265.  
  4266. if False == self.CheckKeyList(value["name"], value, self.EDIT_LINE_KEY_LIST):
  4267. return False
  4268.  
  4269.  
  4270. if value.has_key("secret_flag"):
  4271. window.SetSecret(value["secret_flag"])
  4272. if value.has_key("with_codepage"):
  4273. if value["with_codepage"]:
  4274. window.bCodePage = True
  4275. if value.has_key("only_number"):
  4276. if value["only_number"]:
  4277. window.SetNumberMode()
  4278. if value.has_key("enable_codepage"):
  4279. window.SetIMEFlag(value["enable_codepage"])
  4280. if value.has_key("enable_ime"):
  4281. window.SetIMEFlag(value["enable_ime"])
  4282. if value.has_key("limit_width"):
  4283. window.SetLimitWidth(value["limit_width"])
  4284. if value.has_key("multi_line"):
  4285. if value["multi_line"]:
  4286. window.SetMultiLine()
  4287.  
  4288. window.SetMax(int(value["input_limit"]))
  4289. window.SetSize(int(value["width"]), int(value["height"]))
  4290. self.LoadElementText(window, value, parentWindow)
  4291.  
  4292. return True
  4293.  
  4294. ## TitleBar
  4295. def LoadElementTitleBar(self, window, value, parentWindow):
  4296.  
  4297. if False == self.CheckKeyList(value["name"], value, self.TITLE_BAR_KEY_LIST):
  4298. return False
  4299.  
  4300. window.MakeTitleBar(int(value["width"]), value.get("color", "red"))
  4301. self.LoadDefaultData(window, value, parentWindow)
  4302.  
  4303. return True
  4304.  
  4305. ## HorizontalBar
  4306. def LoadElementHorizontalBar(self, window, value, parentWindow):
  4307.  
  4308. if False == self.CheckKeyList(value["name"], value, self.HORIZONTAL_BAR_KEY_LIST):
  4309. return False
  4310.  
  4311. window.Create(int(value["width"]))
  4312. self.LoadDefaultData(window, value, parentWindow)
  4313.  
  4314. return True
  4315.  
  4316. ## Board
  4317. def LoadElementBoard(self, window, value, parentWindow):
  4318.  
  4319. if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4320. return False
  4321.  
  4322. window.SetSize(int(value["width"]), int(value["height"]))
  4323. self.LoadDefaultData(window, value, parentWindow)
  4324.  
  4325. return True
  4326.  
  4327. ## Board With TitleBar
  4328. def LoadElementBoardWithTitleBar(self, window, value, parentWindow):
  4329.  
  4330. if False == self.CheckKeyList(value["name"], value, self.BOARD_WITH_TITLEBAR_KEY_LIST):
  4331. return False
  4332.  
  4333. window.SetSize(int(value["width"]), int(value["height"]))
  4334. window.SetTitleName(value["title"])
  4335. self.LoadDefaultData(window, value, parentWindow)
  4336.  
  4337. return True
  4338.  
  4339. ## ThinBoard
  4340. def LoadElementThinBoard(self, window, value, parentWindow):
  4341.  
  4342. if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4343. return False
  4344.  
  4345. window.SetSize(int(value["width"]), int(value["height"]))
  4346. self.LoadDefaultData(window, value, parentWindow)
  4347.  
  4348. return True
  4349.  
  4350. ## ThinBoard Gold
  4351. def LoadElementThinBoardGold(self, window, value, parentWindow):
  4352.  
  4353. if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4354. return False
  4355.  
  4356. window.SetSize(int(value["width"]), int(value["height"]))
  4357. self.LoadDefaultData(window, value, parentWindow)
  4358.  
  4359. return True
  4360.  
  4361. def LoadElementThinBoardCircle(self, window, value, parentWindow):
  4362.  
  4363. if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  4364. return False
  4365.  
  4366. window.SetSize(int(value["width"]), int(value["height"]))
  4367. self.LoadDefaultData(window, value, parentWindow)
  4368.  
  4369. return True
  4370.  
  4371. ## Box
  4372. def LoadElementBox(self, window, value, parentWindow):
  4373.  
  4374. if False == self.CheckKeyList(value["name"], value, self.BOX_KEY_LIST):
  4375. return False
  4376.  
  4377. if True == value.has_key("color"):
  4378. window.SetColor(value["color"])
  4379.  
  4380. window.SetSize(int(value["width"]), int(value["height"]))
  4381. self.LoadDefaultData(window, value, parentWindow)
  4382.  
  4383. return True
  4384.  
  4385. ## Bar
  4386. def LoadElementBar(self, window, value, parentWindow):
  4387.  
  4388. if False == self.CheckKeyList(value["name"], value, self.BAR_KEY_LIST):
  4389. return False
  4390.  
  4391. if True == value.has_key("color"):
  4392. window.SetColor(value["color"])
  4393.  
  4394. window.SetSize(int(value["width"]), int(value["height"]))
  4395. self.LoadDefaultData(window, value, parentWindow)
  4396.  
  4397. return True
  4398.  
  4399. ## Line
  4400. def LoadElementLine(self, window, value, parentWindow):
  4401.  
  4402. if False == self.CheckKeyList(value["name"], value, self.LINE_KEY_LIST):
  4403. return False
  4404.  
  4405. if True == value.has_key("color"):
  4406. window.SetColor(value["color"])
  4407.  
  4408. window.SetSize(int(value["width"]), int(value["height"]))
  4409. self.LoadDefaultData(window, value, parentWindow)
  4410.  
  4411. return True
  4412.  
  4413. ## Slot
  4414. def LoadElementSlotBar(self, window, value, parentWindow):
  4415.  
  4416. if False == self.CheckKeyList(value["name"], value, self.SLOTBAR_KEY_LIST):
  4417. return False
  4418.  
  4419. window.SetSize(int(value["width"]), int(value["height"]))
  4420. self.LoadDefaultData(window, value, parentWindow)
  4421.  
  4422. return True
  4423.  
  4424. ## Gauge
  4425. def LoadElementGauge(self, window, value, parentWindow):
  4426.  
  4427. if False == self.CheckKeyList(value["name"], value, self.GAUGE_KEY_LIST):
  4428. return False
  4429.  
  4430. window.MakeGauge(value["width"], value["color"])
  4431. self.LoadDefaultData(window, value, parentWindow)
  4432.  
  4433. return True
  4434.  
  4435. ## ScrollBar
  4436. def LoadElementScrollBar(self, window, value, parentWindow):
  4437.  
  4438. if False == self.CheckKeyList(value["name"], value, self.SCROLLBAR_KEY_LIST):
  4439. return False
  4440.  
  4441. window.SetScrollBarSize(value["size"])
  4442. self.LoadDefaultData(window, value, parentWindow)
  4443.  
  4444. return True
  4445.  
  4446. ## SliderBar
  4447. def LoadElementSliderBar(self, window, value, parentWindow):
  4448.  
  4449. self.LoadDefaultData(window, value, parentWindow)
  4450.  
  4451. return True
  4452.  
  4453. ## ListBox
  4454. def LoadElementListBox(self, window, value, parentWindow):
  4455.  
  4456. if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  4457. return False
  4458.  
  4459. if value.has_key("item_align"):
  4460. window.SetTextCenterAlign(value["item_align"])
  4461.  
  4462. window.SetSize(value["width"], value["height"])
  4463. self.LoadDefaultData(window, value, parentWindow)
  4464.  
  4465. return True
  4466.  
  4467. ## ListBox2
  4468. def LoadElementListBox2(self, window, value, parentWindow):
  4469.  
  4470. if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  4471. return False
  4472.  
  4473. window.SetRowCount(value.get("row_count", 10))
  4474. window.SetSize(value["width"], value["height"])
  4475. self.LoadDefaultData(window, value, parentWindow)
  4476.  
  4477. if value.has_key("item_align"):
  4478. window.SetTextCenterAlign(value["item_align"])
  4479.  
  4480. return True
  4481. def LoadElementListBoxEx(self, window, value, parentWindow):
  4482.  
  4483. if False == self.CheckKeyList(value["name"], value, self.LIST_BOX_KEY_LIST):
  4484. return False
  4485.  
  4486. window.SetSize(value["width"], value["height"])
  4487. self.LoadDefaultData(window, value, parentWindow)
  4488.  
  4489. if value.has_key("itemsize_x") and value.has_key("itemsize_y"):
  4490. window.SetItemSize(int(value["itemsize_x"]), int(value["itemsize_y"]))
  4491.  
  4492. if value.has_key("itemstep"):
  4493. window.SetItemStep(int(value["itemstep"]))
  4494.  
  4495. if value.has_key("viewcount"):
  4496. window.SetViewItemCount(int(value["viewcount"]))
  4497.  
  4498. return True
  4499.  
  4500. class ReadingWnd(Bar):
  4501.  
  4502. def __init__(self):
  4503. Bar.__init__(self,"TOP_MOST")
  4504.  
  4505. self.__BuildText()
  4506. self.SetSize(80, 19)
  4507. self.Show()
  4508.  
  4509. def __del__(self):
  4510. Bar.__del__(self)
  4511.  
  4512. def __BuildText(self):
  4513. self.text = TextLine()
  4514. self.text.SetParent(self)
  4515. self.text.SetPosition(4, 3)
  4516. self.text.Show()
  4517.  
  4518. def SetText(self, text):
  4519. self.text.SetText(text)
  4520.  
  4521. def SetReadingPosition(self, x, y):
  4522. xPos = x + 2
  4523. yPos = y - self.GetHeight() - 2
  4524. self.SetPosition(xPos, yPos)
  4525.  
  4526. def SetTextColor(self, color):
  4527. self.text.SetPackedFontColor(color)
  4528.  
  4529.  
  4530. def MakeSlotBar(parent, x, y, width, height):
  4531. slotBar = SlotBar()
  4532. slotBar.SetParent(parent)
  4533. slotBar.SetSize(width, height)
  4534. slotBar.SetPosition(x, y)
  4535. slotBar.Show()
  4536. return slotBar
  4537.  
  4538. def MakeImageBox(parent, name, x, y):
  4539. image = ImageBox()
  4540. image.SetParent(parent)
  4541. image.LoadImage(name)
  4542. image.SetPosition(x, y)
  4543. image.Show()
  4544. return image
  4545.  
  4546. def MakeTextLine(parent):
  4547. textLine = TextLine()
  4548. textLine.SetParent(parent)
  4549. textLine.SetWindowHorizontalAlignCenter()
  4550. textLine.SetWindowVerticalAlignCenter()
  4551. textLine.SetHorizontalAlignCenter()
  4552. textLine.SetVerticalAlignCenter()
  4553. textLine.Show()
  4554. return textLine
  4555.  
  4556. def MakeButton(parent, x, y, tooltipText, path, up, over, down):
  4557. button = Button()
  4558. button.SetParent(parent)
  4559. button.SetPosition(x, y)
  4560. button.SetUpVisual(path + up)
  4561. button.SetOverVisual(path + over)
  4562. button.SetDownVisual(path + down)
  4563. button.SetToolTipText(tooltipText)
  4564. button.Show()
  4565. return button
  4566.  
  4567. def RenderRoundBox(x, y, width, height, color):
  4568. grp.SetColor(color)
  4569. grp.RenderLine(x+2, y, width-3, 0)
  4570. grp.RenderLine(x+2, y+height, width-3, 0)
  4571. grp.RenderLine(x, y+2, 0, height-4)
  4572. grp.RenderLine(x+width, y+1, 0, height-3)
  4573. grp.RenderLine(x, y+2, 2, -2)
  4574. grp.RenderLine(x, y+height-2, 2, 2)
  4575. grp.RenderLine(x+width-2, y, 2, 2)
  4576. grp.RenderLine(x+width-2, y+height, 2, -2)
  4577.  
  4578. def GenerateColor(r, g, b):
  4579. r = float(r) / 255.0
  4580. g = float(g) / 255.0
  4581. b = float(b) / 255.0
  4582. return grp.GenerateColor(r, g, b, 1.0)
  4583.  
  4584. def EnablePaste(flag):
  4585. ime.EnablePaste(flag)
  4586.  
  4587. def GetHyperlink():
  4588. return wndMgr.GetHyperlink()
  4589.  
  4590. def MakeText(parent, textlineText, x, y, color):
  4591. textline = TextLine()
  4592. if parent != None:
  4593. textline.SetParent(parent)
  4594. textline.SetPosition(x, y)
  4595. if color != None:
  4596. textline.SetFontColor(color[0], color[1], color[2])
  4597. textline.SetText(textlineText)
  4598. textline.Show()
  4599. return textline
  4600. def MakeThinBoard(parent, x, y, width, heigh, moveable=FALSE,center=FALSE):
  4601. thin = ThinBoard()
  4602. if parent != None:
  4603. thin.SetParent(parent)
  4604. if moveable == TRUE:
  4605. thin.AddFlag('movable')
  4606. thin.AddFlag('float')
  4607. thin.SetSize(width, heigh)
  4608. thin.SetPosition(x, y)
  4609. if center == TRUE:
  4610. thin.SetCenterPosition()
  4611. thin.Show()
  4612. return thin
  4613.  
  4614. RegisterToolTipWindow("TEXT", TextLine)
  4615.  
  4616. class CheckBox(Window):
  4617. def __init__(self):
  4618. Window.__init__(self)
  4619.  
  4620. self.backgroundImage = None
  4621. self.checkImage = None
  4622.  
  4623. self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
  4624. self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
  4625.  
  4626. self.CreateElements()
  4627.  
  4628. def __del__(self):
  4629. Window.__del__(self)
  4630.  
  4631. self.backgroundImage = None
  4632. self.checkImage = None
  4633.  
  4634. self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
  4635. self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }
  4636.  
  4637. def CreateElements(self):
  4638. self.backgroundImage = ImageBox()
  4639. self.backgroundImage.SetParent(self)
  4640. self.backgroundImage.AddFlag("not_pick")
  4641. self.backgroundImage.LoadImage("d:/ymir work/ui/game/refine/checkbox.tga")
  4642. self.backgroundImage.Show()
  4643.  
  4644. self.checkImage = ImageBox()
  4645. self.checkImage.SetParent(self)
  4646. self.checkImage.AddFlag("not_pick")
  4647. self.checkImage.SetPosition(0, -4)
  4648. self.checkImage.LoadImage("d:/ymir work/ui/game/refine/checked.tga")
  4649. self.checkImage.Hide()
  4650.  
  4651. self.textInfo = TextLine()
  4652. self.textInfo.SetParent(self)
  4653. self.textInfo.SetPosition(20, -2)
  4654. self.textInfo.Show()
  4655.  
  4656. self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])
  4657.  
  4658. def SetTextInfo(self, info):
  4659. if self.textInfo:
  4660. self.textInfo.SetText(info)
  4661.  
  4662. self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])
  4663.  
  4664. def SetCheckStatus(self, flag):
  4665. if flag:
  4666. self.checkImage.Show()
  4667. else:
  4668. self.checkImage.Hide()
  4669.  
  4670. def GetCheckStatus(self):
  4671. if self.checkImage:
  4672. return self.checkImage.IsShow()
  4673.  
  4674. return False
  4675.  
  4676. def SetEvent(self, func, *args) :
  4677. result = self.eventFunc.has_key(args[0])
  4678. if result :
  4679. self.eventFunc[args[0]] = func
  4680. self.eventArgs[args[0]] = args
  4681. else :
  4682. print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
  4683.  
  4684. def OnMouseLeftButtonUp(self):
  4685. if self.checkImage:
  4686. if self.checkImage.IsShow():
  4687. self.checkImage.Hide()
  4688.  
  4689. if self.eventFunc["ON_UNCKECK"]:
  4690. apply(self.eventFunc["ON_UNCKECK"], self.eventArgs["ON_UNCKECK"])
  4691. else:
  4692. self.checkImage.Show()
  4693.  
  4694. if self.eventFunc["ON_CHECK"]:
  4695. apply(self.eventFunc["ON_CHECK"], self.eventArgs["ON_CHECK"])
  4696.  
Add Comment
Please, Sign In to add comment