﻿init -81 python:
    try:
        mmm.add(
            gui0_menu(
                _("Credits"),
                ShowMenu("credits"),
                False, False, True
                ),
            )
    except:
        pass

init python:
    class credits_class:
        def __init__(self, lst, animation_speed = 2):
            self.lst = lst
            self.animation_speeed = animation_speed
        def next(self, curr):
            renpy.show_screen("cred_ins", item = self.lst[curr], anispeed = self.animation_speeed, _tag = "cred_{}".format(curr))
 
# ----------------------------- define a credit list
default credits1 = credits_class(
    [
        [
            4, # Duration
            ["text", "0GUI credit example", 50], # ["type", "Text string.", text size] # a text example
        ],
        [
            4,
            ["Demo art by", ["Mugかぶり (characters)", "Uncle Mugen (backgrounds)"]], # ["Role", ["name 1", "name 2", ...]]
        ],
        [
            4,
            ["Story  by", ["KiaAzad", "Not a story per se."]], # Multiple items example
            ["Music by", ["We don't have em yet!"]],
            ["SFX by", ["KiaAzad"]],
        ],
        [
            4,
            ["Programming by", ["KiaAzad"]], 
        ],
        [
            4,
            ["GUI design by", ["KiaAzad"]],
        ],
        [
            4,
            ["Special thanks to our Patreon supporters", ["Lady Isak Grozny", "Jamego"]],
        ],
        [
            15,
            ["text", "Thank you for using 0GUI.", 60],
            ["button", "Return", Return()], # Button example ["type", "text", action]
        ],
        [
            1,
            ["action", Return()], # Action example ["type", action]
        ],
    ],
    animation_speed = 2 # [optional] default is 2sec
    )

# ----------------------------- the animation
transform cred_trans(speed, p, d=renpy.random.random()):
    subpixel True
    alpha 0 zoom 0
    pause d
    parallel:
        ease_bounce speed/2 zoom 1
        pause p+speed-d
        ease speed/2 zoom 0
    parallel:
        linear speed alpha 1
        pause p-d
        ease_quart speed alpha 0


# ----------------------------- The screens
screen credits(c=credits1):
    tag menu
    default curr = 0
    add "#000d"
    if curr == 0:
        timer 1 repeat True action Function(c.next, curr), SetScreenVariable("curr", curr+1)
    elif curr < len(c.lst):
        timer c.lst[curr][0]+(c.animation_speeed*2) repeat True action Function(c.next, curr), SetScreenVariable("curr", curr+1)

screen cred_ins(item, anispeed):
    timer item[0]+(anispeed*2) action Hide("cred_ins")
    # style_prefix "cred"
    frame:
        xfill True yfill True margin 100,100 background None
        vbox:
            spacing 40
            for x in item[1:]:
                if x[0] == "text":
                    text x[1] at cred_trans(anispeed, item[0]) size x[2]
                elif x[0] == "action":
                    timer item[0] action x[1]
                elif x[0] == "button":
                    button:
                        at cred_trans(anispeed, item[0])
                        text x[1]
                        action x[2]
                else:
                    vbox:
                        text x[0] at cred_trans(anispeed, item[0]) size 30 color "#4ff"
                        vbox:
                            box_wrap True
                            for i in x[1]:
                                text i at cred_trans(anispeed, item[0]) size 50


# style cred_text:
#     font "Boku2-Bold.otf"