forked from zwickethomas/Photonics-Helfer
		
	bugfix
This commit is contained in:
		
							parent
							
								
									9cea3342ed
								
							
						
					
					
						commit
						efae2e2f69
					
				
							
								
								
									
										59
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								src/main.c
									
									
									
									
									
								
							@ -9,7 +9,7 @@
 | 
				
			|||||||
#elif _WIN32
 | 
					#elif _WIN32
 | 
				
			||||||
    #include <windows.h>
 | 
					    #include <windows.h>
 | 
				
			||||||
    #include <conio.h>
 | 
					    #include <conio.h>
 | 
				
			||||||
    #include <conio.h>
 | 
					    system("chcp 65001 >null");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// import sub programme
 | 
					// import sub programme
 | 
				
			||||||
@ -25,6 +25,7 @@ Datum: 04.12.2024
 | 
				
			|||||||
Änderungen:
 | 
					Änderungen:
 | 
				
			||||||
0.1 04.12.2024 Dokument erstellt
 | 
					0.1 04.12.2024 Dokument erstellt
 | 
				
			||||||
0.2 09.12.2024 Willkommensnachricht
 | 
					0.2 09.12.2024 Willkommensnachricht
 | 
				
			||||||
 | 
					0.3 10.12.2024 Meun hinzugefügt
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __linux__
 | 
					#ifdef __linux__
 | 
				
			||||||
@ -154,32 +155,17 @@ void print_menu(int terminal_width, int terminal_height, int line){
 | 
				
			|||||||
    print_blank_lines((terminal_height - 11) / 2);
 | 
					    print_blank_lines((terminal_height - 11) / 2);
 | 
				
			||||||
    int spaces = (terminal_width - 41) / 2;
 | 
					    int spaces = (terminal_width - 41) / 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #ifdef __linux__
 | 
					 | 
				
			||||||
        print_line("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓", spaces, (0 <= line && line < 1) ? ";31": ";37");
 | 
					        print_line("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓", spaces, (0 <= line && line < 1) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃  Programm 1                           ┃", spaces, (0 <= line && line < 1) ? ";31": ";37");
 | 
					        print_line("┃  Programm 1                           ┃", spaces, (0 <= line && line < 1) ? ";31": ";37");
 | 
				
			||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (0 <= line && line < 2) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (0 <= line && line < 2) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃  Programm 1                           ┃", spaces, (1 <= line && line < 2) ? ";31": ";37");
 | 
					        print_line("┃  Programm 2                           ┃", spaces, (1 <= line && line < 2) ? ";31": ";37");
 | 
				
			||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (1 <= line && line < 3) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (1 <= line && line < 3) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃  Programm 1                           ┃", spaces, (2 <= line && line < 3) ? ";31": ";37");
 | 
					        print_line("┃  Programm 3                           ┃", spaces, (2 <= line && line < 3) ? ";31": ";37");
 | 
				
			||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (2 <= line && line < 4) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (2 <= line && line < 4) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃  Programm 1                           ┃", spaces, (3 <= line && line < 4) ? ";31": ";37");
 | 
					        print_line("┃  Programm 4                           ┃", spaces, (3 <= line && line < 4) ? ";31": ";37");
 | 
				
			||||||
        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (3 <= line && line < 5) ? ";31": ";37");
 | 
					        print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (3 <= line && line < 5) ? ";31": ";37");
 | 
				
			||||||
        print_line("┃                                       ┃", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
					        print_line("┃                                       ┃", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
				
			||||||
        print_line("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
					        print_line("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
				
			||||||
    #elif _WIN32
 | 
					 | 
				
			||||||
        print_line("+---------------------------------------+", spaces, (0 <= line && line < 1) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("|  Programm 1                           |", spaces, (0 <= line && line < 1) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("+---------------------------------------+", spaces, (0 <= line && line < 2) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("|  Programm 1                           |", spaces, (1 <= line && line < 2) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("+---------------------------------------+", spaces, (1 <= line && line < 3) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("|  Programm 1                           |", spaces, (2 <= line && line < 3) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("+---------------------------------------+", spaces, (2 <= line && line < 4) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("|  Programm 1                           |", spaces, (3 <= line && line < 4) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("+---------------------------------------+", spaces, (3 <= line && line < 5) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("|                                       |", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
					 | 
				
			||||||
        print_line("+---------------------------------------+", spaces, (4 <= line && line < 5) ? ";31": ";37");
 | 
					 | 
				
			||||||
    #endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -199,19 +185,25 @@ void print_help(){
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void get_terminal_size(int argc, char **argv, int *width, int *height){
 | 
					void get_terminal_size(int argc, char **argv, int *width, int *height){
 | 
				
			||||||
    do{
 | 
					 | 
				
			||||||
        #ifdef __linux__
 | 
					        #ifdef __linux__
 | 
				
			||||||
            get_terminal_size_linux(argc, argv, width, height);
 | 
					            get_terminal_size_linux(argc, argv, width, height);
 | 
				
			||||||
        #elif _WIN32
 | 
					        #elif _WIN32
 | 
				
			||||||
            get_terminal_size_windows(argc, argv, width, height);
 | 
					            get_terminal_size_windows(argc, argv, width, height);
 | 
				
			||||||
        #endif
 | 
					        #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (*width < 100 || *height < 20){
 | 
					 | 
				
			||||||
            clear_terminal();
 | 
					 | 
				
			||||||
            printf("Terminal zu klein!");
 | 
					 | 
				
			||||||
            // sleep_universal(1);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
    }while(*width < 100 || *height < 20);
 | 
					
 | 
				
			||||||
 | 
					void get_terminal_size_init(int argc, char **argv, int *width, int *height){
 | 
				
			||||||
 | 
					    get_terminal_size(argc, argv, width, height);
 | 
				
			||||||
 | 
					    if (*width < 100 || *height < 30){
 | 
				
			||||||
 | 
					        clear_terminal();
 | 
				
			||||||
 | 
					        printf("Terminal zu klein!\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        while(*width < 100 || *height < 30){
 | 
				
			||||||
 | 
					            get_terminal_size(argc, argv, width, height);
 | 
				
			||||||
 | 
					            sleep_universal(1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char **argv){
 | 
					int main(int argc, char **argv){
 | 
				
			||||||
@ -220,8 +212,14 @@ int main(int argc, char **argv){
 | 
				
			|||||||
    int line = 0;
 | 
					    int line = 0;
 | 
				
			||||||
    bool run = true;
 | 
					    bool run = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // neues terminal öffnen (nur linux)
 | 
				
			||||||
 | 
					    #ifdef __linux__
 | 
				
			||||||
 | 
					        system("tput smcup");
 | 
				
			||||||
 | 
					    #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Terminal grösse herauslesen
 | 
					    // Terminal grösse herauslesen
 | 
				
			||||||
    get_terminal_size(argc, argv, &width, &height);
 | 
					    // get_terminal_size(argc, argv, &width, &height);
 | 
				
			||||||
 | 
					    get_terminal_size_init(argc, argv, &width, &height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // int x = test_gruppe_programmname();
 | 
					    // int x = test_gruppe_programmname();
 | 
				
			||||||
@ -230,20 +228,15 @@ int main(int argc, char **argv){
 | 
				
			|||||||
    printf ("lines %d\n", height);
 | 
					    printf ("lines %d\n", height);
 | 
				
			||||||
    printf ("columns %d\n", width);
 | 
					    printf ("columns %d\n", width);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // neues terminal öffnen (nur linux)
 | 
					 | 
				
			||||||
    #ifdef __linux__
 | 
					 | 
				
			||||||
        system("tput smcup");
 | 
					 | 
				
			||||||
    #endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // print wellcome message
 | 
					    // print wellcome message
 | 
				
			||||||
    print_wellcome(width, height);
 | 
					    print_wellcome(width, height);
 | 
				
			||||||
    // print_game_over(width, height);
 | 
					    // print_game_over(width, height);
 | 
				
			||||||
    // print_menu(width, height, line);
 | 
					    // print_menu(width, height, line);
 | 
				
			||||||
    while(run){
 | 
					    while(run){
 | 
				
			||||||
        get_terminal_size(argc, argv, &width, &height);
 | 
					        get_terminal_size_init(argc, argv, &width, &height);
 | 
				
			||||||
        print_menu(width, height, line);
 | 
					        print_menu(width, height, line);
 | 
				
			||||||
        // char key_input = (char)getch();
 | 
					        char key_input = (char)getch();
 | 
				
			||||||
        char key_input = (char)0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        switch (key_input) {
 | 
					        switch (key_input) {
 | 
				
			||||||
            case 'k': line--; break;
 | 
					            case 'k': line--; break;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user