File: error.py

package info (click to toggle)
pydance 1.0.3-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 8,120 kB
  • ctags: 731
  • sloc: python: 7,440; makefile: 71; ruby: 49; ansic: 21; sh: 7
file content (39 lines) | stat: -rw-r--r-- 1,164 bytes parent folder | download | duplicates (2)
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
# Put up a pretty error message.

from interface import *
from constants import mainconfig
import fontfx
import ui

class ErrorMessage(InterfaceWindow):
  def __init__(self, screen, line):
    InterfaceWindow.__init__(self, screen, "error-bg.png")
    text = fontfx.shadow("Error!", 60, [255, 255, 255], offset = 2)
    text_rect = text.get_rect()
    text_rect.center = [320, 50]
    screen.blit(text, text_rect)

    # FIXME: Remove this when I'm sure that nothing uses the old calling
    # method. (Pre-1.0)
    if isinstance(line, list): lines = " ".join(line)

    font = fontfx.WrapFont(32, 440)
    b = font.render(line, shdw = True, centered = True)
    r = b.get_rect()
    r.center = [320, 240]
    screen.blit(b, r)

    text = fontfx.shadow("Press Enter/Start/Escape", 32, [160, 160, 160])
    textpos = text.get_rect()
    textpos.center = [320, 440]
    screen.blit(text, textpos)

    pygame.display.update()
    ui.ui.clear()

    pid, ev = (0, ui.PASS)
    while ev not in [ui.START, ui.CONFIRM, ui.QUIT]:
      if ev == ui.FULLSCREEN:
        pygame.display.toggle_fullscreen()
        mainconfig["fullscreen"] ^= 1
      pid, ev = ui.ui.wait()