aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-04-14 22:59:31 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-04-14 22:59:31 +0300
commitfbb0739ac9fa8260d1e7a908fd7f9cb8c57a1188 (patch)
treef5fd023e050b20ec2711276f2605eb3862caf6c4 /main.c
parentc9ac361e1282bfaa895a1456222bca2d86253a96 (diff)
downloadastar-fbb0739ac9fa8260d1e7a908fd7f9cb8c57a1188.tar.xz
Add ability to open maps with a keybind
Diffstat (limited to 'main.c')
-rw-r--r--main.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/main.c b/main.c
index 9706875..1fdf05c 100644
--- a/main.c
+++ b/main.c
@@ -66,6 +66,8 @@ int main(int argc, char **argv) {
size_t mwidth = 20; /* Maze width */
size_t mheight = 10; /* Maze height */
+ char filename[FILENAME_BUF_SIZE] = "\0";
+
char is_maze = 0;
char bmp_only = 0;
char *bmp_filename = NULL;
@@ -232,7 +234,6 @@ int main(int argc, char **argv) {
set_message(FILENAME_PROMPT);
print_message(height);
- char filename[FILENAME_BUF_SIZE] = "out.bmp";
mvgetnstr(height + map_offset_y + 1, map_offset_x - 2 + sizeof(FILENAME_PROMPT), filename, FILENAME_BUF_SIZE - 1);
map_to_bmp(map, width, height, start_pos, end_pos, path, visited, filename);
@@ -243,6 +244,31 @@ int main(int argc, char **argv) {
getch();
break;
+ case 'w': /* FIXME: Keys don't make any sense anymore. 'o' should be open. And do them through defines for god's sake */
+ is_maze = 0;
+ curs_set(2); /* Show the cursor */
+ echo(); /* Echo characters */
+
+ set_message(FILENAME_PROMPT);
+ print_message(height);
+ char filename[FILENAME_BUF_SIZE] = "\0";
+ mvgetnstr(height + map_offset_y + 1, map_offset_x - 2 + sizeof(FILENAME_PROMPT), filename, FILENAME_BUF_SIZE - 1);
+
+ map_free(map, height);
+ path_free(path, height);
+ visited = visited_new(width, height);
+
+ map = file_plaintext_map(filename, &width, &height, &start_pos, &end_pos);
+ visited = visited_new(width, height);
+ path = path_func(dirs, map, width, height, start_pos, end_pos, visited, anim);
+
+ set_message("Loaded map from %s", filename); print_message(height);
+
+ curs_set(0); /* Hide the cursor */
+ noecho(); /* Don't echo characters */
+
+ break;
+
case 'n':
if (is_maze) {
map_free(map, height);