import bge
import Settings

def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner
    dict = bge.logic.globalDict
    scene = bge.logic.getCurrentScene()
    black = scene.objects['black']
    shuvit_logo = scene.objects['shuvit_logo']
    levels = ['garage18', 'mini_scene']
    scenes = bge.logic.getSceneList()
    #print(dict['load_timer'])
    
    if dict['overlay_fadein'] == 1:
        #dict['overlay_fadein'] = 0
        #black.playAction('black_fade', 0,60, layer=0, play_mode=0)
        #print("---add fade")
        #fade_in
        
        for i in scenes:
            if i.name == "fade_in":
                scene2 = i
                scene2.end()         
        cont.activate(own.actuators['add_fade'])  
        
        #skater.playAction("reg_noses", 30,40, layer=trans_layer, play_mode=0, speed=.5)
    if dict['overlay_fadeout'] == 1:
        dict['overlay_fadeout'] = 0    
        black.playAction('black_fade', 100,200, layer=2, play_mode=0) 
        shuvit_logo.playAction('logo_fade', 100,200, layer=0, play_mode=0)  
        #print('fade out black and logo') 
        
    if dict['load_timer'] > 0:
        dict['load_timer'] -= 1
    if dict['load_timer'] == 3:
        #load   
        scenes = bge.logic.getSceneList()
        #print('scenes: ', scenes)

                 
        #Settings.loadlevel()
        #print('----reloading----')
        dict['load_timer'] == 0
        cont.activate(own.actuators['reload_game'])
        
        #cont.activate(own.actuators["loading"])
        #print('loading', dict['level'])
    
main()
