diff options
| -rw-r--r-- | src/screen.c | 27 | ||||
| -rw-r--r-- | src/screen.h | 3 |
2 files changed, 20 insertions, 10 deletions
diff --git a/src/screen.c b/src/screen.c index 6df9cac..d695ee7 100644 --- a/src/screen.c +++ b/src/screen.c | |||
| @@ -88,11 +88,13 @@ static const char *menu_choices[] = { | |||
| 88 | 88 | ||
| 89 | static struct funcholder userfuncs[] = { | 89 | static struct funcholder userfuncs[] = { |
| 90 | {.callback = spin, .type = FH_SPIN, .params = {.spinp = {.bannerwin = NULL, .phrasenum = 0}}}, | 90 | {.callback = spin, .type = FH_SPIN, .params = {.spinp = {.bannerwin = NULL, .phrasenum = 0}}}, |
| 91 | {.callback = buy, .type = FH_BUY, .params = {.buyp = {}}}, | 91 | {.callback = buy, .type = FH_BUY, .params = {.buyp = {.numspins = 3, .price = 1}}}, |
| 92 | {.callback = quit, .type = FH_QUIT, .params = {.quitp = {}}} | 92 | {.callback = quit, .type = FH_QUIT, .params = {.quitp = {.REPLACEME = NULL}}} |
| 93 | }; | 93 | }; |
| 94 | 94 | ||
| 95 | void intercleanup(int signum, siginfo_t *info, void *ucontext) { | 95 | void intercleanup(int signum) { |
| 96 | signum++; // So gcc doesn't yell at me | ||
| 97 | |||
| 96 | endwin(); | 98 | endwin(); |
| 97 | error(0, 0, "[VX-GAMBLEGROUND] Caught interrupt"); | 99 | error(0, 0, "[VX-GAMBLEGROUND] Caught interrupt"); |
| 98 | exit(0); | 100 | exit(0); |
| @@ -102,9 +104,9 @@ void intercleanup(int signum, siginfo_t *info, void *ucontext) { | |||
| 102 | 104 | ||
| 103 | static const struct sigaction handlers[] = { | 105 | static const struct sigaction handlers[] = { |
| 104 | { // intercleanup | 106 | { // intercleanup |
| 105 | .sa_flags = SA_SIGINFO, | 107 | .sa_flags = 0, |
| 106 | .sa_mask = SIGINT, | 108 | .sa_mask = SIGINT, |
| 107 | .sa_sigaction = intercleanup | 109 | .sa_handler = intercleanup |
| 108 | } | 110 | } |
| 109 | }; | 111 | }; |
| 110 | 112 | ||
| @@ -211,11 +213,9 @@ int main() { | |||
| 211 | // Variable definitions | 213 | // Variable definitions |
| 212 | 214 | ||
| 213 | ITEM *items[STATIC_ARRSIZE(menu_choices) + 1]; // An array of ITEM pointers large enough to store all the menu items | 215 | ITEM *items[STATIC_ARRSIZE(menu_choices) + 1]; // An array of ITEM pointers large enough to store all the menu items |
| 214 | int holder1 = -1, holder2 = -1; // Holders for the max yx of the menu subwindow | ||
| 215 | struct funcholder *p = NULL; // Function pointer used for callbacks in the menu driver | 216 | struct funcholder *p = NULL; // Function pointer used for callbacks in the menu driver |
| 217 | WINDOW *menuholder = NULL; // The window for displaying the menu | ||
| 216 | int row = -1, col = -1; // The rows and columns of the main screen | 218 | int row = -1, col = -1; // The rows and columns of the main screen |
| 217 | WINDOW *phrase = NULL; // The window for displaying the banner | ||
| 218 | WINDOW *menuholder; // The window for displaying the menu | ||
| 219 | int randomnum; // A random number for getting the banner phrase | 219 | int randomnum; // A random number for getting the banner phrase |
| 220 | MENU *menu; // The actual menu object | 220 | MENU *menu; // The actual menu object |
| 221 | int c; // Integer for storing keys from user input | 221 | int c; // Integer for storing keys from user input |
| @@ -258,6 +258,7 @@ int main() { | |||
| 258 | keypad(menuholder, TRUE); | 258 | keypad(menuholder, TRUE); |
| 259 | 259 | ||
| 260 | 260 | ||
| 261 | int holder1 = -1, holder2 = -1; | ||
| 261 | getmaxyx(menuholder, holder1, holder2); | 262 | getmaxyx(menuholder, holder1, holder2); |
| 262 | if(holder1 < 0 || holder2 < 0) { | 263 | if(holder1 < 0 || holder2 < 0) { |
| 263 | endwin(); | 264 | endwin(); |
| @@ -272,7 +273,6 @@ int main() { | |||
| 272 | set_menu_back(menu, COLOR_PAIR(CCP_BANNER)); | 273 | set_menu_back(menu, COLOR_PAIR(CCP_BANNER)); |
| 273 | wnoutrefresh(menuholder); | 274 | wnoutrefresh(menuholder); |
| 274 | 275 | ||
| 275 | |||
| 276 | WINDOW *slots = newwin(row - 2, col, 1, 0); | 276 | WINDOW *slots = newwin(row - 2, col, 1, 0); |
| 277 | if(slots == NULL) { | 277 | if(slots == NULL) { |
| 278 | endwin(); | 278 | endwin(); |
| @@ -385,6 +385,10 @@ int spin(void *spinp) { | |||
| 385 | 385 | ||
| 386 | // Increase number of spins | 386 | // Increase number of spins |
| 387 | int buy(void *buyp) { | 387 | int buy(void *buyp) { |
| 388 | struct buyp *p = (struct buyp*)buyp; | ||
| 389 | p->numspins += 3; | ||
| 390 | p->price *= 2; | ||
| 391 | |||
| 388 | endwin(); | 392 | endwin(); |
| 389 | error(0, 0, "buy"); | 393 | error(0, 0, "buy"); |
| 390 | exit(0); | 394 | exit(0); |
| @@ -394,6 +398,9 @@ int buy(void *buyp) { | |||
| 394 | 398 | ||
| 395 | // Quit out | 399 | // Quit out |
| 396 | int quit(void *quitp) { | 400 | int quit(void *quitp) { |
| 401 | struct quitp *p = (struct quitp*)quitp; | ||
| 402 | p->REPLACEME = "lol"; | ||
| 403 | |||
| 397 | endwin(); | 404 | endwin(); |
| 398 | error(0, 0, "quit"); | 405 | error(0, 0, "quit"); |
| 399 | exit(0); | 406 | exit(0); |
diff --git a/src/screen.h b/src/screen.h index 1a59b5b..c3deb00 100644 --- a/src/screen.h +++ b/src/screen.h | |||
| @@ -89,10 +89,13 @@ struct funcholder { | |||
| 89 | } spinp; | 89 | } spinp; |
| 90 | 90 | ||
| 91 | struct buyp { | 91 | struct buyp { |
| 92 | unsigned long int price; | ||
| 93 | int numspins; | ||
| 92 | 94 | ||
| 93 | } buyp; | 95 | } buyp; |
| 94 | 96 | ||
| 95 | struct quitp { | 97 | struct quitp { |
| 98 | char *REPLACEME; | ||
| 96 | 99 | ||
| 97 | } quitp; | 100 | } quitp; |
| 98 | } params; | 101 | } params; |
