print("Init Start Menu begin")


local menu = game:getSceneManager():getStartMenu()
local font = game:getFontResource("occ24bg")

local vault = resourceManager:getVault(ResourceManager.COMMON)

local wndPosX = 213 
local wndPosY = 252

local frameW = 207
local frameH = 340

local spriteBG = KrSprite(vault:GetSpriteResource("mainScreenBG"))
-- aniPoolWindowFrame(spriteBG)
aniFadeInFadeOut(spriteBG, 0, 1, 0, 255)
-- spriteBG:SetPos(196, 47, -1)
menu:setBackground(spriteBG)




-- инициализация заголовка окна

local x = 1024 / 2; 
local y = 644
local offsetY = 35 + 10

local time = 1;
local outTime = 0.1; 
buttDelay = 0
buttDelayDelta = 0
buttFadeTime = .1

--[[
buttDelay = 8
buttDelayDelta = -.1
buttFadeTime = .8
]]--

-- create player name label

	local rText = 255;
	local gText = 241;
	local bText = 159;
	local aText = 230;

	local rHText = 255;
	local gHText = 255;
	local bHText = 255;
	local aHText = 216;


local textBox = KrTextBox(game:getFontResource("occ24bg"), 1024, 82, -2, KrTextBox.CENTER);
aniFadeInFadeOut(textBox,0,1,0)

setTextColor(textBox, 255, 0, 0, 255);
textBox:SetPos(0, 240, -1);
textBox:SetText(getText("Welcome Alex!"), 0)
textBox:SetText(getText("If it's not you click here"), 1)
                   
menu:setPlayerNameLabel(textBox)

textBox = KrTextBox(game:getFontResource("occ24bg"), 1024, 82, -2, KrTextBox.CENTER);
aniFadeInFadeOut(textBox,0,1,0,230)

setTextColor(textBox, 255, 255, 160, 230);
textBox:SetPos(0, 240, -1);
textBox:SetText(getText("Welcome Alex!"), 0)
textBox:SetText(getText("If it's not you click here"), 1)


menu:setPlayerName2Label(textBox)

-- Кнопки меню

	
	local button = XButton();

	rText = 245;
	gText = 203;
	bText = 99;
	aText = 216;

	rHText = 255;
	gHText = 255;
	bHText = 255;
	aHText = 216;

	local width = 160
	local height = 40
	local sensX = -82
	local sensY = -20
	local textY = sensY + 10;

	local btnShift = 62;
		
	initXBtn(button, "Btn_XXX", x, y, sensX, sensY, width, height, vault)
	initXButtonText(button, getText("START_MENU.BUTTONS.BTN_EXIT"),
						sensX, textY, 
						width, height, 
						"occ24bg", KrTextBox.CENTER)

	button:setTextColor(rText, gText, bText, aText);
	button:setTextColorBType(XButton.NORMAL_HIGHLIGHTED, rHText, gHText, bHText, aHText);
	button:setTextColorBType(XButton.NORMAL_PRESSED, rHText, gHText, bHText, aHText);

	aniFadeInFadeOut(button:getRoot(),buttDelay,time,outTime)
	buttDelay = buttDelay + buttDelayDelta

	menu:setExitButton(button)

	local button = XButton();

	y = y - btnShift;

	initXBtn(button, "Btn_XXX", x, y, sensX, sensY, width, height, vault)
	initXButtonText(button, getText("START_MENU.BUTTONS.BTN_AUTHORS"),
						sensX, textY, 
						width, height, 
						"occ24bg", KrTextBox.CENTER)

	button:setTextColor(rText, gText, bText, aText);
	button:setTextColorBType(XButton.NORMAL_HIGHLIGHTED, rHText, gHText, bHText, aHText);
	button:setTextColorBType(XButton.NORMAL_PRESSED, rHText, gHText, bHText, aHText);

	aniFadeInFadeOut(button:getRoot(),buttDelay,time,outTime)
	buttDelay = buttDelay + buttDelayDelta

	menu:setAuthorsButton(button)


	local buttonHelp = XButton();

	y = y - btnShift;

	initXBtn(buttonHelp, "Btn_XXX", x, y, sensX, sensY, width, height, vault)
	initXButtonText(buttonHelp, getText("START_MENU.BUTTONS.BTN_HELP"),
						sensX, textY, 
						width, height, 
						"occ24bg", KrTextBox.CENTER)

	buttonHelp:setTextColor(rText, gText, bText, aText);
	buttonHelp:setTextColorBType(XButton.NORMAL_HIGHLIGHTED, rHText, gHText, bHText, aHText);
	buttonHelp:setTextColorBType(XButton.NORMAL_PRESSED, rHText, gHText, bHText, aHText);

	aniFadeInFadeOut(buttonHelp:getRoot(),buttDelay,time,outTime)
	buttDelay = buttDelay + buttDelayDelta

	menu:setHelpButton(buttonHelp)



	local button = XButton();

	y = y - btnShift;

	initXBtn(button, "Btn_XXX", x, y, sensX, sensY, width, height, vault)
	initXButtonText(button, getText("START_MENU.BUTTONS.BTN_SETTINGS"),
						sensX, textY, 
						width, height, 
						"occ24bg", KrTextBox.CENTER)

	button:setTextColor(rText, gText, bText, aText);
	button:setTextColorBType(XButton.NORMAL_HIGHLIGHTED, rHText, gHText, bHText, aHText);
	button:setTextColorBType(XButton.NORMAL_PRESSED, rHText, gHText, bHText, aHText);

	aniFadeInFadeOut(button:getRoot(),buttDelay,time,outTime)
	buttDelay = buttDelay + buttDelayDelta

	button:setEnabled(true)
	menu:setSettingsButton(button)


	local button = XButton();


	y = y - btnShift;

	initXBtn(button, "Btn_XXX", x, y, sensX, sensY, width, height, vault)
	initXButtonText(button, getText("START_MENU.BUTTONS.BTN_CREATIVE"),
						sensX, textY, 
						width, height, 
						"occ24bg", KrTextBox.CENTER)

	button:setTextColor(rText, gText, bText, aText);
	button:setTextColorBType(XButton.NORMAL_HIGHLIGHTED, rHText, gHText, bHText, aHText);
	button:setTextColorBType(XButton.NORMAL_PRESSED, rHText, gHText, bHText, aHText);

	aniFadeInFadeOut(button:getRoot(),buttDelay,time,outTime)
	buttDelay = buttDelay + buttDelayDelta

	button:setEnabled(true)
	menu:setCreativeButton(button)



	local buttonStart = XButton();

	y = y - btnShift;

	initXBtn(buttonStart, "Btn_XXX", x, y, sensX, sensY, width, height, vault)
	initXButtonText(buttonStart, getText("START_MENU.BUTTONS.BTN_START"),
						sensX, textY, 
						width, height, 
						"occ24bg", KrTextBox.CENTER)

	buttonStart:setTextColor(rText, gText, bText, aText);
	buttonStart:setTextColorBType(XButton.NORMAL_HIGHLIGHTED, rHText, gHText, bHText, aHText);
	buttonStart:setTextColorBType(XButton.NORMAL_PRESSED, rHText, gHText, bHText, aHText);

	aniFadeInFadeOut(buttonStart:getRoot(),buttDelay,time,outTime)
	buttDelay = buttDelay + buttDelayDelta

	menu:setStartButton(buttonStart)




	local button = XButton();

	x = x - 300;

	initXBtn(button, "Btn_here", 578 + 17, 290, 0, -40, 42, 43, vault)
--	initXButtonText(button, getText("START_MENU.BUTTONS.BTN_CHANGE_PLAYER"),
	initXButtonText(button, " ",
						sensX, textY, 
						width, height, 
						"occ24bg", KrTextBox.CENTER)

	button:setTextColor(rText, gText, bText, aText);
	button:setTextColorBType(XButton.NORMAL_HIGHLIGHTED, rHText, gHText, bHText, aHText);
	button:setTextColorBType(XButton.NORMAL_PRESSED, rHText, gHText, bHText, aHText);

	aniFadeInFadeOut(button:getRoot(),0,time,0)
	buttDelay = buttDelay + buttDelayDelta

	menu:setChangePlayerButton(button)


	button = XButton();

	y = y - btnShift * 10;

	initXBtn(button, "Btn_XXX", x, y, sensX, sensY, width, height, vault)
	initXButtonText(button, getText("START_MENU.BUTTONS.BTN_FAVORITES"),
						sensX, textY, 
						width, height, 
						"occ24bg", KrTextBox.CENTER)

	button:setTextColor(rText, gText, bText, aText);
	button:setTextColorBType(XButton.NORMAL_HIGHLIGHTED, rHText, gHText, bHText, aHText);
	button:setTextColorBType(XButton.NORMAL_PRESSED, rHText, gHText, bHText, aHText);

	aniFadeInFadeOut(button:getRoot(),buttDelay,time,outTime)
	buttDelay = buttDelay + buttDelayDelta

	button:setEnabled(false)
	menu:setFavoritesButton(button)




print("Init Start Menu end")