diff options
Diffstat (limited to 'src/screen.c')
| -rw-r--r-- | src/screen.c | 142 |
1 files changed, 72 insertions, 70 deletions
diff --git a/src/screen.c b/src/screen.c index 7018c2a..e70bf21 100644 --- a/src/screen.c +++ b/src/screen.c | |||
| @@ -396,7 +396,7 @@ int rangemod(int x, int offset, int min, int max) { | |||
| 396 | return ((x - min + offset) % (max - min + 1)) + min; | 396 | return ((x - min + offset) % (max - min + 1)) + min; |
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | static int init_rgb_color(int colornum, int red, int green, int blue) { | 399 | int init_rgb_color(int colornum, int red, int green, int blue) { |
| 400 | int nred = normalize(red, RGB_MIN, RGB_MAX, CURSESCOLOR_MIN, CURSESCOLOR_MAX); | 400 | int nred = normalize(red, RGB_MIN, RGB_MAX, CURSESCOLOR_MIN, CURSESCOLOR_MAX); |
| 401 | int ngreen = normalize(green, RGB_MIN, RGB_MAX, CURSESCOLOR_MIN, CURSESCOLOR_MAX); | 401 | int ngreen = normalize(green, RGB_MIN, RGB_MAX, CURSESCOLOR_MIN, CURSESCOLOR_MAX); |
| 402 | int nblue = normalize(blue, RGB_MIN, RGB_MAX, CURSESCOLOR_MIN, CURSESCOLOR_MAX); | 402 | int nblue = normalize(blue, RGB_MIN, RGB_MAX, CURSESCOLOR_MIN, CURSESCOLOR_MAX); |
| @@ -429,72 +429,74 @@ int mvwcreate_box(WINDOW *win, int y, int x, int height, int width, const chtype | |||
| 429 | 429 | ||
| 430 | //////////////////////////////////// MAIN //////////////////////////////////// | 430 | //////////////////////////////////// MAIN //////////////////////////////////// |
| 431 | 431 | ||
| 432 | int main() { | 432 | // Use this as an example for implementing screen's functions in another file |
| 433 | // I have no fucking clue why gcc complains that this isn't properly bracketed. Maybe im rarted | 433 | |
| 434 | const struct sigaction handler = { | 434 | // int main() { |
| 435 | .sa_flags = SA_SIGINFO, | 435 | // // I have no fucking clue why gcc complains that this isn't properly bracketed. Maybe im rarted |
| 436 | .sa_mask = SIGINT | SIGWINCH, | 436 | // const struct sigaction handler = { |
| 437 | .sa_sigaction = catcher, | 437 | // .sa_flags = SA_SIGINFO, |
| 438 | }; | 438 | // .sa_mask = SIGINT | SIGWINCH, |
| 439 | doinit(&handler); | 439 | // .sa_sigaction = catcher, |
| 440 | 440 | // }; | |
| 441 | docolors(); | 441 | // doinit(&handler); |
| 442 | 442 | ||
| 443 | // Variable definitions | 443 | // docolors(); |
| 444 | ITEM *items[STATIC_ARRSIZE(menu_choices) + 1]; // An array of ITEM pointers large enough to store all the menu items | 444 | |
| 445 | struct params params; // Function pointer used for callbacks in the menu driver | 445 | // // Variable definitions |
| 446 | WINDOW *menuholder = NULL; // The window for displaying the menu | 446 | // ITEM *items[STATIC_ARRSIZE(menu_choices) + 1]; // An array of ITEM pointers large enough to store all the menu items |
| 447 | int row = -1, col = -1; // The rows and columns of the main screen | 447 | // struct params params; // Function pointer used for callbacks in the menu driver |
| 448 | uint32_t randomnum; // A random number for getting the banner phrase | 448 | // WINDOW *menuholder = NULL; // The window for displaying the menu |
| 449 | MENU *menu; // The actual menu object | 449 | // int row = -1, col = -1; // The rows and columns of the main screen |
| 450 | 450 | // uint32_t randomnum; // A random number for getting the banner phrase | |
| 451 | struct slotholder slots; | 451 | // MENU *menu; // The actual menu object |
| 452 | 452 | ||
| 453 | getmaxyx(stdscr, row, col); | 453 | // struct slotholder slots; |
| 454 | randomnum = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); | 454 | |
| 455 | 455 | // getmaxyx(stdscr, row, col); | |
| 456 | WINDOW *banner = create_banner(col, randomnum); | 456 | // randomnum = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); |
| 457 | init_items(items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); | 457 | |
| 458 | 458 | // WINDOW *banner = create_banner(col, randomnum); | |
| 459 | // No point in moving this into a function | 459 | // init_items(items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); |
| 460 | menu = new_menu(items); | 460 | |
| 461 | if(menu == NULL) { | 461 | // // No point in moving this into a function |
| 462 | endwin(); | 462 | // menu = new_menu(items); |
| 463 | error(1, errno, "Could not create menu"); | 463 | // if(menu == NULL) { |
| 464 | } | 464 | // endwin(); |
| 465 | 465 | // error(1, errno, "Could not create menu"); | |
| 466 | // Set up the menuholder & init everything | 466 | // } |
| 467 | menuholder = newwin(1, col, row - 1, 0); | 467 | |
| 468 | keypad(menuholder, TRUE); | 468 | // // Set up the menuholder & init everything |
| 469 | init_custom_menu_format(menuholder, menu, (int []){1, col}, O_ONEVALUE | O_IGNORECASE, O_SHOWDESC | O_NONCYCLIC); | 469 | // menuholder = newwin(1, col, row - 1, 0); |
| 470 | 470 | // keypad(menuholder, TRUE); | |
| 471 | 471 | // init_custom_menu_format(menuholder, menu, (int []){1, col}, O_ONEVALUE | O_IGNORECASE, O_SHOWDESC | O_NONCYCLIC); | |
| 472 | slots.slotwin = newwin(row - 2, col, 1, 0); | 472 | |
| 473 | if(slots.slotwin == NULL) { | 473 | |
| 474 | endwin(); | 474 | // slots.slotwin = newwin(row - 2, col, 1, 0); |
| 475 | error(1, errno, "[VX-GAMBLEGROUND] Could not create slots window"); | 475 | // if(slots.slotwin == NULL) { |
| 476 | } | 476 | // endwin(); |
| 477 | 477 | // error(1, errno, "[VX-GAMBLEGROUND] Could not create slots window"); | |
| 478 | init_slotholder(&slots); | 478 | // } |
| 479 | 479 | ||
| 480 | doupdate(); | 480 | // init_slotholder(&slots); |
| 481 | 481 | ||
| 482 | params.bannerwin = banner; | 482 | // doupdate(); |
| 483 | params.menu = menu; | 483 | |
| 484 | params.menuholder = menuholder; | 484 | // params.bannerwin = banner; |
| 485 | params.numspins = 3; | 485 | // params.menu = menu; |
| 486 | params.price = 1; | 486 | // params.menuholder = menuholder; |
| 487 | params.slots = &slots; | 487 | // params.numspins = 3; |
| 488 | 488 | // params.price = 1; | |
| 489 | handle_input(menuholder, menu, ¶ms); | 489 | // params.slots = &slots; |
| 490 | 490 | ||
| 491 | // Clean up the menu | 491 | // handle_input(menuholder, menu, ¶ms); |
| 492 | unpost_menu(menu); | 492 | |
| 493 | free_menu(menu); | 493 | // // Clean up the menu |
| 494 | for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) | 494 | // unpost_menu(menu); |
| 495 | free_item(items[i]); | 495 | // free_menu(menu); |
| 496 | //*/ | 496 | // for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) |
| 497 | 497 | // free_item(items[i]); | |
| 498 | endwin(); // Clean up curses | 498 | // //*/ |
| 499 | return 0; | 499 | |
| 500 | } \ No newline at end of file | 500 | // endwin(); // Clean up curses |
| 501 | // return 0; | ||
| 502 | // } \ No newline at end of file | ||
