//=============================================================================
// ComputerScreenATM
//=============================================================================
class SJoin extends ComputerUIWindow;

var MenuUIActionButtonWindow btnLogin;
var MenuUIEditWindow         editAccount;
var localized String AccountLabel;



#exec TEXTURE IMPORT NAME=MMJoinz1 FILE=Textures\MMJoinz1.bmp
#exec TEXTURE IMPORT NAME=MMJoinz2 FILE=Textures\MMJoinz2.bmp


function CloseScreen(String action)
{
}

function CreateControls()
{
	Super.CreateControls();
	btnLogin  = winButtonBar.AddButton(ButtonLabelLogin,  HALIGN_Right);
	CreateMenuLabel(10, 111, AccountLabel, winClient);
	editAccount = CreateMenuEditWindow(131, 109, 143, 24, winClient);
	winTitle.SetTitle(Title);
}


function UpdateStatus()
{
	winTitle.SetTitle(Title);
}

function SetCompOwner(ElectronicDevices newCompOwner)
{
	SetFocusWindow(editAccount);
	Super.SetCompOwner(newCompOwner);
}

function SetNetworkTerminal(NetworkTerminal newTerm)
{
	Super.SetNetworkTerminal(newTerm);
	if (winTerm != None)
		winTerm.SetHackButtonToReturn();
}

function bool ButtonActivated( Window buttonPressed )
{
	local bool bHandled;
	bHandled = True;

	switch( buttonPressed )
	{
		case btnLogin:
			ProcessLogin();
			break;

		default:
			bHandled = False;
			break;
	}

	if (bHandled)
		return True;
	else
		return Super.ButtonActivated(buttonPressed);
}

event bool EditActivated(window edit, bool bModified)
{
	if (btnLogin.IsSensitive())
	{
		ProcessLogin();
		return True;
	}
	else
	{
		return False;
	}
}

function ProcessLogin()
{
	local string str;
	str = editAccount.GetText();
	JoinBox(CompOwner).address = str;

	if (winTerm != None)
		winTerm.CloseScreen("EXIT");
}

event bool TextChanged(window edit, bool bModified)
{
	EnableButtons();
	return False;
}

function EnableButtons()
{
	btnLogin.SetSensitivity((editAccount.GetText() != ""));
}


defaultproperties
{
     AccountLabel="Password:"
     Title="MainMan's City"
     ClientWidth=303
     ClientHeight=231
     verticalOffset=30
     clientTextures(0)=Texture'MMStart.MMJoinz1'
     clientTextures(1)=Texture'MMStart.MMJoinz2'
     textureRows=1
     textureCols=2
     bAlwaysCenter=True
     statusPosY=206
}
