diff --git a/source/core.adb b/source/core.adb index 754331f..9241534 100644 --- a/source/core.adb +++ b/source/core.adb @@ -31,16 +31,16 @@ package body core is procedure draw_state_box (x, y : in integer) is begin - render_string (c_string ("Cursor X :" & integer'image (cursor_x)), x, y + 0, 16#CCCCCC#, false); - render_string (c_string ("Cursor Y :" & integer'image (cursor_y)), x, y + 32, 16#CCCCCC#, false); - render_string (c_string ("Cursor Mode :" & integer'image (cursor_mode)), x, y + 64, 16#CCCCCC#, false); - render_string (c_string ("Signal Code :" & signal_code'image (signal_code'val (signal_mode))), x, y + 96, 16#CCCCCC#, false); - render_string (c_string ("Camera X :" & integer'image (camera.x)), x, y + 128, 16#CCCCCC#, false); - render_string (c_string ("Camera Y :" & integer'image (camera.y)), x, y + 160, 16#CCCCCC#, false); - render_string (c_string ("Global Time :" & integer'image (global_time)), x, y + 192, 16#CCCCCC#, false); - render_string (c_string ("Gameplay Time :" & integer'image (gameplay_time)), x, y + 224, 16#CCCCCC#, false); - render_string (c_string ("Animation Time :" & integer'image (animation_time)), x, y + 256, 16#CCCCCC#, false); - render_string (c_string ("Framerate :" & integer'image (framerate)), x, y + 288, 16#CCCCCC#, false); + write ("Cursor X :" & integer'image (cursor_x), x, y + 0, 16#CCCCCC#); + write ("Cursor Y :" & integer'image (cursor_y), x, y + 32, 16#CCCCCC#); + write ("Cursor Mode :" & integer'image (cursor_mode), x, y + 64, 16#CCCCCC#); + write ("Signal Code :" & signal_code'image (signal_code'val (signal_mode)), x, y + 96, 16#CCCCCC#); + write ("Camera X :" & integer'image (camera.x), x, y + 128, 16#CCCCCC#); + write ("Camera Y :" & integer'image (camera.y), x, y + 160, 16#CCCCCC#); + write ("Global Time :" & integer'image (global_time), x, y + 192, 16#CCCCCC#); + write ("Gameplay Time :" & integer'image (gameplay_time), x, y + 224, 16#CCCCCC#); + write ("Animation Time :" & integer'image (animation_time), x, y + 256, 16#CCCCCC#); + write ("Framerate :" & integer'image (framerate), x, y + 288, 16#CCCCCC#); end draw_state_box; ------------------------------------------------------------------------------------------ diff --git a/source/main.adb b/source/main.adb index 08bc07f..2218409 100644 --- a/source/main.adb +++ b/source/main.adb @@ -48,6 +48,7 @@ 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); @@ -111,9 +112,12 @@ begin -- core.draw_state_box (preview_width + 32, 32); -- - menu.draw (menu.resource_information, 420, 100, false); - menu.draw (menu.skill_information, 740, 100, false); - menu.draw (menu.attribute_information, 100, 100, true); + menu.draw (menu.attribute_information, 100, 100, false); + 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#); end loop gameplay; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/menu.adb b/source/menu.adb index e920737..fb59c1e 100644 --- a/source/menu.adb +++ b/source/menu.adb @@ -6,11 +6,18 @@ 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; + + ------------------------------------------------------------------------------------------ + procedure configure is begin - trait (attribute_information) := ("Attribute Information ", attribute.count, 10, new element_array (0 .. attribute.count - 1)); - trait (skill_information) := ("Skill Information ", skill.count, 10, new element_array (0 .. skill.count - 1)); - trait (resource_information) := ("Resource Information ", resource.count, 10, new element_array (0 .. resource.count - 1)); + 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)); -- for index in attribute.codex loop @@ -30,13 +37,31 @@ package body menu is ------------------------------------------------------------------------------------------ + procedure synchronize is + limitation : integer; + begin + for index in codex + loop + 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 := codex'pos (index); + return; + else + mouse_over_menu := codex'pos (none); + end if; + end loop; + end synchronize; + + ------------------------------------------------------------------------------------------ + procedure draw (index : in codex; x, y : in integer; center : in boolean) is - draw_offset : constant integer := 16; - icon_offset : constant integer := 4; - icon_size : constant integer := 32; - offset : constant integer := icon_size + 2 * icon_offset; + scroll_bar : constant boolean := (if trait (index).length < trait (index).height then false else true); limitation : constant integer := (if trait (index).length < trait (index).height then trait (index).length else trait (index).height); - width : constant integer := 240; + 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); @@ -53,8 +78,8 @@ package body menu is loop ui.draw_frame (offset_x + draw_offset, offset_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 + icon_offset + offset, offset_y + draw_offset + icon_offset + element_index * 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); end loop; end draw; diff --git a/source/menu.ads b/source/menu.ads index cd51a7d..a22f971 100644 --- a/source/menu.ads +++ b/source/menu.ads @@ -9,7 +9,7 @@ package menu is ); type codex is ( - none, attribute_information, skill_information, resource_information + attribute_information, skill_information, resource_information, none ); ------------------------------------------------------------------------------------------ @@ -29,6 +29,8 @@ package menu is title : core.short_string; length : integer; height : integer; + x : integer; + y : integer; elements : access element_array; end record; @@ -36,11 +38,15 @@ package menu is ------------------------------------------------------------------------------------------ + mouse_over_menu : integer; + mouse_over_menu_element : integer; + trait : trait_array; ------------------------------------------------------------------------------------------ procedure configure; + procedure synchronize; procedure draw (index : in codex; x, y : in integer; center : in boolean);