init
This commit is contained in:
163
jj_vitp/Interface/widgets/widget_support/item_definition.e
Normal file
163
jj_vitp/Interface/widgets/widget_support/item_definition.e
Normal file
@@ -0,0 +1,163 @@
|
||||
note
|
||||
description: "[
|
||||
Support class for holding coordinates for the definition
|
||||
of all widgets for the VITP game.
|
||||
Each POINT_LIST represents the definition of an area such
|
||||
as a sea area or land mass or the corners of a tile in
|
||||
a widget for an attack unit.
|
||||
|
||||
The points defining the widgets may be larger than required,
|
||||
so we provide scaling factors to be used after the widget
|
||||
is built.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
ITEM_DEFINITION
|
||||
|
||||
inherit
|
||||
|
||||
LINKED_LIST [POINT_LIST]
|
||||
redefine
|
||||
make
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize Current with a `control_point' at the origin
|
||||
do
|
||||
Precursor
|
||||
create dot_offset
|
||||
create lines.make
|
||||
factor_x := 1.0
|
||||
factor_y := 1.0
|
||||
end
|
||||
|
||||
anchor_type: REAL_64
|
||||
-- Anchor scales and offsets to this numeric type
|
||||
|
||||
feature -- Access
|
||||
|
||||
factor_x: like anchor_type
|
||||
-- Amount to scale widget in x direction (after it is built)
|
||||
|
||||
factor_y: like anchor_type
|
||||
-- Amount to scale widget in x direction (after it is built)
|
||||
|
||||
offset_x: like anchor_type
|
||||
-- Amount to x translate the widget to get it in to its initial
|
||||
-- position on the board (after the widget is built)
|
||||
|
||||
offset_y: like anchor_type
|
||||
-- Amount to y translate the widget to get it in to its initial
|
||||
-- position on the board (after the widget is built)
|
||||
|
||||
dot_offset_x: like anchor_type
|
||||
-- Amount to translate the `dot' in the described {VITP_WIDGET}
|
||||
-- This offset is relative to the center point of the widget
|
||||
|
||||
dot_offset: EV_COORDINATE
|
||||
-- dot_offset_y: like anchor_type
|
||||
-- Amount to translate the `dot' in the described {VITP_WIDGET}
|
||||
-- This offset is relative to the center point of the widget
|
||||
|
||||
line_count: INTEGER
|
||||
-- The number of text lines
|
||||
do
|
||||
Result := lines.count
|
||||
end
|
||||
|
||||
line (a_index: INTEGER): STRING
|
||||
-- The line at `a_index'
|
||||
require
|
||||
has_lines: has_lines
|
||||
index_large_enough: a_index >= 1
|
||||
index_small_enough: a_index <= line_count
|
||||
do
|
||||
Result := lines [a_index]
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_offset (ax, ay: like anchor_type)
|
||||
-- The amount by which the widget defined by Current should be translated
|
||||
do
|
||||
offset_x := ax
|
||||
offset_y := ay
|
||||
end
|
||||
|
||||
set_dot_offset (a_offset: like dot_offset)
|
||||
-- Change the `dot_offset
|
||||
do
|
||||
dot_offset := a_offset
|
||||
end
|
||||
|
||||
set_offset_x (ax: like anchor_type)
|
||||
-- Change the `offset_x'
|
||||
do
|
||||
offset_x := ax
|
||||
end
|
||||
|
||||
set_offset_y (ay: like anchor_type)
|
||||
-- Change the `offset_y'
|
||||
do
|
||||
offset_y := ay
|
||||
end
|
||||
|
||||
set_factors (ax, ay: like anchor_type)
|
||||
-- Change both x and y scale factors
|
||||
require
|
||||
x_factor_large_enough: ax > 0.0
|
||||
y_factor_large_enough: ay > 0.0
|
||||
do
|
||||
factor_x := ax
|
||||
factor_y := ay
|
||||
end
|
||||
|
||||
set_factor_x (ax: like anchor_type)
|
||||
-- Change the `factor_x'
|
||||
require
|
||||
factor_large_enough: ax > 0.0
|
||||
do
|
||||
factor_x := ax
|
||||
end
|
||||
|
||||
set_factor_y (ay: like anchor_type)
|
||||
-- Change the `factor_y'
|
||||
require
|
||||
factor_large_enough: ay > 0.0
|
||||
do
|
||||
factor_y := ay
|
||||
end
|
||||
|
||||
add_line (a_line: STRING)
|
||||
-- Add a line of text
|
||||
require
|
||||
line_exists: a_line /= Void
|
||||
do
|
||||
lines.extend (a_line)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_lines: BOOLEAN
|
||||
-- Does Current have at least one line?
|
||||
do
|
||||
Result := not lines.is_empty
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
lines: LINKED_LIST [STRING]
|
||||
-- All the lines of text that belong in the represented area
|
||||
|
||||
invariant
|
||||
|
||||
dot_offset_exists: dot_offset /= Void
|
||||
lines_exists: lines /= Void
|
||||
|
||||
end
|
18
jj_vitp/Interface/widgets/widget_support/point_list.e
Normal file
18
jj_vitp/Interface/widgets/widget_support/point_list.e
Normal file
@@ -0,0 +1,18 @@
|
||||
note
|
||||
description: "[
|
||||
Support class for holding coordinates for the definition
|
||||
of areas for the VITP game.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
POINT_LIST
|
||||
|
||||
inherit
|
||||
|
||||
LINKED_LIST [EV_COORDINATE]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
end
|
56
jj_vitp/Interface/widgets/widget_support/polygon_clipper.e
Normal file
56
jj_vitp/Interface/widgets/widget_support/polygon_clipper.e
Normal file
@@ -0,0 +1,56 @@
|
||||
note
|
||||
description: "[
|
||||
Provides functions to clip one polygon against another.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
POLYGON_CLIPPER
|
||||
|
||||
inherit
|
||||
|
||||
ANY
|
||||
redefine
|
||||
default_create
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Set up Current
|
||||
do
|
||||
create clipping_results.make
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
clipped (polygon, other: EV_MODEL_POLYGON): LINKED_LIST [EV_MODEL_POLYGON]
|
||||
-- The polygon representing the intersection of `polygon' and `other'
|
||||
local
|
||||
e_count, other_e_count: INTEGER
|
||||
i, j: INTEGER
|
||||
do
|
||||
create Result.make
|
||||
e_count := polygon.point_count - 1
|
||||
other_e_count := other.point_count - 1
|
||||
from i := 1
|
||||
until i > e_count
|
||||
loop
|
||||
from j := 1
|
||||
until j > other_e_count
|
||||
loop
|
||||
j := j + 1
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
clipping_results: LINKED_LIST [EV_MODEL_POLYGON]
|
||||
-- Holds intermediate calculations
|
||||
|
||||
end
|
23
jj_vitp/Interface/widgets/widget_support/silhouette.e
Normal file
23
jj_vitp/Interface/widgets/widget_support/silhouette.e
Normal file
@@ -0,0 +1,23 @@
|
||||
note
|
||||
description: "[
|
||||
Class used in {VITP_GAME}, Victory in the Pacific, to diplay
|
||||
the outline of a unit (e.g. {SHIP}, {AMPHIBOUSE_UNIT}, etc.)
|
||||
on an {ATTACK_UNIT_WIDGET}.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "3/14/24"
|
||||
copyright: "Copyright (c) 2021, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
class
|
||||
SILHOUETTE
|
||||
|
||||
inherit
|
||||
|
||||
EV_MODEL_POLYGON
|
||||
|
||||
create
|
||||
default_create,
|
||||
make_with_coordinates
|
||||
|
||||
end
|
30
jj_vitp/Interface/widgets/widget_support/vitp_widget_table.e
Normal file
30
jj_vitp/Interface/widgets/widget_support/vitp_widget_table.e
Normal file
@@ -0,0 +1,30 @@
|
||||
note
|
||||
description: "[
|
||||
A HASH_TABLE pairing widgets with a {VITP_ITEM}.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
VITP_WIDGET_TABLE [G -> VITP_WIDGET, K -> VITP_ITEM]
|
||||
-- VITP_WIDGET_TABLE [G -> VITP_WIDGET, K -> STRING_8]
|
||||
|
||||
inherit
|
||||
|
||||
HASH_TABLE [G, K]
|
||||
|
||||
create
|
||||
make,
|
||||
make_equal
|
||||
|
||||
feature -- Access
|
||||
|
||||
widget (key: K): G
|
||||
-- Item associated with `key'.
|
||||
-- Should be present
|
||||
do
|
||||
check attached item (key) as v then
|
||||
Result := v
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user