class 'CYesNoScreen' (BaseScreen)

function CYesNoScreen:__init(name, screen)
	BaseScreen.__init(self, name, screen)

	self.yesHandler = nil
	self.noHandler  = nil
	
	local bttn_yes = self:CreateButton('bttn_yes',	'OnYesButtonClick',  KEY_ENTER)
	local bttn_no  = self:CreateButton('bttn_no',	'OnNoButtonClick',   KEY_ESCAPE)
	
	bttn_yes:SetAction('OnYesButtonClick', self)
	bttn_no:SetAction('OnNoButtonClick', self)
	
	bttn_yes:SetActionSound("Menu_button_click")
	bttn_no:SetActionSound("Menu_button_click")
	
    do
	    local text = CreateTextEntity(MENU_FONT, '')
	    text:AttachTo(screen)
	    text:SetXY(512, 334)
	    text:SetZ(120)
	    text:SetScale(1)
	    text:SetRect(412, 264, 200, 100)
	    text:SetTracking(-1)
	    text:SetSpacing(0.9)
	    text:SetBorderSize(450, 100)
	    text:SetTextAlignment(HGETEXT_MIDDLE + HGETEXT_CENTER)
	    self.textMessage = text
    end
    
    screen:SetXY(0, -50)
end
--------------------------------------------------------------------------------

function CYesNoScreen:OnYesButtonClick()
    assert(self.yesHandler)
    
    PopUpScreensMgr:Pop()
	Helpers.CallFunctionByName(self.yesHandler)
end
--------------------------------------------------------------------------------

function CYesNoScreen:OnNoButtonClick()
    assert(self.noHandler)
    
    PopUpScreensMgr:Pop()
	Helpers.CallFunctionByName(self.noHandler)
end
--------------------------------------------------------------------------------

function CYesNoScreen:SetData(message, yesHandler, noHandler)
    self.textMessage:SetText(GetString(message))
	self.yesHandler = yesHandler
	self.noHandler  = noHandler
end

--------------------------------------------------------------------------------
function CreateYesNoScreen(message, yesCallback, noCallback, hideActiveScreen)
    if not hideActiveScreen then
        hideActiveScreen = false
    end

	local screen = CreateScriptedScreen('data/Scripts/screens/YesNoScreen.lua', 'CYesNoScreen')
	screen:GetAssociatedLuaObject():SetData(message, yesCallback, noCallback)
    PopUpScreensMgr:Push(screen, hideActiveScreen, nil)
    return screen
end
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function CYesNoScreen:LoadData(screen)
    local anim
	anim = CreateAnimation('data/Texture/GUI/OK/WindowOK.png',0,0,580,450,1,0)
	anim:SetHotSpot(290,225)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('YesNoScreenBackground',anim,512,384,100,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/Buttons/bttn_yes.png',0,0,162,104,3,0)
	anim:SetHotSpot(81,52)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_yes',anim,425,584,120,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/Buttons/bttn_no.png',0,0,162,104,3,0)
	anim:SetHotSpot(81,52)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_no',anim,601,584,100,0,1,1)
end
-- CLEAR_ON_SAVE_END
