note
	description: "[
		An {VITP_WIDGET} representing the Japanese air units.
		Redefined from {AIR_UNIT_WIDGET} in order to add, color,
		and position the pictures for the two other aircraft
		on the tile.
		]"
	author:    "Jimmy J. Johnson"
	date:      "3/3/24"
	copyright: "Copyright (c) 2021, Jimmy J. Johnson"
	license:   "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"

class
	JAPANESE_AIR_UNIT_WIDGET

inherit

	AIR_UNIT_WIDGET
		redefine
			create_interface_objects,
			extend_widgets,
			position_widgets,
			set_widget_order,
			paint
		end

create
	make

feature {NONE} -- Initialization

	create_interface_objects
			-- Create attributes
		do
			Precursor {AIR_UNIT_WIDGET}
				-- create empty polygons for the extra two picturs
			create picture_2
			create picture_3
		end

	extend_widgets
			-- Put widgets into Current.  This cannot be done
			-- in `create_interface_object', because cannot call
			-- `extend' feature until all objects [in descendants]
			-- are also created.
		local
			list: ARRAYED_LIST [EV_COORDINATE]
		do
			Precursor {AIR_UNIT_WIDGET}
			extend (picture_2)
			extend (picture_3)
				-- Precursor adds points to `picture', not do other two
			list := silhouette_coordinates (unit)
			from list.start
			until list.after
			loop
					-- `extend_point' adds a copy of the point
				picture_2.extend_point (list.item)
				picture_3.extend_point (list.item)
				list.forth
			end
		end

	position_widgets
			-- Move Current and contained widgets to correct
			-- location and set their sizes
		do
			Precursor {AIR_UNIT_WIDGET}
				-- The scale coming through the Precursor from
				-- {ATTACK_UNIT_WIDGET} is "scale (0.1)" which makes
				-- placement of the planes too fine, therefore, this
				-- feature scales the widget back up, moves the sub-
				-- widgets, then scales back down.
			scale (10)
				-- Scale the planes
			picture.scale (0.06)	-- lead
			picture_2.scale (0.06)	-- left wingman
			picture_3.scale (0.06)	-- right wingman
				-- Rotate the planes 90 degrees
			picture.rotate (Pi/2)
			picture_2.rotate (Pi/2)
			picture_3.rotate (Pi/2)
				-- Position the planes
			picture.set_x_y (tile.x, tile.y - 8)
			picture_2.set_x_y (tile.x - 36, tile.y + 5)
			picture_3.set_x_y (tile.x + 36, tile.y + 5)
				-- Scale back down
			scale (0.1)
		end

	set_widget_order
			-- Ensure the widgets are ordered properly
			-- (i.e. whose on top?)
		do
			Precursor {AIR_UNIT_WIDGET}
			bring_to_front (picture_2)
			bring_to_front (picture_3)
		end

feature -- Basic operations

	paint
			-- Set the colors for the `tile'
		do
			Precursor
				-- Cyan so I could tell which plane was which
			picture.set_foreground_color (adjusted_color (Black))
			picture.set_background_color (adjusted_color (Black))
			picture_2.set_foreground_color (adjusted_color (Black))
			picture_2.set_background_color (adjusted_color (Black))
			picture_3.set_foreground_color (adjusted_color (Black))
			picture_3.set_background_color (adjusted_color (Black))
		end

feature {NONE} -- Implementation

	picture_2: SILHOUETTE	--EV_MODEL_POLYGON
			-- The silhouette (or shape) of the 2nd airplane
			-- on the tile

	picture_3: SILHOUETTE	--EV_MODEL_POLYGON
			-- The silhouette (or shape) of the 3rd airplane
			-- on the tile


end
