Advertisement
Guest User

Untitled

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