--============================================================================
--  memory_wiz.lua
--  Copyright (c) 2010; Bamtang Games. All Rights Reserved.
------------------------------------------------------------------------------
require("scripts/style.lua");

function closeMemoryWiz()
    if (gGameStyle == "quest") then
        SwapToModal("scripts/metamap.lua");
    elseif (gGameStyle == "quick") then
        SwapToModal("scripts/quick_play.lua");
    end
end

function selectBackground(scenaryId, timeId)
    prefix = "gpx/background/background_";

    if     scenaryId == 1 then scenary = "mountain_";
    elseif scenaryId == 2 then scenary = "city_";
    elseif scenaryId == 3 then scenary = "beach_";
    elseif scenaryId == 4 then scenary = "space_";
    else                       scenary = "";
    end

    if     timeId == 0 then time = "morning";
    elseif timeId == 1 then time = "noon";
    elseif timeId == 2 then time = "afternoon";
    else                    time = "night";
    end

    SetBitmap("bmpBackground", prefix..scenary..time);
end

function selectSize(num)
    EnableWindow("bmpLayout7x8",num == 1);
    EnableWindow("bmpLayout9x10",num == 2);
    EnableWindow("bmpLayout11x12",(num == 3) or (num == 4));
    EnableWindow("bmpFrame7x8",num == 1);
    EnableWindow("bmpFrame9x10",num == 2);
    EnableWindow("bmpFrame11x12", (num == 3) or (num == 4));
end

function selectLifes(num)
    EnableWindow("bmpHeart1",num >= 1);
    EnableWindow("bmpHeart2",num >= 2);
    EnableWindow("bmpHeart3",num >= 3);
end

function updateGameUserName()
    SetLabel("lblPlayer", gsw_getCurrentUserString("swtName",""));
end

function showAlphaBackground(show)
    EnableWindow("bmpBgAlpha", show);
end

------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Panel - PowerUp
function ShowPowerUpPanel(power)
    local lname = "";
    local ltext = "";
    local limage = "";
    if power == 1 then
        lname = "powerup wild";
        limage = "gpx/tiles/wild";
        ltext = "powerup wild text";
    elseif power == 2 then
        lname = "powerup bomb";
        limage = "gpx/tiles/bomb";
        ltext = "powerup bomb text";
    elseif power == 3 then
        lname = "powerup sidewinder";
        limage = "gpx/tiles/sidewinder";
        ltext = "powerup sidewinder text";
    elseif power == 4 then
        lname = "powerup showtime";
        limage = "gpx/tiles/showtime";
        ltext = "powerup showtime text";
    elseif power == 5 then
        lname = "powerup freeze";
        limage = "gpx/tiles/freeze";
        ltext = "powerup freeze text";
    end
    result = DisplayDialog {
        "scripts/power_up.lua";
        name = lname;
        text = ltext;
        image = limage;
    };
end

function continueLevel()
    if gGameMode == "Classic" then
        gfn_ClassicOnStart();
    elseif gGameMode == "Blitz" then
        gfn_BlitzOnStart();
    elseif gGameMode == "Strategy" then
        gfn_StrategyOnStart();
    elseif gGameMode == "Rome" then
        gfn_RomeOnStart();
    elseif gGameMode == "Joker" then
        gfn_JokerOnStart();
    end
end
------------------------------------------------------------------------------
MakeDialog {

    Bitmap {
        name = "bmpBackground";
        x = 0; y = 0;
    };

    wndMemoryWiz {
        name = "canvasMemoryWiz";
        x = 0; y = 0; w = 1024; h = 768;

        btmMemoryWiz {
            name = "btmMemoryWiz";
            x = 0; y = 0; w = 1024; h = 768;

            avatar_boy  = { x = 785; y = 320 };
            avatar_girl = { x = 800; y = 312 };
            avatar_cat  = { x = 800; y = 345 };
            avatar_dog  = { x = 800; y = 314 };

            icon_x = 125;
            icon_y = 130;

            Bitmap {
                name = "bmpLayout7x8";
                image = "gpx/screens/layout_7x8";
                x = 0; y = 0;
            };
            Bitmap {
                name = "bmpLayout9x10";
                image = "gpx/screens/layout_9x10";
                x = 0; y = 0;
            };
            Bitmap {
                name = "bmpLayout11x12";
                image = "gpx/screens/layout_11x12";
                x = 0; y = 0;
            };

            Bitmap {
                name = "bmpFrame7x8";
                image = "gpx/screens/frame_7x8";
                x = 312; y = 221;
            };
            Bitmap {
                name = "bmpFrame9x10";
                image = "gpx/screens/frame_9x10";
                x = 267; y = 169;
            };
            Bitmap {
                name = "bmpFrame11x12";
                image = "gpx/screens/frame_11x12";
                x = 224; y = 131;
            };

            Bitmap {
                name = "bmpLayoutBarTime";
                image = "gpx/bar/layout_bar_time";
                x = 274; y = 720;
            };

            Text {
                label = "lblGoal";
                font = Font20;
                x = 70; y = 53; w = 140; h = 35;
                flags = kHAlignLeft + kVAlignTop;
            };

            Text {
                name = "lblGoal";
                label = "#0";
                font = Font34;
                x = 85; y = 90; w = 80; h = 80;
                flags = kHAlignCenter + kVAlignCenter;
            };

            Text {
                name = "lblLevelText";
                label = "lblLevel";
                font = Font20;
                x = 30; y = 645; w = 140; h = 40;
                flags = kHAlignCenter + kVAlignCenter;
            };

            Text {
                name = "lblLevel";
                label = "#0";
                font = Font34;
                x = 110; y = 555; w = 80; h = 80;
                flags = kHAlignCenter + kVAlignCenter;
            };

            Text {
                label = "lblScore";
                font = Font18;
                x = 760; y = 51; w = 200; h = 40;
                flags = kHAlignLeft + kVAlignTop;
            };

            Text {
                name = "lblScore";
                label = "#0";
                font = Font34;
                x = 780; y = 70; w = 200; h = 40;
                flags = kHAlignLeft + kVAlignTop;
            };

            Text {
                label = "lblTotalScore";
                font = Font16;
                x = 797; y = 148; w = 200; h = 40;
                flags = kHAlignLeft + kVAlignTop;
            };

            Text {
                name = "lblTotalScore";
                label = "#0";
                font = Font30;
                x = 813; y = 173; w = 200; h = 40;
                flags = kHAlignLeft + kVAlignTop;
            };

            Text {
                name = "lblBestCombo";
                label = "lblBestCombo";
                font = Font16;
                x = 798; y = 244; w = 200; h = 40;
                flags = kHAlignLeft + kVAlignTop;
            };

            Text {
                name = "txtBestCombo";
                label = "#0";
                font = Font34;
                x = 815; y = 266; w = 200; h = 40;
                flags = kHAlignLeft + kVAlignTop;
            };

            Text {
                name = "lblPlayer";
                label = "#Player";
                font = Font18;
                x = 822; y = 577; w = 147; h = 32;
                flags = kHAlignCenter + kVAlignCenter;
            };

            Bitmap {
                name = "bmpHeart1";
                image = "gpx/gameplay/heart_small.png";
                x = 800;
                y = 615;
            };

            Bitmap {
                name = "bmpHeart2";
                image = "gpx/gameplay/heart_small.png";
                x = 846;
                y = 615;
            };

            Bitmap {
                name = "bmpHeart3";
                image = "gpx/gameplay/heart_small.png";
                x = 892;
                y = 615;
            };

            Bitmap {
                name = "gpxClassic";
                x = 137; y = 639;
                image = "gpx/modes/icon_layout_classic";
            };
            Bitmap {
                name = "gpxBlitz";
                x = 137; y = 639;
                image = "gpx/modes/icon_layout_blitz";
            };
            Bitmap {
                name = "gpxRome";
                x = 137; y = 639;
                image = "gpx/modes/icon_layout_Cradle";
            };
            Bitmap {
                name = "gpxStrategy";
                x = 137; y = 639;
                image = "gpx/modes/icon_layout_strategy";
            };
            Bitmap {
                name = "gpxJoker";
                x = 137; y = 639;
                image = "gpx/modes/icon_layout_Joker";
            };

            Bitmap {
                name = "gpxClock";
                x = 148; y = 709;
                image = "gpx/screens/layout_clock";
            };
            Text {
                name = "txtClock";
                font = Font22;
                x = 195; y = 720; w = 90; h = 33;
                flags = kHAlignCenter + kVAlignCenter;
            };

            Bitmap {
                name = "lblGoalBar";
                image = "gpx/bar/layout_bar_goal";
                x = 105; y = 178;
            };
            Bitmap {
                name = "gpxGoalOriented";
                image = "gpx/screens/layout_paneltextgoal";
                x = 12; y = 182;
            };
            Text {
                name = "lblGoalOriented";
                font = Font14;
                x = 40; y = 193; w = 142; h = 71;
                flags = kHAlignCenter + kVAlignCenter;
            };


            Bitmap {
                name = "gpxNewRow";
                x = 145; y = 716;
                image = NewRowButtonGraphics[4];
            };
            Text {
                name = "txtNewRow";
                label = "New Row";
                font = Font14;
                x = 145; y = 716; w = 152; h = 42;
                flags = kHAlignCenter + kVAlignCenter;
            };
            SetStyle(PanelButtonStyle);
            Button {
                name = "btnNewRow";
                x = 145; y = 716;
                label = "New Row";
                font = Font14;
                command =
                    function()
                        gfn_onNewRow();
                    end
            };
        };

        SetStyle(PauseButtonStyle);
        Button {
            name = "btnPause";
            x = 802; y = 710;
            label = "pause";
            command =
                function()
                    DoModal("scripts/pause.lua");
                end
        };

        guiMemoryWiz {
            name = "guiMemoryWiz";
            x = 0; y = 0; w = 1024; h = 768;
        };

        Bitmap {
            name = "bmpBgAlpha";
            image = "gpx/screens/transparent_background";
            x = 0; y = 0;
        };

        topMemoryWiz {
            name = "topMemoryWiz";
            x = 0; y = 0; w = 1024; h = 768;
        };

        --Bitmap {
        --    name = "bmpLayoutFreeze01";
        --    image = "gpx/bar/bar_freeze01";
        --    x = 137; y = 707;
        --};
        --Bitmap {
        --    name = "bmpLayoutFreeze02";
        --    image = "gpx/bar/bar_freeze02";
        --    x = 137; y = 707;
        --};
        
		-- AchievePanel4
		Bitmap {
			name = "bmpAchievePanel4";
			image = "gpx/screens/panel_achievements.png";
			x = 489; y = 827;
			alpha = true;
			Bitmap {
				name = "bmpIcon";
				x = 15; y = 15;
				image = "gpx/screens/panel03";
			};
			clsText {
				name = "lblTitle";
				font = Font32;
				flags = kVAlignCenter + kHAlignCenter;
				label = "Anim_Achieve_Title";
				x = 130; y = 18; w = 450; h = 40;
				Scale = 0.33;
				Space = -10;
			};
			clsText {
				name = "lblText";
				font = Font26;
				flags = kVAlignCenter + kHAlignCenter;
				label = "lblFinishQuestTitle";
				x = 130; y = 55; w = 450; h = 40;
				Scale = 0.25;
				Space = -10;
			};
		};

		-- AchievePanel3
		Bitmap {
			name = "bmpAchievePanel3";
			image = "gpx/screens/panel_achievements.png";
			x = 489; y = 827;
			alpha = true;
			Bitmap {
				name = "bmpIcon";
				x = 15; y = 15;
				image = "gpx/screens/panel03";
			};
			clsText {
				name = "lblTitle";
				font = Font32;
				flags = kVAlignCenter + kHAlignCenter;
				label = "Anim_Achieve_Title";
				x = 130; y = 18; w = 450; h = 40;
				Scale = 0.33;
				Space = -10;
			};
			clsText {
				name = "lblText";
				font = Font26;
				flags = kVAlignCenter + kHAlignCenter;
				label = "lblFinishQuestTitle";
				x = 130; y = 55; w = 450; h = 40;
				Scale = 0.25;
				Space = -10;
			};
		};
		-- AchievePanel2
		Bitmap {
			name = "bmpAchievePanel2";
			image = "gpx/screens/panel_achievements.png";
			x = 489; y = 827;
			alpha = true;
			Bitmap {
				name = "bmpIcon";
				x = 15; y = 15;
				image = "gpx/screens/panel03";
			};
			clsText {
				name = "lblTitle";
				font = Font32;
				flags = kVAlignCenter + kHAlignCenter;
				label = "Anim_Achieve_Title";
				x = 130; y = 18; w = 450; h = 40;
				Scale = 0.33;
				Space = -10;
			};
			clsText {
				name = "lblText";
				font = Font26;
				flags = kVAlignCenter + kHAlignCenter;
				label = "lblFinishQuestTitle";
				x = 130; y = 55; w = 450; h = 40;
				Scale = 0.25;
				Space = -10;
			};
		};
		-- AchievePanel1
		Bitmap {
			name = "bmpAchievePanel1";
			image = "gpx/screens/panel_achievements.png";
			x = 489; y = 827;
			alpha = true;
			Bitmap {
				name = "bmpIcon";
				x = 15; y = 15;
				image = "gpx/screens/panel03";
			};
			clsText {
				name = "lblTitle";
				font = Font32;
				flags = kVAlignCenter + kHAlignCenter;
				label = "Anim_Achieve_Title";
				x = 130; y = 18; w = 450; h = 40;
				Scale = 0.33;
				Space = -10;
			};
			clsText {
				name = "lblText";
				font = Font26;
				flags = kVAlignCenter + kHAlignCenter;
				label = "lblFinishQuestTitle";
				x = 130; y = 55; w = 450; h = 40;
				Scale = 0.25;
				Space = -10;
			};
		};
		-- AchievePanel0
		Bitmap {
			name = "bmpAchievePanel0";
			image = "gpx/screens/panel_achievements.png";
			x = 489; y = 827;
			alpha = true;
			Bitmap {
				name = "bmpIcon";
				x = 15; y = 15;
				image = "gpx/screens/panel03";
			};
			clsText {
				name = "lblTitle";
				font = Font32;
				flags = kVAlignCenter + kHAlignCenter;
				label = "Anim_Achieve_Title";
				x = 130; y = 18; w = 450; h = 40;
				Scale = 0.33;
				Space = -10;
			};
			clsText {
				name = "lblText";
				font = Font26;
				flags = kVAlignCenter + kHAlignCenter;
				label = "lblFinishQuestTitle";
				x = 130; y = 55; w = 450; h = 40;
				Scale = 0.25;
				Space = -10;
			};
		};
    };
}

-- Give our game container window the focus
SetFocus("canvasMemoryWiz");

updateGameUserName();
