summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2024-08-10 22:32:13 -0500
committer@syxhe <https://t.me/syxhe>2024-08-10 22:32:13 -0500
commit293b1eb5ebf9f486ce9a89398319f646f2a29c3b (patch)
tree9b46511cf48ee14cbcec222ae41a2a98b0ede769 /src
parent26107501a9c975a7b39b22402316f3e8cd8d0d8e (diff)
Implement subslots & pass to spin()
Diffstat (limited to 'src')
-rw-r--r--src/screen.c79
-rw-r--r--src/screen.h13
2 files changed, 69 insertions, 23 deletions
diff --git a/src/screen.c b/src/screen.c
index 8393e07..00381d2 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -60,6 +60,10 @@ static const char *phrases[] = {
60 ":3", 60 ":3",
61 "You think Jack Rhysider will interview me now?", 61 "You think Jack Rhysider will interview me now?",
62 "Check out \"Darknet Diaries\"", 62 "Check out \"Darknet Diaries\"",
63 "Chill and losing it since 2016",
64 "POOL'S CLOSED",
65 "I've been diagnosed with snaids",
66 "My balls itch",
63 67
64 // by @danielsprofile on telegram 68 // by @danielsprofile on telegram
65 "Daniel Spears loves femboys", 69 "Daniel Spears loves femboys",
@@ -87,30 +91,35 @@ static const char *menu_choices[] = {
87}; 91};
88 92
89static struct funcholder userfuncs[] = { 93static struct funcholder userfuncs[] = {
90 {.callback = spin, .type = FH_SPIN, .params = {.spinp = {.bannerwin = NULL, .phrasenum = 0}}}, 94 {.callback = spin, .type = FH_SPIN},
91 {.callback = buy, .type = FH_BUY, .params = {.buyp = {.numspins = 3, .price = 1}}}, 95 {.callback = buy, .type = FH_BUY},
92 {.callback = quit, .type = FH_QUIT, .params = {.quitp = {.REPLACEME = NULL}}} 96 {.callback = quit, .type = FH_QUIT}
93}; 97};
94 98
95void intercleanup(int signum) { 99void catcher(int signum, siginfo_t *info, void *ucontext) {
96 // Only want to handle interrupts 100 // This is retarded lol, but makes gcc happy
97 if(signum != SIGINT) 101 info->si_code = info->si_code;
98 abort(); 102 ucontext = ucontext;
99 103
100 endwin(); 104 switch(signum) {
101 error(0, 0, "[VX-GAMBLEGROUND] Caught interrupt"); 105 case SIGINT:
102 exit(0); 106 endwin();
107 error(0, 0, "[VX-GAMBLEGROUND] Caught interrupt");
108 exit(0);
109
110 case SIGWINCH:
111 endwin();
112 error(1, 0, "[VX-GAMBLEGROUND] User changed window size and I haven't implemented code to handle it yet");
113 abort(); // Makes gcc happy (angry about implicit fallthrough)
114
115 default:
116 abort();
117 }
103 118
104 return; 119 return;
105} 120}
106 121
107static const struct sigaction handlers[] = { 122static struct sigaction handler = {.sa_flags = SA_SIGINFO, .sa_mask = SIGINT | SIGWINCH, .sa_sigaction = catcher};
108 { // intercleanup
109 .sa_flags = 0,
110 .sa_mask = SIGINT,
111 .sa_handler = intercleanup
112 }
113};
114 123
115// Initialize sodium, curses, and set the proper locale. Exits on error, returns 0 otherwise 124// Initialize sodium, curses, and set the proper locale. Exits on error, returns 0 otherwise
116static int doinit(void) { 125static int doinit(void) {
@@ -123,8 +132,8 @@ static int doinit(void) {
123 if(initscr() == NULL) // Initialize curses 132 if(initscr() == NULL) // Initialize curses
124 error(1, errno, "[VX-GAMBLEGROUND] Could not init standard screen"); 133 error(1, errno, "[VX-GAMBLEGROUND] Could not init standard screen");
125 134
126 if(sigaction(SIGINT, &handlers[0], NULL) < 0) 135 if(sigaction(SIGINT, &handler, NULL) < 0 || sigaction(SIGWINCH, &handler, NULL) < 0)
127 error(1, errno, "[VX-GAMBLEGROUND] Could not set up signal handler"); 136 error(1, errno, "[VX-GAMBLEGROUND] Could not set up signal catcher");
128 137
129 return 0; 138 return 0;
130} 139}
@@ -239,6 +248,7 @@ int main() {
239 MENU *menu; // The actual menu object 248 MENU *menu; // The actual menu object
240 int c; // Integer for storing keys from user input 249 int c; // Integer for storing keys from user input
241 250
251 struct slotholder slots;
242 252
243 getmaxyx(stdscr, row, col); 253 getmaxyx(stdscr, row, col);
244 if(row < 0 || col < 0) { 254 if(row < 0 || col < 0) {
@@ -268,22 +278,41 @@ int main() {
268 init_custom_menu_format(menuholder, menu, (int []){1, col}, O_ONEVALUE | O_IGNORECASE, O_SHOWDESC | O_NONCYCLIC); 278 init_custom_menu_format(menuholder, menu, (int []){1, col}, O_ONEVALUE | O_IGNORECASE, O_SHOWDESC | O_NONCYCLIC);
269 279
270 280
271 WINDOW *slots = newwin(row - 2, col, 1, 0); 281 slots.slotwin = newwin(row - 2, col, 1, 0);
272 if(slots == NULL) { 282 if(slots.slotwin == NULL) {
273 endwin(); 283 endwin();
274 error(1, errno, "[VX-GAMBLEGROUND] Could not create slots window"); 284 error(1, errno, "[VX-GAMBLEGROUND] Could not create slots window");
275 } 285 }
276 286
287 /*
277 const char *sampletext = "Lmao longer sample"; 288 const char *sampletext = "Lmao longer sample";
278 mvwaddstr(slots, (row - 2) / 2, (col / 2) - (strlen(sampletext) / 2), sampletext); 289 mvwaddstr(slots, (row - 2) / 2, (col / 2) - (strlen(sampletext) / 2), sampletext);
279 wnoutrefresh(slots); 290 wnoutrefresh(slots);
291 */
292
293 /*
294 int sy, sx;
295 getmaxyx(slots, sy, sx);
296 WINDOW *TEST = derwin(slots, sy, sx/3, 0, 0);
297 wbkgd(TEST, COLOR_PAIR(CCP_TESTING));
298 waddstr(TEST, "lol");
299 wnoutrefresh(TEST);
300 //*/
301
302 getmaxyx(slots.slotwin, slots.sloty, slots.slotx);
303 for(size_t i = 0; i < STATIC_ARRSIZE(slots.subslots); i++) {
304 slots.subslots[i].subslot = derwin(slots.slotwin, slots.sloty, slots.slotx/3, 0, slots.slotx/3 * i);
305 wbkgd(slots.subslots[i].subslot, COLOR_PAIR((slots.subslots[i].color = CCP_RED + i)));
306 mvwaddstr(slots.subslots[i].subslot, slots.sloty/2, slots.slotx/3/2 - 2, "lol");
307 wnoutrefresh(slots.subslots[i].subslot);
308 }
280 309
281 doupdate(); 310 doupdate();
282 311
283 userfuncs[0].params.spinp.bannerwin = banner; 312 userfuncs[0].params.spinp.bannerwin = banner;
284 userfuncs[0].params.spinp.phrasenum = randomnum;
285 userfuncs[0].params.spinp.menuholder = menuholder; 313 userfuncs[0].params.spinp.menuholder = menuholder;
286 userfuncs[0].params.spinp.menu = menu; 314 userfuncs[0].params.spinp.menu = menu;
315 userfuncs[0].params.spinp.slots = &slots;
287 316
288 // Get user input and deal with the menu 317 // Get user input and deal with the menu
289 while((c = wgetch(menuholder)) != KEY_F(4)) { 318 while((c = wgetch(menuholder)) != KEY_F(4)) {
@@ -361,6 +390,12 @@ int spin(void *spinp) {
361 set_menu_back(p->menu, COLOR_PAIR(color)); 390 set_menu_back(p->menu, COLOR_PAIR(color));
362 wnoutrefresh(p->menuholder); 391 wnoutrefresh(p->menuholder);
363 392
393 for(size_t subs = 0; subs < STATIC_ARRSIZE(p->slots->subslots); subs++) {
394 p->slots->subslots[subs].color = rangemod(p->slots->subslots[subs].color, 1, CCP_RED, CCP_WHITE);
395 wbkgd(p->slots->subslots[subs].subslot, COLOR_PAIR(p->slots->subslots[subs].color));
396 wnoutrefresh(p->slots->subslots[subs].subslot);
397 }
398
364 doupdate(); 399 doupdate();
365 nanosleep(&sleeper, NULL); 400 nanosleep(&sleeper, NULL);
366 } 401 }
diff --git a/src/screen.h b/src/screen.h
index 5afbe6e..93297ee 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -66,6 +66,17 @@ enum customcolor_pairs {
66#define COLORWIDTH (CCP_WHITE - CCP_RED) 66#define COLORWIDTH (CCP_WHITE - CCP_RED)
67#define NUMCOLORPAIRS (COLORWIDTH + 1) 67#define NUMCOLORPAIRS (COLORWIDTH + 1)
68 68
69struct slotholder {
70 WINDOW *slotwin;
71 int slotx;
72 int sloty;
73
74 struct subslot {
75 WINDOW *subslot;
76 enum customcolor_pairs color;
77
78 } subslots[3];
79};
69 80
70struct funcholder { 81struct funcholder {
71 int (*callback)(void*); 82 int (*callback)(void*);
@@ -82,7 +93,7 @@ struct funcholder {
82 union param { 93 union param {
83 struct spinp { 94 struct spinp {
84 WINDOW *bannerwin; 95 WINDOW *bannerwin;
85 int phrasenum; 96 struct slotholder *slots;
86 97
87 WINDOW *menuholder; 98 WINDOW *menuholder;
88 MENU *menu; 99 MENU *menu;