Disabled actor rotation for speed
[flail.git] / menuitem.py
blob77997e95d0afa7d32d46f6e2ebb7ab057da0dd92
1 from pyglet import font,image
2 from pyglet.gl.gl import *
4 from geom import vector
6 class menuitem (object):
7 def __init__(self,str,x=0,y=0):
8 self.label = str
9 self.pos = vector (x,y)
10 self.bg = image.load('data/menuitem.png').texture
11 self.is_highlighted = False
12 self.alpha = 0.1
13 self.text = font.Text(font.load('Arial',32),
14 str,
15 x = x,
16 y = y,
17 valign = 'center',
18 halign = 'center'
21 glBindTexture (GL_TEXTURE_2D, self.bg.id)
22 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER)
23 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER)
25 def highlight(self):
26 self.is_highlighted = True
27 self.alpha = 0.3
29 def unhighlight(self):
30 self.is_highlighted = False
31 self.alpha = 0.1
33 def render (self):
34 glBindTexture (GL_TEXTURE_2D, self.bg.id)
35 glBegin (GL_TRIANGLE_STRIP)
37 glColor4d (0.0, 0.0, 1.0, self.alpha)
38 glTexCoord2d (self.bg.tex_coords[0],
39 self.bg.tex_coords[1])
40 glVertex2d (-self.bg.width / 2,
41 -self.bg.height / 2)
43 glTexCoord2d (self.bg.tex_coords[3],
44 self.bg.tex_coords[4])
45 glVertex2d ( self.bg.width / 2,
46 -self.bg.height / 2)
48 glTexCoord2d (self.bg.tex_coords[9],
49 self.bg.tex_coords[10])
50 glVertex2d (-self.bg.width / 2,
51 self.bg.height / 2)
53 glTexCoord2d (self.bg.tex_coords[6],
54 self.bg.tex_coords[7])
55 glVertex2d ( self.bg.width / 2,
56 self.bg.height / 2)
58 glEnd ()
60 self.text.draw ()