function OnCreateContent()
--	dialogScreen = screen;
	
	CreateGraphics();
    CreateButtons();
end

function OnFreeContent()
--	dialogScreen = nil;
--	questionText = nil;
end

function OnUpdate(dt)
end

function OnSetCaptionText(text)
	assert(dialogScreen.captionText ~= nil);
	dialogScreen.captionText:SetText(text);
end

function OnSetQuestionText(text)
	assert(dialogScreen.questionText ~= nil);
	dialogScreen.questionText:SetText(text);
end

------------------------------------------------------------------------------
--// auxiliary functions

function CreateGraphics()
	local bg = CreateSprite(); 
	bg:SetName('DialogWindow');
	bg:AttachTo(dialogScreen);
	bg:SetSprite('DialogWindowSCTexture');
	bg:SetXY(SCREEN_WIDTH/2.0, SCREEN_HEIGHT/2.0);
	bg:SetZ(0.1);
	bg:SetVisible(true);

	local textTitle = CreateTextEntity('GUICaptionFont', '');
	textTitle:SetName('DialogWindowTitle');
    textTitle:AttachTo(bg);
	textTitle:SetXY(0.0, -160.0);
	textTitle:SetZ(0.1);
	textTitle:SetScale(1.2);

	questionText = CreateTextEntity('GUITextFont', '');
	questionText:SetName('DialogWindowMessage');
    questionText:AttachTo(bg);
	questionText:SetXY(0.0, -80.0);
	questionText:SetZ(1.0);
	
	dialogScreen.captionText = textTitle;
	dialogScreen.questionText = questionText;

	CreateWindowShade(bg);
end

function CreateButtons()
	do
		local button = CreateButton('ButtonUp','ButtonOver','ButtonDown', 'YES', dialogScreen);
		button:AttachTo(dialogScreen);
		button:SetXY(SCREEN_WIDTH/2.0 - 83.0, 530.0);
		button:SetZ(1);
		button:SetVisible(true);

		local caption = CreateTextEntity('GUICaptionFont', 'YES');
		caption:SetName('YesButtonCaption');
	    caption:AttachTo(button);
		caption:SetXY(0,0);
		caption:SetZ(1.0);
	end
	do
		local button = CreateButton('ButtonUp','ButtonOver','ButtonDown', 'NO', dialogScreen);
		button:AttachTo(dialogScreen);
		button:SetXY(SCREEN_WIDTH/2.0 + 83.0, 530.0);
		button:SetZ(1);
		button:SetVisible(true);

		local caption = CreateTextEntity('GUICaptionFont', 'NO');
		caption:SetName('NoButtonCaption');
	    caption:AttachTo(button);
		caption:SetXY(0,0);
		caption:SetZ(1.0);
	end
	PlaySound('L99S08');
end

