class 'COKScreen' (BaseScreen)

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

	self.okHandler = nil
    self.textBox = nil

 	-- create button
	do
	    local bttn_ok = self:CreateButton('bttn_ok')
	    bttn_ok:SetAction('OnOkButtonOKScreen', self)
	    bttn_ok:SetActionSound('Menu_button_click')
	    bttn_ok:SetKeyEquivalent(KEY_ENTER)
	end

	do
		local textBox = CreateTextEntity(MENU_FONT, '')
		textBox:SetXY(518, 334)
		textBox:SetZ(181)
		textBox:SetScale(1)
		textBox:AttachTo(screen)
        textBox:SetTracking(-1)
	    textBox:SetSpacing(0.9)
	    textBox:SetBorderSize(450, 100)
		textBox:SetTextAlignment(HGETEXT_CENTER + HGETEXT_MIDDLE)
		self.textBox = textBox
	end
	
	screen:SetXY(0, -50)
end

function COKScreen:OnButtonPress(buttonName)

end

function COKScreen:OnOkButtonOKScreen()
    if self.okHandler then
        self.okHandler()
	else
		PopUpScreensMgr:Pop()
	end
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function COKScreen:SetData(message, okHandler)
    self.textBox:SetText(message)
	self.okHandler = okHandler
end
--------------------------------------------------------------------------------

function CreateOKScreen(message, okCallback, hideActiveScreen)
	local screen = CreateScriptedScreen('data/Scripts/screens/OKScreen.lua', 'COKScreen')
	PopUpScreensMgr:Push(screen, hideActiveScreen, nil)
	screen:GetAssociatedLuaObject():SetData(message, okCallback)
    return screen
end
--------------------------------------------------------------------------------

function DisplayMessage(title, message)
    local topScreen = PopUpScreensMgr:GetTop();
	if topScreen and topScreen:GetAssociatedLuaObject().name == 'COKScreen' then
		return
	end
	
    local scr = CreateOKScreen(message, nil, false);
    scr:GetAssociatedLuaObject().textBox:SetBorderSize(500, 100)
    scr:GetAssociatedLuaObject().textBox:SetXY(512, 370)
end
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function COKScreen: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('WindowOK',anim,512,384,100,0,1,1)
	
	anim = CreateAnimation('data/Texture/GUI/Buttons/bttn_ok.png',0,0,162,104,3,0)
	anim:SetHotSpot(81,52)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bttn_ok',anim,512,583,120,0,1,1)
	
end
-- CLEAR_ON_SAVE_END
