<?xml version="1.0" encoding="utf-8"?>

<objects>

	<script file="gui/common/network.js"/>
	<script file="gui/common/functions_global_object.js"/>
	<script file="gui/gamesetup/gamesetup_mp.js"/>

	<!-- Add a translucent black background to fade out the menu page -->
	<object type="image" z="0" sprite="bkTranslucent"/>

	<object type="image" style="StoneDialog" size="50%-190 50%-120 50%+190 50%+120">

		<action on="Tick">
			onTick();
		</action>

		<object style="TitleText" type="text" size="50%-128 0%-16 50%+128 16">
			Multiplayer
		</object>

                <object name="pageJoin" size="0 32 100% 100%" hidden="true">

			<object type="text" style="CenteredLabelText" size="0 0 400 30">
				Joining an existing game.
			</object>

			<object type="text" size="0 40 200 70" style="RightLabelText">
				Player name:
			</object>

			<object name="joinPlayerName" type="input" size="210 40 100%-32 64" style="StoneInput">
				<action on="Load"><![CDATA[
					this.caption = Engine.GetDefaultPlayerName();
				]]></action>
			</object>

			<object type="text" size="0 80 200 110" style="RightLabelText">
				Server Hostname or IP:
			</object>

			<object name="joinIP" type="input" size="210 80 100%-32 104" style="StoneInput">
				127.0.0.1
			</object>3 100%-33 103 100%-3

			<object type="button" size="50%-144 100%-60 50%-16 100%-32" style="StoneButton">
				Continue
				<action on="Press"><![CDATA[
					if (startJoin(
						getGUIObjectByName("joinPlayerName").caption,
						getGUIObjectByName("joinIP").caption))
					{
						switchSetupPage("pageJoin", "pageConnecting");
					}
				]]></action>
			</object>
		</object>

		<object name="pageHost" size="0 32 100% 100%" hidden="true">

			<object type="text" style="CenteredLabelText" size="0 0 400 30">
				Set up your server to host.
			</object>

			<object type="text" size="0 40 200 70" style="RightLabelText">
				Player name:
			</object>

			<object name="hostPlayerName" type="input" size="210 40 100%-32 64" style="StoneInput">
				<action on="Load"><![CDATA[
					this.caption = Engine.GetDefaultPlayerName();
				]]></action>
			</object>

			<object hidden="true"> <!-- TODO: restore this when the server name is actually used -->
			<object type="text" size="0 80 200 110" style="RightLabelText">
				Server name:
			</object>

			<object name="hostServerName" type="input" size="210 80 100%-32 104" style="StoneInput">
				<action on="Load"><![CDATA[
					this.caption = Engine.GetDefaultPlayerName() + "'s game";
				]]></action>
			</object>
			</object>

			<object type="button" size="50%-144 100%-60 50%-16 100%-32" style="StoneButton">
				Continue
				<action on="Press"><![CDATA[
					if (startHost(
						getGUIObjectByName("hostPlayerName").caption,
						getGUIObjectByName("hostServerName").caption))
					{
						switchSetupPage("pageHost", "pageConnecting");
					}
				]]></action>
			</object>
		</object>

		<object type="button" style="StoneButton" size="50%+16 100%-60 50%+144 100%-32">
			Cancel
			<action on="Press"><![CDATA[cancelSetup();]]></action>
		</object>

		<object name="pageConnecting" hidden="true">
			<object name="connectionStatus" type="text" style="CenteredLabelText" size="0 100 100% 120">
				[Connection status]
			</object>
		</object>

	</object>

</objects>
