Advertisement
Guest User

loading_tips

a guest
Jan 28th, 2020
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. """
  2. root/introloading.py
  3. """
  4. ## Search:
  5. self.loadingGage=self.GetChild("FullGage")
  6.  
  7. ## Add:
  8. self.loadingTip=self.GetChild("LoadingTip")
  9.  
  10. ## Search:
  11. width = float(wndMgr.GetScreenWidth()) / float(self.loadingImage.GetWidth())
  12.  
  13. ## Before add:
  14.  
  15. tipTexts = pack_open(uiScriptLocale.tipList, "r").readlines()
  16. tipID = app.GetRandom(1,len(tipTexts))
  17. for i in xrange(len(tipTexts)):
  18. lines = str(tipTexts[i])
  19. if lines == "\n" or lines == "":
  20. continue
  21. tokens = lines.split("\t")
  22. tipID_inFile, tipText_inFile = int(tokens[0]), str(tokens[1])
  23. if tipID == tipID_inFile:
  24. self.loadingTip.SetText(tipText_inFile)
  25.  
  26. """
  27. root/uiscriptlocale.py
  28. """
  29. ## Search:
  30. LoadLocaleFile(LOCALE_INTERFACE_FILE_NAME, locals())
  31.  
  32. ## Add:
  33. tipList = "%s/loading_tips.txt" % (name)
  34.  
  35. """
  36. root/ui.py
  37. """
  38. ## Search:
  39. class ThinBoard(Window):
  40.  
  41. ## Before add:
  42. class MiddleBoard(Window):
  43. CORNER_WIDTH = 16
  44. CORNER_HEIGHT = 16
  45. LINE_WIDTH = 16
  46. LINE_HEIGHT = 16
  47. BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.51)
  48.  
  49. LT = 0
  50. LB = 1
  51. RT = 2
  52. RB = 3
  53. L = 0
  54. R = 1
  55. T = 2
  56. B = 3
  57.  
  58. def __init__(self, layer = "UI"):
  59. Window.__init__(self, layer)
  60.  
  61. CornerFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Corner_"+dir+".tga" for dir in ["LeftTop","LeftBottom","RightTop","RightBottom"] ]
  62. LineFileNames = [ "d:/ymir work/ui/pattern/ThinBoard_Line_"+dir+".tga" for dir in ["Left","Right","Top","Bottom"] ]
  63.  
  64. self.Corners = []
  65. for fileName in CornerFileNames:
  66. Corner = ExpandedImageBox()
  67. Corner.AddFlag("attach")
  68. Corner.AddFlag("not_pick")
  69. Corner.LoadImage(fileName)
  70. Corner.SetParent(self)
  71. Corner.SetPosition(0, 0)
  72. Corner.Show()
  73. self.Corners.append(Corner)
  74.  
  75. self.Lines = []
  76. for fileName in LineFileNames:
  77. Line = ExpandedImageBox()
  78. Line.AddFlag("attach")
  79. Line.AddFlag("not_pick")
  80. Line.LoadImage(fileName)
  81. Line.SetParent(self)
  82. Line.SetPosition(0, 0)
  83. Line.Show()
  84. self.Lines.append(Line)
  85.  
  86. Base = Bar()
  87. Base.SetParent(self)
  88. Base.AddFlag("attach")
  89. Base.AddFlag("not_pick")
  90. Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
  91. Base.SetColor(self.BOARD_COLOR)
  92. Base.Show()
  93. self.Base = Base
  94.  
  95. self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
  96. self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
  97.  
  98. def __del__(self):
  99. Window.__del__(self)
  100.  
  101. def SetSize(self, width, height):
  102.  
  103. width = max(self.CORNER_WIDTH*2, width)
  104. height = max(self.CORNER_HEIGHT*2, height)
  105. Window.SetSize(self, width, height)
  106.  
  107. self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
  108. self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
  109. self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
  110. self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
  111. self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
  112.  
  113. verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
  114. horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
  115. self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  116. self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
  117. self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  118. self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
  119. self.Base.SetSize(width - self.CORNER_WIDTH*2, height - self.CORNER_HEIGHT*2)
  120.  
  121. def ShowInternal(self):
  122. self.Base.Show()
  123. for wnd in self.Lines:
  124. wnd.Show()
  125. for wnd in self.Corners:
  126. wnd.Show()
  127.  
  128. def HideInternal(self):
  129. self.Base.Hide()
  130. for wnd in self.Lines:
  131. wnd.Hide()
  132. for wnd in self.Corners:
  133. wnd.Hide()
  134.  
  135. ## Search:
  136.  
  137. elif Type == "thinboard":
  138. parent.Children[Index] = ThinBoard()
  139. parent.Children[Index].SetParent(parent)
  140. self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
  141.  
  142. ## Before add:
  143.  
  144. elif Type == "middleboard":
  145. parent.Children[Index] = MiddleBoard()
  146. parent.Children[Index].SetParent(parent)
  147. self.LoadElementMiddleBoard(parent.Children[Index], ElementValue, parent)
  148.  
  149. ## Search:
  150. ## ThinBoard
  151. def LoadElementThinBoard(self, window, value, parentWindow):
  152.  
  153. ## Before add:
  154.  
  155. ## MiddleBoard
  156. def LoadElementMiddleBoard(self, window, value, parentWindow):
  157.  
  158. if FALSE == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
  159. return FALSE
  160.  
  161. window.SetSize(int(value["width"]), int(value["height"]))
  162. self.LoadDefaultData(window, value, parentWindow)
  163.  
  164. return True
  165.  
  166. """
  167. locale/xx/ui/loadingwindow.py
  168. """
  169. ## Search:
  170. ## Board
  171. {
  172. "name" : "BackGround",
  173. "type" : "expanded_image",
  174.  
  175. "x" : 0,
  176. "y" : 0,
  177.  
  178. "image" : "d:/ymir work/ui/intro/pattern/Line_Pattern.tga",
  179.  
  180. "x_scale" : float(SCREEN_WIDTH) / 800.0,
  181. "y_scale" : float(SCREEN_HEIGHT) / 600.0,
  182. },
  183.  
  184. ## Before add:
  185. {
  186. "name" : "TipBackground",
  187. "type" : "middleboard",
  188.  
  189. "x" : 0,
  190. "y" : float(SCREEN_HEIGHT) * 500 / 600.0 - 100,
  191.  
  192. "width" : SCREEN_WIDTH,
  193. "height" : 100,
  194.  
  195. "children" :
  196. (
  197. {
  198. "name" : "LoadingTip",
  199. "type" : "text",
  200.  
  201. "x" : float(SCREEN_WIDTH) / 2,
  202. "y" : 40,
  203.  
  204. "fontsize" : "LARGE",
  205. "text_horizontal_align" : "center",
  206. },
  207. ),
  208. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement