/**************************************************************************

template_widget.tgi
Copyright © 2002-2003 TimeGate Studios

DESCRIPTION:	Widgets for the user interface.  Widgets are the code side of 
		the user interface.  The widget hierarchy is specified by code,
		so the data must match up with the hierarchy and names in the code.

REVISION HISTORY:
pcb100702 - created

USAGE:
	
	[WidgetName Template=Widget]			;; a static widget (has no functionality)
	[WidgetName Template=PanelWidget]		;; panels, layers
	[WidgetName Template=Interface]			;; interfaces use this
	[WidgetName Template=ToggleButtonWidget]
	[WidgetName Template=PushButtonWidget]
	[WidgetName Template=LabelWidget]
	[WidgetName Template=DecalWidget]
	[WidgetName Template=...]

EXAMPLE:

	[Delete Template=PushButtonWidget]
	{
		pressed_client_L = 12
		pressed_client_T = 12
		pressed_client_R = 8r
		pressed_client_B = 8b

		[Client Template=Widget]
		{
			[View Template=DecalVE]
			;; client bounds will be overridden when pressed
			L = 10
			T = 10
			R = 10r
			B = 10b
			texture = "button/some_push_button_image.tga"
		}

		[View Template=GroupVE]
		{
			L = 0
			T = 0
			R = 0r
			B = 0b

			[Child Template=DecalVE]
			when = UNFOCUSED
			texture = button/button_background_unfocused.tga

			[Child Template=DecalVE]
			when = FOCUSED + UNSELECTED
			texture = button/button_background_focused_unselected.tga"

			[Child Template=DecalVE]
			when = FOCUSED + SELECTED
			texture = button/button_background_focused_selected.tga
		}
	}

**************************************************************************/

;; -------------------------------------
;; WidgetTransitionFXs
;; -------------------------------------

[Template WidgetTransitionFX]
{
	;; type of effect (set by derived nodes)
	string type
	
	;; delay before starting (in seconds)
	float delay = 0
	
	;; the duration of the transition (in seconds)
	float duration = 0

	;; true to propagate this transition to the widget's children
	bool propagate = false
}

[Template WTFXColorAlpha Inherit=WidgetTransitionFX]
{
	type = COLORALPHA
	
	;; specify starting and ending colors
	point3	start_color = 1,1,1
	float	start_alpha = 1
	point3	end_color = 1,1,1
	float	end_alpha = 1
}

;; -------------------------------------
;; Widget
;; -------------------------------------


[Template Widget]
{
	;; hidden field - defined by appropriate template
	string	type = STATIC
	
	;; visible = set to false to hide the widget. 
	;; NOTE: the code explicitly sets visibility on certain widgets, so this flag won't always work.
	visible = true
	
	;; intercept_pick = set to true to make a parent widget selectable.
	;; mainly used if the parent widget's bounds is larger than the child widget and you want the
	;; parent widget's bounds used for testing in the TGC_GroupVE::Pick function.
	intercept_pick = false
	
	;; max_child_count = the guesstimated number of children that this widget could have. 
	;; This number is used to help performance of drawing widgets. It should be as close as possible
	;; to the accurate number (for best performance)
	max_child_count = 15

	;; derived classes may implement a ToolTip (the tooltip name shows up as the tooltip title)
	localized tooltip_name = ""
	localized tooltip = ""

	;; render_threshold - setting this to X means the widget will not
	;;   render its view elements the UI render level goes above X.
	;;   Not setting it will default to the code-assigned default value.
	;;   The UI render level is changed with the "ui [level]" command.

	
	;; cwp052804 - removed, Game Interface now creates a list of script commands instead of widget
	;; names.  This allows for more flexibility.
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;; if true, this widget can be targeted by triggers (for purposes such as highlighting a
	;; button in the tutorial)
	;;trigger_targetable = false
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	[optional RenderThreshold]
	int	render_threshold
	
	;; View - GroupVE to list the decals and other view elements to visualize the widget.
	[View Template=ViewElement]

	;; optional transition fxs
	[list ActivateTransitionFX Template=WidgetTransitionFX]
	[list DeactivateTransitionFX Template=WidgetTransitionFX]
}

;; This template means a basic widget type.  Not a button, panel, or anything else complicated.
[Template StaticWidget Inherit=Widget]
{
}

[Template StaticLabelWidget Inherit=StaticWidget]
{
	max_child_count = 0
	[View Template=LabelVE]
}

[Template StaticDecalWidget Inherit=StaticWidget]
{
	max_child_count = 0
	[View Template=DecalVE]
}

[Template PanelWidget Inherit=Widget]
{
	type = PANEL
	max_child_count = 50
	
	;; sets sound to play upon pressing/depressing the button
	string	set_sound = NULL
	string	unset_sound = NULL
}

[Template Interface Inherit=PanelWidget]
{
	;; This specifies what interface music should be played during this screen. Please note that
	;; if NULL, the currently playing music will continue to play. To be silent, inherit from the
	;; SilentInterface template instead.
	string interface_music = NULL
	
	;; if true, shows the menu background NIFVE
	bool show_menu_background = false
	
	bool show_logo_and_build_stamp = false
}

[Template SilentInterface Inherit=Interface]
{
	string interface_music = music_silent
}

[Template ButtonWidget Inherit=Widget]
{
	;; sets sound to play upon pressing/depressing the button
	string	set_sound = button_push
	string	unset_sound = NULL
	
	max_child_count = 2	;; Buttons can only have a label or decal

	
	;; sets the client view bounds when pressed/selected.
	string	pressed_client_L = 0
	string	pressed_client_T = 0
	string	pressed_client_R = 0r
	string	pressed_client_B = 0b

	;; Client - The text/image/whatever displayed on the button.
	[Client Template=Widget]
	{
		;; Default to no view. Can be overriden.
		[View Template=NoVE]
	}
}

;; toggle buttons are SELECTED or UNSELECTED.
[Template ToggleButtonWidget Inherit=ButtonWidget]
{
	type = TOGGLE_BUTTON
	set_sound = toggle_button
}

;; push buttons are PRESSED or UNPRESSED.
[Template PushButtonWidget Inherit=ButtonWidget]
{
	type = PUSH_BUTTON
	set_sound = push_button
}

[Template LabelWidget Inherit=Widget]
{
	type = LABEL
	max_child_count = 1

	;; Label - the label that can be updated by the code.
	[Label Template=LabelVE]
}

[Template DecalWidget Inherit=Widget]
{
	type = DECAL
	max_child_count = 1

	;; Decal - the decal that can be updated by the code.
	[Decal Template=DecalVEBase]
}

[Template SliderWidget Inherit=PanelWidget]
{
	type = SLIDER
	max_child_count = 5

	string	sound_clicked = slider_bar

	;; By default, standard sliders are full left-to-right, with 0 absolute adjustment
	point2 usage_area_pcg = 0, 1
	point2 usage_area_absolute = 0, 0
	
	;; min and max values of the slider (may be managed by code)
	float min_value = 0
	float max_value = 1
	float step_size = 0			;; 0=infinite step size
	float page_size = 0.25

	;; this sets the grip height/width
	float grip_display_size = 10

	;; the "grip" is the button on the scrollbar.  Its view bounds are completely set by code.
	;; TODO: should require "ButtonWidget"
	[Grip inherit=Widget]
	{
		[DisableDecal template=DecalWidget]
		{
			visible = false
			[View template=NoVE]
			[Decal template=DecalVE]
		}
	}
	;; Decal - the background for the slider, which is updated by the code to reflect the actual
	;; used portion of the decal
	[Background Template=NoVE]	
}

[Template SliderAdvancedWidget Inherit=SliderWidget]
{
	type = SLIDER_ADVANCED
	
	;; Should we be showing the bounds or not?
	flag	show_minmax = true
	
	;; Should we be showing the current value or not?
	flag	show_current_val = true
	
	;; Minimum bounds label
	[MinBoundLabel Template=LabelWidget]
	
	;; Maximum bounds label
	[MaxBoundLabel Template=LabelWidget]
	
	;; Current value label
	[CurrentValueLabel Template=LabelWidget]
}

[Template ScrollbarWidget Inherit=Widget]
{
	type = SCROLLBAR
	max_child_count = 5

	[Slider Template=SliderWidget]
	
	[LessButton Template=PushButtonWidget]
	[MoreButton Template=PushButtonWidget]
}

;; used by ListboxWidget below
[Template ListboxItemEntry]
{
	localized	text		;; the text displayed to the user
	string		param		;; internal string used to identify an item
}

[Template ListBoxItemLook Template=LabelWidget]
{
	;; View node must be set.  "T" and "B" will be overridden by code.

	[Label Template=LabelVE]
	text = ""
	;; font must be set
	;; justify must be set
	;; color may be set
}

[Template ListboxWidget Inherit=Widget]
{
	type = LISTBOX
	max_child_count = 10

	int num_visible_items	;; how many items are visible at a time. the rest can be viewed with the scrollbar.
	float item_height		;; the height of each item.  used by the code to set view bounds of items.
	bool sorted = true		;; if true the items are sorted alphabetically
	float vertical_item_offset = 0	;; offset of first and last items from the top and bottom of the list box respectively
	bool multiselect = false	;; true to be able to select multiple items
	bool ignore_redundant_select = true	;; false to invoke the action on an already selected item
	bool resize_to_fit = true
	
	[View]
	{
		; B is set by code (depends on num_visible_items and item_height)
	}

	;; ItemLook - define the look of an item here
	[ItemLook Template=ListBoxItemLook]
	
	;; ItemEntry - initial entries in the list
	[List ItemEntry Template=ListboxItemEntry]

	[Scrollbar Template=ScrollbarWidget]
}

[Template DropDownWidget Inherit=Widget]
{
	type = DROPDOWN
	max_child_count = 10

	;; true means opens upward when clicked on
	flag	dropup = false
	
	;; sounds played when opening/closing the dropdown
	string	sound_open = tiled_button
	string	sound_close = NULL

	;; the dropdown view describes the look without the listbox (selected item and button,
	;; possibly with other background or text).  This will usually be completely covered by
	;; the selected item and button so initialized to NoVE but can be overridden.
	[View Template=NoVE]

	;; SelectedItem - defines look of dropdown's currently selected item 
	;;				(on top of dropdown, always shows up)
	[SelectedItem Template=ListBoxItemLook]
	
	[Listbox Template=ListboxWidget]
	{
		;; bounds are set by code.  Width will be the same as the dropdown.
		;; Initialized to "NoVE" because it will be fully covered by listbox items.
		[View Template=NoVE]
	}

	[OpenButton Template=PushButtonWidget]
}

;; used by MenuWidget below
[Template MenuItemEntry]
{
	localized	text		;; the text displayed to the user
	string		command		;; the command to run when the item is selected (such as "CreateNewRandomMap")
}

[Template MenuWidget Inherit=LabelWidget]
{
	type = MENU
	max_child_count = 12	;; This entry should be tweaked per-menu

	;; the size of each menu item.  used by the code to set view bounds of items.
	float item_height
	float item_width
	float vertical_item_offset = 0	;; offset of first and last items from the top and bottom of the list box respectively

	;; sounds played when opening/closing a menu panel
	string	sound_open = tiled_button
	string	sound_close = NULL

	;; [View] node specifies the menu title background (ex: DecalVE)
	;; [Label] node specifies the menu title (ex: "File")

	;; ItemPanel - the panel that holds the menu items for this menu.
	[ItemPanel Template=PanelWidget]
	{
		;; bounds are set by code.  Initialized to "NoVE" because it will be fully covered by menu items.
		[View Template=NoVE]
	}

	;; ItemLook - define the look of a menu item here
	[ItemLook Template=LabelWidget]
	{
		tooltip = "@Set By Code"
	
		;; View node must be set.  Bounds will be overridden by code.

		[Label Template=LabelVE]
		r = 10r
		text = ""
		justify = left
		;; font must be set
		;; color may be set
	}

	;; ItemEntry - initial entries in the menu
	[List ItemEntry Template=MenuItemEntry]
}

[Template EditboxWidget Inherit=Widget]
{
	type = EDITBOX

	int max_characters = 0		;; max number of characters (0 = infinite)
	localized text = ""
	
	bool integer_only = false   ;; set this when you want a numeric editbox without the -/+ buttons
	
	int integer_max = -1 ;; set this when you want a cap on a numeric editbox (-1 = no cap)
	
	[View Template = NoVE]
	; all of these must be set now, LTRB, since this is what determines the size.

	[Cursor Inherit=LabelWidget]
	{
		[View]
	
		[Label Template=LabelVE]
	}
	
	[Label Inherit=LabelWidget]
	{
		[View]

		[Label Template=LabelVE]
	}
}

[Template NumericEditboxWidget Inherit=Widget]
{
	type = NUMERIC_EDITBOX

	[Editbox Template=EditboxWidget]

	[UpButton Template=PushButtonWidget]
	
	[DownButton Template=PushButtonWidget]
}

[Template ViewportWidget Inherit=Widget]
{
	type = VIEWPORT

	;; Default to no view because normally covered by the ItemPanel and Scrollbar.  Can be overridden.
	[View Template=NoVE]

	[ItemPanel Template=PanelWidget]
}

[Template ModelWidget Inherit=Widget]
{
	type = MODEL

	[View Template=NoVE]

	[Model Template=ModelVE]
}

[Template StatusBarWidget Inherit=Widget]
{
	type = STATUS_BAR
	
	flag has_target_percentage = false
	float target_percentage = 0

	[View Template=DecalVE]
	
	[TargetPercentage Template=DecalWidget]
	{
		[View Template = NoVE]
		{
			L = 0
			T = 0
			R = +5
			B = +5
		}
			
		[Decal Template = DecalVE]
		{
			texture = /UI/%s/Game/ObjectDisplay/PLACEHOLDERTargetPercentageBar.png
		}
	}

	[StatusBar Inherit=StatusBarVE]
}

[Template MiniMapWidget Inherit=PanelWidget]
{
	type = MINIMAP
	
	flag	dynamic_position = false
	point2	minimap_size = 172, 172

	[View Template=NoVE]

	[MiniMapVE Template=MiniMapVE]
}

[Template VideoWidget Inherit=PanelWidget]
{
	type = VIDEO

	flag disconnect_on_completion = false
	flag solo_audio_video_widget = false
	flag repeating_video = false	

	;; Instances have to declare the location of the VE, but the template declares that one exists.
	[View Template=VideoVE]	
}

[Template CinematicWidget Inherit=VideoWidget]
{
	type = CINEMATIC
	
	[list VideoResource]
	{
		string video_resource = NULL
	}
}
