示例#1
0
	def drawBoxRelative(self, left, bottom, width, height, color):
		left,  bottom = self.relativeCoords(left,  bottom)
		width, height = width * self.scale, height * self.scale
		right, top    = left + int(width - 1), bottom - int(height - 1)
		points = self.boxToVector(left, top, right, bottom)
		borderColor = changeAlpha(color, 0xFF)
		innerColor = changeAlpha(color, 0x40)
		
		if self.drawFilling:
			self.drawFill(left, top, right, bottom, innerColor)
		if self.drawBorders:
			self.drawBoxBorders(left, top, right, bottom, borderColor)
示例#2
0
    def drawBoxRelative(self, left, bottom, width, height, color):
        left, bottom = self.relativeCoords(left, bottom)
        width, height = width * self.scale, height * self.scale
        right, top = left + int(width - 1), bottom - int(height - 1)
        points = self.boxToVector(left, top, right, bottom)
        borderColor = changeAlpha(color, 0xFF)
        innerColor = changeAlpha(color, 0x40)

        if self.drawFilling:
            self.drawFill(left, top, right, bottom, innerColor)
        if self.drawBorders:
            self.drawBoxBorders(left, top, right, bottom, borderColor)
示例#3
0
	def annotateBox(self, left, bottom, right, top, ID, offset, color):
		relLeft,  relBottom = self.relativeCoords(left,  bottom)
		relRight, relTop    = self.relativeCoords(right, top   )

		coordPair = "(%+0.2f, %+0.2f)"
		coordsFormat = coordPair + "-" + coordPair
		coords = coordsFormat % (left, bottom, right, top)
		flagsStr = "0x%02X" % ID
		result = coords + "; " + flagsStr
		textColor = changeAlpha(color, 255)
		xPosition = relLeft # annotation starts flush with box's left side
		yPosition = relBottom + offset # annotation below box
		#yPosition = relTop - offset # annotation above box
		self.drawText(xPosition, yPosition, 500, 500, textColor, result)
示例#4
0
	def __init__(self, environment, tickerInterval=2):
		self.env = environment
		self.config = self.env.config
		self.process = self.env.process
		self.gameState = self.env.gameState
		self.camera = self.gameState.camera
		self.p1 = self.gameState.p1
		self.p2 = self.gameState.p2
		self.windowsMessage = MSG()

		# TODO: move this BS to config file soon
		self.annotations = argvContains("-annotate")
		self.drawFilling = argvContains("-usefill")
		self.drawBorders = not argvContains("-noborders")
		self.drawPivots  = not argvContains("-nopivots")
		self.syncedMode  = not argvContains("-nosync")
		self.drawTicker  = argvContains("-counter")
		if argvContains("-thicklines"):
			self.lineThickness = 3
		else:
			self.lineThickness = 1
		# control list used in for loops when drawing thick lines
		# (so we aren't creating new list objects all day)
		self.thicknessRange = range(0, self.lineThickness)
		
		# Direct3D created objects
		self.hwnd = None
		self.wndClass = None
		self.d3d = None
		self.device = POINTER(IDirect3DDevice9)()
		self.line = POINTER(ID3DXLine)()
		self.font = POINTER(ID3DXFont)()
		self.fillbuf = None
		self.spareFillbuf = (CUSTOMVERTEX * 4)()

		# reusable resources for drawing primitives
		self.boxvec = (D3DXVECTOR2 * 5)()
		self.linevec = (D3DXVECTOR2 * 2)()
		
		self.left = 0
		self.top = 0
		self.right = 0
		self.bottom = 0
		self.width = 0
		self.height = 0
		self.centerX = 0
		self.centerY = 0
		self.scale = 1.0 # scale factor applied to box coordinates before draw
		self.baseY = 0 # base position onscreen where Y = 0 (i.e., the ground)

		# controls how frequently to check for window movement/resize
		self.updateWindowTickerInterval = tickerInterval
		self.updateWindowTicker = tickerInterval # count down, reset at 0
		
		# frame ticker at the bottom of the screen
		self.frameTicker = 0
		self.frameTickerLimit = 600
		tickerHalfFormat = "%0" + str(digitsIn(self.frameTickerLimit)) + "d"
		self.tickerFormat = tickerHalfFormat + "/" + tickerHalfFormat
		self.tickerWidth = len(self.tickerFormat % (0, 0)) * 10
		self.tickerHeight = 20
		self.tickerTextColor = colorByName("white")
		self.tickerFillColor = changeAlpha(colorByName("black"), 0xB0)
		# set by self.positionTicker()
		self.tickerX = 0
		self.tickerY = 0

		self.boxColors = {1: {}, 2 : {}}
		self.fillBoxColors()
示例#5
0
    def __init__(self, environment, tickerInterval=2):
        self.env = environment
        self.config = self.env.config
        self.process = self.env.process
        self.gameState = self.env.gameState
        self.camera = self.gameState.camera
        self.p1 = self.gameState.p1
        self.p2 = self.gameState.p2
        self.windowsMessage = MSG()

        # TODO: move this BS to config file soon
        self.annotations = argvContains("-annotate")
        self.drawFilling = argvContains("-usefill")
        self.drawBorders = not argvContains("-noborders")
        self.drawPivots = not argvContains("-nopivots")
        self.syncedMode = not argvContains("-nosync")
        self.drawTicker = argvContains("-counter")
        if argvContains("-thicklines"):
            self.lineThickness = 3
        else:
            self.lineThickness = 1
        # control list used in for loops when drawing thick lines
        # (so we aren't creating new list objects all day)
        self.thicknessRange = range(0, self.lineThickness)

        # Direct3D created objects
        self.hwnd = None
        self.wndClass = None
        self.d3d = None
        self.device = POINTER(IDirect3DDevice9)()
        self.line = POINTER(ID3DXLine)()
        self.font = POINTER(ID3DXFont)()
        self.fillbuf = None
        self.spareFillbuf = (CUSTOMVERTEX * 4)()

        # reusable resources for drawing primitives
        self.boxvec = (D3DXVECTOR2 * 5)()
        self.linevec = (D3DXVECTOR2 * 2)()

        self.left = 0
        self.top = 0
        self.right = 0
        self.bottom = 0
        self.width = 0
        self.height = 0
        self.centerX = 0
        self.centerY = 0
        self.scale = 1.0  # scale factor applied to box coordinates before draw
        self.baseY = 0  # base position onscreen where Y = 0 (i.e., the ground)

        # controls how frequently to check for window movement/resize
        self.updateWindowTickerInterval = tickerInterval
        self.updateWindowTicker = tickerInterval  # count down, reset at 0

        # frame ticker at the bottom of the screen
        self.frameTicker = 0
        self.frameTickerLimit = 600
        tickerHalfFormat = "%0" + str(digitsIn(self.frameTickerLimit)) + "d"
        self.tickerFormat = tickerHalfFormat + "/" + tickerHalfFormat
        self.tickerWidth = len(self.tickerFormat % (0, 0)) * 10
        self.tickerHeight = 20
        self.tickerTextColor = colorByName("white")
        self.tickerFillColor = changeAlpha(colorByName("black"), 0xB0)
        # set by self.positionTicker()
        self.tickerX = 0
        self.tickerY = 0

        self.boxColors = {1: {}, 2: {}}
        self.fillBoxColors()