Module SongChoosingScene
[hide private]
[frames] | no frames]

Source Code for Module SongChoosingScene

 1  ##################################################################### 
 2  # -*- coding: iso-8859-1 -*-                                        # 
 3  #                                                                   # 
 4  # Frets on Fire                                                     # 
 5  # Copyright (C) 2006 Sami Kyöstilä                                  # 
 6  #                                                                   # 
 7  # This program is free software; you can redistribute it and/or     # 
 8  # modify it under the terms of the GNU General Public License       # 
 9  # as published by the Free Software Foundation; either version 2    # 
10  # of the License, or (at your option) any later version.            # 
11  #                                                                   # 
12  # This program is distributed in the hope that it will be useful,   # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of    # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     # 
15  # GNU General Public License for more details.                      # 
16  #                                                                   # 
17  # You should have received a copy of the GNU General Public License # 
18  # along with this program; if not, write to the Free Software       # 
19  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,        # 
20  # MA  02110-1301, USA.                                              # 
21  ##################################################################### 
22   
23  from Scene import SceneServer, SceneClient 
24  import Player 
25  import Dialogs 
26  import Song 
27  import Config 
28  from Language import _ 
29   
30  # save chosen song into config file 
31  Config.define("game", "selected_library",  str, "") 
32  Config.define("game", "selected_song",     str, "") 
33   
34 -class SongChoosingScene:
35 pass
36
37 -class SongChoosingSceneServer(SongChoosingScene, SceneServer):
38 pass
39
40 -class SongChoosingSceneClient(SongChoosingScene, SceneClient):
41 - def createClient(self, libraryName = None, songName = None):
42 self.wizardStarted = False 43 self.libraryName = libraryName 44 self.songName = songName
45
46 - def run(self, ticks):
47 SceneClient.run(self, ticks) 48 49 if not self.wizardStarted: 50 self.wizardStarted = True 51 52 if not self.songName: 53 while True: 54 self.libraryName, self.songName = \ 55 Dialogs.chooseSong(self.engine, \ 56 selectedLibrary = Config.get("game", "selected_library"), 57 selectedSong = Config.get("game", "selected_song")) 58 59 if not self.songName: 60 self.session.world.finishGame() 61 return 62 63 Config.set("game", "selected_library", self.libraryName) 64 Config.set("game", "selected_song", self.songName) 65 66 info = Song.loadSongInfo(self.engine, self.songName, library = self.libraryName) 67 d = Dialogs.chooseItem(self.engine, info.difficulties, 68 _("Choose a difficulty:"), selected = self.player.difficulty) 69 if d: 70 self.player.difficulty = d 71 break 72 else: 73 info = Song.loadSongInfo(self.engine, self.songName, library = self.libraryName) 74 75 # Make sure the difficulty we chose is available 76 if not self.player.difficulty in info.difficulties: 77 self.player.difficulty = info.difficulties[0] 78 79 self.session.world.deleteScene(self) 80 self.session.world.createScene("GuitarScene", libraryName = self.libraryName, songName = self.songName)
81