1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import FSM
- import utils as u
- import menus as m
- #====================================
-
- 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 SelectSound(State):
- def __init__(self,FSM):
- super(SelectSound, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "SelSou"
- o.pub.register("beat", self)
- u.draw_header(o)
- self.draw_square()
- o.update_display(0)
- super(SelectSound, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- if o.keyState[16] == 1:
- m.draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- u.draw_header(o)
- self.draw_square()
- o.update_display(0)
-
- if o.keyState[16] == 2:
- if o.keyState[0] == 1:
- self.FSM.ToTransition('toMain')
- else:
- _id = 0
- for k in o.keyState:
- if _id > 15:
- pass
- else:
- if k == 1:
- o.eSound = _id
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.draw.text((0, 0), "SelSou", font=o.h1, fill=o.light_blue)
- o.draw.text((20, 60), str(o.eSound), font=o.h2, fill=o.light_grey)
- self.draw_square()
- o.update_display(0)
- self.FSM.owner.soundSlots[_id].play()
- #print('now editing sound ', _id)
- _id += 1
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=(0, 0, 0))
- o.draw.text((0, 0), "SelSou", font=o.h1, fill="#FFFFFF")
- o.draw.text((0, 20), str(o.eSound), font=o.h2, fill="#FFFFFF")
- o.update_display(0)
- u.play_seq(o, message)
-
- def draw_square(self):
- o = self.FSM.owner
- size = 32
- og_x = 110
- o_x = og_x
- o_y = 0
- _id = 0
-
- for n in o.soundSlots[o.eSound].notes[o.ePattern]:
- if _id == o.eSound:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.light_grey)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.dark_grey)
- o_x = o_x + size
- _id += 1
- if _id % 4 == 0:
- o_y += size
- o_x = og_x
-
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
|