require( "scripts/style.lua" );


MyFont = {
  standardFont,
  30,
  BorderColor
};

NameFont = {
  standardFont,
  18,
  MenuRedColor
};

TipFont = {
  standardFont,
  12,
  BorderColor
};

local playername = gEnterNameValue;




MakeDialog
{
	Bitmap
	{ 
		image="backgrounds/popup",
		x=kCenter,
		y=kCenter,
		
		EnterNameWindow
		{
			x=0,y=0,w=kMax,h=kMax,
			Text
			{
				font = MyFont,
				name = "entername",
				x=0,y=120,w=kMax,h=30,
				flags = kHAlignCenter + kVAlignTop,
				label = "entername"
			};
			
			Bitmap
			{
				image="backgrounds/textfield.png",
				x=kCenter,
				y=180,
				
				TextEdit
				{
					font = NameFont,
					name = "nameedit",
					label = playername,
					x=5,y=6,w=kMax-5,h=kMax,
					length=12,
					ignore = kIllegalNameChars
					
				};
			};
				
			SetStyle(StandardButtonStyle);
			Button
			{
				x=35,
				y=230,
				name="enterok",
				label="ok",
				default = true,
				command = 
					function()
						if (IsNameInUse(GetLabel("nameedit"))) then
							DisplayDialog { 
								"scripts/ok.lua", 
								body ="nameinuse",
								title = ""
							};
							SetFocus( "nameedit" )
						else
							CloseWindow(GetLabel("nameedit"));
						end
					end
			},
			
			
			
			Button
			{
				x=235,
				y=230,
				name="entercancel",
				label="cancel",
				command = 
					function()
						CloseWindow(nil);
					end
			};
			
			Button
			{
				x=280,
				y=285,
				scale = 0.7,
				name="advanced",
				label="advanced",
				command = 
					function()
						if (IsNameInUse(GetLabel("nameedit"))) then
							DisplayDialog { 
								"scripts/ok.lua", 
								body ="nameinuse",
								title = ""
							};
							SetFocus( "nameedit" )
						else
							CloseWindow(GetLabel("nameedit"));
							gGotoSSSGLogin = true;
						end
					end
			};
			
			SetStyle(DefaultStyle);
			
			Text
			{
				font = TipFont,
				name = "advancedtip",
				x=50,y=280,w=220,h=60,
				flags = kHAlignLeft + kVAlignTop,
				label = "advancedtip",
				padding = 0
			};
		}
		
	},
	
	SetFocus( "nameedit" )
}



