diff --git a/source/main.adb b/source/main.adb index 7b03200..68ed213 100644 --- a/source/main.adb +++ b/source/main.adb @@ -94,6 +94,7 @@ begin attribute.menu (300, 200, false); skill.menu (600, 300, true); resource.menu (300, 500, false); + unit.menu (300, 500, true); end loop gameplay; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/ui.adb b/source/ui.adb index 2c797af..f5f59a7 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -98,6 +98,13 @@ package body ui is ------------------------------------------------------------------------------------------ + procedure draw_overicon (x, y : in integer) is + begin + draw (overicon, x, y); + end draw_overicon; + + ------------------------------------------------------------------------------------------ + procedure draw_frame (x, y, width, height : in integer) is offset_x : constant integer := sprite (active, frame_middle).width; offset_y : constant integer := sprite (active, frame_middle).height; diff --git a/source/ui.ads b/source/ui.ads index e41da3d..90aeccc 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -18,7 +18,7 @@ package ui is frame_upper_left, frame_upper, frame_upper_right, frame_left, frame_middle, frame_right, frame_lower_left, frame_lower, frame_lower_right, - cursor, icon, + cursor, icon, overicon, 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 @@ -37,7 +37,8 @@ package ui is procedure configure; - procedure draw_icon (x, y : in integer); + procedure draw_icon (x, y : in integer); + procedure draw_overicon (x, y : in integer); procedure draw_frame (x, y, width, height : in integer); diff --git a/source/unit.adb b/source/unit.adb index e839244..cf31386 100644 --- a/source/unit.adb +++ b/source/unit.adb @@ -1,4 +1,4 @@ -with core, effect, faction, unit; +with core, ui, effect, faction, unit; use unit; @@ -8,8 +8,9 @@ package body unit is type sprite_array is array (codex) of core.sprite; - sprite : sprite_array; - --~icon : sprite_array; + sprite : sprite_array; + icon_sprite : sprite_array; + view_sprite : sprite_array; ------------------------------------------------------------------------------------------ @@ -23,7 +24,9 @@ package body unit is folder : constant string := core.lowercase (faction.codex'image (trait (index).kind)); file : constant string := core.lowercase (codex'image (index)); begin - sprite (index) := core.load_sprite ("./sprite/unit/" & folder & "/" & file & ".png", 6, 6); + sprite (index) := core.load_sprite ("./sprite/unit/" & folder & "/" & file & ".png", 6, 6); + icon_sprite (index) := core.load_sprite ("./sprite/unit/icon/" & file & ".png", 1, 1); + view_sprite (index) := core.load_sprite ("./sprite/unit/view/" & file & ".png", 1, 1); end; end loop; end configure; @@ -35,6 +38,41 @@ package body unit is core.move (sprite (index), x, y, 6, animation'pos (state)); end draw; + ------------------------------------------------------------------------------------------ + + procedure icon (index : in codex; x, y : in integer) is + begin + core.draw (icon_sprite (index), x + 2, y + 2); + ui.draw_overicon (x, y); + end icon; + + ------------------------------------------------------------------------------------------ + + procedure view (index : in codex; x, y : in integer) is + begin + core.draw (view_sprite (index), x, y); + --~ui.draw_tiny_frame (); + end view; + + ------------------------------------------------------------------------------------------ + + procedure menu (x, y : in integer; center : in boolean) is + offset : constant integer := 16; + width : constant integer := 168 * faction.count + 2 * offset; + height : constant integer := 14 * core.icon + 2 * offset; + 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_title_bar (move_x, move_y, width, "Units"); + -- + for index in codex + loop + icon (index, move_x + offset + faction.codex'pos (trait (index).kind) * 168, move_y + offset + (codex'pos (index) mod 14) * core.icon); + core.write (trait (index).name, move_x + offset + faction.codex'pos (trait (index).kind) * 168 + core.icon, move_y + offset + (codex'pos (index) mod 14) * core.icon); + end loop; + end menu; + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end unit; diff --git a/source/unit.ads b/source/unit.ads index caa0786..515de09 100644 --- a/source/unit.ads +++ b/source/unit.ads @@ -9,9 +9,9 @@ package unit is ); type codex is ( - azure_dragon, boar, crystal_dragon, diamond_golem, enchanter, faerie_dragon, - gold_golem, halfing, mummy, nomad, peasant, rogue, - rust_dragon, sharpshooter, troll, + azure_dragon, boar, crystal_dragon, enchanter, faerie_dragon, gold_golem, + halfing, mummy, nomad, peasant, rogue, rust_dragon, + sharpshooter, troll, -- pikeman, halberdier, archer, marksman, griffin, royal_griffin, swordsman, crusader, monk, zealot, cavalier, champion, @@ -22,10 +22,10 @@ package unit is behemoth, ancient_behemoth, -- imp, familiar, gog, magog, hell_hound, cerberus, - demon, horned_demon, pit_fiend, pit_lord, efreeti, efreet_sultan, + demon, horned_demon, pit_fiend, pit_lord, efreet, efreet_sultan, devil, arch_devil, -- - gremlin, master_gremlin, stone_gargoyle, obisidian_gargoyle, stone_golem, iron_golem, + gremlin, master_gremlin, stone_gargoyle, obsidian_gargoyle, stone_golem, iron_golem, mage, arch_mage, geany, master_geany, naga, naga_queen, giant, titan, -- @@ -78,7 +78,6 @@ package unit is ("Azure Dragon ", faction.neutral, 1, 2, 1, 9, effect.none), ("Boar ", faction.neutral, 1, 2, 1, 9, effect.none), ("Crystal Dragon ", faction.neutral, 1, 2, 1, 9, effect.none), - ("Diamond Golem ", faction.neutral, 1, 2, 1, 9, effect.none), ("Enchanter ", faction.neutral, 1, 2, 1, 9, effect.none), ("Faerie Dragon ", faction.neutral, 1, 2, 1, 9, effect.none), ("Gold Golem ", faction.neutral, 1, 2, 1, 9, effect.none), @@ -232,6 +231,10 @@ package unit is procedure configure; procedure draw (index : in codex; state : in animation; x, y : in integer); + procedure icon (index : in codex; x, y : in integer); + procedure view (index : in codex; x, y : in integer); + + procedure menu (x, y : in integer; center : in boolean); ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------