def compileMapSquareList(self, sq): if sq.guiData.has_key("listID"): glDeleteLists(sq.guiData["listID"], 1) textureNames = sq.texture() texIDt = Resources.texture(textureNames[0]) sq.guiData['textureID'] = texIDt #fix me: update with the new amount of textures. texIDl = Resources.texture(textureNames[1]) texIDb = Resources.texture(textureNames[2]) texIDr = Resources.texture(textureNames[3]) texIDf = Resources.texture(textureNames[4]) textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf] listID = glGenLists(1) sq.guiData["listID"] = listID glNewList(listID, GL_COMPILE) GLUtil.makeCube(sq.z, sq.cornerHeights, textureIDs, sq.cornerColors, sq.waterHeight, sq.waterColor, sq.minHeight()) #glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) #glLineWidth(0.75) #GLUtil.makeCube(sq.z, (0.0,0.0,0.0,1.0), sq.cornerHeights, False) #glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) glEndList() topListID = glGenLists(1) sq.guiData['topListID'] = topListID glNewList(topListID, GL_COMPILE) GLUtil.makeCubeTop(sq.z, sq.cornerHeights) glEndList()
def compileMapSquareList(self, sq): if sq.guiData.has_key("listID"): glDeleteLists(sq.guiData["listID"], 1) textureNames = sq.texture() texIDt = Resources.texture(textureNames[0]) sq.guiData["textureID"] = texIDt # FIXME: update with the new amount of textures. texIDl = Resources.texture(textureNames[1]) texIDb = Resources.texture(textureNames[2]) texIDr = Resources.texture(textureNames[3]) texIDf = Resources.texture(textureNames[4]) textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf] listID = glGenLists(1) sq.guiData["listID"] = listID glNewList(listID, GL_COMPILE) GLUtil.makeCube( sq.z, sq.cornerHeights, textureIDs, sq.cornerColors, sq.waterHeight, sq.waterColor, sq.minHeight() ) glEndList() topListID = glGenLists(1) sq.guiData["topListID"] = topListID glNewList(topListID, GL_COMPILE) GLUtil.makeCubeTop(sq.z, sq.cornerHeights) glEndList()
def compileMapSquareList(self, sq): if sq.guiData.has_key("listID"): glDeleteLists(sq.guiData["listID"], 1) textureNames = sq.texture() texIDt = Resources.texture(textureNames[0]) sq.guiData[ 'textureID'] = texIDt #fix me: update with the new amount of textures. texIDl = Resources.texture(textureNames[1]) texIDb = Resources.texture(textureNames[2]) texIDr = Resources.texture(textureNames[3]) texIDf = Resources.texture(textureNames[4]) textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf] listID = glGenLists(1) sq.guiData["listID"] = listID glNewList(listID, GL_COMPILE) GLUtil.makeCube(sq.z, sq.cornerHeights, textureIDs, sq.cornerColors, sq.waterHeight, sq.waterColor, sq.minHeight()) #glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) #glLineWidth(0.75) #GLUtil.makeCube(sq.z, (0.0,0.0,0.0,1.0), sq.cornerHeights, False) #glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) glEndList() topListID = glGenLists(1) sq.guiData['topListID'] = topListID glNewList(topListID, GL_COMPILE) GLUtil.makeCubeTop(sq.z, sq.cornerHeights) glEndList()
def compileMapSquareList(self, sq): if sq.guiData.has_key("listID"): glDeleteLists(sq.guiData["listID"], 1) textureNames = sq.texture() texIDt = Resources.texture(textureNames[0]) sq.guiData['textureID'] = texIDt # FIXME: update with the new amount of textures. texIDl = Resources.texture(textureNames[1]) texIDb = Resources.texture(textureNames[2]) texIDr = Resources.texture(textureNames[3]) texIDf = Resources.texture(textureNames[4]) textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf] listID = glGenLists(1) sq.guiData["listID"] = listID glNewList(listID, GL_COMPILE) GLUtil.makeCube(sq.z, sq.cornerHeights, textureIDs, sq.cornerColors, sq.waterHeight, sq.waterColor, sq.minHeight()) glEndList() topListID = glGenLists(1) sq.guiData['topListID'] = topListID glNewList(topListID, GL_COMPILE) GLUtil.makeCubeTop(sq.z, sq.cornerHeights) glEndList()
def draw(self): glDisable(GL_LIGHTING) glPushMatrix() GLUtil.mapTrans(self.x, self.y, 0.0) glColor4f(0.0, 0.0, 0.75, GUI.get().highlightAlpha()) GLUtil.makeCubeTop(self.mapSquare().z, self.mapSquare().cornerHeights) glPopMatrix() glEnable(GL_LIGHTING)
def draw(self, width, posn): rightR = (self._rightColor[0] * width - self._leftColor[0] * (1.0 - width)) rightG = (self._rightColor[1] * width - self._leftColor[1] * (1.0 - width)) rightB = (self._rightColor[2] * width - self._leftColor[2] * (1.0 - width)) GLUtil.drawBar(self._leftColor, [rightR, rightG, rightB, 1.0], self._width * width, self._height, posn)
def draw(self, width, posn): rightR = (self._rightColor[0] * width - self._leftColor[0] * (1.0 - width)) rightG = (self._rightColor[1] * width - self._leftColor[1] * (1.0 - width)) rightB = (self._rightColor[2] * width - self._leftColor[2] * (1.0 - width)) GLUtil.drawBar(self._leftColor, [rightR, rightG, rightB, 1.0], self._width*width, self._height, posn)
def draw(self): if self._showing and len(self.options) > 0: glDisable(GL_LIGHTING) self.box.draw() cursorX, cursorY = self.posn cursorX += 12 cursorY += 12 + 20 * self.selectedOption GLUtil.drawAt((cursorX, cursorY), self.cursorTexture, self.cursorImage) glEnable(GL_LIGHTING)
def draw(self): height = 0.5 + 1.0 * self._time if self._time < 0.0: alpha = 0.0 elif self._time < 0.25: alpha = 4.0 * self._time elif self._time > 0.75: alpha = 1.0 - 4.0 * (self._time - 0.75) else: alpha = 1.0 GLUtil.drawFloatingText(self._texture, self._aspectRatio, height, alpha)
def __init__(self, posn, width, nOptions): self.displayers = [] self.options = [] self.enabledOptions = [] self.posn = posn for i in xrange(nOptions): td = TextDisplayer() td.setText("") td.setFont(Resources.font(size=16, bold=True)) self.displayers.append(td) self.box = TextDisplayerBox(self.displayers, posn, width, nOptions) self.selectedOption = 0 self._showing = False (textureID, image, renderedSize) = GLUtil.renderTextToTexture(Resources.font(size=16, bold=True), (255,255,255,255), ">", False, None) self.cursorImage = image self.cursorTexture = textureID
def draw(self): if not self.enabled: self.lastText = "" return text = self.getText() color = self.getColor() glDisable(GL_LIGHTING) if self.lastText != text or self.lastColor != color: self.lastText = text self.lastColor = color if self.texture != -1: glDeleteTextures([self.texture]) if self.listID != -1: glDeleteLists(self.listID,1) (self.texture, self.listID, self.renderedSize) = GLUtil.drawText(self.getFont(), color, text, self.getPosn(), self.getBorder(), self.getBackgroundColor(), self.getCenterX(), self.getCenterY()) else: if self.listID > 0: glCallList(self.listID) glEnable(GL_LIGHTING)
def draw(self): if not self.enabled: self.lastText = "" return text = self.getText() color = self.getColor() glDisable(GL_LIGHTING) if self.lastText != text or self.lastColor != color: self.lastText = text self.lastColor = color if self.texture != -1: glDeleteTextures([self.texture]) if self.listID != -1: glDeleteLists(self.listID, 1) (self.texture, self.listID, self.renderedSize) = GLUtil.drawText(self.getFont(), color, text, self.getPosn(), self.getBorder(), self.getBackgroundColor(), self.getCenterX(), self.getCenterY()) else: if self.listID > 0: glCallList(self.listID) glEnable(GL_LIGHTING)
def makeBorder(self): width = self.width height = self.height if height == None: height = len(self.displayers) height *= 20 image = GLUtil.createBorder(width, height) (texture, image) = GLUtil.makeTexture(image, None) listID = glGenLists(1) glNewList(listID, GL_COMPILE_AND_EXECUTE) GLUtil.drawAt(self.posn, texture, image) glEndList() return (listID, texture)
def __init__(self, unit): Sprite.__init__(self) self.__unit = unit imageName = unit.getSprites('standing')[0] self.__texture = GLUtil.makeTexture(Resources.image(imageName))[0] wimageName = None self.__otexture = None self.__wtexture = None self.__weaponGrip = None self.__unitHand = None if unit.weapon() != None: wimageName = unit.weapon().getSprites('standing')[0] self.__weaponGrip = Resources.spriteConfig.grip(wimageName) self.__unitHand = Resources.spriteConfig.hand(imageName) if wimageName != None: self.__wtexture = GLUtil.makeTexture( Resources.image(wimageName))[0] oimageName = unit.getOverSprites('standing') if oimageName != []: oimageName = oimageName[0] self.__otexture = GLUtil.makeTexture( Resources.image(oimageName))[0] self.__offsetX = 0.0 self.__offsetY = 0.0 self.__offsetZ = 0.0 self._animations = [] self._color = (1.0, 1.0, 1.0, 1.0) # The number of color and Texture Status # and time for animation between Status self._colorStatus = -1 self._textureStatus = -1 self._textureTime = time.time() self._colorTime = time.time() self._unitStatusColor = (1.0, 1.0, 1.0, 1.0) self._isActing = False
def draw(self): if self._time > 0.1 * self._frame: self._frame += 1 if self._frame > self._maxFrame - 1: self._frame = self._maxFrame - 1 if self._texture == []: return if self._otexture == []: GLUtil.makeUnit(self._texture[self._frame], wtexture=self._wtexture, weaponGrip=self._weapGrip, unitHand=self._unitHand[self._frame], color=self._unitdisplayer._unitStatusColor) else: GLUtil.makeUnit(self._texture[self._frame], wtexture=self._wtexture, otexture=self._otexture[self._frame], weaponGrip=self._weapGrip, unitHand=self._unitHand[self._frame], color=self._unitdisplayer._unitStatusColor)
def draw(self): if self._time > 0.1 *self._frame: self._frame +=1 if self._frame > self._maxFrame - 1: self._frame = self._maxFrame - 1 if self._texture == []: return if self._otexture == []: GLUtil.makeUnit(self._texture[self._frame], wtexture = self._wtexture, weaponGrip = self._weapGrip, unitHand = self._unitHand[self._frame], color = self._unitdisplayer._unitStatusColor) else: GLUtil.makeUnit(self._texture[self._frame], wtexture = self._wtexture, otexture = self._otexture[self._frame], weaponGrip = self._weapGrip, unitHand = self._unitHand[self._frame], color = self._unitdisplayer._unitStatusColor)
def __init__(self, damageAmount, beneficial=NEUTRAL, delay=0.0): if beneficial == BENEFICIAL: color = GREEN elif beneficial == NEGATIVE: color = WHITE else: color = WHITE self._time = -delay (self._texture, i, isize) = GLUtil.renderTextToTexture(Resources.font(size=48), color, str(damageAmount), False, None) self._aspectRatio = float(isize[0]) / isize[1]
def __init__(self, unit): Sprite.__init__(self) self.__unit = unit imageName = unit.getSprites('standing')[0] self.__texture = GLUtil.makeTexture(Resources.image(imageName))[0] wimageName = None self.__otexture = None self.__wtexture = None self.__weaponGrip = None self.__unitHand = None if unit.weapon() != None: wimageName = unit.weapon().getSprites('standing')[0] self.__weaponGrip = Resources.spriteConfig.grip(wimageName) self.__unitHand = Resources.spriteConfig.hand(imageName) if wimageName != None: self.__wtexture = GLUtil.makeTexture(Resources.image(wimageName))[0] oimageName = unit.getOverSprites('standing') if oimageName != []: oimageName = oimageName[0] self.__otexture = GLUtil.makeTexture(Resources.image(oimageName))[0] self.__offsetX = 0.0 self.__offsetY = 0.0 self.__offsetZ = 0.0 self._animations = [] self._color = (1.0, 1.0, 1.0, 1.0) # The number of color and Texture Status # and time for animation between Status self._colorStatus = -1 self._textureStatus = -1 self._textureTime = time.time() self._colorTime = time.time() self._unitStatusColor = (1.0, 1.0, 1.0, 1.0) self._isActing = False
def __init__(self, unit, delay=0.0, attackStyle="melee"): # Number of frames of the attack animation self._maxFrame = unit.getSprites(attackStyle).__len__() if self._maxFrame == 0: attackStyle = 'standing' self._maxFrame = unit.getSprites(attackStyle).__len__() # Load the textures self._unitHand = [] self._texture = [] for image in unit.getSprites(attackStyle): self._texture.append(GLUtil.makeTexture(Resources.image(image))[0]) self._unitHand.append(Resources.spriteConfig.hand(image)) # Load the weapon textures self._wtexture = None self._weapGrip = None if unit.weapon() != None: wimage = unit.weapon().getSprites('standing')[0] if wimage != None: self._wtexture = GLUtil.makeTexture(Resources.image(wimage))[0] self._weapGrip = Resources.spriteConfig.grip(wimage) else: wimage = None # Load the over textures self._otexture = [] if wimage != None: oimages = unit.getOverSprites(attackStyle) if len(oimages) < self._maxFrame: oimages = [] for image in oimages: self._otexture.append( GLUtil.makeTexture(Resources.image(image))[0]) self._unitdisplayer = ScenarioGUI.get().unitDisplayer(unit) self._unitdisplayer.Acting() self._time = -delay self._frame = 0
def draw(self): #glDisable(GL_DEPTH_TEST) if self._color[3] < 0.0: return glDisable(GL_LIGHTING) glDepthFunc(GL_LEQUAL) glPushMatrix() GLUtil.mapTrans(self.x, self.y, self.z) # Draw the circle around the unit's feet (r, g, b) = Faction.color(self.__unit.faction()) none = Resources.texture("none") glBindTexture(GL_TEXTURE_2D, none) glPushMatrix() if self.__unit.facing() == Constants.E: glRotate(-90.0, 0.0, 0.0, 1.0) elif self.__unit.facing() == Constants.S: glRotate(180.0, 0.0, 0.0, 1.0) elif self.__unit.facing() == Constants.W: glRotate(90.0, 0.0, 0.0, 1.0) glColor4f(r, g, b, 1.0 * self._color[3]) glBegin(GL_TRIANGLES) glVertex3f(0.0, 0.0, 0.0) glVertex3f(-0.15, 0.35, 0.0) glVertex3f(0.15, 0.35, 0.0) glEnd() glPopMatrix() quad = gluNewQuadric() gluDisk(quad, 0.3, 0.4, 32, 1) gluDeleteQuadric(quad) # Checking for texture and color status unitStatus = self.__unit.statusEffects() if len(unitStatus.texture()) == 0: self._textureStatus = -1 else: if time.time() > self._textureTime: self._textureTime = time.time() + 1.1 self._textureStatus += 1 if self._textureStatus >= len(unitStatus.texture()): self._textureStatus = 0 try: if engine.Effect.Status.effectTextures[unitStatus.texture()[ self._textureStatus]] != None: GLUtil.makeStatus( engine.Effect.Status.effectTextures[ unitStatus.texture()[self._textureStatus]], self._color) except: # when the status is over this can happen pass statuscolor = None if len(unitStatus.color()) == 0: self._colorStatus = -1 else: if time.time() > self._colorTime: self._colorTime = time.time() + 1.3 self._colorStatus += 1 if self._colorStatus >= len(unitStatus.color()): self._colorStatus = 0 try: if engine.Effect.Status.effectTextures[unitStatus.color()[ self._colorStatus]] != None: statuscolor = engine.Effect.Status.effectTextures[ unitStatus.color()[self._colorStatus]] except: pass if statuscolor == None: if self.isActing() == True: self._unitStatusColor = self._color else: GLUtil.makeUnit(texture=self.__texture, wtexture=self.__wtexture, otexture=self.__otexture, color=self._color, weaponGrip=self.__weaponGrip, unitHand=self.__unitHand) else: if self.isActing() == True: self._unitStatusColor = statuscolor else: GLUtil.makeUnit(texture=self.__texture, wtexture=self.__wtexture, otexture=self.__otexture, color=statuscolor, weaponGrip=self.__weaponGrip, unitHand=self.__unitHand) for a in self._animations: a.draw() glPopMatrix() glDepthFunc(GL_LESS) glEnable(GL_LIGHTING)
def draw(self): #glDisable(GL_DEPTH_TEST) if self._color[3] < 0.0: return glDisable(GL_LIGHTING) glDepthFunc(GL_LEQUAL) glPushMatrix() GLUtil.mapTrans(self.x, self.y, self.z) # Draw the circle around the unit's feet (r, g, b) = Faction.color(self.__unit.faction()) none = Resources.texture("none") glBindTexture(GL_TEXTURE_2D, none) glPushMatrix() if self.__unit.facing() == Constants.E: glRotate(-90.0, 0.0, 0.0, 1.0) elif self.__unit.facing() == Constants.S: glRotate(180.0, 0.0, 0.0, 1.0) elif self.__unit.facing() == Constants.W: glRotate(90.0, 0.0, 0.0, 1.0) glColor4f(r, g, b, 1.0 * self._color[3]) glBegin(GL_TRIANGLES) glVertex3f(0.0, 0.0, 0.0) glVertex3f(-0.15, 0.35, 0.0) glVertex3f(0.15, 0.35, 0.0) glEnd() glPopMatrix() quad = gluNewQuadric() gluDisk(quad, 0.3, 0.4, 32, 1) gluDeleteQuadric(quad) # Checking for texture and color status unitStatus = self.__unit.statusEffects() if len(unitStatus.texture()) == 0 : self._textureStatus = -1 else: if time.time() > self._textureTime: self._textureTime = time.time() +1.1 self._textureStatus += 1 if self._textureStatus >= len(unitStatus.texture()): self._textureStatus = 0 try: if engine.Effect.Status.effectTextures[unitStatus.texture()[self._textureStatus]] != None: GLUtil.makeStatus(engine.Effect.Status.effectTextures[unitStatus.texture()[self._textureStatus]], self._color) except: # when the status is over this can happen pass statuscolor = None if len(unitStatus.color()) == 0 : self._colorStatus = -1 else: if time.time() > self._colorTime: self._colorTime = time.time() +1.3 self._colorStatus += 1 if self._colorStatus >= len(unitStatus.color()): self._colorStatus = 0 try: if engine.Effect.Status.effectTextures[unitStatus.color()[self._colorStatus]] != None: statuscolor = engine.Effect.Status.effectTextures[unitStatus.color()[self._colorStatus]] except : pass if statuscolor == None : if self.isActing() == True: self._unitStatusColor = self._color else: GLUtil.makeUnit(texture = self.__texture, wtexture = self.__wtexture, otexture = self.__otexture, color = self._color, weaponGrip = self.__weaponGrip, unitHand = self.__unitHand) else: if self.isActing() == True: self._unitStatusColor = statuscolor else: GLUtil.makeUnit(texture = self.__texture, wtexture = self.__wtexture, otexture = self.__otexture, color = statuscolor, weaponGrip = self.__weaponGrip, unitHand = self.__unitHand) for a in self._animations: a.draw() glPopMatrix() glDepthFunc(GL_LESS) glEnable(GL_LIGHTING)