init
This commit is contained in:
62
jj_vitp/Interface/views/VITP_application.e
Normal file
62
jj_vitp/Interface/views/VITP_application.e
Normal file
@@ -0,0 +1,62 @@
|
||||
note
|
||||
description: "Root class for testing the VITP game."
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
VITP_APPLICATION
|
||||
|
||||
inherit
|
||||
|
||||
JJ_APPLICATION
|
||||
redefine
|
||||
create_interface_objects,
|
||||
target,
|
||||
window_anchor
|
||||
end
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Set up the attribute
|
||||
do
|
||||
print ("VITP_APPLICATION.create_interface_objects %N")
|
||||
Precursor
|
||||
target.sequence_of_play.start
|
||||
print ("%T end VITP_APPLICATION.create_interface_objects %N")
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (anchors)
|
||||
|
||||
target: VITP_GAME
|
||||
-- The object this application will handle
|
||||
|
||||
target_anchor: VITP_GAME
|
||||
-- Anchor for features using nodes.
|
||||
-- Not to be called; just used to anchor types.
|
||||
-- Declared as a feature to avoid adding an attribute.
|
||||
require else
|
||||
not_callable: False
|
||||
do
|
||||
check
|
||||
do_not_call: False then
|
||||
-- Because give no info; simply used as anchor.
|
||||
end
|
||||
end
|
||||
|
||||
window_anchor: VITP_MAIN_WINDOW
|
||||
-- Anchor for the type of `first_window'
|
||||
-- Not to be called; just used to anchor types.
|
||||
-- Declared as a feature to avoid adding an attribute.
|
||||
require else
|
||||
not_callable: False
|
||||
do
|
||||
check
|
||||
do_not_call: False then
|
||||
-- Because give no info; simply used as anchor.
|
||||
end
|
||||
end
|
||||
|
||||
end
|
115
jj_vitp/Interface/views/VITP_main_window.e
Normal file
115
jj_vitp/Interface/views/VITP_main_window.e
Normal file
@@ -0,0 +1,115 @@
|
||||
note
|
||||
description: "[
|
||||
Main window for VITP
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
VITP_MAIN_WINDOW
|
||||
|
||||
inherit
|
||||
|
||||
JJ_MAIN_WINDOW
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
-- initialize_interface,
|
||||
target_imp,
|
||||
set_target
|
||||
-- draw
|
||||
end
|
||||
|
||||
FONT_AND_COLOR_CONSTANTS
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
GAME_CONSTANTS
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
print ("VITP_MAIN_WINDOW.create_interface_objects %N")
|
||||
Precursor {JJ_MAIN_WINDOW}
|
||||
-- Call to force creation of VITP_GAME
|
||||
print ("%T VITP_MAIN_WINDOW.create_interface_objects just before creating board_tool %N")
|
||||
create board_tool.make (target)
|
||||
print ("%T VITP_MAIN_WINDOW.create_interface_objects just before creating chart_tool %N")
|
||||
create chart_tool.make (target)
|
||||
create sequence_tool.make (target)
|
||||
-- create board_tool
|
||||
-- create chart_tool
|
||||
-- create sequence_tool
|
||||
print ("%T end VITP_MAIN_WINDOW.create_interface_objects %N")
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the window
|
||||
local
|
||||
g: VITP_GAME
|
||||
do
|
||||
print ("VITP_MAIN_WINDOW.initialize %N")
|
||||
Precursor {JJ_MAIN_WINDOW}
|
||||
split_manager.enable_mode_changes
|
||||
split_manager.set_vertical
|
||||
-- split_manager.extend (sequence_tool)
|
||||
split_manager.extend (board_tool)
|
||||
split_manager.set_horizontal
|
||||
split_manager.extend (chart_tool)
|
||||
-- -- Must `start' the `sequence_of_play' here, not in
|
||||
-- -- {VITP_GAME} because of Void safety
|
||||
-- create g
|
||||
-- g.sequence_of_play.start
|
||||
-- set_target (g)
|
||||
-- Set window size, etc.
|
||||
set_size (1600, 1200)
|
||||
set_position (600, 100)
|
||||
print ("%T end VITP_MAIN_WINDOW.initialize %N")
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_game: like target)
|
||||
-- Change the target
|
||||
do
|
||||
Precursor {JJ_MAIN_WINDOW} (a_game)
|
||||
board_tool.set_target (a_game)
|
||||
chart_tool.set_target (a_game)
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
board_tool: BOARD_TOOL
|
||||
-- Drawing will be done here.
|
||||
|
||||
chart_tool: CHART_TOOL
|
||||
-- Draw the order of appearance charts here
|
||||
|
||||
sequence_tool: GAME_SEQUENCE_TOOL
|
||||
-- Tool containing the view that displays the sequence of play
|
||||
|
||||
target_imp: detachable VITP_GAME
|
||||
-- Implementation of the `target'
|
||||
|
||||
|
||||
end
|
80
jj_vitp/Interface/views/all_widgets_factory.e
Normal file
80
jj_vitp/Interface/views/all_widgets_factory.e
Normal file
@@ -0,0 +1,80 @@
|
||||
note
|
||||
description: "[
|
||||
Class combining the various widget factories into one.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/15/24"
|
||||
copyright: "Copyright (c) 2024, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
class
|
||||
ALL_WIDGETS_FACTORY
|
||||
|
||||
inherit
|
||||
|
||||
ATTACK_WIDGETS_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
LOCATION_WIDGITS_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_widgets
|
||||
-- Create widgets for the corresponding game item
|
||||
-- for each of the ancestors
|
||||
do
|
||||
-- create all_widgets.make (100)
|
||||
print ("ALL_WIDGETS_FACTORY.make_widgets %N")
|
||||
Precursor {ATTACK_WIDGETS_FACTORY}
|
||||
Precursor {LOCATION_WIDGITS_FACTORY}
|
||||
print ("%T end ALL_WIDGETS_FACTORY.make_widgets %N")
|
||||
end
|
||||
|
||||
--feature -- Access
|
||||
|
||||
-- all_widgets: VITP_WIDGET_TABLE [VITP_WIDGET, VITP_ITEM]
|
||||
-- -- Keeps track of all widgets
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
extend_widgets
|
||||
-- Put each widget into `world'
|
||||
-- for each of the ancetors
|
||||
do
|
||||
Precursor {ATTACK_WIDGETS_FACTORY}
|
||||
Precursor {LOCATION_WIDGITS_FACTORY}
|
||||
-- widgets.merge (attack_widgets)
|
||||
-- widgets.merge (location_widgets)
|
||||
end
|
||||
|
||||
pair_widgets
|
||||
-- Associate each widget with a unit
|
||||
-- for each of the ancestors
|
||||
do
|
||||
Precursor {ATTACK_WIDGETS_FACTORY}
|
||||
Precursor {LOCATION_WIDGITS_FACTORY}
|
||||
end
|
||||
|
||||
fill_widgets
|
||||
-- Call `set_target' to give each widget a target
|
||||
-- for each of the ancestors
|
||||
do
|
||||
Precursor {ATTACK_WIDGETS_FACTORY}
|
||||
Precursor {LOCATION_WIDGITS_FACTORY}
|
||||
end
|
||||
|
||||
end
|
714
jj_vitp/Interface/views/allied_forces_widget_factory.e
Normal file
714
jj_vitp/Interface/views/allied_forces_widget_factory.e
Normal file
@@ -0,0 +1,714 @@
|
||||
note
|
||||
description: "[
|
||||
One of the classes that decompose the numourous VITP widgets
|
||||
into more managable groups. This class models the widgets
|
||||
that contain all the Allied units for turns one through nine.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/15/24"
|
||||
copyright: "Copyright (c) 2024, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
class
|
||||
ALLIED_FORCES_WIDGET_FACTORY
|
||||
|
||||
inherit
|
||||
|
||||
WIDGET_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_widgets
|
||||
-- Create widgets for the corresponding game item
|
||||
do
|
||||
create allied_forces_widgets.make (100)
|
||||
Precursor {WIDGET_FACTORY}
|
||||
-- Turn 1, on battleship row (Pearl Harbor)
|
||||
create nevada_widget.make (game.nevada)
|
||||
create arizona_widget.make (game.arizona)
|
||||
create west_virginia_widget.make (game.west_virginia)
|
||||
create tennessee_widget.make (game.tennessee)
|
||||
create oklahoma_widget.make (game.oklahoma)
|
||||
create maryland_widget.make (game.maryland)
|
||||
create california_widget.make (game.california)
|
||||
create pennsylvania_widget.make (game.pennsylvania)
|
||||
create new_orleans_widget.make (game.new_orleans)
|
||||
create san_francisco_widget.make (game.san_francisco)
|
||||
create seventh_af_widget.make (game.seventh_af)
|
||||
-- Turn 1, at sea (cannot move)
|
||||
create hermes_widget.make (game.hermes)
|
||||
create revenge_widget.make (game.revenge)
|
||||
create prince_of_wales_widget.make (game.prince_of_wales)
|
||||
create repulse_widget.make (game.repulse)
|
||||
create fifth_af_widget.make (game.fifth_af)
|
||||
create louisville_widget.make (game.louisville)
|
||||
create pensacola_widget.make (game.pensacola)
|
||||
create indianapolis_widget.make (game.indianapolis)
|
||||
create minneapolis_widget.make (game.minneapolis)
|
||||
-- Turn 1, in port (may move)
|
||||
create houston_widget.make (game.houston)
|
||||
create exeter_widget.make (game.exeter)
|
||||
create de_ruyter_widget.make (game.de_ruyter)
|
||||
create australia_ship_widget.make (game.australia_ship)
|
||||
create canberra_widget.make (game.canberra)
|
||||
-- Turn 1, Location uncertain (group W)
|
||||
create enterprise_widget.make (game.enterprise)
|
||||
create salt_lake_city_widget.make (game.salt_lake_city)
|
||||
create northampton_widget.make (game.northampton)
|
||||
create chester_widget.make (game.chester)
|
||||
-- Turn 1, Location uncertain (group X)
|
||||
create lexington_widget.make (game.lexington)
|
||||
create chicago_widget.make (game.chicago)
|
||||
create portland_widget.make (game.portland)
|
||||
create astoria_widget.make (game.astoria)
|
||||
-- Turn 1, Location uncertain (group Y)
|
||||
create saratoga_widget.make (game.saratoga)
|
||||
-- Turn 1, Location uncertain (group Z)
|
||||
create hornet_widget.make (game.hornet)
|
||||
create yorktown_widget.make (game.yorktown)
|
||||
create vincennes_widget.make (game.vincennes)
|
||||
create quincy_widget.make (game.quincy)
|
||||
-- Turn_2
|
||||
create royal_sovereign_widget.make (game.royal_sovereign)
|
||||
create ramilies_widget.make (game.ramilies)
|
||||
create resolution_widget.make (game.resolution)
|
||||
create warspite_widget.make (game.warspite)
|
||||
create indomitable_widget.make (game.indomitable)
|
||||
create formidable_widget.make (game.formidable)
|
||||
create cornwall_widget.make (game.cornwall)
|
||||
create dorestshire_widget.make (game.dorestshire)
|
||||
create new_mexico_widget.make (game.new_mexico)
|
||||
create idaho_widget.make (game.idaho)
|
||||
create tenth_af_widget.make (game.tenth_af)
|
||||
create eleventh_af_widget.make (game.eleventh_af)
|
||||
-- Turn 3
|
||||
create north_carolina_widget.make (game.north_carolina)
|
||||
create mississippi_widget.make (game.mississippi)
|
||||
create colorado_widget.make (game.colorado)
|
||||
create marines_1_widget.make (game.marines_1)
|
||||
create marines_2_widget.make (game.marines_2)
|
||||
create raaf_widget.make (game.raaf)
|
||||
create rnzaf_widget.make (game.rnzaf)
|
||||
create valiant_widget.make (game.valiant)
|
||||
create illustrious_widget.make (game.illustrious)
|
||||
-- Turn 4
|
||||
create south_dakota_widget.make (game.south_dakota)
|
||||
create indiana_widget.make (game.indiana)
|
||||
create washington_widget.make (game.washington)
|
||||
create wasp_widget.make (game.wasp)
|
||||
create marine_widget.make (game.marine)
|
||||
create thirteenth_af_widget.make (game.thirteenth_af)
|
||||
create devonshire_widget.make (game.devonshire)
|
||||
create shropshire_widget.make (game.shropshire)
|
||||
create first_027_removal_widget.make (game.first_027_removal)
|
||||
create second_027_removal_widget.make (game.second_027_removal)
|
||||
-- Turn 5
|
||||
create massachusetts_widget.make (game.massachusetts)
|
||||
create wichita_widget.make (game.wichita)
|
||||
create victorious_widget.make (game.victorious)
|
||||
create marines_3_widget.make (game.marines_3)
|
||||
create fourteenth_af_widget.make (game.fourteenth_af)
|
||||
create naval_widget.make (game.naval)
|
||||
create resolution_removal_widget.make (game.resolution_removal)
|
||||
create revenge_removal_widget.make (game.revenge_removal)
|
||||
create valiant_removal_widget.make (game.valiant_removal)
|
||||
create warspite_removal_widget.make (game.warspite_removal)
|
||||
-- Turn 6
|
||||
create alabama_widget.make (game.alabama)
|
||||
create essex_widget.make (game.essex)
|
||||
create cv_10_widget.make (game.cv_10)
|
||||
create cv_16_widget.make (game.cv_16)
|
||||
create independence_widget.make (game.independence)
|
||||
create princeton_widget.make (game.princeton)
|
||||
create belleau_wood_widget.make (game.belleau_wood)
|
||||
create cowpens_widget.make (game.cowpens)
|
||||
create monterey_widget.make (game.monterey)
|
||||
create baltimore_widget.make (game.baltimore)
|
||||
create boston_widget.make (game.boston)
|
||||
create marines_4_widget.make (game.marines_4)
|
||||
create victorious_removal_widget.make (game.victorious_removal)
|
||||
-- Turn 7
|
||||
create iowa_widget.make (game.iowa)
|
||||
create new_jersey_widget.make (game.new_jersey)
|
||||
create intrepid_widget.make (game.intrepid)
|
||||
create cv_12_widget.make (game.cv_12)
|
||||
create bunker_hill_widget.make (game.bunker_hill)
|
||||
create cv_18_widget.make (game.cv_18)
|
||||
create bataan_widget.make (game.bataan)
|
||||
create cabot_widget.make (game.cabot)
|
||||
create langley_ii_widget.make (game.langley_ii)
|
||||
create canberra_ii_widget.make (game.canberra_ii)
|
||||
create quincy_ii_widget.make (game.quincy_ii)
|
||||
create f_boat_widget.make (game.f_boat)
|
||||
create third_027_removal_widget.make (game.third_027_removal)
|
||||
create first_443_removal_widget.make (game.first_443_removal)
|
||||
-- Turn 8
|
||||
create wisconsin_widget.make (game.wisconsin)
|
||||
create missouri_widget.make (game.missouri)
|
||||
create ticonderoga_widget.make (game.ticonderoga)
|
||||
create san_jacinto_widget.make (game.san_jacinto)
|
||||
create marines_5_widget.make (game.marines_5)
|
||||
-- Turn 9
|
||||
create new_york_widget.make (game.new_york)
|
||||
create texas_widget.make (game.texas)
|
||||
create alaska_widget.make (game.alaska)
|
||||
create franklin_widget.make (game.franklin)
|
||||
create shangri_la_widget.make (game.shangri_la)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
allied_forces_widgets: VITP_WIDGET_TABLE [ATTACK_UNIT_WIDGET, ATTACK_UNIT]
|
||||
-- Keeps track of Allied attack units turns 2 to 9
|
||||
|
||||
feature -- Access (Allied unit widgets turn 2 to 9)
|
||||
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
nevada_widget: SHIP_WIDGET
|
||||
arizona_widget: SHIP_WIDGET
|
||||
west_virginia_widget: SHIP_WIDGET
|
||||
tennessee_widget: SHIP_WIDGET
|
||||
oklahoma_widget: SHIP_WIDGET
|
||||
maryland_widget: SHIP_WIDGET
|
||||
california_widget: SHIP_WIDGET
|
||||
pennsylvania_widget: SHIP_WIDGET
|
||||
new_orleans_widget: SHIP_WIDGET
|
||||
san_francisco_widget: SHIP_WIDGET
|
||||
seventh_af_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
-- At sea (cannot move)
|
||||
hermes_widget: SHIP_WIDGET
|
||||
revenge_widget: SHIP_WIDGET
|
||||
prince_of_wales_widget: SHIP_WIDGET
|
||||
repulse_widget: SHIP_WIDGET
|
||||
fifth_af_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
louisville_widget: SHIP_WIDGET
|
||||
pensacola_widget: SHIP_WIDGET
|
||||
indianapolis_widget: SHIP_WIDGET
|
||||
minneapolis_widget: SHIP_WIDGET
|
||||
-- In port (may move)
|
||||
houston_widget: SHIP_WIDGET
|
||||
exeter_widget: SHIP_WIDGET
|
||||
de_ruyter_widget: SHIP_WIDGET
|
||||
australia_ship_widget: SHIP_WIDGET
|
||||
canberra_widget: SHIP_WIDGET
|
||||
-- Location Uncertain, group W
|
||||
enterprise_widget: SHIP_WIDGET
|
||||
salt_lake_city_widget: SHIP_WIDGET
|
||||
northampton_widget: SHIP_WIDGET
|
||||
chester_widget: SHIP_WIDGET
|
||||
-- Location Uncertain, group X
|
||||
lexington_widget: SHIP_WIDGET
|
||||
chicago_widget: SHIP_WIDGET
|
||||
portland_widget: SHIP_WIDGET
|
||||
astoria_widget: SHIP_WIDGET
|
||||
-- Location Uncertain, group Y
|
||||
saratoga_widget: SHIP_WIDGET
|
||||
-- Location Uncertain, group W
|
||||
hornet_widget: SHIP_WIDGET
|
||||
yorktown_widget: SHIP_WIDGET
|
||||
vincennes_widget: SHIP_WIDGET
|
||||
quincy_widget: SHIP_WIDGET
|
||||
-- Turn 2
|
||||
royal_sovereign_widget: SHIP_WIDGET
|
||||
ramilies_widget: SHIP_WIDGET
|
||||
resolution_widget: SHIP_WIDGET
|
||||
warspite_widget: SHIP_WIDGET
|
||||
indomitable_widget: SHIP_WIDGET
|
||||
formidable_widget: SHIP_WIDGET
|
||||
cornwall_widget: SHIP_WIDGET
|
||||
dorestshire_widget: SHIP_WIDGET
|
||||
new_mexico_widget: SHIP_WIDGET
|
||||
idaho_widget: SHIP_WIDGET
|
||||
tenth_af_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
eleventh_af_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
-- Turn 3
|
||||
north_carolina_widget: SHIP_WIDGET
|
||||
mississippi_widget: SHIP_WIDGET
|
||||
colorado_widget: SHIP_WIDGET
|
||||
marines_1_widget: AMPHIBIOUS_UNIT_wIDGET
|
||||
marines_2_widget: AMPHIBIOUS_UNIT_WIDGET
|
||||
raaf_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
rnzaf_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
valiant_widget: SHIP_WIDGET
|
||||
illustrious_widget: SHIP_WIDGET
|
||||
-- Turn 4
|
||||
south_dakota_widget: SHIP_WIDGET
|
||||
indiana_widget: SHIP_WIDGET
|
||||
washington_widget: SHIP_WIDGET
|
||||
wasp_widget: SHIP_WIDGET
|
||||
marine_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
thirteenth_af_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
devonshire_widget: SHIP_WIDGET
|
||||
shropshire_widget: SHIP_WIDGET
|
||||
first_027_removal_widget: SHIP_WIDGET
|
||||
second_027_removal_widget: SHIP_WIDGET
|
||||
-- Turn 5
|
||||
massachusetts_widget: SHIP_WIDGET
|
||||
wichita_widget: SHIP_WIDGET
|
||||
victorious_widget: SHIP_WIDGET
|
||||
marines_3_widget: AMPHIBIOUS_UNIT_WIDGET
|
||||
fourteenth_af_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
naval_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
resolution_removal_widget: SHIP_WIDGET
|
||||
revenge_removal_widget: SHIP_WIDGET
|
||||
valiant_removal_widget: SHIP_WIDGET
|
||||
warspite_removal_widget: SHIP_WIDGET
|
||||
-- Turn 6
|
||||
alabama_widget: SHIP_WIDGET
|
||||
essex_widget: SHIP_WIDGET
|
||||
cv_10_widget: SHIP_WIDGET
|
||||
cv_16_widget: SHIP_WIDGET
|
||||
independence_widget: SHIP_WIDGET
|
||||
princeton_widget: SHIP_WIDGET
|
||||
belleau_wood_widget: SHIP_WIDGET
|
||||
cowpens_widget: SHIP_WIDGET
|
||||
monterey_widget: SHIP_WIDGET
|
||||
baltimore_widget: SHIP_WIDGET
|
||||
boston_widget: SHIP_WIDGET
|
||||
marines_4_widget: AMPHIBIOUS_UNIT_WIDGET
|
||||
victorious_removal_widget: SHIP_WIDGET
|
||||
-- Turn 7
|
||||
iowa_widget: SHIP_WIDGET
|
||||
new_jersey_widget: SHIP_WIDGET
|
||||
intrepid_widget: SHIP_WIDGET
|
||||
cv_12_widget: SHIP_WIDGET
|
||||
bunker_hill_widget: SHIP_WIDGET
|
||||
cv_18_widget: SHIP_WIDGET
|
||||
bataan_widget: SHIP_WIDGET
|
||||
cabot_widget: SHIP_WIDGET
|
||||
langley_ii_widget: SHIP_WIDGET
|
||||
canberra_ii_widget: SHIP_WIDGET
|
||||
quincy_ii_widget: SHIP_WIDGET
|
||||
f_boat_widget: SUBMARINE_WIDGET
|
||||
third_027_removal_widget: SHIP_WIDGET
|
||||
first_443_removal_widget: SHIP_WIDGET
|
||||
-- Turn 8
|
||||
wisconsin_widget: SHIP_WIDGET
|
||||
missouri_widget: SHIP_WIDGET
|
||||
ticonderoga_widget: SHIP_WIDGET
|
||||
san_jacinto_widget: SHIP_WIDGET
|
||||
marines_5_widget: AMPHIBIOUS_UNIT_WIDGET
|
||||
-- Turn 9
|
||||
new_york_widget: SHIP_WIDGET
|
||||
texas_widget: SHIP_WIDGET
|
||||
alaska_widget: SHIP_WIDGET
|
||||
franklin_widget: SHIP_WIDGET
|
||||
shangri_la_widget: SHIP_WIDGET
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
extend_widgets
|
||||
-- Put turn-two to turn-nine allied {ATTACK_UNIT_WIDGET} into `world'.
|
||||
do
|
||||
create allied_forces_widgets.make (100)
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
allied_forces_widgets.extend (nevada_widget, game.nevada)
|
||||
allied_forces_widgets.extend (arizona_widget, game.arizona)
|
||||
allied_forces_widgets.extend (west_virginia_widget, game.west_virginia)
|
||||
allied_forces_widgets.extend (tennessee_widget, game.tennessee)
|
||||
allied_forces_widgets.extend (oklahoma_widget, game.oklahoma)
|
||||
allied_forces_widgets.extend (maryland_widget, game.maryland)
|
||||
allied_forces_widgets.extend (california_widget, game.california)
|
||||
allied_forces_widgets.extend (pennsylvania_widget, game.pennsylvania)
|
||||
allied_forces_widgets.extend (new_orleans_widget, game.new_orleans)
|
||||
allied_forces_widgets.extend (san_francisco_widget, game.san_francisco)
|
||||
allied_forces_widgets.extend (seventh_af_widget, game.seventh_af)
|
||||
-- At sea (cannot move)
|
||||
allied_forces_widgets.extend (hermes_widget, game.hermes)
|
||||
allied_forces_widgets.extend (revenge_widget, game.revenge)
|
||||
allied_forces_widgets.extend (prince_of_wales_widget, game.prince_of_wales)
|
||||
allied_forces_widgets.extend (repulse_widget, game.repulse)
|
||||
allied_forces_widgets.extend (fifth_af_widget, game.fifth_af)
|
||||
allied_forces_widgets.extend (louisville_widget, game.louisville)
|
||||
allied_forces_widgets.extend (pensacola_widget, game.pensacola)
|
||||
allied_forces_widgets.extend (indianapolis_widget, game.indianapolis)
|
||||
allied_forces_widgets.extend (minneapolis_widget, game.minneapolis)
|
||||
-- In port (may move)
|
||||
allied_forces_widgets.extend (houston_widget, game.houston)
|
||||
allied_forces_widgets.extend (exeter_widget, game.exeter)
|
||||
allied_forces_widgets.extend (de_ruyter_widget, game.de_ruyter)
|
||||
allied_forces_widgets.extend (australia_ship_widget, game.australia_ship)
|
||||
allied_forces_widgets.extend (canberra_widget, game.canberra)
|
||||
-- Location Uncertain, group W
|
||||
allied_forces_widgets.extend (enterprise_widget, game.enterprise)
|
||||
allied_forces_widgets.extend (salt_lake_city_widget, game.salt_lake_city)
|
||||
allied_forces_widgets.extend (northampton_widget, game.northampton)
|
||||
allied_forces_widgets.extend (chester_widget, game.chester)
|
||||
-- Location Uncertain, group X
|
||||
allied_forces_widgets.extend (lexington_widget, game.lexington)
|
||||
allied_forces_widgets.extend (chicago_widget, game.chicago)
|
||||
allied_forces_widgets.extend (portland_widget, game.portland)
|
||||
allied_forces_widgets.extend (astoria_widget, game.astoria)
|
||||
-- Location Uncertain, group Y
|
||||
allied_forces_widgets.extend (saratoga_widget, game.saratoga)
|
||||
-- Location Uncertain (group Z
|
||||
allied_forces_widgets.extend (hornet_widget, game.hornet)
|
||||
allied_forces_widgets.extend (yorktown_widget, game.yorktown)
|
||||
allied_forces_widgets.extend (vincennes_widget, game.vincennes)
|
||||
allied_forces_widgets.extend (quincy_widget, game.quincy)
|
||||
-- Turn 2
|
||||
allied_forces_widgets.extend (royal_sovereign_widget, game.royal_sovereign)
|
||||
allied_forces_widgets.extend (ramilies_widget, game.ramilies)
|
||||
allied_forces_widgets.extend (resolution_widget, game.resolution)
|
||||
allied_forces_widgets.extend (warspite_widget, game.warspite)
|
||||
allied_forces_widgets.extend (indomitable_widget, game.indomitable)
|
||||
allied_forces_widgets.extend (formidable_widget, game.formidable)
|
||||
allied_forces_widgets.extend (cornwall_widget, game.cornwall)
|
||||
allied_forces_widgets.extend (dorestshire_widget, game.dorestshire)
|
||||
allied_forces_widgets.extend (new_mexico_widget, game.new_mexico)
|
||||
allied_forces_widgets.extend (idaho_widget, game.idaho)
|
||||
allied_forces_widgets.extend (eleventh_af_widget, game.eleventh_af)
|
||||
-- Turn 3
|
||||
allied_forces_widgets.extend (north_carolina_widget, game.north_carolina)
|
||||
allied_forces_widgets.extend (mississippi_widget, game.mississippi)
|
||||
allied_forces_widgets.extend (colorado_widget, game.colorado)
|
||||
allied_forces_widgets.extend (marines_1_widget, game.marines_1)
|
||||
allied_forces_widgets.extend (marines_2_widget, game.marines_2)
|
||||
allied_forces_widgets.extend (raaf_widget, game.raaf)
|
||||
allied_forces_widgets.extend (rnzaf_widget, game.rnzaf)
|
||||
allied_forces_widgets.extend (valiant_widget, game.valiant)
|
||||
allied_forces_widgets.extend (illustrious_widget, game.illustrious)
|
||||
-- Turn 4
|
||||
allied_forces_widgets.extend (south_dakota_widget, game.south_dakota)
|
||||
allied_forces_widgets.extend (indiana_widget, game.indiana)
|
||||
allied_forces_widgets.extend (washington_widget, game.washington)
|
||||
allied_forces_widgets.extend (wasp_widget, game.wasp)
|
||||
allied_forces_widgets.extend (marine_widget, game.marine)
|
||||
allied_forces_widgets.extend (thirteenth_af_widget, game.thirteenth_af)
|
||||
allied_forces_widgets.extend (devonshire_widget, game.devonshire)
|
||||
allied_forces_widgets.extend (shropshire_widget, game.shropshire)
|
||||
-- allied_forces_widgets.extend (first_027_removal_widget, game.first_027_removal)
|
||||
-- allied_forces_widgets.extend (second_027_removal_widget, game.second_027_removal)
|
||||
-- Turn 5
|
||||
allied_forces_widgets.extend (massachusetts_widget, game.massachusetts)
|
||||
allied_forces_widgets.extend (wichita_widget, game.wichita)
|
||||
allied_forces_widgets.extend (victorious_widget, game.victorious)
|
||||
allied_forces_widgets.extend (marines_3_widget, game.marines_3)
|
||||
allied_forces_widgets.extend (fourteenth_af_widget, game.fourteenth_af)
|
||||
allied_forces_widgets.extend (naval_widget, game.naval)
|
||||
-- allied_forces_widgets.extend (resolution_removal_widget, game.resolution_removal)
|
||||
-- allied_forces_widgets.extend (revenge_removal_widget, game.revenge_removal)
|
||||
-- allied_forces_widgets.extend (valiant_removal_widget, game.valiant_removal)
|
||||
-- allied_forces_widgets.extend (warspite_removal_widget, game.warspite_removal)
|
||||
-- Turn 6
|
||||
allied_forces_widgets.extend (alabama_widget, game.alabama)
|
||||
allied_forces_widgets.extend (essex_widget, game.essex)
|
||||
allied_forces_widgets.extend (cv_10_widget, game.cv_10)
|
||||
allied_forces_widgets.extend (cv_16_widget, game.cv_16)
|
||||
allied_forces_widgets.extend (independence_widget, game.independence)
|
||||
allied_forces_widgets.extend (princeton_widget, game.princeton)
|
||||
allied_forces_widgets.extend (belleau_wood_widget, game.belleau_wood)
|
||||
allied_forces_widgets.extend (cowpens_widget, game.cowpens)
|
||||
allied_forces_widgets.extend (monterey_widget, game.monterey)
|
||||
allied_forces_widgets.extend (baltimore_widget, game.baltimore)
|
||||
allied_forces_widgets.extend (boston_widget, game.boston)
|
||||
allied_forces_widgets.extend (marines_4_widget, game.marines_4)
|
||||
-- allied_forces_widgets.extend (victorious_removal_widget, game.victorious_removal)
|
||||
-- Turn 7
|
||||
allied_forces_widgets.extend (iowa_widget, game.iowa)
|
||||
allied_forces_widgets.extend (new_jersey_widget, game.new_jersey)
|
||||
allied_forces_widgets.extend (intrepid_widget, game.intrepid)
|
||||
allied_forces_widgets.extend (cv_12_widget, game.cv_12)
|
||||
allied_forces_widgets.extend (bunker_hill_widget, game.bunker_hill)
|
||||
allied_forces_widgets.extend (cv_18_widget, game.cv_18)
|
||||
allied_forces_widgets.extend (bataan_widget, game.bataan)
|
||||
allied_forces_widgets.extend (cabot_widget, game.cabot)
|
||||
allied_forces_widgets.extend (langley_ii_widget, game.langley_ii)
|
||||
allied_forces_widgets.extend (canberra_ii_widget, game.canberra_ii)
|
||||
allied_forces_widgets.extend (quincy_ii_widget, game.quincy_ii)
|
||||
allied_forces_widgets.extend (f_boat_widget, game.f_boat)
|
||||
-- Turn 8
|
||||
allied_forces_widgets.extend (wisconsin_widget, game.wisconsin)
|
||||
allied_forces_widgets.extend (missouri_widget, game.missouri)
|
||||
allied_forces_widgets.extend (ticonderoga_widget, game.ticonderoga)
|
||||
allied_forces_widgets.extend (san_jacinto_widget, game.san_jacinto)
|
||||
allied_forces_widgets.extend (marines_5_widget, game.marines_5)
|
||||
-- Turn 9
|
||||
allied_forces_widgets.extend (new_york_widget, game.new_york)
|
||||
allied_forces_widgets.extend (texas_widget, game.texas)
|
||||
allied_forces_widgets.extend (alaska_widget, game.alaska)
|
||||
allied_forces_widgets.extend (franklin_widget, game.franklin)
|
||||
allied_forces_widgets.extend (shangri_la_widget, game.shangri_la)
|
||||
widgets.merge (allied_forces_widgets)
|
||||
end
|
||||
|
||||
pair_widgets
|
||||
-- Associate turn-two to turn-nine widgets with a unit
|
||||
do
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
allied_forces_widgets.force (nevada_widget, game.nevada)
|
||||
allied_forces_widgets.force (arizona_widget, game.arizona)
|
||||
allied_forces_widgets.force (west_virginia_widget, game.west_virginia)
|
||||
allied_forces_widgets.force (tennessee_widget, game.tennessee)
|
||||
allied_forces_widgets.force (oklahoma_widget, game.oklahoma)
|
||||
allied_forces_widgets.force (maryland_widget, game.maryland)
|
||||
allied_forces_widgets.force (california_widget, game.california)
|
||||
allied_forces_widgets.force (pennsylvania_widget, game.pennsylvania)
|
||||
allied_forces_widgets.force (new_orleans_widget, game.new_orleans)
|
||||
allied_forces_widgets.force (san_francisco_widget, game.san_francisco)
|
||||
allied_forces_widgets.force (seventh_af_widget, game.seventh_af)
|
||||
-- At sea (cannot move)
|
||||
allied_forces_widgets.force (hermes_widget, game.hermes)
|
||||
allied_forces_widgets.force (revenge_widget, game.revenge)
|
||||
allied_forces_widgets.force (prince_of_wales_widget, game.prince_of_wales)
|
||||
allied_forces_widgets.force (repulse_widget, game.repulse)
|
||||
allied_forces_widgets.force (fifth_af_widget, game.fifth_af)
|
||||
allied_forces_widgets.force (louisville_widget, game.louisville)
|
||||
allied_forces_widgets.force (pensacola_widget, game.pensacola)
|
||||
allied_forces_widgets.force (indianapolis_widget, game.indianapolis)
|
||||
allied_forces_widgets.force (minneapolis_widget, game.minneapolis)
|
||||
-- In port (may move)
|
||||
allied_forces_widgets.force (houston_widget, game.houston)
|
||||
allied_forces_widgets.force (exeter_widget, game.exeter)
|
||||
allied_forces_widgets.force (de_ruyter_widget, game.de_ruyter)
|
||||
allied_forces_widgets.force (australia_ship_widget, game.australia_ship)
|
||||
allied_forces_widgets.force (canberra_widget, game.canberra)
|
||||
-- Location Uncertain, group W
|
||||
allied_forces_widgets.force (enterprise_widget, game.enterprise)
|
||||
allied_forces_widgets.force (salt_lake_city_widget, game.salt_lake_city)
|
||||
allied_forces_widgets.force (northampton_widget, game.northampton)
|
||||
allied_forces_widgets.force (chester_widget, game.chester)
|
||||
-- Location Uncertain, group X
|
||||
allied_forces_widgets.force (lexington_widget, game.lexington)
|
||||
allied_forces_widgets.force (chicago_widget, game.chicago)
|
||||
allied_forces_widgets.force (portland_widget, game.portland)
|
||||
allied_forces_widgets.force (astoria_widget, game.astoria)
|
||||
-- Location Uncertain, group Y
|
||||
allied_forces_widgets.force (saratoga_widget, game.saratoga)
|
||||
-- Location Uncertain (group Z
|
||||
allied_forces_widgets.force (hornet_widget, game.hornet)
|
||||
allied_forces_widgets.force (yorktown_widget, game.yorktown)
|
||||
allied_forces_widgets.force (vincennes_widget, game.vincennes)
|
||||
allied_forces_widgets.force (quincy_widget, game.quincy)
|
||||
-- Turn 2
|
||||
allied_forces_widgets.force (royal_sovereign_widget, game.royal_sovereign)
|
||||
allied_forces_widgets.force (ramilies_widget, game.ramilies)
|
||||
allied_forces_widgets.force (resolution_widget, game.resolution)
|
||||
allied_forces_widgets.force (warspite_widget, game.warspite)
|
||||
allied_forces_widgets.force (indomitable_widget, game.indomitable)
|
||||
allied_forces_widgets.force (formidable_widget, game.formidable)
|
||||
allied_forces_widgets.force (cornwall_widget, game.cornwall)
|
||||
allied_forces_widgets.force (dorestshire_widget, game.dorestshire)
|
||||
allied_forces_widgets.force (new_mexico_widget, game.new_mexico)
|
||||
allied_forces_widgets.force (idaho_widget, game.idaho)
|
||||
allied_forces_widgets.force (tenth_af_widget, game.tenth_af)
|
||||
allied_forces_widgets.force (eleventh_af_widget, game.eleventh_af)
|
||||
-- Turn 3
|
||||
allied_forces_widgets.force (north_carolina_widget, game.north_carolina)
|
||||
allied_forces_widgets.force (mississippi_widget, game.mississippi)
|
||||
allied_forces_widgets.force (colorado_widget, game.colorado)
|
||||
allied_forces_widgets.force (marines_1_widget, game.marines_1)
|
||||
allied_forces_widgets.force (marines_2_widget, game.marines_2)
|
||||
allied_forces_widgets.force (raaf_widget, game.raaf)
|
||||
allied_forces_widgets.force (rnzaf_widget, game.rnzaf)
|
||||
allied_forces_widgets.force (valiant_widget, game.valiant)
|
||||
allied_forces_widgets.force (illustrious_widget, game.illustrious)
|
||||
-- Turn 4
|
||||
allied_forces_widgets.force (south_dakota_widget, game.south_dakota)
|
||||
allied_forces_widgets.force (indiana_widget, game.indiana)
|
||||
allied_forces_widgets.force (washington_widget, game.washington)
|
||||
allied_forces_widgets.force (wasp_widget, game.wasp)
|
||||
allied_forces_widgets.force (marine_widget, game.marine)
|
||||
allied_forces_widgets.force (thirteenth_af_widget, game.thirteenth_af)
|
||||
allied_forces_widgets.force (devonshire_widget, game.devonshire)
|
||||
allied_forces_widgets.force (shropshire_widget, game.shropshire)
|
||||
-- allied_forces_widgets.force (first_027_removal_widget, game.first_027_removal)
|
||||
-- allied_forces_widgets.force (second_027_removal_widget, game.second_027_removal)
|
||||
-- Turn 5
|
||||
allied_forces_widgets.force (massachusetts_widget, game.massachusetts)
|
||||
allied_forces_widgets.force (wichita_widget, game.wichita)
|
||||
allied_forces_widgets.force (victorious_widget, game.victorious)
|
||||
allied_forces_widgets.force (marines_3_widget, game.marines_3)
|
||||
allied_forces_widgets.force (fourteenth_af_widget, game.fourteenth_af)
|
||||
allied_forces_widgets.force (naval_widget, game.naval)
|
||||
-- allied_forces_widgets.force (resolution_removal_widget, game.resolution_removal)
|
||||
-- allied_forces_widgets.force (revenge_removal_widget, game.revenge_removal)
|
||||
-- allied_forces_widgets.force (valiant_removal_widget, game.valiant_removal)
|
||||
-- allied_forces_widgets.force (warspite_removal_widget, game.warspite_removal)
|
||||
-- Turn 6
|
||||
allied_forces_widgets.force (alabama_widget, game.alabama)
|
||||
allied_forces_widgets.force (essex_widget, game.essex)
|
||||
allied_forces_widgets.force (cv_10_widget, game.cv_10)
|
||||
allied_forces_widgets.force (cv_16_widget, game.cv_16)
|
||||
allied_forces_widgets.force (independence_widget, game.independence)
|
||||
allied_forces_widgets.force (princeton_widget, game.princeton)
|
||||
allied_forces_widgets.force (belleau_wood_widget, game.belleau_wood)
|
||||
allied_forces_widgets.force (cowpens_widget, game.cowpens)
|
||||
allied_forces_widgets.force (monterey_widget, game.monterey)
|
||||
allied_forces_widgets.force (baltimore_widget, game.baltimore)
|
||||
allied_forces_widgets.force (boston_widget, game.boston)
|
||||
allied_forces_widgets.force (marines_4_widget, game.marines_4)
|
||||
-- allied_forces_widgets.force (victorious_removal_widget, game.victorious_removal)
|
||||
-- Turn 7
|
||||
allied_forces_widgets.force (iowa_widget, game.iowa)
|
||||
allied_forces_widgets.force (new_jersey_widget, game.new_jersey)
|
||||
allied_forces_widgets.force (intrepid_widget, game.intrepid)
|
||||
allied_forces_widgets.force (cv_12_widget, game.cv_12)
|
||||
allied_forces_widgets.force (bunker_hill_widget, game.bunker_hill)
|
||||
allied_forces_widgets.force (cv_18_widget, game.cv_18)
|
||||
allied_forces_widgets.force (bataan_widget, game.bataan)
|
||||
allied_forces_widgets.force (cabot_widget, game.cabot)
|
||||
allied_forces_widgets.force (langley_ii_widget, game.langley_ii)
|
||||
allied_forces_widgets.force (canberra_ii_widget, game.canberra_ii)
|
||||
allied_forces_widgets.force (quincy_ii_widget, game.quincy_ii)
|
||||
allied_forces_widgets.force (f_boat_widget, game.f_boat)
|
||||
-- Turn 8
|
||||
allied_forces_widgets.force (wisconsin_widget, game.wisconsin)
|
||||
allied_forces_widgets.force (missouri_widget, game.missouri)
|
||||
allied_forces_widgets.force (ticonderoga_widget, game.ticonderoga)
|
||||
allied_forces_widgets.force (san_jacinto_widget, game.san_jacinto)
|
||||
allied_forces_widgets.force (marines_5_widget, game.marines_5)
|
||||
-- Turn 9
|
||||
allied_forces_widgets.force (new_york_widget, game.new_york)
|
||||
allied_forces_widgets.force (texas_widget, game.texas)
|
||||
allied_forces_widgets.force (alaska_widget, game.alaska)
|
||||
allied_forces_widgets.force (franklin_widget, game.franklin)
|
||||
allied_forces_widgets.force (shangri_la_widget, game.shangri_la)
|
||||
end
|
||||
|
||||
fill_widgets
|
||||
-- Call `set_target' to give each widget a target.
|
||||
do
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
nevada_widget.set_target (game.nevada)
|
||||
arizona_widget.set_target (game.arizona)
|
||||
west_virginia_widget.set_target (game.west_virginia)
|
||||
tennessee_widget.set_target (game.tennessee)
|
||||
oklahoma_widget.set_target (game.oklahoma)
|
||||
maryland_widget.set_target (game.maryland)
|
||||
california_widget.set_target (game.california)
|
||||
pennsylvania_widget.set_target (game.pennsylvania)
|
||||
new_orleans_widget.set_target (game.new_orleans)
|
||||
san_francisco_widget.set_target (game.san_francisco)
|
||||
seventh_af_widget.set_target (game.seventh_af)
|
||||
-- At sea (cannot move)
|
||||
hermes_widget.set_target (game.hermes)
|
||||
revenge_widget.set_target (game.revenge)
|
||||
prince_of_wales_widget.set_target (game.prince_of_wales)
|
||||
repulse_widget.set_target (game.repulse)
|
||||
fifth_af_widget.set_target (game.fifth_af)
|
||||
louisville_widget.set_target (game.louisville)
|
||||
pensacola_widget.set_target (game.pensacola)
|
||||
indianapolis_widget.set_target (game.indianapolis)
|
||||
minneapolis_widget.set_target (game.minneapolis)
|
||||
-- In port (may move)
|
||||
houston_widget.set_target (game.houston)
|
||||
exeter_widget.set_target (game.exeter)
|
||||
de_ruyter_widget.set_target (game.de_ruyter)
|
||||
australia_ship_widget.set_target (game.australia_ship)
|
||||
canberra_widget.set_target (game.canberra)
|
||||
-- Location Uncertain, group W
|
||||
enterprise_widget.set_target (game.enterprise)
|
||||
salt_lake_city_widget.set_target (game.salt_lake_city)
|
||||
northampton_widget.set_target (game.northampton)
|
||||
chester_widget.set_target (game.chester)
|
||||
-- Location Uncertain, group X
|
||||
lexington_widget.set_target (game.lexington)
|
||||
chicago_widget.set_target (game.chicago)
|
||||
portland_widget.set_target (game.portland)
|
||||
astoria_widget.set_target (game.astoria)
|
||||
-- Location Uncertain, group Y
|
||||
saratoga_widget.set_target (game.saratoga)
|
||||
-- Location Uncertain, group W
|
||||
hornet_widget.set_target (game.hornet)
|
||||
yorktown_widget.set_target (game.yorktown)
|
||||
vincennes_widget.set_target (game.vincennes)
|
||||
quincy_widget.set_target (game.quincy)
|
||||
-- Turn 2
|
||||
royal_sovereign_widget.set_target (game.royal_sovereign)
|
||||
ramilies_widget.set_target (game.ramilies)
|
||||
resolution_widget.set_target (game.resolution)
|
||||
warspite_widget.set_target (game.warspite)
|
||||
indomitable_widget.set_target (game.indomitable)
|
||||
formidable_widget.set_target (game.formidable)
|
||||
cornwall_widget.set_target (game.cornwall)
|
||||
dorestshire_widget.set_target (game.dorestshire)
|
||||
new_mexico_widget.set_target (game.new_mexico)
|
||||
idaho_widget.set_target (game.idaho)
|
||||
tenth_af_widget.set_target (game.tenth_af)
|
||||
eleventh_af_widget.set_target (game.eleventh_af)
|
||||
-- Turn 3
|
||||
north_carolina_widget.set_target (game.north_carolina)
|
||||
mississippi_widget.set_target (game.mississippi)
|
||||
colorado_widget.set_target (game.colorado)
|
||||
marines_1_widget.set_target (game.marines_1)
|
||||
marines_2_widget.set_target (game.marines_2)
|
||||
raaf_widget.set_target (game.raaf)
|
||||
rnzaf_widget.set_target (game.rnzaf)
|
||||
valiant_widget.set_target (game.valiant)
|
||||
illustrious_widget.set_target (game.illustrious)
|
||||
-- Turn 4
|
||||
south_dakota_widget.set_target (game.south_dakota)
|
||||
indiana_widget.set_target (game.indiana)
|
||||
washington_widget.set_target (game.washington)
|
||||
wasp_widget.set_target (game.wasp)
|
||||
marine_widget.set_target (game.marine)
|
||||
thirteenth_af_widget.set_target (game.thirteenth_af)
|
||||
devonshire_widget.set_target (game.devonshire)
|
||||
shropshire_widget.set_target (game.shropshire)
|
||||
first_027_removal_widget.set_target (game.first_027_removal)
|
||||
second_027_removal_widget.set_target (game.second_027_removal)
|
||||
-- Turn 5
|
||||
massachusetts_widget.set_target (game.massachusetts)
|
||||
wichita_widget.set_target (game.wichita)
|
||||
victorious_widget.set_target (game.victorious)
|
||||
marines_3_widget.set_target (game.marines_3)
|
||||
fourteenth_af_widget.set_target (game.fourteenth_af)
|
||||
naval_widget.set_target (game.naval)
|
||||
resolution_removal_widget.set_target (game.resolution)
|
||||
revenge_removal_widget.set_target (game.revenge)
|
||||
valiant_removal_widget.set_target (game.valiant_removal)
|
||||
warspite_removal_widget.set_target (game.warspite)
|
||||
-- Turn 6
|
||||
alabama_widget.set_target (game.alabama)
|
||||
essex_widget.set_target (game.essex)
|
||||
cv_10_widget.set_target (game.cv_10)
|
||||
cv_16_widget.set_target (game.cv_16)
|
||||
independence_widget.set_target (game.independence)
|
||||
princeton_widget.set_target (game.princeton)
|
||||
belleau_wood_widget.set_target (game.belleau_wood)
|
||||
cowpens_widget.set_target (game.cowpens)
|
||||
monterey_widget.set_target (game.monterey)
|
||||
baltimore_widget.set_target (game.baltimore)
|
||||
boston_widget.set_target (game.boston)
|
||||
marines_4_widget.set_target (game.marines_4)
|
||||
victorious_removal_widget.set_target (game.victorious_removal)
|
||||
-- Turn 7
|
||||
iowa_widget.set_target (game.iowa)
|
||||
new_jersey_widget.set_target (game.new_jersey)
|
||||
intrepid_widget.set_target (game.intrepid)
|
||||
cv_12_widget.set_target (game.cv_12)
|
||||
bunker_hill_widget.set_target (game.bunker_hill)
|
||||
cv_18_widget.set_target (game.cv_18)
|
||||
bataan_widget.set_target (game.bataan)
|
||||
cabot_widget.set_target (game.cabot)
|
||||
langley_ii_widget.set_target (game.langley_ii)
|
||||
canberra_ii_widget.set_target (game.canberra_ii)
|
||||
quincy_ii_widget.set_target (game.quincy_ii)
|
||||
f_boat_widget.set_target (game.f_boat)
|
||||
third_027_removal_widget.set_target (game.third_027_removal)
|
||||
first_443_removal_widget.set_target (game.first_443_removal)
|
||||
-- Turn 8
|
||||
wisconsin_widget.set_target (game.wisconsin)
|
||||
missouri_widget.set_target (game.missouri)
|
||||
ticonderoga_widget.set_target (game.ticonderoga)
|
||||
san_jacinto_widget.set_target (game.san_jacinto)
|
||||
marines_5_widget.set_target (game.marines_5)
|
||||
-- Turn 9
|
||||
new_york_widget.set_target (game.new_york)
|
||||
texas_widget.set_target (game.texas)
|
||||
alaska_widget.set_target (game.alaska)
|
||||
franklin_widget.set_target (game.franklin)
|
||||
shangri_la_widget.set_target (game.shangri_la)
|
||||
end
|
||||
|
||||
end
|
590
jj_vitp/Interface/views/allied_order_of_appearance_chart_view.e
Normal file
590
jj_vitp/Interface/views/allied_order_of_appearance_chart_view.e
Normal file
@@ -0,0 +1,590 @@
|
||||
note
|
||||
description: "[
|
||||
|
||||
]"
|
||||
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
|
||||
ALLIED_ORDER_OF_APPEARANCE_CHART_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
ORDER_OF_APPEARANCE_VIEW
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
add_widgets,
|
||||
add_units,
|
||||
add_miscellaneous_text,
|
||||
add_copyright_text,
|
||||
set_target,
|
||||
widget_factory,
|
||||
draw
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Set up Current
|
||||
do
|
||||
Precursor {ORDER_OF_APPEARANCE_VIEW}
|
||||
create group_widgets.make
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up attributes
|
||||
do
|
||||
nationality := {NATIONALITY_CONSTANTS}.allied
|
||||
Precursor
|
||||
flag.hide
|
||||
big_marker.hide
|
||||
little_marker.hide
|
||||
end
|
||||
|
||||
add_widgets
|
||||
-- Create the widgets for the chart
|
||||
do
|
||||
Precursor
|
||||
add_removals
|
||||
add_uncommitted_box
|
||||
end
|
||||
|
||||
add_turns
|
||||
-- Add the "TURN X" and "TO date" texts
|
||||
local
|
||||
i: INTEGER
|
||||
do
|
||||
from i := 2
|
||||
until i > 9
|
||||
loop
|
||||
add_turn_text (i)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
add_units
|
||||
-- Add {ATTACK_UNIT_WIDGETS} to Current
|
||||
do
|
||||
-- Turn 1 widgets or on a different chart
|
||||
-- Turn 2
|
||||
add_model (positioned_widget (widget_factory.royal_sovereign_widget, Royal_sovereign_cp))
|
||||
add_model (positioned_widget (widget_factory.ramilies_widget, ramilies_cp))
|
||||
add_model (positioned_widget (widget_factory.resolution_widget, resolution_cp))
|
||||
add_model (positioned_widget (widget_factory.warspite_widget, warspite_cp))
|
||||
add_model (positioned_widget (widget_factory.indomitable_widget, indomitable_cp))
|
||||
add_model (positioned_widget (widget_factory.formidable_widget, formidable_cp))
|
||||
add_model (positioned_widget (widget_factory.cornwall_widget, cornwall_cp))
|
||||
add_model (positioned_widget (widget_factory.dorestshire_widget, dorestshire_cp))
|
||||
add_model (positioned_widget (widget_factory.new_mexico_widget, new_mexico_cp))
|
||||
add_model (positioned_widget (widget_factory.idaho_widget, idaho_cp))
|
||||
add_model (positioned_widget (widget_factory.tenth_af_widget, tenth_af_cp))
|
||||
add_model (positioned_widget (widget_factory.eleventh_af_widget, eleventh_af_cp))
|
||||
-- Turn 3
|
||||
add_model (positioned_widget (widget_factory.north_carolina_widget, north_carolina_cp))
|
||||
add_model (positioned_widget (widget_factory.mississippi_widget, mississippi_cp))
|
||||
add_model (positioned_widget (widget_factory.colorado_widget,colorado_cp))
|
||||
add_model (positioned_widget (widget_factory.marines_1_widget, marines_1_cp))
|
||||
add_model (positioned_widget (widget_factory.marines_2_widget, marines_2_cp))
|
||||
add_model (positioned_widget (widget_factory.raaf_widget, raaf_cp))
|
||||
add_model (positioned_widget (widget_factory.rnzaf_widget, rnzaf_cp))
|
||||
add_model (positioned_widget (widget_factory.valiant_widget, valiant_cp))
|
||||
add_model (positioned_widget (widget_factory.illustrious_widget, illustrious_cp))
|
||||
-- Turn 4
|
||||
add_model (positioned_widget (widget_factory.south_dakota_widget, south_dakota_cp))
|
||||
add_model (positioned_widget (widget_factory.indiana_widget, indiana_cp))
|
||||
add_model (positioned_widget (widget_factory.washington_widget, washington_cp))
|
||||
add_model (positioned_widget (widget_factory.wasp_widget, wasp_cp))
|
||||
add_model (positioned_widget (widget_factory.marine_widget, marine_cp))
|
||||
add_model (positioned_widget (widget_factory.thirteenth_af_widget, thirteenth_af_cp))
|
||||
add_model (positioned_widget (widget_factory.devonshire_widget, devonshire_cp))
|
||||
add_model (positioned_widget (widget_factory.shropshire_widget, shropshire_cp))
|
||||
-- Turn 5
|
||||
add_model (positioned_widget (widget_factory.massachusetts_widget, massachusetts_cp))
|
||||
add_model (positioned_widget (widget_factory.wichita_widget, wichita_cp))
|
||||
add_model (positioned_widget (widget_factory.victorious_widget, victorious_cp))
|
||||
add_model (positioned_widget (widget_factory.marines_3_widget, marines_3_cp))
|
||||
add_model (positioned_widget (widget_factory.fourteenth_af_widget, fourteenth_af_cp))
|
||||
add_model (positioned_widget (widget_factory.naval_widget, naval_cp))
|
||||
-- Turn 6
|
||||
add_model (positioned_widget (widget_factory.alabama_widget, alabama_cp))
|
||||
add_model (positioned_widget (widget_factory.essex_widget, essex_cp))
|
||||
add_model (positioned_widget (widget_factory.cv_10_widget, cv_10_cp))
|
||||
add_model (positioned_widget (widget_factory.cv_16_widget, cv_16_cp))
|
||||
add_model (positioned_widget (widget_factory.independence_widget, independence_cp))
|
||||
add_model (positioned_widget (widget_factory.princeton_widget, princeton_cp))
|
||||
add_model (positioned_widget (widget_factory.belleau_wood_widget, belleau_wood_cp))
|
||||
add_model (positioned_widget (widget_factory.cowpens_widget, cowpens_cp))
|
||||
add_model (positioned_widget (widget_factory.monterey_widget, monterey_cp))
|
||||
add_model (positioned_widget (widget_factory.baltimore_widget, baltimore_cp))
|
||||
add_model (positioned_widget (widget_factory.boston_widget, boston_cp))
|
||||
add_model (positioned_widget (widget_factory.marines_4_widget, marines_4_cp))
|
||||
-- Turn 7
|
||||
add_model (positioned_widget (widget_factory.iowa_widget, iowa_cp))
|
||||
add_model (positioned_widget (widget_factory.new_jersey_widget, new_jersey_cp))
|
||||
add_model (positioned_widget (widget_factory.intrepid_widget, intrepid_cp))
|
||||
add_model (positioned_widget (widget_factory.cv_12_widget, cv_12_cp))
|
||||
add_model (positioned_widget (widget_factory.bunker_hill_widget, bunker_hill_cp))
|
||||
add_model (positioned_widget (widget_factory.cv_18_widget, cv_18_cp))
|
||||
add_model (positioned_widget (widget_factory.bataan_widget, bataan_cp))
|
||||
add_model (positioned_widget (widget_factory.cabot_widget, cabot_cp))
|
||||
add_model (positioned_widget (widget_factory.langley_ii_widget, langley_ii_cp))
|
||||
add_model (positioned_widget (widget_factory.canberra_ii_widget, canberra_ii_cp))
|
||||
add_model (positioned_widget (widget_factory.quincy_ii_widget, quincy_ii_cp))
|
||||
add_model (positioned_widget (widget_factory.f_boat_widget, f_boat_cp))
|
||||
-- Turn 8
|
||||
add_model (positioned_widget (widget_factory.wisconsin_widget, wisconsin_cp))
|
||||
add_model (positioned_widget (widget_factory.missouri_widget, missouri_cp))
|
||||
add_model (positioned_widget (widget_factory.ticonderoga_widget, ticonderoga_cp))
|
||||
add_model (positioned_widget (widget_factory.san_jacinto_widget, san_jacinto_cp))
|
||||
add_model (positioned_widget (widget_factory.marines_5_widget, marines_5_cp))
|
||||
-- Turn 9
|
||||
add_model (positioned_widget (widget_factory.new_york_widget, new_york_cp))
|
||||
add_model (positioned_widget (widget_factory.texas_widget, texas_cp))
|
||||
add_model (positioned_widget (widget_factory.alaska_widget, alaska_cp))
|
||||
add_model (positioned_widget (widget_factory.franklin_widget, franklin_cp))
|
||||
add_model (positioned_widget (widget_factory.shangri_la_widget, shangri_la_cp))
|
||||
end
|
||||
|
||||
add_removals
|
||||
-- All removal widgets and "REMOVALS" texts
|
||||
local
|
||||
wf: like widget_factory
|
||||
do
|
||||
wf := widget_factory
|
||||
world.extend (positioned_widget (wf.first_027_removal_widget, first_027_removal_cp))
|
||||
world.extend (positioned_widget (wf.second_027_removal_widget, second_027_removal_cp))
|
||||
world.extend (positioned_widget (wf.resolution_removal_widget, resolution_removal_cp))
|
||||
world.extend (positioned_widget (wf.revenge_removal_widget, revenge_removal_cp))
|
||||
world.extend (positioned_widget (wf.valiant_removal_widget, valiant_removal_cp))
|
||||
world.extend (positioned_widget (wf.warspite_removal_widget, warspite_removal_cp))
|
||||
world.extend (positioned_widget (wf.victorious_removal_widget, victorious_removal_cp))
|
||||
world.extend (positioned_widget (wf.third_027_removal_widget, third_027_removal_cp))
|
||||
world.extend (positioned_widget (wf.first_443_removal_widget, first_443_removal_cp))
|
||||
-- Set flipped
|
||||
wf.first_027_removal_widget.set_flipped
|
||||
wf.second_027_removal_widget.set_flipped
|
||||
wf.resolution_removal_widget.set_flipped
|
||||
wf.revenge_removal_widget.set_flipped
|
||||
wf.valiant_removal_widget.set_flipped
|
||||
wf.warspite_removal_widget.set_flipped
|
||||
wf.victorious_removal_widget.set_flipped
|
||||
wf.third_027_removal_widget.set_flipped
|
||||
wf.first_443_removal_widget.set_flipped
|
||||
-- Set flat
|
||||
wf.first_027_removal_widget.set_flat
|
||||
wf.second_027_removal_widget.set_flat
|
||||
wf.resolution_removal_widget.set_flat
|
||||
wf.revenge_removal_widget.set_flat
|
||||
wf.valiant_removal_widget.set_flat
|
||||
wf.warspite_removal_widget.set_flat
|
||||
wf.victorious_removal_widget.set_flat
|
||||
wf.third_027_removal_widget.set_flat
|
||||
wf.first_443_removal_widget.set_flat
|
||||
end
|
||||
|
||||
add_uncommitted_box
|
||||
-- Add the uncommitted box, making spots for possible widgets
|
||||
local
|
||||
rec: EV_MODEL_RECTANGLE
|
||||
bot_rt: EV_COORDINATE
|
||||
t: EV_MODEL_TEXT
|
||||
cp: EV_COORDINATE
|
||||
wf: like widget_factory
|
||||
do
|
||||
create bot_rt.make (uncommitted_box_cp.x + (1.5 * ship_size).floor, uncommitted_box_cp.y + 2 * ship_size)
|
||||
create rec.make_with_points (uncommitted_box_cp, bot_rt)
|
||||
world.extend (rec)
|
||||
rec.set_foreground_color (color)
|
||||
rec.set_background_color (lightened (color, 2.8))
|
||||
t := new_text ("Groups W, X, Y, Z%N uncommitted %N on Turn 1", turn_x_losses_font)
|
||||
t.set_x_y (rec.x, rec.y)
|
||||
world.extend (t)
|
||||
-- Add widgets to the box using offset's from the `uncommitted_box_cp'
|
||||
create cp
|
||||
wf := widget_factory
|
||||
-- Group W - Enterprise
|
||||
cp.set_position (uncommitted_box_cp.x + gap_size, uncommitted_box_cp.y - 3 * gap_size)
|
||||
world.extend (positioned_widget (wf.chester_widget, cp))
|
||||
cp.set_position (cp.x - 1, cp.y - 2)
|
||||
world.extend (positioned_widget (wf.northampton_widget, cp))
|
||||
cp.set_position (cp.x - 1, cp.y - 2)
|
||||
world.extend (positioned_widget (wf.salt_lake_city_widget, cp))
|
||||
cp.set_position (cp.x - 1, cp.y - 2)
|
||||
world.extend (positioned_widget (wf.enterprise_widget, cp))
|
||||
-- Group X - Lexington
|
||||
cp.set_position (uncommitted_box_cp.x + 3 * gap_size, uncommitted_box_cp.y)
|
||||
world.extend (positioned_widget (wf.astoria_widget, cp))
|
||||
cp.set_position (cp.x + 1, cp.y - 2)
|
||||
world.extend (positioned_widget (wf.portland_widget, cp))
|
||||
cp.set_position (cp.x + 1, cp.y - 2)
|
||||
world.extend (positioned_widget (wf.chicago_widget, cp))
|
||||
cp.set_position (cp.x + 1, cp.y - 2)
|
||||
world.extend (positioned_widget (wf.lexington_widget, cp))
|
||||
-- Group Y -Saratoga
|
||||
cp.set_position (uncommitted_box_cp.x + 4 * gap_size, uncommitted_box_cp.y + ship_size + 2 * gap_size)
|
||||
world.extend (positioned_widget (wf.saratoga_widget, cp))
|
||||
-- Group Z - Hornet
|
||||
cp.set_position (uncommitted_box_cp.x - gap_size, uncommitted_box_cp.y + ship_size + gap_size)
|
||||
world.extend (positioned_widget (wf.quincy_widget, cp))
|
||||
cp.set_position (cp.x - 1, cp.y - 2)
|
||||
world.extend (positioned_widget (wf.vincennes_widget, cp))
|
||||
cp.set_position (cp.x - 1, cp.y - 2)
|
||||
world.extend (positioned_widget (wf.yorktown_widget, cp))
|
||||
cp.set_position (cp.x - 1, cp.y - 2)
|
||||
world.extend (positioned_widget (wf.hornet_widget, cp))
|
||||
-- Hide Group W
|
||||
wf.chester_widget.hide
|
||||
wf.northampton_widget.hide
|
||||
wf.salt_lake_city_widget.hide
|
||||
wf.enterprise_widget.hide
|
||||
-- Hide Group X
|
||||
wf.astoria_widget.hide
|
||||
wf.portland_widget.hide
|
||||
wf.chicago_widget.hide
|
||||
wf.lexington_widget.hide
|
||||
-- Hide Group Y
|
||||
wf.saratoga_widget.hide
|
||||
-- Hide group Z
|
||||
wf.quincy_widget.hide
|
||||
wf.vincennes_widget.hide
|
||||
wf.yorktown_widget.hide
|
||||
wf.hornet_widget.hide
|
||||
end
|
||||
|
||||
add_miscellaneous_text
|
||||
-- Add the remaining text fields
|
||||
local
|
||||
cp: EV_COORDINATE
|
||||
t: EV_MODEL_TEXT
|
||||
s: STRING
|
||||
do
|
||||
create cp
|
||||
s := " AUSTRALIA 1 Repair Point Each Turn %N"
|
||||
s := s + "AT CEYLON 1 Repair Point Each Turn"
|
||||
t := new_text (s, at_port_font)
|
||||
cp.set (resolution_cp.x, turn_2_cp.y)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (" 3 Repair Points %N PEARL HARBOR", at_port_font)
|
||||
cp.set (new_mexico_cp.x - gap_size, turn_2_cp.y)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (" 6 Repair Points %N AT PEARL HARBOR", at_port_font)
|
||||
cp.set (colorado_cp.x, turn_3_cp.y)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (" 9 Repair Points %N AT PEARL HARBOR", at_port_font)
|
||||
cp.set (colorado_cp.x, turn_4_cp.y)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (" 12 Repair Points %N AT PEARL HARBOR", at_port_font)
|
||||
cp.set (colorado_cp.x, turn_5_cp.y)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (" 15 Repair Points %N AT PEARL HARBOR", at_port_font)
|
||||
cp.set (colorado_cp.x, turn_6_cp.y)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (" 15 Repair Points %N AT PEARL HARBOR", at_port_font)
|
||||
cp.set (colorado_cp.x, turn_7_cp.y)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (" 15 Repair Points %N AT PEARL HARBOR", at_port_font)
|
||||
cp.set (colorado_cp.x, turn_8_cp.y)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text ("AT PEARL HARBOR 15 Repair Points", at_port_font)
|
||||
cp.set (colorado_cp.x, new_york_cp.y - 2 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- some more text
|
||||
t := new_text ("AT CEYLON", at_port_font)
|
||||
cp.set (valiant_cp.x + 2 * gap_size, valiant_cp.y - 3 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text ("AT CEYLON", at_port_font)
|
||||
cp.set (devonshire_cp.x + 2 * gap_size, devonshire_cp.y - 3 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- also available
|
||||
t := new_text (" Also %NAvailable", turn_x_losses_font)
|
||||
cp.set (tenth_af_cp.x, tenth_af_cp.y - 3 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
s := "Also Available"
|
||||
t := new_text (s, turn_x_losses_font)
|
||||
cp.set (raaf_cp.x + 2 * gap_size, raaf_cp.y - 2 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (s, turn_x_losses_font)
|
||||
cp.set (marine_cp.x + 2 * gap_size, marine_cp.y - 2 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (s, turn_x_losses_font)
|
||||
cp.set (fourteenth_af_cp.x + 2 * gap_size, fourteenth_af_cp.y - 2 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Also Available for F-boat
|
||||
t := new_text ("Also Available", turn_x_losses_font)
|
||||
cp.set (f_boat_cp.x, f_boat_cp.y - 2 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Replace with texts
|
||||
s := "(replace with other British if sunk)"
|
||||
t := new_text (s, small_font)
|
||||
cp.set (first_027_removal_cp.x, first_027_removal_cp.y + ship_size + gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (s, small_font)
|
||||
cp.set (revenge_removal_cp.x, revenge_removal_cp.y + ship_size + gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
s := "(replace with other %NBritish if sunk)"
|
||||
t := new_text (s, small_font)
|
||||
cp.set (victorious_removal_cp.x + ship_size + gap_size, victorious_removal_cp.y + gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- REMOVAL texts
|
||||
s := "REMOVALS"
|
||||
t := new_text (s, turn_x_losses_font)
|
||||
cp.set (first_027_removal_cp.x + 5 * gap_size, first_027_removal_cp.y - 2 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (s, turn_x_losses_font)
|
||||
cp.set (revenge_removal_cp.x + 5 * gap_size, revenge_removal_cp.y - 2 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
t := new_text (s, turn_x_losses_font)
|
||||
cp.set (third_027_removal_cp.x + 5 * gap_size, third_027_removal_cp.y - 2 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
s := "REMOVAL"
|
||||
t := new_text (s, turn_x_losses_font)
|
||||
cp.set (victorious_removal_cp.x + gap_size, victorious_removal_cp.y - 2 * gap_size)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
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 (bottom_right_cp.x - t.width - 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.allied_oa_chart
|
||||
end
|
||||
|
||||
title: STRING = "Allied 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.
|
||||
local
|
||||
afw: like widget_factory.allied_forces_widgets
|
||||
do
|
||||
Precursor (a_item)
|
||||
afw := widget_factory.allied_forces_widgets
|
||||
-- Make the widgets white
|
||||
-- afw.first_027_removal_widget.set_flipped
|
||||
-- afw.second_027_removal_widget.set_flipped
|
||||
-- afw.resolution_removal_widget.set_flipped
|
||||
-- afw.revenge_removal_widget.set_flipped
|
||||
-- afw.valiant_removal_widget.set_flipped
|
||||
-- afw.warspite_removal_widget.set_flipped
|
||||
-- afw.victorious_removal_widget.set_flipped
|
||||
-- afw.third_027_removal_widget.set_flipped
|
||||
-- afw.first_443_removal_widget.set_flipped
|
||||
-- -- Make it look like print
|
||||
-- afw.first_027_removal_widget.set_flat
|
||||
-- afw.second_027_removal_widget.set_flat
|
||||
-- afw.resolution_removal_widget.set_flat
|
||||
-- afw.revenge_removal_widget.set_flat
|
||||
-- afw.valiant_removal_widget.set_flat
|
||||
-- afw.warspite_removal_widget.set_flat
|
||||
-- afw.victorious_removal_widget.set_flat
|
||||
-- afw.third_027_removal_widget.set_flat
|
||||
-- afw.first_443_removal_widget.set_flat
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Redraw the view.
|
||||
-- Redefined to account for "Location Uncertain" widgets from turn 1.
|
||||
local
|
||||
t: VITP_WIDGET_TABLE [ATTACK_UNIT_WIDGET, ATTACK_UNIT]
|
||||
w: ATTACK_UNIT_WIDGET
|
||||
-- s: STRING
|
||||
u: ATTACK_UNIT
|
||||
do
|
||||
Precursor
|
||||
from group_widgets.start
|
||||
until group_widgets.after
|
||||
loop
|
||||
w := group_widgets.item
|
||||
if not w.is_view_empty and then w.unit.location = location then
|
||||
w.show
|
||||
else
|
||||
w.hide
|
||||
end
|
||||
group_widgets.forth
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
widget_factory: ALLIED_FORCES_WIDGET_FACTORY
|
||||
-- Container for all the widget (e.g. attack widget,
|
||||
-- location widget, etc)
|
||||
|
||||
group_widgets: LINKED_LIST [SHIP_WIDGET]
|
||||
-- To keep track of the "Location Uncertain" widgets, so they
|
||||
-- can be shown in `draw' only if they are on this chart.
|
||||
|
||||
feature {NONE} -- Control point constants
|
||||
|
||||
bottom_right_cp: EV_COORDINATE once create Result.make (260, 355) end
|
||||
-- Change the Turn-x control points
|
||||
turn_1_cp: EV_COORDINATE do create Result end
|
||||
turn_2_cp: EV_COORDINATE do create Result.make (7, 14) end
|
||||
turn_3_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, 50) end
|
||||
turn_4_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, 85) end
|
||||
turn_5_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, 120) end
|
||||
turn_6_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, 155) end
|
||||
turn_7_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, 215) end
|
||||
turn_8_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, 275) end
|
||||
turn_9_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, 310) 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
|
||||
-- Change the Turn-x-losses control points
|
||||
turn_1_losses_cp: EV_COORDINATE do create Result.make (194, 64) end
|
||||
turn_2_losses_cp: EV_COORDINATE do create Result.make (204, 98) end
|
||||
turn_3_losses_cp: EV_COORDINATE do create Result.make (200, 132) end
|
||||
turn_4_losses_cp: EV_COORDINATE do create Result.make (194, 192) end
|
||||
turn_5_losses_cp: EV_COORDINATE do create Result.make (194, 254) end
|
||||
turn_6_losses_cp: EV_COORDINATE do create Result.make (194, 288) end
|
||||
turn_7_losses_cp: EV_COORDINATE do create Result.make (194, 324) end
|
||||
|
||||
-- Turn 2
|
||||
Royal_sovereign_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, Turn_2_cp.y + 12) end
|
||||
ramilies_cp: EV_COORDINATE do create Result.make (royal_sovereign_cp.x + ship_size, royal_sovereign_cp.y) end
|
||||
resolution_cp: EV_COORDINATE do create Result.make (ramilies_cp.x + ship_size, royal_sovereign_cp.y) end
|
||||
warspite_cp: EV_COORDINATE do create Result.make (resolution_cp.x + ship_size, royal_sovereign_cp.y) end
|
||||
indomitable_cp: EV_COORDINATE do create Result.make (warspite_cp.x + ship_size, royal_sovereign_cp.y) end
|
||||
formidable_cp: EV_COORDINATE do create Result.make (indomitable_cp.x + ship_size, royal_sovereign_cp.y) end
|
||||
cornwall_cp: EV_COORDINATE do create Result.make (formidable_cp.x + ship_size, royal_sovereign_cp.y) end
|
||||
dorestshire_cp: EV_COORDINATE do create Result.make (cornwall_cp.x + ship_size, royal_sovereign_cp.y) end
|
||||
new_mexico_cp: EV_COORDINATE do create Result.make (dorestshire_cp.x + ship_size + gap_size, royal_sovereign_cp.y) end
|
||||
idaho_cp: EV_COORDINATE do create Result.make (new_mexico_cp.x + ship_size, royal_sovereign_cp.y) end
|
||||
uncommitted_box_cp: EV_COORDINATE do create Result.make (idaho_cp.x + ship_size, Turn_2_cp.y + gap_size) end
|
||||
tenth_af_cp: EV_COORDINATE do create Result.make (240, 22) end
|
||||
eleventh_af_cp: EV_COORDINATE do create Result.make (tenth_af_cp.x, tenth_af_cp.y + air_size) end
|
||||
-- Turn 3
|
||||
north_carolina_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, Turn_3_cp.y + 12) end
|
||||
mississippi_cp: EV_COORDINATE do create Result.make (north_carolina_cp.x + ship_size, north_carolina_cp.y) end
|
||||
colorado_cp: EV_COORDINATE do create Result.make (mississippi_cp.x + ship_size, north_carolina_cp.y) end
|
||||
marines_1_cp: EV_COORDINATE do create Result.make (colorado_cp.x + ship_size, north_carolina_cp.y + ship_size - air_size) end
|
||||
marines_2_cp: EV_COORDINATE do create Result.make (marines_1_cp.x + air_size, marines_1_cp.y) end
|
||||
raaf_cp: EV_COORDINATE do create Result.make (marines_2_cp.x + air_size + 2 * gap_size, marines_1_cp.y) end
|
||||
rnzaf_cp: EV_COORDINATE do create Result.make (raaf_cp.x + air_size, marines_1_cp.y) end
|
||||
valiant_cp: EV_COORDINATE do create Result.make (rnzaf_cp.x + air_size + 4 * gap_size, north_carolina_cp.y) end
|
||||
illustrious_cp: EV_COORDINATE do create Result.make (valiant_cp.x + ship_size, north_carolina_cp.y) end
|
||||
-- Turn 4
|
||||
south_dakota_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, turn_4_cp.y + 12) end
|
||||
indiana_cp: EV_COORDINATE do create Result.make (south_dakota_cp.x + ship_size, south_dakota_cp.y) end
|
||||
washington_cp: EV_COORDINATE do create Result.make (indiana_cp.x + ship_size, south_dakota_cp.y) end
|
||||
wasp_cp: EV_COORDINATE do create Result.make (washington_cp.x + ship_size, south_dakota_cp.y) end
|
||||
marine_cp: EV_COORDINATE do create Result.make (wasp_cp.x + ship_size + gap_size, south_dakota_cp.y + ship_size - air_size) end
|
||||
thirteenth_af_cp: EV_COORDINATE do create Result.make (marine_cp.x + air_size, marine_cp.y) end
|
||||
devonshire_cp: EV_COORDINATE do create Result.make (thirteenth_af_cp.x + air_size + gap_size, south_dakota_cp.y) end
|
||||
shropshire_cp: EV_COORDINATE do create Result.make (devonshire_cp.x + ship_size, south_dakota_cp.y) end
|
||||
first_027_removal_cp: EV_COORDINATE do create Result.make (shropshire_cp.x + ship_size + gap_size, south_dakota_cp.y) end
|
||||
second_027_removal_cp: EV_COORDINATE do create Result.make (first_027_removal_cp.x + ship_size, south_dakota_cp.y) end
|
||||
-- Turn 5
|
||||
massachusetts_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, turn_5_cp.y + 12) end
|
||||
wichita_cp: EV_COORDINATE do create Result.make (massachusetts_cp.x + ship_size, massachusetts_cp.y) end
|
||||
victorious_cp: EV_COORDINATE do create Result.make (wichita_cp.x + ship_size, massachusetts_cp.y) end
|
||||
marines_3_cp: EV_COORDINATE do create Result.make (victorious_cp.x + ship_size, massachusetts_cp.y + ship_size - air_size) end
|
||||
fourteenth_af_cp: EV_COORDINATE do create Result.make (marines_3_cp.x + air_size + gap_size, marines_3_cp.y) end
|
||||
naval_cp: EV_COORDINATE do create Result.make (fourteenth_af_cp.x + air_size, fourteenth_af_cp.y) end
|
||||
resolution_removal_cp: EV_COORDINATE do create Result.make (naval_cp.x + air_size + 2 * gap_size, massachusetts_cp.y) end
|
||||
revenge_removal_cp: EV_COORDINATE do create Result.make (resolution_removal_cp.x + ship_size, massachusetts_cp.y) end
|
||||
valiant_removal_cp: EV_COORDINATE do create Result.make (revenge_removal_cp.x + ship_size, massachusetts_cp.y) end
|
||||
warspite_removal_cp: EV_COORDINATE do create Result.make (valiant_removal_cp.x + ship_size, massachusetts_cp.y) end
|
||||
-- Turn 6
|
||||
alabama_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, turn_6_cp.y + 12) end
|
||||
essex_cp: EV_COORDINATE do create Result.make (alabama_cp.x + ship_size, alabama_cp.y) end
|
||||
cv_10_cp: EV_COORDINATE do create Result.make (essex_cp.x + ship_size, alabama_cp.y) end
|
||||
cv_16_cp: EV_COORDINATE do create Result.make (cv_10_cp.x + ship_size, alabama_cp.y) end
|
||||
independence_cp: EV_COORDINATE do create Result.make (cv_16_cp.x + ship_size, alabama_cp.y) end
|
||||
princeton_cp: EV_COORDINATE do create Result.make (independence_cp.x + ship_size, alabama_cp.y) end
|
||||
belleau_wood_cp: EV_COORDINATE do create Result.make (princeton_cp.x + ship_size, alabama_cp.y) end
|
||||
cowpens_cp: EV_COORDINATE do create Result.make (belleau_wood_cp.x + ship_size, alabama_cp.y) end
|
||||
monterey_cp: EV_COORDINATE do create Result.make (cowpens_cp.x + ship_size, alabama_cp.y) end
|
||||
baltimore_cp: EV_COORDINATE do create Result.make (monterey_cp.x + ship_size, alabama_cp.y) end
|
||||
boston_cp: EV_COORDINATE do create Result.make (baltimore_cp.x + ship_size, alabama_cp.y) end
|
||||
marines_4_cp: EV_COORDINATE do create Result.make (boston_cp.x + ship_size, alabama_cp.y + ship_size - air_size) end
|
||||
victorious_removal_cp: EV_COORDINATE do create Result.make (alabama_cp.x, turn_6_cp.y + 39) end
|
||||
-- Turn 7
|
||||
iowa_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, turn_7_cp.y + 12) end
|
||||
new_jersey_cp: EV_COORDINATE do create Result.make (iowa_cp.x + ship_size, iowa_cp.y) end
|
||||
intrepid_cp: EV_COORDINATE do create Result.make (new_jersey_cp.x + ship_size, iowa_cp.y) end
|
||||
cv_12_cp: EV_COORDINATE do create Result.make (intrepid_cp.x + ship_size, iowa_cp.y) end
|
||||
bunker_hill_cp: EV_COORDINATE do create Result.make (cv_12_cp.x + ship_size, iowa_cp.y) end
|
||||
cv_18_cp: EV_COORDINATE do create Result.make (bunker_hill_cp.x + ship_size, iowa_cp.y) end
|
||||
bataan_cp: EV_COORDINATE do create Result.make (cv_18_cp.x + ship_size, iowa_cp.y) end
|
||||
cabot_cp: EV_COORDINATE do create Result.make (bataan_cp.x + ship_size, iowa_cp.y) end
|
||||
langley_ii_cp: EV_COORDINATE do create Result.make (cabot_cp.x + ship_size, iowa_cp.y) end
|
||||
canberra_ii_cp: EV_COORDINATE do create Result.make (langley_ii_cp.x + ship_size, iowa_cp.y) end
|
||||
quincy_ii_cp: EV_COORDINATE do create Result.make (canberra_ii_cp.x + ship_size, iowa_cp.y) end
|
||||
f_boat_cp: EV_COORDINATE do create Result.make (quincy_ii_cp.x + ship_size + 4 * gap_size, iowa_cp.y) end
|
||||
third_027_removal_cp: EV_COORDINATE do create Result.make (iowa_cp.x, iowa_cp.y + ship_size + 3 * gap_size) end
|
||||
first_443_removal_cp: EV_COORDINATE do create Result.make (third_027_removal_cp.x + ship_size, third_027_removal_cp.y) end
|
||||
-- Turn 8
|
||||
wisconsin_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, turn_8_cp.y + 12) end
|
||||
missouri_cp: EV_COORDINATE do create Result.make (wisconsin_cp.x + ship_size, wisconsin_cp.y) end
|
||||
ticonderoga_cp: EV_COORDINATE do create Result.make (missouri_cp.x + ship_size, wisconsin_cp.y) end
|
||||
san_jacinto_cp: EV_COORDINATE do create Result.make (ticonderoga_cp.x + ship_size, wisconsin_cp.y) end
|
||||
marines_5_cp: EV_COORDINATE do create Result.make (san_jacinto_cp.x + ship_size, wisconsin_cp.y + ship_size - air_size) end
|
||||
-- Turn_9
|
||||
new_york_cp: EV_COORDINATE do create Result.make (turn_2_cp.x, turn_9_cp.y + 12) end
|
||||
texas_cp: EV_COORDINATE do create Result.make (new_york_cp.x + ship_size, new_york_cp.y) end
|
||||
alaska_cp: EV_COORDINATE do create Result.make (texas_cp.x + ship_size, new_york_cp.y) end
|
||||
franklin_cp: EV_COORDINATE do create Result.make (alaska_cp.x + ship_size, new_york_cp.y) end
|
||||
shangri_la_cp: EV_COORDINATE do create Result.make (franklin_cp.x + ship_size, new_york_cp.y) end
|
||||
|
||||
end
|
473
jj_vitp/Interface/views/allied_starting_forces_view.e
Normal file
473
jj_vitp/Interface/views/allied_starting_forces_view.e
Normal file
@@ -0,0 +1,473 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} that displays the Allied units that enter
|
||||
the {VITP_GAME} on turn 1.
|
||||
]"
|
||||
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
|
||||
ALLIED_STARTING_FORCES_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
ORDER_OF_APPEARANCE_VIEW
|
||||
redefine
|
||||
initialize,
|
||||
widget_factory,
|
||||
add_return_boxes,
|
||||
add_widgets,
|
||||
add_units,
|
||||
add_starting_control_widgets,
|
||||
add_miscellaneous_text,
|
||||
add_copyright_text
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Set up attributes
|
||||
do
|
||||
nationality := {NATIONALITY_CONSTANTS}.allied
|
||||
Precursor
|
||||
end
|
||||
|
||||
add_turns
|
||||
-- Add the "TURN X" and "TO date" texts
|
||||
local
|
||||
i: INTEGER
|
||||
do
|
||||
from i := 1
|
||||
until i > 1
|
||||
loop
|
||||
add_turn_text (i)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
add_return_boxes
|
||||
-- Add the "Returning Air/Land Units" boxes
|
||||
-- Redefined to do nothing
|
||||
do
|
||||
end
|
||||
|
||||
add_widgets
|
||||
-- Create the EV_TEXT objects for the chart
|
||||
do
|
||||
Precursor
|
||||
end
|
||||
|
||||
add_units
|
||||
-- Add {ATTACK_UNIT_WIDGETS} to Current
|
||||
local
|
||||
f: like widget_factory
|
||||
do
|
||||
Precursor
|
||||
f := widget_factory
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
add_model (positioned_widget (f.nevada_widget, nevada_cp))
|
||||
add_model (positioned_widget (f.arizona_widget, arizona_cp))
|
||||
add_model (positioned_widget (f.west_virginia_widget, west_virginia_cp))
|
||||
add_model (positioned_widget (f.tennessee_widget, tennessee_cp))
|
||||
add_model (positioned_widget (f.oklahoma_widget, oklahoma_cp))
|
||||
add_model (positioned_widget (f.maryland_widget, maryland_cp))
|
||||
add_model (positioned_widget (f.california_widget, california_cp))
|
||||
add_model (positioned_widget (f.pennsylvania_widget, pennsylvania_cp))
|
||||
add_model (positioned_widget (f.new_orleans_widget, new_orleans_cp))
|
||||
add_model (positioned_widget (f.san_francisco_widget, san_francisco_cp))
|
||||
add_model (positioned_widget (f.seventh_af_widget, seventh_af_cp))
|
||||
-- At Sea (cannot move)
|
||||
add_model (positioned_widget (f.hermes_widget, hermes_cp))
|
||||
add_model (positioned_widget (f.revenge_widget, revenge_cp))
|
||||
add_model (positioned_widget (f.prince_of_wales_widget, prince_of_wales_cp))
|
||||
add_model (positioned_widget (f.repulse_widget, repulse_cp))
|
||||
add_model (positioned_widget (f.fifth_af_widget, fifth_af_cp))
|
||||
add_model (positioned_widget (f.louisville_widget, louisville_cp))
|
||||
add_model (positioned_widget (f.pensacola_widget, pensacola_cp))
|
||||
add_model (positioned_widget (f.indianapolis_widget, indianapolis_cp))
|
||||
add_model (positioned_widget (f.minneapolis_widget, minneapolis_cp))
|
||||
-- In Port (may move)
|
||||
add_model (positioned_widget (f.houston_widget, houston_cp))
|
||||
add_model (positioned_widget (f.exeter_widget, exeter_cp))
|
||||
add_model (positioned_widget (f.de_ruyter_widget, de_ruyter_cp))
|
||||
add_model (positioned_widget (f.australia_ship_widget, australia_cp))
|
||||
add_model (positioned_widget (f.canberra_widget, canberra_cp))
|
||||
-- Group W
|
||||
add_model (positioned_widget (f.enterprise_widget, enterprise_cp))
|
||||
add_model (positioned_widget (f.salt_lake_city_widget, salt_lake_city_cp))
|
||||
add_model (positioned_widget (f.northampton_widget, northampton_cp))
|
||||
add_model (positioned_widget (f.chester_widget, chester_cp))
|
||||
-- Group X
|
||||
add_model (positioned_widget (f.lexington_widget, lexington_cp))
|
||||
add_model (positioned_widget (f.chicago_widget, chicago_cp))
|
||||
add_model (positioned_widget (f.portland_widget, portland_cp))
|
||||
add_model (positioned_widget (f.astoria_widget, astoria_cp))
|
||||
-- Group Y
|
||||
add_model (positioned_widget (f.saratoga_widget, saratoga_cp))
|
||||
-- Group Z
|
||||
add_model (positioned_widget (f.hornet_widget, hornet_cp))
|
||||
add_model (positioned_widget (f.yorktown_widget, yorktown_cp))
|
||||
add_model (positioned_widget (f.vincennes_widget, vincennes_cp))
|
||||
add_model (positioned_widget (f.quincy_widget, quincy_cp))
|
||||
end
|
||||
|
||||
add_starting_control_widgets
|
||||
-- Add the "Starting Control" text and markers if required
|
||||
local
|
||||
cp:EV_COORDINATE
|
||||
t: EV_MODEL_TEXT
|
||||
s: STRING
|
||||
b: EV_MODEL_GROUP
|
||||
do
|
||||
Precursor
|
||||
create cp
|
||||
-- Add "Starting Control" widgets
|
||||
s := "STARTING %N CONTROL"
|
||||
t := new_text (s, turn_x_losses_font)
|
||||
cp.set (seventh_af_cp.x + 3 * air_size + air_size // 2, san_francisco_cp.y - ship_size // 3)
|
||||
t.set_x_y (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Position the `flag' marker
|
||||
cp.set (t.x, san_francisco_cp.y + air_size // 3)
|
||||
flag.set_x_y (cp.x, cp.y)
|
||||
-- Add boxes around the port names
|
||||
s := "Hawaian Islands %N%
|
||||
%U.S. Mandate %N%
|
||||
%Coral Sea %N%
|
||||
%South Pacific %N%
|
||||
%Central Pacific %N%
|
||||
%Indian Ocian %N%
|
||||
%Bay of Bengal %N%
|
||||
%Indonesia"
|
||||
b := new_jagged_box (s, 9, 9, 9, {MATH_CONST}.pi_2)
|
||||
b.set_x_y (flag.x, flag.y + air_size + 5 * gap_size)
|
||||
world.extend (b)
|
||||
-- Position `big_marker' and `little_marker' relative to `flag'
|
||||
big_marker.set_x_y (flag.x, chester_cp.y - ship_size // 4)
|
||||
little_marker.set_x_y (flag.x - air_size - air_size // 2, quincy_cp.y + air_size + air_size // 4)
|
||||
-- Add boxes around the port names
|
||||
s := "Pearl Harbor %N%
|
||||
%Samoa %N%
|
||||
%Australia %N%
|
||||
%Ceylon %N%
|
||||
%Singapore"
|
||||
b := new_jagged_box (s, 6, 9, 6, {MATH_CONST}.pi_2)
|
||||
b.set_x_y (flag.x, big_marker.y + ship_size - air_size // 3 )
|
||||
world.extend (b)
|
||||
-- Add boxes around the port names
|
||||
s := "%N%
|
||||
%Johnston Island %N%
|
||||
%Dutch Harbor %N%
|
||||
%Attu %N%
|
||||
%New Hebrides %N%
|
||||
%Guadalcanal %N%
|
||||
%Port Moreby %N%
|
||||
%Lae %N%
|
||||
%Midway %N%
|
||||
%Andaman Islands %N%
|
||||
%Phillipines"
|
||||
b := new_jagged_box (s, 9, 11, 9, 0)
|
||||
b.set_x_y (flag.x, little_marker.y)
|
||||
world.extend (b)
|
||||
end
|
||||
|
||||
add_miscellaneous_text
|
||||
-- Create the remaining EV_TEXT objects for the chart
|
||||
local
|
||||
cp: EV_COORDINATE
|
||||
t: EV_MODEL_TEXT
|
||||
s: STRING
|
||||
do
|
||||
create cp
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
s := "ON BATTLESHIP ROW (PEARL HARBOR)"
|
||||
t := new_text (s, at_port_font)
|
||||
cp.set (west_virginia_cp.x, west_virginia_cp.y - air_size // 2)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- At Sea (cannot move)
|
||||
s := "AT SEA (CANNOT MOVE)"
|
||||
t := new_text (s, at_port_font)
|
||||
cp.set (hermes_cp.x, hermes_cp.y - air_size // 2)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Bay of Bengal
|
||||
s := "BAY OF BENGAL"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (hermes_cp.x, hermes_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Indonesia
|
||||
s := "INDONESIA"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (prince_of_wales_cp.x, hermes_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Coral Sea
|
||||
s := "CORAL SEA"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (louisville_cp.x, hermes_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- US Mandate
|
||||
s := "US MANDATE"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (pensacola_cp.x, hermes_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Hawaiian Islands
|
||||
s := "HAWAIIAN ISLANDS"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (indianapolis_cp.x, hermes_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- In Port (may move)
|
||||
s := "IN PORT (MAY MOVE)"
|
||||
t := new_text (s, at_port_font)
|
||||
cp.set (houston_cp.x, houston_cp.y - air_size // 2)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Philippines
|
||||
s := "PHILIPPINES"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (houston_cp.x, houston_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Singapore
|
||||
s := "SINGAPORE"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (exeter_cp.x, houston_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Australia
|
||||
s := "AUSTRALIA"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (australia_cp.x, houston_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Location Uncertain
|
||||
s := "LOCATION UNCERTAIN"
|
||||
t := new_text (s, at_port_font)
|
||||
cp.set (enterprise_cp.x, houston_cp.y - air_size // 2)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Group W
|
||||
s := "GROUP W"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (enterprise_cp.x, houston_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Location Uncertain
|
||||
s := "LOCATION UNCERTAIN"
|
||||
t := new_text (s, at_port_font)
|
||||
cp.set (lexington_cp.x, lexington_cp.y - air_size // 2)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Group X
|
||||
s := "GROUP X"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (lexington_cp.x, lexington_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Group Y
|
||||
s := "GROUP Y"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (saratoga_cp.x, lexington_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- Group Z
|
||||
s := "GROUP Z"
|
||||
t := new_text (s, to_date_font)
|
||||
cp.set (hornet_cp.x, lexington_cp.y - air_size // 4)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
-- 1 = Central Pacific...
|
||||
s := "1 = Central Pcific; 2,3 = Hawaiian Islands; 4-6 = U.S.A. -- arrival Turn 2"
|
||||
t := new_text (s, small_font)
|
||||
cp.set (astoria_cp.x + ship_size // 4, astoria_cp.y - air_size // 2)
|
||||
t.set_point_position (cp.x, cp.y)
|
||||
world.extend (t)
|
||||
end
|
||||
|
||||
add_copyright_text
|
||||
-- Add the copy-right notices to each chart
|
||||
local
|
||||
rec: EV_MODEL_RECTANGLE
|
||||
w, h: INTEGER
|
||||
m: INTEGER -- text margin in box
|
||||
cp: EV_COORDINATE
|
||||
t1, t2: EV_MODEL_TEXT
|
||||
s: STRING
|
||||
f: EV_FONT
|
||||
do
|
||||
create cp
|
||||
w := 5 * ship_size + air_size
|
||||
h := 2 * air_size
|
||||
m := gap_size
|
||||
-- Make the box
|
||||
cp.set (bottom_right_cp.x - w, bottom_right_cp.y + ship_size)
|
||||
create rec.make_rectangle (cp.x, cp.y, w, h)
|
||||
rec.set_foreground_color (color)
|
||||
-- rec.set_background_color (lightened (color, 2.8))
|
||||
world.extend (rec)
|
||||
-- Design Department
|
||||
s := "DESIGN DEPARTMENT"
|
||||
f := small_font
|
||||
f.set_weight ({EV_FONT_CONSTANTS}.weight_bold)
|
||||
t1 := new_text (s, f)
|
||||
cp.set (rec.x , rec.point_a.y + 3 * m)
|
||||
t1.set_x_y (cp.x, cp.y)
|
||||
world.extend (t1)
|
||||
|
||||
-- The left half of the text
|
||||
f.set_family ({EV_FONT_CONSTANTS}.family_modern)
|
||||
f.set_weight ({EV_FONT_CONSTANTS}.weight_thin)
|
||||
s := "%T We will answer questions about the play of this %N%
|
||||
%game at no charge but only if you enclose a %N%
|
||||
%stamped, self-addressed envelope with your query. %N%
|
||||
%Before writing to us however, we suggest %N%
|
||||
%thoughtful reference to the rules which should"
|
||||
t1 := new_text (s, f)
|
||||
cp.set (rec.point_a.x + m, rec.point_a.y + 5 * m)
|
||||
t1.set_point_position (cp.x, cp.y)
|
||||
world.extend (t1)
|
||||
-- The right half of the text
|
||||
s := "answer any question and save you time and %N%
|
||||
%postage. For a current replacment parts price %N%
|
||||
%list send a stamped, self-addressed envelope to %N%
|
||||
%The Avalon Hill Co., 4517 Harford Rd. Balti- %N%
|
||||
%more MD 21214"
|
||||
t2 := new_text (s, f)
|
||||
cp.set (rec.point_b.x - m - t2.width, t1.point_y)
|
||||
t2.set_point_position (cp.x, cp.y)
|
||||
world.extend (t2)
|
||||
-- The company name
|
||||
s := " The %N%
|
||||
%AVALON HILL %N%
|
||||
%Game Company"
|
||||
t2 := new_text (s, company_name_font)
|
||||
cp.set (0, bottom_right_cp.y + ship_size // 2)
|
||||
t2.set_point_position (cp.x, cp.y)
|
||||
world.extend (t2)
|
||||
-- The company address
|
||||
s := "4517 Harford Road, Baltimore, MD 21214"
|
||||
f.set_family ({EV_FONT_CONSTANTS}.family_modern)
|
||||
f.set_weight ({EV_FONT_CONSTANTS}.weight_bold)
|
||||
f.set_height (4)
|
||||
t2 := new_text (s, f)
|
||||
cp.set (top_left_cp.x + gap_size, bottom_right_cp.y + 3 * air_size)
|
||||
t2.set_point_position (cp.x, cp.y)
|
||||
world.extend (t2)
|
||||
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.allied_starting_forces_chart
|
||||
end
|
||||
|
||||
title: STRING = "Allied Starting Forces"
|
||||
-- The text at the top of this chart
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
widget_factory: ALLIED_FORCES_WIDGET_FACTORY
|
||||
-- Hold all the widgets
|
||||
|
||||
company_name_font: EV_FONT
|
||||
-- Large, bold, and italic
|
||||
once
|
||||
create Result
|
||||
Result.set_height (11)
|
||||
Result.set_shape ({EV_FONT_CONSTANTS}.shape_italic)
|
||||
Result.set_weight ({EV_FONT_CONSTANTS}.weight_bold)
|
||||
Result.set_family ({EV_FONT_CONSTANTS}.family_roman)
|
||||
end
|
||||
|
||||
feature {NONE} -- Control point constants
|
||||
|
||||
bottom_right_cp: EV_COORDINATE once create Result.make (254, 150) end
|
||||
-- Turn X text (not used)
|
||||
turn_1_cp: EV_COORDINATE do create Result.make (7, 14) end
|
||||
turn_2_cp: EV_COORDINATE do create Result end
|
||||
turn_3_cp: EV_COORDINATE do create Result end
|
||||
turn_4_cp: EV_COORDINATE do create Result end
|
||||
turn_5_cp: EV_COORDINATE do create Result end
|
||||
turn_6_cp: EV_COORDINATE do create Result end
|
||||
turn_7_cp: EV_COORDINATE do create Result end
|
||||
turn_8_cp: EV_COORDINATE do create Result end
|
||||
turn_9_cp: EV_COORDINATE do create Result end
|
||||
-- To some date text (not used)
|
||||
to_dec_41_cp: EV_COORDINATE do create Result end
|
||||
to_may_42_cp: EV_COORDINATE do create Result end
|
||||
to_sep_42_cp: EV_COORDINATE do create Result end
|
||||
to_jan_43_cp: EV_COORDINATE do create Result end
|
||||
to_jun_43_cp: EV_COORDINATE do create Result end
|
||||
to_jan_44_cp: EV_COORDINATE do create Result end
|
||||
to_may_44_cp: EV_COORDINATE do create Result end
|
||||
to_oct_44_cp: EV_COORDINATE do create Result end
|
||||
to_jan_45_cp: EV_COORDINATE do create Result end
|
||||
-- Turn x losses (not used)
|
||||
turn_1_losses_cp: EV_COORDINATE do create Result end
|
||||
turn_2_losses_cp: EV_COORDINATE do create Result end
|
||||
turn_3_losses_cp: EV_COORDINATE do create Result end
|
||||
turn_4_losses_cp: EV_COORDINATE do create Result end
|
||||
turn_5_losses_cp: EV_COORDINATE do create Result end
|
||||
turn_6_losses_cp: EV_COORDINATE do create Result end
|
||||
turn_7_losses_cp: EV_COORDINATE do create Result end
|
||||
|
||||
-- On Battleship Row
|
||||
nevada_cp: EV_COORDINATE do create Result.make (Turn_1_cp.x, Turn_1_cp.y + 12) end
|
||||
arizona_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 1 * ship_size, nevada_cp.y) end
|
||||
west_virginia_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 2 * ship_size, nevada_cp.y) end
|
||||
tennessee_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 3 * ship_size, nevada_cp.y) end
|
||||
oklahoma_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 4 * ship_size, nevada_cp.y) end
|
||||
maryland_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 5 * ship_size, nevada_cp.y) end
|
||||
california_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 6 * ship_size, nevada_cp.y) end
|
||||
pennsylvania_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 7 * ship_size, nevada_cp.y) end
|
||||
new_orleans_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 8 * ship_size, nevada_cp.y) end
|
||||
san_francisco_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 8 * ship_size, nevada_cp.y) end
|
||||
seventh_af_cp: EV_COORDINATE do create Result.make (nevada_cp.x + 9 * ship_size, nevada_cp.y + ship_size - air_size) end
|
||||
-- At Sea (cannot move)
|
||||
hermes_cp: EV_COORDINATE do create Result.make (turn_1_cp.x, nevada_cp.y + ship_size + 5 * gap_size) end
|
||||
revenge_cp: EV_COORDINATE do create Result.make (nevada_cp.x + ship_size, hermes_cp.y) end
|
||||
prince_of_wales_cp: EV_COORDINATE do create Result.make (revenge_cp.x + ship_size + 4 * gap_size, hermes_cp.y) end
|
||||
repulse_cp: EV_COORDINATE do create Result.make (prince_of_wales_cp.x + ship_size, hermes_cp.y) end
|
||||
fifth_af_cp: EV_COORDINATE do create Result.make (repulse_cp.x + ship_size, hermes_cp.y + ship_size - air_size) end
|
||||
louisville_cp: EV_COORDINATE do create Result.make (fifth_af_cp.x + air_size + 4 * gap_size, hermes_cp.y) end
|
||||
pensacola_cp: EV_COORDINATE do create Result.make (louisville_cp.x + ship_size + 4 * gap_size, hermes_cp.y) end
|
||||
indianapolis_cp: EV_COORDINATE do create Result.make (pensacola_cp.x + ship_size + 4 * gap_size, hermes_cp.y) end
|
||||
minneapolis_cp: EV_COORDINATE do create Result.make (indianapolis_cp.x + ship_size, hermes_cp.y) end
|
||||
-- In Port (may move)
|
||||
houston_cp: EV_COORDINATE do create Result.make (turn_1_cp.x, hermes_cp.y + ship_size + 5 * gap_size) end
|
||||
exeter_cp: EV_COORDINATE do create Result.make (houston_cp.x + ship_size + 4 * gap_size, houston_cp.y) end
|
||||
de_ruyter_cp: EV_COORDINATE do create Result.make (exeter_cp.x + ship_size, houston_cp.y) end
|
||||
australia_cp: EV_COORDINATE do create Result.make (de_ruyter_cp.x + ship_size + 4 * gap_size, houston_cp.y) end
|
||||
canberra_cp: EV_COORDINATE do create Result.make (australia_cp.x + ship_size, houston_cp.y) end
|
||||
-- Group W
|
||||
enterprise_cp: EV_COORDINATE do create Result.make (louisville_cp.x + ship_size, houston_cp.y) end
|
||||
salt_lake_city_cp: EV_COORDINATE do create Result.make (enterprise_cp.x + ship_size, houston_cp.y) end
|
||||
northampton_cp: EV_COORDINATE do create Result.make (salt_lake_city_cp.x + ship_size, houston_cp.y) end
|
||||
chester_cp: EV_COORDINATE do create Result.make (northampton_cp.x + ship_size, houston_cp.y) end
|
||||
-- Group X
|
||||
lexington_cp: EV_COORDINATE do create Result.make (turn_1_cp.x, houston_cp.y + ship_size + 5 * gap_size) end
|
||||
chicago_cp: EV_COORDINATE do create Result.make (lexington_cp.x + ship_size, lexington_cp.y) end
|
||||
portland_cp: EV_COORDINATE do create Result.make (chicago_cp.x + ship_size, lexington_cp.y) end
|
||||
astoria_cp: EV_COORDINATE do create Result.make (portland_cp.x + ship_size, lexington_cp.y) end
|
||||
-- Group Y
|
||||
saratoga_cp: EV_COORDINATE do create Result.make (astoria_cp.x + ship_size + 4 * gap_size, lexington_cp.y) end
|
||||
-- Group Z
|
||||
hornet_cp: EV_COORDINATE do create Result.make (saratoga_cp.x + ship_size + 4 * gap_size, lexington_cp.y) end
|
||||
yorktown_cp: EV_COORDINATE do create Result.make (hornet_cp.x + ship_size, lexington_cp.y) end
|
||||
vincennes_cp: EV_COORDINATE do create Result.make (yorktown_cp.x + ship_size, lexington_cp.y) end
|
||||
quincy_cp: EV_COORDINATE do create Result.make (vincennes_cp.x + ship_size, lexington_cp.y) end
|
||||
|
||||
end
|
290
jj_vitp/Interface/views/allied_starting_forces_world.e
Normal file
290
jj_vitp/Interface/views/allied_starting_forces_world.e
Normal file
@@ -0,0 +1,290 @@
|
||||
note
|
||||
description: "[
|
||||
One of the classes that decomposes the numourous VITP widgets
|
||||
into more managable groups. This class models the widgets
|
||||
that contain the Allied starting-forces units (i.e. the
|
||||
Allied units that appear on turn 1).
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/15/24"
|
||||
copyright: "Copyright (c) 2024, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
class
|
||||
ALLIED_STARTING_FORCES_WORLD
|
||||
|
||||
inherit
|
||||
|
||||
WIDGET_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
create {ALLIED_STARTING_FORCES_WORLD}
|
||||
list_make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_widgets
|
||||
-- Create widgets for the corresponding game item
|
||||
do
|
||||
-- Turn 1, on battleship row (Pearl Harbor)
|
||||
create nevada_widget.make (game.nevada)
|
||||
create arizona_widget.make (game.arizona)
|
||||
create west_virginia_widget.make (game.west_virginia)
|
||||
create tennessee_widget.make (game.tennessee)
|
||||
create oklahoma_widget.make (game.oklahoma)
|
||||
create maryland_widget.make (game.maryland)
|
||||
create california_widget.make (game.california)
|
||||
create pennsylvania_widget.make (game.pennsylvania)
|
||||
create new_orleans_widget.make (game.new_orleans)
|
||||
create san_francisco_widget.make (game.san_francisco)
|
||||
create seventh_af_widget.make (game.seventh_af)
|
||||
-- Turn 1, at sea (cannot move)
|
||||
create hermes_widget.make (game.hermes)
|
||||
create revenge_widget.make (game.revenge)
|
||||
create prince_of_wales_widget.make (game.prince_of_wales)
|
||||
create repulse_widget.make (game.repulse)
|
||||
create fifth_af_widget.make (game.fifth_af)
|
||||
create louisville_widget.make (game.louisville)
|
||||
create pensacola_widget.make (game.pensacola)
|
||||
create indianapolis_widget.make (game.indianapolis)
|
||||
create minneapolis_widget.make (game.minneapolis)
|
||||
-- Turn 1, in port (may move)
|
||||
create houston_widget.make (game.houston)
|
||||
create exeter_widget.make (game.exeter)
|
||||
create de_ruyter_widget.make (game.de_ruyter)
|
||||
create australia_ship_widget.make (game.australia_ship)
|
||||
create canberra_widget.make (game.canberra)
|
||||
-- Turn 1, Location uncertain (group W)
|
||||
create enterprise_widget.make (game.enterprise)
|
||||
create salt_lake_city_widget.make (game.salt_lake_city)
|
||||
create northampton_widget.make (game.northampton)
|
||||
create chester_widget.make (game.chester)
|
||||
-- Turn 1, Location uncertain (group X)
|
||||
create lexington_widget.make (game.lexington)
|
||||
create chicago_widget.make (game.chicago)
|
||||
create portland_widget.make (game.portland)
|
||||
create astoria_widget.make (game.astoria)
|
||||
-- Turn 1, Location uncertain (group Y)
|
||||
create saratoga_widget.make (game.saratoga)
|
||||
-- Turn 1, Location uncertain (group Z)
|
||||
create hornet_widget.make (game.hornet)
|
||||
create yorktown_widget.make (game.yorktown)
|
||||
create vincennes_widget.make (game.vincennes)
|
||||
create quincy_widget.make (game.quincy)
|
||||
end
|
||||
|
||||
feature -- Access (tables)
|
||||
|
||||
widgets: VITP_WIDGET_TABLE [ATTACK_UNIT_WIDGET, ATTACK_UNIT]
|
||||
-- Keeps track of widgets
|
||||
|
||||
feature -- Access (allied starting forces widgets)
|
||||
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
nevada_widget: SHIP_WIDGET
|
||||
arizona_widget: SHIP_WIDGET
|
||||
west_virginia_widget: SHIP_WIDGET
|
||||
tennessee_widget: SHIP_WIDGET
|
||||
oklahoma_widget: SHIP_WIDGET
|
||||
maryland_widget: SHIP_WIDGET
|
||||
california_widget: SHIP_WIDGET
|
||||
pennsylvania_widget: SHIP_WIDGET
|
||||
new_orleans_widget: SHIP_WIDGET
|
||||
san_francisco_widget: SHIP_WIDGET
|
||||
seventh_af_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
-- At sea (cannot move)
|
||||
hermes_widget: SHIP_WIDGET
|
||||
revenge_widget: SHIP_WIDGET
|
||||
prince_of_wales_widget: SHIP_WIDGET
|
||||
repulse_widget: SHIP_WIDGET
|
||||
fifth_af_widget: ALLIED_AIR_UNIT_WIDGET
|
||||
louisville_widget: SHIP_WIDGET
|
||||
pensacola_widget: SHIP_WIDGET
|
||||
indianapolis_widget: SHIP_WIDGET
|
||||
minneapolis_widget: SHIP_WIDGET
|
||||
-- In port (may move)
|
||||
houston_widget: SHIP_WIDGET
|
||||
exeter_widget: SHIP_WIDGET
|
||||
de_ruyter_widget: SHIP_WIDGET
|
||||
australia_ship_widget: SHIP_WIDGET
|
||||
canberra_widget: SHIP_WIDGET
|
||||
-- Location Uncertain, group W
|
||||
enterprise_widget: SHIP_WIDGET
|
||||
salt_lake_city_widget: SHIP_WIDGET
|
||||
northampton_widget: SHIP_WIDGET
|
||||
chester_widget: SHIP_WIDGET
|
||||
-- Location Uncertain, group X
|
||||
lexington_widget: SHIP_WIDGET
|
||||
chicago_widget: SHIP_WIDGET
|
||||
portland_widget: SHIP_WIDGET
|
||||
astoria_widget: SHIP_WIDGET
|
||||
-- Location Uncertain, group Y
|
||||
saratoga_widget: SHIP_WIDGET
|
||||
-- Location Uncertain, group W
|
||||
hornet_widget: SHIP_WIDGET
|
||||
yorktown_widget: SHIP_WIDGET
|
||||
vincennes_widget: SHIP_WIDGET
|
||||
quincy_widget: SHIP_WIDGET
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
extend_widgets
|
||||
-- Put each widget {ATTACK_UNIT_WIDGET} into `world'.
|
||||
do
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
extend (nevada_widget)
|
||||
extend (arizona_widget)
|
||||
extend (west_virginia_widget)
|
||||
extend (tennessee_widget)
|
||||
extend (oklahoma_widget)
|
||||
extend (maryland_widget)
|
||||
extend (california_widget)
|
||||
extend (pennsylvania_widget)
|
||||
extend (new_orleans_widget)
|
||||
extend (san_francisco_widget)
|
||||
extend (seventh_af_widget)
|
||||
-- At sea (cannot move)
|
||||
extend (hermes_widget)
|
||||
extend (revenge_widget)
|
||||
extend (prince_of_wales_widget)
|
||||
extend (repulse_widget)
|
||||
extend (fifth_af_widget)
|
||||
extend (louisville_widget)
|
||||
extend (pensacola_widget)
|
||||
extend (indianapolis_widget)
|
||||
extend (minneapolis_widget)
|
||||
-- In port (may move)
|
||||
extend (houston_widget)
|
||||
extend (exeter_widget)
|
||||
extend (de_ruyter_widget)
|
||||
extend (australia_ship_widget)
|
||||
extend (canberra_widget)
|
||||
-- Location Uncertain, group W
|
||||
extend (enterprise_widget)
|
||||
extend (salt_lake_city_widget)
|
||||
extend (northampton_widget)
|
||||
extend (chester_widget)
|
||||
-- Location Uncertain, group X
|
||||
extend (lexington_widget)
|
||||
extend (chicago_widget)
|
||||
extend (portland_widget)
|
||||
extend (astoria_widget)
|
||||
-- Location Uncertain, group Y
|
||||
extend (saratoga_widget)
|
||||
-- Location Uncertain, group W
|
||||
extend (hornet_widget)
|
||||
extend (yorktown_widget)
|
||||
extend (vincennes_widget)
|
||||
extend (quincy_widget)
|
||||
end
|
||||
|
||||
pair_widgets
|
||||
-- Associate each widget with a unit
|
||||
do
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
widgets.force (nevada_widget, game.nevada)
|
||||
widgets.force (arizona_widget, game.arizona)
|
||||
widgets.force (west_virginia_widget, game.west_virginia)
|
||||
widgets.force (tennessee_widget, game.tennessee)
|
||||
widgets.force (oklahoma_widget, game.oklahoma)
|
||||
widgets.force (maryland_widget, game.maryland)
|
||||
widgets.force (california_widget, game.california)
|
||||
widgets.force (pennsylvania_widget, game.pennsylvania)
|
||||
widgets.force (new_orleans_widget, game.new_orleans)
|
||||
widgets.force (san_francisco_widget, game.san_francisco)
|
||||
widgets.force (seventh_af_widget, game.seventh_af)
|
||||
-- At sea (cannot move)
|
||||
widgets.force (hermes_widget, game.hermes)
|
||||
widgets.force (revenge_widget, game.revenge)
|
||||
widgets.force (prince_of_wales_widget, game.prince_of_wales)
|
||||
widgets.force (repulse_widget, game.repulse)
|
||||
widgets.force (fifth_af_widget, game.fifth_af)
|
||||
widgets.force (louisville_widget, game.louisville)
|
||||
widgets.force (pensacola_widget, game.pensacola)
|
||||
widgets.force (indianapolis_widget, game.indianapolis)
|
||||
widgets.force (minneapolis_widget, game.minneapolis)
|
||||
-- In port (may move)
|
||||
widgets.force (houston_widget, game.houston)
|
||||
widgets.force (exeter_widget, game.exeter)
|
||||
widgets.force (de_ruyter_widget, game.de_ruyter)
|
||||
widgets.force (australia_ship_widget, game.australia_ship)
|
||||
widgets.force (canberra_widget, game.canberra)
|
||||
-- Location Uncertain, group W
|
||||
widgets.force (enterprise_widget, game.enterprise)
|
||||
widgets.force (salt_lake_city_widget, game.salt_lake_city)
|
||||
widgets.force (northampton_widget, game.northampton)
|
||||
widgets.force (chester_widget, game.chester)
|
||||
-- Location Uncertain, group X
|
||||
widgets.force (lexington_widget, game.lexington)
|
||||
widgets.force (chicago_widget, game.chicago)
|
||||
widgets.force (portland_widget, game.portland)
|
||||
widgets.force (astoria_widget, game.astoria)
|
||||
-- Location Uncertain, group Y
|
||||
widgets.force (saratoga_widget, game.saratoga)
|
||||
-- Location Uncertain (group Z
|
||||
widgets.force (hornet_widget, game.hornet)
|
||||
widgets.force (yorktown_widget, game.yorktown)
|
||||
widgets.force (vincennes_widget, game.vincennes)
|
||||
widgets.force (quincy_widget, game.quincy)
|
||||
end
|
||||
|
||||
fill_widgets
|
||||
-- Call `set_target' to give each widget a target.
|
||||
do
|
||||
-- On Battleship Row (Pearl Harbor)
|
||||
nevada_widget.set_target (game.nevada)
|
||||
arizona_widget.set_target (game.arizona)
|
||||
west_virginia_widget.set_target (game.west_virginia)
|
||||
tennessee_widget.set_target (game.tennessee)
|
||||
oklahoma_widget.set_target (game.oklahoma)
|
||||
maryland_widget.set_target (game.maryland)
|
||||
california_widget.set_target (game.california)
|
||||
pennsylvania_widget.set_target (game.pennsylvania)
|
||||
new_orleans_widget.set_target (game.new_orleans)
|
||||
san_francisco_widget.set_target (game.san_francisco)
|
||||
seventh_af_widget.set_target (game.seventh_af)
|
||||
-- At sea (cannot move)
|
||||
hermes_widget.set_target (game.hermes)
|
||||
revenge_widget.set_target (game.revenge)
|
||||
prince_of_wales_widget.set_target (game.prince_of_wales)
|
||||
repulse_widget.set_target (game.repulse)
|
||||
fifth_af_widget.set_target (game.fifth_af)
|
||||
louisville_widget.set_target (game.louisville)
|
||||
pensacola_widget.set_target (game.pensacola)
|
||||
indianapolis_widget.set_target (game.indianapolis)
|
||||
minneapolis_widget.set_target (game.minneapolis)
|
||||
-- In port (may move)
|
||||
houston_widget.set_target (game.houston)
|
||||
exeter_widget.set_target (game.exeter)
|
||||
de_ruyter_widget.set_target (game.de_ruyter)
|
||||
australia_ship_widget.set_target (game.australia_ship)
|
||||
canberra_widget.set_target (game.canberra)
|
||||
-- Location Uncertain, group W
|
||||
enterprise_widget.set_target (game.enterprise)
|
||||
salt_lake_city_widget.set_target (game.salt_lake_city)
|
||||
northampton_widget.set_target (game.northampton)
|
||||
chester_widget.set_target (game.chester)
|
||||
-- Location Uncertain, group X
|
||||
lexington_widget.set_target (game.lexington)
|
||||
chicago_widget.set_target (game.chicago)
|
||||
portland_widget.set_target (game.portland)
|
||||
astoria_widget.set_target (game.astoria)
|
||||
-- Location Uncertain, group Y
|
||||
saratoga_widget.set_target (game.saratoga)
|
||||
-- Location Uncertain, group W
|
||||
hornet_widget.set_target (game.hornet)
|
||||
yorktown_widget.set_target (game.yorktown)
|
||||
vincennes_widget.set_target (game.vincennes)
|
||||
quincy_widget.set_target (game.quincy)
|
||||
end
|
||||
|
||||
end
|
81
jj_vitp/Interface/views/attack_widgets_factory.e
Normal file
81
jj_vitp/Interface/views/attack_widgets_factory.e
Normal file
@@ -0,0 +1,81 @@
|
||||
note
|
||||
description: "[
|
||||
One of the classes that decompose the numourous VITP widgets
|
||||
into more managable groups. This class models the widgets
|
||||
that contain the attack units.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/15/24"
|
||||
copyright: "Copyright (c) 2024, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
class
|
||||
ATTACK_WIDGETS_FACTORY
|
||||
|
||||
inherit
|
||||
|
||||
JAPANESE_FORCES_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
ALLIED_FORCES_WIDGET_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make_widgets
|
||||
-- Create the widgets in Current
|
||||
do
|
||||
print ("ATTACK_WIDGET_FACTORY.make_widgets %N")
|
||||
create attack_widgets.make (100)
|
||||
Precursor {JAPANESE_FORCES_FACTORY}
|
||||
print ("ATTACK_WIDGET_FACTORY.make_widgets after first Precuror call%N")
|
||||
Precursor {ALLIED_FORCES_WIDGET_FACTORY}
|
||||
print ("%T end ATTACK_WIDGET_FACTORY.make_widgets %N")
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
attack_widgets: VITP_WIDGET_TABLE [ATTACK_UNIT_WIDGET, ATTACK_UNIT]
|
||||
-- Keeps track of widgets
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
extend_widgets
|
||||
-- Put each widget into `world'.
|
||||
do
|
||||
-- The first two line `merge' into `widgets'
|
||||
Precursor {JAPANESE_FORCES_FACTORY}
|
||||
Precursor {ALLIED_FORCES_WIDGET_FACTORY}
|
||||
-- But also need to merge into `attack_widges'
|
||||
attack_widgets.merge (japanese_forces_widgets)
|
||||
attack_widgets.merge (allied_forces_widgets)
|
||||
end
|
||||
|
||||
pair_widgets
|
||||
-- Associate each widget with a unit
|
||||
do
|
||||
Precursor {JAPANESE_FORCES_FACTORY}
|
||||
Precursor {ALLIED_FORCES_WIDGET_FACTORY}
|
||||
end
|
||||
|
||||
fill_widgets
|
||||
-- Call `set_target' to give each widget a target.
|
||||
do
|
||||
Precursor {JAPANESE_FORCES_FACTORY}
|
||||
Precursor {ALLIED_FORCES_WIDGET_FACTORY}
|
||||
end
|
||||
|
||||
end
|
228
jj_vitp/Interface/views/board_tool.e
Normal file
228
jj_vitp/Interface/views/board_tool.e
Normal file
@@ -0,0 +1,228 @@
|
||||
note
|
||||
description: "[
|
||||
Used to hold a BOARD_VIEW in the VITP vitp.program.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
BOARD_TOOL
|
||||
|
||||
inherit
|
||||
|
||||
VITP_TOOL
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
build_tool_bar,
|
||||
add_actions,
|
||||
-- initialize_interface,
|
||||
-- set_actions,
|
||||
set_target,
|
||||
draw,
|
||||
set_button_states
|
||||
end
|
||||
|
||||
GAME_CONSTANTS
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation
|
||||
-- bridge pattern.
|
||||
do
|
||||
print ("BOARD_TOOL.create_interface_objects %N")
|
||||
Precursor {VITP_TOOL}
|
||||
print ("BOARD_TOOL.create_interface_objects before creating board_view %N")
|
||||
create board_view.make (vitp)
|
||||
print ("BOARD_TOOL.create_interface_objects after creating board_view %N")
|
||||
create repair_button
|
||||
create flip_raiders_button
|
||||
create commit_button
|
||||
create sop_button
|
||||
repair_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_tool_color_buffer))
|
||||
repair_button.set_tooltip ("Repair Units")
|
||||
flip_raiders_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_reset_diagram_color_buffer))
|
||||
flip_raiders_button.set_tooltip ("Flip Raiders")
|
||||
commit_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_client_link_buffer))
|
||||
commit_button.set_tooltip ("Commit and Advance")
|
||||
sop_button.set_text ("SOP Button fix me")
|
||||
print ("%T end BOARD_TOOL.create_interface_objects %N")
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Build the interface for this window
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
split_manager.extend (board_view)
|
||||
set_minimum_width (1000)
|
||||
end
|
||||
|
||||
build_tool_bar
|
||||
-- Set up the user tool bar for this tool
|
||||
local
|
||||
vs: EV_VERTICAL_SEPARATOR
|
||||
do
|
||||
Precursor
|
||||
-- tool_bar.extend (create {EV_VERTICAL_SEPARATOR})
|
||||
-- tool_bar.extend (repair_button)
|
||||
-- tool_bar.extend (flip_raiders_button)
|
||||
tool_bar.extend (sop_button)
|
||||
-- Separator between two buttons
|
||||
create vs
|
||||
tool_bar.extend (vs)
|
||||
tool_bar.disable_item_expand (vs)
|
||||
vs.set_minimum_width (20)
|
||||
-- Add button
|
||||
tool_bar.extend (commit_button)
|
||||
tool_bar.disable_item_expand (commit_button)
|
||||
create vs
|
||||
tool_bar.extend (vs)
|
||||
tool_bar.disable_item_expand (vs)
|
||||
vs.set_minimum_width (20)
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Associate actions with the buttons
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
commit_button.select_actions.extend (agent on_commit)
|
||||
sop_button.select_actions.extend (agent on_execute)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
board_view: BOARD_VIEW
|
||||
-- Handle to the view corresponding to the first view created by the
|
||||
-- `view_manager' in `initialize'.
|
||||
-- Convinience feature.
|
||||
|
||||
focused_view: VITP_CELL_VIEW
|
||||
-- The view that currently has the focus
|
||||
do
|
||||
Result := board_view
|
||||
-- if japanese_chart_view.has_focus then
|
||||
-- Result := japanese_chart_view
|
||||
-- else
|
||||
-- Result := board_view
|
||||
-- end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_game: like vitp)
|
||||
-- Change the value of `target' and add it to the `target_set' (the set
|
||||
-- of objects contained in this view. The old target is removed from
|
||||
-- the set.
|
||||
-- This feature can be used as a pattern if a descendant wants to give
|
||||
-- special treatment to a single target.
|
||||
do
|
||||
Precursor {VITP_TOOL} (a_game)
|
||||
board_view.set_target (a_game)
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Redraw the tool
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
-- board_view.draw
|
||||
set_button_states
|
||||
end
|
||||
|
||||
on_commit
|
||||
-- Action to be performed when the `commit_button' is pressed
|
||||
do
|
||||
-- vitp.advance
|
||||
-- board_view.on_advanced
|
||||
vitp.sequence_of_play.forth
|
||||
draw_views (vitp)
|
||||
end
|
||||
|
||||
on_execute
|
||||
-- Perform the any action associated with the current step
|
||||
-- in the sequence of play.
|
||||
local
|
||||
sop: VITP_SEQUENCE_OF_PLAY
|
||||
do
|
||||
sop := vitp.sequence_of_play
|
||||
sop.execute_step_actions
|
||||
draw_views (vitp)
|
||||
end
|
||||
|
||||
feature {NONE} -- implementation
|
||||
|
||||
set_button_states
|
||||
-- Enable or disable the buttons depending on the
|
||||
-- state of the view
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
set_added_buttons_states
|
||||
end
|
||||
|
||||
set_added_buttons_states
|
||||
-- Enable or disable the buttons that this tool
|
||||
-- added to the tool bar.
|
||||
local
|
||||
sop: VITP_SEQUENCE_OF_PLAY
|
||||
s: GAME_STEP
|
||||
c: FONT_AND_COLOR_CONSTANTS
|
||||
do
|
||||
if is_view_empty then
|
||||
repair_button.disable_sensitive
|
||||
flip_raiders_button.disable_sensitive
|
||||
commit_button.disable_sensitive
|
||||
else
|
||||
sop := vitp.sequence_of_play
|
||||
if not sop.is_off then
|
||||
sop_button.set_text (sop.full_name)
|
||||
create c
|
||||
if sop.is_japanese_player then
|
||||
sop_button.set_background_color (c.Japanese_unit_color)
|
||||
sop_button.set_foreground_color (c.black)
|
||||
elseif sop.is_allied_player then
|
||||
sop_button.set_background_color (c.us_unit_color)
|
||||
sop_button.set_foreground_color (c.white)
|
||||
end
|
||||
if sop.is_step_executable then
|
||||
sop_button.enable_sensitive
|
||||
else
|
||||
sop_button.disable_sensitive
|
||||
end
|
||||
if sop.is_step_completed then
|
||||
commit_button.enable_sensitive
|
||||
else
|
||||
commit_button.disable_sensitive
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
sop_button: EV_BUTTON
|
||||
-- Button showing the current game step in the Sequence
|
||||
-- of play. The background color corresponds to the active
|
||||
-- player (red for Japanese and blue for Allied). This
|
||||
-- button is active when the `vitp'.`sequence_of_play'
|
||||
-- indicates that automatic actions are executable.
|
||||
|
||||
repair_button: EV_TOOL_BAR_BUTTON
|
||||
-- Button to mark units for repair
|
||||
|
||||
flip_raiders_button: EV_TOOL_BAR_BUTTON
|
||||
-- Button to flip from patroller to raider or back
|
||||
|
||||
commit_button: EV_BUTTON --EV_TOOL_BAR_BUTTON
|
||||
-- Button for player to indicate he is finished with the step
|
||||
|
||||
end
|
652
jj_vitp/Interface/views/board_view.e
Normal file
652
jj_vitp/Interface/views/board_view.e
Normal file
@@ -0,0 +1,652 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} that corresponds to the game board in Victory
|
||||
In the Pacific (VITP). This view has widgets that hold
|
||||
and allow control of game actions (e.g. movement, attacks,
|
||||
repositions, etc) of game elements (e.g. ships, control
|
||||
markers, ports, etc.)
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
BOARD_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
VITP_CELL_VIEW
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
add_actions,
|
||||
set_target,
|
||||
draw,
|
||||
pick_notified_operations,
|
||||
pick_ended_operations
|
||||
end
|
||||
|
||||
FONT_AND_COLOR_CONSTANTS
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
POSITION_CONSTANTS
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
redefine
|
||||
playing_area_ratio
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
print ("BOARD_VIEW.create_interface_objects %N")
|
||||
Precursor {VITP_CELL_VIEW}
|
||||
print ("%T BOARD_VIEW.create_interface_objects before creating widget_factory %N")
|
||||
create widget_factory.make (game)
|
||||
print ("%T BOARD_VIEW.create_interface_objects after creatingh widget_factory %N")
|
||||
-- create dot
|
||||
-- create bounding_figure
|
||||
-- Create for Void safety
|
||||
-- create mouse_offset
|
||||
create last_mouse_position
|
||||
-- create containers
|
||||
create task_force_widgets.make (100)
|
||||
create highlighted_widgets.make
|
||||
-- create the corner points used to determine the scale factor
|
||||
create top_left_dot
|
||||
create bottom_right_dot
|
||||
-- create container for the grid cells (rows, columns)
|
||||
-- create cell_array.make (playing_area_height // cell_size,
|
||||
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Called after `Default_create'
|
||||
do
|
||||
Precursor {VITP_CELL_VIEW}
|
||||
-- world.extend (dragging_arrow)
|
||||
-- dragging_arrow.hide
|
||||
-- -- create the `handle'
|
||||
-- create handle
|
||||
-- world.extend (handle)
|
||||
build_border
|
||||
-- Attack widgets go on top of all other widgets except the dots
|
||||
-- build_corner_dots
|
||||
-- Place the dots from {POSITION_CONSTANTS} into Current
|
||||
-- The dots move based on scaling of the view, allowing
|
||||
-- cell positions to be determined regardless of the
|
||||
-- actual size of the view.
|
||||
add_widgets
|
||||
world.extend (top_left_dot)
|
||||
world.extend (bottom_right_dot)
|
||||
end
|
||||
|
||||
add_widgets
|
||||
-- Add the sea areas, ports, and unit widgets to the `world',
|
||||
-- hiding the unit widgets until needed
|
||||
local
|
||||
wf: like widget_factory
|
||||
t: like widget_factory.widgets
|
||||
w: VITP_WIDGET
|
||||
do
|
||||
wf := widget_factory
|
||||
-- Add sea areas first
|
||||
t := wf.sea_area_widgets
|
||||
from t.start
|
||||
until t.after
|
||||
loop
|
||||
-- world.extend (t.item_for_iteration)
|
||||
add_model (t.item_for_iteration)
|
||||
t.forth
|
||||
end
|
||||
-- Add ports
|
||||
t := wf.port_widgets
|
||||
from t.start
|
||||
until t.after
|
||||
loop
|
||||
-- world.extend (t.item_for_iteration)
|
||||
add_model (t.item_for_iteration)
|
||||
t.forth
|
||||
end
|
||||
-- Add unit widgets
|
||||
t := wf.attack_widgets
|
||||
from t.start
|
||||
until t.after
|
||||
loop
|
||||
w := t.item_for_iteration
|
||||
print ("{BOARD_VIEW}.add_widgets: Adding " + w.target.name + " at (" + w.x.out + ", " + w.y.out + ") %N")
|
||||
-- world.extend (w)
|
||||
add_model (w)
|
||||
-- w.hide
|
||||
t.forth
|
||||
end
|
||||
end
|
||||
|
||||
build_corner_dots
|
||||
-- Create the two dots that will mark the top-left and bottom-right corners of
|
||||
-- the board. These aid calculation of the current scaling factor and scolling
|
||||
do
|
||||
top_left_dot.set_x_y (playing_area_left, playing_area_top)
|
||||
bottom_right_dot.set_x_y (playing_area_right, playing_area_bottom)
|
||||
top_left_dot.set_line_width (10)
|
||||
bottom_right_dot.set_line_width (10)
|
||||
world.extend (top_left_dot)
|
||||
world.extend (bottom_right_dot)
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Add actions to the widgets
|
||||
local
|
||||
w: ATTACK_UNIT_WIDGET
|
||||
do
|
||||
-- Do not call precursor
|
||||
-- asia_widget.pointer_button_press_actions.force_extend (agent toggle_land)
|
||||
-- pointer_motion_actions.extend (agent on_pointer_moved)
|
||||
-- pointer_button_release_actions.extend (agent on_button_released)
|
||||
end
|
||||
|
||||
build_border
|
||||
-- Put a border around the game board to hide some of the land overhangs
|
||||
local
|
||||
poly: EV_MODEL_POLYGON
|
||||
s: INTEGER
|
||||
bw, bh: INTEGER_32
|
||||
c: EV_COLOR
|
||||
do
|
||||
s := 5
|
||||
c := Medium_grey
|
||||
bw := board_width
|
||||
bh := board_height
|
||||
-- top
|
||||
create poly.default_create
|
||||
poly.set_line_width (0)
|
||||
poly.extend_point (create {EV_COORDINATE}.make (-s, -s))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (bw + s, -s))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (bw + s, 0))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (-s, 0))
|
||||
poly.set_background_color (c)
|
||||
poly.set_foreground_color (c)
|
||||
world.extend (poly)
|
||||
-- botton
|
||||
create poly.default_create
|
||||
poly.set_line_width (0)
|
||||
poly.extend_point (create {EV_COORDINATE}.make (-s, bh))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (bw + s, bh))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (bw + s, bh + s))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (-s, bh + s))
|
||||
poly.set_background_color (c)
|
||||
poly.set_foreground_color (c)
|
||||
world.extend (poly)
|
||||
-- left
|
||||
create poly.default_create
|
||||
poly.set_line_width (0)
|
||||
poly.extend_point (create {EV_COORDINATE}.make (-s, -s))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (0, -s))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (0, bh + s))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (-s, bh + s))
|
||||
poly.set_background_color (c)
|
||||
poly.set_foreground_color (c)
|
||||
world.extend (poly)
|
||||
-- right
|
||||
create poly.default_create
|
||||
poly.set_line_width (0)
|
||||
poly.extend_point (create {EV_COORDINATE}.make (bw, -s))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (bw + s, -s))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (bw + s, bh + s))
|
||||
poly.extend_point (create {EV_COORDINATE}.make (bw, bh + s))
|
||||
poly.set_background_color (c)
|
||||
poly.set_foreground_color (c)
|
||||
world.extend (poly)
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
set_target (a_item: like game)
|
||||
-- Associate `a_item' with Current.
|
||||
do
|
||||
Precursor (a_item)
|
||||
-- Build a polygon that defines the boundary of current for which we
|
||||
-- find the centerpoint, the `dot'. Other widgets can then be built
|
||||
-- and if desired placed in Current relative to `dot'
|
||||
widget_factory.set_game (game)
|
||||
-- paint
|
||||
-- set_pebble (a_item)
|
||||
-- set_accept_cursor (sub_pixmap (bounding_box))
|
||||
end
|
||||
|
||||
draw
|
||||
-- Redraw the view
|
||||
-- This means the game has changed in some way
|
||||
-- (e.g. a ship was added).
|
||||
do
|
||||
if not is_view_empty then
|
||||
-- update_attack_widgets
|
||||
-- should be no need to draw the whole view unless the game
|
||||
-- was changed.
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
widget_factory: ALL_WIDGETS_FACTORY
|
||||
-- Holds all the widgets on the board
|
||||
|
||||
playing_area_ratio: REAL_64
|
||||
-- Ratio of the playing_area_width' to the [possibly]
|
||||
-- scaled size of the `playing_area_width'. Default = one,
|
||||
-- but redefined here to use the distance between the
|
||||
-- two corner dots.
|
||||
do
|
||||
Result := playing_area_width / (bottom_right_dot.x - top_left_dot.x)
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
cell_at (a_x, a_y: INTEGER_32): VITP_CELL
|
||||
-- The cell at the screen coordinates `a_x', `a_y'
|
||||
local
|
||||
x, y: INTEGER_32
|
||||
do
|
||||
x := ((a_x * playing_area_ratio) / cell_size).truncated_to_integer + 1
|
||||
y := ((a_y * playing_area_ratio) / cell_size).truncated_to_integer + 1
|
||||
Result := game.cell (x, y)
|
||||
end
|
||||
|
||||
screen_coordinates (a_cell: VITP_CELL): TUPLE [x, y: INTEGER_32]
|
||||
-- The screen coordinates corresponding to `a_cell'
|
||||
local
|
||||
x, y: INTEGER_32
|
||||
do
|
||||
x := ((a_cell.index.x * cell_size) / playing_area_ratio).truncated_to_integer
|
||||
y := ((a_cell.index.y * cell_size) / playing_area_ratio).truncated_to_integer
|
||||
Result := [x, y]
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_forwarding: BOOLEAN
|
||||
-- Has a widget been brought to the top?
|
||||
|
||||
is_dragging: BOOLEAN
|
||||
-- Are we in the process of sliding a widget or a group of widgets?
|
||||
|
||||
-- is_picking: BOOLEAN
|
||||
-- -- Are we in the process of a pick-and-put operation?
|
||||
|
||||
is_repositioning: BOOLEAN
|
||||
-- Is a widget being repositioned?
|
||||
|
||||
is_moving: BOOLEAN
|
||||
-- Is a unit being moved to a new location?
|
||||
|
||||
is_highlighting: BOOLEAN
|
||||
-- Is a widget or group of widgets being emphasized?
|
||||
|
||||
is_highlighting_location: BOOLEAN
|
||||
-- Is one or more port widgets being emphasized?
|
||||
|
||||
is_highlighting_units: BOOLEAN
|
||||
-- Is one or more unit widgets being emphasized?
|
||||
|
||||
is_highlighting_task_force: BOOLEAN
|
||||
-- Is one or more {TASK_FORCE_WIDGET}s being emphasized?
|
||||
|
||||
is_processing_task_force: BOOLEAN
|
||||
-- A {TASK_FORCE_WIDGET} is being clicked/move/released
|
||||
|
||||
feature -- Actions
|
||||
|
||||
pick_notified_operations (a_target: ANY)
|
||||
-- React to the pick of `a_target' from some view
|
||||
local
|
||||
sop: like game.sequence_of_play
|
||||
set: LINKED_SET [PORT]
|
||||
p: PORT
|
||||
pw: PORT_WIDGET
|
||||
do
|
||||
Precursor (a_target)
|
||||
print ("{BOARD_VIEW}.pick_notified_operations on {" + generating_type.name + "}%N")
|
||||
sop := game.sequence_of_play
|
||||
if sop.is_reinforcement_step and then attached {ATTACK_UNIT} a_target as t then
|
||||
set := t.reinforceable_ports
|
||||
print ("%T undimming " + set.count.out + " areas %N")
|
||||
from set.start
|
||||
until set.after
|
||||
loop
|
||||
p := set.item
|
||||
print ("%T%T making " + p.name + " brighter %N")
|
||||
pw := widget_factory.port_widgets.definite_item (p)
|
||||
pw.set_dimming_level ({DIMABLE}.bright)
|
||||
pw.activate_drop_action
|
||||
highlighted_widgets.extend (pw)
|
||||
set.forth
|
||||
end
|
||||
-- application.process_graphical_events
|
||||
end
|
||||
end
|
||||
|
||||
pick_ended_operations
|
||||
-- React to the end of a pick and drop operation
|
||||
do
|
||||
Precursor
|
||||
print ("{BOARD_VIEW}.pick_ended_operations on {" + generating_type.name + "} %N")
|
||||
from highlighted_widgets.start
|
||||
until highlighted_widgets.after
|
||||
loop
|
||||
highlighted_widgets.item.deactivate_drop_action
|
||||
highlighted_widgets.item.restore_dimming_level
|
||||
highlighted_widgets.forth
|
||||
end
|
||||
highlighted_widgets.wipe_out
|
||||
end
|
||||
|
||||
on_pointer_enter (a_widget: VITP_WIDGET)
|
||||
-- React to a pointer entering `a_widget'
|
||||
local
|
||||
tfw: TASK_FORCE_WIDGET
|
||||
do
|
||||
io.put_string ("BOARD_WORLD.on_pointer_enter: on " + a_widget.target.name + " %N")
|
||||
-- if attached {ATTACK_UNIT_WIDGET} a_widget as w then
|
||||
-- if w.unit.is_task_force then
|
||||
-- tfw := task_force_widgets.widget (w.unit.task_force)
|
||||
-- forward_widget_to_top (w, tfw)
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
on_pointer_leave (a_widget: VITP_WIDGET)
|
||||
-- React to a pointer leaving a `a_widget'
|
||||
do
|
||||
io.put_string ("BOARD_WORLD.on_pointer_leave: on " + a_widget.target.name + " %N")
|
||||
-- if is_forwarding then
|
||||
-- restore_forwarded_widget
|
||||
-- end
|
||||
end
|
||||
|
||||
on_button_pressed (a_widget: VITP_WIDGET; ax: INTEGER; ay: INTEGER; a_button: INTEGER)
|
||||
-- React to a pointer button pressed notification from `a_widget'
|
||||
do
|
||||
io.put_string ("BOARD_WORLD.on_button_pressed: button " + a_button.out +
|
||||
" pressed at (" + ax.out + ", " + ay.out + ") on " + a_widget.target.name + " %N")
|
||||
-- last_mouse_position.set_precise (ax, ay)
|
||||
-- if is_forwarding then
|
||||
-- restore_forwarded_widget
|
||||
-- end
|
||||
-- if a_button = 1 then
|
||||
-- if attached {ATTACK_UNIT_WIDGET} a_widget as w then
|
||||
-- highlight_unit (w.unit)
|
||||
-- begin_widget_reposition (w, ax, ay)
|
||||
-- elseif attached {LOCATION_WIDGET} a_widget as w then
|
||||
-- highlight_location (w.location)
|
||||
-- highlight_location_occupants (w.location)
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
on_button_double_pressed (a_widget: VITP_WIDGET; ax: INTEGER; ay: INTEGER; a_button: INTEGER)
|
||||
-- React to a pointer button released notification from `a_widget'
|
||||
do
|
||||
io.put_string ("BOARD_WORLD.on_button_double_pressed: button " + a_button.out +
|
||||
" double-pressed at (" + ax.out + ", " + ay.out + ") on " + a_widget.target.name + "%N")
|
||||
if a_button = 1 then
|
||||
if attached {TASK_FORCE_WIDGET} a_widget as w and then
|
||||
not w.point_on_bounding_figure (ax, ay) then
|
||||
if w.is_stacked then
|
||||
w.tile
|
||||
else
|
||||
w.stack
|
||||
end
|
||||
-- Next lines to prevent undesired movement
|
||||
is_repositioning := false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_button_released (a_widget: VITP_WIDGET; ax: INTEGER; ay: INTEGER; a_button: INTEGER)
|
||||
-- React to a pointer button released notification from `a_widget'
|
||||
do
|
||||
io.put_string ("BOARD_WORLD.on_button_released: button " + a_button.out + " pressed at (" + ax.out + ", " + ay.out + ") %N")
|
||||
if is_highlighting_location then
|
||||
normalize_locations
|
||||
end
|
||||
if is_highlighting_units then
|
||||
normalize_units
|
||||
end
|
||||
if is_repositioning then
|
||||
-- finish_widget_reposition
|
||||
end
|
||||
end
|
||||
|
||||
on_pointer_motion (a_widget: VITP_WIDGET; ax, ay: INTEGER)
|
||||
-- React to a pointer move notification from `a_widget'
|
||||
do
|
||||
io.put_string ("BOARD_WORLD.on_notify_pointer_motion: at (" + ax.out + ", " + ay.out + ") %N")
|
||||
-- if is_repositioning then
|
||||
---- last_mouse_position.set_position (ax, ay)
|
||||
-- -- Adjust for difference in the location of `active_widget' and `last_mouse_position'
|
||||
---- if can_reposition (ax, ay) then
|
||||
---- set_pointer_style (create {EV_POINTER_STYLE}.make_predefined ({EV_POINTER_STYLE_CONSTANTS}.Standard_cursor))
|
||||
---- reposition_active_widget (ax, ay)
|
||||
---- else
|
||||
---- set_pointer_style (create {EV_POINTER_STYLE}.make_predefined ({EV_POINTER_STYLE_CONSTANTS}.No_cursor))
|
||||
---- end
|
||||
-- end
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
position_task_force_widget (a_widget: TASK_FORCE_WIDGET)
|
||||
-- Place `a_widget' on the board so it does not overlap other
|
||||
-- widgets, possibly moving other widgets.
|
||||
do
|
||||
|
||||
end
|
||||
|
||||
position_widget (a_widget: ATTACK_UNIT_WIDGET)
|
||||
-- Ensure each widget is postioned according to its position,
|
||||
-- perhaps repositioning it to accomodate other widgets.
|
||||
do
|
||||
|
||||
end
|
||||
|
||||
feature --{WIDGET_FACTORY} -- Basic operations
|
||||
|
||||
on_flip_widget (a_widget: SHIP_WIDGET)
|
||||
-- Toggle the raiding status of `a_widget'
|
||||
do
|
||||
io.put_string ("on_flip_raider /n")
|
||||
a_widget.flip
|
||||
ensure
|
||||
ship_status_toggled: a_widget.ship.is_raiding = not (old a_widget.ship.is_raiding)
|
||||
end
|
||||
|
||||
board_coordinate_to_model_position (a_position: EV_COORDINATE): VITP_POSITION
|
||||
-- `a_position' converted to the model's coordinate system
|
||||
require
|
||||
position_exists: a_position /= Void
|
||||
local
|
||||
brp, tlp: EV_COORDINATE
|
||||
p: EV_COORDINATE
|
||||
x_size, y_size: REAL_64
|
||||
long, lat: REAL_64
|
||||
do
|
||||
p := a_position
|
||||
brp := bottom_right_dot.point
|
||||
tlp := top_left_dot.point
|
||||
x_size := brp.x_precise - tlp.x_precise
|
||||
y_size := brp.y_precise - tlp.y_precise
|
||||
long := (p.x_precise - tlp.x_precise) * (board_right / x_size)
|
||||
lat := (p.y_precise - tlp.y_precise) * (board_bottom / y_size)
|
||||
create Result.set_xy (long.truncated_to_integer, lat.truncated_to_integer)
|
||||
end
|
||||
|
||||
highlight_location (a_location: LOCATION)
|
||||
-- Brighten the widget corresponding to `a_location'
|
||||
require
|
||||
location_exists: a_location /= Void
|
||||
local
|
||||
w: VITP_WIDGET
|
||||
do
|
||||
w := widget_factory.widgets.definite_item (a_location)
|
||||
if world.has (w) then
|
||||
w.set_dimming_level ({DIMABLE}.Bright)
|
||||
w.paint
|
||||
highlighted_widgets.extend (w)
|
||||
is_highlighting_location := true
|
||||
end
|
||||
end
|
||||
|
||||
highlight_location_occupants (a_location: LOCATION)
|
||||
-- Brighten the widgets corresponding to the occupants of `a_location'
|
||||
require
|
||||
location_exists: a_location /= Void
|
||||
local
|
||||
u_list: LINKED_SET [ATTACK_UNIT]
|
||||
w: VITP_WIDGET
|
||||
do
|
||||
u_list := a_location.units
|
||||
from u_list.start
|
||||
until u_list.after
|
||||
loop
|
||||
w := widget_factory.widgets.definite_item (u_list.item)
|
||||
w.set_dimming_level ({DIMABLE}.Bright)
|
||||
w.paint
|
||||
highlighted_widgets.extend (w)
|
||||
u_list.forth
|
||||
end
|
||||
is_highlighting_units := true
|
||||
end
|
||||
|
||||
highlight_unit (a_unit: ATTACK_UNIT)
|
||||
-- Brighten the widget corresponding to `a_unit'
|
||||
require
|
||||
unit_exists: a_unit /= Void
|
||||
local
|
||||
tfw: TASK_FORCE_WIDGET
|
||||
w: VITP_WIDGET
|
||||
do
|
||||
-- if a_unit.is_task_force then
|
||||
-- tfw := task_force_widgets.widget (a_unit.task_force)
|
||||
-- if tfw.is_stacked then
|
||||
-- w := tfw
|
||||
-- else
|
||||
-- w := world.attack_widgets.widget (a_unit)
|
||||
-- end
|
||||
-- else
|
||||
-- w := world.attack_widgets.widget (a_unit)
|
||||
-- end
|
||||
w := widget_factory.widgets.definite_item (a_unit)
|
||||
w.set_dimming_level ({DIMABLE}.Bright)
|
||||
w.paint
|
||||
highlighted_widgets.extend (w)
|
||||
is_highlighting_units := true
|
||||
end
|
||||
|
||||
normalize_locations
|
||||
-- Restor all location widgets to a normal brightness level
|
||||
local
|
||||
w: LOCATION_WIDGET
|
||||
do
|
||||
-- from world.location_widgets.start
|
||||
-- until world.location_widgets.after
|
||||
-- loop
|
||||
-- w := world.location_widgets.item_for_iteration
|
||||
-- w.set_dimming_level ({DIMABLE}.Normal)
|
||||
-- w.paint
|
||||
-- world.location_widgets.forth
|
||||
-- end
|
||||
-- is_highlighting_location := false
|
||||
end
|
||||
|
||||
normalize_units
|
||||
-- Restore all attack widgets to a normal brightness level
|
||||
local
|
||||
w: ATTACK_UNIT_WIDGET
|
||||
do
|
||||
-- from world.attack_widgets.start
|
||||
-- until world.attack_widgets.after
|
||||
-- loop
|
||||
-- w := world.attack_widgets.item_for_iteration
|
||||
-- w.set_dimming_level ({DIMABLE}.Normal)
|
||||
-- w.paint
|
||||
-- world.attack_widgets.forth
|
||||
-- end
|
||||
-- is_highlighting_units := false
|
||||
end
|
||||
|
||||
feature --{VITP_WIDGET} -- Implementation
|
||||
|
||||
task_force_widgets: VITP_WIDGET_TABLE [TASK_FORCE_WIDGET, TASK_FORCE]
|
||||
|
||||
last_mouse_position: EV_COORDINATE
|
||||
-- For possible restoration to the location where the reposition began
|
||||
|
||||
forwarded_widget: detachable ATTACK_UNIT_WIDGET
|
||||
-- A widget that has been brought to the top of its owner
|
||||
|
||||
forwarded_widget_owner: detachable VITP_WIDGET
|
||||
-- The widget in which `forwarded_widget' resides
|
||||
|
||||
highlighted_widgets: LINKED_SET [VITP_WIDGET]
|
||||
-- The widgets with the focus
|
||||
|
||||
top_left_dot: EV_MODEL_DOT
|
||||
-- A dot at top left of the board, that will scale and scroll with the view,
|
||||
-- whose position when compared with `bottom_right_dot' provides a scale
|
||||
-- factor used to position widgets
|
||||
|
||||
bottom_right_dot: EV_MODEL_DOT
|
||||
-- See `top_left_dot'
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
-- X_stacking_increment: INTEGER
|
||||
-- -- The distance in pixels to offset a stacked widget in the x direction
|
||||
-- local
|
||||
-- w: ATTACK_UNIT_WIDGET
|
||||
-- do
|
||||
-- -- Since we base this distance on the current size of a ship widget,
|
||||
-- -- we must ensure we have a widget from which to calculate the value.
|
||||
-- check not world.attack_widgets.is_empty then
|
||||
-- w := world.attack_widgets.iteration_item (1)
|
||||
---- Result := (w.tile_size / 10).rounded
|
||||
-- Result := (w.tile_size / 10).rounded
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- Y_stacking_increment: INTEGER
|
||||
-- -- The distance in pixels to offset a stacked widget in the x direction
|
||||
-- local
|
||||
-- w: ATTACK_UNIT_WIDGET
|
||||
-- do
|
||||
-- -- Since we base this distance on the current size of a ship widget,
|
||||
-- -- we must ensure we have a widget from which to calculate the value.
|
||||
-- check not world.attack_widgets.is_empty then
|
||||
-- w := world.attack_widgets.iteration_item (1)
|
||||
---- Result := (w.tile_size / 10).rounded
|
||||
-- Result := (w.tile_size / 10).rounded
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
--feature {NONE} -- Implemetation
|
||||
|
||||
-- target_imp: detachable VITP_GAME
|
||||
-- -- Detachable implementation of `target' for void safety
|
||||
|
||||
end
|
152
jj_vitp/Interface/views/chart_tool.e
Normal file
152
jj_vitp/Interface/views/chart_tool.e
Normal file
@@ -0,0 +1,152 @@
|
||||
note
|
||||
description: "[
|
||||
Used to hold a CHART_VIEW in the VITP game program.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
CHART_TOOL
|
||||
|
||||
inherit
|
||||
|
||||
VITP_TOOL
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
-- add_actions,
|
||||
set_target,
|
||||
draw
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
create japanese_oa_chart_view.make (vitp)
|
||||
create allied_oa_chart_view.make (vitp)
|
||||
create allied_starting_forces_view.make (vitp)
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Build the interface for this window
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
disable_history
|
||||
split_manager.extend (japanese_oa_chart_view)
|
||||
split_manager.extend (allied_starting_forces_view)
|
||||
split_manager.set_vertical
|
||||
split_manager.extend (allied_oa_chart_view)
|
||||
end
|
||||
|
||||
-- add_actions
|
||||
-- -- Add actions to views
|
||||
-- do
|
||||
-- Precursor
|
||||
---- japanese_oa_chart_view.pointer_button_press_actions.extend (agent on_pressed (japanese_oa_chart_view, ?,?,?,?,?,?,?,?))
|
||||
---- allied_oa_chart_view.pointer_button_press_actions.extend (agent on_pressed (allied_oa_chart_view, ?,?,?,?,?,?,?,?))
|
||||
---- allied_starting_forces_view.pointer_button_press_actions.extend (agent on_pressed (allied_starting_forces_view, ?,?,?,?,?,?,?,?))
|
||||
|
||||
-- allied_starting_forces_view.pointer_enter_actions.extend (agent on_enter)
|
||||
-- allied_starting_forces_view.pointer_button_release_actions.extend (agent on_pressed (allied_starting_forces_view, ?,?,?,?,?,?,?,?))
|
||||
-- end
|
||||
|
||||
feature {NONE} -- Agent actions
|
||||
|
||||
on_enter
|
||||
-- Test actions
|
||||
do
|
||||
io.put_string (generating_type.name + ".on_enter: %N")
|
||||
end
|
||||
|
||||
on_pressed (a_view: ORDER_OF_APPEARANCE_VIEW;
|
||||
ax, ay, button: INTEGER;
|
||||
ax_tilt, ay_tilt, a_pressure: DOUBLE;
|
||||
a_screen_x, a_screen_y: INTEGER)
|
||||
-- I was going to use this feature for setting the `focused_view'
|
||||
-- when the user clicks within one of the views, but it never gets
|
||||
-- called (so I commented out `add_actions'). I bet the event
|
||||
-- loop never checks for `pointer_press_actions'. ???
|
||||
do
|
||||
io.put_string (generating_type.name + ".on_pressed: " + a_view.generating_type.name + "%N")
|
||||
focused_view_imp := a_view
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
-- target: VITP_GAME
|
||||
|
||||
japanese_oa_chart_view: JAPANESE_ORDER_OF_APPEARANCE_CHART_VIEW
|
||||
-- The view representing the Japanese order of appearance
|
||||
|
||||
allied_oa_chart_view: ALLIED_ORDER_OF_APPEARANCE_CHART_VIEW
|
||||
-- The view representing the Allied ordr of appearance
|
||||
|
||||
allied_starting_forces_view: ALLIED_STARTING_FORCES_VIEW
|
||||
-- The view reprsenting the Allied, turn 1, starting forces chart
|
||||
|
||||
focused_view: VITP_CELL_VIEW
|
||||
-- The view that currently has the focus
|
||||
do
|
||||
if attached focused_view_imp as v and then v.is_displayed then
|
||||
Result := v
|
||||
else
|
||||
if japanese_oa_chart_view.is_displayed then
|
||||
Result := japanese_oa_chart_view
|
||||
elseif allied_oa_chart_view.is_displayed then
|
||||
Result := allied_oa_chart_view
|
||||
elseif allied_starting_forces_view.is_displayed then
|
||||
Result := allied_starting_forces_view
|
||||
else
|
||||
-- Unlikely, but all view are hidden, so default
|
||||
Result := japanese_oa_chart_view
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_game: like vitp)
|
||||
-- Change the value of `target' and add it to the `target_set' (the set
|
||||
-- of objects contained in this view. The old target is removed from
|
||||
-- the set.
|
||||
do
|
||||
Precursor {VITP_TOOL} (a_game)
|
||||
japanese_oa_chart_view.set_target (a_game)
|
||||
allied_oa_chart_view.set_target (a_game)
|
||||
allied_starting_forces_view.set_target (a_game)
|
||||
end
|
||||
|
||||
set_focused_view (a_view: ORDER_OF_APPEARANCE_VIEW)
|
||||
-- Set `focused_view' to `a_view'.
|
||||
-- Called by {ORDER_OF_APPEARANCE_VIEW} when `a_view' was clicked
|
||||
require
|
||||
valid_view: a_view = japanese_oa_chart_view or
|
||||
a_view = allied_oa_chart_view or
|
||||
a_view = allied_starting_forces_view
|
||||
do
|
||||
focused_view_imp := a_view
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Redraw the tool and the contained view
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
japanese_oa_chart_view.draw
|
||||
allied_oa_chart_view.draw
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
focused_view_imp: detachable like focused_view
|
||||
-- Implementaion of `focused_view'
|
||||
end
|
113
jj_vitp/Interface/views/game_sequence_tool.e
Normal file
113
jj_vitp/Interface/views/game_sequence_tool.e
Normal file
@@ -0,0 +1,113 @@
|
||||
note
|
||||
description: "[
|
||||
Tool to manipulate the sequence of the game play.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
GAME_SEQUENCE_TOOL
|
||||
|
||||
inherit
|
||||
|
||||
VITP_TOOL
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
build_tool_bar,
|
||||
add_actions,
|
||||
set_target,
|
||||
draw
|
||||
end
|
||||
|
||||
GAME_CONSTANTS
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
create advance_button
|
||||
advance_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_supplier_color_buffer))
|
||||
advance_button.set_tooltip ("Advance")
|
||||
create view.make (vitp)
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Build the interface for this window
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
split_manager.extend (view)
|
||||
-- set_target (vitp)
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Add functionality to the buttons
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
advance_button.select_actions.extend (agent on_advance)
|
||||
end
|
||||
|
||||
build_tool_bar
|
||||
-- Add buttons to `tool_bar' (from TOOL).
|
||||
do
|
||||
Precursor {VITP_TOOL}
|
||||
-- tool_bar.extend (advance_button)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
view: GAME_SEQUENCE_VIEW
|
||||
-- Handle to the view corresponding to the first view created by the
|
||||
-- `view_manager' in `initialize'.
|
||||
-- Convinience feature.
|
||||
|
||||
focused_view: VITP_CELL_VIEW
|
||||
-- The view that currently has the focus
|
||||
do
|
||||
Result := view
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_game: like vitp)
|
||||
-- Change the `target'
|
||||
do
|
||||
Precursor {VITP_TOOL} (a_game)
|
||||
view.set_target (a_game)
|
||||
end
|
||||
|
||||
draw
|
||||
-- Redraw the view
|
||||
do
|
||||
view.draw
|
||||
end
|
||||
|
||||
feature {NONE} -- Actions
|
||||
|
||||
on_advance
|
||||
-- React to a press of the `advance_button'
|
||||
do
|
||||
-- sop.forth
|
||||
draw_views (vitp)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
advance_button: EV_TOOL_BAR_BUTTON
|
||||
-- Button to advance to the next phase/step of the game
|
||||
|
||||
end
|
93
jj_vitp/Interface/views/game_sequence_view.e
Normal file
93
jj_vitp/Interface/views/game_sequence_view.e
Normal file
@@ -0,0 +1,93 @@
|
||||
note
|
||||
description: "[
|
||||
View to display the sequence of the vitp.play.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
GAME_SEQUENCE_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
VITP_CELL_VIEW
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
draw
|
||||
-- target_imp
|
||||
end
|
||||
|
||||
GAME_CONSTANTS
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VITP_CELL_VIEW}
|
||||
create turn_text
|
||||
create phase_text
|
||||
create step_text
|
||||
create player_text
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Create the text widgets making up current
|
||||
local
|
||||
rp: EV_COORDINATE
|
||||
do
|
||||
Precursor {VITP_CELL_VIEW}
|
||||
world.extend (turn_text)
|
||||
world.extend (phase_text)
|
||||
world.extend (step_text)
|
||||
world.extend (player_text)
|
||||
create rp.make (10, 10)
|
||||
turn_text.set_point (rp)
|
||||
create rp.make (10, 30)
|
||||
phase_text.set_point (rp)
|
||||
create rp.make (10, 50)
|
||||
step_text.set_point (rp)
|
||||
create rp.make (10, 70)
|
||||
player_text.set_point (rp)
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Redraw the view
|
||||
do
|
||||
io.put_string (generating_type.name + ".draw: fix me %N")
|
||||
-- turn_text.set_text ("Turn: %T" + vitp.turn.out)
|
||||
-- phase_text.set_text ("Phase: %T" + vitp.phase_text)
|
||||
-- step_text.set_text ("Set: %T" + vitp.stage_text)
|
||||
-- player_text.set_text ("Player: %T" + vitp.player_text)
|
||||
Precursor {VITP_CELL_VIEW}
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
-- target_imp: detachable VITP_SEQUENCE_OF_PLAY
|
||||
-- -- The target of this view
|
||||
|
||||
turn_text: EV_MODEL_TEXT
|
||||
|
||||
phase_text: EV_MODEL_TEXT
|
||||
|
||||
step_text: EV_MODEL_TEXT
|
||||
|
||||
player_text: EV_MODEL_TEXT
|
||||
|
||||
|
||||
end
|
439
jj_vitp/Interface/views/japanese_forces_factory.e
Normal file
439
jj_vitp/Interface/views/japanese_forces_factory.e
Normal file
@@ -0,0 +1,439 @@
|
||||
note
|
||||
description: "[
|
||||
One of the classes that decompose the numourous VITP widgets
|
||||
into more managable groups containing the Japanese-unit widgets.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/15/24"
|
||||
copyright: "Copyright (c) 2024, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
class
|
||||
JAPANESE_FORCES_FACTORY
|
||||
|
||||
inherit
|
||||
|
||||
WIDGET_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_widgets
|
||||
-- Create widgets for the corresponding game item
|
||||
do
|
||||
print ("JAPANESE_FORCES_WIDGET_FACTORY.make_widgets %N")
|
||||
Precursor {WIDGET_FACTORY}
|
||||
print ("%T JAPANESE_FORCES_WIDGET_FACTORY.make_widgets after Precursor call %N")
|
||||
create japanese_forces_widgets.make (100)
|
||||
print ("%T JAPANESE_FORCES_WIDGET_FACTORY.make_widgets after create japanese_forces_widgets %N")
|
||||
-- Turn 1
|
||||
check attached game then
|
||||
print ("%T JAPANESE_FORCES_WIDGET_FACTORY.make_widgets check statement %N")
|
||||
print ("%T JAPANESE_FORCES_WIDGET_FACTORY.make_widgets " + game.shokaku.name + "%N")
|
||||
|
||||
end
|
||||
create shokaku_widget.make (game.shokaku)
|
||||
print ("%T JAPANESE_FORCES_WIDGET_FACTORY.make_widgets after create shokaku_widget %N")
|
||||
create zuikaku_widget.make (game.zuikaku)
|
||||
create akagi_widget.make (game.akagi)
|
||||
create kaga_widget.make (game.kaga)
|
||||
create soryu_widget.make (game.soryu)
|
||||
create hiryu_widget.make (game.hiryu)
|
||||
create ryujo_widget.make (game.ryujo)
|
||||
create hosho_widget.make (game.hosho)
|
||||
create zuiho_widget.make (game.zuiho)
|
||||
create mutsu_widget.make (game.mutsu)
|
||||
create nagato_widget.make (game.nagato)
|
||||
create fuso_widget.make (game.fuso)
|
||||
create hyuga_widget.make (game.hyuga)
|
||||
create ise_widget.make (game.ise)
|
||||
create yamashiro_widget.make (game.yamashiro)
|
||||
create haruna_widget.make (game.haruna)
|
||||
create hiei_widget.make (game.hiei)
|
||||
create kirishima_widget.make (game.kirishima)
|
||||
create kongo_widget.make (game.kongo)
|
||||
create ashigara_widget.make (game.ashigara)
|
||||
create atago_widget.make (game.atago)
|
||||
create chokai_widget.make (game.chokai)
|
||||
create haguro_widget.make (game.haguro)
|
||||
create maya_widget.make (game.maya)
|
||||
create myoko_widget.make (game.myoko)
|
||||
create nachi_widget.make (game.nachi)
|
||||
create takao_widget.make (game.takao)
|
||||
create chikuma_widget.make (game.chikuma)
|
||||
create kumano_widget.make (game.kumano)
|
||||
create mikuma_widget.make (game.mikuma)
|
||||
create mogami_widget.make (game.mogami)
|
||||
create suzuya_widget.make (game.suzuya)
|
||||
create tone_widget.make (game.tone)
|
||||
create aoba_widget.make (game.aoba)
|
||||
create furutaka_widget.make (game.furutaka)
|
||||
create kako_widget.make (game.kako)
|
||||
create kinugasa_widget.make (game.kinugasa)
|
||||
create kitakami_widget.make (game.kitakami)
|
||||
create oi_widget.make (game.oi)
|
||||
create yokosuka_widget.make (game.yokosuka)
|
||||
create airflot_21_widget.make (game.airflot_21)
|
||||
create airflot_22_widget.make (game.airflot_22)
|
||||
create airflot_23_widget.make (game.airflot_23)
|
||||
create airflot_24_widget.make (game.airflot_24)
|
||||
create airflot_25_widget.make (game.airflot_25)
|
||||
create airflot_26_widget.make (game.airflot_26)
|
||||
create i_boat_widget.make (game.i_boat)
|
||||
-- Turn 2
|
||||
create shoho_widget.make (game.shoho)
|
||||
create junyo_widget.make (game.junyo)
|
||||
create sasebo_widget.make (game.sasebo)
|
||||
-- Turn 3
|
||||
create hiyo_widget.make (game.hiyo)
|
||||
create yamato_widget.make (game.yamato)
|
||||
create kure_widget.make (game.kure)
|
||||
-- Turn 4
|
||||
do_nothing
|
||||
-- Turn 5
|
||||
create musashi_widget.make (game.musashi)
|
||||
-- Turn 6
|
||||
do_nothing
|
||||
-- Turn 7
|
||||
create chiyoda_widget.make (game.chiyoda)
|
||||
create chitose_widget.make (game.chitose)
|
||||
create ryuho_widget.make (game.ryuho)
|
||||
create taiho_widget.make (game.taiho)
|
||||
create i_boat_removal_widget.make (game.i_boat_removal)
|
||||
-- Turn 8
|
||||
create unryu_widget.make (game.unryu)
|
||||
create amagi_widget.make (game.amagi)
|
||||
-- Turn 9
|
||||
create katsuragi_widget.make (game.katsuragi)
|
||||
create shinano_widget.make (game.shinano)
|
||||
end
|
||||
|
||||
feature -- Access (tables)
|
||||
|
||||
japanese_forces_widgets: VITP_WIDGET_TABLE [ATTACK_UNIT_WIDGET, ATTACK_UNIT]
|
||||
-- Keeps track of widgets
|
||||
|
||||
feature -- Access (Japanese unit widgets)
|
||||
|
||||
-- Turn 1, row 1
|
||||
shokaku_widget: SHIP_WIDGET
|
||||
zuikaku_widget: SHIP_WIDGET
|
||||
akagi_widget: SHIP_WIDGET
|
||||
kaga_widget: SHIP_WIDGET
|
||||
soryu_widget: SHIP_WIDGET
|
||||
hiryu_widget: SHIP_WIDGET
|
||||
ryujo_widget: SHIP_WIDGET
|
||||
hosho_widget: SHIP_WIDGET
|
||||
zuiho_widget: SHIP_WIDGET
|
||||
mutsu_widget: SHIP_WIDGET
|
||||
nagato_widget: SHIP_WIDGET
|
||||
fuso_widget: SHIP_WIDGET
|
||||
-- Turn 1, row 2
|
||||
hyuga_widget: SHIP_WIDGET
|
||||
ise_widget: SHIP_WIDGET
|
||||
yamashiro_widget: SHIP_WIDGET
|
||||
haruna_widget: SHIP_WIDGET
|
||||
hiei_widget: SHIP_WIDGET
|
||||
kirishima_widget: SHIP_WIDGET
|
||||
kongo_widget: SHIP_WIDGET
|
||||
ashigara_widget: SHIP_WIDGET
|
||||
atago_widget: SHIP_WIDGET
|
||||
chokai_widget: SHIP_WIDGET
|
||||
haguro_widget: SHIP_WIDGET
|
||||
maya_widget: SHIP_WIDGET
|
||||
-- Turn 1, row 3
|
||||
myoko_widget: SHIP_WIDGET
|
||||
nachi_widget: SHIP_WIDGET
|
||||
takao_widget: SHIP_WIDGET
|
||||
chikuma_widget: SHIP_WIDGET
|
||||
kumano_widget: SHIP_WIDGET
|
||||
mikuma_widget: SHIP_WIDGET
|
||||
mogami_widget: SHIP_WIDGET
|
||||
suzuya_widget: SHIP_WIDGET
|
||||
tone_widget: SHIP_WIDGET
|
||||
aoba_widget: SHIP_WIDGET
|
||||
furutaka_widget: SHIP_WIDGET
|
||||
kako_widget: SHIP_WIDGET
|
||||
-- Turn 1, row 4
|
||||
kinugasa_widget: SHIP_WIDGET
|
||||
kitakami_widget: SHIP_WIDGET
|
||||
oi_widget: SHIP_WIDGET
|
||||
yokosuka_widget: AMPHIBIOUS_UNIT_WIDGET
|
||||
-- Turn 1, also available
|
||||
airflot_21_widget: JAPANESE_AIR_UNIT_WIDGET
|
||||
airflot_22_widget: JAPANESE_AIR_UNIT_WIDGET
|
||||
airflot_23_widget: JAPANESE_AIR_UNIT_WIDGET
|
||||
airflot_24_widget: JAPANESE_AIR_UNIT_WIDGET
|
||||
airflot_25_widget: JAPANESE_AIR_UNIT_WIDGET
|
||||
airflot_26_widget: JAPANESE_AIR_UNIT_WIDGET
|
||||
i_boat_widget: SUBMARINE_WIDGET
|
||||
-- Turn 2
|
||||
shoho_widget: SHIP_WIDGET
|
||||
junyo_widget: SHIP_WIDGET
|
||||
sasebo_widget: AMPHIBIOUS_UNIT_WIDGET
|
||||
-- Turn 3
|
||||
hiyo_widget: SHIP_WIDGET
|
||||
yamato_widget: SHIP_WIDGET
|
||||
kure_widget: AMPHIBIOUS_UNIT_WIDGET
|
||||
-- Turn 5
|
||||
musashi_widget: SHIP_WIDGET
|
||||
-- Turn 7
|
||||
chiyoda_widget: SHIP_WIDGET
|
||||
chitose_widget: SHIP_WIDGET
|
||||
ryuho_widget: SHIP_WIDGET
|
||||
taiho_widget: SHIP_WIDGET
|
||||
i_boat_removal_widget: SUBMARINE_WIDGET
|
||||
-- Turn 8
|
||||
unryu_widget: SHIP_WIDGET
|
||||
amagi_widget: SHIP_WIDGET
|
||||
-- Turn 9
|
||||
katsuragi_widget: SHIP_WIDGET
|
||||
shinano_widget: SHIP_WIDGET
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
extend_widgets
|
||||
-- Put each widget into `world'.
|
||||
do
|
||||
-- Turn 1, row 1
|
||||
japanese_forces_widgets.extend (shokaku_widget, game.shokaku)
|
||||
japanese_forces_widgets.extend (zuikaku_widget, game.zuikaku)
|
||||
japanese_forces_widgets.extend (akagi_widget, game.akagi)
|
||||
japanese_forces_widgets.extend (kaga_widget, game.kaga)
|
||||
japanese_forces_widgets.extend (soryu_widget, game.soryu)
|
||||
japanese_forces_widgets.extend (hiryu_widget, game.hiryu)
|
||||
japanese_forces_widgets.extend (ryujo_widget, game.ryujo)
|
||||
japanese_forces_widgets.extend (hosho_widget, game.hosho)
|
||||
japanese_forces_widgets.extend (zuiho_widget, game.zuiho)
|
||||
japanese_forces_widgets.extend (mutsu_widget, game.mutsu)
|
||||
japanese_forces_widgets.extend (nagato_widget, game.nagato)
|
||||
japanese_forces_widgets.extend (fuso_widget, game.fuso)
|
||||
-- Turn 1, row 2
|
||||
japanese_forces_widgets.extend (hyuga_widget, game.hyuga)
|
||||
japanese_forces_widgets.extend (ise_widget, game.ise)
|
||||
japanese_forces_widgets.extend (yamashiro_widget, game.yamashiro)
|
||||
japanese_forces_widgets.extend (haruna_widget, game.haruna)
|
||||
japanese_forces_widgets.extend (hiei_widget, game.hiei)
|
||||
japanese_forces_widgets.extend (kirishima_widget, game.kirishima)
|
||||
japanese_forces_widgets.extend (kongo_widget, game.kongo)
|
||||
japanese_forces_widgets.extend (ashigara_widget, game.ashigara)
|
||||
japanese_forces_widgets.extend (atago_widget, game.atago)
|
||||
japanese_forces_widgets.extend (chokai_widget, game.chokai)
|
||||
japanese_forces_widgets.extend (haguro_widget, game.haguro)
|
||||
japanese_forces_widgets.extend (maya_widget, game.maya)
|
||||
-- Turn 1, row 3
|
||||
japanese_forces_widgets.extend (myoko_widget, game.myoko)
|
||||
japanese_forces_widgets.extend (nachi_widget, game.nachi)
|
||||
japanese_forces_widgets.extend (takao_widget, game.takao)
|
||||
japanese_forces_widgets.extend (chikuma_widget, game.chikuma)
|
||||
japanese_forces_widgets.extend (kumano_widget, game.kumano)
|
||||
japanese_forces_widgets.extend (mikuma_widget, game.mikuma)
|
||||
japanese_forces_widgets.extend (mogami_widget, game.mogami)
|
||||
japanese_forces_widgets.extend (suzuya_widget, game.suzuya)
|
||||
japanese_forces_widgets.extend (tone_widget, game.tone)
|
||||
japanese_forces_widgets.extend (aoba_widget, game.aoba)
|
||||
japanese_forces_widgets.extend (furutaka_widget, game.furutaka)
|
||||
japanese_forces_widgets.extend (kako_widget, game.kako)
|
||||
-- Turn 1, row 4
|
||||
japanese_forces_widgets.extend (kinugasa_widget, game.kinugasa)
|
||||
japanese_forces_widgets.extend (kitakami_widget, game.kitakami)
|
||||
japanese_forces_widgets.extend (oi_widget, game.oi)
|
||||
japanese_forces_widgets.extend (yokosuka_widget, game.yokosuka)
|
||||
-- Turn 1, also available
|
||||
japanese_forces_widgets.extend (airflot_21_widget, game.airflot_21)
|
||||
japanese_forces_widgets.extend (airflot_22_widget, game.airflot_22)
|
||||
japanese_forces_widgets.extend (airflot_23_widget, game.airflot_23)
|
||||
japanese_forces_widgets.extend (airflot_24_widget, game.airflot_24)
|
||||
japanese_forces_widgets.extend (airflot_25_widget, game.airflot_25)
|
||||
japanese_forces_widgets.extend (airflot_26_widget, game.airflot_26)
|
||||
japanese_forces_widgets.extend (i_boat_widget, game.i_boat)
|
||||
-- Turn 2
|
||||
japanese_forces_widgets.extend (shoho_widget, game.shoho)
|
||||
japanese_forces_widgets.extend (junyo_widget, game.junyo)
|
||||
japanese_forces_widgets.extend (sasebo_widget, game.sasebo)
|
||||
-- Turn 3
|
||||
japanese_forces_widgets.extend (hiyo_widget, game.hiyo)
|
||||
japanese_forces_widgets.extend (yamato_widget, game.yamato)
|
||||
japanese_forces_widgets.extend (kure_widget, game.kure)
|
||||
-- Turn 5
|
||||
japanese_forces_widgets.extend (musashi_widget, game.musashi)
|
||||
-- Turn 7
|
||||
japanese_forces_widgets.extend (chiyoda_widget, game.chiyoda)
|
||||
japanese_forces_widgets.extend (chitose_widget, game.chitose)
|
||||
japanese_forces_widgets.extend (ryuho_widget, game.ryuho)
|
||||
japanese_forces_widgets.extend (taiho_widget, game.taiho)
|
||||
-- Turn 8
|
||||
japanese_forces_widgets.extend (unryu_widget, game.unryu)
|
||||
japanese_forces_widgets.extend (amagi_widget, game.amagi)
|
||||
-- Turn 9
|
||||
japanese_forces_widgets.extend (katsuragi_widget, game.katsuragi)
|
||||
japanese_forces_widgets.extend (shinano_widget, game.shinano)
|
||||
widgets.merge (japanese_forces_widgets)
|
||||
end
|
||||
|
||||
pair_widgets
|
||||
-- Associate each widget with a unit
|
||||
do
|
||||
-- Turn 1, row 1
|
||||
japanese_forces_widgets.force (shokaku_widget, game.shokaku)
|
||||
japanese_forces_widgets.force (zuikaku_widget, game.zuikaku)
|
||||
japanese_forces_widgets.force (akagi_widget, game.akagi)
|
||||
japanese_forces_widgets.force (kaga_widget, game.kaga)
|
||||
japanese_forces_widgets.force (soryu_widget, game.soryu)
|
||||
japanese_forces_widgets.force (hiryu_widget, game.hiryu)
|
||||
japanese_forces_widgets.force (ryujo_widget, game.ryujo)
|
||||
japanese_forces_widgets.force (hosho_widget, game.hosho)
|
||||
japanese_forces_widgets.force (zuiho_widget, game.zuiho)
|
||||
japanese_forces_widgets.force (mutsu_widget, game.mutsu)
|
||||
japanese_forces_widgets.force (nagato_widget, game.nagato)
|
||||
japanese_forces_widgets.force (fuso_widget, game.fuso)
|
||||
-- Turn 1, row 2
|
||||
japanese_forces_widgets.force (hyuga_widget, game.hyuga)
|
||||
japanese_forces_widgets.force (ise_widget, game.ise)
|
||||
japanese_forces_widgets.force (yamashiro_widget, game.yamashiro)
|
||||
japanese_forces_widgets.force (haruna_widget, game.haruna)
|
||||
japanese_forces_widgets.force (hiei_widget, game.hiei)
|
||||
japanese_forces_widgets.force (kirishima_widget, game.kirishima)
|
||||
japanese_forces_widgets.force (kongo_widget, game.kongo)
|
||||
japanese_forces_widgets.force (ashigara_widget, game.ashigara)
|
||||
japanese_forces_widgets.force (atago_widget, game.atago)
|
||||
japanese_forces_widgets.force (chokai_widget, game.chokai)
|
||||
japanese_forces_widgets.force (haguro_widget, game.haguro)
|
||||
japanese_forces_widgets.force (maya_widget, game.maya)
|
||||
-- Turn 1, row 3
|
||||
japanese_forces_widgets.force (myoko_widget, game.myoko)
|
||||
japanese_forces_widgets.force (nachi_widget, game.nachi)
|
||||
japanese_forces_widgets.force (takao_widget, game.takao)
|
||||
japanese_forces_widgets.force (chikuma_widget, game.chikuma)
|
||||
japanese_forces_widgets.force (kumano_widget, game.kumano)
|
||||
japanese_forces_widgets.force (mikuma_widget, game.mikuma)
|
||||
japanese_forces_widgets.force (mogami_widget, game.mogami)
|
||||
japanese_forces_widgets.force (suzuya_widget, game.suzuya)
|
||||
japanese_forces_widgets.force (tone_widget, game.tone)
|
||||
japanese_forces_widgets.force (aoba_widget, game.aoba)
|
||||
japanese_forces_widgets.force (furutaka_widget, game.furutaka)
|
||||
japanese_forces_widgets.force (kako_widget, game.kako)
|
||||
-- Turn 1, row 4
|
||||
japanese_forces_widgets.force (kinugasa_widget, game.kinugasa)
|
||||
japanese_forces_widgets.force (kitakami_widget, game.kitakami)
|
||||
japanese_forces_widgets.force (oi_widget, game.oi)
|
||||
japanese_forces_widgets.force (yokosuka_widget, game.yokosuka)
|
||||
-- Turn 1, also available
|
||||
japanese_forces_widgets.force (airflot_21_widget, game.airflot_21)
|
||||
japanese_forces_widgets.force (airflot_22_widget, game.airflot_22)
|
||||
japanese_forces_widgets.force (airflot_23_widget, game.airflot_23)
|
||||
japanese_forces_widgets.force (airflot_24_widget, game.airflot_24)
|
||||
japanese_forces_widgets.force (airflot_25_widget, game.airflot_25)
|
||||
japanese_forces_widgets.force (airflot_26_widget, game.airflot_26)
|
||||
japanese_forces_widgets.force (i_boat_widget, game.i_boat)
|
||||
-- Turn 2
|
||||
japanese_forces_widgets.force (shoho_widget, game.shoho)
|
||||
japanese_forces_widgets.force (junyo_widget, game.junyo)
|
||||
japanese_forces_widgets.force (sasebo_widget, game.sasebo)
|
||||
-- Turn 3
|
||||
japanese_forces_widgets.force (hiyo_widget, game.hiyo)
|
||||
japanese_forces_widgets.force (yamato_widget, game.yamato)
|
||||
japanese_forces_widgets.force (kure_widget, game.kure)
|
||||
-- Turn 5
|
||||
japanese_forces_widgets.force (musashi_widget, game.musashi)
|
||||
-- Turn 7
|
||||
japanese_forces_widgets.force (chiyoda_widget, game.chiyoda)
|
||||
japanese_forces_widgets.force (chitose_widget, game.chitose)
|
||||
japanese_forces_widgets.force (ryuho_widget, game.ryuho)
|
||||
japanese_forces_widgets.force (taiho_widget, game.taiho)
|
||||
-- Turn 8
|
||||
japanese_forces_widgets.force (unryu_widget, game.unryu)
|
||||
japanese_forces_widgets.force (amagi_widget, game.amagi)
|
||||
-- Turn 9
|
||||
japanese_forces_widgets.force (katsuragi_widget, game.katsuragi)
|
||||
japanese_forces_widgets.force (shinano_widget, game.shinano)
|
||||
end
|
||||
|
||||
fill_widgets
|
||||
-- Call `set_target' to give each widget a target.
|
||||
do
|
||||
-- Turn 1, row 1
|
||||
shokaku_widget.set_target (game.shokaku)
|
||||
zuikaku_widget.set_target (game.zuikaku)
|
||||
akagi_widget.set_target (game.akagi)
|
||||
kaga_widget.set_target (game.kaga)
|
||||
soryu_widget.set_target (game.soryu)
|
||||
hiryu_widget.set_target (game.hiryu)
|
||||
ryujo_widget.set_target (game.ryujo)
|
||||
hosho_widget.set_target (game.hosho)
|
||||
zuiho_widget.set_target (game.zuiho)
|
||||
mutsu_widget.set_target (game.mutsu)
|
||||
nagato_widget.set_target (game.nagato)
|
||||
fuso_widget.set_target (game.fuso)
|
||||
-- Turn 1, row 2
|
||||
hyuga_widget.set_target (game.hyuga)
|
||||
ise_widget.set_target (game.ise)
|
||||
yamashiro_widget.set_target (game.yamashiro)
|
||||
haruna_widget.set_target (game.haruna)
|
||||
hiei_widget.set_target (game.hiei)
|
||||
kirishima_widget.set_target (game.kirishima)
|
||||
kongo_widget.set_target (game.kongo)
|
||||
ashigara_widget.set_target (game.ashigara)
|
||||
atago_widget.set_target (game.atago)
|
||||
chokai_widget.set_target (game.chokai)
|
||||
haguro_widget.set_target (game.haguro)
|
||||
maya_widget.set_target (game.maya)
|
||||
-- Turn 1, row 3
|
||||
myoko_widget.set_target (game.myoko)
|
||||
nachi_widget.set_target (game.nachi)
|
||||
takao_widget.set_target (game.takao)
|
||||
chikuma_widget.set_target (game.chikuma)
|
||||
kumano_widget.set_target (game.kumano)
|
||||
mikuma_widget.set_target (game.mikuma)
|
||||
mogami_widget.set_target (game.mogami)
|
||||
suzuya_widget.set_target (game.suzuya)
|
||||
tone_widget.set_target (game.tone)
|
||||
aoba_widget.set_target (game.aoba)
|
||||
furutaka_widget.set_target (game.furutaka)
|
||||
kako_widget.set_target (game.kako)
|
||||
-- Turn 1, row 4
|
||||
kinugasa_widget.set_target (game.kinugasa)
|
||||
kitakami_widget.set_target (game.kitakami)
|
||||
oi_widget.set_target (game.oi)
|
||||
yokosuka_widget.set_target (game.yokosuka)
|
||||
-- Turn 1, also available
|
||||
airflot_21_widget.set_target (game.airflot_21)
|
||||
airflot_22_widget.set_target (game.airflot_22)
|
||||
airflot_23_widget.set_target (game.airflot_23)
|
||||
airflot_24_widget.set_target (game.airflot_24)
|
||||
airflot_25_widget.set_target (game.airflot_25)
|
||||
airflot_26_widget.set_target (game.airflot_26)
|
||||
i_boat_widget.set_target (game.i_boat)
|
||||
-- Turn 2
|
||||
shoho_widget.set_target (game.shoho)
|
||||
junyo_widget.set_target (game.junyo)
|
||||
sasebo_widget.set_target (game.sasebo)
|
||||
-- Turn 3
|
||||
hiyo_widget.set_target (game.hiyo)
|
||||
yamato_widget.set_target (game.yamato)
|
||||
kure_widget.set_target (game.kure)
|
||||
-- Turn 5
|
||||
musashi_widget.set_target (game.musashi)
|
||||
-- Turn 7
|
||||
chiyoda_widget.set_target (game.chiyoda)
|
||||
chitose_widget.set_target (game.chitose)
|
||||
ryuho_widget.set_target (game.ryuho)
|
||||
taiho_widget.set_target (game.taiho)
|
||||
i_boat_removal_widget.set_target (game.i_boat_removal)
|
||||
-- Turn 8
|
||||
unryu_widget.set_target (game.unryu)
|
||||
amagi_widget.set_target (game.amagi)
|
||||
-- Turn 9
|
||||
katsuragi_widget.set_target (game.katsuragi)
|
||||
shinano_widget.set_target (game.shinano)
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,374 @@
|
||||
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
|
77
jj_vitp/Interface/views/location_widgits_factory.e
Normal file
77
jj_vitp/Interface/views/location_widgits_factory.e
Normal file
@@ -0,0 +1,77 @@
|
||||
note
|
||||
description: "[
|
||||
One of the classes that decompose the numourous VITP widgets
|
||||
into more managable groups. This class models the widgets
|
||||
that contain the ports AND sea areas.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/15/24"
|
||||
copyright: "Copyright (c) 2024, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
|
||||
class
|
||||
LOCATION_WIDGITS_FACTORY
|
||||
|
||||
inherit
|
||||
|
||||
PORT_WIDGET_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
SEA_AREAS_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make_widgets
|
||||
-- Create the widgets in Current
|
||||
do
|
||||
create location_widgets.make (100)
|
||||
Precursor {PORT_WIDGET_FACTORY}
|
||||
Precursor {SEA_AREAS_FACTORY}
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
location_widgets: VITP_WIDGET_TABLE [LOCATION_WIDGET, LOCATION]
|
||||
-- Keeps track of widgets
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
extend_widgets
|
||||
-- Put each widget into `world'.
|
||||
do
|
||||
Precursor {PORT_WIDGET_FACTORY}
|
||||
Precursor {SEA_AREAS_FACTORY}
|
||||
location_widgets.merge (port_widgets)
|
||||
location_widgets.merge (sea_area_widgets)
|
||||
end
|
||||
|
||||
pair_widgets
|
||||
-- Associate each widget with a unit
|
||||
do
|
||||
Precursor {PORT_WIDGET_FACTORY}
|
||||
Precursor {SEA_AREAS_FACTORY}
|
||||
end
|
||||
|
||||
fill_widgets
|
||||
-- Call `set_target' to give each widget a target.
|
||||
do
|
||||
Precursor {PORT_WIDGET_FACTORY}
|
||||
Precursor {SEA_AREAS_FACTORY}
|
||||
end
|
||||
|
||||
end
|
888
jj_vitp/Interface/views/order_of_appearance_view.e
Normal file
888
jj_vitp/Interface/views/order_of_appearance_view.e
Normal file
@@ -0,0 +1,888 @@
|
||||
note
|
||||
description: "[
|
||||
Root class for the three order-of-appearance charts in
|
||||
the {VITP_GAME}.
|
||||
The position of the control points were obtained by measuring
|
||||
the phisical charts in millimeters from the edge or top.
|
||||
]"
|
||||
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)"
|
||||
|
||||
deferred class
|
||||
ORDER_OF_APPEARANCE_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
VITP_CELL_VIEW
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
add_actions,
|
||||
draw,
|
||||
set_target
|
||||
end
|
||||
|
||||
FONT_AND_COLOR_CONSTANTS
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create attributes
|
||||
do
|
||||
Precursor {VITP_CELL_VIEW}
|
||||
create widget_factory.make (game)
|
||||
create returning_air_widgets.make
|
||||
create returning_amphibious_widgets.make
|
||||
create flag.make (location)
|
||||
create big_marker.make (location)
|
||||
create little_marker.make (location)
|
||||
create background.make_with_points (top_left_cp, bottom_right_cp)
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up Current
|
||||
do
|
||||
-- Precursor creates the `world' and other previously-
|
||||
-- defined attributes
|
||||
Precursor {VITP_CELL_VIEW}
|
||||
set_minimum_size (ship_size * 14, ship_size * 16)
|
||||
build_flag
|
||||
build_markers
|
||||
add_widgets
|
||||
end
|
||||
|
||||
build_flag
|
||||
-- Set `flag' characteristics
|
||||
do
|
||||
flag.set_flat
|
||||
flag.show_outline
|
||||
end
|
||||
|
||||
build_markers
|
||||
-- Set the characteristics for `big_marker' and `little_marker'.
|
||||
do
|
||||
-- `big_marker'
|
||||
big_marker.scale (0.08)
|
||||
big_marker.show_boarder
|
||||
-- `little_marker'
|
||||
little_marker.scale (0.05)
|
||||
little_marker.hide_anchor
|
||||
little_marker.show_boarder
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Add a click event to the background
|
||||
do
|
||||
Precursor {VITP_CELL_VIEW}
|
||||
-- The next line does not work, I use the `background' to
|
||||
-- pick up the actions. I bet the event loop does not
|
||||
-- call this actions or a {EV_CELL_VIEW}?
|
||||
pointer_button_press_actions.extend (agent on_pressed)
|
||||
background.pointer_button_press_actions.extend (agent on_pressed)
|
||||
end
|
||||
|
||||
on_pressed (ax, ay, button: INTEGER;
|
||||
ax_tilt, ay_tilt, a_pressure: DOUBLE;
|
||||
a_screen_x, a_screen_y: INTEGER)
|
||||
-- Agent placed in the `background' retangle to allow the
|
||||
-- user to click, sending a message to the parent {CHART_TOOL}
|
||||
-- to set Current as the focused view.
|
||||
local
|
||||
pt: TOOL
|
||||
do
|
||||
io.put_string (generating_type.name + ".on_pressed: " + generating_type.name + "%N")
|
||||
pt := parent_tool
|
||||
check attached {CHART_TOOL} parent_tool as t then
|
||||
t.set_focused_view (Current)
|
||||
end
|
||||
end
|
||||
|
||||
add_widgets
|
||||
-- Add the attack widgets (e.g. Japanese attack widgets)
|
||||
-- to the view's `world' by calling the appropriate feature
|
||||
-- (e.g. `extend_allied_attack_unit_widgets', etc) from
|
||||
-- {WIDGET_FACTORY}.
|
||||
do
|
||||
add_background
|
||||
add_title
|
||||
add_top_markers
|
||||
add_turns
|
||||
add_return_boxes
|
||||
add_units
|
||||
add_returning_widgets
|
||||
add_miscellaneous_text
|
||||
add_starting_control_widgets
|
||||
add_copyright_text
|
||||
end
|
||||
|
||||
add_background
|
||||
-- Put a rectangle representing the paper of the chart.
|
||||
-- This is an attempt to get button press actions to get
|
||||
-- called so that he zoom-in/zoom-out buttons can be applied
|
||||
-- the the correct view in the enclosing {CHART_TOOL}
|
||||
do
|
||||
background.set_background_color (Light_grey)
|
||||
world.extend (background)
|
||||
end
|
||||
|
||||
add_title
|
||||
-- Put the title into Current
|
||||
local
|
||||
p: EV_COORDINATE
|
||||
t: EV_MODEL_TEXT
|
||||
do
|
||||
t := new_text (title, title_font)
|
||||
create p.make (middle_cp.x - t.width // 2 + 4, 4)
|
||||
t.set_point_position (p.x, p.y)
|
||||
world.extend (t)
|
||||
end
|
||||
|
||||
add_top_markers
|
||||
-- Add the circles or stars to the top of the chart
|
||||
local
|
||||
s, s2: STAR
|
||||
e, e2: EV_MODEL_ELLIPSE
|
||||
do
|
||||
if nationality = {NATIONALITY_CONSTANTS}.japanese then
|
||||
-- Create the red circles
|
||||
create e.make_with_positions (0, 0, 9, 9)
|
||||
create e2.make_with_positions (0, 0, 9, 9)
|
||||
e.set_x_y (26, 8)
|
||||
e2.set_x_y (240, 8)
|
||||
e.set_background_color (color)
|
||||
e.set_foreground_color (color)
|
||||
e2.set_background_color (color)
|
||||
e2.set_foreground_color (color)
|
||||
world.extend (e)
|
||||
world.extend (e2)
|
||||
else
|
||||
-- Create the blue stars
|
||||
create s
|
||||
create s2
|
||||
s.scale (0.08)
|
||||
s2.scale (0.08)
|
||||
s.set_x_y (26, 8)
|
||||
s2.set_x_y (240, 8)
|
||||
s.set_foreground_color (color)
|
||||
s.set_background_color (color)
|
||||
s2.set_foreground_color (color)
|
||||
s2.set_background_color (color)
|
||||
world.extend (s)
|
||||
world.extend (s2)
|
||||
end
|
||||
end
|
||||
|
||||
add_turns
|
||||
-- Add the "TURN X" and "TO x-date" text
|
||||
deferred
|
||||
-- Call `add_turn_text' a number of times
|
||||
end
|
||||
|
||||
add_turn_text (a_turn: INTEGER)
|
||||
-- Add the "TURN X" and TO_date_text
|
||||
local
|
||||
p: EV_COORDINATE
|
||||
t: EV_MODEL_TEXT
|
||||
s: STRING
|
||||
do
|
||||
s := "Turn " + a_turn.out
|
||||
if a_turn = 9 then
|
||||
s := s + " (Optional)"
|
||||
end
|
||||
p := turn_x_cp (a_turn)
|
||||
t := new_text (s, Turn_font)
|
||||
t.set_point_position (p.x, p.y)
|
||||
world.extend (t)
|
||||
t := new_text (turn_x_date (a_turn), To_date_font)
|
||||
t.set_point_position (p.x + 2, p.y + 8)
|
||||
world.extend (t)
|
||||
end
|
||||
|
||||
add_return_boxes
|
||||
-- Add the "Returning Air/Land Units" boxes
|
||||
do
|
||||
world.extend (new_box_widget ("Turn 1 Losses", Turn_1_losses_cp))
|
||||
world.extend (new_box_widget ("Turn 2 Losses", Turn_2_losses_cp))
|
||||
world.extend (new_box_widget ("Turn 3 Losses", Turn_3_losses_cp))
|
||||
world.extend (new_box_widget ("Turn 4 Losses", Turn_4_losses_cp))
|
||||
world.extend (new_box_widget ("Turn 5 Losses", Turn_5_losses_cp))
|
||||
world.extend (new_box_widget ("Turn 6 Losses", Turn_6_losses_cp))
|
||||
world.extend (new_box_widget ("Turn 7 Losses", Turn_7_losses_cp))
|
||||
end
|
||||
|
||||
add_miscellaneous_text
|
||||
-- Add other texts as necessary
|
||||
do
|
||||
end
|
||||
|
||||
add_starting_control_widgets
|
||||
-- Add the "Starting Control" text and markers if required
|
||||
do
|
||||
-- Add the markers, but hide them
|
||||
world.extend (flag)
|
||||
world.extend (big_marker)
|
||||
world.extend (little_marker)
|
||||
end
|
||||
|
||||
add_copyright_text
|
||||
-- Add the copy-right notices to each chart
|
||||
do
|
||||
end
|
||||
|
||||
new_text (a_text: STRING; a_font: EV_FONT): EV_MODEL_TEXT
|
||||
-- Create a new model from he parameters
|
||||
do
|
||||
create Result.make_with_text (a_text)
|
||||
Result.set_font (a_font)
|
||||
Result.set_foreground_color (color)
|
||||
end
|
||||
|
||||
new_text_widget (a_text: STRING; a_font: EV_FONT; a_point: EV_COORDINATE): EV_MODEL_TEXT
|
||||
-- Create a new model from the parameters
|
||||
do
|
||||
create Result.make_with_text (a_text)
|
||||
Result.set_font (a_font)
|
||||
Result.set_foreground_color (color)
|
||||
Result.set_point_position (a_point.x, a_point.y)
|
||||
end
|
||||
|
||||
new_box_widget (a_text: STRING; a_point: EV_COORDINATE): EV_MODEL_WORLD
|
||||
-- Create the "Returning Air/Land Units" box
|
||||
local
|
||||
w, mid: INTEGER
|
||||
lf, rt: INTEGER
|
||||
p1, p2: EV_COORDINATE
|
||||
rec: EV_MODEL_RECTANGLE
|
||||
mt, mt2: EV_MODEL_TEXT
|
||||
|
||||
g: EV_MODEL_GROUP
|
||||
use_2: BOOLEAN
|
||||
ret_s, ret_s2: STRING
|
||||
may_s, may_s2: STRING
|
||||
mt_ret, mt_turn, mt_may: EV_MODEL_TEXT
|
||||
correction: INTEGER
|
||||
do
|
||||
-- Make the box relative to `ship_size' and don't
|
||||
-- go beyond the implied border of the `background'
|
||||
create Result
|
||||
-- Get an x-point that is relative to right border
|
||||
w := 3 * ship_size
|
||||
rt := (a_point.x + w).min (background.point_b.x - 3 * gap_size)
|
||||
lf := (rt - w).max (a_point.x)
|
||||
create p1.make (lf, a_point.y)
|
||||
create p2.make (rt, a_point.y + ship_size)
|
||||
create rec.make_with_points (p1, p2)
|
||||
rec.set_foreground_color (color)
|
||||
rec.set_background_color (lightened (color, 2.8))
|
||||
Result.extend (rec)
|
||||
-- Build a group to hold all the text and center that
|
||||
-- group in the `rec'
|
||||
|
||||
ret_s := "RETURNING "
|
||||
ret_s2 := "AIR/LAND UNITS"
|
||||
may_s := "(may be placed in any friendly "
|
||||
may_s2 := "major port)"
|
||||
create g
|
||||
mt := new_text (ret_s + ret_s2, returning_units_font)
|
||||
if mt.width >= rec.width * 0.96 then
|
||||
-- Use two lines for some of the text
|
||||
use_2 := true
|
||||
end
|
||||
mt_turn := new_text (a_text, turn_x_losses_font)
|
||||
correction := 2
|
||||
if use_2 then
|
||||
-- Break text over two lines
|
||||
mt_ret := new_text (" " + ret_s + "%N" + ret_s2, returning_units_font)
|
||||
mt_ret.set_x_y (rec.x, rec.y - mt_ret.height // 2)
|
||||
mt_turn.set_x_y (rec.x, rec.y + correction)
|
||||
mt_may := new_text (may_s + "%N " + may_s2, may_be_placed_font)
|
||||
mt_may.set_x_y (rec.x - 2 * correction, mt_turn.y + mt_turn.height)
|
||||
else
|
||||
-- Use one line per text
|
||||
mt_ret := new_text (ret_s + ret_s2, returning_units_font)
|
||||
mt_ret.set_x_y (rec.x, rec.y - mt_ret.height)
|
||||
mt_turn.set_x_y (rec.x, rec.y + correction // 2)
|
||||
mt_may := new_text (may_s + may_s2, may_be_placed_font)
|
||||
mt_may.set_x_y (rec.x - 3 * correction, mt_turn.y + mt_turn.height)
|
||||
end
|
||||
Result.extend (mt_ret)
|
||||
Result.extend (mt_turn)
|
||||
Result.extend (mt_may)
|
||||
end
|
||||
|
||||
new_jagged_box (a_text: STRING; a_count_1, a_count_2, a_count_3: INTEGER; a_angle: REAL_64): EV_MODEL_GROUP
|
||||
-- Builds a three-sided box with jagged lines centered around
|
||||
-- `a_text' (intended for port names) for placement
|
||||
-- around the the port names in the "Starting Control".
|
||||
-- Each side (clockwise from top) consists of the number
|
||||
-- of triangles given by the parameters, then rotated `a_angle'.
|
||||
-- require
|
||||
-- count_big_enough: a_count >= 1
|
||||
-- count_small_enough: a_count <= 8
|
||||
local
|
||||
i: INTEGER
|
||||
a: ARRAY [EV_COORDINATE]
|
||||
poly: EV_MODEL_POLYGON
|
||||
t: EV_MODEL_TEXT
|
||||
p1, p2, p3: EV_COORDINATE
|
||||
w, h: INTEGER
|
||||
do
|
||||
create Result
|
||||
-- create a.make_empty
|
||||
-- Build big trianges and then scale down.
|
||||
w := 60
|
||||
h := w // 2
|
||||
create p1
|
||||
create p2
|
||||
create p3
|
||||
a := <<p1, p2, p3>>
|
||||
-- Make the first (i.e. top) line
|
||||
from i := 1
|
||||
until i > a_count_1
|
||||
loop
|
||||
create p1.set (p2.x, p2.y)
|
||||
create p2.set (p1.x + w, p1.y)
|
||||
create p3.set (p1.x + h, p1.y - h)
|
||||
a := <<p1, p2, p3>>
|
||||
create poly.make_with_coordinates (a)
|
||||
poly.set_foreground_color (color)
|
||||
poly.set_background_color (color)
|
||||
Result.extend (poly)
|
||||
i := i + 1
|
||||
end
|
||||
-- Make the second (i.e. right) line
|
||||
from i := 1
|
||||
until i > a_count_2
|
||||
loop
|
||||
create p1.set (p2.x, p2.y)
|
||||
create p2.set (p1.x, p1.y + w)
|
||||
create p3.set (p1.x + h, p1.y + h)
|
||||
a := <<p1, p2, p3>>
|
||||
create poly.make_with_coordinates (a)
|
||||
poly.set_foreground_color (color)
|
||||
poly.set_background_color (color)
|
||||
Result.extend (poly)
|
||||
i := i + 1
|
||||
end
|
||||
-- Make the third (i.e. bottom) line
|
||||
from i := 1
|
||||
until i > a_count_3
|
||||
loop
|
||||
create p1.set (p2.x, p2.y)
|
||||
create p2.set (p1.x - w, p1.y)
|
||||
create p3.set (p1.x - h, p1.y + h)
|
||||
a := <<p1, p2, p3>>
|
||||
create poly.make_with_coordinates (a)
|
||||
poly.set_foreground_color (color)
|
||||
poly.set_background_color (color)
|
||||
Result.extend (poly)
|
||||
i := i + 1
|
||||
end
|
||||
Result.scale (0.05)
|
||||
Result.rotate (a_angle)
|
||||
t := new_text (a_text, may_be_placed_font)
|
||||
-- not quite centered so subtract a correction
|
||||
Result.set_x_y (t.x, t.y - gap_size)
|
||||
Result.extend (t)
|
||||
end
|
||||
|
||||
add_units
|
||||
-- Add {ATTACK_UNIT_WIDGETS} to Current
|
||||
do
|
||||
end
|
||||
|
||||
add_returning_widgets
|
||||
-- Adds an {AIR_UNIT_WIDGET} and an {AMPHIBIOUS_UNIT_WIDGET}
|
||||
-- to possibly hold a returning unit. This widgets are NOT
|
||||
-- initially empty. They are targetted, positioned and
|
||||
-- shown/hidden in feature `draw'.
|
||||
local
|
||||
i: INTEGER
|
||||
air_w: AIR_UNIT_WIDGET
|
||||
amp_w: AMPHIBIOUS_UNIT_WIDGET
|
||||
do
|
||||
-- There is a maximum of ten air units that can
|
||||
-- return on any given turn.
|
||||
from i := 1
|
||||
until i > 10
|
||||
loop
|
||||
-- Can not be empty
|
||||
create air_w.make (game.airflot_21)
|
||||
returning_air_widgets.extend (air_w)
|
||||
world.extend (air_w)
|
||||
air_w.hide
|
||||
i := i + 1
|
||||
end
|
||||
-- There is a maximum of four amphibious units that can
|
||||
-- return on any given turn.
|
||||
from i := 1
|
||||
until i > 4
|
||||
loop
|
||||
-- Can not be empty
|
||||
create amp_w.make (game.yokosuka)
|
||||
returning_amphibious_widgets.extend (amp_w)
|
||||
world.extend (amp_w)
|
||||
amp_w.hide
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
positioned_widget (a_widget: ATTACK_UNIT_WIDGET; a_point: EV_COORDINATE): ATTACK_UNIT_WIDGET
|
||||
-- The `a_widget' after positioning it at `a_point'
|
||||
do
|
||||
Result := a_widget
|
||||
Result.set_point_position (a_point.x, a_point.y)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
widget_factory: WIDGET_FACTORY
|
||||
-- Creator and repository for widgets in this view
|
||||
|
||||
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.)
|
||||
deferred
|
||||
ensure
|
||||
valid_result: Result = game.japanese_oa_chart or
|
||||
Result = game.allied_oa_chart or
|
||||
Result = game.allied_starting_forces_chart
|
||||
end
|
||||
|
||||
nationality: INTEGER
|
||||
-- The nationality of the unit on this chart
|
||||
|
||||
color: EV_COLOR
|
||||
-- The main color used for the text in Current
|
||||
do
|
||||
if nationality = {NATIONALITY_CONSTANTS}.japanese then
|
||||
Result := (create {FONT_AND_COLOR_CONSTANTS}).Japanese_unit_color
|
||||
else
|
||||
Result := (create {FONT_AND_COLOR_CONSTANTS}).us_unit_color
|
||||
end
|
||||
end
|
||||
|
||||
title: STRING
|
||||
-- The text at top of this chart
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_item: like game)
|
||||
-- Associate `a_item' with Current.
|
||||
do
|
||||
Precursor (a_item)
|
||||
widget_factory.set_game (a_item)
|
||||
-- The unit widgets come from `game', so must wait
|
||||
-- until calling this feature to add them to Current.
|
||||
-- (i.e. do not add them in `initialize')
|
||||
-- NO, that is wrong. We do not make new widget when
|
||||
-- targetting to a new game, we just repair the widgets
|
||||
-- to the new units.
|
||||
-- Make the flag color itself based on location's owner
|
||||
flag.set_location (location)
|
||||
-- big_marker.set_target (location)
|
||||
-- little_marker.set_target (location)
|
||||
big_marker.set_location (location)
|
||||
little_marker.set_location (location)
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Redraw the view
|
||||
local
|
||||
-- t: VITP_WIDGET_TABLE [ATTACK_UNIT_WIDGET, ATTACK_UNIT]
|
||||
w: ATTACK_UNIT_WIDGET
|
||||
u: ATTACK_UNIT
|
||||
i: INTEGER
|
||||
do
|
||||
-- Replace this with call to `notify_views'
|
||||
-- check attached {VITP_WIDGET_TABLE [ATTACK_UNIT_WIDGET, ATTACK_UNIT]} world.widgets as t then
|
||||
-- -- because of select clause
|
||||
---- t := world.widgets
|
||||
-- from t.start
|
||||
-- until t.after
|
||||
-- loop
|
||||
-- w := t.item_for_iteration
|
||||
-- u := t.key_for_iteration
|
||||
-- if u.location = location then
|
||||
-- w.set_unflipped
|
||||
-- w.set_raised
|
||||
-- else
|
||||
-- w.set_flipped
|
||||
-- w.set_flat
|
||||
-- end
|
||||
-- t.forth
|
||||
-- end
|
||||
-- end
|
||||
-- Place any returning air & amphibious units
|
||||
if not is_view_empty then
|
||||
from i := 3
|
||||
until i > 9
|
||||
loop
|
||||
place_returning_air (i)
|
||||
place_returning_amphibious (i)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
flag.paint
|
||||
Precursor {VITP_CELL_VIEW}
|
||||
end
|
||||
|
||||
place_returning_air (a_turn: INTEGER)
|
||||
-- Place any returning air units at proper place
|
||||
require
|
||||
turn_big_enough: a_turn >= 3
|
||||
turn_small_enough: a_turn <= 9
|
||||
local
|
||||
t: VITP_TABLE [AIR_UNIT]
|
||||
i: INTEGER
|
||||
u: AIR_UNIT
|
||||
w: AIR_UNIT_WIDGET
|
||||
cp: EV_COORDINATE
|
||||
do
|
||||
if nationality = {NATIONALITY_CONSTANTS}.japanese then
|
||||
t := game.returning_japanese_air_units (a_turn)
|
||||
else
|
||||
t := game.returning_allied_air_units (a_turn)
|
||||
end
|
||||
create cp
|
||||
i := 1
|
||||
from t.start
|
||||
until t.after
|
||||
loop
|
||||
u := t.item_for_iteration
|
||||
w := returning_air_widgets.i_th (i)
|
||||
w.set_target (u)
|
||||
w.show
|
||||
-- position the widget based on turn
|
||||
cp := turn_x_cp (a_turn)
|
||||
cp.set_position (cp.x + a_turn * air_size, cp.y + gap_size)
|
||||
w.set_point_position (cp.x, cp.y)
|
||||
t.forth
|
||||
i := i + 1
|
||||
end
|
||||
-- Now hide remaining (i.e. extra) widgets
|
||||
from
|
||||
until i > returning_air_widgets.count
|
||||
loop
|
||||
returning_air_widgets.i_th (i).hide
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
place_returning_amphibious (a_turn: INTEGER)
|
||||
-- Place any returning amphibious units at proper place
|
||||
require
|
||||
turn_big_enough: a_turn >= 3
|
||||
turn_small_enough: a_turn <= 9
|
||||
local
|
||||
t: VITP_TABLE [AMPHIBIOUS_UNIT]
|
||||
i: INTEGER
|
||||
u: AMPHIBIOUS_UNIT
|
||||
w: AMPHIBIOUS_UNIT_WIDGET
|
||||
cp: EV_COORDINATE
|
||||
do
|
||||
if nationality = {NATIONALITY_CONSTANTS}.japanese then
|
||||
t := game.returning_japanese_amphibious_units (a_turn)
|
||||
else
|
||||
t := game.returning_allied_amphibious_units (a_turn)
|
||||
end
|
||||
create cp
|
||||
i := 1
|
||||
from t.start
|
||||
until t.after
|
||||
loop
|
||||
u := t.item_for_iteration
|
||||
w := returning_amphibious_widgets.i_th (i)
|
||||
w.set_target (u)
|
||||
w.show
|
||||
-- position the widget based on turn
|
||||
cp := turn_x_cp (a_turn)
|
||||
cp.set_position (cp.x + a_turn * air_size, cp.y + 2 * gap_size + air_size)
|
||||
w.set_point_position (cp.x, cp.y)
|
||||
t.forth
|
||||
i := i + 1
|
||||
end
|
||||
-- Now hide remaining (i.e. extra) widgets
|
||||
from
|
||||
until i > returning_amphibious_widgets.count
|
||||
loop
|
||||
-- returning_amphibious_widgets.item.hide
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
flag: FLAG
|
||||
-- The flag that is one of the "Starting Control" widgets
|
||||
|
||||
big_marker: CONTROL_MARKER
|
||||
-- The larger of the two port control markers, that is
|
||||
-- part the "Starting Control" widgets.
|
||||
|
||||
little_marker: CONTROL_MARKER
|
||||
-- The larger of the two port control markers, that is
|
||||
-- part the "Starting Control" widgets.
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
returning_air_widgets: LINKED_LIST [AIR_UNIT_WIDGET]
|
||||
-- List of widgets which can hold any returning air units
|
||||
-- Built up in `draw'
|
||||
|
||||
returning_amphibious_widgets: LINKED_LIST [AMPHIBIOUS_UNIT_WIDGET]
|
||||
-- List of widgets which can hold any returning amphibious unit
|
||||
|
||||
background: EV_MODEL_RECTANGLE --attribute create Result.make_with_points (top_left_cp, bottom_right_cp) end
|
||||
-- Represents the paper of the chart and provides a
|
||||
-- clickable area for selection of Current to pass on
|
||||
-- a click event to the containing {CHART_TOOL} so that
|
||||
-- the zoom-in/zoom-out buttons will work.
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
turn_x_cp (a_turn: INTEGER): EV_COORDINATE
|
||||
-- The control point for the "TURN X" text for `a_turn'
|
||||
require
|
||||
turn_big_enough: a_turn >= 1
|
||||
turn_small_enough: a_turn <= 9
|
||||
do
|
||||
inspect a_turn
|
||||
when 1 then
|
||||
Result := Turn_1_cp
|
||||
when 2 then
|
||||
Result := Turn_2_cp
|
||||
when 3 then
|
||||
Result := Turn_3_cp
|
||||
when 4 then
|
||||
Result := Turn_4_cp
|
||||
when 5 then
|
||||
Result := Turn_5_cp
|
||||
when 6 then
|
||||
Result := Turn_6_cp
|
||||
when 7 then
|
||||
Result := Turn_7_cp
|
||||
when 8 then
|
||||
Result := Turn_8_cp
|
||||
when 9 then
|
||||
Result := Turn_9_cp
|
||||
else
|
||||
check
|
||||
should_not_happen: False
|
||||
-- because of precondition
|
||||
end
|
||||
create Result
|
||||
end
|
||||
end
|
||||
|
||||
turn_x_date (a_turn: INTEGER): STRING
|
||||
-- The date (e.g. "TO DEMCEMBER 1941", etc) corresponding to
|
||||
-- turn number `a_turn
|
||||
require
|
||||
turn_big_enough: a_turn >= 1
|
||||
turn_small_enough: a_turn <= 9
|
||||
do
|
||||
inspect a_turn
|
||||
when 1 then
|
||||
Result := Turn_1_date
|
||||
when 2 then
|
||||
Result := Turn_2_date
|
||||
when 3 then
|
||||
Result := Turn_3_date
|
||||
when 4 then
|
||||
Result := Turn_4_date
|
||||
when 5 then
|
||||
Result := Turn_5_date
|
||||
when 6 then
|
||||
Result := Turn_6_date
|
||||
when 7 then
|
||||
Result := Turn_7_date
|
||||
when 8 then
|
||||
Result := Turn_8_date
|
||||
when 9 then
|
||||
Result := Turn_9_date
|
||||
else
|
||||
check
|
||||
should_not_happen: False
|
||||
-- because of precondition
|
||||
end
|
||||
Result := ""
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
title_font: EV_FONT
|
||||
once
|
||||
create Result
|
||||
Result.set_height (9)
|
||||
Result.set_weight ({EV_FONT_CONSTANTS}.Weight_bold)
|
||||
end
|
||||
|
||||
turn_font: EV_FONT
|
||||
once
|
||||
create Result
|
||||
Result.set_height (9)
|
||||
Result.set_weight ({EV_FONT_CONSTANTS}.Weight_bold)
|
||||
end
|
||||
|
||||
to_date_font: EV_FONT
|
||||
once
|
||||
create Result
|
||||
Result.set_height (3)
|
||||
Result.set_weight ({EV_FONT_CONSTANTS}.Weight_bold)
|
||||
end
|
||||
|
||||
at_port_font: EV_FONT
|
||||
once
|
||||
create Result
|
||||
Result.set_height (5)
|
||||
Result.set_weight ({EV_FONT_CONSTANTS}.Weight_bold)
|
||||
end
|
||||
|
||||
returning_units_font: EV_FONT
|
||||
once
|
||||
create Result
|
||||
Result.set_height (4)
|
||||
Result.set_weight ({EV_FONT_CONSTANTS}.Weight_bold)
|
||||
end
|
||||
|
||||
turn_x_losses_font: EV_FONT
|
||||
once
|
||||
create Result
|
||||
Result.set_height (3)
|
||||
Result.set_weight ({EV_FONT_CONSTANTS}.Weight_bold)
|
||||
end
|
||||
|
||||
may_be_placed_font: EV_FONT
|
||||
once
|
||||
create Result
|
||||
Result.set_height (3)
|
||||
-- Result.set_weight ({EV_FONT_CONSTANTS}.Weight_bold)
|
||||
end
|
||||
|
||||
may_be_placed_italic_font: EV_FONT
|
||||
once
|
||||
create Result
|
||||
Result.set_height (3)
|
||||
Result.set_shape ({EV_FONT_CONSTANTS}.shape_italic)
|
||||
end
|
||||
|
||||
small_font: EV_FONT
|
||||
once
|
||||
create Result
|
||||
Result.set_height (2)
|
||||
end
|
||||
|
||||
returning_units_box_color: EV_COLOR
|
||||
-- The [lighter] color used for the backgroun of the
|
||||
-- "Returning Air/Land Units" boxes
|
||||
do
|
||||
if nationality = {NATIONALITY_CONSTANTS}.japanese then
|
||||
Result := Japanese_unit_color_dim
|
||||
else
|
||||
Result := US_unit_color_dim
|
||||
end
|
||||
end
|
||||
|
||||
Returning_units_text: STRING = "RETURNING AIR/LAND UNITS"
|
||||
-- Text placed in the returning units boxes
|
||||
|
||||
May_be_placed_text: String = "may be placed in any friendly major port"
|
||||
-- More text for the returning units boxes
|
||||
|
||||
turn_1_date: STRING = "TO DECEMBER 1941"
|
||||
-- Date placed near the "TURN 1" text
|
||||
|
||||
turn_2_date: STRING = "TO MAY 1942"
|
||||
-- Date placed near the "TURN 1" text
|
||||
|
||||
turn_3_date: STRING = "TO SEPTEMBER 1942"
|
||||
-- Date placed near the "TURN 1" text
|
||||
|
||||
turn_4_date: STRING = "TO JANUARY 1943"
|
||||
-- Date placed near the "TURN 1" text
|
||||
|
||||
turn_5_date: STRING = "TO JUNE 1943"
|
||||
-- Date placed near the "TURN 1" text
|
||||
|
||||
turn_6_date: STRING = "TO JANUARY 1944"
|
||||
-- Date placed near the "TURN 1" text
|
||||
|
||||
turn_7_date: STRING = "TO MAY 1944"
|
||||
-- Date placed near the "TURN 1" text
|
||||
|
||||
turn_8_date: STRING = "TO OCTOBER 1944"
|
||||
-- Date placed near the "TURN 1" text
|
||||
|
||||
turn_9_date: STRING = "TO JANUARY 1945"
|
||||
-- Date placed near the "TURN 1" text
|
||||
|
||||
feature {NONE} -- Implementation (control points in millimeters)
|
||||
|
||||
top_left_cp: EV_COORDINATE once create Result.make (0, 0) end
|
||||
bottom_right_cp: EV_COORDINATE deferred end
|
||||
middle_cp: EV_COORDINATE do create Result.make (bottom_right_cp.x // 2, bottom_right_cp.y // 2) end
|
||||
-- Turn X text
|
||||
turn_1_cp: EV_COORDINATE deferred end
|
||||
turn_2_cp: EV_COORDINATE deferred end
|
||||
turn_3_cp: EV_COORDINATE deferred end
|
||||
turn_4_cp: EV_COORDINATE deferred end
|
||||
turn_5_cp: EV_COORDINATE deferred end
|
||||
turn_6_cp: EV_COORDINATE deferred end
|
||||
turn_7_cp: EV_COORDINATE deferred end
|
||||
turn_8_cp: EV_COORDINATE deferred end
|
||||
turn_9_cp: EV_COORDINATE deferred end
|
||||
-- To some date text
|
||||
to_dec_41_cp: EV_COORDINATE deferred end
|
||||
to_may_42_cp: EV_COORDINATE deferred end
|
||||
to_sep_42_cp: EV_COORDINATE deferred end
|
||||
to_jan_43_cp: EV_COORDINATE deferred end
|
||||
to_jun_43_cp: EV_COORDINATE deferred end
|
||||
to_jan_44_cp: EV_COORDINATE deferred end
|
||||
to_may_44_cp: EV_COORDINATE deferred end
|
||||
to_oct_44_cp: EV_COORDINATE deferred end
|
||||
to_jan_45_cp: EV_COORDINATE deferred end
|
||||
-- Turn x losses
|
||||
turn_1_losses_cp: EV_COORDINATE deferred end
|
||||
turn_2_losses_cp: EV_COORDINATE deferred end
|
||||
turn_3_losses_cp: EV_COORDINATE deferred end
|
||||
turn_4_losses_cp: EV_COORDINATE deferred end
|
||||
turn_5_losses_cp: EV_COORDINATE deferred end
|
||||
turn_6_losses_cp: EV_COORDINATE deferred end
|
||||
turn_7_losses_cp: EV_COORDINATE deferred end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
gap_size: INTEGER = 2
|
||||
-- To add a small gap between widgets
|
||||
|
||||
ship_size: INTEGER
|
||||
-- Size of a [square] ship widget
|
||||
once
|
||||
-- Result := {SHIP_WIDGET}.default_tile_size.rounded
|
||||
check attached {SHIP_WIDGET} widget_factory.widgets.item (game.akagi) as w then
|
||||
Result := w.tile_size.rounded
|
||||
end
|
||||
end
|
||||
|
||||
air_size: INTEGER
|
||||
-- Size of a [square] air unit widget
|
||||
once
|
||||
-- Result := ({SHIP_WIDGET}.default_tile_size * 0.7).rounded
|
||||
check attached {AIR_UNIT_WIDGET} widget_factory.widgets.item (game.airflot_21) as w then
|
||||
Result := w.tile_size.rounded
|
||||
end
|
||||
end
|
||||
|
||||
end
|
177
jj_vitp/Interface/views/port_widget_factory.e
Normal file
177
jj_vitp/Interface/views/port_widget_factory.e
Normal file
@@ -0,0 +1,177 @@
|
||||
note
|
||||
description: "[
|
||||
One of the classes that decompose the numourous VITP widgets
|
||||
into more managable groups. This class models the widgets
|
||||
that contain the ports.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/15/24"
|
||||
copyright: "Copyright (c) 2024, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
class
|
||||
PORT_WIDGET_FACTORY
|
||||
|
||||
inherit
|
||||
|
||||
WIDGET_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_widgets
|
||||
-- Create widgets for the corresponding game item
|
||||
do
|
||||
Precursor {WIDGET_FACTORY}
|
||||
create port_widgets.make (100)
|
||||
-- Create widgets
|
||||
create andaman_islands_widget.make (game.andaman_islands)
|
||||
create attu_widget.make (game.attu)
|
||||
create australia_widget.make (game.australia)
|
||||
create ceylon_widget.make (game.ceylon)
|
||||
create dutch_harbor_widget.make (game.dutch_harbor)
|
||||
create guadalcanal_widget.make (game.guadalcanal)
|
||||
create johnston_island_widget.make (game.johnston_island)
|
||||
create kwajalein_widget.make (game.kwajalein)
|
||||
create lae_widget.make (game.lae)
|
||||
create maloelap_widget.make (game.maloelap)
|
||||
create midway_widget.make (game.midway)
|
||||
create new_hebrides_widget.make (game.new_hebrides)
|
||||
create okinawa_widget.make (game.okinawa)
|
||||
create pearl_harbor_widget.make (game.pearl_harbor)
|
||||
create philippines_widget.make (game.philippines)
|
||||
create port_moresby_widget.make (game.port_moresby)
|
||||
create saigon_widget.make (game.saigon)
|
||||
create saipan_widget.make (game.saipan)
|
||||
create samoa_widget.make (game.samoa)
|
||||
create singapore_widget.make (game.singapore)
|
||||
create truk_widget.make (game.truk)
|
||||
create yokosuka_navy_yard_widget.make (game.yokosuka_navy_yard)
|
||||
end
|
||||
|
||||
feature -- Access (tables)
|
||||
|
||||
port_widgets: VITP_WIDGET_TABLE [PORT_WIDGET, PORT]
|
||||
-- Keeps track of widgets
|
||||
|
||||
feature -- Access (ports)
|
||||
|
||||
Andaman_islands_widget: ANDAMAN_ISLANDS_WIDGET
|
||||
Attu_widget: ATTU_WIDGET
|
||||
Australia_widget: AUSTRALIA_WIDGET
|
||||
Ceylon_widget: CEYLON_WIDGET
|
||||
Dutch_harbor_widget: DUTCH_HARBOR_WIDGET
|
||||
Guadalcanal_widget: GUADALCANAL_WIDGET
|
||||
Johnston_island_widget: JOHNSTON_ISLAND_WIDGET
|
||||
Kwajalein_widget: KWAJALEIN_WIDGET
|
||||
Lae_widget: LAE_WIDGET
|
||||
Maloelap_widget: MALOELAP_WIDGET
|
||||
Midway_widget: MIDWAY_WIDGET
|
||||
New_hebrides_widget: NEW_HEBRIDES_WIDGET
|
||||
Okinawa_widget: OKINAWA_WIDGET
|
||||
Pearl_harbor_widget: PEARL_HARBOR_WIDGET
|
||||
Philippines_widget: PHILIPPINES_WIDGET
|
||||
Port_moresby_widget: PORT_MORESBY_WIDGET
|
||||
Saigon_widget: SAIGON_WIDGET
|
||||
Saipan_widget: SAIPAN_WIDGET
|
||||
Samoa_widget: SAMOA_WIDGET
|
||||
Singapore_widget: SINGAPORE_WIDGET
|
||||
Truk_widget: TRUK_WIDGET
|
||||
Yokosuka_navy_yard_widget: YOKOSUKA_NAVY_YARD_WIDGET
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
extend_widgets
|
||||
-- Put each widget {ATTACK_UNIT_WIDGET} into `world'.
|
||||
do
|
||||
port_widgets.extend (Andaman_islands_widget, game.Andaman_islands)
|
||||
port_widgets.extend (Attu_widget, game.Attu)
|
||||
port_widgets.extend (Australia_widget, game.Australia)
|
||||
port_widgets.extend (Ceylon_widget, game.Ceylon)
|
||||
port_widgets.extend (Dutch_harbor_widget, game.Dutch_harbor)
|
||||
port_widgets.extend (Guadalcanal_widget, game.Guadalcanal)
|
||||
port_widgets.extend (Johnston_island_widget, game.Johnston_island)
|
||||
port_widgets.extend (Kwajalein_widget, game.Kwajalein)
|
||||
port_widgets.extend (Lae_widget, game.Lae)
|
||||
port_widgets.extend (Maloelap_widget, game.Maloelap)
|
||||
port_widgets.extend (Midway_widget, game.Midway)
|
||||
port_widgets.extend (New_hebrides_widget, game.New_hebrides)
|
||||
port_widgets.extend (Okinawa_widget, game.Okinawa)
|
||||
port_widgets.extend (Pearl_harbor_widget, game.Pearl_harbor)
|
||||
port_widgets.extend (Philippines_widget, game.Philippines)
|
||||
port_widgets.extend (Port_moresby_widget, game.Port_moresby)
|
||||
port_widgets.extend (Saigon_widget, game.Saigon)
|
||||
port_widgets.extend (Saipan_widget, game.Saipan)
|
||||
port_widgets.extend (Samoa_widget, game.Samoa)
|
||||
port_widgets.extend (Singapore_widget, game.Singapore)
|
||||
port_widgets.extend (Truk_widget, game.Truk)
|
||||
port_widgets.extend (Yokosuka_navy_yard_widget, game.Yokosuka_navy_yard)
|
||||
widgets.merge (port_widgets)
|
||||
end
|
||||
|
||||
pair_widgets
|
||||
-- Associate each widget with a unit
|
||||
do
|
||||
port_widgets.force (Andaman_islands_widget, game.Andaman_islands)
|
||||
port_widgets.force (Attu_widget, game.Attu)
|
||||
port_widgets.force (Australia_widget, game.Australia)
|
||||
port_widgets.force (Ceylon_widget, game.Ceylon)
|
||||
port_widgets.force (Dutch_harbor_widget, game.Dutch_harbor)
|
||||
port_widgets.force (Guadalcanal_widget, game.Guadalcanal)
|
||||
port_widgets.force (Johnston_island_widget, game.Johnston_island)
|
||||
port_widgets.force (Kwajalein_widget, game.Kwajalein)
|
||||
port_widgets.force (Lae_widget, game.Lae)
|
||||
port_widgets.force (Maloelap_widget, game.Maloelap)
|
||||
port_widgets.force (Midway_widget, game.Midway)
|
||||
port_widgets.force (New_hebrides_widget, game.New_hebrides)
|
||||
port_widgets.force (Okinawa_widget, game.Okinawa)
|
||||
port_widgets.force (Pearl_harbor_widget, game.Pearl_harbor)
|
||||
port_widgets.force (Philippines_widget, game.Philippines)
|
||||
port_widgets.force (Port_moresby_widget, game.Port_moresby)
|
||||
port_widgets.force (Saigon_widget, game.Saigon)
|
||||
port_widgets.force (Saipan_widget, game.Saipan)
|
||||
port_widgets.force (Samoa_widget, game.Samoa)
|
||||
port_widgets.force (Singapore_widget, game.Singapore)
|
||||
port_widgets.force (Truk_widget, game.Truk)
|
||||
port_widgets.force (Yokosuka_navy_yard_widget, game.Yokosuka_navy_yard)
|
||||
ensure then
|
||||
port_count_correct: port_widgets.count = 22
|
||||
-- ports_paired: across port_widgets as pw all pw.item.vitp = vitp end
|
||||
end
|
||||
|
||||
fill_widgets
|
||||
-- Call `set_target' to give each widget a target.
|
||||
do
|
||||
Andaman_islands_widget.set_target (game.andaman_islands)
|
||||
Attu_widget.set_target (game.attu)
|
||||
Australia_widget.set_target (game.australia)
|
||||
Ceylon_widget.set_target (game.ceylon)
|
||||
Dutch_harbor_widget.set_target (game.dutch_harbor)
|
||||
Guadalcanal_widget.set_target (game.guadalcanal)
|
||||
Johnston_island_widget.set_target (game.johnston_island)
|
||||
Kwajalein_widget.set_target (game.kwajalein)
|
||||
Lae_widget.set_target (game.lae)
|
||||
Maloelap_widget.set_target (game.maloelap)
|
||||
Midway_widget.set_target (game.midway)
|
||||
New_hebrides_widget.set_target (game.new_hebrides)
|
||||
Okinawa_widget.set_target (game.okinawa)
|
||||
Pearl_harbor_widget.set_target (game.pearl_harbor)
|
||||
Philippines_widget.set_target (game.philippines)
|
||||
Port_moresby_widget.set_target (game.port_moresby)
|
||||
Saigon_widget.set_target (game.saigon)
|
||||
Saipan_widget.set_target (game.saipan)
|
||||
Samoa_widget.set_target (game.samoa)
|
||||
Singapore_widget.set_target (game.singapore)
|
||||
Truk_widget.set_target (game.truk)
|
||||
Yokosuka_navy_yard_widget.set_target (game.yokosuka_navy_yard)
|
||||
end
|
||||
|
||||
end
|
129
jj_vitp/Interface/views/sea_areas_factory.e
Normal file
129
jj_vitp/Interface/views/sea_areas_factory.e
Normal file
@@ -0,0 +1,129 @@
|
||||
note
|
||||
description: "[
|
||||
One of the classes that decompose the numourous VITP widgets
|
||||
into more managable groups. This class models the widgets
|
||||
that contain the sea areas.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/15/24"
|
||||
copyright: "Copyright (c) 2024, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
class
|
||||
SEA_AREAS_FACTORY
|
||||
|
||||
inherit
|
||||
|
||||
WIDGET_FACTORY
|
||||
redefine
|
||||
make_widgets,
|
||||
extend_widgets,
|
||||
pair_widgets,
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_widgets
|
||||
-- Create widgets for the corresponding game item
|
||||
do
|
||||
Precursor {WIDGET_FACTORY}
|
||||
create sea_area_widgets.make (100)
|
||||
-- Create widgets
|
||||
create aleutian_islands_widget.make (game.aleutian_islands)
|
||||
create bay_of_bengal_widget.make (game.bay_of_bengal)
|
||||
create central_pacific_ocean_widget.make (game.central_pacific_ocean)
|
||||
create coral_sea_widget.make (game.coral_sea)
|
||||
create hawaiian_islands_widget.make (game.hawaiian_islands)
|
||||
create indian_ocean_widget.make (game.indian_ocean)
|
||||
create indonesia_widget.make (game.indonesia)
|
||||
create japanese_islands_widget.make (game.japanese_islands)
|
||||
create marianas_islands_widget.make (game.marianas_islands)
|
||||
create marshall_islands_widget.make (game.marshall_islands)
|
||||
create north_pacific_ocean_widget.make (game.north_pacific_ocean)
|
||||
create south_pacific_ocean_widget.make (game.south_pacific_ocean)
|
||||
create us_mandate_widget.make (game.us_mandate)
|
||||
end
|
||||
|
||||
feature -- Access (tables)
|
||||
|
||||
sea_area_widgets: VITP_WIDGET_TABLE [SEA_AREA_WIDGET, SEA_AREA]
|
||||
-- Keeps track of sea-area widgets
|
||||
|
||||
feature -- Access (sea area widgets)
|
||||
|
||||
aleutian_islands_widget: ALEUTIAN_ISLANDS_WIDGET
|
||||
bay_of_bengal_widget: BAY_OF_BENGAL_WIDGET
|
||||
central_pacific_ocean_widget: CENTRAL_PACIFIC_OCEAN_WIDGET
|
||||
coral_sea_widget: CORAL_SEA_WIDGET
|
||||
hawaiian_islands_widget: HAWAIIAN_ISLANDS_WIDGET
|
||||
indian_ocean_widget: INDIAN_OCEAN_WIDGET
|
||||
indonesia_widget: INDONESIA_WIDGET
|
||||
japanese_islands_widget: JAPANESE_ISLANDS_WIDGET
|
||||
marianas_islands_widget: MARIANAS_ISLANDS_WIDGET
|
||||
marshall_islands_widget: MARSHALL_ISLANDS_WIDGET
|
||||
north_pacific_ocean_widget: NORTH_PACIFIC_OCEAN_WIDGET
|
||||
south_pacific_ocean_widget: SOUTH_PACIFIC_OCEAN_WIDGET
|
||||
us_mandate_widget: US_MANDATE_WIDGET
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
extend_widgets
|
||||
-- Put each widget into `world'
|
||||
do
|
||||
sea_area_widgets.extend (aleutian_islands_widget, game.aleutian_islands)
|
||||
sea_area_widgets.extend (bay_of_bengal_widget, game.bay_of_bengal)
|
||||
sea_area_widgets.extend (central_pacific_ocean_widget, game.central_pacific_ocean)
|
||||
sea_area_widgets.extend (coral_sea_widget, game.coral_sea)
|
||||
sea_area_widgets.extend (hawaiian_islands_widget, game.hawaiian_islands)
|
||||
sea_area_widgets.extend (indian_ocean_widget, game.indian_ocean)
|
||||
sea_area_widgets.extend (indonesia_widget, game.indonesia)
|
||||
sea_area_widgets.extend (japanese_islands_widget, game.japanese_islands)
|
||||
sea_area_widgets.extend (marianas_islands_widget, game.marianas_islands)
|
||||
sea_area_widgets.extend (marshall_islands_widget, game.marshall_islands)
|
||||
sea_area_widgets.extend (north_pacific_ocean_widget, game.north_pacific_ocean)
|
||||
sea_area_widgets.extend (south_pacific_ocean_widget, game.south_pacific_ocean)
|
||||
sea_area_widgets.extend (us_mandate_widget, game.us_mandate)
|
||||
widgets.merge (sea_area_widgets)
|
||||
end
|
||||
|
||||
pair_widgets
|
||||
-- Associate each widget with a sea area
|
||||
do
|
||||
sea_area_widgets.force (aleutian_islands_widget, game.aleutian_islands)
|
||||
sea_area_widgets.force (bay_of_bengal_widget, game.bay_of_bengal)
|
||||
sea_area_widgets.force (central_pacific_ocean_widget, game.central_pacific_ocean)
|
||||
sea_area_widgets.force (coral_sea_widget, game.coral_sea)
|
||||
sea_area_widgets.force (hawaiian_islands_widget, game.hawaiian_islands)
|
||||
sea_area_widgets.force (indian_ocean_widget, game.indian_ocean)
|
||||
sea_area_widgets.force (indonesia_widget, game.indonesia)
|
||||
sea_area_widgets.force (japanese_islands_widget, game.japanese_islands)
|
||||
sea_area_widgets.force (marianas_islands_widget, game.marianas_islands)
|
||||
sea_area_widgets.force (marshall_islands_widget, game.marshall_islands)
|
||||
sea_area_widgets.force (north_pacific_ocean_widget, game.north_pacific_ocean)
|
||||
sea_area_widgets.force (south_pacific_ocean_widget, game.south_pacific_ocean)
|
||||
sea_area_widgets.force (us_mandate_widget, game.us_mandate)
|
||||
end
|
||||
|
||||
fill_widgets
|
||||
-- Call `set_target' to give each widget a target
|
||||
do
|
||||
aleutian_islands_widget.set_target (game.aleutian_islands)
|
||||
bay_of_bengal_widget.set_target (game.bay_of_bengal)
|
||||
central_pacific_ocean_widget.set_target (game.central_pacific_ocean)
|
||||
coral_sea_widget.set_target (game.coral_sea)
|
||||
hawaiian_islands_widget.set_target (game.hawaiian_islands)
|
||||
indian_ocean_widget.set_target (game.indian_ocean)
|
||||
indonesia_widget.set_target (game.indonesia)
|
||||
japanese_islands_widget.set_target (game.japanese_islands)
|
||||
marianas_islands_widget.set_target (game.marianas_islands)
|
||||
marshall_islands_widget.set_target (game.marshall_islands)
|
||||
north_pacific_ocean_widget.set_target (game.north_pacific_ocean)
|
||||
south_pacific_ocean_widget.set_target (game.south_pacific_ocean)
|
||||
us_mandate_widget.set_target (game.us_mandate)
|
||||
end
|
||||
|
||||
end
|
70
jj_vitp/Interface/views/vitp_cell_view.e
Normal file
70
jj_vitp/Interface/views/vitp_cell_view.e
Normal file
@@ -0,0 +1,70 @@
|
||||
note
|
||||
description: "[
|
||||
Root class for all "windows" in VITP.
|
||||
A scrollable drawing area (i.e. an {EV_MODEL_WORLD_CELL} that is
|
||||
also a {VIEW} through inheritance from {JJ_MODEL_WORLD_CELL_VIEW}.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
VITP_CELL_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
JJ_MODEL_WORLD_CELL_VIEW
|
||||
rename
|
||||
target as game
|
||||
redefine
|
||||
draw,
|
||||
target_imp
|
||||
end
|
||||
|
||||
--create
|
||||
-- default_create
|
||||
|
||||
--create {VITP_CELL_VIEW}
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Redraw the window
|
||||
do
|
||||
-- world.wipe_out
|
||||
world.full_redraw
|
||||
Precursor {JJ_MODEL_WORLD_CELL_VIEW}
|
||||
end
|
||||
|
||||
scale_up
|
||||
-- Increase to the next largest size
|
||||
do
|
||||
world.scale (scale_factor)
|
||||
resize_if_necessary
|
||||
end
|
||||
|
||||
scale_down
|
||||
-- Decrease to the next smallest size
|
||||
do
|
||||
world.scale (1 / scale_factor)
|
||||
if world.bounding_box.width < client_width or
|
||||
world.bounding_box.height < client_height then
|
||||
fit_to_screen
|
||||
end
|
||||
-- fix the scrollbars
|
||||
resize_if_necessary
|
||||
crop
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
target_imp: detachable VITP_GAME
|
||||
-- Detachable implementation of `target' for void safety
|
||||
|
||||
scale_factor: DOUBLE = 1.5
|
||||
-- The amount to grow (or swrink by reciprocal)
|
||||
|
||||
Default_width: INTEGER = 200
|
||||
-- The default width of `border'
|
||||
|
||||
Default_height: INTEGER = 300
|
||||
-- the default width of `border'
|
||||
end
|
1167
jj_vitp/Interface/views/vitp_game_attributes.e
Normal file
1167
jj_vitp/Interface/views/vitp_game_attributes.e
Normal file
File diff suppressed because it is too large
Load Diff
140
jj_vitp/Interface/views/vitp_tool.e
Normal file
140
jj_vitp/Interface/views/vitp_tool.e
Normal file
@@ -0,0 +1,140 @@
|
||||
note
|
||||
description: "[
|
||||
Root class for tools used in the VITP game.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
deferred class
|
||||
VITP_TOOL
|
||||
|
||||
inherit
|
||||
|
||||
TOOL
|
||||
rename
|
||||
target as vitp
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
add_actions,
|
||||
target_imp
|
||||
-- set_target
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
print ("VITP_TOOL.create_interface_objects %N")
|
||||
Precursor {TOOL}
|
||||
print ("%T VITP_TOOL.create_interface_objects after Precursor {TOOL} %N")
|
||||
create zoom_in_button
|
||||
create zoom_out_button
|
||||
create fit_button
|
||||
zoom_in_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_zoom_in_color_buffer))
|
||||
zoom_in_button.set_tooltip ("Zoom In")
|
||||
zoom_out_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_zoom_out_color_buffer))
|
||||
zoom_out_button.set_tooltip ("Zoom Out")
|
||||
fit_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (icon_format_exporteds_color_buffer))
|
||||
fit_button.set_tooltip ("Fit to View")
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Build the interface for this window
|
||||
do
|
||||
Precursor {TOOL}
|
||||
build_tool_bar
|
||||
split_manager.enable_mode_changes
|
||||
split_manager.set_horizontal
|
||||
end
|
||||
|
||||
build_tool_bar
|
||||
-- Add buttons to `tool_bar' (from TOOL).
|
||||
local
|
||||
vs: EV_VERTICAL_SEPARATOR
|
||||
do
|
||||
-- Add a separator and space it out with minimum size.
|
||||
create vs
|
||||
tool_bar.extend (vs)
|
||||
tool_bar.disable_item_expand (vs)
|
||||
vs.set_minimum_width (20)
|
||||
-- Add the zoom buttons
|
||||
tool_bar.extend (zoom_in_button)
|
||||
tool_bar.extend (zoom_out_button)
|
||||
tool_bar.extend (fit_button)
|
||||
tool_bar.disable_item_expand (zoom_in_button)
|
||||
tool_bar.disable_item_expand (zoom_out_button)
|
||||
tool_bar.disable_item_expand (fit_button)
|
||||
-- Add a separator and space it out with minimum size.
|
||||
create vs
|
||||
tool_bar.extend (vs)
|
||||
tool_bar.disable_item_expand (vs)
|
||||
vs.set_minimum_width (20)
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Add functionality to the buttons
|
||||
do
|
||||
Precursor {TOOL}
|
||||
zoom_in_button.select_actions.extend (agent on_zoom_in)
|
||||
zoom_out_button.select_actions.extend (agent on_zoom_out)
|
||||
fit_button.select_actions.extend (agent on_fit)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
focused_view: VITP_CELL_VIEW
|
||||
-- The view that currently has the focus
|
||||
deferred
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (actions)
|
||||
|
||||
on_set_defaults
|
||||
-- Restore the view-vector to the default settings.
|
||||
do
|
||||
end
|
||||
|
||||
on_zoom_in
|
||||
-- Make the board larger
|
||||
do
|
||||
focused_view.scale_up
|
||||
end
|
||||
|
||||
on_zoom_out
|
||||
-- Make the board smaller
|
||||
do
|
||||
focused_view.scale_down
|
||||
end
|
||||
|
||||
on_fit
|
||||
-- Make the content fit the view
|
||||
do
|
||||
focused_view.fit_to_screen
|
||||
focused_view.resize_if_necessary
|
||||
focused_view.crop
|
||||
end
|
||||
|
||||
Default_object: VITP_GAME
|
||||
--
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
target_imp: detachable VITP_GAME
|
||||
-- Detachable implementation of `target' for void safety
|
||||
|
||||
zoom_in_button: EV_BUTTON --EV_TOOL_BAR_BUTTON
|
||||
-- Button to make the game board larger.
|
||||
|
||||
zoom_out_button: EV_BUTTON --EV_TOOL_BAR_BUTTON
|
||||
-- Button to make the game board smaller.
|
||||
|
||||
fit_button: EV_BUTTON
|
||||
-- Button to fit the content to the view
|
||||
|
||||
end
|
37
jj_vitp/Interface/views/vitp_view.e
Normal file
37
jj_vitp/Interface/views/vitp_view.e
Normal file
@@ -0,0 +1,37 @@
|
||||
note
|
||||
description: "[
|
||||
Root class for all the views in VITP
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
VITP_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
JJ_MODEL_WORLD_VIEW
|
||||
redefine
|
||||
-- create_interface_objects,
|
||||
-- world,
|
||||
-- target,
|
||||
-- draw
|
||||
end
|
||||
|
||||
create {VITP_VIEW}
|
||||
list_make
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
-- draw
|
||||
-- -- Redraw the window
|
||||
-- do
|
||||
---- world.wipe_out
|
||||
-- world.full_redraw
|
||||
-- Precursor {JJ_MODEL_WORLD_VIEW}
|
||||
-- end
|
||||
|
||||
|
||||
invariant
|
||||
|
||||
|
||||
end
|
80
jj_vitp/Interface/views/widget_factory.e
Normal file
80
jj_vitp/Interface/views/widget_factory.e
Normal file
@@ -0,0 +1,80 @@
|
||||
note
|
||||
description: "[
|
||||
Top container class of the classes that decompose the numourous
|
||||
VITP widgets into more managable groups.
|
||||
This class keeps track of widgets, allowing a {VITP_WIDGET}
|
||||
to add/remove a widget to/from its world.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/15/24"
|
||||
copyright: "Copyright (c) 2024, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
class
|
||||
WIDGET_FACTORY
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_game: like game)
|
||||
-- Create an instance
|
||||
do
|
||||
print ("WIDGET_FACTORY.make %N")
|
||||
game := a_game
|
||||
make_widgets
|
||||
extend_widgets
|
||||
pair_widgets
|
||||
fill_widgets
|
||||
print ("%T end WIDGET_FACTORY.make %N")
|
||||
end
|
||||
|
||||
make_widgets
|
||||
-- Create widgets for the corresponding game item
|
||||
do
|
||||
create widgets.make (100)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
game: VITP_GAME
|
||||
-- The game for which the widgets are created
|
||||
|
||||
widgets: VITP_WIDGET_TABLE [VITP_WIDGET, VITP_ITEM]
|
||||
-- Container to keep track of all widgets
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_game (a_game: like game)
|
||||
-- Associate `a_game' with Current.
|
||||
do
|
||||
game := a_game
|
||||
-- Add widgets to the table only once, because
|
||||
-- the widgets don't change
|
||||
if widgets.is_empty then
|
||||
extend_widgets
|
||||
end
|
||||
pair_widgets
|
||||
fill_widgets
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
extend_widgets
|
||||
-- Put each widget into a list.
|
||||
do
|
||||
end
|
||||
|
||||
pair_widgets
|
||||
-- Associate each widget with a unit
|
||||
do
|
||||
end
|
||||
|
||||
fill_widgets
|
||||
-- Called by `set_target' to place each item into
|
||||
-- its associated widget.
|
||||
do
|
||||
end
|
||||
|
||||
end
|
142
jj_vitp/Interface/views/widget_position_table.e
Normal file
142
jj_vitp/Interface/views/widget_position_table.e
Normal file
@@ -0,0 +1,142 @@
|
||||
note
|
||||
description: "[
|
||||
A table of TUPLEs where each TUPLE holds an EV_WORLD object
|
||||
(e.g. EV_TEXT_WIDGET, ATTACK_UNIT_WIDGET, etc.) along with
|
||||
an EV_COORDINATE of where that widget should be placed,
|
||||
indexed by a string name.
|
||||
]"
|
||||
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
|
||||
WIDGET_POSITION_TABLE [G -> EV_MODEL, K -> HASHABLE]
|
||||
|
||||
--inherit
|
||||
|
||||
-- HASH_TABLE [TUPLE [mod: G; loc: EV_COORDINATE], K]
|
||||
-- rename
|
||||
-- extend as table_extend
|
||||
-- export
|
||||
-- {NONE}
|
||||
-- put,
|
||||
-- force,
|
||||
-- table_extend,
|
||||
-- replace,
|
||||
-- replace_key,
|
||||
-- merge
|
||||
-- end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Create an instance
|
||||
do
|
||||
create table.make (100)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
widget (a_key: K): EV_MODEL
|
||||
-- The widget associated with `a_key'
|
||||
require
|
||||
has_key: has (a_key)
|
||||
do
|
||||
Result := table.definite_item (a_key).mod
|
||||
end
|
||||
|
||||
location (a_key: K): EV_COORDINATE
|
||||
-- The location associated with `a_key'
|
||||
require
|
||||
has_key: has (a_key)
|
||||
do
|
||||
Result := table.definite_item (a_key).loc
|
||||
end
|
||||
|
||||
widget_for_iteration: EV_MODEL
|
||||
-- The `widget' item at the current iteration position
|
||||
require
|
||||
not_off: not is_off
|
||||
do
|
||||
Result := table.item_for_iteration.mod
|
||||
end
|
||||
|
||||
location_for_iteration: EV_COORDINATE
|
||||
-- The `location' item at the current iteration position
|
||||
require
|
||||
not_off: not is_off
|
||||
do
|
||||
Result := table.item_for_iteration.loc
|
||||
end
|
||||
|
||||
key_for_iteration: K
|
||||
-- The key at thge currenbt iteration position
|
||||
require
|
||||
not_off: not is_off
|
||||
do
|
||||
Result := table.key_for_iteration
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
has (a_key: K): BOOLEAN
|
||||
-- Does Current contain an item with `a_key'
|
||||
do
|
||||
Result := table.has (a_key)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
extend (a_widget: EV_MODEL; a_x, a_y: INTEGER; a_key: K)
|
||||
-- Add `a_widget' to the table, located at (a_x, a_y) and
|
||||
-- indexed by `a_key'. Replace any previous item that
|
||||
-- was indexed by `a_key'.
|
||||
-- An EV_COORDINATE is created from `a_x' and `a_y'.
|
||||
local
|
||||
loc: EV_COORDINATE
|
||||
do
|
||||
create loc.make (a_x, a_y)
|
||||
table.force ([a_widget, loc], a_key)
|
||||
end
|
||||
|
||||
reposition (a_key: K; a_x, a_y: INTEGER)
|
||||
-- Change the `location' for the item indexed by `a_key'
|
||||
require
|
||||
has_key: has (a_key)
|
||||
do
|
||||
location (a_key).set_x (a_x)
|
||||
location (a_key).set_y (a_y)
|
||||
end
|
||||
|
||||
feature -- Cursor movement
|
||||
|
||||
start
|
||||
-- Bring cursor to first position
|
||||
do
|
||||
table.start
|
||||
end
|
||||
|
||||
forth
|
||||
-- Advance cursor to next position or `is_off'
|
||||
require
|
||||
not_off: not is_off
|
||||
do
|
||||
table.forth
|
||||
end
|
||||
|
||||
is_off: BOOLEAN
|
||||
-- Is the cursor after the last item?
|
||||
do
|
||||
Result := table.off
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
table: HASH_TABLE [TUPLE [mod: EV_MODEL; loc: EV_COORDINATE], K]
|
||||
-- Implementation of Current
|
||||
|
||||
end
|
Reference in New Issue
Block a user