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 0000000..5ef8165 Binary files /dev/null and b/sprite/ui/monospace.png differ