require ( "scripts/style.lua" );
require ( "scripts/ui/style_buttons.lua" );
require ( "scripts/ui/style_text.lua" );
require ( "config/world2/costs.lua" );
require ( "config/world2/mechanics.lua" );
-- integrated scripts:
require ( "scripts/integrated/quest_mirror.lua" );
require ( "scripts/integrated/blight_mirror.lua" );
require ( "scripts/integrated/storage.lua" );
require ( "scripts/integrated/fountain.lua" );
require ( "scripts/integrated/water_barrel.lua" );
require ( "scripts/integrated/magic_object.lua" );
require ( "scripts/integrated/gates.lua" );
require ( "scripts/integrated/texts.lua" );
require ( "scripts/integrated/ui_buttons_rollover.lua" );
require ( "scripts/integrated/ui_info_rollover.lua" );
require ( "scripts/integrated/spawning_pool.lua" );

require ( "facebook/common/facebook_functions.lua" );

TextStyle = {
    font = { standardFont, 14, WhiteColor},
    parent=DialogBodyText,
    x=0,y=10,w=kMax,h=kMax-10
};

InfoTextFont = {
    standardFont,
    16,
    WhiteColor,
};

StartDayButtonGraphics = {
    "interface/game/btn_start_day/start",
    "interface/game/btn_start_day/start_p",
    "interface/game/btn_start_day/start_a",
};

ButtonLabelFont = {
  standardFont,
  18,
  BlackColor,
};

GameScreenButtonSound = {
    ClickSound="audio/sfx/shop/hudbutton_click.ogg";
    OverSound="audio/sfx/shop/hudbutton_rollover.ogg";
};

ShopButtonStyle = {
    actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed"},
    snd_click = "audio/sfx/shop/hudbutton_click.ogg",
    snd_over  = "audio/sfx/shop/hudbutton_rollover.ogg",
    timer_settings = {name="ui", category="UI"},
};

local kPopupActive = false;
kDialogActive = false;

AskForPotionReplace = function(tex_plant)
    if (kPopupActive) then
        return;
    end;
    
    local cost = GetCount("plant_sell_cost");
    
    PlaySound("audio/sfx/shop/dialogappear.ogg");
    
    PauseTimer("game", "game");
    kPopupActive = true;
    kPauseDlgShowAllowed = false;
    local retval = DisplayDialog {
                        "scripts/dlg_yesno.lua",
                        body = "ask_potion_replace",
                        title = "dlg_replace_title",
                        lbl_yes = "replace",
                        lbl_no = "close",
                        image = tex_plant,
                    };
    kPauseDlgShowAllowed = true;
    DoBuyPotion(retval == "yes");
    StartTimer("game", "game");
    kPopupActive = false;
    
    PlaySound("audio/sfx/shop/dialogdisappear.ogg");
end;

AskForSell = function(tex_plant)
    if (kPopupActive) then
        return;
    end;
    
    local cost = GetCount("plant_sell_cost");
    
    PlaySound("audio/sfx/shop/dialogappear.ogg");
    
    PauseTimer("game", "game");
    kPopupActive = true;
    kPauseDlgShowAllowed = false;
    local retval = DisplayDialog {
                        "scripts/dlg_yesno.lua",
                        body = "#"..GetString("ask_sell", tostring(cost)),
                        title = "dlg_sell_title",
                        lbl_yes = "sell",
                        lbl_no = "close",
                        image = tex_plant,
                        pic_scale = 0.8,
                    };
    if (retval == "yes") then
        SupplyItem("money", cost);
    end;
    kPauseDlgShowAllowed = true;
    SellPlant(retval == "yes");
    StartTimer("game", "game");
    kPopupActive = false;
    
    PlaySound("audio/sfx/shop/dialogdisappear.ogg");
end;

fn_InterfacePanels_Hide = function()
    --pnl_potions_StartCurveCallBack("curves/game_ui_panels.xml", "potions_out", "");
    pnl_mech_plants_StartCurveCallBack("curves/game_ui_panels.xml", "mech_plants_out", "");
    pic_new_quest_StartCurveCallBack("curves/game_ui_panels.xml", "mirror_out", "");
    btn_sell_plant_StartCurveCallBack("curves/game_ui_panels.xml", "tool_out", "");
    btn_remove_weed_StartCurveCallBack("curves/game_ui_panels.xml", "tool_out", "");
    pnl_harvest_plants_StartCurveCallBack("curves/game_ui_panels.xml", "harvest_plants_out", "");
    EnableWindow("new_quest", false);
    EnableWindow("btn_refill_water", false);
    
    -- taken from pnl_harvest_plants:
    DeactivateControl("start_day");
    HideControl("start_day");
    SetItemCount("pnl_shop_state", 0);
end;
fn_InterfacePanels_Show = function()
    --pnl_potions_StartCurveCallBack("curves/game_ui_panels.xml", "potions_in", "");
    pnl_mech_plants_StartCurveCallBack("curves/game_ui_panels.xml", "mech_plants_in", "fn_InterfacePanels_ShowComplete();");
    pic_new_quest_StartCurveCallBack("curves/game_ui_panels.xml", "mirror_in", "");
    btn_sell_plant_StartCurveCallBack("curves/game_ui_panels.xml", "tool_in", "");
    btn_remove_weed_StartCurveCallBack("curves/game_ui_panels.xml", "tool_in", "");
    pnl_harvest_plants_StartCurveCallBack("curves/game_ui_panels.xml", "harvest_plants_in", "");
    
    -- taken from pnl_harvest_plants:
    ShowControl("start_day");
end;
fn_InterfacePanels_ShowComplete = function()
    if GetCount("pnl_blight") == 0 then
        EnableWindow("new_quest", true);
        EnableWindow("btn_refill_water", true);
    end;
    ActivateControl("start_day");
    GM_StartPersistentAction("ShopClick");
    StartTimer("game", "game");
    SetItemCount("pnl_shop_state", 1);
end;


fn_CompleteGarden = function()
    SetItemCount('garden_2_progress', 2);
    SetItemCount('garden_3_progress', 1);
    SetItemCount("curr_garden", 3);
    LoadMap();
end;

fn_FadeToMap = function()
    if IsContentLimited() then
		DisplayDialog{
			"scripts/ok.lua",
			title = "endtrial",
			body = "endtrialconfirm",
		};
		LoadMainMenu();
	else
        bmp_fade_StartCurveCallBack("curves/fade.xml","map","fn_CompleteGarden();");
    end;
end;


MakeDialog
{
    GameWindow
    {
        x=0,y=0,
        w=1024,h=768,
        name = "GameWindow",
        scroll_speed=400,
        
        text_storage_count_position = "530, 345",
        sell_particle_position = "800, 555",
        timer_position = "69,78",
        
        tex_background = "game/garden_2/back",
        quest_set = "config/world2/quest.xml",
        
        config_environment = "config/world2/environment.ini",
        config_garden_statue = "config/world2/united_statue.lua",
        config_fountain = "config/world2/united_fountain.lua",
        config_storage = "config/world2/united_storage.lua",
        config_water_barrel = "config/world2/united_waterbarrel.lua",
        config_magic_object = "config/world2/united_magic_object.lua",
        config_garden_gates = "config/world2/gates.ini",
        config_seedbed = "config/world2/seedbed.ini",
        config_storage_gfx = "config/world2/storage.ini",
        npc_config = "config/world2/npc.ini",
        
        config_plant_1 = "config/world2/united_plant_1.lua",
        config_plant_2 = "config/world2/united_plant_2.lua",
        config_plant_3 = "config/world2/united_plant_3.lua",
        config_plant_4 = "config/world2/united_plant_butterfly.lua",
        config_plant_5 = "config/world2/united_plant_fertilizer.lua",
        config_plant_6 = "config/world2/united_plant_pest_magnet.lua",
        config_plant_7 = "config/world2/united_plant_water.lua",
        config_plant_8 = "config/world2/united_plant_might.lua",
        
        ruled_sprite = "waterfall",
        
        on_create = function()
            SetItemCount("pnl_shop_state", 0);
            DeactivateControl("start_day");
            ShowControl("start_day");
            fn_InterfacePanels_Show();
            bmp_tree_1_StartCurveInfinite("curves/fx_g2_tree.xml", "tree_1", 0);
            bmp_tree_2_StartCurveInfinite("curves/fx_g2_tree.xml", "tree_2", 0);
            bmp_tree_3_StartCurveInfinite("curves/fx_g2_tree.xml", "tree_3", 0);
            bmp_tree_4_StartCurveInfinite("curves/fx_g2_tree.xml", "tree_4", 0);
            bmp_tree_5_StartCurveInfinite("curves/fx_g2_tree.xml", "tree_5", 0);
            bmp_tree_6_StartCurveInfinite("curves/fx_g2_tree.xml", "tree_6", 0);
            bmp_tree_7_StartCurveInfinite("curves/fx_g2_tree.xml", "tree_7", 0);
            bmp_tree_8_StartCurveInfinite("curves/fx_g2_tree.xml", "tree_8", 0);
            bmp_tree_9_StartCurveInfinite("curves/fx_g2_tree.xml", "tree_9", 0);
        end;
        
        Spawn_GatesRollOverPanel(512, 150),
        Spawn_StorageRollOverPanel(320, 330, 300, 210),
        Spawn_FountainRollOverPanel(340, 495, 300, 600),
        Spawn_MagicObjectRollOverPanel(700, 270, 700, 160),
        Spawn_UIButtonsRollover("garden2", 181, 251, 326, 396, 466),
        
        SetStyle(ShopButtonStyle),

        BitmapVisual
        {
            name="bmp_tree_1",
            ini_file = "config/ui/garden_2_trees.ini",
            ini_tag  = "TREE_01",
        },
        BitmapVisual
        {
            name="bmp_tree_2",
            ini_file = "config/ui/garden_2_trees.ini",
            ini_tag  = "TREE_02",
        },
        BitmapVisual
        {
            name="bmp_tree_3",
            ini_file = "config/ui/garden_2_trees.ini",
            ini_tag  = "TREE_03",
        },
        BitmapVisual
        {
            name="bmp_tree_4",
            ini_file = "config/ui/garden_2_trees.ini",
            ini_tag  = "TREE_04",
        },
        BitmapVisual
        {
            name="bmp_tree_5",
            ini_file = "config/ui/garden_2_trees.ini",
            ini_tag  = "TREE_05",
        },
        BitmapVisual
        {
            name="bmp_tree_6",
            ini_file = "config/ui/garden_2_trees.ini",
            ini_tag  = "TREE_06",
        },
        BitmapVisual
        {
            name="bmp_tree_7",
            ini_file = "config/ui/garden_2_trees.ini",
            ini_tag  = "TREE_07",
        },
        BitmapVisual
        {
            name="bmp_tree_8",
            ini_file = "config/ui/garden_2_trees.ini",
            ini_tag  = "TREE_08",
        },
        BitmapVisual
        {
            name="bmp_tree_9",
            ini_file = "config/ui/garden_2_trees.ini",
            ini_tag  = "TREE_09",
        },
        
        WndFxSprite
        {
            name = "dust_fx",
            x = 0,
            y = 0,
            w = 1024,
            h = 768,
            effect_position = "512,0",
            file_name = "fx/world2/dust.lua",
            start_activate = true,
            advance = 50,
            timer_settings = {
                name = "ui",
                category = "UI",
            },
        },

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

        -----------------------------------------------------------
        -- Gate gems
        -----------------------------------------------------------

        WndFxSprite
        {
            name = "gate_gem_1_fx",
            x = 0,
            y = 0,
            w = 1024,
            h = 768,
            effect_position = "372,38",
            file_name = "fx/gate_gem.lua",
            start_activate = false,
            advance = 100,
            param_1 = {
                type = "color",
                name = "dStartColor",
                value = "255,0,0,63"
            },
            timer_settings = {
                name = "ui",
                category = "UI",
            },
        },

        WndFxSprite
        {
            name = "gate_gem_2_fx",
            x = 0,
            y = 0,
            w = 1024,
            h = 768,
            effect_position = "435,40",
            file_name = "fx/gate_gem.lua",
            start_activate = false,
            advance = 100,
            param_1 = {
                type = "color",
                name = "dStartColor",
                value = "255,0,255,63"
            },
            timer_settings = {
                name = "ui",
                category = "UI",
            },
        },

        WndFxSprite
        {
            name = "gate_gem_3_fx",
            x = 0,
            y = 0,
            w = 1024,
            h = 768,
            effect_position = "499,38",
            file_name = "fx/gate_gem.lua",
            start_activate = false,
            advance = 100,
            param_1 = {
                type = "color",
                name = "dStartColor",
                value = "0,0,255,63"
            },
            timer_settings = {
                name = "ui",
                category = "UI",
            },
        },

        WndFxSprite
        {
            name = "gate_gem_4_fx",
            x = 0,
            y = 0,
            w = 1024,
            h = 768,
            effect_position = "561 ,38",
            file_name = "fx/gate_gem.lua",
            start_activate = false,
            advance = 100,
            param_1 = {
                type = "color",
                name = "dStartColor",
                value = "255,191,0,63"
            },
            timer_settings = {
                name = "ui",
                category = "UI",
            },
        },

        WndFxSprite
        {
            name = "gate_gem_5_fx",
            x = 0,
            y = 0,
            w = 1024,
            h = 768,
            effect_position = "623,38",
            file_name = "fx/gate_gem.lua",
            start_activate = false,
            advance = 100,
            param_1 = {
                type = "color",
                name = "dStartColor",
                value = "0,255,0,63"
            },
            timer_settings = {
                name = "ui",
                category = "UI",
            },
        },

        BitmapVisual
        {
            name="pic_new_quest",
            x = 126, y = 785,
            rect         = "-45,128;44,128;94,71;105,40;105,2;93,-41;59,-96;13,-123;-11,-123;-59,-94;-100,-26;-110,17;-109,44;-86,85;",
            image        = "interface/game/btn_quest/mirror",
            eat_mouse    = true,
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed",
                "ActHintClickMirror"},
            WndFxSprite
            {
                x = kCenter,
                y = kCenter+20,
                w = 200,
                h = 200,
                effect_position = "100,100",
                file_name = "fx/quest_mirror_portal.lua",
                start_activate = true,
                advance = 100,
                timer_settings = {
                    name = "ui",
                    category = "UI",
                },
                
                Bitmap
                {
                    x = kCenter,
                    y = kCenter,
                    image = "interface/game/pnl_quest_mirror/btn_person_2/p_02",
                    scale = 0.6,
                },
            },
            SetStyle(ButtonStyle),
            ButtonVisual
            {
                name="new_quest",
                font = CreateNamedFont(MinionSbItSymbolSet, 28, ButtonBrown),
                graphics = UIButtonGraphics,
                snd_click    = GameScreenButtonSound.ClickSound,
                snd_over     = GameScreenButtonSound.OverSound,
                flags = kVAlignCenter + kHAlignCenter,
                mask = "buttons/uibutton_alfa",
                label = "btn_quest",
                tex_normal   = "buttons/uibutton",
                tex_over     = "buttons/uibutton_a",
                tex_push     = "buttons/uibutton_p",
                actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed",
                    "ActHintClickMirror"},
                rect         = "-18,35;14,35;65,23;65,-23;13,-35;-18,-35;-69,-22;-68,21;",
                layer_click  = 1002,
                on_click = function()
                    if QuestAvailable() then
                        ShowControl("quest_mirror_dlg");
                    end;
                end,
                x = 118,
                y = 30,
                SetStyle(TextStyle),
                CreateMinionText(26, ButtonYellow, kCenter+1, kCenter+1, "#"..GetString("button_outline", GetString("btn_quest")), 140, 26),
                CreateMinionText(26, ButtonBrown, kCenter, kCenter, "#"..GetString("button_outline", GetString("btn_quest")), 140, 26),
            },
        },
        
        --fn_SpawnPotionsPanel(),
        
        fn_Spawn_Storage(),

        -- sell flower
        SetStyle(ShopButtonStyle),
        ButtonVisual
        {
            ini_file = "config/ui/game_interface.ini",
            ini_tag  = "BTN_TOOL_SELL",
            name="btn_sell_plant",
            
            on_click = function()
                if GetCount("hint_sell_plant2") == 1 then
                    EnableWindow("sell_flower_pop_up", false);
                    SetItemCount('hint_sell_plant2', 2);
                end;
                StartSellFlower();
            end;
            on_enter = function()
                EnableWindow("sell_flower_pop_up", true);
            end;
            on_exit  = function()
                EnableWindow("sell_flower_pop_up", false);
            end;
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed",
                "ActHintSell"},
        },
        -- destroy weed
        ButtonVisual
        {
            ini_file = "config/ui/game_interface.ini",
            ini_tag  = "BTN_TOOL_SHOVEL",
            name="btn_remove_weed",
            
            on_click = function()
                StartRemoveWeed(costs.remove_weed);
            end;
            on_enter = function()
                EnableWindow("remove_weed_pop_up", true);
            end;
            on_exit  = function()
                EnableWindow("remove_weed_pop_up", false);
            end;
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed",
                "ActHintRemoveWeed"},
            
            context = {"money"},
            context_change = function(item, old_val, new_val)
                btn_remove_weed_SetClickable(new_val >= costs.remove_weed);
            end;
        },
        
        Bitmap
        {
            image = "interface/game/clock",
            x = 0,
            y = 0,
        },
        Bitmap
        {
            image = "interface/game/left",
            x = 0,
            y = 200,
        },
        Bitmap
        {
            image = "interface/game/down",
            x = 32,
            y = 736,
        },
        Bitmap
        {
            image = "interface/game/down_obj",
            x = 128,
            y = 640,
        },
        Bitmap
        {
            image = "interface/game/top",
            x = 128,
            y = 0,
        },
        Bitmap
        {
            image = "interface/game/right",
            x = 992,
            y = 32,
        },
        
        fn_SpawnHarvestPlantsPanel("2"),

        fn_SpawnMechPlantsPanel("2"),
        
        Spawn_WaterBarrelRollOverPanel(),
        
        Bitmap
        {
            name = "dig_pop_up",
            x=2000,y=0,
            image="interface/game/pop_up/back",
            SetStyle(TextStyle),
            CreateMinionText(20, CaptionYellow, kCenter, kCenter, "dig_pop_up", 140, 20),
        },
        Bitmap
        {
            name = "plant_pop_up",
            x=2000,y=0,
            image="interface/game/pop_up/back",
            
            SetStyle(TextStyle),
            CreateMinionText(20, CaptionYellow, kCenter, kCenter, "plant_pop_up", 140, 20),
        },
        Bitmap
        {
            name = "sell_pop_up",
            x=2000,y=0,
            image="interface/game/pop_up/back",
            SetStyle(TextStyle),
            CreateMinionText(20, CaptionYellow, kCenter, kCenter, "sell_pop_up", 140, 20),
        },
        Spawn_UIInfoRollover(),
        
        TextVisual
        {
            name = "text_day_count",
            x=23,y=141,
            h=20,w=90,
            flags=kHAlignCenter+kVAlignCenter,
            font=InfoTextFont,
            context = {"day_elapsed",},
            context_change = function(item, old_val, new_val)
                text_day_count_SetText(GetString("day_elapsed", tostring(new_val)));
            end;
        },
        
        WndFxSprite
        {
            name = "start_fx",
            x = 0,
            y = 0,
            w = 230,
            h = 230,
            effect_position = "69,78",
            file_name = "fx/start_light.lua",
            start_activate = true,
            advance = 100,
            timer_settings = {
                name = "ui",
                category = "UI",
            },
        },
        
        -- Start Day Button
        --SetStyle(ButtonStyle),
        BitmapVisual
        {
            name = "start_day_mouse_helper",
            image = "cutscenes/black",
            alpha_val = 0,
            x = 69, y = 75,
            w=10,h=10,
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed", "Butterfly", "UIClick", "GameClick"},
            rect = "-2,67;18,65;38,56;54,41;64,22;68,-1;63,-26;47,-50;23,-65;-3,-70;-32,-62;-54,-44;-65,-22;-70,3;-63,29;-48,50;-26,63;",
            layer_click = 1000,
            eat_mouse = true,
        },
        ButtonExt
        {
            x = 69,
            y = 75,
            name="start_day",
            label="start_day",
            font = CreateNamedFont(MinionSbItSymbolSet, 36, ButtonBrown),
            type = kPush,
            graphics = StartDayButtonGraphics,
            sound = GameScreenButtonSound.ClickSound,
            rolloversound = GameScreenButtonSound.OverSound,
            mask = "interface/game/btn_start_day/start_alpha",
            state_handlers = {
                showing = function()
                    EnableWindow("start_day", true);
                end;
                showed = function()
                    ActivateControl("start_day");
                    if (GetCount("day_elapsed") == 1) or (GetCount("bud_collected") == 0) then
                        EnableWindow("start_fx", true);
                    end;
                end;
                hiding = function()
                    DeactivateControl("start_day");
                    EnableWindow("start_day", false);
                end;
            },
            command = function()
                local water_amount = GetCount("water");
                local water_capacity = GetCount("waterbarrel_capacity");
                local force_water = "yes";
                if (water_amount <= 5) then
                    force_water = DisplayDialog {
                        "scripts/dlg_yesno.lua",
                        title = "start_low_water_title",
                        body = "#"..GetString("start_low_water_body", tostring(water_amount)),
                        image = "interface/dlg_yes_no/low_water",
                    };
                end;
                
                local bud_amount = GetCount("bud_collected");
                local storage_capacity = GetCount("storage_capacity");
                local force_storage = "yes";
                if (force_water == "yes") and (bud_amount >= (storage_capacity-8)) then
                    force_storage = DisplayDialog {
                        "scripts/dlg_yesno.lua",
                        title = "start_storage_full_title",
                        body = "#"..GetString("start_storage_full_body", tostring(bud_amount), tostring(storage_capacity)),
                        image = "interface/dlg_yes_no/storage_full",
                    };
                end;

                if (force_storage == "yes") and (force_water == "yes") then
                    StartDay();
                    StartTimer("game", "game");
                    fn_InterfacePanels_Hide();
                    EnableWindow("start_fx", false);
                end;
            end;
        },
        
        
        -- Sell flowers button
        BitmapVisual
        {
            name="pic_sell_flowers",
            x = 797, y = 650,
            rect = "-73,119;75,119;79,108;82,68;74,50;76,27;76,12;67,-26;48,-52;52,-61;44,-90;28,-98;-33,-98;-49,-72;-48,-50;-68,-36;-89,-15;-89,-10;-82,-1;-81,18;-73,37;-82,69;-82,94;",
            image        = "interface/game/btn_sell_flowers/button_sell",
            eat_mouse    = true,
        },
        SetStyle(ShopButtonStyle),
        ButtonVisual
        {
            ini_file = "config/ui/game_interface.ini",
            ini_tag  = "BTN_LAB_ENTER",
            name="sell_flowers",
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed",
                "ActForceLab"},
            layer_click  = 1002,
            on_click = function()
                if not kDialogActive then
                    SetItemCount("pnl_sell_screen_state", 1);
                    kPauseDlgShowAllowed = false;
                    GM_StartPersistentAction("PotionClick");
                    SuspendFXPool("");
                    ResumeFXPool("laboratory");
                    local retval = DoModal("scripts/sell_screen.lua");
                    if retval == "yes" then
                        LoadMainMenu();
                    else
                        ResetShopStarted();
                        ResumeFXPool("");
                        SuspendFXPool("laboratory");
                    end;
                end;
            end;
            SetStyle(TextStyle),
            CreateMinionText(26, ButtonYellow, kCenter+1, kCenter+1, "#"..GetString("button_outline", GetString("btn_potions")), 140, 26),
            CreateMinionText(26, ButtonBrown, kCenter, kCenter, "#"..GetString("button_outline", GetString("btn_potions")), 140, 26),
        },
        ButtonVisual
        {
            ini_file = "config/ui/game_interface.ini",
            ini_tag  = "BTN_LAB_ENTER",
            x = 943,
            y = 550,
            
            name="btn_refill_water",
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed",
                "ActForceLab"},
            layer_click  = 1002,
            on_click = function()
                if not kDialogActive then
                    DoModal("scripts/refill_water.lua");
                end;
            end;
            SetStyle(TextStyle),
            CreateMinionText(26, ButtonYellow, kCenter+1, kCenter+1, "#"..GetString("button_outline", GetString("btn_refill")), 140, 26),
            CreateMinionText(26, ButtonBrown, kCenter, kCenter, "#"..GetString("button_outline", GetString("btn_refill")), 140, 26),
        },
        
        -- Pause Button
        ButtonVisual
        {
            ini_file = "config/ui/game_interface.ini",
            ini_tag  = "BTN_PAUSE",
            name="pause",
            
            snd_click = "audio/sfx/game_ui/button_clickUI.ogg",
			snd_over  = "audio/sfx/game_ui/button_rolloverUI.ogg",
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed", "Butterfly", "UIClick", "GameClick"},
            
            on_click = function()
                if kPauseDlgShowAllowed and (not kQuitConfirmShowed) and (not kFaceBookOverrides) then
                    kPauseDlgShowAllowed = false;
                    if GetCount("lvl_gates") ~= 6 then
                        GM_StartPersistentAction("UIClick");
                        if (IsDay()) then
                            GM_StartPersistentAction("GameClick");
                        else
                            if not kDialogActive then
                                GM_StartPersistentAction("ShopClick");
                            end;
                        end;
                    end;
                    HM_HideHint();
                    if GetCount("pnl_refill_state") == 1 then
                        EnableWindow("refill_water", false);
                    end;
                    retval = DoModal("scripts/pause.lua");
                    if GetCount("pnl_refill_state") == 1 then
                        EnableWindow("refill_water", true);
                        GM_StartPersistentAction("RefillWaterClick");
                    end;
                    if (retval == "quit") then
                        LoadMainMenu();
                    elseif (retval == "map") then
                        LoadMap();
                    elseif (retval == "restart") then
                        SwapToModal("scripts/restart_level.lua");
                    else
                        HM_RestoreHint();
                        if GetCount("lvl_gates") == 6 then
                            GM_StartPersistentAction("FinishGarden");
                        end;
                    end;
                    kPauseDlgShowAllowed = true;
                end;
            end;

            SetStyle(TextStyle),
            CreateMinionText(26, ButtonYellow, kCenter+1, kCenter+1, "#"..GetString("button_outline", GetString("pause")), 140, 26),
            CreateMinionText(26, ButtonBrown, kCenter, kCenter, "#"..GetString("button_outline", GetString("pause")), 140, 26),
        },
        
        fn_Spawn_Texts(),
        BitmapVisual
        {
            name="bmp_fade",
            image    = "cutscenes/black",
            timer_settings = {
                name = "fade",
                category = "UI",
            },
            alpha_val = 0,
            center = "0,0",
            x = 0, y = 0,
            w = 1024, h = 768,
        },
        
        Spawn_QuestMirror(),
        Spawn_BlightMirror(),

        Facebook_CreateShareButton(),    
    },
};

Facebook_HideMedalButton();