log dans un fichier horodaté.
[minwii.git] / src / logging.disabled / FamiliarizerLog.py
1 '''
2 Created on 28 aout 2009
3
4 @author: Samuel Benveniste
5 '''
6
7 import os
8 import sys
9 import subprocess
10 import re
11
12 import pygame
13 import pygame.midi
14 import pickle
15
16 from gui.constants import *
17
18 from gui.PlayingScreen import PlayingScreen
19 from gui.InstrumentChoice import InstrumentChoice
20 from instruments.Instrument import Instrument
21 from cursor.WarpingCursor import *
22 from controllers.Wiimote import Wiimote
23 from songs.Song import Song
24 from gui.StaticFamiliarizer import StaticFamiliarizer
25 from gui.SongFamiliarizer import SongFamiliarizer
26 from gui.SongPlayingScreen import SongPlayingScreen
27 from gui.DummyInstrumentChoice import DummyInstrumentChoice
28
29 class FamiliarizerLog():
30 '''
31 classdocs
32 '''
33
34 def __init__(self,eventLog,level,activeWiimotes):
35 '''
36 Constructor
37 '''
38 self.eventLog = eventLog
39 self.level = level
40 self.activeWiimotes = activeWiimotes
41 self.scale = scaleDict["majorScale"]
42
43 if __name__ == '__main__':
44
45 f = file('../../../saves/19-01-2009-testcoll1-v65-1.fmwi', 'r')
46 unpickler = pickle.Unpickler(f)
47 log = unpickler.load()
48 f.close()
49
50 pygame.init()
51 modeResolution = (1024,768)
52 window = pygame.display.set_mode(modeResolution,pygame.FULLSCREEN)
53 pygame.midi.init()
54 instruments = [Instrument(log.scale, i + 1, "".join(["../instruments/instrumentImages/", instrumentImagePathList[i], ".jpg"]), octaves[i]) for i in range(9)]
55
56 joys = [[id,pygame.joystick.Joystick(id).get_name()] for id in range(pygame.joystick.get_count())]
57 for joy in joys:
58 if joy[1] in joyNames:
59 pygame.joystick.Joystick(joy[0]).init()
60
61 ports = [pygame.midi.get_device_info(id)[1] for id in range(pygame.midi.get_count())]
62 portOffset = ports.index(portNames[0])
63 print(portOffset)
64
65 screen = pygame.display.get_surface()
66 clock = pygame.time.Clock()
67 cursorImages=[['../cursor/cursorImages/black/10.png'],['../cursor/cursorImages/red/10.png'],['../cursor/cursorImages/blue/10.png'],['../cursor/cursorImages/green/10.png']]
68 durations = [75 for i in range(len(cursorImages))]
69
70 extsc = True
71 casc = False
72 easyMode = True
73
74 song = Song(scaleDict["majorScale"],[3,9,6,4,1,8,5,7,2,10],True)
75
76 wiimoteCount = 4
77
78 cursors = [WarpingCursor(None, cursorImages[i], durations, (300 * i, 300 * i),'../cursor/cursorImages/black/flash.png') for i in range(wiimoteCount)]
79 wiimotes = [Wiimote(i, i + portOffset, None, instruments[0], cursors[i]) for i in range(wiimoteCount)]
80 dummyInstrumentChoice = DummyInstrumentChoice(wiimotes, window, screen, clock, joys, portOffset, log.activeWiimotes)
81 if log.level < 2 :
82 familiarize = StaticFamiliarizer(wiimotes, window, screen, clock, joys, portOffset,log.activeWiimotes,level = log.level,eventLog = log.eventLog,replay = True)
83 elif log.level == 2 :
84 familiarize = SongFamiliarizer(wiimotes, window, screen, clock, joys, portOffset,song,log.activeWiimotes,casc,extsc,easyMode,eventLog = log.eventLog,replay = True)
85 else :
86 familiarize = SongPlayingScreen(dummyInstrumentChoice,songDict["clairdelalune"],easyMode = True,eventLog = log.eventLog,replay = True)
87
88 while familiarize.nextLevel != None :
89 if familiarize.nextLevel < 2 :
90 familiarize = StaticFamiliarizer(wiimotes, window, screen, clock, joys, portOffset,log.activeWiimotes,level = familiarize.nextLevel,eventLog = familiarize.eventLog,replay = True)
91 elif familiarize.nextLevel == 2 :
92 familiarize = SongFamiliarizer(wiimotes, window, screen, clock, joys, portOffset,song,log.activeWiimotes,casc,extsc,easyMode,eventLog = familiarize.eventLog,replay = True)
93 else :
94 familiarize = SongPlayingScreen(dummyInstrumentChoice,songDict["clairdelalune"],easyMode = True,eventLog = familiarize.eventLog,replay = True)
95
96 for wiimote in wiimotes:
97 del wiimote.port
98
99 pygame.midi.quit()
100 pygame.quit()