/beatscape.py
#!/usr/bin/python
# beatscape is the mother of all musical button games.

import sys
import pygame
from keygraph import *
from keyfile import *
from bmevent import *
from chanman import *
from formats import *
from keyhandler import *
import game

try:
	import config
except ImportError:
	print "Could not parse config.py. Maybe you forgot a semicolon? :-P"
	exit(1)

song = ''

if len(sys.argv) > 1:
	song = sys.argv[1]

try:
	import psyco
	print "w00t! going psyco!"
	psyco.full()
except ImportError:
	pass

pygame.mixer.pre_init(44100, -16, True, 1)
pygame.init()
opts = pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE
pygame.display.set_mode((640,480), opts)
screen = pygame.display.get_surface()

for n in range(0,pygame.joystick.get_count()):
	pygame.joystick.Joystick(n).init();

if song:
	# For now, assume IIDX. We'll make this smarter later.
	game.playgame(gametypes['IIDX'],song)
	exit(0)

from mainmenu import *
from fileselect import *

l = ['mainmenu']

while 1:
	obj = None

	if l[0] == 'mainmenu':
		obj = MainMenu()
	elif l[0] == 'fileselect':
		obj = FileSelect()
	elif l[0] == 'play':
		obj = game.Game(l[1])
	elif l[0] == 'quit':
		sys.exit(0)

	l = obj.run()
	# Flush events before switching to the next mode
	pygame.event.clear()

pygame.quit()