require( "scripts/style.lua" );


local start="start" ;
local startname="start" ;
local cancel="cancel" ;
local cancelname="cancel" ;
local hire="hire" ;
local hirename="hire" ;
local name="proceeddlg";
local startfunction=function()end; --using this default 'startfunction' because gDialogTable.yes might be overwriten
local cancelfunction=function()end;
local hirefunction=function()end;
local playingTutorial = false;

if (gDialogTable.startlabel) then
	start = gDialogTable.startlabel ;
end
if (gDialogTable.replaylabel) then
	replay = gDialogTable.replaylabel ;
end
if (gDialogTable.startname) then
	startname = gDialogTable.startname;
end
if (gDialogTable.name) then
	name = gDialogTable.name;
end
if (gDialogTable.start) then
	startfunction = gDialogTable.start;
end
if (gDialogTable.cancel) then
	cancelfunction = gDialogTable.cancel;
end
if (gDialogTable.hirelabel) then
	start = gDialogTable.hirelabel ;
end
if (gDialogTable.hirename) then
	startname = gDialogTable.hirename;
end
if (gDialogTable.hire) then
	hirefunction = gDialogTable.hire;
end

if (gDialogTable.tutorial) then
	playingTutorial = gDialogTable.tutorial;
end

if(DestroyTutorialWindow)then
	DestroyTutorialWindow();
end

MakeDialog
{
	--name=name, -- Remember, this is like saying table['name']=name, so it works.
	
	FaderWindow
	{
		wait=0,
		duration=100,
		fit = true,
		startalpha = 0,
		finalalpha = 1,
		skip = false,
	
		Bitmap
		{
			image="backgrounds/shade",
			alpha = 1,
		},
		
		Window
		{
			name=name,
			fit = true,
			Bitmap
			{
				image="backgrounds/dialog",
				--x=kCenter,
				--y=kCenter,
				x=306,
				y=226,

				SetStyle(DialogTitleText),
				Text
				{
					w = kMax,
					x = 0,
					flags = kHAlignCenter + kVAlignCenter,
					name = "proceedtitle",
					label= gDialogTable.title,
				};
				SetStyle(DialogBodyText),
				Text
				{
					name = "proceedbody",
					label= gDialogTable.body,
				};
				SetStyle(ButtonStdOkStyle),
				--ShadowedButton
				Button
				{
					command= startfunction,
					clickSound = "audio/sfx/buttons/default_click.ogg",
					close = true,
					flags = 5,
					--mylabel = GetString("start"),
					label = "start",
					name = startname,
					x = kCenter-10,
					y = kMax-90,
				},
				--ShadowedButton
				Button
				{
					command=hirefunction,
					clickSound = "audio/sfx/buttons/default_click.ogg",
					close = false,
					flags = 5,
					--mylabel = GetString("hire"),
					label = "hire",
					name = hirename,
					x = kMax-97,
					y = kMax-120,
				},
				
				SetStyle(ButtonStdCancelStyle),
				--ShadowedButton
				Button
				{
					command=cancelfunction,
					clickSound = "audio/sfx/buttons/default_click.ogg",
					close = true,
					flags = 5,
					name = cancelname,
					x = kMax-80,
					y = kMax-175,
				},
			},
			Window
			{
				name = "hiretutorialwindow",
				fit = true,
				Bitmap
				{
					image="gui/tutorial/bg_h",
					x = 610, y = 80,
					SetStyle(DialogBodyText),
					Text
					{
						h = kMax-60,
						flags = kVAlignCenter + kHAlignCenter,
						y = 40,
						name = "okbody",
						--label= "tutorial_quest2_produce",
						label="tutorial_hire_txt3",
					};
				},
				Bitmap
				{
					name="giuseppe",
					image="gui/tutorial/giuseppe",
					x=540,
					y=120,
				},
				
				Animation
				{
					w=54,h=116,
					anim_file = "anim/click_arrow_left",
					x=720,
					y=420,
				},
				Blocker
				{
					w = 80, h = 70,
					x = 640, y = 360,
					fake = true,
				},
				
				Blocker
				{
					w=120, h=100,
					x=440, y=440,
					fake = true,
				},
			},
		},
	},
} -- MakeDialog

PlayPopupSound();

if (isPlayingCarreer() and (playingTutorial or HasItem("lock_hire"))) then
	EnableWindow(hirename, false);
end;

if(showHireTutorial)then
	-- don't do EnableWindow("hiretutorialwindow", showHireTutorial);
	-- because showHireTutorial might be undefined ("bad argument")
	EnableWindow("hiretutorialwindow", true);
else
	EnableWindow("hiretutorialwindow", false);
end
