Advertisement
Guest User

ui

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