123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import FSM
- import utils as u
- import menus as m
- from itertools import cycle
- #====================================
- State = type("State", (object,), {})
- #====================================
- class State(object):
- def __init__(self, FSM):
- self.FSM = FSM
- def Enter(self):
- pass
- def Execute(self):
- pass
- def Exit(self):
- pass
- #====================================
- class EditSong(State):
- def __init__(self,FSM):
- super(EditSong, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- o.header_text = "Edit Song"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- u.draw_header(o)
- self.draw_main(o)
- o.update_display(0)
- self.new_song = []
- super(EditSong, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- m.menu1_actions(self, o)
- m.menu2_actions_song(self, o)
- if o.keyState[16] == 1:
- m.draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- u.draw_header(o)
- self.draw_main(o)
- o.update_display(0)
- if o.keyState[17] == 1:
- m.draw_menu2_song(o)
- o.update_display(0)
- elif o.keyState[17] == 4:
- u.draw_header(o)
- self.draw_main(o)
- o.update_display(0)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- _id = 0
- for k in self.FSM.owner.keyState:
- if k == 1 and _id < 16:
- self.new_song.append((_id + (o.pat_bank * 16)))
- u.draw_header(o)
- self.draw_main(o)
- o.update_display(0)
- _id += 1
-
-
- def draw_main(self, o):
- ypos = 35
- ysize = 20
- tmp_song = [8, 6, 7, 5, 3, 0, 9]
- lines = u.breakup_song_text(o.song)
-
- if self.new_song != []:
- lines = u.breakup_song_text(self.new_song)
- o.center_block("New Song", o.h2, [0, ypos, o.width, ypos + ysize], o.pink)
- else:
- o.center_block("Current Song", o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
-
- ypos += ysize
- o.center_block(lines[0], o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
- ypos += ysize
- o.center_block(lines[1], o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
- ypos += ysize
- o.center_block(lines[2], o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
- ypos += ysize
- o.center_block(lines[3], o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- u.play_seq(o, message)
-
- def Exit(self):
- o = self.FSM.owner
- self.FSM.owner.pub.unregister("beat", self)
- if self.new_song != []:
- o.song = self.new_song
- o.songCycle = cycle(self.new_song)
- self.curPattern = next(o.songCycle)
- o.songStart = o.curPattern
-
- #====================================
|