From b6e7a1153e2967a531e02d3dbc784a53b7ae1169 Mon Sep 17 00:00:00 2001 From: xolatile Date: Sat, 17 Feb 2024 18:13:17 -0500 Subject: [PATCH] Work in progress grid rendering... --- source/core.adb | 33 +++++++++++++++++++++++++++++++++ source/core.ads | 5 +++++ source/main.adb | 7 +++++-- source/raylib.c | 6 ++++++ source/ui.adb | 2 +- source/ui.ads | 5 ++--- 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/source/core.adb b/source/core.adb index 26d125d..406618c 100644 --- a/source/core.adb +++ b/source/core.adb @@ -179,6 +179,39 @@ package body core is return result; end uppercase; + ------------------------------------------------------------------------------------------ + + procedure draw_central_grid (x, y, width, height : in integer) is + begin + render_vector (width / 2 + x, y, width / 2 + x, height + y); + render_vector ( x, height / 2 + y, width + x, height / 2 + y); + end draw_central_grid; + + ------------------------------------------------------------------------------------------ + + procedure draw_squared_grid (x, y, width, height : in integer) is + offset_x : constant integer := x + base + (width mod base) / 2; + offset_y : constant integer := y + base / 2 + (height mod base) / 2; + begin + for horizontal in 0 .. height / base + loop + render_vector (x, offset_y + horizontal * base, x + width, offset_y + horizontal * base); + -- + for vertical in 0 .. width / base + loop + render_vector (offset_x + vertical * base, y, offset_x + vertical * base, y + height); + end loop; + end loop; + end draw_squared_grid; + + ------------------------------------------------------------------------------------------ + + procedure draw_hexagon_grid (x, y, width, height : in integer) is + begin + render_vector (width / 2 + x, y, width / 2 + x, height + y); + render_vector ( x, height / 2 + y, width + x, height / 2 + y); + end draw_hexagon_grid; + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end core; diff --git a/source/core.ads b/source/core.ads index 0e1a0cd..1ed56be 100644 --- a/source/core.ads +++ b/source/core.ads @@ -72,6 +72,7 @@ package core is procedure render_sprite (sprite, x, y, u, v, width, height : in integer) with import => true, convention => c; procedure render_string (text : in string; x, y, colour : in integer; monospace : in boolean) with import => true, convention => c; + procedure render_vector (x1, y1, x2, y2 : in integer) with import => true, convention => c; function import_sprite (file_path : in string) return integer with import => true, convention => c; function sprite_width (index : in integer) return integer with import => true, convention => c; @@ -109,6 +110,10 @@ package core is function lowercase (text : in string) return string; function uppercase (text : in string) return string; + procedure draw_central_grid (x, y, width, height : in integer); + procedure draw_squared_grid (x, y, width, height : in integer); + procedure draw_hexagon_grid (x, y, width, height : in integer); + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end core; diff --git a/source/main.adb b/source/main.adb index 3090bd7..5e37179 100644 --- a/source/main.adb +++ b/source/main.adb @@ -81,6 +81,9 @@ begin --~construction.draw (this, 128 * (construction.codex'pos (this) mod 12) + 32, 128 * (construction.codex'pos (this) / 12) + 32); --~end loop; -- + core.draw_central_grid (24, 24, core.window_width - 480 - 48, core.window_height - 48); + core.draw_squared_grid (24, 24, core.window_width - 480 - 48, core.window_height - 48); + -- ui.draw_menu (0, 0, core.window_width - 480, core.window_height, false); ui.draw_tiny_menu (core.window_width - 480, 0, 480, core.window_height, true); -- @@ -99,8 +102,8 @@ begin -- core.draw_state_box (1352, 32); -- - menu.draw (menu.attribute_information, 100, 100); - menu.draw (menu.resource_information, 600, 100); + --~menu.draw (menu.attribute_information, 100, 100); + --~menu.draw (menu.resource_information, 600, 100); end loop gameplay; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/raylib.c b/source/raylib.c index 963e720..1f9aeb1 100644 --- a/source/raylib.c +++ b/source/raylib.c @@ -54,6 +54,8 @@ extern int window_height (void); extern void render_sprite (int sprite, int x, int y, int u, int v, int width, int height); extern void render_string (char * string, int x, int y, int colour, char monospace); +extern void render_vector (int x1, int y1, int x2, int y2); + extern void engine_configure (void); extern void engine_synchronize (void); @@ -103,6 +105,10 @@ void render_string (char * string, int x, int y, int colour, char monospace) { DrawTextPro ((monospace != 0) ? mono : font, string, position, dump, 0.0, 18, 3, new_tint); } +void render_vector (int x1, int y1, int x2, int y2) { + DrawLine (x1, y1, x2, y2, RED); +} + void engine_configure (void) { engine_active = 1; diff --git a/source/ui.adb b/source/ui.adb index 2ff0529..0d955ab 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -25,8 +25,8 @@ package body ui is end load_ui; begin load_ui (default, "default/"); - load_ui (yd, "yd/"); load_ui (steam, "steam/"); + --~load_ui (yd, "yd/"); -- active := default; end configure; diff --git a/source/ui.ads b/source/ui.ads index d9dc944..82aeded 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -5,7 +5,7 @@ package ui is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ type style is ( - default, yd, steam + default, steam, yd ); type codex is ( @@ -19,8 +19,7 @@ package ui is frame_left, frame_middle, frame_right, frame_lower_left, frame_lower, frame_lower_right, cursor, - fill_bar_left, fill_bar_horizontal, fill_bar_right, - fill_in_left, fill_in_horizontal, fill_in_right, + fill_bar_left, fill_bar_horizontal, fill_bar_right, fill_horizontal, scroll_bar_lower, scroll_bar_middle, scroll_bar_upper, title_bar_left, title_bar_middle, title_bar_right );