From d6844ce19e58357b2451d8d4c715d744036f3fc0 Mon Sep 17 00:00:00 2001 From: xolatile Date: Sat, 30 Dec 2023 07:14:08 -0500 Subject: [PATCH] Changed GUI overlay... --- source/engine.c | 99 ++++++++------------------------------------------------- source/engine.h | 2 +- source/main.c | 5 +-- 3 files changed, 15 insertions(+), 91 deletions(-) diff --git a/source/engine.c b/source/engine.c index 3b7811e..f5cd556 100644 --- a/source/engine.c +++ b/source/engine.c @@ -5,7 +5,6 @@ #include #include #include -#include static void limit (int * pointer, int minimum, int maximum) { if (* pointer < minimum) { * pointer = minimum; } @@ -26,12 +25,7 @@ static void show_skill_menu (void) { menu_show [menu_skills] = menu_show [men static void show_value_menu (void) { menu_show [menu_values] = menu_show [menu_values] ? 0 : 1; } static void show_resoo_menu (void) { menu_show [menu_resources] = menu_show [menu_resources] ? 0 : 1; } -static void (* action_list [signal_count]) (void); - -int camera_x = 0; -int camera_y = 0; - -void view_hud (int x, int y, int width, int height, int small, int alpha) { +static void view_hud (int x, int y, int width, int height, int small, int alpha) { int i, j, u, v; u = width % ICON_SIZE; @@ -76,6 +70,18 @@ void view_hud (int x, int y, int width, int height, int small, int alpha) { } } +static void (* action_list [signal_count]) (void); + +int camera_x = 0; +int camera_y = 0; + +void view_side (void) { + view_map_overlay (); + + view_hud (render_width () - SIDE_SIZE, 0, SIDE_SIZE, render_height (), 0, 0); + view_hud (0, 0, render_width () - SIDE_SIZE, render_height (), 0, 1); +} + void view_menu (int menu, int x, int y, int small, int align, int alpha) { int item, aligned_x, aligned_y, i, j; @@ -169,84 +175,5 @@ void engine_configure (void) { } void engine_synchronize (void) { - /*if (IsKeyPressed (KEY_RIGHT)) { camera_x++; limit (& camera_x, 0, world_width - (render_width () / (int) (BASE_SIZE * render_zoom))); } - if (IsKeyPressed (KEY_LEFT)) { camera_x--; limit (& camera_x, 0, world_width - (render_width () / (int) (BASE_SIZE * render_zoom))); } - if (IsKeyPressed (KEY_DOWN)) { camera_y++; limit (& camera_y, 0, world_height - (render_height () / (int) (BASE_SIZE * render_zoom))); } - if (IsKeyPressed (KEY_UP)) { camera_y--; limit (& camera_y, 0, world_height - (render_height () / (int) (BASE_SIZE * render_zoom))); } - - if (IsKeyPressed (KEY_T)) { menu_show [menu_traits] = menu_show [menu_traits] ? 0 : 1; } - if (IsKeyPressed (KEY_S)) { menu_show [menu_skills] = menu_show [menu_skills] ? 0 : 1; } - if (IsKeyPressed (KEY_V)) { menu_show [menu_values] = menu_show [menu_values] ? 0 : 1; } - if (IsKeyPressed (KEY_R)) { menu_show [menu_resources] = menu_show [menu_resources] ? 0 : 1; }*/ - action_list [signal] (); - - /*if (IsKeyPressed (KEY_P)) { dump_world_screenshot (); }*/ } - -/*static void dump_block (unsigned int * * * pixels, unsigned int * source, int index, int x, int y) { - int i, j; - - for (i = 0; i < BASE_SIZE; ++i) { - for (j = 0; j < BASE_SIZE; ++j) { - pixels [x] [y] [i * BASE_SIZE + j] = source [index * BASE_SIZE * BASE_SIZE + i * BASE_SIZE + j]; - } - } -} - -static void dump_world_screenshot (void) { - unsigned int * * * screenshot; - unsigned int * a; - - unsigned int map [28 * BASE_SIZE * 12 * BASE_SIZE]; - - int i, j, k; - - png_image input = { 0 }; - png_image output = { 0 }; - - input.version = PNG_IMAGE_VERSION; - - png_image_begin_read_from_file (& input, "sprite/ashlands.png"); - - input.format = PNG_FORMAT_RGBA; - - png_image_finish_read (& input, NULL, map, 0, NULL); - - png_image_free (& input); - - a = calloc (CHAD_WORLD_SIZE * CHAD_WORLD_SIZE * BASE_SIZE * BASE_SIZE, sizeof (* a)); - screenshot = calloc (CHAD_WORLD_SIZE, sizeof (* screenshot)); - for (i = 0; i < CHAD_WORLD_SIZE; ++i) { - screenshot [i] = calloc (CHAD_WORLD_SIZE, sizeof (* * screenshot)); - for (j = 0; j < CHAD_WORLD_SIZE; ++j) { - screenshot [i] [j] = calloc (BASE_SIZE * BASE_SIZE, sizeof (* * * screenshot)); - } - } - - for (i = 0; i < CHAD_WORLD_SIZE; ++i) { - for (j = 0; j < CHAD_WORLD_SIZE; ++j) { - dump_block (screenshot, map, world [0] [i] [j], i, j); - } - } - - for (i = 0; i < CHAD_WORLD_SIZE; ++i) { - for (j = 0; j < CHAD_WORLD_SIZE; ++j) { - for (k = 0; k < BASE_SIZE * BASE_SIZE; ++k) { - a [(i * CHAD_WORLD_SIZE + j) * BASE_SIZE * BASE_SIZE + k] = screenshot [i] [j] [k]; - } - } - } - - output.version = PNG_IMAGE_VERSION; - output.format = PNG_FORMAT_RGBA; - output.width = (unsigned int) (CHAD_WORLD_SIZE * BASE_SIZE); - output.height = (unsigned int) (CHAD_WORLD_SIZE * BASE_SIZE); - - if (png_image_write_to_file (& output, "a.png", 0, a, 0, NULL) == 0) write (1, "\033[1;31mFailed to export render as PNG image!\033[0m\n", 49); - - png_image_free (& output); - - free (screenshot); - free (a); -}*/ diff --git a/source/engine.h b/source/engine.h index 217090a..3b28ce5 100644 --- a/source/engine.h +++ b/source/engine.h @@ -4,7 +4,7 @@ extern int camera_x; extern int camera_y; -extern void view_hud (int x, int y, int width, int height, int small, int alpha); +extern void view_side (void); extern void view_menu (int menu, int x, int y, int small, int align, int alpha); diff --git a/source/main.c b/source/main.c index e8af6d3..e29be49 100644 --- a/source/main.c +++ b/source/main.c @@ -15,10 +15,7 @@ int main (void) { view_map (camera_x, camera_y); - view_map_overlay (); - - view_hud (render_width () - SIDE_SIZE, 0, SIDE_SIZE, render_height (), 0, 0); - view_hud (0, 0, render_width () - SIDE_SIZE, render_height (), 0, 1); + view_side (); view_menu (menu_resources, 96, 96, 1, 0, 1);