From b016ea93e7673c65d572b237fb9ebca4c68035b8 Mon Sep 17 00:00:00 2001 From: xolatile Date: Sat, 4 May 2024 08:40:03 -0400 Subject: [PATCH] Added icon selection... --- source/core.adb | 18 +++++++++--------- source/ui.adb | 27 ++++++++++++++++++++------- sprite/ui/dwarf/icon_selected.png | Bin 0 -> 296 bytes sprite/ui/fairy/icon_selected.png | Bin 0 -> 147 bytes sprite/ui/gnoll/icon_selected.png | Bin 0 -> 147 bytes sprite/ui/goblin/icon_selected.png | Bin 0 -> 147 bytes sprite/ui/imp/icon_selected.png | Bin 0 -> 171 bytes sprite/ui/kobold/icon_selected.png | Bin 0 -> 147 bytes sprite/ui/main/icon_selected.png | Bin 0 -> 147 bytes 9 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 sprite/ui/dwarf/icon_selected.png create mode 100644 sprite/ui/fairy/icon_selected.png create mode 100644 sprite/ui/gnoll/icon_selected.png create mode 100644 sprite/ui/goblin/icon_selected.png create mode 100644 sprite/ui/imp/icon_selected.png create mode 100644 sprite/ui/kobold/icon_selected.png create mode 100644 sprite/ui/main/icon_selected.png diff --git a/source/core.adb b/source/core.adb index 04c3497..3d30672 100644 --- a/source/core.adb +++ b/source/core.adb @@ -337,15 +337,15 @@ package body core is when others => signal_mode := signal_code'pos (signal_none); end case; -- - for index in reverse 0 .. block_count - 1 loop - if core.cursor.x > block_array (index).x and core.cursor.x < block_array (index).width - and core.cursor.y > block_array (index).y and core.cursor.y < block_array (index).height - and core.cursor_mode = block_array (index).mode then - block_array (index).action.all; - core.cursor_mode := 0; - exit; - end if; - end loop; + --~for index in reverse 0 .. block_count - 1 loop + --~if core.cursor.x > block_array (index).x and core.cursor.x < block_array (index).width + --~and core.cursor.y > block_array (index).y and core.cursor.y < block_array (index).height + --~and core.cursor_mode = block_array (index).mode then + --~block_array (index).action.all; + --~core.cursor_mode := 0; + --~exit; + --~end if; + --~end loop; -- block_count := 0; -- diff --git a/source/ui.adb b/source/ui.adb index d6f0c2e..a4d21cc 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -32,7 +32,7 @@ package body ui is text_left, text_middle, text_right, text_lower_left, text_lower, text_lower_right, -- - cursor, icon, overicon, + cursor, icon, overicon, icon_selected, -- fill_bar_left, fill_bar_horizontal, fill_bar_right, fill_horizontal, -- @@ -54,10 +54,22 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure select_text_box (text : in string; x, y, width, height : in integer) is + function cursor_inside (x, y, width, height : in integer) return boolean is begin + --~return (core.cursor.x > x and core.cursor.x < x + width and core.cursor.y > y and core.cursor.y < y + height); if core.cursor.x > x and core.cursor.x < x + width and core.cursor.y > y and core.cursor.y < y + height then + return true; + else + return false; + end if; + end cursor_inside; + + ------------------------------------------------------------------------------------------ + + procedure select_text_box (text : in string; x, y, width, height : in integer) is + begin + if cursor_inside (x, y, width, height) then core.write_text_box (text); end if; end select_text_box; @@ -228,11 +240,12 @@ package body ui is core.draw (data, x, y); core.zoom := save_zoom; -- - if core.cursor.x > x and core.cursor.x < x + core.icon - and core.cursor.y > y and core.cursor.y < y + core.icon - and core.cursor_mode = 1 then - action.all; - core.cursor_mode := 0; + if cursor_inside (x, y, core.icon, core.icon) then + draw (icon_selected, x, y); + if core.cursor_mode = 1 then + action.all; + core.cursor_mode := 0; + end if; end if; end draw_icon; diff --git a/sprite/ui/dwarf/icon_selected.png b/sprite/ui/dwarf/icon_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..a6e869ece856df0e4ef833ce51a455265bec8325 GIT binary patch literal 296 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?31We{epSZZGe6ujl> z;usQf`0aH^(Pjf4wg)Ba+0qon(inNC3UDhdl$sF08!@BRLqllOVZ8$$)trwf#r&50 zf8Cw`C$kBgAS+MX%;qw&sD~~o6Zt>etnOIR%72()wP3?O4ohbj-9Iyp_XHa;?(qr~ z4CIbq&N<^I3xlSq;O%<7%~mdKI;Vst0I>ln&Hw-a literal 0 HcmV?d00001 diff --git a/sprite/ui/gnoll/icon_selected.png b/sprite/ui/gnoll/icon_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..f6907d3ee24076811141767fb333c4adba958a81 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?31We{epSZZGe6m<1; zaSVw#{Py}rK?Va3r@)h`OyB2E6is@~vhZg~$UbYW)Zd{7%MW!jztg+BR^I*l8y}!1 gIB2kNuvwmYfMHrJ_vN}=Z#j^Jr>mdKI;Vst0I>ln&Hw-a literal 0 HcmV?d00001 diff --git a/sprite/ui/goblin/icon_selected.png b/sprite/ui/goblin/icon_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..f6907d3ee24076811141767fb333c4adba958a81 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?31We{epSZZGe6m<1; zaSVw#{Py}rK?Va3r@)h`OyB2E6is@~vhZg~$UbYW)Zd{7%MW!jztg+BR^I*l8y}!1 gIB2kNuvwmYfMHrJ_vN}=Z#j^Jr>mdKI;Vst0I>ln&Hw-a literal 0 HcmV?d00001 diff --git a/sprite/ui/imp/icon_selected.png b/sprite/ui/imp/icon_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..632db4d51b54ba20ece36bed5af0f976946bd4eb GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?31We{epSZZGe6pZzB zaSVw#{Py}r-Ub66my7vNI3uP>Mwn?kaC3Ba#e800`f<*O&v22D}E_d_I@9w-)@; zoHg-v_jm8Tb?@qL@BG2R!XcpG(7?dR1Y}%@|Nm`e!;xMIdB>&aKMPA*bFL1|)y@N2 O#Ng@b=d#Wzp$Pze3^@J( literal 0 HcmV?d00001 diff --git a/sprite/ui/kobold/icon_selected.png b/sprite/ui/kobold/icon_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..f6907d3ee24076811141767fb333c4adba958a81 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?31We{epSZZGe6m<1; zaSVw#{Py}rK?Va3r@)h`OyB2E6is@~vhZg~$UbYW)Zd{7%MW!jztg+BR^I*l8y}!1 gIB2kNuvwmYfMHrJ_vN}=Z#j^Jr>mdKI;Vst0I>ln&Hw-a literal 0 HcmV?d00001 diff --git a/sprite/ui/main/icon_selected.png b/sprite/ui/main/icon_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..f6907d3ee24076811141767fb333c4adba958a81 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?31We{epSZZGe6m<1; zaSVw#{Py}rK?Va3r@)h`OyB2E6is@~vhZg~$UbYW)Zd{7%MW!jztg+BR^I*l8y}!1 gIB2kNuvwmYfMHrJ_vN}=Z#j^Jr>mdKI;Vst0I>ln&Hw-a literal 0 HcmV?d00001