def onClick( self, controlID ): try: if controlID == 450: pos = self.getControl( 450 ).getSelectedPosition() self.stageBG = ( "", os.path.join( MEDIAS_PATH, "BG%s.png" % str( pos ) ) )[ pos != 0 ] [ self.getControl( 350 ).getListItem( i ).setIconImage( self.stageBG ) for i in range( 100 ) ] elif controlID == 150: wall_item = self.getControl( 150 ).getSelectedItem() self.wallType = int( wall_item.getLabel() ) self.wallSelect = sprites.wallsValues[ self.wallType ][ 0 ] [ self.getListItem( i ).setIconImage( self.wallSelect ) for i in range( 260 ) ] self.setFocusId( 50 ) elif controlID == 50: pos = self.getCurrentListPosition() wall_item = self.getControl( 250 ).getListItem( pos ) self.wallSelect = sprites.wallsValues[ self.wallType ][ 0 ] wall_item.setIconImage( self.wallSelect ) self.stage[ pos ] = self.wallType elif controlID == 121: self.setStageName() elif controlID == 122: #load custom stage stg = utilities.getBrowseDialog( os.path.join( BASE_RESOURCE_PATH, "custom_levels" )+os.sep, heading="Select Your Stage", mask=".stage" ) if os.path.isfile( stg ): self.loadStage( stg ) self.setStage() elif controlID == 123: if sum( self.stage ): self.saveStage() elif controlID == 124: self.onReset() elif controlID == 125: #load original stage or tournament stage_path = utilities.getBrowseDialog( os.path.join( BASE_RESOURCE_PATH, "media", "stages" )+os.sep, heading="Select Original Stage", dlg_type=2, shares="pictures", use_thumbs=True ) level_id = os.path.splitext( os.path.basename( stage_path ) )[ 0 ].split( "_" )[ -1 ] if level_id.isdigit(): level_id = int( level_id ) self.stage = arkanoid.Levels()[ level_id ] self.stageBG = "BG%i.png" % arkanoid.getLevelBackground( level_id ) self.stageName = ( "Arkanoid %i" % level_id, "Tournament %i" % level_id )[ "tournament" in os.path.basename( stage_path ).lower() ] self.setStage() elif controlID in [ 320, 321 ]: self.closeEditor() except: print_exc()
def onClick(self, controlID): try: if self.GAME and self.GAME.GameOver: del self.GAME self.GAME = None if self.GAME and controlID == 500: if not self.GAME.threadLevel and not self.GAME.ballRunning: self.GAME.startLevel() elif self.GAME.vaus_statut == "LASER": #else: self.launchFire() elif not self.GAME and controlID == 201: mode = (controlID - 200) self.launchGame(0, mode) elif not self.GAME and controlID == 202: mode = (controlID - 200) self.launchGame(0, mode) elif not self.GAME and controlID == 203: mode = (controlID - 200) #browse custom stage stg = utilities.getBrowseDialog( os.path.join(BASE_RESOURCE_PATH, "custom_levels") + os.sep, heading="Select Your Stage", mask=".stage") if stg and os.path.isfile(stg): f = open(stg, "r") bg, stage = eval(f.read()) f.close() #test valide stage and background error_info = "Bad file! %s" % stg if not len(stage) == 260: raise error_info for colrow in stage: if not (0 <= colrow <= 10): raise error_info if os.path.exists(bg): bg = bg elif bg and not os.path.exists(bg): bg = os.path.join(MEDIAS_PATH, bg) stageName = os.path.splitext(os.path.basename(stg))[0] customlevel = bg, stage, stageName self.launchGame(0, mode, customlevel) elif not self.GAME and controlID == 204: mode = (controlID - 200) stage_path = utilities.getBrowseDialog( os.path.join(BASE_RESOURCE_PATH, "media", "stages") + os.sep, heading="Select Practice Stage", dlg_type=2, shares="pictures", use_thumbs=True) level_id = os.path.splitext( os.path.basename(stage_path))[0].split("_")[-1] if level_id.isdigit(): mode = (mode, 5)["tournament" in os.path.basename( stage_path).lower()] self.launchGame(int(level_id), mode) elif controlID == 122: import editor w = editor.levelEditor("levelEditor.xml", CWD, CURRENT_SKIN, FORCE_FALLBACK) w.doModal() del w, editor elif controlID == 125: w = HighScores("highScores.xml", CWD, CURRENT_SKIN, FORCE_FALLBACK) w.doModal() del w elif controlID == 320: self.closeGame() elif controlID == 123: self._stop_game() elif controlID == 126: settings = xbmc.Settings(CWD) skin_setting = settings.getSetting("skin") settings.openSettings() xbmc.sleep(500) self.setSettings() if skin_setting != xbmc.Settings(CWD).getSetting("skin"): self.closeGame() xbmc.executescript(os.path.join(CWD, 'default.py')) elif controlID == 127: import infos w = infos.Info("infos.xml", CWD, CURRENT_SKIN, FORCE_FALLBACK) w.doModal() del w, infos except: print_exc()
def onClick( self, controlID ): try: if self.GAME and self.GAME.GameOver: del self.GAME self.GAME = None if self.GAME and controlID == 500: if not self.GAME.threadLevel and not self.GAME.ballRunning: self.GAME.startLevel() elif self.GAME.vaus_statut == "LASER": #else: self.launchFire() elif not self.GAME and controlID == 201: mode = ( controlID - 200 ) self.launchGame( 0, mode ) elif not self.GAME and controlID == 202: mode = ( controlID - 200 ) self.launchGame( 0, mode ) elif not self.GAME and controlID == 203: mode = ( controlID - 200 ) #browse custom stage stg = utilities.getBrowseDialog( os.path.join( BASE_RESOURCE_PATH, "custom_levels" )+os.sep, heading="Select Your Stage", mask=".stage" ) if stg and os.path.isfile( stg ): f = open( stg, "r" ) bg, stage = eval( f.read() ) f.close() #test valide stage and background error_info = "Bad file! %s" % stg if not len( stage ) == 260: raise error_info for colrow in stage: if not ( 0 <= colrow <= 10 ): raise error_info if os.path.exists( bg ): bg = bg elif bg and not os.path.exists( bg ): bg = os.path.join( MEDIAS_PATH, bg ) stageName = os.path.splitext( os.path.basename( stg ) )[ 0 ] customlevel = bg, stage, stageName self.launchGame( 0, mode, customlevel ) elif not self.GAME and controlID == 204: mode = ( controlID - 200 ) stage_path = utilities.getBrowseDialog( os.path.join( BASE_RESOURCE_PATH, "media", "stages" )+os.sep, heading="Select Practice Stage", dlg_type=2, shares="pictures", use_thumbs=True ) level_id = os.path.splitext( os.path.basename( stage_path ) )[ 0 ].split( "_" )[ -1 ] if level_id.isdigit(): mode = ( mode, 5 )[ "tournament" in os.path.basename( stage_path ).lower() ] self.launchGame( int( level_id ), mode ) elif controlID == 122: import editor w = editor.levelEditor( "levelEditor.xml", CWD, CURRENT_SKIN, FORCE_FALLBACK ) w.doModal() del w, editor elif controlID == 125: w = HighScores( "highScores.xml", CWD, CURRENT_SKIN, FORCE_FALLBACK ) w.doModal() del w elif controlID == 320: self.closeGame() elif controlID == 123: self._stop_game() elif controlID == 126: settings = xbmc.Settings( CWD ) skin_setting = settings.getSetting( "skin" ) settings.openSettings() xbmc.sleep( 500 ) self.setSettings() if skin_setting != xbmc.Settings( CWD ).getSetting( "skin" ): self.closeGame() xbmc.executescript( os.path.join( CWD, 'default.py' ) ) elif controlID == 127: import infos w = infos.Info( "infos.xml", CWD, CURRENT_SKIN, FORCE_FALLBACK ) w.doModal() del w, infos except: print_exc()