note
	description: "[
		A {VIEW} that displays the units and the turns on
		which each unit enters the {VITP_GAME}
		]"
	author:    "Jimmy J. Johnson"
	date:      "11/11/23"
	copyright: "Copyright (c) 2023, Jimmy J. Johnson"
	license:   "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"

class
	JAPANESE_ORDER_OF_APPEARANCE_CHART_VIEW

inherit

	ORDER_OF_APPEARANCE_VIEW
		redefine
			add_widgets,
			add_units,
			add_miscellaneous_text,
			add_starting_control_widgets,
			add_copyright_text,
			set_target,
			widget_factory
		end

create
	make

feature {NONE} -- Initialization

	add_widgets
			-- Create the widgets for the chart
		do
			Precursor
			add_removals
		end

	add_turns
			-- Add the "TURN X" and "TO date" texts
		local
			i: INTEGER
		do
			from i := 1
			until i > 9
			loop
				add_turn_text (i)
				i := i + 1
			end
		end

	add_miscellaneous_text
			-- Create the remaining EV_TEXT objects for the chart
		local
			p, cp: EV_COORDINATE
			i: INTEGER
			t: EV_MODEL_TEXT
		do
			Precursor
				-- "At Yokosuka Navy Yard" text (placed relative to the "TURN X" text)
			create p
			from i := 1
			until i > 8
			loop
				p := turn_x_cp (i)
				create cp.make (p.x + 42, p.y + 5)
				world.extend (new_text_widget ("AT YOKOSUKA NAVY YARD", At_port_font, cp))
				i := i + 1
			end
			create cp.make (Turn_9_cp.x + 80, Turn_9_cp.y + 1)
			world.extend (new_text_widget ("AT YOKOSUKA %N  NAVY YARD", At_port_font, cp))
				-- "Also Available" and other misc. text
			world.extend (new_text_widget ("ALSO AVAILABLE", At_port_font, Also_available_cp))
				-- "REMOVAL" above I-boat
			cp.set (i_boat_removal_cp.x, i_boat_removal_cp.y - 2 * gap_size)
			t := new_text ("REMOVAL", turn_x_losses_font)
			t.set_x_y (cp.x, cp.y)
			world.extend (t)
		end

	add_starting_control_widgets
			-- Add the "Starting Control" text and markers if required
		local
			cp:EV_COORDINATE
			t: EV_MODEL_TEXT
			s: STRING
			rec: EV_MODEL_RECTANGLE
			b: EV_MODEL_GROUP
		do
			Precursor
			create cp
				-- Make the "Pearl Harbor Raid" box
			cp.set (shokaku_cp.x + 4 * ship_size, yokosuka_cp.y + 3 * gap_size)
			create rec.make_rectangle (cp.x, cp.y, 8 * ship_size, air_size)
			rec.set_foreground_color (color)
			world.extend (rec)
				-- Make "Pearl Harbor Raid" text
			cp.set (rec.x, rec.y - gap_size)
			t := new_text ("PEARL HARBOR RAID", at_port_font)
			t.set_x_y (cp.x, cp.y)
			world.extend (t)
				-- Make "As many ships as desired ..." text
			cp.set (rec.x, rec.y + gap_size)
			s := "As many ships as desired, but only ships with%
					% a movement factor of 5 or better"
				-- Add "Starting Control" widgets
			t := new_text (s, turn_x_losses_font)
			t.set_x_y (cp.x, cp.y)
			world.extend (t)
				-- Position the `flag' marker
			cp.set (airflot_21_cp.x + 8 * air_size, airflot_21_cp.y)
			flag.set_point_position (cp.x, cp.y)
			flag.show
				-- Position `big_marker' and `little_marker' relative to `flag'
			big_marker.set_x_y (flag.x + 4 * air_size - gap_size, flag.y)
			little_marker.set_x_y (flag.x + 7 * air_size, flag.y)
				-- Starting control text
			t := new_text ("STARTING CONTROL", at_port_font)
			t.set_point_position (cp.x, cp.y - 3 * gap_size)
			world.extend (t)
			s := "%N%NJapanese %N    Islands %NMarianas %NMarshalls"
				-- Add boxes around the port names
			b := new_jagged_box (s, 6, 6, 7, 0)
			b.set_point_position (flag.point_x + 2 * air_size, flag.point_y)
			world.extend (b)
			s := "%N%NYokosuka %N   Navy Yard %NTruk %NSaigon"
				-- Add boxes around the port names
			b := new_jagged_box (s, 6, 6, 7, 0)
			b.set_point_position (flag.point_x + 5 * air_size + 2 * gap_size, flag.point_y)
			world.extend (b)
			s := "%N%NOkinawa %NSaipan %NMalaolap %NKwajalein"
				-- Add boxes around the port names
			b := new_jagged_box (s, 6, 6, 7, 0)
			b.set_point_position (flag.point_x + 8 * air_size + gap_size, flag.point_y)
			world.extend (b)
		end

	add_removals
			-- All removal widgets and "REMOVAL" texts
			-- Just one for the I-Boat
		do
			add_model (positioned_widget (widget_factory.i_boat_removal_widget, i_boat_removal_cp))
			widget_factory.i_boat_removal_widget.set_flipped
			widget_factory.i_boat_removal_widget.set_flat
		end

	add_units
			-- Add {ATTACK_UNIT_WIDGETS} to Current
		do
			Precursor
			add_model (positioned_widget (widget_factory.shokaku_widget, Shokaku_cp))
			add_model (positioned_widget (widget_factory.zuikaku_widget, Zuikaku_cp))
			add_model (positioned_widget (widget_factory.akagi_widget, Akagi_cp))
			add_model (positioned_widget (widget_factory.kaga_widget, Kaga_cp))
			add_model (positioned_widget (widget_factory.soryu_widget, Soryu_cp))
			add_model (positioned_widget (widget_factory.hiryu_widget, Hiryu_cp))
			add_model (positioned_widget (widget_factory.ryujo_widget, Ryujo_cp))
			add_model (positioned_widget (widget_factory.hosho_widget, Hosho_cp))
			add_model (positioned_widget (widget_factory.zuiho_widget, Zuiho_cp))
			add_model (positioned_widget (widget_factory.mutsu_widget, Mutsu_cp))
			add_model (positioned_widget (widget_factory.nagato_widget, Nagato_cp))
			add_model (positioned_widget (widget_factory.fuso_widget, Fuso_cp))
			add_model (positioned_widget (widget_factory.hyuga_widget, Hyuga_cp))
			add_model (positioned_widget (widget_factory.ise_widget, Ise_cp))
			add_model (positioned_widget (widget_factory.yamashiro_widget, Yamashiro_cp))
			add_model (positioned_widget (widget_factory.haruna_widget, Haruna_cp))
			add_model (positioned_widget (widget_factory.hiei_widget, Hiei_cp))
			add_model (positioned_widget (widget_factory.kirishima_widget, Kirishima_cp))
			add_model (positioned_widget (widget_factory.kongo_widget, Kongo_cp))
			add_model (positioned_widget (widget_factory.ashigara_widget, Ashigara_cp))
			add_model (positioned_widget (widget_factory.atago_widget, Atago_cp))
			add_model (positioned_widget (widget_factory.chokai_widget, Chokai_cp))
			add_model (positioned_widget (widget_factory.haguro_widget, Haguro_cp))
			add_model (positioned_widget (widget_factory.maya_widget, Maya_cp))
			add_model (positioned_widget (widget_factory.myoko_widget, Myoko_cp))
			add_model (positioned_widget (widget_factory.nachi_widget, Nachi_cp))
			add_model (positioned_widget (widget_factory.takao_widget, Takao_cp))
			add_model (positioned_widget (widget_factory.chikuma_widget, Chikuma_cp))
			add_model (positioned_widget (widget_factory.kumano_widget, Kumano_cp))
			add_model (positioned_widget (widget_factory.mikuma_widget, Mikuma_cp))
			add_model (positioned_widget (widget_factory.mogami_widget, Mogami_cp))
			add_model (positioned_widget (widget_factory.suzuya_widget, Suzuya_cp))
			add_model (positioned_widget (widget_factory.tone_widget, Tone_cp))
			add_model (positioned_widget (widget_factory.aoba_widget, Aoba_cp))
			add_model (positioned_widget (widget_factory.furutaka_widget, Furutaka_cp))
			add_model (positioned_widget (widget_factory.kako_widget, Kako_cp))
			add_model (positioned_widget (widget_factory.kinugasa_widget, Kinugasa_cp))
			add_model (positioned_widget (widget_factory.kitakami_widget, Kitakami_cp))
			add_model (positioned_widget (widget_factory.oi_widget, Oi_cp))
			add_model (positioned_widget (widget_factory.yokosuka_widget, Yokosuka_cp))
			add_model (positioned_widget (widget_factory.airflot_21_widget, Airflot_21_cp))
			add_model (positioned_widget (widget_factory.airflot_22_widget, Airflot_22_cp))
			add_model (positioned_widget (widget_factory.airflot_23_widget, Airflot_23_cp))
			add_model (positioned_widget (widget_factory.airflot_24_widget, Airflot_24_cp))
			add_model (positioned_widget (widget_factory.airflot_25_widget, Airflot_25_cp))
			add_model (positioned_widget (widget_factory.airflot_26_widget, Airflot_26_cp))
			add_model (positioned_widget (widget_factory.i_boat_widget, I_boat_cp))
			add_model (positioned_widget (widget_factory.shoho_widget, Shoho_cp))
			add_model (positioned_widget (widget_factory.junyo_widget, Junyo_cp))
			add_model (positioned_widget (widget_factory.sasebo_widget, Sasebo_cp))
			add_model (positioned_widget (widget_factory.hiyo_widget, Hiyo_cp))
			add_model (positioned_widget (widget_factory.yamato_widget, Yamato_cp))
			add_model (positioned_widget (widget_factory.kure_widget, Kure_cp))
			add_model (positioned_widget (widget_factory.musashi_widget, Musashi_cp))
			add_model (positioned_widget (widget_factory.chiyoda_widget, Chiyoda_cp))
			add_model (positioned_widget (widget_factory.chitose_widget, Chitose_cp))
			add_model (positioned_widget (widget_factory.ryuho_widget, Ryuho_cp))
			add_model (positioned_widget (widget_factory.taiho_widget, Taiho_cp))
			add_model (positioned_widget (widget_factory.unryu_widget, Unryu_cp))
			add_model (positioned_widget (widget_factory.amagi_widget, Amagi_cp))
			add_model (positioned_widget (widget_factory.katsuragi_widget, Katsuragi_cp))
			add_model (positioned_widget (widget_factory.shinano_widget, Shinano_cp))
		end

	add_copyright_text
			-- Add the copy-right notices to each chart
		local
			cp: EV_COORDINATE
			t: EV_MODEL_TEXT
			s: STRING
			f: EV_FONT
		do
			create cp
				-- Copyright
			s := "Copyright 1977,  The Avalon Hill Game Co. Balto, MD  Printed in U.S.A."
			f := small_font
			t := new_text (s, f)
			cp.set (top_left_cp.x + gap_size, bottom_right_cp.y - 2 * gap_size)
			t.set_point_position (cp.x, cp.y)
			world.extend (t)
		end

feature -- Access

	location: LOCATION
			-- A {LOCATION} from the {VITP_GAME} used in `draw' to determine
			-- if a unit is on this chart or somewhere else (i.e. in the game.)
		do
			Result := game.japanese_oa_chart
		end

	title: STRING = "Japanese Order of Appearance Chart"
			-- The text at the top of this chart

feature -- Element change

	set_target (a_item: like game)
			-- Associate `a_item' with Current.
		do
			Precursor (a_item)
--				-- Make the widgets white
--			world.i_boat_removal_widget.set_flipped
--				-- Make it look like print
--			world.i_boat_removal_widget.set_flat
		end

feature {NONE} -- Implementation

	widget_factory: JAPANESE_FORCES_FACTORY
			-- Container for all the widget (e.g. attack widget,
			-- location widget, etc)

feature {NONE} -- Control point constants

	bottom_right_cp: EV_COORDINATE do create Result.make (260, 316) end
		-- Turn X text		
	turn_1_cp: EV_COORDINATE do create Result.make (7, 14) end
	turn_2_cp: EV_COORDINATE do create Result.make (turn_1_cp.x, 136) end
	turn_3_cp: EV_COORDINATE do create Result.make (133, turn_2_cp.y) end
	turn_4_cp: EV_COORDINATE do create Result.make (turn_1_cp.x, 170) end
	turn_5_cp: EV_COORDINATE do create Result.make (turn_3_cp.x, turn_4_cp.y) end
	turn_6_cp: EV_COORDINATE do create Result.make (turn_1_cp.x, 205) end
	turn_7_cp: EV_COORDINATE do create Result.make (turn_1_cp.x, 240) end
	turn_8_cp: EV_COORDINATE do create Result.make (turn_1_cp.x, 275) end
	turn_9_cp: EV_COORDINATE do create Result.make (turn_3_cp.x, turn_8_cp.y) end
		-- To some date text
	to_dec_41_cp: EV_COORDINATE do create Result.make (turn_1_cp.x + 2, turn_1_cp.y + 8)  end
	to_may_42_cp: EV_COORDINATE do create Result.make (turn_2_cp.x + 2, turn_2_cp.y + 8)  end
	to_sep_42_cp: EV_COORDINATE do create Result.make (turn_3_cp.x + 2, turn_3_cp.y + 8)  end
	to_jan_43_cp: EV_COORDINATE do create Result.make (turn_4_cp.x + 2, turn_4_cp.y + 8)  end
	to_jun_43_cp: EV_COORDINATE do create Result.make (turn_5_cp.x + 2, turn_5_cp.y + 8)  end
	to_jan_44_cp: EV_COORDINATE do create Result.make (turn_6_cp.x + 2, turn_6_cp.y + 8)  end
	to_may_44_cp: EV_COORDINATE do create Result.make (turn_7_cp.x + 2, turn_7_cp.y + 8)  end
	to_oct_44_cp: EV_COORDINATE do create Result.make (turn_8_cp.x + 2, turn_8_cp.y + 8)  end
	to_jan_45_cp: EV_COORDINATE do create Result.make (turn_9_cp.x + 2, turn_9_cp.y + 8)  end
		-- Turn x losses
	turn_1_losses_cp: EV_COORDINATE do create Result.make (Turn_3_cp.x + 60, turn_3_cp.y + 12) end
	turn_2_losses_cp: EV_COORDINATE do create Result.make (57, turn_5_cp.y + 12) end
	turn_3_losses_cp: EV_COORDINATE do create Result.make (turn_1_losses_cp.x, turn_2_losses_cp.y) end
	turn_4_losses_cp: EV_COORDINATE do create Result.make (turn_2_losses_cp.x, turn_6_cp.y + 12) end
	turn_5_losses_cp: EV_COORDINATE do create Result.make (96, Turn_7_cp.y + 12) end
	turn_6_losses_cp: EV_COORDINATE do create Result.make (turn_2_losses_cp.x, Turn_8_cp.y + 12) end
	turn_7_losses_cp: EV_COORDINATE do create Result.make (turn_1_losses_cp.x, Turn_6_losses_cp.y) end
		-- Misc
	also_available_cp: EV_COORDINATE do create Result.make (turn_1_cp.x, 109) end
	starting_control_cp: EV_COORDINATE do create Result.make (133, also_available_cp.y - 1) end
		-- Turn one, row one
	shokaku_cp: EV_COORDINATE do create Result.make (Turn_1_cp.x + 6, Turn_1_cp.y + 12) end
	Zuikaku_cp: EV_COORDINATE do create Result.make (Shokaku_cp.x + ship_size, Shokaku_cp.y) end
	Akagi_cp: EV_COORDINATE do create Result.make (Zuikaku_cp.x + ship_size, Shokaku_cp.y) end
	Kaga_cp: EV_COORDINATE do create Result.make (Akagi_cp.x + ship_size, Shokaku_cp.y) end
	Soryu_cp: EV_COORDINATE do create Result.make (Kaga_cp.x + ship_size, Shokaku_cp.y) end
	Hiryu_cp: EV_COORDINATE do create Result.make (Soryu_cp.x + ship_size, Shokaku_cp.y) end
	Ryujo_cp: EV_COORDINATE do create Result.make (Hiryu_cp.x + ship_size, Shokaku_cp.y) end
	Hosho_cp: EV_COORDINATE do create Result.make (Ryujo_cp.x + ship_size, Shokaku_cp.y) end
	Zuiho_cp: EV_COORDINATE do create Result.make (Hosho_cp.x + ship_size, Shokaku_cp.y) end
	Mutsu_cp: EV_COORDINATE do create Result.make (Zuiho_cp.x + ship_size, Shokaku_cp.y) end
	Nagato_cp: EV_COORDINATE do create Result.make (Mutsu_cp.x + ship_size, Shokaku_cp.y) end
	Fuso_cp: EV_COORDINATE do create Result.make (Nagato_cp.x + ship_size, Shokaku_cp.y) end
		-- Turn one, row 2
	Hyuga_cp: EV_COORDINATE do create Result.make (Shokaku_cp.x, Shokaku_cp.y + ship_size) end
	Ise_cp: EV_COORDINATE do create Result.make (Hyuga_cp.x + ship_size, Hyuga_cp.y) end
	Yamashiro_cp: EV_COORDINATE do create Result.make (Ise_cp.x + ship_size, Hyuga_cp.y) end
	Haruna_cp: EV_COORDINATE do create Result.make (Yamashiro_cp.x + ship_size, Hyuga_cp.y) end
	Hiei_cp: EV_COORDINATE do create Result.make (Haruna_cp.x + ship_size, Hyuga_cp.y) end
	Kirishima_cp: EV_COORDINATE do create Result.make (Hiei_cp.x + ship_size, Hyuga_cp.y) end
	Kongo_cp: EV_COORDINATE do create Result.make (Kirishima_cp.x + ship_size, Hyuga_cp.y) end
	Ashigara_cp: EV_COORDINATE do create Result.make (Kongo_cp.x + ship_size, Hyuga_cp.y) end
	Atago_cp: EV_COORDINATE do create Result.make (Ashigara_cp.x + ship_size, Hyuga_cp.y) end
	Chokai_cp: EV_COORDINATE do create Result.make (Atago_cp.x + ship_size, Hyuga_cp.y) end
	Haguro_cp: EV_COORDINATE do create Result.make (Chokai_cp.x + ship_size, Hyuga_cp.y) end
	Maya_cp: EV_COORDINATE do create Result.make (Haguro_cp.x + ship_size, Hyuga_cp.y) end
		-- Turn one, row 3
	Myoko_cp: EV_COORDINATE do create Result.make (Shokaku_cp.x, Hyuga_cp.y + ship_size) end
	Nachi_cp: EV_COORDINATE do create Result.make (Myoko_cp.x + ship_size, Myoko_cp.y) end
	Takao_cp: EV_COORDINATE do create Result.make (Nachi_cp.x + ship_size, Myoko_cp.y) end
	Chikuma_cp: EV_COORDINATE do create Result.make (Takao_cp.x + ship_size, Myoko_cp.y) end
	Kumano_cp: EV_COORDINATE do create Result.make (Chikuma_cp.x + ship_size, Myoko_cp.y) end
	Mikuma_cp: EV_COORDINATE do create Result.make (Kumano_cp.x + ship_size, Myoko_cp.y) end
	Mogami_cp: EV_COORDINATE do create Result.make (Mikuma_cp.x + ship_size, Myoko_cp.y) end
	Suzuya_cp: EV_COORDINATE do create Result.make (Mogami_cp.x + ship_size, Myoko_cp.y) end
	Tone_cp: EV_COORDINATE do create Result.make (Suzuya_cp.x + ship_size, Myoko_cp.y) end
	Aoba_cp: EV_COORDINATE do create Result.make (Tone_cp.x + ship_size, Myoko_cp.y) end
	Furutaka_cp: EV_COORDINATE do create Result.make (Aoba_cp.x + ship_size, Myoko_cp.y) end
	Kako_cp: EV_COORDINATE do create Result.make (Furutaka_cp.x + ship_size, Myoko_cp.y) end
		-- Turn one, row 4
	Kinugasa_cp: EV_COORDINATE do create Result.make (Shokaku_cp.x, Myoko_cp.y + ship_size) end
	Kitakami_cp: EV_COORDINATE do create Result.make (Kinugasa_cp.x + ship_size, Kinugasa_cp.y) end
	Oi_cp: EV_COORDINATE do create Result.make (Kitakami_cp.x + ship_size, Kinugasa_cp.y) end
	Yokosuka_cp: EV_COORDINATE do create Result.make (Oi_cp.x + ship_size, Kinugasa_cp.y) end
			-- "Also Available" row
	Airflot_21_cp: EV_COORDINATE do create Result.make (7, 115) end
	Airflot_22_cp: EV_COORDINATE do create Result.make (Airflot_21_cp.x + air_size, Airflot_21_cp.y) end
	Airflot_23_cp: EV_COORDINATE do create Result.make (Airflot_22_cp.x + air_size, Airflot_21_cp.y) end
	Airflot_24_cp: EV_COORDINATE do create Result.make (Airflot_23_cp.x + air_size, Airflot_21_cp.y) end
	Airflot_25_cp: EV_COORDINATE do create Result.make (Airflot_24_cp.x + air_size, Airflot_21_cp.y) end
	Airflot_26_cp: EV_COORDINATE do create Result.make (Airflot_25_cp.x + air_size, Airflot_21_cp.y) end
	I_boat_cp: EV_COORDINATE do create Result.make (Airflot_26_cp.x + air_size, Airflot_21_cp.y + air_size - ship_size) end
			-- Turn two
	Shoho_cp: EV_COORDINATE do create Result.make (Shokaku_cp.x, Turn_2_cp.y + 12) end
	Junyo_cp: EV_COORDINATE do create Result.make (Shoho_cp.x + ship_size, Shoho_cp.y) end
	Sasebo_cp: EV_COORDINATE do create Result.make (Junyo_cp.x + ship_size + gap_size, Shoho_cp.y) end
		-- Turn three
	Hiyo_cp: EV_COORDINATE do create Result.make (Ryujo_cp.x, Shoho_cp.y) end
	Yamato_cp: EV_COORDINATE do create Result.make (Hiyo_cp.x + ship_size, Shoho_cp.y) end
	Kure_cp: EV_COORDINATE do create Result.make (Yamato_cp.x + ship_size + gap_size, Shoho_cp.y) end
		-- Turn four
		-- Turn five
	Musashi_cp: EV_COORDINATE do create Result.make (Ryujo_cp.x, Turn_5_cp.y + 12) end
		-- Turn six
		-- Turn seven
	Chiyoda_cp: EV_COORDINATE do create Result.make (Shokaku_cp.x, Turn_7_cp.y + 12) end
	Chitose_cp: EV_COORDINATE do create Result.make (Chiyoda_cp.x + ship_size, Chiyoda_cp.y) end
	Ryuho_cp: EV_COORDINATE do create Result.make (Chitose_cp.x + ship_size, Chiyoda_cp.y) end
	Taiho_cp: EV_COORDINATE do create Result.make (Ryuho_cp.x + ship_size, Chiyoda_cp.y) end
	i_boat_removal_cp: EV_COORDINATE do create Result.make (turn_7_cp.x + 8 * ship_size, chiyoda_cp.y) end
		-- Turn eight
	Unryu_cp: EV_COORDINATE do create Result.make (Shokaku_cp.x, Turn_8_cp.y + 12) end
	Amagi_cp: EV_COORDINATE do create Result.make (Unryu_cp.x + ship_size, Unryu_cp.y) end
		-- Turn nine
	Katsuragi_cp: EV_COORDINATE do create Result.make (Ryujo_cp.x, Unryu_cp.y) end
	Shinano_cp: EV_COORDINATE do create Result.make (Katsuragi_cp.x + ship_size, Unryu_cp.y) end

end
