/usr/share/games/bouncy/ui.py is in bouncy 0.6.20071104-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | import sys, pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import fonts, pyglyph
class UserInterface:
def twod_setup(self, colour=(0,0,0)):
# set up 2d mode
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
x, y = self.viewport
glViewport(0, 0, x, y)
glOrtho(0, x, 0, y, -50, 50)
glMatrixMode(GL_MODELVIEW)
colour += (0,)
glClearColor(*colour)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glDisable(GL_LIGHTING)
glDisable(GL_DEPTH_TEST)
def ok_dialog(self, text):
text = pyglyph.layout_text(text, font=fonts.sans40)
x, y = self.viewport
self.twod_setup()
glBegin(GL_QUADS)
glColor4f(.9, .9, .9, 1)
glVertex2f(x/2 - 300, y/2-100)
glVertex2f(x/2 + 300, y/2-100)
glVertex2f(x/2 + 300, y/2+100)
glVertex2f(x/2 - 300, y/2+100)
glEnd()
pyglyph.begin()
text.draw(pos=(x/2, y/2),
anchor=(pyglyph.Align.center, pyglyph.Align.center))
pyglyph.end()
pygame.display.flip()
while 1:
for e in pygame.event.get():
if e.type == QUIT: sys.exit()
if e.type == MOUSEBUTTONDOWN: return
if not hasattr(e, 'key'): continue
if e.key == K_RETURN: return
if e.key == K_ESCAPE: return
def fade(self, dir, ts, ts_max):
# fade to black
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
x, y = self.viewport
glOrtho(0, x, 0, y, -1, 1)
glMatrixMode(GL_MODELVIEW)
glDisable(GL_LIGHTING)
glDisable(GL_DEPTH_TEST)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glLoadIdentity()
glBegin(GL_QUADS)
if dir == 'out':
glColor(0, 0, 0, min(1, float(ts)/ts_max))
else:
glColor(0, 0, 0, max(0, 1 - float(ts)/ts_max))
glVertex3f(0, 0, 0)
glVertex3f(0, y, 0)
glVertex3f(x, y, 0)
glVertex3f(x, 0, 0)
glEnd()
|