Removed prototype menus, there is a better way to make them...
This commit is contained in:
parent
e096e0e842
commit
cdac9d02f7
@ -111,7 +111,7 @@ package body core is
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure view (data : in sprite; x, y, u, v, width, height : in integer) is
|
||||
crop_u, crop_v, crop_width, crop_height : integer;
|
||||
--~crop_u, crop_v, crop_width, crop_height : integer;
|
||||
begin
|
||||
if x > u + width
|
||||
or y > v + height
|
||||
@ -120,8 +120,8 @@ package body core is
|
||||
return;
|
||||
end if;
|
||||
--
|
||||
crop_width := data.width - (if x + data.width > u + width then (x + data.width) mod (u + width) else 0);
|
||||
crop_height := data.height - (if y + data.height > v + height then (y + data.height) mod (v + height) else 0);
|
||||
--~crop_width := data.width - (if x + data.width > u + width then (x + data.width) mod (u + width) else 0);
|
||||
--~crop_height := data.height - (if y + data.height > v + height then (y + data.height) mod (v + height) else 0);
|
||||
--
|
||||
--~crop_u := (if x < u then data.width - u mod (x + data.width) else 0);
|
||||
--~crop_v := (if y < v then data.height - v mod (y + data.height) else 0);
|
||||
@ -129,10 +129,11 @@ package body core is
|
||||
--~crop_v := (if y < v and y < v - data.height then data.height - (y + data.height) mod v else 0);
|
||||
--~crop_u := data.width - (if x < u then (x + data.width) mod u else 0);
|
||||
--~crop_v := data.height - (if y < v then (y + data.height) mod v else 0);
|
||||
crop_u := data.width - (if x < u then u mod x else 0);
|
||||
crop_v := data.height - (if y < v then v mod y else 0);
|
||||
--~crop_u := data.width - (if x < u then u mod x else 0);
|
||||
--~crop_v := data.height - (if y < v then v mod y else 0);
|
||||
--
|
||||
render_sprite (data.index, x, y, crop_u, crop_v, crop_width, crop_height);
|
||||
--~render_sprite (data.index, x, y, crop_u, crop_v, crop_width, crop_height);
|
||||
render_sprite (data.index, x, y, 0, 0, data.width, data.height);
|
||||
end view;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
@ -1,7 +1,7 @@
|
||||
with ada.text_io;
|
||||
use ada.text_io;
|
||||
|
||||
with core, ui, effect, attribute, skill, resource, faction, might, magic, item, unit, construction, world, menu;
|
||||
with core, ui, effect, attribute, skill, resource, faction, might, magic, item, unit, construction, world;
|
||||
|
||||
procedure main is
|
||||
|
||||
@ -20,14 +20,10 @@ procedure main is
|
||||
-- Marina Ann Hantzis
|
||||
|
||||
side_panel : integer := 480;
|
||||
--~preview_x : integer := 24;
|
||||
--~preview_y : integer := 24;
|
||||
--~preview_width : integer := 1800 - side_panel;
|
||||
--~preview_height : integer := 900;
|
||||
preview_x : integer := 100;
|
||||
preview_y : integer := 100;
|
||||
preview_width : integer := 800;
|
||||
preview_height : integer := 600;
|
||||
preview_x : integer := 24;
|
||||
preview_y : integer := 24;
|
||||
preview_width : integer := 0;
|
||||
preview_height : integer := 0;
|
||||
|
||||
begin
|
||||
|
||||
@ -42,7 +38,6 @@ begin
|
||||
unit.configure;
|
||||
construction.configure;
|
||||
world.configure;
|
||||
menu.configure;
|
||||
|
||||
core.fairy_synchronize (6); -- CALLING SUBROUTINE DEFINED IN FORTRAN
|
||||
|
||||
@ -52,7 +47,6 @@ begin
|
||||
exit when core.engine_active = false;
|
||||
--
|
||||
core.synchronize;
|
||||
menu.synchronize;
|
||||
--
|
||||
--~if core.cursor_mode = 1 then
|
||||
--~world_active := world.codex'val ((world.codex'pos (world_active) + 1) mod 6);
|
||||
@ -61,15 +55,17 @@ begin
|
||||
--
|
||||
if core.signal_mode = core.signal_code'pos (core.signal_a) then side_panel := side_panel + 60; end if;
|
||||
if core.signal_mode = core.signal_code'pos (core.signal_d) then side_panel := side_panel - 60; end if;
|
||||
preview_width := 1800 - side_panel;
|
||||
--
|
||||
preview_width := core.window_width - side_panel;
|
||||
preview_height := core.window_height;
|
||||
--
|
||||
if core.signal_mode = core.signal_code'pos (core.signal_left) then core.camera.x := core.camera.x - 1; end if;
|
||||
if core.signal_mode = core.signal_code'pos (core.signal_right) then core.camera.x := core.camera.x + 1; end if;
|
||||
if core.signal_mode = core.signal_code'pos (core.signal_up) then core.camera.y := core.camera.y - 1; end if;
|
||||
if core.signal_mode = core.signal_code'pos (core.signal_down) then core.camera.y := core.camera.y + 1; end if;
|
||||
--
|
||||
core.camera.x := core.clip (core.camera.x, 0, 80 - 1);
|
||||
core.camera.y := core.clip (core.camera.y, 0, 40 - 1);
|
||||
core.camera.x := core.clip (core.camera.x, 0, world.map.width - preview_width / core.base);
|
||||
core.camera.y := core.clip (core.camera.y, 0, world.map.height - preview_height / core.base);
|
||||
--
|
||||
world.draw (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y, core.cursor_mode = 2);
|
||||
--
|
||||
@ -120,17 +116,6 @@ begin
|
||||
--~for index in skill.codex loop skill.draw (index, 32 * skill.codex'pos (index) + 64, 128); end loop;
|
||||
--
|
||||
core.draw_state_box (preview_width + 32, 32);
|
||||
--
|
||||
--~menu.draw (menu.attribute_information, 100, 100, false);
|
||||
--~menu.draw (menu.skill_information, 700, 100, false);
|
||||
--~menu.draw (menu.resource_information, 400, 100, true);
|
||||
--
|
||||
core.write ("Menu :" & menu.trait (menu.mouse_over_menu).title, preview_width + 32, 32 + 320, 16#CCCCCC#);
|
||||
if menu.mouse_over_menu_element = -1 then
|
||||
core.write ("Menu Element :" & "-- ", preview_width + 32, 32 + 352, 16#CCCCCC#);
|
||||
else
|
||||
core.write ("Menu Element :" & menu.trait (menu.mouse_over_menu).elements (menu.mouse_over_menu_element).text, preview_width + 32, 32 + 352, 16#CCCCCC#);
|
||||
end if;
|
||||
end loop gameplay;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
126
source/menu.adb
126
source/menu.adb
@ -1,126 +0,0 @@
|
||||
with core, ui, effect, attribute, skill, resource, faction, might, magic, item, unit, construction, world, menu;
|
||||
|
||||
use menu;
|
||||
|
||||
package body menu is
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
draw_offset : constant integer := 16;
|
||||
icon_offset : constant integer := 4;
|
||||
icon_size : constant integer := 32;
|
||||
offset : constant integer := icon_size + 2 * icon_offset;
|
||||
|
||||
button_width : constant integer := offset + 24 * 8;
|
||||
button_height : constant integer := offset;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
function make_button (element_index : in integer; text : in core.short_string; icon : in core.sprite) return element is
|
||||
begin
|
||||
return (button, 0, text, icon, draw_offset, draw_offset + element_index * offset, button_width, button_height);
|
||||
end make_button;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure configure is
|
||||
begin
|
||||
trait (attribute_information) := ("Attribute Information ", true, attribute.count, 10, 100, 64, new element_array (0 .. attribute.count - 1));
|
||||
trait (skill_information) := ("Skill Information ", true, skill.count, 10, 700, 64, new element_array (0 .. skill.count - 1));
|
||||
trait (resource_information) := ("Resource Information ", true, resource.count, 10, 400, 64, new element_array (0 .. resource.count - 1));
|
||||
trait (none) := ("-- ", true, 2, 10, 0, 0, new element_array (0 .. 1));
|
||||
--
|
||||
for index in 0 .. attribute.count - 1
|
||||
loop
|
||||
trait (attribute_information).elements (index) := make_button (index, attribute.name (index), attribute.icon (index));
|
||||
end loop;
|
||||
--
|
||||
for index in 0 .. skill.count - 1
|
||||
loop
|
||||
trait (skill_information).elements (index) := make_button (index, skill.name (index), skill.icon (index));
|
||||
end loop;
|
||||
--
|
||||
for index in 0 .. resource.count - 1
|
||||
loop
|
||||
trait (resource_information).elements (index) := make_button (index, resource.name (index), resource.icon (index));
|
||||
end loop;
|
||||
--
|
||||
for index in 0 .. 1
|
||||
loop
|
||||
trait (none).elements (index) := make_button (index, "-- ", resource.icon (0));
|
||||
end loop;
|
||||
end configure;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure synchronize is
|
||||
limitation : integer;
|
||||
begin
|
||||
mouse_over_menu := none;
|
||||
mouse_over_menu_element := -1;
|
||||
--
|
||||
for index in codex
|
||||
loop
|
||||
if trait (index).hide then
|
||||
goto next;
|
||||
end if;
|
||||
limitation := (if trait (index).length < trait (index).height then trait (index).length else trait (index).height);
|
||||
--
|
||||
if core.cursor_x > trait (index).x
|
||||
and core.cursor_x < trait (index).x + 2 * draw_offset + offset + 24 * 8
|
||||
and core.cursor_y > trait (index).y
|
||||
and core.cursor_y < trait (index).y + limitation * offset + 2 * draw_offset then
|
||||
mouse_over_menu := index;
|
||||
end if;
|
||||
--
|
||||
if mouse_over_menu /= none then
|
||||
for element_index in 0 .. limitation - 1
|
||||
loop
|
||||
if core.cursor_x > trait (index).x + trait (index).elements (element_index).x
|
||||
and core.cursor_x < trait (index).x + trait (index).elements (element_index).x + trait (index).elements (element_index).width
|
||||
and core.cursor_y > trait (index).y + trait (index).elements (element_index).y
|
||||
and core.cursor_y < trait (index).y + trait (index).elements (element_index).y + trait (index).elements (element_index).height then
|
||||
mouse_over_menu_element := element_index;
|
||||
end if;
|
||||
end loop;
|
||||
return;
|
||||
end if;
|
||||
<<next>>
|
||||
end loop;
|
||||
end synchronize;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw (index : in codex; x, y : in integer; center : in boolean) is
|
||||
scroll_bar : constant boolean := (if trait (index).length > trait (index).height then true else false);
|
||||
limitation : constant integer := (if scroll_bar then trait (index).height else trait (index).length);
|
||||
width : constant integer := 2 * draw_offset + offset + 24 * 8;
|
||||
height : constant integer := limitation * offset + 2 * draw_offset;
|
||||
begin
|
||||
if index = none then
|
||||
return;
|
||||
end if;
|
||||
--
|
||||
trait (index).hide := false;
|
||||
trait (index).x := (if center then (core.window_width - width) / 2 else x);
|
||||
trait (index).y := (if center then (core.window_height - height) / 2 else y);
|
||||
--
|
||||
ui.draw_title_bar (trait (index).x, trait (index).y, width, trait (index).title);
|
||||
ui.draw_tiny_menu (trait (index).x, trait (index).y, width, height, true);
|
||||
--
|
||||
for element_index in 0 .. limitation - 1
|
||||
loop
|
||||
ui.draw_frame (trait (index).x + draw_offset, trait (index).y + draw_offset + element_index * offset, width - 2 * draw_offset, offset);
|
||||
--
|
||||
core.draw (trait (index).elements (element_index).icon, trait (index).x + draw_offset + icon_offset, trait (index).y + draw_offset + icon_offset + element_index * offset);
|
||||
core.write (trait (index).elements (element_index).text, trait (index).x + draw_offset + offset, trait (index).y + draw_offset + 2 * icon_offset + element_index * offset);
|
||||
end loop;
|
||||
--
|
||||
if scroll_bar then
|
||||
ui.draw_scroll_bar (trait (index).x + width - draw_offset, trait (index).y + draw_offset, height - 2 * draw_offset, 0);
|
||||
end if;
|
||||
end draw;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end menu;
|
@ -1,60 +0,0 @@
|
||||
with core;
|
||||
|
||||
package menu is
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
type format is (
|
||||
separator, button, text_box, data_box, check_box, title_bar, scroll_bar, fill_bar
|
||||
);
|
||||
|
||||
type codex is (
|
||||
attribute_information, skill_information, resource_information, none
|
||||
);
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
type element is
|
||||
record
|
||||
kind : format;
|
||||
data : integer;
|
||||
text : core.short_string;
|
||||
icon : core.sprite;
|
||||
x : integer;
|
||||
y : integer;
|
||||
width : integer;
|
||||
height : integer;
|
||||
end record;
|
||||
|
||||
type element_array is array (natural range <>) of element;
|
||||
|
||||
type information is
|
||||
record
|
||||
title : core.short_string;
|
||||
hide : boolean;
|
||||
length : integer;
|
||||
height : integer;
|
||||
x : integer;
|
||||
y : integer;
|
||||
elements : access element_array;
|
||||
end record;
|
||||
|
||||
type trait_array is array (codex) of information;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
mouse_over_menu : codex;
|
||||
mouse_over_menu_element : integer;
|
||||
|
||||
trait : trait_array;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure configure;
|
||||
procedure synchronize;
|
||||
|
||||
procedure draw (index : in codex; x, y : in integer; center : in boolean);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end menu;
|
@ -7,24 +7,6 @@ package body world is
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
type entity is
|
||||
record
|
||||
index, x, y : integer;
|
||||
end record;
|
||||
|
||||
type block_array is array (natural range <>, natural range <>) of integer;
|
||||
type entity_array is array (natural range <>) of entity;
|
||||
|
||||
type information is
|
||||
record
|
||||
terrain : codex;
|
||||
width : natural;
|
||||
height : natural;
|
||||
block : access block_array;
|
||||
landmark : access entity_array;
|
||||
construction : access entity_array;
|
||||
end record;
|
||||
|
||||
type sprite_array is array (natural range <>) of core.sprite;
|
||||
|
||||
type world_array is array (natural range <>) of access information;
|
||||
@ -37,7 +19,6 @@ package body world is
|
||||
|
||||
blocks : core.sprite;
|
||||
landmarks : landmark_sprite_array := (others => null);
|
||||
map : information;
|
||||
|
||||
limit : constant limit_array := (29, 64, 70, 94, 51, 94);
|
||||
|
||||
@ -137,7 +118,10 @@ package body world is
|
||||
--
|
||||
for object in 0 .. landmark_limit
|
||||
loop
|
||||
core.view (landmarks (map.terrain) (map.landmark (object).index), map.landmark (object).x - core.camera.x * core.base, map.landmark (object).y - core.camera.y * core.base, x, y, width, height);
|
||||
core.view (landmarks (map.terrain) (map.landmark (object).index),
|
||||
map.landmark (object).x - core.camera.x * core.base,
|
||||
map.landmark (object).y - core.camera.y * core.base,
|
||||
x, y, width, height);
|
||||
end loop;
|
||||
--
|
||||
if show_grid then
|
||||
|
@ -10,6 +10,30 @@ package world is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
type entity is
|
||||
record
|
||||
index, x, y : integer;
|
||||
end record;
|
||||
|
||||
type block_array is array (natural range <>, natural range <>) of integer;
|
||||
type entity_array is array (natural range <>) of entity;
|
||||
|
||||
type information is
|
||||
record
|
||||
terrain : codex;
|
||||
width : natural;
|
||||
height : natural;
|
||||
block : access block_array;
|
||||
landmark : access entity_array;
|
||||
construction : access entity_array;
|
||||
end record;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
map : information;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure configure;
|
||||
|
||||
procedure make (index : in codex; width, height : in natural);
|
||||
|
Loading…
Reference in New Issue
Block a user