From b1b00b4a8aad8ea97c318aab597b9468c536e656 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Fri, 30 Aug 2024 16:23:06 -0500 Subject: Restructure screen & add header defs --- src/main.c | 1 + src/screen.c | 465 ++++++++++++++++++++++++----------------------------------- src/screen.h | 150 ++++++++++++++++++- 3 files changed, 332 insertions(+), 284 deletions(-) diff --git a/src/main.c b/src/main.c index 2eb512c..a382ccb 100644 --- a/src/main.c +++ b/src/main.c @@ -42,6 +42,7 @@ static char argdoc[] = "lmao"; static struct argp_option options[] = { {.name = "passphrase", .key = 'p', .arg = "key", .flags = 0, .doc = "Specify passphrase for encryption/decryption", .group = 0}, {"decrypt", 'd', 0, 0, "Skip the slots minigame and immediately decrypt (or encrypt) files", 0}, + {"noenc", 'n', 0, 0, "Don't encrypt files when ran, just play slots"}, {0} }; diff --git a/src/screen.c b/src/screen.c index 5fe2822..7018c2a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -5,6 +5,9 @@ * files back. To do this, I am using curses and probably the menu library to create the TUI. Once I figure * out how to actually do this, everything should work hopefully maybe * + * DEAR HACKER, PLEASE PLEASE DO NOT BOTHER LEARNING CURSES FOR A JOKE. IT WAS A BAD IDEA AND IF YOU'RE RESTARDED + * LIKE ME SUNKEN COST WILL KICK IN AND IT WILL NAG AT YOU UNTIL IT'S DONE. DO NOT MAKE THE SAME MISTAKE I MADE. + * RUN, RUN FOR THE SAKE OF ALL THAT'S HOLY AND OTHERWISE */ #define _GNU_SOURCE @@ -24,87 +27,7 @@ #include #include -static const char *phrases[] = { - // By @syxhe on telegram - "WE CLOWN IN THIS MF, TAKE YO SENSITIVE ASS BACK TO @GENTOOMEMES", - "R.I.P VxHeaven", - "tmp(2) nuked by Smelly", - "99% of Ransomware Operators quit before compromising a bank", - "Equation Group wuz here", - "Lazarus wuz here", - "LockBit wuz here", - "Sponsored by Equation Group", - "Sponsored by Lazarus", - "Sponsored by LockBit", - "Free my boy Ross Ulbricht he did nothing wrong", - "Stay off the dark web, kids", - "FREE BITCOIN JUST 3 SPINS AWAY", - "We all glow in the dark", - "Shoutouts to Simpleflips", - "Shoutouts to BugHunter", - "Shoutouts to EyeDeeKay", - ":beecat:", - ":3", - "You think Jack Rhysider will interview me now?", - "Check out \"Darknet Diaries\"", - "Chill and losing it since 2016", - "POOL'S CLOSED", - "I've been diagnosed with snaids", - "My balls itch", - "We killin filez and shiit", - "lonix users BTFO once again", - "This space left intentionally blank", - "Thinking of a way out is self-centered at best", - "Searching for the punchline to an infinite jest?", - "Still learning what it means to feel", - "Killroy was NOT here", - "Go fuck yourself lmao", - "It's so over", - "We're so back", - "It never even began", - "Pepito they shot Trump", - "This shit ain't nothing to me man", - "I'm him, I will continue to be him", - "THERE ARE MOSQUITOS IN YOUR URETHRA, GET THEM OUT!!!", - "Something wicked this way comes", - "Schizo hour", - "Man I could really use some Chicken Bouillon rn", - "Fuck my digital footprint, I need a digital footjob", - "Having my weekly \"Ted was right\" moment", - "Why aren't you in the gym?", - "Proof?", - "I've gone completely mental", - "The rage consumes me", - "Go outside. Now.", - "Beautiful Day Sunny Morning", - "Fuck crypto all my homies hate crypto", - "stfu fedsmoker is my dad he'll eat you alive", - "Almost dog in hot car'd myself", - - // by @danielsprofile on telegram - "Daniel Spears loves femboys", - "LizardSquad > Razer", - "Sponsored by Major League Gaming", - "Sponsored by LemonParty.org", - "Sponsored by FTX", - "RIP Harambe", - "Shoutout Elliot Alderson", - "Ted Kaczynski was right", - "The FBI watches me jerk off to MILFs lol", - "robux generator free online 2024 100% working undetected", - "Doge wuz here", - "We like Fortnite we like Fortnite", - "We live in a society", - "Hab you seen a alien pls?", - "using a flipperzero makes me an APT, right?", - "Subscribe to PewDiePie", -}; - -static const char *menu_choices[] = { - "Spin", - "Buy spins", - "Quit" -}; +//////////////////////////////////// SPECIFICALLY USEFUL FUNCS //////////////////////////////////// void catcher(int signum, siginfo_t *info, void *ucontext) { // This is retarded lol, but makes gcc happy @@ -113,26 +36,24 @@ void catcher(int signum, siginfo_t *info, void *ucontext) { switch(signum) { case SIGINT: - endwin(); - error(0, 0, "[VX-GAMBLEGROUND] Caught interrupt"); - exit(0); + endwin(); + error(0, 0, "[VX-GAMBLEGROUND] Caught interrupt"); + exit(0); case SIGWINCH: - endwin(); - error(1, 0, "[VX-GAMBLEGROUND] User changed window size and I haven't implemented code to handle it yet"); - abort(); // Makes gcc happy (angry about implicit fallthrough) + endwin(); + error(1, 0, "[VX-GAMBLEGROUND] User changed window size and I haven't implemented code to handle it yet"); + abort(); // Makes gcc happy (angry about implicit fallthrough) default: - abort(); + abort(); } return; } -static struct sigaction handler = {.sa_flags = SA_SIGINFO, .sa_mask = SIGINT | SIGWINCH, .sa_sigaction = catcher}; - // Initialize sodium, curses, and set the proper locale. Exits on error, returns 0 otherwise -static int doinit(void) { +int doinit(const struct sigaction *handler) { if(sodium_init() < 0) error(1, errno, "[VX-GAMBLEGROUND] Could not initialize sodium"); @@ -142,8 +63,8 @@ static int doinit(void) { if(initscr() == NULL) // Initialize curses error(1, errno, "[VX-GAMBLEGROUND] Could not init standard screen"); - if(sigaction(SIGINT, &handler, NULL) < 0 || sigaction(SIGWINCH, &handler, NULL) < 0) - error(1, errno, "[VX-GAMBLEGROUND] Could not set up signal catcher"); + if(sigaction(SIGINT, handler, NULL) < 0 || sigaction(SIGWINCH, handler, NULL) < 0) + error(1, errno, "[VX-GAMBLEGROUND] Could not set up signal handlers"); cbreak(); // Disables character buffering @@ -154,69 +75,53 @@ static int doinit(void) { } // Initialize colors & define a few custom colors & color pairs. Exits on error, returns 0 otherwise -static int docolors(void) { - if(has_colors() && can_change_color()) { // Init colors if available & create color pairings - start_color(); - - // Init colors here - // TODO: FIGURE OUT WHY COLORS ARE SO FUCKEY - /* The colors were being weird because I was being retarded and redefining already existing colors - // to numbers well outside curses' 0-1000 range. Making an enum that redefined the already existing - // curses colors made this go away. Also VSCode's terminal theming is fucking with it as well, so - // use a normal terminal for accurate colors */ - - init_rgb_color(CC_RED, 255, 0, 0); - init_rgb_color(CC_ORANGE, 255, 128, 0); - init_rgb_color(CC_YELLOW, 255, 255, 0); - init_rgb_color(CC_GREEN, 0, 255, 0); - init_rgb_color(CC_BLUE, 0, 0, 255); - init_rgb_color(CC_PURPLE, 128, 0, 255); - init_rgb_color(CC_MAGENTA, 255, 0, 255); - init_rgb_color(CC_WHITE, 255, 255, 255); - init_rgb_color(CC_BLACK, 0, 0, 0); - - init_rgb_color(CC_WINNING, 232, 185, 35); - - - init_pair(CCP_TESTING, CC_RED, CC_WHITE); - init_pair(CCP_BANNER, CC_WHITE, CURSES_BLUE); - - init_pair(CCP_RED, CC_WHITE, CC_RED); - init_pair(CCP_ORANGE, CC_BLACK, CC_ORANGE); - init_pair(CCP_YELLOW, CC_BLACK, CC_YELLOW); - init_pair(CCP_GREEN, CC_BLACK, CC_GREEN); - init_pair(CCP_BLUE, CC_WHITE, CC_BLUE); - init_pair(CCP_PURPLE, CC_WHITE, CC_PURPLE); - init_pair(CCP_MAGENTA, CC_WHITE, CC_MAGENTA); - init_pair(CCP_WHITE, CC_BLACK, CC_WHITE); - - init_pair(CCP_WINNING1, CC_WHITE, CC_WINNING); - init_pair(CCP_WINNING2, CC_WINNING, CC_WHITE); - } else { +int docolors(void) { + // Idk what possessed me to put this entire thing in an if-statement instead of using an early return + // Whatever, it's fixed now + + if(!has_colors() && !can_change_color()) { endwin(); error(1, ENOTSUP, "[VX-GAMBLEGROUND] Colors are not supported on your terminal"); } - return 0; -} + // Necessary for color + start_color(); -static WINDOW* create_banner(int col, int randomnum) { - // Create the banner window - WINDOW *phrase = newwin(1, col, 0, 0); - if(phrase == NULL) { - endwin(); - error(1, errno, "[VX-GAMBLEGROUND] Could not create banner window"); - } - wbkgd(phrase, COLOR_PAIR(CCP_BANNER)); - mvwaddstr(phrase, 0, 1, "VX-GAMBLEGROUND: "); - waddstr(phrase, phrases[randomnum]); - wnoutrefresh(phrase); + // Init everything + init_rgb_color(CC_RED, 255, 0, 0); + init_rgb_color(CC_ORANGE, 255, 128, 0); + init_rgb_color(CC_YELLOW, 255, 255, 0); + init_rgb_color(CC_GREEN, 0, 255, 0); + init_rgb_color(CC_BLUE, 0, 0, 255); + init_rgb_color(CC_PURPLE, 128, 0, 255); + init_rgb_color(CC_MAGENTA, 255, 0, 255); + init_rgb_color(CC_WHITE, 255, 255, 255); + init_rgb_color(CC_BLACK, 0, 0, 0); - return phrase; + init_rgb_color(CC_WINNING, 232, 185, 35); + + + // Create pairs + init_pair(CCP_TESTING, CC_RED, CC_WHITE); + init_pair(CCP_BANNER, CC_WHITE, CURSES_BLUE); + + init_pair(CCP_RED, CC_WHITE, CC_RED); + init_pair(CCP_ORANGE, CC_BLACK, CC_ORANGE); + init_pair(CCP_YELLOW, CC_BLACK, CC_YELLOW); + init_pair(CCP_GREEN, CC_BLACK, CC_GREEN); + init_pair(CCP_BLUE, CC_WHITE, CC_BLUE); + init_pair(CCP_PURPLE, CC_WHITE, CC_PURPLE); + init_pair(CCP_MAGENTA, CC_WHITE, CC_MAGENTA); + init_pair(CCP_WHITE, CC_BLACK, CC_WHITE); + + init_pair(CCP_WINNING1, CC_WHITE, CC_WINNING); + init_pair(CCP_WINNING2, CC_WINNING, CC_WHITE); + + return 0; } // I will figure out how to properly pass a void pointer eventually (if I care enough) -static int init_items(ITEM *items[], const char *menuopts[], size_t menuopts_size, struct funcholder usrptrs[]) { +int init_items(ITEM *items[], const char *menuopts[], size_t menuopts_size, struct funcholder usrptrs[]) { for(size_t i = 0; i < menuopts_size; i++) { items[i] = new_item(menuopts[i], NULL); set_item_userptr(items[i], (void*)&usrptrs[i]); @@ -226,30 +131,7 @@ static int init_items(ITEM *items[], const char *menuopts[], size_t menuopts_siz return 0; } -static int mvwcreate_box(WINDOW *win, int y, int x, int height, int width, const chtype chars[6]) { - const chtype * realchars = chars; - if(chars == NULL) - realchars = (const chtype []){ACS_VLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER}; - - // Vertical lines - mvwvline(win, y, x, realchars[0], height); - mvwvline(win, y, x + width - 1, realchars[0], height); - - // Horizontal lines - mvwhline(win, y, x, realchars[1], width - 1); - mvwhline(win, y + height - 1, x, realchars[1], width) - 1; - - // Corners - mvwaddch(win, y, x, realchars[2]); // Upper left corner - mvwaddch(win, y, x + width - 1, realchars[3]); // Upper right corner - mvwaddch(win, y + height - 1, x, realchars[4]); // Lower left corner - mvwaddch(win, y + height - 1, x + width - 1, realchars[5]); // Lower right corner - - // Yeah I'm not happy about the magic numbers either, but this combo of shit makes the box draw correctly - return 0; -} - -static int init_slotholder(struct slotholder *slots) { +int init_slotholder(struct slotholder *slots) { mvwaddstr(slots->slotwin, 0, 1, "Spins: 3, Price: 1"); wnoutrefresh(slots->slotwin); @@ -275,8 +157,7 @@ static int init_slotholder(struct slotholder *slots) { return 0; } - -static int init_custom_menu_format(WINDOW *menuholder, MENU *menu, const int fmtdim[2], Menu_Options toggleon, Menu_Options toggleoff) { +int init_custom_menu_format(WINDOW *menuholder, MENU *menu, const int fmtdim[2], Menu_Options toggleon, Menu_Options toggleoff) { // Set menu options & format set_menu_format(menu, fmtdim[0], fmtdim[1]); menu_opts_on(menu, toggleon); @@ -300,120 +181,70 @@ static int init_custom_menu_format(WINDOW *menuholder, MENU *menu, const int fmt return 0; } -int main() { - doinit(); - docolors(); - - // Variable definitions - ITEM *items[STATIC_ARRSIZE(menu_choices) + 1]; // An array of ITEM pointers large enough to store all the menu items - struct funcholder *p = NULL; - struct params params; // Function pointer used for callbacks in the menu driver - WINDOW *menuholder = NULL; // The window for displaying the menu - int row = -1, col = -1; // The rows and columns of the main screen - uint32_t randomnum; // A random number for getting the banner phrase - MENU *menu; // The actual menu object - int c; // Integer for storing keys from user input - - struct funcholder userfuncs[] = { - {.callback = spin, .type = FH_SPIN}, - {.callback = buy, .type = FH_BUY}, - {.callback = quit, .type = FH_QUIT}, - {0} - }; - - struct slotholder slots; - - getmaxyx(stdscr, row, col); - if(row < 0 || col < 0) { +WINDOW* create_banner(int col, int randomnum) { + // Create the banner window + WINDOW *phrase = newwin(1, col, 0, 0); + if(phrase == NULL) { endwin(); - error(1, 0, "[VX-GAMBLEGROUND] Couldn't get max terminal size for some reason"); + error(1, errno, "[VX-GAMBLEGROUND] Could not create banner window"); } + wbkgd(phrase, COLOR_PAIR(CCP_BANNER)); + mvwaddstr(phrase, 0, 1, "VX-GAMBLEGROUND: "); + waddstr(phrase, phrases[randomnum]); + wnoutrefresh(phrase); - randomnum = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); - - WINDOW *banner = create_banner(col, randomnum); - init_items(items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); - - // No point in moving this into a function - menu = new_menu(items); - if(menu == NULL) { - endwin(); - error(1, errno, "Could not create menu"); - } + return phrase; +} - // Set up the menuholder & init everything - menuholder = newwin(1, col, row - 1, 0); - keypad(menuholder, TRUE); - init_custom_menu_format(menuholder, menu, (int []){1, col}, O_ONEVALUE | O_IGNORECASE, O_SHOWDESC | O_NONCYCLIC); +int handle_menuitem(MENU *menu, struct params *params) { + struct funcholder *p = (struct funcholder *)item_userptr(current_item(menu)); + switch(p->type) { + case FH_SPIN: case FH_BUY: + p->callback((void*)params); + break; + case FH_QUIT: + p->callback(NULL); + break; - slots.slotwin = newwin(row - 2, col, 1, 0); - if(slots.slotwin == NULL) { + default: endwin(); - error(1, errno, "[VX-GAMBLEGROUND] Could not create slots window"); + error(1, ENOTSUP, "SHIT BROKE"); } - init_slotholder(&slots); - - doupdate(); - - params.bannerwin = banner; - params.menu = menu; - params.menuholder = menuholder; - params.numspins = 3; - params.price = 1; - params.slots = &slots; + return 0; +} +int handle_input(WINDOW *menuholder, MENU *menu, struct params *params) { + int c; // Get user input and deal with the menu while((c = wgetch(menuholder)) != KEY_F(4)) { switch(c) { case KEY_DOWN: - menu_driver(menu, REQ_DOWN_ITEM); - break; + menu_driver(menu, REQ_DOWN_ITEM); + break; case KEY_UP: - menu_driver(menu, REQ_UP_ITEM); - break; + menu_driver(menu, REQ_UP_ITEM); + break; case KEY_LEFT: - menu_driver(menu, REQ_LEFT_ITEM); - break; + menu_driver(menu, REQ_LEFT_ITEM); + break; case KEY_RIGHT: - menu_driver(menu, REQ_RIGHT_ITEM); - break; + menu_driver(menu, REQ_RIGHT_ITEM); + break; case KEY_ENTER: case FUCKED_UP_ENTER: // Enter - p = (struct funcholder *)item_userptr(current_item(menu)); - switch(p->type) { - case FH_SPIN: case FH_BUY: - p->callback((void*)¶ms); - break; - - case FH_QUIT: - p->callback(NULL); - break; - - default: - endwin(); - error(1, ENOTSUP, "SHIT BROKE"); - } - - break; + handle_menuitem(menu, params); + break; default: - break; + break; } } - // Clean up the menu - unpost_menu(menu); - free_menu(menu); - for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) - free_item(items[i]); - //*/ - - endwin(); // Clean up curses return 0; } @@ -431,7 +262,7 @@ int spin(void *params) { char *newstr = NULL; if(asprintf(&newstr, "Spins: %d, Price: %d", p->numspins, p->price) < 0) { endwin(); - error(1, errno, "[VX-GAMBLEGROUND] Shit brokey lol"); + error(1, errno, "[VX-GAMBLEGROUND] asprintf broke"); } mvwaddstr(p->slots->slotwin, 0, 1, newstr); free(newstr); @@ -490,19 +321,6 @@ int spin(void *params) { // Do winning anim mvaddch(0, 0, 'J'); for(int i = 0, color = CCP_WINNING1;; i++, color = rangemod(color, 1, CCP_WINNING1, CCP_WINNING2)) { - // wbkgd(p->bannerwin, COLOR_PAIR(color)); - // wbkgd(p->menuholder, COLOR_PAIR(color)); - - // wbkgd(p->slots->slotwin, COLOR_PAIR(rangemod(color, 1, CCP_WINNING1, CCP_WINNING2))); - // for(size_t j = 0; j < STATIC_ARRSIZE(p->slots->subslot); j++) { - // wbkgd(p->slots->subslot[j], COLOR_PAIR(rangemod(color, j + 1, CCP_WINNING1, CCP_WINNING2))); - // wnoutrefresh(p->slots->subslot[j]); - // } - - // wnoutrefresh(p->bannerwin); - // wnoutrefresh(p->menuholder); - // wnoutrefresh(p->slots->slotwin); - bkgd(COLOR_PAIR(color)); addch("JACKPOT"[rangemod(i, 1, 0, 6)]); @@ -558,7 +376,7 @@ int buy(void *params) { // Quit out int quit(void *params) { - + params = params; // Once agian, useless but makes gcc happy endwin(); error(0, 0, "quit"); @@ -567,7 +385,7 @@ int quit(void *params) { return 0; } - +//////////////////////////////////// GENERALLY USEFUL FUNCTIONS //////////////////////////////////// float normalize(float value, float oldmin, float oldmax, float newmin, float newmax) { // x(normal) = (b - a) * ((x - x(min)) / (max x - min x)) + a, where [a, b] is the new range @@ -584,4 +402,99 @@ static int init_rgb_color(int colornum, int red, int green, int blue) { int nblue = normalize(blue, RGB_MIN, RGB_MAX, CURSESCOLOR_MIN, CURSESCOLOR_MAX); return init_color(colornum, nred, ngreen, nblue); +} + +int mvwcreate_box(WINDOW *win, int y, int x, int height, int width, const chtype chars[6]) { + const chtype * realchars = chars; + if(chars == NULL) + realchars = (const chtype []){ACS_VLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER}; + + // Vertical lines + mvwvline(win, y, x, realchars[0], height); + mvwvline(win, y, x + width - 1, realchars[0], height); + + // Horizontal lines + mvwhline(win, y, x, realchars[1], width - 1); + mvwhline(win, y + height - 1, x, realchars[1], width) - 1; + + // Corners + mvwaddch(win, y, x, realchars[2]); // Upper left corner + mvwaddch(win, y, x + width - 1, realchars[3]); // Upper right corner + mvwaddch(win, y + height - 1, x, realchars[4]); // Lower left corner + mvwaddch(win, y + height - 1, x + width - 1, realchars[5]); // Lower right corner + + // Yeah I'm not happy about the magic numbers either, but this combo of shit makes the box draw correctly + return 0; +} + +//////////////////////////////////// MAIN //////////////////////////////////// + +int main() { + // I have no fucking clue why gcc complains that this isn't properly bracketed. Maybe im rarted + const struct sigaction handler = { + .sa_flags = SA_SIGINFO, + .sa_mask = SIGINT | SIGWINCH, + .sa_sigaction = catcher, + }; + doinit(&handler); + + docolors(); + + // Variable definitions + ITEM *items[STATIC_ARRSIZE(menu_choices) + 1]; // An array of ITEM pointers large enough to store all the menu items + struct params params; // Function pointer used for callbacks in the menu driver + WINDOW *menuholder = NULL; // The window for displaying the menu + int row = -1, col = -1; // The rows and columns of the main screen + uint32_t randomnum; // A random number for getting the banner phrase + MENU *menu; // The actual menu object + + struct slotholder slots; + + getmaxyx(stdscr, row, col); + randomnum = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); + + WINDOW *banner = create_banner(col, randomnum); + init_items(items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); + + // No point in moving this into a function + menu = new_menu(items); + if(menu == NULL) { + endwin(); + error(1, errno, "Could not create menu"); + } + + // Set up the menuholder & init everything + menuholder = newwin(1, col, row - 1, 0); + keypad(menuholder, TRUE); + init_custom_menu_format(menuholder, menu, (int []){1, col}, O_ONEVALUE | O_IGNORECASE, O_SHOWDESC | O_NONCYCLIC); + + + slots.slotwin = newwin(row - 2, col, 1, 0); + if(slots.slotwin == NULL) { + endwin(); + error(1, errno, "[VX-GAMBLEGROUND] Could not create slots window"); + } + + init_slotholder(&slots); + + doupdate(); + + params.bannerwin = banner; + params.menu = menu; + params.menuholder = menuholder; + params.numspins = 3; + params.price = 1; + params.slots = &slots; + + handle_input(menuholder, menu, ¶ms); + + // Clean up the menu + unpost_menu(menu); + free_menu(menu); + for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) + free_item(items[i]); + //*/ + + endwin(); // Clean up curses + return 0; } \ No newline at end of file diff --git a/src/screen.h b/src/screen.h index 25cd8fa..7c776e6 100644 --- a/src/screen.h +++ b/src/screen.h @@ -3,16 +3,101 @@ #include #include +#include -#define STATIC_ARRSIZE(arr) (sizeof((arr)) / sizeof((arr)[0])) +const char *phrases[] = { + // By @syxhe on telegram + "WE CLOWN IN THIS MF, TAKE YO SENSITIVE ASS BACK TO @GENTOOMEMES", + "R.I.P VxHeaven", + "tmp(2) nuked by Smelly", + "99% of Ransomware Operators quit before compromising a bank", + "Equation Group wuz here", + "Lazarus wuz here", + "LockBit wuz here", + "Sponsored by Equation Group", + "Sponsored by Lazarus", + "Sponsored by LockBit", + "Free my boy Ross Ulbricht he did nothing wrong", + "Stay off the dark web, kids", + "FREE BITCOIN JUST 3 SPINS AWAY", + "We all glow in the dark", + "Shoutouts to Simpleflips", + "Shoutouts to BugHunter", + "Shoutouts to EyeDeeKay", + ":beecat:", + ":3", + "You think Jack Rhysider will interview me now?", + "Check out \"Darknet Diaries\"", + "Chill and losing it since 2016", + "POOL'S CLOSED", + "I've been diagnosed with snaids", + "My balls itch", + "We killin filez and shiit", + "lonix users BTFO once again", + "This space left intentionally blank", + "Thinking of a way out is self-centered at best", + "Searching for the punchline to an infinite jest?", + "Still learning what it means to feel", + "Killroy was NOT here", + "Go fuck yourself lmao", + "It's so over", + "We're so back", + "It never even began", + "Pepito they shot Trump", + "This shit ain't nothing to me man", + "I'm him, I will continue to be him", + "THERE ARE MOSQUITOS IN YOUR URETHRA, GET THEM OUT!!!", + "Something wicked this way comes", + "Schizo hour", + "Man I could really use some Chicken Bouillon rn", + "Fuck my digital footprint, I need a digital footjob", + "Having my weekly \"Ted was right\" moment", + "Why aren't you in the gym?", + "Proof?", + "I've gone completely mental", + "The rage consumes me", + "Go outside. Now.", + "Beautiful Day Sunny Morning", + "Fuck crypto all my homies hate crypto", + "stfu fedsmoker is my dad he'll eat you alive", + "Almost dog in hot car'd myself", -#define RGB_MIN 0 -#define RGB_MAX 255 -#define CURSESCOLOR_MIN 0 -#define CURSESCOLOR_MAX 1000 + // by @danielsprofile on telegram + "Daniel Spears loves femboys", + "LizardSquad > Razer", + "Sponsored by Major League Gaming", + "Sponsored by LemonParty.org", + "Sponsored by FTX", + "RIP Harambe", + "Shoutout Elliot Alderson", + "Ted Kaczynski was right", + "The FBI watches me jerk off to MILFs lol", + "robux generator free online 2024 100% working undetected", + "Doge wuz here", + "We like Fortnite we like Fortnite", + "We live in a society", + "Hab you seen a alien pls?", + "using a flipperzero makes me an APT, right?", + "Subscribe to PewDiePie", +}; + +const char *menu_choices[] = { + "Spin", + "Buy spins", + "Quit" +}; + +#define STATIC_ARRSIZE(arr) (sizeof((arr)) / sizeof((arr)[0])) #define FUCKED_UP_ENTER 10 +// functions for the userpointer for each menu item. Defines callbacks and type of function called +#define userfuncs (struct funcholder []){ \ + {.callback = spin, .type = FH_SPIN}, \ + {.callback = buy, .type = FH_BUY}, \ + {.callback = quit, .type = FH_QUIT} \ +} + enum custom_colors { // Unspecified color CC_UNSPEC = -1, @@ -108,17 +193,66 @@ struct params { int numspins; } params; + +//////////////////////////////////// SPECIFICALLY USEFUL FUNCS //////////////////////////////////// + + +// Catch SIGINT and SIGWINCH signals +void catcher(int signum, siginfo_t *info, void *ucontext); + +// Initialize sodium, curses, and set the proper locale. Exits on error, returns 0 otherwise +int doinit(const struct sigaction *handler); + +// Initialize colors & define a few custom colors & color pairs. Exits on error, returns 0 otherwise +int docolors(void); + +// Initialize a set of items using an array of items, an array of menu options, and an array of funcholder structs +int init_items(ITEM *items[], const char *menuopts[], size_t menuopts_size, struct funcholder usrptrs[]); + +// Initialize the individual slot wheels & the window they sit on +int init_slotholder(struct slotholder *slots); + +// Set a specific, custom menu format +int init_custom_menu_format(WINDOW *menuholder, MENU *menu, const int fmtdim[2], Menu_Options toggleon, Menu_Options toggleoff); + +// Create the vx-gambleground banner +WINDOW* create_banner(int col, int randomnum); + +// Deal with menu items when a user hits enter +int handle_menuitem(MENU *menu, struct params *params); + +// Deal with switching menu contexts +int handle_input(WINDOW *menuholder, MENU *menu, struct params *params); + +// Spin the wheel +int spin(void *params); + +// Increase number of spins +int buy(void *params); + +// Quit out +int quit(void *params); + + +//////////////////////////////////// GENERALLY USEFUL FUNCTIONS //////////////////////////////////// + + + // Converts value from within the range of [oldmin, oldmax] to a value within the range [newmin, newmax] float normalize(float value, float oldmin, float oldmax, float newmin, float newmax); // Find the result of x + offset and constrain it to the range [min, max]. x must be >= min int rangemod(int x, int offset, int min, int max); + // Initialize a new curses color using standard rgb values (0-255) instead of curses' 0-1000 range static int init_rgb_color(int colornum, int red, int green, int blue); +#define RGB_MIN 0 +#define RGB_MAX 255 +#define CURSESCOLOR_MIN 0 +#define CURSESCOLOR_MAX 1000 -int spin(void *params); -int buy(void *params); -int quit(void *params); +// Create a box starting at (x, y) with a specified width and height +int mvwcreate_box(WINDOW *win, int y, int x, int height, int width, const chtype chars[6]); #endif \ No newline at end of file -- cgit v1.2.3