Add heretic folder, menu changes.
authorDan Olson <theoddone33@icculus.org>
Fri, 27 Nov 2009 20:55:01 +0000 (12:55 -0800)
committerDan Olson <theoddone33@icculus.org>
Fri, 27 Nov 2009 20:55:01 +0000 (12:55 -0800)
heretic/__init__.py [new file with mode: 0644]
heretic/menus.py [new file with mode: 0644]
pyhexen.py
pyhexen/menu.py

diff --git a/heretic/__init__.py b/heretic/__init__.py
new file mode 100644 (file)
index 0000000..f0e6472
--- /dev/null
@@ -0,0 +1 @@
+import heretic.menus
\ No newline at end of file
diff --git a/heretic/menus.py b/heretic/menus.py
new file mode 100644 (file)
index 0000000..f398543
--- /dev/null
@@ -0,0 +1,43 @@
+import pyhexen
+
+def CreateMenus(menu):
+       "Setup game-specific menus"
+       class MainMenu(pyhexen.menu.SubMenu):
+               def __init__ (self, menu, name, x, y, prev):
+                       pyhexen.menu.SubMenu.__init__(self, menu, name, x, y, prev)
+                       self.SkullBaseLump = self.menu.wad.GetNumForName("M_SKL00")
+               
+               def Draw (self):
+                       frame = (self.menu.time/3) % 18
+                       self.menu.vid.DrawPatch (88, 0, self.menu.wad.CacheLumpName ('M_HTIC'))
+                       self.menu.vid.DrawPatch (40, 10, self.menu.wad.CacheLumpNum (self.SkullBaseLump + (17 - frame)))
+                       self.menu.vid.DrawPatch (232, 10, self.menu.wad.CacheLumpNum (self.SkullBaseLump + frame))
+
+       mainMenu = MainMenu (menu, 'main', 110, 56, None)
+       mainMenu.AddItem (mainMenu.ITT_EFUNC, 'NEW GAME', SCNetCheck, 1, 'episode')
+       mainMenu.AddItem (mainMenu.ITT_SETMENU, 'OPTIONS', None, None, 'options')
+       mainMenu.AddItem (mainMenu.ITT_SETMENU, 'GAME FILES', None, None, 'files')
+       mainMenu.AddItem (mainMenu.ITT_EFUNC, 'INFO', SCInfo, 0, None)
+       mainMenu.AddItem (mainMenu.ITT_EFUNC, 'QUIT GAME', SCQuitGame, 0, None)
+       menu.AddMenu (mainMenu)
+
+       episodeMenu = pyhexen.menu.SubMenu (menu, 'episode', 80, 50, 'main')
+       episodeMenu.AddItem (episodeMenu.ITT_EFUNC, 'CITY OF THE DAMNED', SCEpisode, 1, None)
+       episodeMenu.AddItem (episodeMenu.ITT_EFUNC, "HELL'S MAW", SCEpisode, 2, None)
+       episodeMenu.AddItem (episodeMenu.ITT_EFUNC, "THE DOME OF D'SPARIL", SCEpisode, 3, None)
+       episodeMenu.AddItem (episodeMenu.ITT_EFUNC, 'THE OSSUARY', SCEpisode, 4, None)
+       episodeMenu.AddItem (episodeMenu.ITT_EFUNC, 'THE STAGNANT DEMESNE', SCEpisode, 5, None)
+       menu.AddMenu (episodeMenu)
+       
+def SCNetCheck (arg):
+       pass
+       
+def SCInfo (arg):
+       pass
+
+def SCQuitGame (arg):
+       pass
+
+def SCEpisode (arg):
+       pass
+       
index c77be04..caa00fb 100644 (file)
@@ -2,6 +2,7 @@ import sys
 import pyhexen
 import pygame
 from pygame.locals import *
+import heretic
 
 def input(events):
        for event in events:
@@ -18,22 +19,7 @@ vid.SetPalette (wad.CacheLumpName('PLAYPAL'))
 
 menu = pyhexen.menu.Menu (wad, vid)
 
-# Setup menus... these will be game-specific!
-class MainMenu(pyhexen.menu.SubMenu):
-       def Draw (self):
-               frame = (self.menu.time/3) % 18
-               self.menu.vid.DrawPatch (88, 0, self.menu.wad.CacheLumpName ('M_HTIC'))
-               self.menu.vid.DrawPatch (40, 10, self.menu.wad.CacheLumpNum (self.menu.SkullBaseLump + (17 - frame)))
-               self.menu.vid.DrawPatch (232, 10, self.menu.wad.CacheLumpNum (self.menu.SkullBaseLump + frame))
-
-mainMenu = MainMenu (menu, 'main', 110, 56)
-mainMenu.AddItem ("NEW GAME")
-mainMenu.AddItem ("OPTIONS")
-mainMenu.AddItem ("GAME FILES")
-mainMenu.AddItem ("INFO")
-mainMenu.AddItem ("QUIT GAME")
-
-menu.AddMenu (mainMenu)
+heretic.menus.CreateMenus (menu)
 
 menu.Activate ()
 
index 3f5552c..33d6353 100644 (file)
@@ -3,23 +3,33 @@ import wad
 import vid
 
 class SubMenu:
-       def __init__ (self, menu, name, x, y):
+       ITT_EMPTY = 0
+       ITT_EFUNC = 1
+       ITT_LRFUNC = 2
+       ITT_SETMENU = 3
+       ITT_INERT = 4
+       
+       def __init__ (self, menu, name, x, y, prev):
                self.menu = menu
                self.x = x
                self.y = y
                self.name = name
                self.items = [ ]
+               self.prev = prev
                
        def Draw (self):
                pass
                
-       def AddItem (self, item):
-               self.items.append (item)
+       def AddItem (self, type, name, func, arg, menu):
+               self.items.append ((type,name,func,arg,menu))
                
        def Choose (self, item):
                pass
                
 class Menu:
+       ITEM_HEIGHT = 20
+       SELECTOR_YOFFSET = -1
+       SELECTOR_XOFFSET = -28
        def __init__ (self, wad, vid):
                self.wad = wad
                self.vid = vid
@@ -27,8 +37,8 @@ class Menu:
                self.active = False
                self.current = 0
                self.currentitem = 0
+               self.old = 0
                self.menus = [ ]
-               self.SkullBaseLump = self.wad.GetNumForName("M_SKL00")
                self.FontABaseLump = self.wad.GetNumForName("FONTA_S")+1
                self.FontBBaseLump = self.wad.GetNumForName("FONTB_S")+1
                
@@ -64,24 +74,25 @@ class Menu:
                        self.time = self.time + 1
 
        def Activate (self):
-               self.current = 0
+               self.current = self.old
                self.time = 0
                self.active = True
                
        def Deactivate (self):
-               pass
+               self.active = False
+               self.old = self.current
                
        def Draw (self):
                self.menus[self.current].Draw ()
                x = self.menus[self.current].x
                y = self.menus[self.current].y
-               for i in self.menus[self.current].items:
-                       self.DrawTextB (i, x, y)
-                       y = y + 20 # ITEM_HEIGHT
-               y = self.menus[self.current].y+(self.currentitem*20)+-1 # ITEM_HEIGHT, SELECTOR_YOFFSET
+               for item in self.menus[self.current].items:
+                       self.DrawTextB (item[1], x, y)
+                       y = y + Menu.ITEM_HEIGHT
+               y = self.menus[self.current].y+(self.currentitem*Menu.ITEM_HEIGHT)+Menu.SELECTOR_YOFFSET
                if self.time & 16:
                        selName = 'M_SLCTR1'
                else:
                        selName = 'M_SLCTR2'
-               self.vid.DrawPatch(x-28, y, self.wad.CacheLumpName (selName))
+               self.vid.DrawPatch(x + Menu.SELECTOR_XOFFSET, y, self.wad.CacheLumpName (selName))