| 
									
										
										
										
											2025-10-18 21:35:01 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Created by snapshot112 on 10/17/2025 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-10-17 21:08:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "manual.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <ncurses.h>
 | 
					
						
							| 
									
										
										
										
											2025-10-22 15:07:52 +02:00
										 |  |  | #include "../../engine/grid_game_engine.h"
 | 
					
						
							| 
									
										
										
										
											2025-10-17 21:08:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void manual(const coordinate display_location) { | 
					
						
							|  |  |  |     erase(); | 
					
						
							| 
									
										
										
										
											2025-10-22 15:07:52 +02:00
										 |  |  |     FILE *fp = fopen("assets/manual.txt", "r"); | 
					
						
							| 
									
										
										
										
											2025-10-17 21:08:03 +02:00
										 |  |  |     if (fp == NULL) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-10-18 18:56:28 +02:00
										 |  |  |     grid *grid = grid_create_from_file(fp); | 
					
						
							| 
									
										
										
										
											2025-10-17 21:08:03 +02:00
										 |  |  |     if (grid == NULL) { | 
					
						
							|  |  |  |         mvaddstr(display_location.y, display_location.x, "Error loading grid"); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     fclose(fp); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-10-18 18:56:28 +02:00
										 |  |  |     show_grid_on_offset(grid, display_location.x, display_location.y); | 
					
						
							| 
									
										
										
										
											2025-10-17 21:08:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-10-18 18:56:28 +02:00
										 |  |  |     // Wait until ESCAPE or BACKSPACE is pressed.
 | 
					
						
							|  |  |  |     timeout(200); | 
					
						
							| 
									
										
										
										
											2025-10-18 21:35:01 +02:00
										 |  |  |     for (int ch = getch(); ch != KEY_ESCAPE && ch != KEY_BACKSPACE; ch = getch()) { | 
					
						
							| 
									
										
										
										
											2025-10-18 18:56:28 +02:00
										 |  |  |         // Update the screen in the meantime to accommodate windows resizes.
 | 
					
						
							|  |  |  |         show_grid_on_offset(grid, display_location.x, display_location.y); | 
					
						
							| 
									
										
										
										
											2025-10-17 21:08:03 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-10-18 18:56:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     grid_cleanup(grid); | 
					
						
							| 
									
										
										
										
											2025-10-17 21:08:03 +02:00
										 |  |  | } |