class 'YesNoScreenBase' (BaseScreen)

function YesNoScreenBase:__init(name)
    BaseScreen.__init(self, name)
    
    self.yesHandler = nil
	self.noHandler  = nil

    self:setupButtons()
end

function YesNoScreenBase:setupButtons()
    self:getMainEntity():getEntityNamed('bttn_yes').onPress:add(bind(self.onYesButtonClick, self))
    self:getMainEntity():getEntityNamed('bttn_no').onPress:add(bind(self.onNoButtonClick, self))

    -- add sfx-sound on click
    do
        self:getMainEntity():getEntityNamed('bttn_yes'):setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )
        self:getMainEntity():getEntityNamed('bttn_no'):setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )
    end
end

function YesNoScreenBase:__finalize()
end

function YesNoScreenBase:onUpdate(dt)
end

function YesNoScreenBase:onShown()
    self:addHotKey(ERSK_ENTER, bind(self.onYesButtonClick, self))
    self:addHotKey(ERSK_ESCAPE, bind(self.onNoButtonClick, self))
end

function YesNoScreenBase:onYesButtonClick()
    self:onScreenDestroy()

    if self.yesHandler then
        self.yesHandler()
    end
end

function YesNoScreenBase:onNoButtonClick()
    self:onScreenDestroy()

    if self.noHandler then
        self.noHandler()
    end    
end

function YesNoScreenBase:setData(message, yesHandler, noHandler)
    self:getMainEntity():getEntityNamed('textMessage'):setText( StringManager:getString(message) )
     
    self.yesHandler = yesHandler
    self.noHandler  = noHandler
end

function YesNoScreenBase:onScreenDestroy()
     PopUpScreensMgr:pop()

    self:removeAllHanderInHotKey(ERSK_ENTER)
    self:removeAllHanderInHotKey(ERSK_ESCAPE)
end