"""
VN Scene Script Ext - Timeline 1.0
Provide functions to call Timeline function

tline_play
tline_pause
tline_stop
tline_seek (param - seconds, float like 10.0, 0.0 or others)


"""

exttimeline = None

def custom_action(game,act):
    """:type game: vngameengine.VNNeoController"""
    if not act["action"].startswith("tline_"):
        # not timeline function!
        return False

    global exttimeline
    if exttimeline == None:
        import extplugins
        exttimeline = extplugins.ExtTimeline()

    if not exttimeline.isDetected:
        print "can't play Timeline cmd, because Timeline not found"
        return True

    if act["action"] == "tline_play":
        try:
            exttimeline.Play()
            return True
        except Exception, e:
            print "VNGE timeline cmd error, can't parse command '%s':"%act["origintext"], e
            return True

    if act["action"] == "tline_pause":
        try:
            exttimeline.Pause()
            return True
        except Exception, e:
            print "VNGE timeline cmd error, can't parse command '%s':"%act["origintext"], e
            return True

    if act["action"] == "tline_stop":
        try:
            exttimeline.Stop()
            return True
        except Exception, e:
            print "VNGE timeline cmd error, can't parse command '%s':"%act["origintext"], e
            return True

    if act["action"] == "tline_seek":
        try:
            seektime = act["actionparam"]
            exttimeline.SeekPlaybackTime(seektime)
            return True
        except Exception, e:
            print "VNGE timeline cmd error, can't parse command '%s':"%act["origintext"], e
            return True

def debug_buttons(game,state):
    return [] # if we want no additional buttons

    # return in format of set_buttons_alt
    #return ["Demo btn (keitaro10)", demo1]