#include "..\\content\\..\\Content\\..\\content\\..\\Content\\ShellScripts\\stddefs.h"

#DEFINE GRFPATH "Assets\\Graphics\\"
#DEFINE SNDPATH "Assets\\Sounds\\"
#DEFINE SCRIPTPATH "Assets\\Scripts\\"

#DEFINE CANCEL_ID 5
#DEFINE PROVIDER_COUNT 5

main
{
	GUI_CREATE
	{
		object o_button[PROVIDER_COUNT + 1]=s_button
		object i_cursor=s_cursor

		sound press = SNDPATH "sfx_button5.wav"
		assign 0, press
		sound typing = SNDPATH "fx_button.wav"
		assign 1, typing

		font3d gFont3d= "arial.ttf"

		string text[PROVIDER_COUNT + 1]
		text[0] = "TCP/IP"
		text[1] = "IPX"
		text[2] = "SERIAL"
		text[3] = "MODEM"
		text[4] = "GUNTech"
		text[5] = "CANCEL"

		string which[PROVIDER_COUNT]
		which[0] = SCRIPTPATH "NetworkTCPIP.script"
		which[1] = SCRIPTPATH "NetworkIPX.script"
		which[2] = SCRIPTPATH "NetworkSerial.script"
		which[3] = SCRIPTPATH "NetworkModem.script"
		which[4] = SCRIPTPATH "NetworkGunTech.script"

		// construct service provider buttons
		for(int i=0; i < PROVIDER_COUNT; i++)
		{
			$$CheckThisConnection$$ = i+1
			callback($$IsConnectionAvailable$$)
			if ($$Available$$==0)
			{
				o_button[i].greyed = 1
			}

			o_button[i].location=getresx()/2-20,getresy()/3+i*20,1
			o_button[i].id = i
			initialize(o_button[i])
		}

		// construct cancel button
		o_button[PROVIDER_COUNT].location=getresx()/2-20,getresy()/3+7*20,1
		o_button[PROVIDER_COUNT].id = PROVIDER_COUNT
		initialize(o_button[PROVIDER_COUNT])
	}

	GUI_DRAW
	{
		setpencolor(0xff000000)
		drawrect 0,0 to getresx(),getresy()
		print3d_margins = 0,0 to getresx(), getresy();
		print3d_attributes = gFont3d, 0xffffffff, 2,0,1,0,0
		print3d_position = getresx()/2 - (getprint3dwidth("Generic Networking GUI"))/2,getresy()/5
		print3d "Generic Networking GUI"
	}
}



s_button
{
	GUI_CREATE
	{
		int button_state = 0
		int greyed = 0
		int bcolor
		int id= 1
		region=0,0 to 64,16
		framerate=1

	}			

	GUI_INIT
	{
		if (!greyed)
			bcolor = 0xff0000ff
		else
			bcolor = 0xff000040
	}

	REGION_ENTERED
	{
		if (!greyed)
			bcolor = 0xff8080ff
	}


	REGION_EXITED
	{
		if (!greyed)
			bcolor = 0xff0000ff
	}

	LBUTTON_UPDATE
	{
		if (!greyed)
		{
			if (mouse.left == BUTTON_PRESSED)
				bcolor =  0xffa0a0ff
			if (mouse.left == BUTTON_CLICKED)
			{
				play 0

				// check if provider button or cancel button
				if id==PROVIDER_COUNT
				{
					$$gConnectionType$$ = -1
					callback($$SetShellCommand$$, END_NETWORK_STARTUP_SHELL_COMMAND)
					script_end
				}
				else
				{
					$$gConnectionType$$ = id
					script_run which[id], 0x1000
					script_end
				}
			}
		}
	}

	GUI_DRAW
	{
		setpencolor(bcolor)
		ldrawrect region
		print3d_margins = 0,0 to getresx(), getresy();
		print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0
		print3d_position =location.x+8, location.y+2
		print3d text[id]
	}
}


s_cursor
{
	GUI_CREATE
	{
		pane_create pic=16,32,1,volatile
		alphamode(pic)=am_alpha_alphainvalpha

		bitmap bm=GRFPATH "mouse_pointer.tga"
		blit bm,0,0 on pic
		update(pic)
		
		location=0,0,2
	}

	GUI_DRAW
	{
		render pic, mouse.x, mouse.y, 2
	}
}


