function fn_Spawn_Button_Plant(control, tag, config, tex_cursor, cost, hint_action, new_x, new_y, delta_x, delta_y)
    return Group
    {
        ButtonVisual
        {
            ini_file = "config/ui/game_interface.ini",
            ini_tag  = tag,
            name=control,
            
            on_click = function()
                if GetCount("hint_"..control) == 1 then
                    SetItemCount("hint_"..control, 2);
                end;
                StartPlantFlower(config, tex_cursor, cost);
                EnableWindow(control.."_pop_up", false);
            end;
            on_enter = function()
                EnableWindow(control.."_pop_up", true);
            end;
            on_exit  = function()
                EnableWindow(control.."_pop_up", false);
            end;
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed", hint_action--[[, hint_action.."_1"--]]},
            
            context = {"money", "lock_"..control.."_lvl_1", "day_elapsed", "day_unlock_"..control},
            context_change = function(item, old_val, new_val)
                if (item == "lock_"..control.."_lvl_1") then
                    Invoke_SetLocked(control, (new_val == 1));
                    if (new_val == 0) then
                        Invoke_SetClickable(control, GetCount("money") >= cost);
                        EnableWindow(control.."_new_label", GetCount("day_elapsed") <= GetCount("day_unlock_"..control) + 2);
                    end;
                    if (new_val == 1) then
                        EnableWindow(control.."_new_label", false);
                    end;
                end;
                if (item == "money") and (GetCount("lock_"..control.."_lvl_1") == 0) then
                    Invoke_SetClickable(control, GetCount("money") >= cost);
                end;
                if (item == "day_elapsed") and (GetCount("lock_"..control.."_lvl_1") == 0) then
                    EnableWindow(control.."_new_label", new_val <= GetCount("day_unlock_"..control) + 2);
                end;
                if (item == "day_unlock_"..control) and (GetCount("lock_"..control.."_lvl_1") == 0) then
                    EnableWindow(control.."_new_label", GetCount("day_elapsed") <= new_val + 2);
                end;
            end,
        },
        Bitmap
        {
            name  = control.."_new_label",
            x = new_x, y = new_y,
            image = "interface/new_badge",
            SetStyle(TextStyle),
            CreateOndineShadowText(16, WhiteColor, kCenter, kCenter+2, "new_plant", 50, 20),
        },
        SetStyle(BtnPrice),
        ButtonVisual
        {
            name=control.."_price",
            x = new_x+delta_x, y = new_y+delta_y,
            
            on_click = function()
                if GetCount("hint_"..control) == 1 then
                    SetItemCount("hint_"..control, 2);
                end;
                StartPlantFlower(config, tex_cursor, cost);
                EnableWindow(control.."_pop_up", false);
            end;
            on_enter = function()
                EnableWindow(control.."_pop_up", true);
            end;
            on_exit  = function()
                EnableWindow(control.."_pop_up", false);
            end;
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed", hint_action--[[, hint_action.."_1"--]]},
            
            context = {"money", "lock_"..control.."_lvl_1", "day_elapsed", "day_unlock_"..control},
            context_change = function(item, old_val, new_val)
                if (item == "lock_"..control.."_lvl_1") then
                    Invoke_SetLocked(control.."_price", (new_val == 1));
                    EnableWindow(control.."_price_txt", (new_val ~= 1));
                    EnableWindow(control.."_price_txt_sh", (new_val ~= 1));
                    if (new_val == 0) then
                        Invoke_SetClickable(control.."_price", GetCount("money") >= cost);
                    end;
                end;
                if (item == "money") and (GetCount("lock_"..control.."_lvl_1") == 0) then
                    Invoke_SetClickable(control.."_price", GetCount("money") >= cost);
                end;
            end,
            SetStyle(TextStyle),
            CreateMinionNamedText(15, CaptionBrown, kCenter+8, kCenter+1, "#"..GetString("caption_outline", tostring(cost)), 30, 15, control.."_price_txt"),
            CreateMinionNamedText(15, CaptionYellow, kCenter+7, kCenter, "#"..GetString("caption_outline", tostring(cost)), 30, 15, control.."_price_txt_sh"),
        },
    };
end;
function fn_Spawn_Button_Potion(control, tag, id, tex_cursor, cost, hint_action, new_x, new_y)
    return Group
    {
        ButtonVisual
        {
            ini_file = "config/ui/game_interface.ini",
            ini_tag  = tag,
            name="btn_"..control,
            
            on_click = function()
                StartBuyPotion(id, tex_cursor, cost);
                EnableWindow("rollover_"..control, false);
                if (GetCount("hint_spells") == 1) then
                    SetItemCount("hint_spells", 2);
                    SetItemCount("hint_place_spell", 1);
                end;
            end;
            on_enter = function()
                if (GetCount("hint_spells") ~= 1) then
                    EnableWindow("rollover_"..control, true);
                end;
            end;
            on_exit  = function()
                EnableWindow("rollover_"..control, false);
            end;
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed", hint_action},
            
            context = {"money", "lvl_magic_object", "lock_"..control, "day_elapsed", "day_unlock_"..control},
            context_change = function(item, old_val, new_val)
                if (item == "lock_"..control) then
                    Invoke_SetLocked("btn_"..control, new_val == 1)
                    if (new_val == 0)then
                        Invoke_SetClickable("btn_"..control, GetCount("money") >= cost);
                        EnableWindow(control.."_new_label", GetCount("day_elapsed") <= GetCount("day_unlock_"..control) + 2);
                    end;
                    if (new_val == 1) then
                        EnableWindow(control.."_new_label", false);
                    end;
                end;
                if GetCount("lock_"..control) == 0 then
                    local c = GetCount("money") >= cost;
                    c = c and GetCount("lvl_magic_object") > 1;
                    Invoke_SetClickable("btn_"..control, c);
                end;
                if (item == "day_elapsed") and (GetCount("lock_"..control) == 0) then
                    EnableWindow(control.."_new_label", new_val <= GetCount("day_unlock_"..control) + 2);
                end;
                if (item == "day_unlock_"..control) and (GetCount("lock_"..control) == 0) then
                    EnableWindow(control.."_new_label", GetCount("day_elapsed") <= new_val + 2);
                end;
            end;
        },
        SetStyle(BtnPrice),
        ButtonVisual
        {
            name="btn_"..control.."_price",
            x = new_x+32, y = new_y+25,
            
            on_click = function()
                StartBuyPotion(id, tex_cursor, cost);
                EnableWindow("rollover_"..control, false);
                if (GetCount("hint_spells") == 1) then
                    SetItemCount("hint_spells", 2);
                    SetItemCount("hint_place_spell", 1);
                end;
            end;
            on_enter = function()
                if (GetCount("hint_spells") ~= 1) then
                    EnableWindow("rollover_"..control, true);
                end;
            end;
            on_exit  = function()
                EnableWindow("rollover_"..control, false);
            end;
            
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed", hint_action},
            
            context = {"money", "lvl_magic_object", "lock_"..control, "day_elapsed", "day_unlock_"..control},
            context_change = function(item, old_val, new_val)
                if (item == "lock_"..control) then
                    Invoke_SetLocked("btn_"..control.."_price", new_val == 1)
                    EnableWindow("btn_"..control.."_price_txt", (new_val ~= 1));
                    EnableWindow("btn_"..control.."_price_txt_sh", (new_val ~= 1));
                    if (new_val == 0)then
                        Invoke_SetClickable("btn_"..control.."_price", GetCount("money") >= cost);
                    end;
                end;
                if GetCount("lock_"..control) == 0 then
                    local c = GetCount("money") >= cost;
                    c = c and GetCount("lvl_magic_object") > 1;
                    Invoke_SetClickable("btn_"..control.."_price", c);
                end;
            end;
            SetStyle(TextStyle),
            CreateMinionNamedText(15, CaptionBrown, kCenter+8, kCenter+1, "#"..GetString("caption_outline", tostring(cost)), 30, 15, "btn_"..control.."_price_txt"),
            CreateMinionNamedText(15, CaptionYellow, kCenter+7, kCenter, "#"..GetString("caption_outline", tostring(cost)), 30, 15, "btn_"..control.."_price_txt_sh"),
        },
        Bitmap
        {
            name  = control.."_new_label",
            x = new_x, y = new_y+30,
            image = "interface/new_badge",
            SetStyle(TextStyle),
            CreateOndineShadowText(16, WhiteColor, kCenter, kCenter+2, "new_plant", 50, 20),
        },
    };
end;

fn_SpawnHarvestPlantsPanel = function(garden)
    return Group
    {
        BitmapVisual
        {
            name = "pnl_harvest_plants",
            image = "interface/game/pnl_actions/harvest_plants_back",
            x = -96, y = 350,
            w = 200, h = 340,
            -- Flower Buttons
            SetStyle(ShopButtonStyle),
            fn_Spawn_Button_Plant("camomile",
                "BTN_FLOWER_HARVEST_1_GARDEN_"..garden,
                "config/world"..garden.."/united_plant_1.lua",
                "g"..garden.."p1",
                costs.camomile,
                "ActHintCamomilePlant",
                101, 110, 64, -15),
            fn_Spawn_Button_Plant("cornflower",
                "BTN_FLOWER_HARVEST_2_GARDEN_"..garden,
                "config/world"..garden.."/united_plant_2.lua",
                "g"..garden.."p2",
                costs.cornflower,
                "ActHintCornflowerPlant",
                101,180, 64, -15),
            fn_Spawn_Button_Plant("rose",
                "BTN_FLOWER_HARVEST_3_GARDEN_"..garden,
                "config/world"..garden.."/united_plant_3.lua",
                "g"..garden.."p3",
                costs.rose,
                "ActHintRosePlant",
                101,250, 64, -15),
        },
    };
end;

fn_SpawnMechPlantsPanel = function(garden)
    return Group
    {
        BitmapVisual
        {
            name = "pnl_mech_plants",
            image = "interface/game/pnl_actions/mech_plants_back",
            x = 1130, y = 325,
            w = 200, h = 470,
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed", "Butterfly", "UIClick", "GameClick"},
            rect = "65,-234;44,-204;17,-201;4,-192;-18,-187;-43,-180;-43,-42;-54,-4;-43,33;-43,178;-23,182;-3,188;13,188;20,197;39,198;66,228;",
            layer_click = 999,
            eat_mouse = true,

            -- Mech Flower Buttons
            SetStyle(ShopButtonStyle),
            fn_Spawn_Button_Plant("magnet_plant",
                "BTN_FLOWER_MAGNET", 
                "config/world"..garden.."/united_plant_pest_magnet.lua",
                "p_magnet",
                costs.magnet,
                "ActHintMagnetPlant",
                36,100, 0, -15),
            fn_Spawn_Button_Plant("fertilizer_plant",
                "BTN_FLOWER_FERTILIZER", 
                "config/world"..garden.."/united_plant_fertilizer.lua",
                "p_fertilizer", 
                costs.fertilizer,
                "ActHintFertilizerPlant",
                36,170, 0, -15),
            fn_Spawn_Button_Plant("water_plant",
                "BTN_FLOWER_WATER", 
                "config/world"..garden.."/united_plant_water.lua",
                "p_water",
                costs.water,
                "ActHintWaterPlant",
                36,245, 0, -15),
            fn_Spawn_Button_Plant("butterfly_plant",
                "BTN_FLOWER_BUTTERFLY", 
                "config/world"..garden.."/united_plant_butterfly.lua",
                "p_butterfly",
                costs.butterfly,
                "ActHintButterflyPlant",
                36,320, 0, -15),
            fn_Spawn_Button_Plant("might_plant",
                "BTN_FLOWER_MIGHT", 
                "config/world"..garden.."/united_plant_might.lua",
                "p_might",
                costs.might,
                "ActHintMightPlant",
                36,390, 0, -15),
        },
    };
end;

fn_SpawnPotionsPanel = function()
    return Group
    {
        BitmapVisual
        {
            name = "pnl_potions",
            image = "interface/game/pnl_actions/potions_back",
            x = 795, y = -90,
            w = 512, h = 180,
            actions = {"ShopClick", "PlantFlower", "BuyPotion", "SellFlower", "RemoveWeed", "Butterfly", "UIClick", "GameClick"},
            rect = "-163,-74;-138,-45;-141,-28;-158,-22;-173,9;-157,53;-139,52;-128,32;128,32;141,49;155,49;167,26;173,4;155,-22;141,-29;141,-50;159,-74;",
            layer_click = 999,
            eat_mouse = true,
            SetStyle(ShopButtonStyle),
            fn_Spawn_Button_Potion("potion_harvest",
                "BTN_POTION_HARVEST",
                1,
                "mp_harvest",
                costs.potion_harvest,
                "ActHintPotionHarvest",
                145,110),
            fn_Spawn_Button_Potion("potion_bugs",
                "BTN_POTION_BUGS",
                2,
                "mp_bugs",
                costs.potion_bugs,
                "ActHintPotionBugs",
                225,113),
            fn_Spawn_Button_Potion("potion_water",
                "BTN_POTION_WATER",
                3,
                "mp_water",
                costs.potion_water,
                "ActHintPotionWater",
                305,110),

            WndFxSprite
            {
                name = "left_lamp_firebugs_fx",
                x = 0,
                y = 0,
                w = 512,
                h = 150,
                effect_position = "107,92",
                file_name = "fx/lamp_firebugs.lua",
                start_activate = true,
                advance = 50,
                timer_settings = {
                    name = "control",
                    category = "control",
                },
            },

            WndFxSprite
            {
                name = "right_lamp_firebugs_fx",
                x = 0,
                y = 0,
                w = 512,
                h = 150,
                effect_position = "403,92",
                file_name = "fx/lamp_firebugs.lua",
                start_activate = true,
                advance = 50,
                timer_settings = {
                    name = "control",
                    category = "control",
                },
            },

            WndFxSprite
            {
                name = "left_lamp_light_fx",
                x = 0,
                y = 0,
                w = 512,
                h = 150,
                effect_position = "107,92",
                file_name = "fx/lamp_light.lua",
                start_activate = true,
                advance = 50,
                timer_settings = {
                    name = "control",
                    category = "control",
                },
            },

            WndFxSprite
            {
                name = "right_lamp_light_fx",
                x = 0,
                y = 0,
                w = 512,
                h = 150,
                effect_position = "403,92",
                file_name = "fx/lamp_light.lua",
                start_activate = true,
                advance = 50,
                timer_settings = {
                    name = "control",
                    category = "control",
                },
            },
        },
    };
end;