From cc1c48753d404771e3f8239bcb8bf5bce62c0040 Mon Sep 17 00:00:00 2001 From: xolatile Date: Wed, 1 May 2024 09:55:56 -0400 Subject: [PATCH] Added fill bar and refactored UI more... --- source/main.adb | 2 ++ source/ui.adb | 25 +++++++++++++++++++++---- source/ui.ads | 1 + sprite/ui/dwarf/fill_bar_left.png | Bin 483 -> 825 bytes 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/source/main.adb b/source/main.adb index 6696947..b7c1784 100644 --- a/source/main.adb +++ b/source/main.adb @@ -163,6 +163,8 @@ begin -- menu_render; -- + ui.draw_fill_bar (400, 400, 400, 0.6); + -- ui.synchronize; -- ui.draw_help_box (0, core.window_height - text_box_height, core.window_width, text_box_height); diff --git a/source/ui.adb b/source/ui.adb index 8853d12..093e116 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -43,10 +43,12 @@ package body ui is ------------------------------------------------------------------------------------------ + structure_limit : constant natural := 12; + sprite : array (style, element) of core.sprite; font : array (style) of core.font; - structure_array : array (0 .. 12) of structure; + structure_array : array (0 .. structure_limit) of structure; structure_count : natural := 0; @@ -180,7 +182,7 @@ package body ui is procedure synchronize is begin - for index in 0 .. 12 loop + for index in 0 .. structure_limit loop exit when index = structure_count; -- if core.signal_mode = core.signal_code'pos (structure_array (index).toggle) then @@ -323,6 +325,21 @@ package body ui is ------------------------------------------------------------------------------------------ + procedure draw_fill_bar (x, y, width : in integer; fill : in float) is + middle_width : constant integer := width - sprite (active, fill_bar_left).width - sprite (active, fill_bar_right).width; + fill_width : constant integer := integer (float (middle_width) * fill); + begin + draw (fill_bar_left, x, y - sprite (active, fill_bar_left).height); + draw (fill_bar_right, x + middle_width + sprite (active, fill_bar_left).width, y - sprite (active, fill_bar_right).height); + -- + draw_horizontally (fill_bar_horizontal, x + sprite (active, fill_bar_left).width, y - sprite (active, fill_bar_horizontal).height, middle_width); + draw_horizontally (fill_horizontal, x + sprite (active, fill_bar_left).width, y - sprite (active, fill_bar_horizontal).height, fill_width); + -- + select_text_box ("", x, y, width, sprite (active, fill_bar_horizontal).height); + end draw_fill_bar; + + ------------------------------------------------------------------------------------------ + procedure draw_scroll_bar (x, y, height : in integer; offset : in integer) is middle_height : constant integer := height - sprite (active, scroll_bar_upper).height - sprite (active, scroll_bar_lower).height; begin @@ -408,7 +425,7 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure draw_state_box (x, y : in integer) is + procedure draw_state_box (x, y : in integer) is -- TODO: Delete this at some point. begin ui.write ("Cursor X:" & core.cursor.x'image, x, y + 0); ui.write ("Cursor Y:" & core.cursor.y'image, x, y + 32); @@ -423,7 +440,7 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure add_structure (data : in structure) is + procedure add_structure (data : in structure) is -- TODO: This is dumb, tho less error-prone... begin structure_array (structure_count) := data; -- diff --git a/source/ui.ads b/source/ui.ads index 54c8b6d..4b2d4fc 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -58,6 +58,7 @@ package ui is procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle'access); 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_scroll_bar (x, y, height : in integer; offset : in integer); procedure draw_menu (x, y, width, height : in integer); diff --git a/sprite/ui/dwarf/fill_bar_left.png b/sprite/ui/dwarf/fill_bar_left.png index 5d8f26507147bc7887718f9be00bf1f1a0db6a92..87232883816139279d35965c7b13c1cb4e7ade93 100644 GIT binary patch delta 817 zcmV-11J3;81GxqviBL{Q4GJ0x0000DNk~Le0000m0000m2nGNE09OL}hmj!{e*)`C zL_t(&-ql#$(W5X7To@W~3u+-PxP@E^uHh?z8eGDCEx3iWpcW`0_YefeF~Pg26*S(A>h9*p&am`m8LpV zcLngw4EtE#>+fmy+Fk*?yZr?e%@=^5-?R;`y`1K6W+HKV5f_6W7f zI={z|Ek3oyl|IIQcCXKG{ZGCt|CFAn@wJ;nLb^g}iRIZC0cM69XqV5+HwBx2kC~fR z*h_QegJ1hW*wXsCKicOdAc9Hc%FN9qAwSwF?QKavkDGZ}<-p0{7s2qrFKWP#`lkYn zwY14A!{=jC48gzc1Gz`Lf9%L7`urMr0)rHurygi>eSQtRR*Pq!JfJ!4M3(CFpCS(c zJOHF#m*W?SGmn%dvYEj9B%tV7Wvr4T8$I&YrU%{oIUwr9Gw~MqFgw2H9RsZN++Ue~ zlGE2}AjfLMNkvTaVX5-~XaX!BOdw}WD0_}CpNQLxA9i4j5_?!^fBHfO_Rcu{_qF1; zVx0&Nb5j>Wgm6Erw5k9&ff zt@0E2T?9&pvawBWe{!0^Eo^iP{Au0jW>Cgx``~@6JbgBrZKp%TKJRHYb{PT!K1DXw z3B1jOGBke)0o8GLLFxy#8(Qu}p-s{vrbZ>-q=BZdbmUTw~Gz0000<2SrXqu0mjfcA|r# delta 472 zcmV;}0Vn>s2IB)EiBL{Q4GJ0x0000DNk~Le0000W0000W2nGNE0CReJ^pPPKe*u+A zL_t(o!|hkQb;BSOy>eK972XPJQ)&f!gf~Y@&%g-Q3amhz@~xmYol?ZeNCtg?#)G2}{YnHAJ)? z^FiifY6#ekmI3`-)~6a7FCx>$%&^vOTJG_twf@jrKlTp8;RZxRaL&y{fAxJ2tu@Z? z1p7GvUytkB%9QjfC*~=HRm99wL%N