require( "scripts/style.lua" );


local playername = gEnterNameValue;

local deleteselected = false;




function OkEditName(a_name, a_testcurent)
	sss = a_name;
	if(IsNameValid(sss)) then 
		if (IsNameInUse(sss, a_testcurent)) then
			SetNameInfosToRun("infodupname");
			DoModal("scripts/infos.lua");
		else
			CloseWindow(sss);
		end
	end
end


MakeDialog
{
	name="EditNameDialog",


		Bitmap
		{
			image="backgrounds/entername",
			x=kCenter,
			y=kCenter,

--			Text
--			{
--				name = "entername",
--				font = {  standardFont, 34,  BlackColor},
--				x=kCenter, y=kCenter - 95,w=500,h=40,
--				flags = kHAlignCenter + kVAlignTop,
--				label = "enternameprompt"
--			},

			EditName
			{
				name="EditName",
				x=0,
				y=0,
				w=kMax,h=kMax,
				okbutt ="b_ok;90,327,108,41;fonts/arial.mvec;128,128,128,255;255,255,255,255;23;buttons/b_ok;buttons/b_ok_pressed;buttons/b_ok_mouseover",
				cancelbutt ="b_cancel;240,327,108,41;fonts/arial.mvec;128,128,128,255;255,255,255,255;23;buttons/b_cancel;buttons/b_cancel_pressed;buttons/b_cancel_mouseover",
				shadow ="backgrounds/sh1;0,0,1024,768;0.3;0.8",

				TextEdit
				{
					font = { standardFont,  30,  WhiteColor},
					flags = kHAlignCenter,
					name = "nameedit",
					label = playername,
					clearinitial = deleteselected,
					x=kCenter,y= kCenter + 84, w=290,h=kMax,
					length=10,
					utf8=true,
					ignore = kIllegalNameChars

				},
			}
		},

}

SetFocus( "nameedit" );


