Example #1
0
 def _update(self, events):
     self.has_changed = True
     if self.midi_in_button.update(events):
         devices = [[od[0], od[0]] for od in midi.inDevices()]
         screen.stack.append(ChoiceList(devices, 'In Device'))
     self.channel_counter.update(events)
     if self.midi_out_button.update(events):
         devices = [[od[0], od[0]] for od in midi.outDevices()]
         screen.stack.append(ChoiceList(devices, 'Out Device'))
     self.bpm_counter.update(events)
Example #2
0
class MainMenu(Menu):
	"""Het hoofd menu als je het spel opstart.
	"""
	
	def __init__(self, gui):
		Menu.__init__(self, gui)

		# Lijst met keuzes.
		self.choices = []
		self.choices.append("New game")
		self.choices.append("Load game")
		self.choices.append("Options")
		self.choices.append("Quit")
		
		# Maak choice list aan.
		self.choiceList = ChoiceList(self.gui.getScreen(), self.choices, (300, 100), self.onSelection)
		
	def handleInput(self, events):
		"""Input afhandelen.
		"""
		self.choiceList.handleInput(events)

	def draw(self):
		"""Tekenen.
		"""
		screen = self.gui.getScreen()

		# Scherm zwart maken.
		screen.fill((0, 0, 0))
		
		# Choice list tekenen.
		self.choiceList.draw()
		
	def onSelection(self, index):
		"""Methode die wordt aangeroepen als er een selectie is gemaakt.
		"""
		
		# Nieuw spel starten.
		if self.choices[index] == "New game":
			self.gui.setCurrentMenu(gamemenu.GameMenu(self.gui))

		# Spel laden.
		elif self.choices[index] == "Load game":
			self.gui.setCurrentMenu(loadmenu.LoadMenu(self.gui))

		# Afsluiten.
		elif self.choices[index] == "Quit":
			sys.exit(0)
Example #3
0
class ESCMenu(Menu):
	"""Menu voor als je op ESC drukt tijdens het spelen.
	"""
	
	def __init__(self, gui):
		Menu.__init__(self, gui)

		# Lijst met keuzes.
		self.choices = []
		self.choices.append("Back")
		self.choices.append("Options")
		self.choices.append("Main Menu")
		self.choices.append("Quit")
		
		# Maak choice list aan.
		self.choiceList = ChoiceList(self.gui.getScreen(), self.choices, (300, 100), self.onSelection)
		
	def handleInput(self, events):
		"""Input afhandelen.
		"""
		self.choiceList.handleInput(events)

	def draw(self):
		"""Tekenen.
		"""
		screen = self.gui.getScreen()

		# Scherm zwart maken.
		screen.fill((0, 0, 0))
		
		# Choice list tekenen.
		self.choiceList.draw()
		
	def onSelection(self, index):
		"""Methode die wordt aangeroepen als er een selectie is gemaakt.
		"""
		# Terug naar het spel.
		if self.choices[index] == "Back":
			self.gui.setCurrentMenu(gamemenu.GameMenu(self.gui))

		# Main menu.
		elif self.choices[index] == "Main Menu":
			self.gui.setCurrentMenu(mainmenu.MainMenu(self.gui))

		# Afsluiten.
		elif self.choices[index] == "Quit":
			sys.exit(0)
Example #4
0
	def __init__(self, gui):
		Menu.__init__(self, gui)

		# Lijst met keuzes.
		self.choices = []
		self.choices.append("Game #01")
		self.choices.append("Game #02")
		self.choices.append("Game #03")
		self.choices.append("Back")
		
		# Maak choice list aan.
		self.choiceList = ChoiceList(self.gui.getScreen(), self.choices, (300, 100), self.onSelection)
Example #5
0
	def __init__(self, gui):
		Menu.__init__(self, gui)

		# Lijst met keuzes.
		self.choices = []
		self.choices.append("New game")
		self.choices.append("Load game")
		self.choices.append("Options")
		self.choices.append("Quit")
		
		# Maak choice list aan.
		self.choiceList = ChoiceList(self.gui.getScreen(), self.choices, (300, 100), self.onSelection)
Example #6
0
class LoadMenu(Menu):
	"""Menu om een game te loaden.
	"""
	
	def __init__(self, gui):
		Menu.__init__(self, gui)

		# Lijst met keuzes.
		self.choices = []
		self.choices.append("Game #01")
		self.choices.append("Game #02")
		self.choices.append("Game #03")
		self.choices.append("Back")
		
		# Maak choice list aan.
		self.choiceList = ChoiceList(self.gui.getScreen(), self.choices, (300, 100), self.onSelection)

	def handleInput(self, events):
		"""Input afhandelen.
		"""
		self.choiceList.handleInput(events)

	def draw(self):
		"""Tekenen.
		"""
		screen = self.gui.getScreen()

		# Scherm zwart maken.
		screen.fill((0, 0, 0))
		
		# Choice list tekenen.
		self.choiceList.draw()
		
	def onSelection(self, index):
		"""Methode die wordt aangeroepen als er een selectie is gemaakt.
		"""
		# Terug naar main menu.
		if self.choices[index] == "Back":
			self.gui.setCurrentMenu(mainmenu.MainMenu(self.gui))
Example #7
0
    def _update(self, events):
        self.has_changed = True
        self.name_field.update(events)
        self.channel_counter.update(events)
        self.measures_counter.update(events)
        if self.bank_counter.update(events) and not self.new:
            part = self.clip.part
            bank = self.bank_counter.value
            program = self.program_counter.value
            if bank > 0 and program > 0:
                midi.out.write_short(midi.CC + part.channel, 32, bank - 1)
                midi.out.write_short(midi.PC + part.channel, program - 1)
        if self.program_counter.update(events) and not self.new:
            part = self.clip.part
            program = self.program_counter.value
            if program > 0:
                midi.out.write_short(midi.PC + part.channel, program - 1)
        if self.clip is None and self.editor_button.clicked(events):
            screen.stack.append(ChoiceList(editors.editors, 'Editor'))
        if self.clip is None and self.instrument_button.clicked(events):
            screen.stack.append(ChoiceList(instruments, 'Instrument'))

        for widget in self.editor_gui:
            widget.update(events)
Example #8
0
 def keydown_events(self, keyevents):
     """Handle pygame keydown events."""
     mods = pygame.key.get_mods()
     for e in keyevents:
         if mods & pygame.KMOD_SHIFT:
             pass
         elif mods & pygame.KMOD_CTRL:
             if e.key == pygame.K_s:
                 self.save_as()
         elif mods & pygame.KMOD_ALT:
             # Change scene
             if e.key == pygame.K_0:
                 self.goto_scene(9)
             else:
                 try:
                     scene = int(e.unicode.encode('utf-8'))
                     self.goto_scene(scene - 1)
                 except:
                     pass
         else:
             if e.key == pygame.K_q:
                 pygame.event.post(pygame.event.Event(pygame.QUIT))
             elif e.key == pygame.K_SPACE:
                 sequencer.toggle()
             elif e.key == pygame.K_o:
                 # Load file
                 files = [[f[len("projects/"):], f]
                          for f in glob('projects/*.yaml')]
                 screen.stack.append(ChoiceList(files, 'Load project'))
             elif e.key == pygame.K_s:
                 # Save
                 path = sequencer.project['path']
                 if path is None:
                     self.save_as()
                 else:
                     sequencer.save(path)
             elif e.key == pygame.K_v:
                 # Paste
                 if self.clip_copy is not None:
                     sequencer.scene().append(self.clip_copy)
                     self.update_partrects()
             elif e.key == pygame.K_p:
                 # Preferences
                 screen.stack.append(ConfigScreen())