From 6cf54f7fac9406a0b6d6330d752e3f3816595a3f Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 19 Feb 2024 18:15:20 -0500 Subject: [PATCH] Menu title in mouse over menu selection... --- source/main.adb | 4 ++-- source/menu.adb | 29 +++++++++++++++-------------- source/menu.ads | 4 ++-- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/source/main.adb b/source/main.adb index 2218409..49040d5 100644 --- a/source/main.adb +++ b/source/main.adb @@ -116,8 +116,8 @@ begin menu.draw (menu.skill_information, 700, 100, false); menu.draw (menu.resource_information, 400, 100, false); -- - core.write ("Menu :" & integer'image (menu.mouse_over_menu), preview_width + 32, 32 + 320, 16#CCCCCC#); - core.write ("Menu Element :" & integer'image (menu.mouse_over_menu_element), preview_width + 32, 32 + 352, 16#CCCCCC#); + core.write ("Menu :" & menu.trait (menu.mouse_over_menu).title, preview_width + 32, 32 + 320, 16#CCCCCC#); + --~core.write ("Menu Element :" & menu.trait (menu.mouse_over_menu_element).name, preview_width + 32, 32 + 352, 16#CCCCCC#); end loop gameplay; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/menu.adb b/source/menu.adb index fb59c1e..7e14520 100644 --- a/source/menu.adb +++ b/source/menu.adb @@ -18,27 +18,28 @@ package body menu is trait (attribute_information) := ("Attribute Information ", attribute.count, 10, 100, 64, new element_array (0 .. attribute.count - 1)); trait (skill_information) := ("Skill Information ", skill.count, 10, 700, 64, new element_array (0 .. skill.count - 1)); trait (resource_information) := ("Resource Information ", resource.count, 10, 400, 64, new element_array (0 .. resource.count - 1)); + trait (none) := ("-- ", 0, 10, 0, 0, null); -- for index in attribute.codex loop - trait (attribute_information).elements (attribute.codex'pos (index)) := (button, 0, attribute.trait (index).name, attribute.icon (index)); + trait (attribute_information).elements (attribute.codex'pos (index)) := (button, attribute.codex'pos (index), attribute.trait (index).name, attribute.icon (index)); end loop; -- for index in skill.codex loop - trait (skill_information).elements (skill.codex'pos (index)) := (button, 0, skill.trait (index).name, skill.icon (index)); + trait (skill_information).elements (skill.codex'pos (index)) := (button, skill.codex'pos (index), skill.trait (index).name, skill.icon (index)); end loop; -- for index in resource.codex loop - trait (resource_information).elements (resource.codex'pos (index)) := (button, 0, resource.trait (index).name, resource.icon (index)); + trait (resource_information).elements (resource.codex'pos (index)) := (button, resource.codex'pos (index), resource.trait (index).name, resource.icon (index)); end loop; end configure; ------------------------------------------------------------------------------------------ procedure synchronize is - limitation : integer; + limitation : integer; begin for index in codex loop @@ -48,10 +49,10 @@ package body menu is 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 := codex'pos (index); + mouse_over_menu := index; return; else - mouse_over_menu := codex'pos (none); + mouse_over_menu := none; end if; end loop; end synchronize; @@ -63,23 +64,23 @@ package body menu is limitation : constant integer := (if trait (index).length < trait (index).height then trait (index).length else trait (index).height); width : constant integer := 2 * draw_offset + offset + 24 * 8; height : constant integer := limitation * offset + 2 * draw_offset; - -- - offset_x : constant integer := (if center then (core.window_width - width) / 2 else x); - offset_y : constant integer := (if center then (core.window_height - height) / 2 else y); begin if index = none then return; end if; -- - ui.draw_title_bar (offset_x, offset_y, width, trait (index).title); - ui.draw_tiny_menu (offset_x, offset_y, width, height, true); + 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 (offset_x + draw_offset, offset_y + draw_offset + element_index * offset, width - 2 * draw_offset, offset); + 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, offset_x + draw_offset + icon_offset, offset_y + draw_offset + icon_offset + element_index * offset); - core.write (trait (index).elements (element_index).text, offset_x + draw_offset + offset, offset_y + draw_offset + 2 * icon_offset + element_index * 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; end draw; diff --git a/source/menu.ads b/source/menu.ads index a22f971..873d924 100644 --- a/source/menu.ads +++ b/source/menu.ads @@ -38,8 +38,8 @@ package menu is ------------------------------------------------------------------------------------------ - mouse_over_menu : integer; - mouse_over_menu_element : integer; + mouse_over_menu : codex; + mouse_over_menu_element : codex; trait : trait_array;