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

gQuitVerifyActive = 1;

local isSettingPause = false;
function setPause(pause)
    if (isSettingPause) then
        SetState(kPause, pause);
    end
end

if GetState(kPause) == "0"  then
    isSettingPause = true;
    setPause(true);
end

local oldButtonsDisabled = gAllButtonsDisabled;
EnableAllButtons();

MakeDialog {
    name = "QuitVerifyDialog";

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

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

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

            Bitmap {
                image = "gpx/screens/trophy_icon_01";
                scale = 0.65;
                x = 2; y = 3;
            };

            Bitmap {
                image = "gpx/screens/trophy_icon_02";
                scale = 0.65;
                x = 264; y = 3;
            };

            clsText {
                name = "lblTitle";
                font = Font36;
                label = "quit?";
                x = kCenter; y = 10; w = 329; h = 70;
                flags = kHAlignCenter + kVAlignCenter;
                Scale = 0.4;
                Space = -10;
            };

            Text {
                name = "lblQuitGame";
                font = Font16;
                label = "lblQuitGame";
                flags = kHAlignCenter + kVAlignCenter;
                x = 0; y = 80; w = 329; h = 50;
            };

            SetStyle(SmallButtonStyle);
            Button {
                name = "btnYes";
                label = "btnYes";
                x = 185; y = 145;
                command =
                    function()
                        setPause(false);
                        PostMessage(CreateNamedMessage(kQuitNow, "quit"));
                    end
            };
            Button {
                name = "btnNo";
                label = "btnNo";
                x = 35; y = 145;
                cancel = true;
                command =
                    function ()
                        gQuitVerifyActive = 0;
                        setPause(false);
                        PopModal("QuitVerifyDialog");

                        if oldButtonsDisabled == true then
                            DisableAllButtons();
                        else
                            EnableAllButtons();
                        end
                    end
            };
        };
    };
}
