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

-- When this dialog is popped up, we're entering pause state, so
-- let's just notify TGameState now.
SetState(kPause, true);

EnableAllButtons();

function ButtonDisabled(button)
    return Group {
        Bitmap {
            name = button.name;
            image = button.image;
            x = button.x; y = button.y;
        
            Text {
                name = button.name.. "_text";
                label = button.label;
                font = button.font;
                flags = kPushButtonAlignment;
                x = 0; y = 0;
                w = kMax; h = kMax;
            };
        };
    };
end

MakeDialog {
    name = "PauseDialog";

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

    wndMove {
        x = kCenter; y = kCenter;
		w = kMax; h = kMax;

        wndPause {
            x = 0; y = 0;
            w = kMax; h = kMax;

            Bitmap {
                x = kCenter; y = kCenter;
                image = "gpx/screens/panel02";

                Bitmap {
                    image = "gpx/screens/trophy_icon_01";
                    x = 22;
                    y = 20;
                };

                Bitmap {
                    image = "gpx/screens/trophy_icon_02";
                    x = 424;
                    y = 20;
                };

                clsText {
                    name = "lblTitle";
                    font = Font58;
                    flags = kHAlignCenter + kVAlignCenter;
                    label = "lblPauseTitle";
                    x = 115; y = 34;
                    w = 306; h = 70;
                    Scale = 0.6;
                    Space = -10;
                };

                SetStyle(PauseButtonStyle);
                Button {
                    name = "btnResume";
                    x = 69; y = 131;
                    label = "btnResume";
                    cancel = true;
                    command =
                        function()
                            SetState(kPause, false);
                            PopModal("PauseDialog");
                        end
                };

                Button {
                    name = "btnOptions";
                    x = 283; y = 131;
                    label = "btnOptions";
                    command =
                        function()
                            DoModal("scripts/options.lua");
                        end
                };

                Button {
                    name = "btnInstruction";
                    x = 69; y = 194;
                    label = "btnInstructions";
                    command =
                        function()
                            DoModal('scripts/instructions.lua');
                        end
                };

                Button {
                    name = "btnAchievements";
                    x = 283; y = 194;
                    label = "btnAchievements";
                    command =
                        function()
                            DoModal('scripts/achievement.lua');
                        end
                };
                ButtonDisabled {
                    name = "btnAchievementsDisabled";
                    image = PauseButtonGpx[4];
                    x = 283; y = 194;
                    label = "btnAchievements";
                };

                Button {
                    name = "btnQuit";
                    x = 170; y = 263;
                    label = "quit";
                    command =
                        function()
                            local dlgBody = "quitconfirm_quest";
                            if (gGameStyle == "quick") then
                                dlgBody = "quitconfirm_quick";
                            end
                            result = DisplayDialog {
                                "scripts/yesno.lua";
                                title = "quitgametitle";
                                body = GetString(dlgBody);
                            };
                            if result == 'yes' then
                                SetState(kPause, true);
                                PopModal("PauseDialog");
                                gsw_MemoryWizQuit();
                            end
                        end
                };
            };
        };
    };
};
