require( "scripts/style.lua" );

mmaxNumUsers = 5

function FuncDeleteUser()
	DeleteUser(GetCurrentSelectedUser())
	FillUserDataList();
	SetWelcomeName();
end
				
function TestDeleteUser()
	if (GetNumUsers() > 1 ) then 
		result = DisplayDialog { 
			"scripts/yesno.lua", 
			body ="deleteconfirm",
			title = "deletetitle" 
		}
	else
		SetNameInfosToRun("infolastuser");
		DoModal("scripts/infos.lua");
	end	
	SetFocus( "ChoosePlayerWindow" );
end


function TestRenameUser()
	gEnterNameValue = GetSelectedPlayerName();
	name = DoModal("scripts/editname.lua");
	if (not(name == nil)  and IsNameValid(name) ) then
		SetCurrentUser(GetCurrentSelectedUser(), true);
		ChangeCurrentUserName(name);
		FillUserDataList();
		SetWelcomeName();
	end
	SetFocus( "ChoosePlayerWindow");
end


function TestCreateUser()
	if ( GetNumUsers() < mmaxNumUsers) then 
		gEnterNameValue = "";
		name = DoModal("scripts/addname.lua");
		if (not(name == nil) and IsNameValid(name) ) then
			CreateNewUser(name);
			SetisFemale(gIsFemaleChoosen);
			FillUserDataList();
			SetWelcomeName();
		end
		else
			SetNameInfosToRun("infonumusers");
			DoModal("scripts/infos.lua");
		end	
		SetFocus( "ChoosePlayerWindow" );
	end


MakeDialog
{
	-- Name the modal dialog
	name="ChoosePlayerModal",
	Bitmap
	{ 
		image="backgrounds/profiles",
		x=kCenter,
		y=kCenter,
		
		ChoosePlayerWindow
		{
			name="ChoosePlayerWindow",
			x = 0, y = 0, w=kMax, h=kMax,
		    	maxNumUsers = mmaxNumUsers,
			listFontName = "fonts/arial.mvec",
			fontH = 30,
			shiftDy = 43,
			shDx = 0, shDy = 0,
			listRect = "82, 80, 285, 32",
			listTextColor = "185,185,155,255",
			listActTextColor = "255,255,255,255",
			listActRectColor = "128,128,128,128",
			--listTextColorSh = "128,0,0,128",
			--listActTextColorSh = "0,128,0,128",
			
                
			butadd ="b_create;10, 327,105,41;fonts/arial.mvec;215,215,215,255;255,255,255,255;23;buttons/profiles/b_add;buttons/profiles/b_add_pressed;buttons/profiles/b_add_mouseover",
			butrename ="b_rename;115, 327,108,41;fonts/arial.mvec;215,215,215,255;255,255,255,255;23;buttons/profiles/b_edit;buttons/profiles/b_edit_pressed;buttons/profiles/b_edit_mouseover",
			butdelete ="b_delete;220, 327,108,41;fonts/arial.mvec;215,215,215,255;255,255,255,255;23;buttons/profiles/b_delete;buttons/profiles/b_delete_pressed;buttons/profiles/b_delete_mouseover",
			butok ="b_ok;325, 327,108,41;fonts/arial.mvec;215,215,215,255;255,255,255,255;23;buttons/b_ok;buttons/b_ok_pressed;buttons/b_ok_mouseover",	 			shadow ="backgrounds/sh1;0,0,1024,768;0.3;0.8",
			
		};
	}
}

SetFocus( "ChoosePlayerWindow" );



--SetPlayerChoices();

