Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Board(Window):
- CORNER_WIDTH = 55
- CORNER_HEIGHT = 55
- LINE_WIDTH = 128
- LINE_HEIGHT = 128
- D = 0
- LT = 0
- LB = 1
- RT = 2
- RB = 3
- L = 0
- R = 1
- T = 2
- B = 3
- def __init__(self):
- Window.__init__(self)
- self.MakeBoard("kanort_work/images/controls/common/board/corner_", "kanort_work/images/controls/common/board/bar_", "kanort_work/images/controls/common/board/decoration_")
- self.MakeBase()
- def MakeBoard(self, cornerPath, linePath, decorPath):
- CornerFileNames = [ cornerPath+dir+".tga" for dir in ("lefttop", "leftbottom", "righttop", "rightbottom", ) ]
- LineFileNames = [ linePath+dir+".tga" for dir in ("left", "right", "top", "bottom", ) ]
- DecorFileNames = [ decorPath+dir+".tga" for dir in ("leftbottom", ) ]
- self.Corners = []
- for fileName in CornerFileNames:
- Corner = ExpandedImageBox()
- Corner.AddFlag("not_pick")
- Corner.LoadImage(fileName)
- Corner.SetParent(self)
- Corner.SetPosition(0, 0)
- Corner.Show()
- self.Corners.append(Corner)
- self.Lines = []
- for fileName in LineFileNames:
- Line = ExpandedImageBox()
- Line.AddFlag("not_pick")
- Line.LoadImage(fileName)
- Line.SetParent(self)
- Line.SetPosition(0, 0)
- Line.Show()
- self.Lines.append(Line)
- self.Decor = []
- for fileName in DecorFileNames:
- Decor = ExpandedImageBox()
- Decor.AddFlag("not_pick")
- Decor.LoadImage(fileName)
- Decor.SetParent(self)
- Decor.SetPosition(0, 0)
- Decor.Show()
- self.Decor.append(Decor)
- self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
- self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)
- def MakeBase(self):
- self.Base = ExpandedImageBox()
- self.Base.AddFlag("not_pick")
- self.Base.LoadImage("kanort_work/images/controls/common/board/fill.tga")
- self.Base.SetParent(self)
- self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
- self.Base.Show()
- def __del__(self):
- Window.__del__(self)
- def SetSize(self, width, height):
- width = max(self.CORNER_WIDTH*2, width)
- height = max(self.CORNER_HEIGHT*2, height)
- Window.SetSize(self, width, height)
- self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
- self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
- self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
- self.Decor[self.D].SetPosition(0 - 5, height - self.CORNER_HEIGHT)
- self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
- self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)
- verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
- horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
- self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
- self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
- if self.Base:
- self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)
Advertisement
Add Comment
Please, Sign In to add comment