Guest User

ui.py

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