Переглянути джерело

Work in progress font and buttons...

master
Ognjen Milan Robovic 1 тиждень тому
джерело
коміт
36358dc2c1
4 змінених файлів з 64 додано та 6 видалено
  1. +18
    -0
      source/main.adb
  2. +44
    -5
      source/ui.adb
  3. +2
    -1
      source/ui.ads
  4. BIN
      sprite/ui/monospace.png

+ 18
- 0
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;
--


+ 44
- 5
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;


+ 2
- 1
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);


BIN
sprite/ui/monospace.png Переглянути файл

Перед Після
Ширина: 242  |  Висота: 80  |  Розмір: 950B

Завантаження…
Відмінити
Зберегти