require "scripts/style"
require "scripts/widgets/shade"

local ok="ok" ;	
local okname="okbutton" ;	

local nextButton="next" ;	
local nextname="nextbutton" ;	

local skip="skip" ;	
local skipname="skipbutton" ;	

local name="popupbox";
	
if (gDialogTable.name) then
	name = gDialogTable.name;
end

function MakePopup(popupname, bg, titley, puw, bw)
 return Bitmap
    {
      name=popupname,
      image=bg,
      -- for some reason, kCenter doesn't work here
      x=kCenter,
      y=kCenter,
	
      SetStyle(DialogTitleText),
      Text
      {      
        y=titley,
        name = "popuptitle",
        label= gDialogTable.title,
      };		
      Bitmap
      {
        name = "popupwrapper",		
        x=puw[1], y=puw[2],
        w=puw[3], h=puw[4], 
        SetStyle(DialogBodyText),
        Text
        {     
          x=0, y=0,
          w=kMax, h=kMax,
          name = "popupbody",
          label= gDialogTable.body,
        };
        AnimSprite
        {
          name="popupimage",
          animations={
            { key="idle", texture="", animation="", default=1},
          },
        },
      },
      Bitmap
      {
        name = "buttonwrapper",
        x = bw[1],        
        y = bw[2],
        w = bw[3],
        h = bw[4],
      
      SetStyle(ButtonStyle),
      Button
      {
        command=
          function()
              ClosePopup(1,false);
          end;
        --close = true,
        flags = 5,
        label = ok,
        name = "button-1",
        x = kCenter - 100,
        y = kCenter,
      },        
      Button
      {
        command=
          function()
              ClosePopup(2,true);
          end;
        --close = true,
        flags = 5,
        label = skip,
        name = "button-2",
        x = kCenter + 0,
        y = kCenter,
      },       
      
      Button
      {
        command=
          function()
              ClosePopup(3,true);
          end;
        --close = true,
        flags = 5,
        label = skip,
        name = "button-3",
        x = kCenter + 100,
        y = kCenter,
      },    
      
      },

    }
end

MakeDialog
{
   
    MakeShade(),
    -- needs to be at 0,0
    name=name, -- Remember, this is like saying table['name']=name, so it works.
    w=kMax,h=kMax,x=0,y=0,

    StateWindow
    {
    x=0, y=0,
    w=kMax, h=kMax,
          name="popup-choice",
          default="popup",
        MakePopup("popup","backgrounds/popup", 45, { 70, 45, kMax-40, kMax-40 }, { 40, kMax - 50, kMax - 20, 50 } ),
        MakePopup("large","backgrounds/bigpopup", 55, { 70, 55, kMax-70, kMax-60 }, { 40, kMax - 50, kMax - 50, 50 } ),
        MakePopup("super","backgrounds/largedialog", 45, { 70, 65, kMax-70, kMax-60 }, { 30, kMax - 50, kMax - 10, 50 } ),
    },

    AnimSprite
    {
      name="arrow",
      x=0, y=0, w=70, h=70,
      animations={
            { key="DoAnimLeft", texture="popup/arrow", animation="DoAnimLeft", default=1},
            { key="DoAnimRight", texture="popup/arrow", animation="DoAnimRight"},
            { key="DoAnimUp", texture="popup/arrow", animation="DoAnimUp"},
            { key="DoAnimDown", texture="popup/arrow", animation="DoAnimDown"},
		  },
    },

} -- MakeDialog
