require( "scripts/style.lua" );
require( "scripts/ui/style_text.lua" );


MedalFont = {
  standardFont,
  20,
  WhiteColor
};

BtnTrophy  = {
    ini_file = "config/ui/trophy_room.ini",
    actions = {"UIClick",},
};

function DoRollover(medalName, iniTag)
    return Group
    {
        BitmapVisual
        {
            name = "pic_"..medalName,
            ini_file = "config/ui/trophy_room.ini",
            ini_tag  = iniTag,
            SetStyle(TextStyle),
            CreateMinionShadowText(20, WhiteColor, kCenter, kCenter, medalName, 180, 110),
        },
    };
end;

function SpawnTrophy(trophy, tag)
    return Group
    {
        ButtonVisual
        {
            name = trophy,
            ini_tag  = tag,
            on_enter = function()
                CR_SwitchToDefault();
                EnableWindow("pic_"..trophy, true);
            end;
            on_exit  = function()
                EnableWindow("pic_"..trophy, false);
            end;
            context = {trophy,},
            context_change = function(item, old_val, new_val)
                if new_val == 1 then
                    Invoke_SetClickable(trophy, true);
                else
                    Invoke_SetClickable(trophy, false);
                end
            end;
        },
    };
end;

MakeDialog
{
    name="trophieswindow",
    
    Bitmap
    {
        image = "trophy/background",
        x = kCenter,
        y = kCenter,
    },
    
    ScreenTrophy
    {
        x = 0,
        y = 0,
        w = 1024,
        h = 768,
        
        SetStyle(BtnTrophy),
        SpawnTrophy("trophy_garden_gold1", "BTN_GARDEN_1_GOLD"),
        SpawnTrophy("trophy_garden_gold2", "BTN_GARDEN_2_GOLD"),
        SpawnTrophy("trophy_garden_gold3", "BTN_GARDEN_3_GOLD"),
        SpawnTrophy("trophy_garden_gold4", "BTN_GARDEN_4_GOLD"),
        SpawnTrophy("trophy_garden_gold5", "BTN_GARDEN_5_GOLD"),
        SpawnTrophy("trophy_5day_plant", "BTN_5_DAY_PLANT"),
        SpawnTrophy("trophy_20day_plant", "BTN_20_DAY_PLANT"),
        SpawnTrophy("trophy_5potions", "BTN_5_POTIONS"),
        SpawnTrophy("trophy_50potions", "BTN_50_POTIONS"),
        SpawnTrophy("trophy_250potions", "BTN_250_POTIONS"),
        SpawnTrophy("trophy_800potions", "BTN_800_POTIONS"),
        SpawnTrophy("trophy_50pests", "BTN_50_PESTS"),
        SpawnTrophy("trophy_250pests", "BTN_250_PESTS"),
        SpawnTrophy("trophy_1000pests", "BTN_1000_PESTS"),
        SpawnTrophy("trophy_100buds", "BTN_100_BUDS"),
        SpawnTrophy("trophy_300buds", "BTN_300_BUDS"),
        SpawnTrophy("trophy_1000buds", "BTN_1000_BUDS"),
        SpawnTrophy("trophy_100coins", "BTN_100_COINS"),
        SpawnTrophy("trophy_500coins", "BTN_500_COINS"),
        SpawnTrophy("trophy_1000coins", "BTN_1000_COINS"),
        SpawnTrophy("trophy_total_coins", "BTN_TOTAL_COINS"),

        DoRollover("trophy_garden_gold1", "PIC_GARDEN_1_GOLD");
        DoRollover("trophy_garden_gold2", "PIC_GARDEN_2_GOLD");
        DoRollover("trophy_garden_gold3", "PIC_GARDEN_3_GOLD");
        DoRollover("trophy_garden_gold4", "PIC_GARDEN_4_GOLD");
        DoRollover("trophy_garden_gold5", "PIC_GARDEN_5_GOLD");
        DoRollover("trophy_5day_plant", "PIC_5_DAY_PLANT");
        DoRollover("trophy_20day_plant", "PIC_20_DAY_PLANT");
        DoRollover("trophy_5potions", "PIC_5_POTIONS");
        DoRollover("trophy_50potions", "PIC_50_POTIONS");
        DoRollover("trophy_250potions", "PIC_250_POTIONS");
        DoRollover("trophy_800potions", "PIC_800_POTIONS");
        DoRollover("trophy_50pests", "PIC_50_PESTS");
        DoRollover("trophy_250pests", "PIC_250_PESTS");
        DoRollover("trophy_1000pests", "PIC_1000_PESTS");
        DoRollover("trophy_100buds", "PIC_100_BUDS");
        DoRollover("trophy_300buds", "PIC_300_BUDS");
        DoRollover("trophy_1000buds", "PIC_1000_BUDS");
        DoRollover("trophy_100coins", "PIC_100_COINS");
        DoRollover("trophy_500coins", "PIC_500_COINS");
        DoRollover("trophy_1000coins", "PIC_1000_COINS");
        DoRollover("trophy_total_coins", "PIC_TOTAL_COINS");
        
        SetStyle(ButtonStyle),
        Button
        {
            x=10,
            y=705,
            name="back",
            type = kPush,
            flags = kHAlignCenter + kVAlignCenter,
            label="back",
            font = CreateNamedFont(MinionSbItSymbolSet, 24, ButtonBrown),
            command = function()
                PopModal("trophieswindow"); 
            end;
        },

        --------------------------------------------------------------------------------------------
        -- FX
        --------------------------------------------------------------------------------------------

        WndFxSprite
        {
            name = "light_rays_fx",
            x = 0,
            y = 0,
            w = 1024,
            h = 768,
            effect_position = "256,192",
            file_name = "fx/trophy_room/light_rays.lua",
            start_activate = true,
            advance = 50,
            timer_settings = {
                name = "ui",
                category = "UI",
            },
        },

        WndFxSprite
        {
            name = "dust_fx",
            x = 0,
            y = 0,
            w = 1024,
            h = 768,
            effect_position = "1024,200",
            file_name = "fx/trophy_room/dust.lua",
            start_activate = true,
            advance = 50,
            timer_settings = {
                name = "ui",
                category = "UI",
            },
        },
    },
}
