Пример #1
0
    def __init__(self):
        "Set up the Exit menu"

        Menu.__init__(self, "MoleFusion Exit Menu", "sprites/back1.jpg")

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(
            open("languages/ExitMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1),
                              (27, 22, 24))

        self.game_by = GW_Label(self.curHandler.getText("game"), (0.5, 0.3),
                                (240, 255, 220))
        self.music_by = GW_Label(self.curHandler.getText("music"), (0.5, 0.5),
                                 (240, 255, 220))
        self.web = GW_Label(self.curHandler.getText("web"), (0.5, 0.7),
                            (255, 255, 255))

        self.widget_man = GuiWidgetManager(
            [self.title, self.game_by, self.music_by, self.web])

        self.time_speed = pygame.time.Clock()
        self.exit = False
        self.on_enter()
Пример #2
0
    def __init__(self):
        "Sets up the options menu"

        Menu.__init__(self, "MoleFusion Options Menu", "sprites/back1.jpg")

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(open("languages/OptionsMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1), (27, 22, 24))

        self.name = GW_Label(self.curHandler.getText("name"), (0.5, 0.2), (255, 255, 255))
        self.inputname = GW_TextInput((0.5, 0.3), 24, 0.4, Constants.PLAYERNAME)

        self.language = GW_Button(self.curHandler.getText("language"), (0.5, 0.5), (255, 255, 255))
        self.language.add_eventhandler("onmouseclick", self.language_onmouseclick)

        self.returnMain = GW_Button(self.curHandler.getText("returnMain"), (0.5, 0.8), (255, 255, 255))
        self.returnMain.add_eventhandler("onmouseclick", self.returnMain_onmouseclick)

        self.widget_man = GuiWidgetManager([self.title, self.name, self.inputname, self.language, self.returnMain])

        self.time_speed = pygame.time.Clock()
        self.exit = False
        self.on_enter()
Пример #3
0
    def __init__(self):
        "Sets up the menu"

        Menu.__init__(self, "MoleFusion Main Menu", "sprites/back1.jpg")

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(open("languages/MainMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1), (27, 22, 24))

        self.start = GW_Button(self.curHandler.getText("start"), (0.5, 0.3), (255, 255, 255))
        self.start.add_eventhandler("onmouseclick", self.start_onmouseclick)

        self.options = GW_Button(self.curHandler.getText("options"), (0.5, 0.45), (255, 255, 255))
        self.options.add_eventhandler("onmouseclick", self.options_onmouseclick)

        self.highscores = GW_Button(self.curHandler.getText("highscores"), (0.5, 0.6), (255, 255, 255))
        self.highscores.add_eventhandler("onmouseclick", self.highscores_onmouseclick)

        self.help = GW_Button(self.curHandler.getText("help"), (0.5, 0.75), (255, 255, 255))
        self.help.add_eventhandler("onmouseclick", self.help_onmouseclick)

        self.quit = GW_Button(self.curHandler.getText("quit"), (0.5, 0.9), (255, 255, 255))
        self.quit.add_eventhandler("onmouseclick", self.quit_onmouseclick)

        self.widget_man = GuiWidgetManager(
            [self.title, self.start, self.options, self.highscores, self.help, self.quit]
        )

        self.time_speed = pygame.time.Clock()

        self.on_enter()
Пример #4
0
	def __init__(self,background):
		"Set up the HighScores menu"
		
		Menu.__init__(self,"MoleFusion HighScore Menu",background)
		
		self.parser = make_parser()
		self.curHandler = Localization()
		self.parser.setContentHandler(self.curHandler)
		self.parser.parse(open("languages/HighScoresMenu_" + Constants.LANGUAGE + ".xml"))
	
		self.title = GW_Label(self.curHandler.getText("title"),(0.5,0.1),(27,22,24))
		
		self.name_column = GW_Label(self.curHandler.getText("name"),(0.25,0.25),(212,224,130))
		self.points_column = GW_Label(self.curHandler.getText("points"),(0.75,0.25),(212,224,130))
		
		self.returnMain = GW_Button(self.curHandler.getText("returnMain"),(0.5,0.9),(255,255,255))
		self.returnMain.add_eventhandler("onmouseclick",self.returnMain_onmouseclick)
		
		h = HighScores()
		highscorelist = h.get_HighScores()

		self.widgetlist = [self.title,self.name_column,self.points_column,self.returnMain]
		
		for val,i in enumerate(highscorelist[0:5]):
			self.widgetlist.append(GW_Label(i.get_name(),(0.25,0.35+val/10.0),(250,254,210)))
			self.widgetlist.append(GW_Label(str(i.get_points()),(0.75,0.35+val/10.0),(250,254,210)))
				
		self.widget_man = GuiWidgetManager(self.widgetlist)
		
		self.time_speed=pygame.time.Clock()
		self.exit=False
		self.on_enter()
Пример #5
0
    def __init__(self, background):
        "Set up the HighScores menu"

        Menu.__init__(self, "MoleFusion HighScore Menu", background)

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(
            open("languages/HighScoresMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1),
                              (27, 22, 24))

        self.name_column = GW_Label(self.curHandler.getText("name"),
                                    (0.25, 0.25), (212, 224, 130))
        self.points_column = GW_Label(self.curHandler.getText("points"),
                                      (0.75, 0.25), (212, 224, 130))

        self.returnMain = GW_Button(self.curHandler.getText("returnMain"),
                                    (0.5, 0.9), (255, 255, 255))
        self.returnMain.add_eventhandler("onmouseclick",
                                         self.returnMain_onmouseclick)

        h = HighScores()
        highscorelist = h.get_HighScores()

        self.widgetlist = [
            self.title, self.name_column, self.points_column, self.returnMain
        ]

        for val, i in enumerate(highscorelist[0:5]):
            self.widgetlist.append(
                GW_Label(i.get_name(), (0.25, 0.35 + val / 10.0),
                         (250, 254, 210)))
            self.widgetlist.append(
                GW_Label(str(i.get_points()), (0.75, 0.35 + val / 10.0),
                         (250, 254, 210)))

        self.widget_man = GuiWidgetManager(self.widgetlist)

        self.time_speed = pygame.time.Clock()
        self.exit = False
        self.on_enter()
Пример #6
0
    def __init__(self):
        "Sets up the menu"

        Menu.__init__(self, "MoleFusion Main Menu", "sprites/back1.jpg")

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(
            open("languages/MainMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1),
                              (27, 22, 24))

        self.start = GW_Button(self.curHandler.getText("start"), (0.5, 0.3),
                               (255, 255, 255))
        self.start.add_eventhandler("onmouseclick", self.start_onmouseclick)

        self.options = GW_Button(self.curHandler.getText("options"),
                                 (0.5, 0.45), (255, 255, 255))
        self.options.add_eventhandler("onmouseclick",
                                      self.options_onmouseclick)

        self.highscores = GW_Button(self.curHandler.getText("highscores"),
                                    (0.5, 0.6), (255, 255, 255))
        self.highscores.add_eventhandler("onmouseclick",
                                         self.highscores_onmouseclick)

        self.help = GW_Button(self.curHandler.getText("help"), (0.5, 0.75),
                              (255, 255, 255))
        self.help.add_eventhandler("onmouseclick", self.help_onmouseclick)

        self.quit = GW_Button(self.curHandler.getText("quit"), (0.5, 0.9),
                              (255, 255, 255))
        self.quit.add_eventhandler("onmouseclick", self.quit_onmouseclick)

        self.widget_man = GuiWidgetManager([
            self.title, self.start, self.options, self.highscores, self.help,
            self.quit
        ])

        self.time_speed = pygame.time.Clock()

        self.on_enter()
Пример #7
0
	def __init__(self):
		"Sets up the Language menu"
		
		Menu.__init__(self,"Language Main Menu","sprites/back1.jpg")

		self.title = GW_Label("Choose Language",(0.5,0.15),(27,22,24))
		
		self.english = GW_Image("sprites/language_engl.png",(0.25,0.35))
		self.english.add_eventhandler("onmouseclick",self.english_onmouseclick)

		self.spanish= GW_Image("sprites/language_espn.png",(0.5,0.35))
		self.spanish.add_eventhandler("onmouseclick",self.spanish_onmouseclick)
		
		self.euskera = GW_Image("sprites/language_eusk.png",(0.75,0.35))
		self.euskera.add_eventhandler("onmouseclick",self.euskera_onmouseclick)

		self.widget_man = GuiWidgetManager([self.title,self.english,self.spanish,self.euskera])
		
		self.time_speed=pygame.time.Clock()
		self.exit=False
		
		self.on_enter()
Пример #8
0
	def __init__(self):
		"Sets up the Help menu"
		
		Menu.__init__(self,"MoleFusion Help Menu","sprites/back1.jpg")
		
		self.parser = make_parser()
		self.curHandler = Localization()
		self.parser.setContentHandler(self.curHandler)
		self.parser.parse(open("languages/HelpMenu_" + Constants.LANGUAGE + ".xml"))
	
		self.title = GW_Label(self.curHandler.getText("title"),(0.5,0.1),(27,22,24))
		
		self.help = GW_Image(self.curHandler.getText("help"),(0.5,0.3))
						
		self.returnMain = GW_Button(self.curHandler.getText("returnMain"),(0.5,0.5),(255,255,255))
		self.returnMain.add_eventhandler("onmouseclick",self.returnMain_onmouseclick)
		
		self.widget_man = GuiWidgetManager([self.title,self.help,self.returnMain])
		
		self.time_speed=pygame.time.Clock()
		self.exit=False
		self.on_enter()
Пример #9
0
class ExitMenu(Menu):
    "Exit Menu"

    def __init__(self):
        "Set up the Exit menu"

        Menu.__init__(self, "MoleFusion Exit Menu", "sprites/back1.jpg")

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(
            open("languages/ExitMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1),
                              (27, 22, 24))

        self.game_by = GW_Label(self.curHandler.getText("game"), (0.5, 0.3),
                                (240, 255, 220))
        self.music_by = GW_Label(self.curHandler.getText("music"), (0.5, 0.5),
                                 (240, 255, 220))
        self.web = GW_Label(self.curHandler.getText("web"), (0.5, 0.7),
                            (255, 255, 255))

        self.widget_man = GuiWidgetManager(
            [self.title, self.game_by, self.music_by, self.web])

        self.time_speed = pygame.time.Clock()
        self.exit = False
        self.on_enter()

    def on_enter(self):
        pygame.event.clear()
        self.screen.blit(self.background, (0, 0))
        pygame.display.flip()
        self.exit = False
        self.widget_man.set_draw(True)

    def on_exit(self):
        pygame.event.clear()
        f = FadeTransition(2000, Constants.FADECOLOR, "to")
        del f
        self.exit = True
        self.widget_man.set_draw(False)

    def run(self):
        while 1 and self.exit == False:
            self.time_speed.tick(Constants.FPS)
            for event in pygame.event.get():
                if event.type == QUIT:
                    self.on_exit()
                elif event.type == KEYDOWN or event.type == MOUSEBUTTONDOWN:
                    self.on_exit()
                else:
                    pygame.event.post(
                        event
                    )  #Reinject the event into the queue for maybe latter process

            self.widget_man.run()
Пример #10
0
class ExitMenu(Menu):
	"Exit Menu"
	
	def __init__(self):
		"Set up the Exit menu"
		
		Menu.__init__(self,"MoleFusion Exit Menu","sprites/back1.jpg")
		
		self.parser = make_parser()
		self.curHandler = Localization()
		self.parser.setContentHandler(self.curHandler)
		self.parser.parse(open("languages/ExitMenu_" + Constants.LANGUAGE + ".xml"))
	
		self.title = GW_Label(self.curHandler.getText("title"),(0.5,0.1),(27,22,24))
		
		self.game_by = GW_Label(self.curHandler.getText("game"),(0.5,0.3),(240,255,220))
		self.music_by = GW_Label(self.curHandler.getText("music"),(0.5,0.5),(240,255,220))
		self.web = GW_Label(self.curHandler.getText("web"),(0.5,0.7),(255,255,255))
						
		self.widget_man = GuiWidgetManager([self.title,self.game_by,self.music_by,self.web])
		
		self.time_speed=pygame.time.Clock()
		self.exit=False
		self.on_enter()

	def on_enter(self):
		pygame.event.clear()		
		self.screen.blit(self.background, (0, 0))
		pygame.display.flip()
		self.exit=False
		self.widget_man.set_draw(True)
	
	def on_exit(self):
		pygame.event.clear()
		f = FadeTransition(2000,Constants.FADECOLOR,"to")
		del f
		self.exit=True
		self.widget_man.set_draw(False)

				
	def run(self):
		while 1 and self.exit==False:
			self.time_speed.tick(Constants.FPS)
			for event in pygame.event.get():
				if event.type == QUIT:
					self.on_exit()
				elif event.type == KEYDOWN or event.type == MOUSEBUTTONDOWN:
					self.on_exit()
				else:
					pygame.event.post(event) #Reinject the event into the queue for maybe latter process	
						
			self.widget_man.run()
Пример #11
0
	def __init__(self):
		"Set up the Exit menu"
		
		Menu.__init__(self,"MoleFusion Exit Menu","sprites/back1.jpg")
		
		self.parser = make_parser()
		self.curHandler = Localization()
		self.parser.setContentHandler(self.curHandler)
		self.parser.parse(open("languages/ExitMenu_" + Constants.LANGUAGE + ".xml"))
	
		self.title = GW_Label(self.curHandler.getText("title"),(0.5,0.1),(27,22,24))
		
		self.game_by = GW_Label(self.curHandler.getText("game"),(0.5,0.3),(240,255,220))
		self.music_by = GW_Label(self.curHandler.getText("music"),(0.5,0.5),(240,255,220))
		self.web = GW_Label(self.curHandler.getText("web"),(0.5,0.7),(255,255,255))
						
		self.widget_man = GuiWidgetManager([self.title,self.game_by,self.music_by,self.web])
		
		self.time_speed=pygame.time.Clock()
		self.exit=False
		self.on_enter()
Пример #12
0
class MainMenu(Menu):
    "Main Menu"

    def __init__(self):
        "Sets up the menu"

        Menu.__init__(self, "MoleFusion Main Menu", "sprites/back1.jpg")

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(open("languages/MainMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1), (27, 22, 24))

        self.start = GW_Button(self.curHandler.getText("start"), (0.5, 0.3), (255, 255, 255))
        self.start.add_eventhandler("onmouseclick", self.start_onmouseclick)

        self.options = GW_Button(self.curHandler.getText("options"), (0.5, 0.45), (255, 255, 255))
        self.options.add_eventhandler("onmouseclick", self.options_onmouseclick)

        self.highscores = GW_Button(self.curHandler.getText("highscores"), (0.5, 0.6), (255, 255, 255))
        self.highscores.add_eventhandler("onmouseclick", self.highscores_onmouseclick)

        self.help = GW_Button(self.curHandler.getText("help"), (0.5, 0.75), (255, 255, 255))
        self.help.add_eventhandler("onmouseclick", self.help_onmouseclick)

        self.quit = GW_Button(self.curHandler.getText("quit"), (0.5, 0.9), (255, 255, 255))
        self.quit.add_eventhandler("onmouseclick", self.quit_onmouseclick)

        self.widget_man = GuiWidgetManager(
            [self.title, self.start, self.options, self.highscores, self.help, self.quit]
        )

        self.time_speed = pygame.time.Clock()

        self.on_enter()

    def on_enter(self):
        pygame.event.clear()
        self.screen.blit(self.background, (0, 0))
        pygame.display.flip()

        self.widget_man.set_draw(True)

    def on_exit(self):
        pygame.event.clear()
        f = FadeTransition(500, Constants.FADECOLOR, "to")
        del f
        self.widget_man.set_draw(False)

    def start_onmouseclick(self, event):
        self.start.onmouseclick(event)
        self.on_exit()
        game = Game()
        game.run()
        self.start.onmouseclickup(event)
        self.on_enter()

    def options_onmouseclick(self, event):
        self.options.onmouseclick(event)
        self.on_exit()
        options = OptionsMenu()
        options.run()
        self.reload_titles()
        self.options.onmouseclickup(event)
        self.on_enter()

    def highscores_onmouseclick(self, event):
        self.highscores.onmouseclick(event)
        self.on_exit()
        highscores = HighScoresMenu("sprites/back1.jpg")
        highscores.run()
        self.reload_titles()
        self.highscores.onmouseclickup(event)
        self.on_enter()

    def help_onmouseclick(self, event):
        self.help.onmouseclick(event)
        self.on_exit()
        help = HelpMenu()
        help.run()
        self.help.onmouseclickup(event)
        self.reload_titles()
        self.on_enter()

    def quit_onmouseclick(self, event):
        self.quit.onmouseclick(event)
        self.on_exit()
        exit = ExitMenu()
        exit.run()
        pygame.event.post(pygame.event.Event(QUIT, {}))

    def reload_titles(self):
        self.parser.parse(open("languages/MainMenu_" + Constants.LANGUAGE + ".xml"))
        self.title.set_title(self.curHandler.getText("title"))
        self.start.set_title(self.curHandler.getText("start"))
        self.options.set_title(self.curHandler.getText("options"))
        self.highscores.set_title(self.curHandler.getText("highscores"))
        self.help.set_title(self.curHandler.getText("help"))
        self.quit.set_title(self.curHandler.getText("quit"))

    def run(self):
        while 1:

            self.time_speed.tick(Constants.FPS)

            for event in pygame.event.get():
                if event.type == QUIT:
                    os._exit(0)

                elif event.type == KEYDOWN and event.key == K_ESCAPE:
                    self.quit_onmouseclick(event)

                else:
                    pygame.event.post(event)  # Reinject the event into the queue for maybe latter process

            self.widget_man.run()
Пример #13
0
class MainMenu(Menu):
    "Main Menu"

    def __init__(self):
        "Sets up the menu"

        Menu.__init__(self, "MoleFusion Main Menu", "sprites/back1.jpg")

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(
            open("languages/MainMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1),
                              (27, 22, 24))

        self.start = GW_Button(self.curHandler.getText("start"), (0.5, 0.3),
                               (255, 255, 255))
        self.start.add_eventhandler("onmouseclick", self.start_onmouseclick)

        self.options = GW_Button(self.curHandler.getText("options"),
                                 (0.5, 0.45), (255, 255, 255))
        self.options.add_eventhandler("onmouseclick",
                                      self.options_onmouseclick)

        self.highscores = GW_Button(self.curHandler.getText("highscores"),
                                    (0.5, 0.6), (255, 255, 255))
        self.highscores.add_eventhandler("onmouseclick",
                                         self.highscores_onmouseclick)

        self.help = GW_Button(self.curHandler.getText("help"), (0.5, 0.75),
                              (255, 255, 255))
        self.help.add_eventhandler("onmouseclick", self.help_onmouseclick)

        self.quit = GW_Button(self.curHandler.getText("quit"), (0.5, 0.9),
                              (255, 255, 255))
        self.quit.add_eventhandler("onmouseclick", self.quit_onmouseclick)

        self.widget_man = GuiWidgetManager([
            self.title, self.start, self.options, self.highscores, self.help,
            self.quit
        ])

        self.time_speed = pygame.time.Clock()

        self.on_enter()

    def on_enter(self):
        pygame.event.clear()
        self.screen.blit(self.background, (0, 0))
        pygame.display.flip()

        self.widget_man.set_draw(True)

    def on_exit(self):
        pygame.event.clear()
        f = FadeTransition(500, Constants.FADECOLOR, "to")
        del f
        self.widget_man.set_draw(False)

    def start_onmouseclick(self, event):
        self.start.onmouseclick(event)
        self.on_exit()
        game = Game()
        game.run()
        self.start.onmouseclickup(event)
        self.on_enter()

    def options_onmouseclick(self, event):
        self.options.onmouseclick(event)
        self.on_exit()
        options = OptionsMenu()
        options.run()
        self.reload_titles()
        self.options.onmouseclickup(event)
        self.on_enter()

    def highscores_onmouseclick(self, event):
        self.highscores.onmouseclick(event)
        self.on_exit()
        highscores = HighScoresMenu("sprites/back1.jpg")
        highscores.run()
        self.reload_titles()
        self.highscores.onmouseclickup(event)
        self.on_enter()

    def help_onmouseclick(self, event):
        self.help.onmouseclick(event)
        self.on_exit()
        help = HelpMenu()
        help.run()
        self.help.onmouseclickup(event)
        self.reload_titles()
        self.on_enter()

    def quit_onmouseclick(self, event):
        self.quit.onmouseclick(event)
        self.on_exit()
        exit = ExitMenu()
        exit.run()
        pygame.event.post(pygame.event.Event(QUIT, {}))

    def reload_titles(self):
        self.parser.parse(
            open("languages/MainMenu_" + Constants.LANGUAGE + ".xml"))
        self.title.set_title(self.curHandler.getText("title"))
        self.start.set_title(self.curHandler.getText("start"))
        self.options.set_title(self.curHandler.getText("options"))
        self.highscores.set_title(self.curHandler.getText("highscores"))
        self.help.set_title(self.curHandler.getText("help"))
        self.quit.set_title(self.curHandler.getText("quit"))

    def run(self):
        while 1:

            self.time_speed.tick(Constants.FPS)

            for event in pygame.event.get():
                if event.type == QUIT:
                    os._exit(0)

                elif event.type == KEYDOWN and event.key == K_ESCAPE:
                    self.quit_onmouseclick(event)

                else:
                    pygame.event.post(
                        event
                    )  #Reinject the event into the queue for maybe latter process

            self.widget_man.run()
Пример #14
0
class LanguageMenu(Menu):
	"Language Menu"
	
	def __init__(self):
		"Sets up the Language menu"
		
		Menu.__init__(self,"Language Main Menu","sprites/back1.jpg")

		self.title = GW_Label("Choose Language",(0.5,0.15),(27,22,24))
		
		self.english = GW_Image("sprites/language_engl.png",(0.25,0.35))
		self.english.add_eventhandler("onmouseclick",self.english_onmouseclick)

		self.spanish= GW_Image("sprites/language_espn.png",(0.5,0.35))
		self.spanish.add_eventhandler("onmouseclick",self.spanish_onmouseclick)
		
		self.euskera = GW_Image("sprites/language_eusk.png",(0.75,0.35))
		self.euskera.add_eventhandler("onmouseclick",self.euskera_onmouseclick)

		self.widget_man = GuiWidgetManager([self.title,self.english,self.spanish,self.euskera])
		
		self.time_speed=pygame.time.Clock()
		self.exit=False
		
		self.on_enter()

	def on_enter(self):
		
		self.screen.blit(self.background, (0, 0))	
		pygame.display.flip()
		
		pygame.mixer.music.load(Constants.MENUMUSIC)
		pygame.mixer.music.play(-1)
		self.widget_man.set_draw(True)
		
	def on_exit(self):
		f = FadeTransition(500,Constants.FADECOLOR,"to")
		del f
		self.exit=True
		self.widget_man.set_draw(False)
		pygame.event.clear()
		
	def english_onmouseclick(self,event):
		Constants.LANGUAGE="en"
		self.on_exit()

	def spanish_onmouseclick(self,event):
		Constants.LANGUAGE="es"
		self.on_exit()

	def euskera_onmouseclick(self,event):
		Constants.LANGUAGE="eu"
		self.on_exit()			
				
	def run(self):
		while 1 and self.exit==False:
			for event in pygame.event.get():
				if event.type == QUIT:
					os._exit(0)
										
				else:
					pygame.event.post(event) #Reinject the event into the queue for maybe latter process	
						
			self.widget_man.run()
			self.time_speed.tick(60)
Пример #15
0
class HelpMenu(Menu):
	"Help Menu"
	
	def __init__(self):
		"Sets up the Help menu"
		
		Menu.__init__(self,"MoleFusion Help Menu","sprites/back1.jpg")
		
		self.parser = make_parser()
		self.curHandler = Localization()
		self.parser.setContentHandler(self.curHandler)
		self.parser.parse(open("languages/HelpMenu_" + Constants.LANGUAGE + ".xml"))
	
		self.title = GW_Label(self.curHandler.getText("title"),(0.5,0.1),(27,22,24))
		
		self.help = GW_Image(self.curHandler.getText("help"),(0.5,0.3))
						
		self.returnMain = GW_Button(self.curHandler.getText("returnMain"),(0.5,0.5),(255,255,255))
		self.returnMain.add_eventhandler("onmouseclick",self.returnMain_onmouseclick)
		
		self.widget_man = GuiWidgetManager([self.title,self.help,self.returnMain])
		
		self.time_speed=pygame.time.Clock()
		self.exit=False
		self.on_enter()

	def on_enter(self):
		pygame.event.clear()		
		self.screen.blit(self.background, (0, 0))
		pygame.display.flip()
		self.exit=False
		self.widget_man.set_draw(True)
	
	def on_exit(self):
		f = FadeTransition(500,Constants.FADECOLOR,"to")
		del f
		self.exit=True
		self.widget_man.set_draw(False)
		pygame.event.clear()
		

	def returnMain_onmouseclick(self,event):
		self.returnMain.onmouseclick(event)
		self.on_exit()
	
	def reload_titles(self):
		self.parser.parse(open("languages/OptionsMenu_" + Constants.LANGUAGE + ".xml"))
		self.title.set_title(self.curHandler.getText("title"))
		self.help.set_title(self.curHandler.getText("help"))
		self.returnMain.set_title(self.curHandler.getText("returnMain"))	
				
	def run(self):
		while 1 and self.exit==False:
			self.time_speed.tick(Constants.FPS)
			for event in pygame.event.get():
				if event.type == QUIT:
					os._exit(0)

				elif event.type == KEYDOWN:
					if (not self.widget_man.has_input_focus()):
						if(event.key == K_ESCAPE):
							return
					#else:
					#	pygame.event.post(event) #Reinject the event into the queue for maybe latter process	
				else:
					pygame.event.post(event) #Reinject the event into the queue for maybe latter process	
						
			self.widget_man.run()
Пример #16
0
class HighScoresMenu(Menu):
    "HighScores Menu"

    def __init__(self, background):
        "Set up the HighScores menu"

        Menu.__init__(self, "MoleFusion HighScore Menu", background)

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(
            open("languages/HighScoresMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1),
                              (27, 22, 24))

        self.name_column = GW_Label(self.curHandler.getText("name"),
                                    (0.25, 0.25), (212, 224, 130))
        self.points_column = GW_Label(self.curHandler.getText("points"),
                                      (0.75, 0.25), (212, 224, 130))

        self.returnMain = GW_Button(self.curHandler.getText("returnMain"),
                                    (0.5, 0.9), (255, 255, 255))
        self.returnMain.add_eventhandler("onmouseclick",
                                         self.returnMain_onmouseclick)

        h = HighScores()
        highscorelist = h.get_HighScores()

        self.widgetlist = [
            self.title, self.name_column, self.points_column, self.returnMain
        ]

        for val, i in enumerate(highscorelist[0:5]):
            self.widgetlist.append(
                GW_Label(i.get_name(), (0.25, 0.35 + val / 10.0),
                         (250, 254, 210)))
            self.widgetlist.append(
                GW_Label(str(i.get_points()), (0.75, 0.35 + val / 10.0),
                         (250, 254, 210)))

        self.widget_man = GuiWidgetManager(self.widgetlist)

        self.time_speed = pygame.time.Clock()
        self.exit = False
        self.on_enter()

    def on_enter(self):
        pygame.event.clear()
        self.screen.blit(self.background, (0, 0))
        pygame.display.flip()
        self.exit = False
        self.widget_man.set_draw(True)

    def on_exit(self):
        pygame.event.clear()
        f = FadeTransition(500, Constants.FADECOLOR, "to")
        del f
        self.exit = True
        self.widget_man.set_draw(False)

    def returnMain_onmouseclick(self, event):
        self.returnMain.onmouseclick(event)
        self.on_exit()

    def run(self):
        while 1 and self.exit == False:
            self.time_speed.tick(Constants.FPS)
            for event in pygame.event.get():
                if event.type == QUIT:
                    os._exit(0)

                elif event.type == KEYDOWN:
                    if (not self.widget_man.has_input_focus()):
                        if (event.key == K_ESCAPE):
                            return
                    #else:
                    #	pygame.event.post(event) #Reinject the event into the queue for maybe latter process
                else:
                    pygame.event.post(
                        event
                    )  #Reinject the event into the queue for maybe latter process

            self.widget_man.run()
Пример #17
0
class HighScoresMenu(Menu):
	"HighScores Menu"
	
	def __init__(self,background):
		"Set up the HighScores menu"
		
		Menu.__init__(self,"MoleFusion HighScore Menu",background)
		
		self.parser = make_parser()
		self.curHandler = Localization()
		self.parser.setContentHandler(self.curHandler)
		self.parser.parse(open("languages/HighScoresMenu_" + Constants.LANGUAGE + ".xml"))
	
		self.title = GW_Label(self.curHandler.getText("title"),(0.5,0.1),(27,22,24))
		
		self.name_column = GW_Label(self.curHandler.getText("name"),(0.25,0.25),(212,224,130))
		self.points_column = GW_Label(self.curHandler.getText("points"),(0.75,0.25),(212,224,130))
		
		self.returnMain = GW_Button(self.curHandler.getText("returnMain"),(0.5,0.9),(255,255,255))
		self.returnMain.add_eventhandler("onmouseclick",self.returnMain_onmouseclick)
		
		h = HighScores()
		highscorelist = h.get_HighScores()

		self.widgetlist = [self.title,self.name_column,self.points_column,self.returnMain]
		
		for val,i in enumerate(highscorelist[0:5]):
			self.widgetlist.append(GW_Label(i.get_name(),(0.25,0.35+val/10.0),(250,254,210)))
			self.widgetlist.append(GW_Label(str(i.get_points()),(0.75,0.35+val/10.0),(250,254,210)))
				
		self.widget_man = GuiWidgetManager(self.widgetlist)
		
		self.time_speed=pygame.time.Clock()
		self.exit=False
		self.on_enter()

	def on_enter(self):
		pygame.event.clear()		
		self.screen.blit(self.background, (0, 0))
		pygame.display.flip()
		self.exit=False
		self.widget_man.set_draw(True)
	
	def on_exit(self):
		pygame.event.clear()
		f = FadeTransition(500,Constants.FADECOLOR,"to")
		del f
		self.exit=True
		self.widget_man.set_draw(False)
		
	def returnMain_onmouseclick(self,event):
		self.returnMain.onmouseclick(event)
		self.on_exit()
				
	def run(self):
		while 1 and self.exit==False:
			self.time_speed.tick(Constants.FPS)
			for event in pygame.event.get():
				if event.type == QUIT:
					os._exit(0)

				elif event.type == KEYDOWN:
					if (not self.widget_man.has_input_focus()):
						if(event.key == K_ESCAPE):
							return
					#else:
					#	pygame.event.post(event) #Reinject the event into the queue for maybe latter process	
				else:
					pygame.event.post(event) #Reinject the event into the queue for maybe latter process	
						
			self.widget_man.run()
Пример #18
0
class OptionsMenu(Menu):
    "Options Menu"

    def __init__(self):
        "Sets up the options menu"

        Menu.__init__(self, "MoleFusion Options Menu", "sprites/back1.jpg")

        self.parser = make_parser()
        self.curHandler = Localization()
        self.parser.setContentHandler(self.curHandler)
        self.parser.parse(open("languages/OptionsMenu_" + Constants.LANGUAGE + ".xml"))

        self.title = GW_Label(self.curHandler.getText("title"), (0.5, 0.1), (27, 22, 24))

        self.name = GW_Label(self.curHandler.getText("name"), (0.5, 0.2), (255, 255, 255))
        self.inputname = GW_TextInput((0.5, 0.3), 24, 0.4, Constants.PLAYERNAME)

        self.language = GW_Button(self.curHandler.getText("language"), (0.5, 0.5), (255, 255, 255))
        self.language.add_eventhandler("onmouseclick", self.language_onmouseclick)

        self.returnMain = GW_Button(self.curHandler.getText("returnMain"), (0.5, 0.8), (255, 255, 255))
        self.returnMain.add_eventhandler("onmouseclick", self.returnMain_onmouseclick)

        self.widget_man = GuiWidgetManager([self.title, self.name, self.inputname, self.language, self.returnMain])

        self.time_speed = pygame.time.Clock()
        self.exit = False
        self.on_enter()

    def on_enter(self):
        pygame.event.clear()
        self.screen.blit(self.background, (0, 0))
        pygame.display.flip()
        self.exit = False
        self.widget_man.set_draw(True)

    def on_exit(self):
        f = FadeTransition(500, Constants.FADECOLOR, "to")
        del f
        Constants.PLAYTIME = pygame.mixer.music.get_pos()
        self.exit = True
        self.widget_man.set_draw(False)
        Constants.PLAYERNAME = self.inputname.get_Text()
        pygame.event.clear()

    def language_onmouseclick(self, event):
        self.language.onmouseclick(event)
        self.on_exit()
        l = LanguageMenu()
        l.run()
        self.language.onmouseclickup(event)
        self.reload_titles()
        self.on_enter()
        pygame.mixer.music.play()

    def returnMain_onmouseclick(self, event):
        self.returnMain.onmouseclick(event)
        self.on_exit()

    def reload_titles(self):
        self.parser.parse(open("languages/OptionsMenu_" + Constants.LANGUAGE + ".xml"))
        self.name.set_title(self.curHandler.getText("name"))
        self.title.set_title(self.curHandler.getText("title"))
        self.language.set_title(self.curHandler.getText("language"))
        self.returnMain.set_title(self.curHandler.getText("returnMain"))

    def run(self):
        while 1 and self.exit == False:
            self.time_speed.tick(Constants.FPS)
            for event in pygame.event.get():
                if event.type == QUIT:
                    os._exit(0)

                elif event.type == KEYDOWN:
                    if not self.widget_man.has_input_focus():
                        if event.key == K_ESCAPE:
                            return
                    else:
                        pygame.event.post(event)  # Reinject the event into the queue for maybe latter process
                else:
                    pygame.event.post(event)  # Reinject the event into the queue for maybe latter process

            self.widget_man.run()