Finishing World refactoring soon, and changed UI cursor collision...
This commit is contained in:
parent
ef79bb3e11
commit
3c20239a7d
@ -251,7 +251,7 @@ package body core is
|
||||
|
||||
function cursor_inside (x, y, width, height : in integer) return boolean is
|
||||
begin
|
||||
return cursor.x > x and cursor.x < x + width * zoom and cursor.y > y and cursor.y < y + height * zoom;
|
||||
return cursor.x > x and cursor.x < x + width and cursor.y > y and cursor.y < y + height;
|
||||
end cursor_inside;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
@ -158,7 +158,7 @@ package body ui is
|
||||
--
|
||||
core.draw (data, x, y, factor => 1);
|
||||
--
|
||||
if core.cursor_inside (x, y, core.icon / core.zoom, core.icon / core.zoom) then
|
||||
if core.cursor_inside (x, y, core.icon, core.icon) then
|
||||
prioritize := true;
|
||||
--
|
||||
draw (icon_selected, x, y);
|
||||
@ -181,7 +181,7 @@ package body ui is
|
||||
core.draw (data, x, y, factor => 1);
|
||||
write (text, x + core.icon + 10, y + 10, code => true);
|
||||
--
|
||||
if core.cursor_inside (x, y, core.icon / core.zoom, core.icon / core.zoom) then
|
||||
if core.cursor_inside (x, y, core.icon, core.icon) then
|
||||
prioritize := true;
|
||||
--
|
||||
if core.cursor_mode = core.cursor_left then
|
||||
@ -199,7 +199,7 @@ package body ui is
|
||||
--
|
||||
draw (overicon, x, y);
|
||||
--
|
||||
if core.cursor_inside (x, y, core.icon / core.zoom, core.icon / core.zoom) then
|
||||
if core.cursor_inside (x, y, core.icon, core.icon) then
|
||||
prioritize := true;
|
||||
--
|
||||
draw (icon_selected, x, y);
|
||||
@ -221,7 +221,7 @@ package body ui is
|
||||
--
|
||||
draw_icon_menu (x, y, data.width + 2 * offset, data.height + 2 * offset);
|
||||
--
|
||||
if core.cursor_inside (x, y, (data.width + 2 * offset) / core.zoom, (data.height + 2 * offset) / core.zoom) then
|
||||
if core.cursor_inside (x, y, data.width + 2 * offset, data.height + 2 * offset) then
|
||||
prioritize := true;
|
||||
--
|
||||
core.write_help_box (text);
|
||||
@ -299,7 +299,7 @@ package body ui is
|
||||
draw (frame_lower_left, x, y + height - sprite (active, frame_lower_left).height);
|
||||
draw (frame_lower_right, x + width - sprite (active, frame_lower_right).width, y + height - sprite (active, frame_lower_right).height);
|
||||
--
|
||||
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
||||
if core.cursor_inside (x, y, width, height) then
|
||||
prioritize := true;
|
||||
end if;
|
||||
end draw_frame;
|
||||
@ -315,9 +315,9 @@ package body ui is
|
||||
ui.write (text,
|
||||
x + offset + (core.icon - font (active).scale) / 2 + core.icon,
|
||||
y + offset + (core.icon - font (active).scale) / 2,
|
||||
(if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then font_tint (active) else (others => 255)));
|
||||
(if core.cursor_inside (x, y, width, height) then font_tint (active) else (others => 255)));
|
||||
--
|
||||
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
||||
if core.cursor_inside (x, y, width, height) then
|
||||
prioritize := true;
|
||||
--
|
||||
if core.cursor_mode = core.cursor_left then
|
||||
@ -346,7 +346,7 @@ package body ui is
|
||||
ui.write (text, x + sprite (active, check_box_on).width, y);
|
||||
--
|
||||
if core.cursor_mode = core.cursor_left
|
||||
and core.cursor_inside (x, y, sprite (active, check_box_on).width / core.zoom, sprite (active, check_box_on).height / core.zoom) then
|
||||
and core.cursor_inside (x, y, sprite (active, check_box_on).width, sprite (active, check_box_on).height) then
|
||||
on := not on;
|
||||
core.cursor_mode := core.cursor_none;
|
||||
end if;
|
||||
@ -358,7 +358,7 @@ package body ui is
|
||||
middle_width : constant integer := width - sprite (active, title_bar_left).width - sprite (active, title_bar_right).width;
|
||||
offset : constant integer := (sprite (active, title_bar_middle).height - font (active).scale) / 2;
|
||||
begin
|
||||
if core.cursor_inside (x, y, width / core.zoom, sprite (active, title_bar_left).height / core.zoom) then
|
||||
if core.cursor_inside (x, y, width, sprite (active, title_bar_left).height) then
|
||||
prioritize := true;
|
||||
end if;
|
||||
--
|
||||
@ -417,7 +417,7 @@ package body ui is
|
||||
procedure draw_menu (x, y, width, height : in integer) is
|
||||
offset : constant integer := sprite (active, none).width;
|
||||
begin
|
||||
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
||||
if core.cursor_inside (x, y, width, height) then
|
||||
prioritize := true;
|
||||
end if;
|
||||
--
|
||||
@ -443,7 +443,7 @@ package body ui is
|
||||
procedure draw_tiny_menu (x, y, width, height : in integer) is
|
||||
offset : constant integer := sprite (active, none).width;
|
||||
begin
|
||||
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
||||
if core.cursor_inside (x, y, width, height) then
|
||||
prioritize := true;
|
||||
end if;
|
||||
--
|
||||
@ -487,7 +487,7 @@ package body ui is
|
||||
draw (icon_lower_left, x, y + height - sprite (active, icon_lower_left).height);
|
||||
draw (icon_lower_right, x + width - sprite (active, icon_lower_right).width, y + height - sprite (active, icon_lower_right).height);
|
||||
--
|
||||
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
||||
if core.cursor_inside (x, y, width, height) then
|
||||
prioritize := true;
|
||||
--
|
||||
core.write_help_box (text);
|
||||
|
136
source/world.adb
136
source/world.adb
@ -277,12 +277,22 @@ package body world is
|
||||
|
||||
procedure draw_landmark (data : in landmark.enumeration; x, y, factor : in integer) is
|
||||
begin
|
||||
core.draw (landmark.game (data), x, y, factor => factor);
|
||||
--
|
||||
if core.cursor_inside (x, y, landmark.game (data).width * factor, landmark.game (data).height * factor) and core.cursor_mode = core.cursor_middle then
|
||||
core.write_text_box (landmark.description (data).name.all);
|
||||
end if;
|
||||
end draw_landmark;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_location (data : in location.enumeration; used : in boolean; x, y, factor : in integer) is
|
||||
begin
|
||||
core.draw (location.game (data), x, y, state => core.animation'val (boolean'pos (used)), factor => factor);
|
||||
--
|
||||
if core.cursor_inside (x, y, location.game (data).width * factor, location.game (data).height * factor) and core.cursor_mode = core.cursor_middle then
|
||||
core.write_text_box (location.description (data).name.all);
|
||||
end if;
|
||||
end draw_location;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
@ -291,7 +301,7 @@ package body world is
|
||||
begin
|
||||
core.draw (construction.game (data), x, y, factor => factor);
|
||||
--
|
||||
if core.cursor_inside (x, y, construction.game (data).width, construction.game (data).height) and core.cursor_mode = core.cursor_middle
|
||||
if core.cursor_inside (x, y, construction.game (data).width * factor, construction.game (data).height * factor) and core.cursor_mode = core.cursor_middle then
|
||||
core.write_text_box (construction.description (data).name.all);
|
||||
end if;
|
||||
end draw_construction;
|
||||
@ -302,7 +312,7 @@ package body world is
|
||||
begin
|
||||
core.draw (equipment.game (data), x, y, state => core.idle, factor => factor);
|
||||
--
|
||||
if core.cursor_inside (x, y, equipment.game (data).width, equipment.game (data).height) and core.cursor_mode = core.cursor_middle and equipment_valid (data)
|
||||
if core.cursor_inside (x, y, equipment.game (data).width * factor, equipment.game (data).height * factor) and core.cursor_mode = core.cursor_middle and equipment_valid (data) then
|
||||
core.write_text_box (equipment.description (data).name.all);
|
||||
end if;
|
||||
end draw_equipment;
|
||||
@ -316,6 +326,10 @@ package body world is
|
||||
for kind in equipment.kind loop
|
||||
core.draw (equipment.game (unit.description (data).equipments (kind)), x, y, state => state, factor => factor);
|
||||
end loop;
|
||||
--
|
||||
if core.cursor_inside (x, y, core.base * factor, core.base * factor) and core.cursor_mode = core.cursor_middle then
|
||||
core.write_text_box (unit.description (data).name.all);
|
||||
end if;
|
||||
end draw_unit;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
@ -872,7 +886,7 @@ package body world is
|
||||
y => core.window_height / 2 - 6 * size,
|
||||
width => 12 * size,
|
||||
height => 12 * size)
|
||||
and core.cursor_mode = core.cursor_left
|
||||
and core.cursor_mode = core.cursor_left -- shit
|
||||
and not ui.prioritize then
|
||||
target.x := horizontal;
|
||||
target.y := vertical;
|
||||
@ -983,18 +997,10 @@ package body world is
|
||||
if map.views (map.landmarks (index).x, map.landmarks (index).y)
|
||||
and map.landmarks (index).x > view_from.x and map.landmarks (index).x < view_from.x + view_to.x
|
||||
and map.landmarks (index).y > view_from.y and map.landmarks (index).y < view_from.y + view_to.y then
|
||||
core.draw (data => landmark.game (map.landmarks (index).index),
|
||||
x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
|
||||
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom);
|
||||
--
|
||||
if core.cursor_inside (x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
|
||||
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom,
|
||||
width => landmark.game (map.landmarks (index).index).width,
|
||||
height => landmark.game (map.landmarks (index).index).height)
|
||||
and core.cursor_mode = core.cursor_middle
|
||||
and not ui.prioritize then
|
||||
core.write_text_box (landmark.description (map.landmarks (index).index).name.all);
|
||||
end if;
|
||||
draw_landmark (data => map.landmarks (index).index,
|
||||
x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
|
||||
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom,
|
||||
factor => core.zoom);
|
||||
end if;
|
||||
end loop;
|
||||
end draw_landmarks;
|
||||
@ -1007,64 +1013,56 @@ package body world is
|
||||
if map.views (map.locations (index).x, map.locations (index).y)
|
||||
and map.locations (index).x > view_from.x and map.locations (index).x < view_from.x + view_to.x
|
||||
and map.locations (index).y > view_from.y and map.locations (index).y < view_from.y + view_to.y then
|
||||
core.draw (data => location.game (map.locations (index).index),
|
||||
x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom,
|
||||
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
|
||||
state => core.animation'val (boolean'pos (map.locations (index).used)));
|
||||
draw_location (data => map.locations (index).index,
|
||||
used => map.locations (index).used,
|
||||
x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom,
|
||||
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
|
||||
factor => core.zoom);
|
||||
--
|
||||
if core.cursor_inside (x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom,
|
||||
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
|
||||
width => location.game (map.locations (index).index).width,
|
||||
height => location.game (map.locations (index).index).height)
|
||||
and core.cursor_mode = core.cursor_middle
|
||||
if core.camera.x > map.locations (index).x - 2
|
||||
and core.camera.x < map.locations (index).x + 1 + location.game (map.locations (index).index).width / core.base
|
||||
and core.camera.y > map.locations (index).y - 2
|
||||
and core.camera.y < map.locations (index).y + 1 + location.game (map.locations (index).index).height / core.base
|
||||
and map.locations (index).used = false
|
||||
and core.signal_mode = core.signal_e
|
||||
and not ui.prioritize then
|
||||
core.write_text_box (location.description (map.locations (index).index).name.all);
|
||||
declare player : chad.information renames world.map.chads (1);
|
||||
--
|
||||
data : effect.information := location.description (map.locations (index).index).evoke;
|
||||
--
|
||||
attribute_index : attribute.enumeration;
|
||||
--~skill_index : skill.enumeration;
|
||||
resource_index : resource.enumeration;
|
||||
material_index : material.enumeration;
|
||||
begin
|
||||
case data.kind is
|
||||
when effect.idle => null;
|
||||
--
|
||||
when effect.modify_attribute => attribute_index := attribute.enumeration'val (data.modifier);
|
||||
player.attributes (attribute_index) := player.attributes (attribute_index) + data.amount;
|
||||
ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
& attribute.description (attribute_index).name.all & " attribute points.");
|
||||
--
|
||||
when effect.modify_skill => null;
|
||||
--~when effect.modify_skill => skill_index := skill.enumeration'val (data.modifier);
|
||||
--~player.skills (skill_index) := player.skills (skill_index) + data.amount;
|
||||
--~ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
--~& skill.description (skill_index).name.all & " skill points.");
|
||||
--
|
||||
when effect.modify_resource => resource_index := resource.enumeration'val (data.modifier);
|
||||
player.resources (resource_index) := player.resources (resource_index) + data.amount;
|
||||
ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
& resource.description (resource_index).name.all & " resource points.");
|
||||
--
|
||||
when effect.modify_material => material_index := material.enumeration'val (data.modifier);
|
||||
player.materials (material_index) := player.materials (material_index) + data.amount;
|
||||
ui.echo ("+" & data.amount'image & " " & material.description (material_index).name.all);
|
||||
end case;
|
||||
end;
|
||||
--
|
||||
map.locations (index).used := true;
|
||||
end if;
|
||||
end if;
|
||||
--
|
||||
if core.camera.x > map.locations (index).x - 2
|
||||
and core.camera.x < map.locations (index).x + 1 + location.game (map.locations (index).index).width / core.base
|
||||
and core.camera.y > map.locations (index).y - 2
|
||||
and core.camera.y < map.locations (index).y + 1 + location.game (map.locations (index).index).height / core.base
|
||||
and map.locations (index).used = false
|
||||
and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e)
|
||||
and not ui.prioritize then
|
||||
declare player : chad.information renames world.map.chads (1);
|
||||
--
|
||||
data : effect.information := location.description (map.locations (index).index).evoke;
|
||||
--
|
||||
attribute_index : attribute.enumeration;
|
||||
--~skill_index : skill.enumeration;
|
||||
resource_index : resource.enumeration;
|
||||
material_index : material.enumeration;
|
||||
begin
|
||||
case data.kind is
|
||||
when effect.idle => null;
|
||||
--
|
||||
when effect.modify_attribute => attribute_index := attribute.enumeration'val (data.modifier);
|
||||
player.attributes (attribute_index) := player.attributes (attribute_index) + data.amount;
|
||||
ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
& attribute.description (attribute_index).name.all & " attribute points.");
|
||||
--
|
||||
when effect.modify_skill => null;
|
||||
--~when effect.modify_skill => skill_index := skill.enumeration'val (data.modifier);
|
||||
--~player.skills (skill_index) := player.skills (skill_index) + data.amount;
|
||||
--~ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
--~& skill.description (skill_index).name.all & " skill points.");
|
||||
--
|
||||
when effect.modify_resource => resource_index := resource.enumeration'val (data.modifier);
|
||||
player.resources (resource_index) := player.resources (resource_index) + data.amount;
|
||||
ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
& resource.description (resource_index).name.all & " resource points.");
|
||||
--
|
||||
when effect.modify_material => material_index := material.enumeration'val (data.modifier);
|
||||
player.materials (material_index) := player.materials (material_index) + data.amount;
|
||||
ui.echo ("+" & data.amount'image & " " & material.description (material_index).name.all);
|
||||
end case;
|
||||
end;
|
||||
--
|
||||
map.locations (index).used := true;
|
||||
end if;
|
||||
end loop;
|
||||
end draw_locations;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user