#textdomain wesnoth-lib
###
### Definition of the main screen for Wesnoth.
###

#define _GUI_BG_HRATIO
    height * 1.0 / image_original_height
#enddef

#define _GUI_BG_WRATIO
    width * 1.0 / image_original_width
#enddef

#define _GUI_BG_RATIO
    (if({_GUI_BG_HRATIO} < {_GUI_BG_WRATIO}, {_GUI_BG_HRATIO}, {_GUI_BG_WRATIO}))
#enddef

#define _GUI_BG_Y
    ((height - image_height)/2)
#enddef

#define _GUI_BG_X
    ((width - image_width)/2)
#enddef

[window_definition]

	id = "title_screen"
	description = "The window definition for the title screen."

	[resolution]

		[background]

			[draw]

				[image]
					w = "(width)"
					h = "(height)"
					x = 0
					y = 0
					name = "(background_image)"
				[/image]

				[image]
                                        w = "(round(image_original_width * {_GUI_BG_RATIO}))"
                                        h = "(round(image_original_height * {_GUI_BG_RATIO}))"
                                        x = "(if({_GUI_BG_X} < 0, 0, {_GUI_BG_X}))"
                                        y = "(if({_GUI_BG_Y} < 0, 0, {_GUI_BG_Y}))"
					name = "(title_image)"
				[/image]

			[/draw]

		[/background]

		[foreground]

			[draw]

			[/draw]

		[/foreground]

	[/resolution]

[/window_definition]
#undef _GUI_BG_HRATIO
#undef _GUI_BG_WRATIO
#undef _GUI_BG_RATIO
#undef _GUI_BG_Y
#undef _GUI_BG_X

#define _GUI_H_SPACER WIDTH GROW_FACTOR
	[column]

		grow_factor = "{GROW_FACTOR}"

		[spacer]
			definition = "default"
			width = "{WIDTH}"
		[/spacer]

	[/column]
#enddef

#define _GUI_V_SPACER HEIGHT
	[column]

		[spacer]
			definition = "default"
			height = {HEIGHT}
		[/spacer]

	[/column]
#enddef

#define _GUI_TIP_SECTION
	[panel]
		definition = "title_screen"

		[grid]

			[row]

				[column]

					[multi_page]
						id = "tips"
						definition = "default"

						[page_definition]

							[row]
								grow_factor = 1

								[column]
									border = "all"
									border_size = 5
									horizontal_grow = "true"
									vertical_grow = "true"

									[label]
										id = "tip"
										definition = "title_screen_tip"

										wrap = "true"
									[/label]

								[/column]

							[/row]

							[row]

								[column]
									border = "all"
									border_size = 5
									horizontal_grow = "true"

									[label]
										id = "source"
										definition = "title_screen_tip"

										text_alignment = "right"
										wrap = "true"
									[/label]

								[/column]

							[/row]

						[/page_definition]

					[/multi_page]

				[/column]

			[/row]

			[row]

				[column]
					horizontal_grow = "true"

					[grid]

						[row]

							[column]
								border = "all"
								border_size = 5
								horizontal_alignment = "left"

								[button]
									id = "help"
									definition = "default"

									label = _ "Help"
									tooltip = _"Show Battle for Wesnoth help"
								[/button]

							[/column]

							[column]
								border = "all"
								border_size = 5
								grow_factor = 1
								horizontal_alignment = "right"

								[button]
									id = "previous_tip"
									definition = "default"

									label = _ "Previous"
									tooltip = _"Show previous tip of the day"
								[/button]

							[/column]

							[column]
								border = "all"
								border_size = 5
								horizontal_alignment = "right"

								[button]
									id = "next_tip"
									definition = "default"

									label = _ "Next"
									tooltip = _"Show next tip of the day"
								[/button]

							[/column]

						[/row]

					[/grid]

				[/column]

			[/row]

		[/grid]

	[/panel]
#enddef


#define _GUI_BUTTON ID CAPTION TOOLTIP
	[row]

		[column]
			border = "all"
			border_size = 5
			horizontal_grow = "true"
			[button]
				id = {ID}
				definition = "default"

				label = {CAPTION}
				tooltip = {TOOLTIP}
			[/button]

		[/column]

	[/row]

#enddef

#define _GUI_MENU_SECTION
	[panel]
		definition = "title_screen"

		[grid]
			{_GUI_BUTTON "tutorial" _"Tutorial" _"Start a tutorial to familiarize yourself with the game"}
			{_GUI_BUTTON "campaign" _"Campaign" _"Start a new single player campaign"}
			{_GUI_BUTTON "multiplayer" _"Multiplayer" _"Play multiplayer (hotseat, LAN, or Internet), or a single scenario against the AI"}
			{_GUI_BUTTON "load" _"Load" _"Load a saved game"}
			{_GUI_BUTTON "addons" _"Add-ons" _"Download usermade campaigns, eras, or map packs"}
			{_GUI_BUTTON "editor" _"Map Editor" _"Start the map editor"}
			{_GUI_BUTTON "language" _"Language" _"Change the language"}
			{_GUI_BUTTON "preferences" _"Preferences" _"Configure the game’s settings"}
			{_GUI_BUTTON "credits" _"Credits" _"View the credits"}
			{_GUI_BUTTON "quit" _"Quit" _"Quit the game"}
			# This debug feature doesn't need to be translated.
			{_GUI_BUTTON "clock" "Clock" "Show debug clock"}
		[/grid]

	[/panel]
#enddef

[window]
	id = "title_screen"
	description = "The game's title screen."

	[resolution]
		definition = "title_screen"

		automatic_placement = "false"
		x = 0
		y = 0
		width = "(screen_width)"
		height = "(screen_height)"

		[tooltip]
			id = "tooltip_large"
		[/tooltip]

		[helptip]
			id = "tooltip_large"
		[/helptip]

		[grid]

			[row]

				{_GUI_V_SPACER 30}

			[/row]

			[row]
				grow_factor = 1

				[column]

					horizontal_grow = "true"
					vertical_grow = "true"

					[stacked_widget]

						[stack]

							[layer]

								[row]

									[column]
										vertical_alignment = "top"

										[progress_bar]
											id = "logo"
											definition = "title_screen"
										[/progress_bar]

									[/column]

								[/row]

							[/layer]

							[layer]

								[row]

									[column]
										horizontal_alignment = "left"
										vertical_alignment = "bottom"

										[label]
											id = "revision_number"
											definition = "title_screen_revision"
										[/label]

									[/column]

								[/row]

							[/layer]

							[layer]

								[row]
									grow_factor = 4

									{GUI_FILLER}

									{GUI_FILLER}

									{GUI_FILLER}

									{_GUI_V_SPACER 50}

									{GUI_FILLER}

								[/row]

								[row]

									{_GUI_H_SPACER 17 1}

									[column]
										vertical_alignment = "bottom"
										horizontal_alignment = "left"
										{_GUI_TIP_SECTION}
									[/column]

									{_GUI_H_SPACER 0 3}

									[column]
										horizontal_alignment = "right"
										vertical_alignment = "bottom"
										{_GUI_MENU_SECTION}
									[/column]

									{_GUI_H_SPACER 17 1}

								[/row]

								[row]
									grow_factor = 1

									{GUI_FILLER}

									{GUI_FILLER}

									{GUI_FILLER}

									{_GUI_V_SPACER 22}

									{GUI_FILLER}

								[/row]

							[/layer]

						[/stack]

					[/stacked_widget]

				[/column]

			[/row]


		[/grid]

	[/resolution]

[/window]

#undef _GUI_TIP_SECTION
#undef _GUI_MENU_SECTION
#undef _GUI_BUTTON
#undef _GUI_H_SPACER
#undef _GUI_V_SPACER
