From 36358dc2c18fbf23e727615497b6227395215118 Mon Sep 17 00:00:00 2001 From: xolatile Date: Thu, 9 May 2024 11:03:39 -0400 Subject: [PATCH] Work in progress font and buttons... --- source/main.adb | 18 ++++++++++++++++++ source/ui.adb | 49 +++++++++++++++++++++++++++++++++++++++++++----- source/ui.ads | 3 ++- sprite/ui/monospace.png | Bin 0 -> 950 bytes 4 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 sprite/ui/monospace.png diff --git a/source/main.adb b/source/main.adb index 984b8c0..3b12d40 100644 --- a/source/main.adb +++ b/source/main.adb @@ -116,6 +116,16 @@ procedure main is ------------------------------------------------------------------------------------------ + procedure main_menu is + begin + draw (ashland_preview, center_x (ashland_preview.width * 2), center_y (ashland_preview.height * 2), factor => 2); + draw (game_title, center_x (game_title.width * 2), center_y (game_title.height * 2), factor => 2); + -- + write ("Main Menu", 0, 0); + end main_menu; + + ------------------------------------------------------------------------------------------ + procedure gameplay is begin if not view_list (status_preview_panel) then @@ -216,6 +226,14 @@ begin introduction; end loop introduction_loop; + main_menu_loop: loop + synchronize; + -- + exit when signal_mode = signal_a; + -- + main_menu; + end loop main_menu_loop; + gameplay_loop: loop synchronize; -- diff --git a/source/ui.adb b/source/ui.adb index 4aa7c2f..4406d4f 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -171,11 +171,18 @@ package body ui is for x in 0 .. data.gui_n - 1 loop case data.gui_list (x).kind is when gui_button => - draw_frame (data.gui_list (x).info, button_data.x, button_data.y, button_data.width, button_data.height); - draw_icon (data.gui_list (x).image, data.gui_list (x).info, button_data.x + offset, button_data.y + offset); - write (data.gui_list (x).text, - button_data.x + offset + core.icon + (core.icon - font (active).scale) / 2, - button_data.y + offset + (core.icon - font (active).scale) / 2); + --~draw_frame (data.gui_list (x).info, button_data.x, button_data.y, button_data.width, button_data.height); + --~draw_icon (data.gui_list (x).image, data.gui_list (x).info, button_data.x + offset, button_data.y + offset); + --~write (data.gui_list (x).text, + --~button_data.x + offset + core.icon + (core.icon - font (active).scale) / 2, + --~button_data.y + offset + (core.icon - font (active).scale) / 2); + draw_button (text => data.gui_list (x).text, + description => data.gui_list (x).info, + icon => data.gui_list (x).image, + x => button_data.x, + y => button_data.y, + width => button_data.width, + height => button_data.height); -- button_data.y := button_data.y + button_data.height; when gui_orient => @@ -336,10 +343,42 @@ package body ui is draw (frame_upper_right, x + width - sprite (active, frame_upper_right).width, y); draw (frame_lower_left, x, y + height - sprite (active, frame_lower_left).height); draw (frame_lower_right, x + width - sprite (active, frame_lower_right).width, y + height - sprite (active, frame_lower_right).height); + -- + if core.cursor_inside (x, y, width, height) then + core.write_text_box (description); + -- + if core.cursor_mode = 1 then + action.all; + core.cursor_mode := 0; + end if; + end if; end draw_frame; ------------------------------------------------------------------------------------------ + procedure draw_button (text, description : in string; icon : in core.sprite; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is + offset : constant integer := core.icon / 4; + begin + draw_frame (description, x, y, width, height); + draw_icon (icon, description, x + offset, y + offset); + -- + write (text, + x + offset + (core.icon - font (active).scale) / 2 + core.icon, + y + offset + (core.icon - font (active).scale) / 2, + (if core.cursor_inside (x, y, width, height) then font_tint (active) else (others => 255))); + -- + if core.cursor_inside (x, y, width, height) then + core.write_text_box (description); + -- + if core.cursor_mode = 1 then + action.all; + core.cursor_mode := 0; + end if; + end if; + end draw_button; + + ------------------------------------------------------------------------------------------ + procedure draw_title_bar (x, y, width : in integer; title : in string) is middle_width : constant integer := width - sprite (active, title_bar_left).width - sprite (active, title_bar_right).width; offset : constant integer := (sprite (active, title_bar_middle).height - font (active).scale) / 2; diff --git a/source/ui.ads b/source/ui.ads index ec9a38c..6007383 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -64,7 +64,8 @@ package ui is procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle_skip'access); - procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access); + procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access); + procedure draw_button (text, description : in string; icon : in core.sprite; x, y, width, height : in integer; action : core.pointer := core.idle_skip'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); diff --git a/sprite/ui/monospace.png b/sprite/ui/monospace.png new file mode 100644 index 0000000000000000000000000000000000000000..5ef81652ff634d91f08452ede7ef5d5757b79296 GIT binary patch literal 950 zcmV;n14;aeP)zD|25VY=wEK7(ik&&z&f8)QY-0; zAHy{dY?KgRF}?sy%^ytw%+GuMM|g!$D_&=FT3Xs`wPs{MY7Kyq0WdNEMg|xe03!on zWB`l|FfxF<5geKT%*X(4fI}0sv=7jlkpZbS07eGD$N(4_U}OM{41kdVFfzc%0PcoE z6Mz{Rz#VXCf|m9H+V=rBhg_;28g(P|VX&?==B+Y%w5@U1ETdZL9XiLz5iz&M8Z-Yt z?vyp6ovVEGKElL5KR^F{u`J8_{bmEEbcOnu)9+ooRks)OM;W8F&Gr4(EX$JoY>yUA ztG+kp)>uDv%d)KP8NWU+(bmRM?V~U_CHPm#&mg}(3z>AHNMCy0LTyr?C@<8+yp~aW z-9l|oePg0OVnrXlGUe2yi<|lr##N{t>8&UItX%%$4W`aX5DE3ALZvQ*C&xw~jX z8KFaaMt!GzYEfd$qpo?jwxoXVJ63vxzG2;V>EP-dnDOE^KHb1)n|Pg#Q)zvv_Q>{r zA6fC90n@AB806vT&Q4r6G-$g`SyJA>Hm>c9(A&nVF+SF=hsV^@M=dvi8jen_Pn!)B zofFr!MoR;3tw9^gsNKPAPQ@EzJ*$sC`=UFY|62OQp7C)~TZN9Xv|GQCn_aPDcQNd3 z4rK0zNo{Uc+0&NjN;Wid>*NycR;oC#zP)|)DviA~=I=H>dt7C-J=fi8pXAb@rhhlb zw3z&39 z?mZg|;CdrVqk+kAXaacX8X3T>skIl>X=&%xnvnsiHGo^C)&pt%?I!>?GIH~8KLKbX z9I!}_TgI;VU7=fVEYQ;4O?%p}F#?zyLlXd`)&Lk8U}OM{41kdVFfsr}1{fItBLf(PLlb}*8NeO* Y3tc*;Q#PIY`~Uy|07*qoM6N<$g5OiL6951J literal 0 HcmV?d00001