a658e8a62e568a8a14300ee1946df52363068ec4
2 Created on 28 aout 2009
4 @author: Samuel Benveniste
16 from gui
.constants
import *
18 from gui
.PlayingScreen
import PlayingScreen
19 from gui
.SongPlayingScreen
import SongPlayingScreen
20 from gui
.InstrumentChoice
import InstrumentChoice
21 from instruments
.Instrument
import Instrument
22 from cursor
.WarpingCursor
import *
23 from controllers
.Wiimote
import Wiimote
24 from songs
.Song
import Song
33 def __init__(self
,eventLog
,scale
,extendedScale
,cascade
,song
,mode
,activeWiimotes
,easyMode
= True):
37 self
.eventLog
= eventLog
39 self
.extendedScale
= extendedScale
40 self
.cascade
= cascade
42 self
.activeWiimotes
= activeWiimotes
45 if __name__
== '__main__':
47 f
= file('../../saves/4-12-2009-B1-v50-1.mwi', 'r')
48 unpickler
= pickle
.Unpickler(f
)
49 log
= unpickler
.load()
54 instruments
= [Instrument(scaleDict
["majorScale"], i
+ 1, "".join(["../instruments/instrumentImages/", instrumentImagePathList
[i
], ".jpg"]), octaves
[i
]) for i
in range(9)]
56 joys
= [[id,pygame
.joystick
.Joystick(id).get_name()] for id in range(pygame
.joystick
.get_count())]
58 if joy
[1] in joyNames
:
59 pygame
.joystick
.Joystick(joy
[0]).init()
61 ports
= [pygame
.midi
.get_device_info(id)[1] for id in range(pygame
.midi
.get_count())]
62 portOffset
= ports
.index(portNames
[0])
65 modeResolution
= (1024,768)
66 window
= pygame
.display
.set_mode(modeResolution
,pygame
.FULLSCREEN
)
67 screen
= pygame
.display
.get_surface()
68 clock
= pygame
.time
.Clock()
69 cursorImages
=[['../cursor/cursorImages/black/10.png'],['../cursor/cursorImages/red/10.png'],['../cursor/cursorImages/blue/10.png'],['../cursor/cursorImages/green/10.png']]
70 durations
= [75 for i
in range(len(cursorImages
[0]))]
73 cursors
= [WarpingCursor(None, cursorImages
[i
], durations
, (300 * i
, 300 * i
),flashImage
= '../cursor/cursorImages/black/flash.png' ) for i
in range(wiimoteCount
)]
74 wiimotes
= [Wiimote(i
, i
+ portOffset
, None, None, cursors
[i
]) for i
in range(wiimoteCount
)]
79 log
.extendedScale
= log
.song
.requiresExtendedScale
83 log
.extendedScale
= log
.song
.requiresExtendedScale
87 log
.extendedScale
= log
.song
.requiresExtendedScale
91 log
.extendedScale
= True
95 choice
= InstrumentChoice(instruments
, wiimotes
, window
, screen
, clock
, joys
, portOffset
,log
.activeWiimotes
, eventLog
= log
.eventLog
,scaleFactor
= songScaleFactor
,replay
= True)
96 play
= SongPlayingScreen(choice
, log
.song
,log
.cascade
, log
.extendedScale
,log
.easyMode
)
101 log
.extendedScale
= False
104 log
.extendedScale
= True
107 log
.extendedScale
= False
110 log
.extendedScale
= True
113 choice
= InstrumentChoice(instruments
, wiimotes
, window
, screen
, clock
, joys
, portOffset
,log
.activeWiimotes
,eventLog
= log
.eventLog
,replay
= True)
114 play
= PlayingScreen(choice
, None,log
.cascade
, log
.extendedScale
)
116 while play
.backToInstrumentChoice
== True :
118 for wiimote
in wiimotes
:
121 wiimotes
= [Wiimote(i
, i
+ portOffset
, None, None, cursors
[i
]) for i
in range(wiimoteCount
)]
122 previousEventLog
= play
.eventLog
124 if log
.song
!= None :
125 choice
= InstrumentChoice(instruments
, wiimotes
,window
, screen
, clock
, joys
, portOffset
, log
.activeWiimotes
,eventLog
= previousEventLog
, replay
= True, scaleFactor
= songScaleFactor
)
126 play
= SongPlayingScreen(choice
, log
.song
, False, log
.extendedScale
,log
.easyMode
)
128 choice
= InstrumentChoice(instruments
, wiimotes
, log
.window
, screen
, clock
, joys
, portOffset
,log
.activeWiimotes
, eventLog
= previousEventLog
, replay
= True)
129 play
= PlayingScreen(choice
, None, log
.cascade
, log
.extendedScale
)
131 for wiimote
in wiimotes
: