From 38ff1739ae612c2f2caf30dcf5291537082a65ff Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 19 May 2024 05:18:19 -0400 Subject: [PATCH] Tested out tinted tiny fill bars, works, uploading other sprites soon... --- source/chad.adb | 6 +++--- source/ui.adb | 29 ++++++++++++++++++++++++----- source/ui.ads | 2 +- ui/dwarf/tiny_fill_bar_horizontal.png | Bin 166 -> 162 bytes ui/dwarf/tiny_fill_horizontal.png | Bin 142 -> 137 bytes 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/source/chad.adb b/source/chad.adb index 3c3907e..2b8667d 100644 --- a/source/chad.adb +++ b/source/chad.adb @@ -53,9 +53,9 @@ package body chad is -- ui.draw_sprite (view (player.index), trait (player.index).name, x + offset, y + offset, 0); -- - ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 1 * core.icon + offset, 4 * core.icon, float (player.health.value) / float (player.health.limit)); - ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 2 * core.icon + offset, 4 * core.icon, float (player.mana.value) / float (player.mana.limit)); - ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 3 * core.icon + offset, 4 * core.icon, float (player.stamina.value) / float (player.stamina.limit)); + ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 1 * core.icon + offset, 4 * core.icon, float (player.health.value) / float (player.health.limit), (255, 0, 0, 255)); + ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 2 * core.icon + offset, 4 * core.icon, float (player.mana.value) / float (player.mana.limit), (0, 0, 255, 255)); + ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 3 * core.icon + offset, 4 * core.icon, float (player.stamina.value) / float (player.stamina.limit), (0, 255, 0, 255)); -- ui.write (text => "Health " & player.health.value'image & " /" & player.health.limit'image, x => x + view_width + 4 * core.icon + 3 * offset, diff --git a/source/ui.adb b/source/ui.adb index 21ffdc2..cbdf4a1 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -467,15 +467,34 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure draw_tiny_fill_bar (x, y, width : in integer; fill : in float) is + procedure draw_tiny_fill_bar (x, y, width : in integer; fill : in float; tint : in core.colour) is middle_width : constant integer := width - sprite (active, tiny_fill_bar_left).width - sprite (active, tiny_fill_bar_right).width; fill_width : constant integer := integer (float (middle_width) * fill); + crop_width : constant integer := sprite (active, tiny_fill_horizontal).width; + crop_height : constant integer := sprite (active, tiny_fill_horizontal).height; begin - draw (tiny_fill_bar_left, x, y - sprite (active, tiny_fill_bar_left).height); - draw (tiny_fill_bar_right, x + middle_width + sprite (active, tiny_fill_bar_left).width, y - sprite (active, tiny_fill_bar_right).height); + draw (tiny_fill_bar_left, x, y - crop_height); + draw (tiny_fill_bar_right, x + middle_width + crop_width, y - crop_height); -- - draw_horizontally (tiny_fill_bar_horizontal, x + sprite (active, tiny_fill_bar_left).width, y - sprite (active, tiny_fill_bar_horizontal).height, middle_width); - draw_horizontally (tiny_fill_horizontal, x + sprite (active, tiny_fill_bar_left).width, y - sprite (active, tiny_fill_bar_horizontal).height, fill_width); + draw_horizontally (tiny_fill_bar_horizontal, x + sprite (active, tiny_fill_bar_left).width, y - crop_height, middle_width); + -- + for move in 0 .. fill_width / crop_width - 1 loop + core.draw (data => sprite (active, tiny_fill_horizontal), + x => x + crop_width + move * crop_width, + y => y - crop_height, + tint => tint, + factor => 1); + end loop; + -- + if width mod crop_width > 0 then + core.draw (data => sprite (active, tiny_fill_horizontal), + x => x + crop_width + (fill_width / crop_width) * crop_width, + y => y - crop_height, + width => fill_width mod crop_width, + height => crop_height, + tint => tint, + factor => 1); + end if; end draw_tiny_fill_bar; ------------------------------------------------------------------------------------------ diff --git a/source/ui.ads b/source/ui.ads index ddf8834..e0929a7 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -74,7 +74,7 @@ package ui is procedure draw_title_bar (x, y, width : in integer; title : in string); procedure draw_fill_bar (x, y, width : in integer; fill : in float); - procedure draw_tiny_fill_bar (x, y, width : in integer; fill : in float); + procedure draw_tiny_fill_bar (x, y, width : in integer; fill : in float; tint : in core.colour); procedure draw_scroll_bar (x, y, height : in integer; offset : in integer); procedure draw_menu (x, y, width, height : in integer); diff --git a/ui/dwarf/tiny_fill_bar_horizontal.png b/ui/dwarf/tiny_fill_bar_horizontal.png index a8722210635db97f8ffafb63d1090c718b22df1e..f64468512a8e4e24d4e1a5705708d0caeb7bb829 100644 GIT binary patch delta 112 zcmV-$0FVEs0ipqrIcZc$L_t(o!|m3w4ZuJML(zZeCSew4VQjCGRGGm=?1uIU31mqA zp3~ir6L5Fex`8Vx04ty*F*CU40jyV0?mrMf009ILKmmNE#4%IJ(unMUBzXZk0j2?vIc-=;L_t(o!|m2h4Zu(c1K_?NCAClsXhFx6Vr7%j!`e%)Uq~PT z$=|a`zD~gHZtDc@%miQs97&HP0Dz-cRav)SyYD~%0R#|002=^E!qs`n@)6kqN%8?) WswdrP%THYZ0000|~r^8DQ<{;usQf`0eFDUIqgW=8JhV>r*ovoOBH&|2~-4?&aZRf{GGjo9^)jF#v(5tDnm{r-UW|f*~Ji delta 92 zcmV-i0Hgnj0geHXIaNSOL_t(o!|l^i5da_v1W|M-U