Ejemplo n.º 1
0
 def on_slide_timer(self):
     """change the image(s)"""
     layout_path = os.path.dirname(self.WinMain.layout_file)
     if self.running:
         if self.saver_type == 'slideshow':
             #change images
             self.game_idx = self.WinMain.get_random_game_idx()
             game_info = filters.get_game_dict(
                 self.WinMain.lsGames[self.game_idx])
             for i, img in enumerate(self._main_images):
                 img_path = self.WinMain.emu_ini.get(
                     'artwork_%s_image_path' % (i + 1))
                 if img.get_property('visible'):
                     #get image filename
                     img_filename = self.WinMain.get_artwork_image(
                         img_path, layout_path, game_info,
                         self.WinMain.current_emu, (i + 1))
                     #display image
                     self.display_scaled_image(
                         img, img_filename, self.WinMain.keep_aspect,
                         img.get_data('text-rotation'))
         elif self.saver_type == 'movie':
             #video working
             if not self.video_enabled:
                 return
             #play a movie
             movie_found = False
             cnt = 0
             while not movie_found or cnt > 10000:
                 cnt += 1  #ensure we don't go into a infinite loop
                 self.game_idx = self.WinMain.get_random_game_idx()
                 game_info = filters.get_game_dict(
                     self.WinMain.lsGames[self.game_idx])
                 #vid file
                 vid_filename = self.get_video_file(
                     self.WinMain.emu_ini.get('movie_path'), game_info)
                 movie_found = os.path.isfile(vid_filename)
                 if movie_found:
                     #stop existing vid playing
                     if self.video_playing:
                         self.video_playing = False
                         self.video_player.stop()
                     #play new vid
                     self.video_playing = True
                     self.movie_type = 'scrsaver'
                     self.drwVideo.set_property('visible', True)
                     self.video_player.play(vid_filename)
         #set desc
         self.lblGameDescription.set_text(
             self.WinMain.lsGames[self.game_idx][GL_GAME_NAME])
         #collect any memory "leaks"
         gc.collect()
     else:
         #stop, so hide window
         #self.winScrSaver.hide()
         #self.WinMain.winMain.show()
         self.WinMain.hide_window('scrsaver')
     #done
     return self.running
Ejemplo n.º 2
0
 def on_slide_timer(self):
     """change the image(s)"""
     layout_path = os.path.dirname(self.WinMain.layout_file)
     if self.running:
         if self.saver_type == 'slideshow':
             #change images
             self.game_idx = self.WinMain.get_random_game_idx()
             game_info = filters.get_game_dict(self.WinMain.lsGames[self.game_idx])
             for i, img in enumerate(self._main_images):
                 img_path = self.WinMain.emu_ini.get('artwork_%s_image_path' % (i + 1))
                 if img.get_property('visible'):
                     #get image filename
                     img_filename = self.WinMain.get_artwork_image(
                         img_path,
                         layout_path,
                         game_info,
                         self.WinMain.current_emu,
                         (i + 1))
                     #display image
                     self.display_scaled_image(img, img_filename, self.WinMain.keep_aspect, img.get_data('text-rotation'))
         elif self.saver_type == 'movie':
             #video working
             if not self.video_enabled:
                 return
             #play a movie
             movie_found = False
             cnt = 0
             while not movie_found or cnt > 10000:
                 cnt += 1 #ensure we don't go into a infinite loop
                 self.game_idx = self.WinMain.get_random_game_idx()
                 game_info = filters.get_game_dict(self.WinMain.lsGames[self.game_idx])
                 #vid file
                 vid_filename = self.get_video_file(
                     self.WinMain.emu_ini.get('movie_path'),
                     game_info)
                 movie_found = os.path.isfile(vid_filename)
                 if movie_found:
                     #stop existing vid playing
                     if self.video_playing:
                         self.video_playing = False
                         self.video_player.stop()
                     #play new vid
                     self.video_playing = True
                     self.movie_type = 'scrsaver'
                     self.drwVideo.set_property('visible', True)
                     self.video_player.play(vid_filename)
         #set desc
         self.lblGameDescription.set_text(self.WinMain.lsGames[self.game_idx][GL_GAME_NAME])
         #collect any memory "leaks"
         gc.collect()
     else:
         #stop, so hide window
         #self.winScrSaver.hide()
         #self.WinMain.winMain.show()
         self.WinMain.hide_window('scrsaver')
     #done
     return self.running
Ejemplo n.º 3
0
 def menu_selected(self, *args):
     """menu item selected"""
     if len(self.lsOptions) <= 0:
         #no options!
         return
     #get selected item
     menu_desc, menu_item = self.lsOptions[self.sclOptions.get_selected()]
     if self.current_menu == 'main':
         #main menu
         if menu_item == 'random':
             #pick random game
             self.WinMain.sclGames.set_selected(self.WinMain.get_random_game_idx())
             self.WinMain.sclGames.update()
         elif menu_item == 'about':
             #about
             self.show_about_dialog('Wah!Cade', CONFIG_DIR)
             self.WinMain.hide_window('options')
         else:
             #show appropriate menu
             self.set_menu(menu_item, menu_desc)
     elif self.current_menu == 'emu_list':
         #emulator list menu, so switch to selected emulator
         self.WinMain.hide_window('options')
         self.WinMain.load_emulator(menu_item)
     elif self.current_menu == 'game_list':
         #game list menu, so switch to selected list
         self.WinMain.hide_window('options')
         self.WinMain.current_list_idx = int(menu_item)
         self.WinMain.load_list()
     elif self.current_menu == 'list_options':
         #games list options menu
         if menu_item == 'remove_from_list':
             #remove current game from current list
             self.WinMain.remove_current_game()
         else:
             #show menu
             self.set_menu(menu_item, menu_desc)
     elif self.current_menu == 'add_to_list':
         #check game isn't already on list
         new_list_filename = os.path.join(
             CONFIG_DIR,
             'files',
             '%s-%s.lst' % (self.WinMain.current_emu, int(menu_item)))
         selected_game = self.WinMain.lsGames[self.WinMain.sclGames.get_selected()]
         new_list = filters.read_filtered_list(new_list_filename)
         if selected_game not in new_list:
             #add current selected game to chosen game list
             filters.add_game_to_filtered_list(
                 gd = filters.get_game_dict(selected_game),
                 list_filename = new_list_filename)
         self.WinMain.hide_window('options')
     elif self.current_menu == 'generate_ftr':
         #filtered lists
         if menu_item == 'ftr:filter_type':
             #change filter type (display clones)
             self._display_clone_idx += 1
             if self._display_clone_idx > 2:
                 self._display_clone_idx = 0
             self.on_sclOptions_changed()
             self.WinMain.current_filter_changed = True
             self.WinMain.current_filter['filter_type'] = self._display_clone_idx
         else:
             #show filter... menu
             self.set_menu(menu_item, menu_desc)
     elif self.current_menu.startswith('ftr:'):
         #update current filter
         self.WinMain.current_filter_changed = True
         ftr_section = self.WinMain.current_filter[self.current_menu[4:]]
         if self.sclOptions.get_selected() == 0:
             #set all = yes
             for k in ftr_section.keys():
                 ftr_section[k] = True
         elif self.sclOptions.get_selected() == 1:
             #set all = no
             for k in ftr_section.keys():
                 ftr_section[k] = False
         else:
             #set yes / no
             item = self.lsOptions[self.sclOptions.get_selected()][0]
             yesno = (self.lblSettingValue.get_text().lower() == 'yes')
             ftr_section[item] = not yesno
             self.on_sclOptions_changed()
     elif self.current_menu == 'find':
         #find by letter
         self.find_game('add', menu_item[5:])
     elif self.current_menu == 'music':
         if menu_item == 'music_play':
             #play / pause
             #print "music_play"
             self.WinMain.gstMusic.play_toggle()
         elif menu_item == 'next_track':
             self.WinMain.gstMusic.next_track()
         elif menu_item == 'previous_track':
             self.WinMain.gstMusic.previous_track()
         elif menu_item == 'show_music_dir':
             #select music dir
             self.set_menu('music_dir')
     elif self.current_menu == 'music_dir':
         #select music dir
         if menu_item == 'music_dir':
             #dir selected
             if menu_desc == '..':
                 #go to parent dir
                 new_music_dir = os.path.dirname(self.WinMain.gstMusic.current_dir)
             else:
                 #change to selected dir
                 new_music_dir = os.path.join(self.WinMain.gstMusic.current_dir, menu_desc)
             #load dir & play
             tracks = self.WinMain.gstMusic.set_directory(new_music_dir, MUSIC_FILESPEC)
             if len(tracks) > 0:
                 self.WinMain.gstMusic.load_playlist(
                     playlist = tracks,
                     play = True,
                     shuffle = self.WinMain.wahcade_ini.get('shuffle_music', 0))
             #display music menu
             self.set_menu('music_dir')
         elif menu_item == 'music_track':
             #track selected
             new_track = os.path.join(self.WinMain.gstMusic.current_dir, menu_desc)
             #print "self.WinMain.gstMusic.tracks=",self.WinMain.gstMusic.tracks
             idx = self.WinMain.gstMusic.tracks.index(new_track)
             self.WinMain.gstMusic.current_track = idx - 1
             self.WinMain.gstMusic.next_track()
     elif self.current_menu == 'exit':
         if menu_item == 'exit_desktop':
             self.WinMain.exit_wahcade()
         elif menu_item == 'exit_reboot':
             self.WinMain.exit_wahcade('reboot')
         elif menu_item == 'exit_shutdown':
             self.WinMain.exit_wahcade('shutdown')
     else:
         #unhandled menu item
         print "unhandled menu"
         print "  self.current_menu=", self.current_menu
         print "  menu_item=", menu_item
Ejemplo n.º 4
0
 def menu_selected(self, *args):
     """menu item selected"""
     if len(self.lsOptions) <= 0:
         #no options!
         return
     #get selected item
     menu_desc, menu_item = self.lsOptions[self.sclOptions.get_selected()]
     if self.current_menu == 'main':
         #main menu
         if menu_item == 'random':
             #pick random game
             self.WinMain.sclGames.set_selected(
                 self.WinMain.get_random_game_idx())
             self.WinMain.sclGames.update()
         elif menu_item == 'about':
             #about
             self.show_about_dialog('Wah!Cade', CONFIG_DIR)
             self.WinMain.hide_window('options')
         else:
             #show appropriate menu
             self.set_menu(menu_item, menu_desc)
     elif self.current_menu == 'emu_list':
         #emulator list menu, so switch to selected emulator
         self.WinMain.hide_window('options')
         self.WinMain.load_emulator(menu_item)
     elif self.current_menu == 'game_list':
         #game list menu, so switch to selected list
         self.WinMain.hide_window('options')
         self.WinMain.current_list_idx = int(menu_item)
         self.WinMain.load_list()
     elif self.current_menu == 'list_options':
         #games list options menu
         if menu_item == 'remove_from_list':
             #remove current game from current list
             self.WinMain.remove_current_game()
         else:
             #show menu
             self.set_menu(menu_item, menu_desc)
     elif self.current_menu == 'add_to_list':
         #check game isn't already on list
         new_list_filename = os.path.join(
             CONFIG_DIR, 'files',
             '%s-%s.lst' % (self.WinMain.current_emu, int(menu_item)))
         selected_game = self.WinMain.lsGames[
             self.WinMain.sclGames.get_selected()]
         new_list = filters.read_filtered_list(new_list_filename)
         if selected_game not in new_list:
             #add current selected game to chosen game list
             filters.add_game_to_filtered_list(
                 gd=filters.get_game_dict(selected_game),
                 list_filename=new_list_filename)
         self.WinMain.hide_window('options')
     elif self.current_menu == 'generate_ftr':
         #filtered lists
         if menu_item == 'ftr:filter_type':
             #change filter type (display clones)
             self._display_clone_idx += 1
             if self._display_clone_idx > 2:
                 self._display_clone_idx = 0
             self.on_sclOptions_changed()
             self.WinMain.current_filter_changed = True
             self.WinMain.current_filter[
                 'filter_type'] = self._display_clone_idx
         else:
             #show filter... menu
             self.set_menu(menu_item, menu_desc)
     elif self.current_menu.startswith('ftr:'):
         #update current filter
         self.WinMain.current_filter_changed = True
         ftr_section = self.WinMain.current_filter[self.current_menu[4:]]
         if self.sclOptions.get_selected() == 0:
             #set all = yes
             for k in ftr_section.keys():
                 ftr_section[k] = True
         elif self.sclOptions.get_selected() == 1:
             #set all = no
             for k in ftr_section.keys():
                 ftr_section[k] = False
         else:
             #set yes / no
             item = self.lsOptions[self.sclOptions.get_selected()][0]
             yesno = (self.lblSettingValue.get_text().lower() == 'yes')
             ftr_section[item] = not yesno
             self.on_sclOptions_changed()
     elif self.current_menu == 'find':
         #find by letter
         self.find_game('add', menu_item[5:])
     elif self.current_menu == 'music':
         if menu_item == 'music_play':
             #play / pause
             #print "music_play"
             self.WinMain.gstMusic.play_toggle()
         elif menu_item == 'next_track':
             self.WinMain.gstMusic.next_track()
         elif menu_item == 'previous_track':
             self.WinMain.gstMusic.previous_track()
         elif menu_item == 'show_music_dir':
             #select music dir
             self.set_menu('music_dir')
     elif self.current_menu == 'music_dir':
         #select music dir
         if menu_item == 'music_dir':
             #dir selected
             if menu_desc == '..':
                 #go to parent dir
                 new_music_dir = os.path.dirname(
                     self.WinMain.gstMusic.current_dir)
             else:
                 #change to selected dir
                 new_music_dir = os.path.join(
                     self.WinMain.gstMusic.current_dir, menu_desc)
             #load dir & play
             tracks = self.WinMain.gstMusic.set_directory(
                 new_music_dir, MUSIC_FILESPEC)
             if len(tracks) > 0:
                 self.WinMain.gstMusic.load_playlist(
                     playlist=tracks,
                     play=True,
                     shuffle=self.WinMain.wahcade_ini.get(
                         'shuffle_music', 0))
             #display music menu
             self.set_menu('music_dir')
         elif menu_item == 'music_track':
             #track selected
             new_track = os.path.join(self.WinMain.gstMusic.current_dir,
                                      menu_desc)
             #print "self.WinMain.gstMusic.tracks=",self.WinMain.gstMusic.tracks
             idx = self.WinMain.gstMusic.tracks.index(new_track)
             self.WinMain.gstMusic.current_track = idx - 1
             self.WinMain.gstMusic.next_track()
     elif self.current_menu == 'exit':
         if menu_item == 'exit_desktop':
             self.WinMain.exit_wahcade()
         elif menu_item == 'exit_reboot':
             self.WinMain.exit_wahcade('reboot')
         elif menu_item == 'exit_shutdown':
             self.WinMain.exit_wahcade('shutdown')
     else:
         #unhandled menu item
         print "unhandled menu"
         print "  self.current_menu=", self.current_menu
         print "  menu_item=", menu_item