]> icculus.org git repositories - theoddone33/hheretic.git/blob - pyhexen/menu.py
c7538239e01db27bd105ec3820758a35fe485cee
[theoddone33/hheretic.git] / pyhexen / menu.py
1 import struct
2 import wad
3 import vid
4
5 class Menu:
6         def __init__ (self, wad, vid):
7                 self.wad = wad
8                 self.vid = vid
9                 self.SkullBaseLump = self.wad.GetNumForName("M_SKL00")
10                 self.FontABaseLump = self.wad.GetNumForName("FONTA_S")+1
11                 self.FontBBaseLump = self.wad.GetNumForName("FONTB_S")+1
12                 
13         def ProcessText (self, text, x, y, baselump, draw=True):
14                 print 'Processing %s' % text
15                 for c in text:
16                         print 'ord %d' % ord (c)
17                         if ord (c) < 33:
18                                 print ("skipzored")
19                                 x = x + 5
20                         else:
21                                 patch = self.wad.CacheLumpNum (baselump + ord (c) - 33)
22                                 (w, h) = struct.unpack_from ('<hh', patch, 0)
23                                 if draw:
24                                         print "Drawing at %d,%d" % (x,y)
25                                         self.vid.DrawPatch (x, y, patch)
26                                 x  = x + w - 1
27                 return x
28                 
29         def DrawTextA (self, text, x, y):
30                 self.ProcessText (text, x, y, self.FontABaseLump)
31                 
32         def TextAWidth (self, text):
33                 return self.ProcessText (text, 0, 0, self.FontABaseLump, False)
34                 
35         def DrawTextB (self, text, x, y):
36                 self.ProcessText (text, x, y, self.FontBBaseLump)
37                 
38         def TextBWidth (self, text):
39                 return self.ProcessText (text, 0, 0, self.FontBBaseLump, False)