diff --git a/source/core.adb b/source/core.adb index c535bea..17e7986 100644 --- a/source/core.adb +++ b/source/core.adb @@ -134,6 +134,18 @@ package body core is ------------------------------------------------------------------------------------------ + function center_x (object : in integer) return integer is begin return (window_width - object) / 2; end center_x; + function center_y (object : in integer) return integer is begin return (window_height - object) / 2; end center_y; + + ------------------------------------------------------------------------------------------ + + function cursor_inside (x, y, width, height : in integer) return boolean is + begin + return cursor.x > x and cursor.x < x + width and cursor.y > y and cursor.y < y + height; + end cursor_inside; + + ------------------------------------------------------------------------------------------ + function import_sprite (file_path : in string; frames, states : in integer) return sprite is this : sprite; begin @@ -217,8 +229,8 @@ package body core is ray.draw_text (data => font_array (data.index), text => c_string (text), view => (float (x), float (y)), - scale => float ((if size = 0 then data.scale else size)), - space => float (data.space), + scale => (if size = 0 then float (font_array (data.index).base) else float (size)), + space => float (font_array (data.index).pad), tint => new_tint); end write; diff --git a/source/core.ads b/source/core.ads index ea49379..29090d9 100644 --- a/source/core.ads +++ b/source/core.ads @@ -110,6 +110,11 @@ package core is function window_width return integer; function window_height return integer; + function center_x (object : in integer) return integer; + function center_y (object : in integer) return integer; + + function cursor_inside (x, y, width, height : in integer) return boolean; + function import_sprite (file_path : in string; frames, states : in integer) return sprite; function import_font (file_path : in string; scale, space : in integer) return font; function import_song (file_path : in string) return song; diff --git a/source/main.adb b/source/main.adb index 33b709a..3db62f5 100644 --- a/source/main.adb +++ b/source/main.adb @@ -105,7 +105,7 @@ procedure main is procedure introduction is begin - ui.write ("[-- Please press Spacebar to continue]", 0, 0, 14, (102, 102, 102, 255)); + core.write ("[-- Please press Spacebar to continue]", 0, center_y (24), (102, 102, 102, 255)); end introduction; ------------------------------------------------------------------------------------------ diff --git a/source/ui.adb b/source/ui.adb index 555904f..c4eed13 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -70,13 +70,6 @@ package body ui is ------------------------------------------------------------------------------------------ - function cursor_inside (x, y, width, height : in integer) return boolean is - begin - return core.cursor.x > x and core.cursor.x < x + width and core.cursor.y > y and core.cursor.y < y + height; - end cursor_inside; - - ------------------------------------------------------------------------------------------ - procedure draw (index : in element := none; x : in integer := 0; y : in integer := 0; @@ -229,6 +222,8 @@ package body ui is procedure synchronize is use core; begin + prioritize := false; + -- for index in 0 .. structure_count - 1 loop if signal_mode = structure_array (index).toggle then structure_array (index).show := not structure_array (index).show; @@ -236,13 +231,15 @@ package body ui is -- if structure_array (index).show then draw_structure (structure_array (index)); + -- + prioritize := true; end if; end loop; end synchronize; ------------------------------------------------------------------------------------------ - procedure write (text : in string; x, y : in integer; size : in natural := 0; tint : in core.colour := (others => 255)) is + procedure write (text : in string; x, y : in integer; tint : in core.colour := (others => 255); size : in natural := 0) is begin core.write (text, x, y, tint, font (active).scale, font (active)); end write; @@ -258,7 +255,7 @@ package body ui is core.draw (data, x, y); core.zoom := save_zoom; -- - if cursor_inside (x, y, core.icon, core.icon) then + if core.cursor_inside (x, y, core.icon, core.icon) then draw (icon_selected, x, y); -- core.write_text_box (description); @@ -360,7 +357,7 @@ package body ui is -- draw_horizontally (title_bar_middle, x + sprite (active, title_bar_left).width, y - sprite (active, title_bar_middle).height, middle_width); -- - write (title, x + sprite (active, title_bar_left).width + offset, y - font (active).scale - 4, tint => font_tint (active)); + write (title, x + sprite (active, title_bar_left).width, y - font (active).scale - 4, tint => font_tint (active)); end draw_title_bar; ------------------------------------------------------------------------------------------ diff --git a/source/ui.ads b/source/ui.ads index 6de346e..5ae989e 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -47,14 +47,15 @@ package ui is ------------------------------------------------------------------------------------------ - active : style := main; + active : style := main; + prioritize : boolean := false; ------------------------------------------------------------------------------------------ procedure configure; procedure synchronize; - procedure write (text : in string; x, y : in integer; size : in natural := 0; tint : in core.colour := (others => 255)); + procedure write (text : in string; x, y : in integer; tint : in core.colour := (others => 255); size : in natural := 0); procedure draw_icon (data : in core.sprite; description : in string; x, y : in integer; action : core.pointer := core.idle'access); procedure draw_overicon (data : in core.sprite; description : in string; x, y : in integer; action : core.pointer := core.idle'access); diff --git a/source/world.adb b/source/world.adb index 80d526e..c9468a0 100644 --- a/source/world.adb +++ b/source/world.adb @@ -130,16 +130,15 @@ package body world is v => v, width => core.base, height => core.base); - --~--MOVE PLAYER TO TILE WHERE YOU CLICKED - --~if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - --~and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom - --~and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom - --~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom - --~and core.cursor_mode = 1 then - --~core.camera.x := horizontal; - --~core.camera.y := vertical; - --~core.cursor_mode := 0; - --~end if; + if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6 + and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6 + and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom - 6 + and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom + 6 + and core.cursor_mode = 1 and not ui.prioritize then + core.camera.x := horizontal; + core.camera.y := vertical; + core.cursor_mode := 0; + end if; end if; end loop; end loop; @@ -174,7 +173,7 @@ package body world is for horizontal in 0 .. map.width - 1 loop exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width; -- - if (horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach then + if (horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach then core.draw (data => dark, x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom, y => offset.y + (vertical - core.camera.y) * core.base * core.zoom); @@ -189,11 +188,6 @@ package body world is offset : core.vector := ((core.window_width - core.base) / 2, (core.window_height - core.base) / 2); begin - --~for x in 0 .. view_reach loop - --~for y in 0 .. view_reach loop - --~map.views ((x + core.camera.x - view_reach / 2) mod map.width, (y + core.camera.y - view_reach / 2) mod map.height) := true; - --~end loop; - --~end loop; for vertical in 0 .. map.height - 1 loop exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height; -- diff --git a/sprite/ui/dwarf/title_bar_left.png b/sprite/ui/dwarf/title_bar_left.png index 55dc9df..96a3bbb 100644 Binary files a/sprite/ui/dwarf/title_bar_left.png and b/sprite/ui/dwarf/title_bar_left.png differ diff --git a/sprite/ui/dwarf/title_bar_middle.png b/sprite/ui/dwarf/title_bar_middle.png index a2a6cb2..1286a7f 100644 Binary files a/sprite/ui/dwarf/title_bar_middle.png and b/sprite/ui/dwarf/title_bar_middle.png differ diff --git a/sprite/ui/dwarf/title_bar_right.png b/sprite/ui/dwarf/title_bar_right.png index af7819f..d8dadd2 100644 Binary files a/sprite/ui/dwarf/title_bar_right.png and b/sprite/ui/dwarf/title_bar_right.png differ