diff --git a/source/ai.adb b/source/ai.adb index 7c4cb59..0a86818 100644 --- a/source/ai.adb +++ b/source/ai.adb @@ -62,7 +62,7 @@ package body ai is --~x : integer := (core.window_width - width) / 2; --~y : integer := (core.window_height - height) / 2; begin - --~ui.draw_tiny_menu (x, y, width, height, true); + --~ui.draw_tiny_menu (x, y, width, height); --~for index in 1 .. actor_count loop --~core.write ("Bot" & index'image, x + offset + 0, y * index + offset, ui.glyphs (ui.active)); --~core.write ("T =" & actor_is_thirsty (index)'image, x + offset + 120, y * index + offset, ui.glyphs (ui.active)); @@ -80,7 +80,7 @@ package body ai is x : integer := (core.window_width - width) / 2; y : integer := (core.window_height - height) / 2; begin - ui.draw_tiny_menu (x, y, width, height, true); + ui.draw_tiny_menu (x, y, width, height); -- active := index; -- diff --git a/source/attribute.adb b/source/attribute.adb index ce3e697..d8eaa97 100644 --- a/source/attribute.adb +++ b/source/attribute.adb @@ -30,7 +30,7 @@ package body attribute is move_x : constant integer := (if center then (core.window_width - width) / 2 else x); move_y : constant integer := (if center then (core.window_height - height) / 2 else y); begin - ui.draw_tiny_menu (move_x, move_y, width, height, true); + ui.draw_tiny_menu (move_x, move_y, width, height); ui.draw_title_bar (move_x, move_y, width, "Attributes"); -- for index in enumeration loop diff --git a/source/magic.adb b/source/magic.adb index 211af19..d5308bd 100644 --- a/source/magic.adb +++ b/source/magic.adb @@ -34,8 +34,7 @@ package body magic is procedure icon (index : in enumeration; x, y : in integer) is begin - core.draw (icon_sprite (index), x + 2, y + 2); - ui.draw_overicon (trait (index).text, x, y); + ui.draw_overicon (icon_sprite (index), trait (index).text, x, y); end icon; ------------------------------------------------------------------------------------------ @@ -58,7 +57,7 @@ package body magic is -- next : array (0 .. 7) of integer := (others => 0); begin - ui.draw_tiny_menu (move_x, move_y, width, height, true); + ui.draw_tiny_menu (move_x, move_y, width, height); ui.draw_title_bar (move_x, move_y, width, "Magic Abilities"); -- for index in enumeration loop diff --git a/source/main.adb b/source/main.adb index 673f661..29fafe1 100644 --- a/source/main.adb +++ b/source/main.adb @@ -149,8 +149,8 @@ begin -- world.draw; -- - ui.draw_menu (0, 0, preview_width, preview_height, false); - ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height, true); + ui.draw_menu (0, 0, preview_width, preview_height); + ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height); -- ui.draw_state_box (preview_width + 32, 32); -- @@ -159,6 +159,9 @@ begin --~magic.menu (0, 0, true); --~might.menu (0, 0, true); -- + ui.draw_menu (60, 60, 243, 243); + ui.draw_tiny_menu (360, 60, 243, 243); + -- menu_render; -- ui.draw_text_box (0, core.window_height - text_box_height, core.window_width, text_box_height); diff --git a/source/might.adb b/source/might.adb index 77b313c..0c50c20 100644 --- a/source/might.adb +++ b/source/might.adb @@ -34,8 +34,7 @@ package body might is procedure icon (index : in enumeration; x, y : in integer) is begin - core.draw (icon_sprite (index), x + 2, y + 2); - ui.draw_overicon (trait (index).text, x, y); + ui.draw_overicon (icon_sprite (index), trait (index).text, x, y); end icon; ------------------------------------------------------------------------------------------ @@ -58,7 +57,7 @@ package body might is -- next : array (0 .. 7) of integer := (others => 0); begin - ui.draw_tiny_menu (move_x, move_y, width, height, true); + ui.draw_tiny_menu (move_x, move_y, width, height); ui.draw_title_bar (move_x, move_y, width, "Might Abilities"); -- for index in enumeration loop diff --git a/source/resource.adb b/source/resource.adb index d4ba8b3..d9f0a5b 100644 --- a/source/resource.adb +++ b/source/resource.adb @@ -30,7 +30,7 @@ package body resource is move_x : constant integer := (if center then (core.window_width - width) / 2 else x); move_y : constant integer := (if center then (core.window_height - height) / 2 else y); begin - ui.draw_tiny_menu (move_x, move_y, width, height, true); + ui.draw_tiny_menu (move_x, move_y, width, height); ui.draw_title_bar (move_x, move_y, width, "Resources"); -- for index in enumeration loop diff --git a/source/skill.adb b/source/skill.adb index 9ea2b89..7c7d3eb 100644 --- a/source/skill.adb +++ b/source/skill.adb @@ -31,7 +31,7 @@ package body skill is move_x : constant integer := (if center then (core.window_width - width) / 2 else x); move_y : constant integer := (if center then (core.window_height - height) / 2 else y); begin - ui.draw_tiny_menu (move_x, move_y, width, height, true); + ui.draw_tiny_menu (move_x, move_y, width, height); ui.draw_title_bar (move_x, move_y, width, "Skills"); -- for index in enumeration loop diff --git a/source/ui.adb b/source/ui.adb index b8f235b..9a2321f 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -8,8 +8,32 @@ package body ui is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - sprite : array (style, enumeration) of core.sprite; - glyphs : array (style) of core.font; + type element is ( + none, + main_background, + corner_upper_left, corner_upper_right, corner_lower_left, corner_lower_right, + tiny_corner_upper_left, tiny_corner_upper_right, tiny_corner_lower_left, tiny_corner_lower_right, + border_upper, border_lower, border_left, border_right, + tiny_border_upper, tiny_border_lower, tiny_border_left, tiny_border_right, + frame_upper_left, frame_upper, frame_upper_right, + frame_left, frame_middle, frame_right, + frame_lower_left, frame_lower, frame_lower_right, + cursor, icon, overicon, + icon_upper_left, icon_upper, icon_upper_right, + icon_left, icon_right, + icon_lower_left, icon_lower, icon_lower_right, + text_upper_left, text_upper, text_upper_right, + text_left, text_middle, text_right, + text_lower_left, text_lower, text_lower_right, + fill_bar_left, fill_bar_horizontal, fill_bar_right, fill_horizontal, + scroll_bar_lower, scroll_bar_middle, scroll_bar_upper, + title_bar_left, title_bar_middle, title_bar_right + ); + + ------------------------------------------------------------------------------------------ + + sprite : array (style, element) of core.sprite; + glyphs : array (style) of core.font; ------------------------------------------------------------------------------------------ @@ -23,49 +47,49 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure draw (index : in enumeration; x, y : in integer) is + procedure draw (index : in element; x, y : in integer) is begin core.zoom := 1; - core.draw (sprite (active, index), x, y); + core.draw (sprite (active, index), x, y, 0, 0, sprite (active, index).width, sprite (active, index).height); core.zoom := 2; end draw; ------------------------------------------------------------------------------------------ - procedure crop (index : in enumeration; x, y, u, v, width, height : in integer) is + procedure crop (index : in element; x, y, width, height : in integer) is begin core.zoom := 1; - core.draw (sprite (active, index), x, y, u, v, width, height); + core.draw (sprite (active, index), x, y, 0, 0, width, height); core.zoom := 2; end crop; ------------------------------------------------------------------------------------------ - procedure draw_horizontally (index : in enumeration; x, y, width : in integer) is - base : constant integer := sprite (active, index).width; + procedure draw_horizontally (index : in element; x, y, width : in integer) is + step : constant integer := sprite (active, index).width; begin - for move in 0 .. width / base - 1 loop - draw (index, x + move * base, y); + for move in 0 .. width / step - 1 loop + draw (index, x + move * step, y); end loop; -- - crop (index, x + (width / base) * base, y, 0, 0, width mod base, sprite (active, index).height); + crop (index, x + (width / step) * step, y, width mod step, sprite (active, index).height); end draw_horizontally; ------------------------------------------------------------------------------------------ - procedure draw_vertically (index : in enumeration; x, y, height : in integer) is - base : constant integer := sprite (active, index).height; + procedure draw_vertically (index : in element; x, y, height : in integer) is + step : constant integer := sprite (active, index).height; begin - for move in 0 .. height / base - 1 loop - draw (index, x, y + move * base); + for move in 0 .. height / step - 1 loop + draw (index, x, y + move * step); end loop; -- - crop (index, x, y + (height / base) * base, 0, 0, sprite (active, index).width, height mod base); + crop (index, x, y + (height / step) * step, sprite (active, index).width, height mod step); end draw_vertically; ------------------------------------------------------------------------------------------ - procedure draw_background (index : in enumeration; x, y, width, height : in integer) is + procedure draw_background (index : in element; x, y, width, height : in integer) is base_width : integer := sprite (active, index).width; base_height : integer := sprite (active, index).height; crop_width : integer := width mod base_width; @@ -76,14 +100,14 @@ package body ui is draw (index, x + move_x * base_width, y + move_y * base_height); end loop; -- - crop (index, x + width - crop_width, y + move_y * base_height, 0, 0, crop_width, base_height); + crop (index, x + width - crop_width, y + move_y * base_height, crop_width, base_height); end loop; -- for move_x in 0 .. width / base_width - 1 loop - crop (index, x + move_x * base_width, y + height - crop_height, 0, 0, base_width, crop_height); + crop (index, x + move_x * base_width, y + height - crop_height, base_width, crop_height); end loop; -- - crop (index, x + width - crop_width, y + height - crop_height, 0, 0, crop_width, crop_height); + crop (index, x + width - crop_width, y + height - crop_height, crop_width, crop_height); end draw_background; ------------------------------------------------------------------------------------------ @@ -91,10 +115,10 @@ package body ui is procedure configure is procedure load_ui (index : in style; folder_path : in string) is begin - glyphs (index) := core.import_font ("./sprite/ui/" & folder_path & "/font.png", (if index = default then 16 else 24), 0); + glyphs (index) := core.import_font ("./sprite/ui/" & folder_path & "/font.png", 16, 0); -- - for this in enumeration loop - sprite (index, this) := core.import_sprite ("./sprite/ui/" & folder_path & core.lowercase (enumeration'image (this)) & ".png", 1, 1); + for this in element loop + sprite (index, this) := core.import_sprite ("./sprite/ui/" & folder_path & core.lowercase (element'image (this)) & ".png", 1, 1); end loop; end load_ui; begin @@ -108,9 +132,10 @@ package body ui is procedure draw_icon (data : in core.sprite; description : in string; x, y : in integer) is begin - draw (icon, x, y); select_text_box (description, x, y, core.icon, core.icon); -- + draw (icon, x, y); + -- core.zoom := 1; core.draw (data, x, y); core.zoom := 2; @@ -118,10 +143,15 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure draw_overicon (description : in string; x, y : in integer) is + procedure draw_overicon (data : in core.sprite; description : in string; x, y : in integer) is begin - draw (overicon, x, y); select_text_box (description, x, y, core.icon, core.icon); + -- + core.zoom := 1; + core.draw (data, x, y); + core.zoom := 2; + -- + draw (overicon, x, y); end draw_overicon; ------------------------------------------------------------------------------------------ @@ -183,7 +213,7 @@ package body ui is -- core.write (title, x + sprite (active, title_bar_left).width / 2, y - sprite (active, title_bar_middle).height / 2 - 4, glyphs (active)); -- - select_text_box ("", x, y - sprite (active, title_bar_middle).height, width, sprite (active, title_bar_middle).height); + select_text_box (title, x, y - sprite (active, title_bar_middle).height, width, sprite (active, title_bar_middle).height); end draw_title_bar; ------------------------------------------------------------------------------------------ @@ -199,7 +229,7 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure draw_menu (x, y, width, height : in integer; background : in boolean) is + procedure draw_menu (x, y, width, height : in integer) is offset : constant integer := sprite (active, none).width; begin if width < sprite (active, corner_upper_left).width + sprite (active, corner_upper_right).width @@ -209,10 +239,6 @@ package body ui is then return; end if; -- - if background then - draw_background (main_background, x + offset, y + offset, width - 2 * offset, height - 2 * offset); - end if; - -- declare upper : constant integer := width - sprite (active, corner_upper_left).width - sprite (active, corner_upper_right).width; lower : constant integer := width - sprite (active, corner_lower_left).width - sprite (active, corner_lower_right).width; left : constant integer := height - sprite (active, corner_upper_left).height - sprite (active, corner_lower_left).height; @@ -234,7 +260,7 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure draw_tiny_menu (x, y, width, height : in integer; background : in boolean) is + procedure draw_tiny_menu (x, y, width, height : in integer) is offset : constant integer := sprite (active, none).width; begin if width < sprite (active, tiny_corner_upper_left).width + sprite (active, tiny_corner_upper_right).width @@ -244,9 +270,7 @@ package body ui is then return; end if; -- - if background then - draw_background (main_background, x + offset, y + offset, width - 2 * offset, height - 2 * offset); - end if; + draw_background (main_background, x + offset, y + offset, width - 2 * offset, height - 2 * offset); -- declare upper : constant integer := width - sprite (active, tiny_corner_upper_left).width - sprite (active, tiny_corner_upper_right).width; lower : constant integer := width - sprite (active, tiny_corner_lower_left).width - sprite (active, tiny_corner_lower_right).width; diff --git a/source/ui.ads b/source/ui.ads index 532b2ab..af9c3f2 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -12,28 +12,6 @@ package ui is default, steam ); - type enumeration is ( - none, - main_background, - corner_upper_left, corner_upper_right, corner_lower_left, corner_lower_right, - tiny_corner_upper_left, tiny_corner_upper_right, tiny_corner_lower_left, tiny_corner_lower_right, - border_upper, border_lower, border_left, border_right, - tiny_border_upper, tiny_border_lower, tiny_border_left, tiny_border_right, - frame_upper_left, frame_upper, frame_upper_right, - frame_left, frame_middle, frame_right, - frame_lower_left, frame_lower, frame_lower_right, - cursor, icon, overicon, - icon_upper_left, icon_upper, icon_upper_right, - icon_left, icon_right, - icon_lower_left, icon_lower, icon_lower_right, - text_upper_left, text_upper, text_upper_right, - text_left, text_middle, text_right, - text_lower_left, text_lower, text_lower_right, - fill_bar_left, fill_bar_horizontal, fill_bar_right, fill_horizontal, - scroll_bar_lower, scroll_bar_middle, scroll_bar_upper, - title_bar_left, title_bar_middle, title_bar_right - ); - ------------------------------------------------------------------------------------------ active : style; @@ -43,7 +21,7 @@ package ui is procedure configure; procedure draw_icon (data : in core.sprite; description : in string; x, y : in integer); - procedure draw_overicon (description : in string; x, y : in integer); + procedure draw_overicon (data : in core.sprite; description : in string; x, y : in integer); procedure draw_text_box (x, y, width, height : in integer); @@ -52,8 +30,8 @@ package ui is procedure draw_title_bar (x, y, width : in integer; title : in string); procedure draw_scroll_bar (x, y, height : in integer; offset : in integer); - procedure draw_menu (x, y, width, height : in integer; background : in boolean); - procedure draw_tiny_menu (x, y, width, height : in integer; background : in boolean); + procedure draw_menu (x, y, width, height : in integer); + procedure draw_tiny_menu (x, y, width, height : in integer); procedure draw_icon_menu (description : in string; x, y, width, height : in integer); diff --git a/source/unit.adb b/source/unit.adb index 75dbc3e..7692f47 100644 --- a/source/unit.adb +++ b/source/unit.adb @@ -43,8 +43,7 @@ package body unit is procedure icon (index : in enumeration; x, y : in integer) is begin - core.draw (icon_sprite (index), x + 2, y + 2); - ui.draw_overicon (trait (index).text, x, y); + ui.draw_overicon (icon_sprite (index), trait (index).text, x, y); end icon; ------------------------------------------------------------------------------------------ @@ -66,7 +65,7 @@ package body unit is move_y : constant integer := (if center then (core.window_height - height) / 2 else y); move : integer := 0; begin - ui.draw_tiny_menu (move_x, move_y, width, height, true); + ui.draw_tiny_menu (move_x, move_y, width, height); ui.draw_title_bar (move_x, move_y, width, "Units"); -- for index in enumeration loop @@ -87,7 +86,7 @@ package body unit is move_y : constant integer := (if center then (core.window_height - height) / 2 else y); move : integer := 0; begin - ui.draw_tiny_menu (move_x, move_y, width, height, true); + ui.draw_tiny_menu (move_x, move_y, width, height); ui.draw_title_bar (move_x, move_y, width, trait (index).name); -- view (index, move_x + offset, move_y + offset); diff --git a/sprite/world/landmark/reeds.png b/sprite/world/landmark/reeds.png index 6f249f1..f98c491 100644 Binary files a/sprite/world/landmark/reeds.png and b/sprite/world/landmark/reeds.png differ