thanato1994

Untitled

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