require "scripts/style"

--------------------------------------
-- 					Init
--------------------------------------
local yes = "yes";
local yesname = "yes";
local no = "no";
local noname = "no";
local name = "popupyesnobox";
local yescmd = gDialogTable.yes;
local nocmd = gDialogTable.no;

-- Setting values 
if (gDialogTable.yeslabel) 
then
	yes = gDialogTable.yeslabel;
end

if (gDialogTable.nolabel) 
then
	no = gDialogTable.nolabel;
end

if (gDialogTable.yesname) 
then
	yesname = gDialogTable.yesname;
end

if (gDialogTable.noname) 
then
	noname = gDialogTable.noname;
end

if (gDialogTable.name) then
	name = gDialogTable.name;
end

--------------------------------------
-- 				Controls
--------------------------------------
txtYesNoTitle = 
	Text
	{
		x = kCenter,
		y = kCenter-90,
		w = 100,
		h = 50,
		name = "yesnotitle",
		label = gDialogTable.title,
	};

txtYesNoBody = 
	Text
	{
		name = "yesnobody",
		x = kCenter,
		y = kCenter - 24,
		w = 340,
		h = 150,
		label = gDialogTable.body,
	};

btnYes = 
	Button
	{
		name = yesname,
		x = kCenter - 110,
		y = kMax - 320,
		close = true,
		flags = 5,
		DefaultButtonLabel(yes),
		command =
			function()
				if (yescmd) 
				then
					yescmd();
				end
			end;
	};

btnNo = 
	Button
	{
		name = noname,
		x = kCenter + 110,
		y = kMax - 320,
		close = true,
		flags = 5,
		DefaultButtonLabel(no),
		command =
			function()
				if (nocmd) 
				then
					nocmd();
				end
			end;
	};
--------------------------------------
-- 				Main Dialog
--------------------------------------
MakeDialog
{
	name = name, 
	Bitmap
	{
		name = "dialogshadow",
		image = "backgrounds/dialogs/backgroundalpha",
	},
	Bitmap
	{
		x = kCenter,
		y = kCenter,
		image = "backgrounds/popups/popupdefault",
		
	
		SetStyle(DialogTitleText),
		txtYesNoTitle,
       
		SetStyle(DialogBodyText),
		txtYesNoBody,
		
		SetStyle(ButtonStyle),
		btnYes,
		btnNo,
    },
}