From 75a94a96eabb863f21ec5478018886e9c892a5a4 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Wed, 17 Jul 2024 23:41:36 -0500 Subject: Work on the ncurses part --- .gitignore | 1 + src/Makefile | 5 ++- src/main.c | 1 - src/main.h | 6 --- src/screen.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/screen.h | 6 +++ 6 files changed, 148 insertions(+), 8 deletions(-) delete mode 100644 src/main.h create mode 100644 src/screen.c create mode 100644 src/screen.h diff --git a/.gitignore b/.gitignore index 960926b..6fe730e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ test* encrypt +screen search main *.o \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index c140071..94d2674 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,8 +11,11 @@ clean: rm -rvf $(BINARY_FILES) -main: main.c main.h search.o encryption.o ll.o +main: main.c search.o encryption.o ll.o encryption.o: encryption.c encryption.h +screen: screen.c screen.h + $(CC) $(CFLAGS) screen.c -o screen -lncurses -lmenu + search.o: search.c search.h ll.o: ll.c ll.h \ No newline at end of file diff --git a/src/main.c b/src/main.c index 2e6c13a..ce20fa0 100644 --- a/src/main.c +++ b/src/main.c @@ -10,7 +10,6 @@ #define _GNU_SOURCE -#include "main.h" #include "encryption.h" #include "search.h" #include "ll.h" diff --git a/src/main.h b/src/main.h deleted file mode 100644 index fa9e338..0000000 --- a/src/main.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __SLOTS__MAIN_H__2980986086219 -#define __SLOTS__MAIN_H__2980986086219 - - - -#endif \ No newline at end of file diff --git a/src/screen.c b/src/screen.c new file mode 100644 index 0000000..d79ec3c --- /dev/null +++ b/src/screen.c @@ -0,0 +1,137 @@ +/*** + * Screen - The actual point of this godforsaken project + * + * This file's goal is to "render" a slot machine that the soon-to-be unlucky victim must play to get their + * 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 + * +Example window layout + +Random Phrases list: + > WE CLOWN IN THIS MF, TAKE YO SENSITIVE ASS BACK TO @GENTOOMEMES + > R.I.P VxHeaven + > tmp(2) nuked by Smelly + > 99% of Randomware 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 + +======================================================== (Window 1) (One line long, top of screen) +VX-GAMBLEGROUND: +======================================================== (End Window 1) (Takes up space between top & bottom windows) +======================================================== (Window 2) + +SLOTS HERE + +======================================================== (End Window 2) +======================================================== (Window 3) (One line long, bottom of screen) +> Spin > Buy Spins > Quit +======================================================== (End Window 3) + */ + +#define _GNU_SOURCE + +#include "screen.h" +#include +#include +#include + +#include +#include + +#include +#include + +#define STATIC_ARRSIZE(arr) (sizeof((arr)) / sizeof((arr)[0])) + +static const char *menu_choices[] = { + "Spin", + "Buy spins", + "Quit", + NULL +}; + +int main() { + if(setlocale(LC_ALL, "") == NULL) // Clear out the locale so it doesn't default to ncurses' ISO-8859-1 setting + error(1, errno, "Could not set proper locale"); + + if(initscr() == NULL) // Initialize curses + error(1, errno, "Could not init standard screen"); + + if(has_colors()) { // Init colors if available & create color pairings + start_color(); + + // Init colors here + + //init_color(); + } + + cbreak(); // Disables character buffering + noecho(); // Disable echoing characters + keypad(stdscr, TRUE); // Enable keypad on the standard screen + + int row = -1, col = -1; + getmaxyx(stdscr, row, col); + + + /* Ignore + for(int c = getch();; c = getch()) + mvaddch(c % row, c % col, c | A_BOLD); + //*/ + + /* Menu example + ITEM **items; + MENU *menu; + + items = calloc(STATIC_ARRSIZE(menu_choices) + 1, sizeof(ITEM*)); + if(items == NULL) + error(-1, errno, "Could not allocate space for menu items"); + + for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) + items[i] = new_item(menu_choices[i], menu_choices[i]); + items[STATIC_ARRSIZE(menu_choices)] = NULL; + + menu = new_menu(items); + mvprintw(LINES - 2, 0, "F1 to Exit"); + post_menu(menu); + refresh(); + + int c; + while((c = getch()) != KEY_F(1)) { + switch(c) { + case KEY_DOWN: + menu_driver(menu, REQ_DOWN_ITEM); + break; + + case KEY_UP: + menu_driver(menu, REQ_UP_ITEM); + break; + + case KEY_ENTER: + break; + } + } + + + for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) + free_item(items[i]); + free_menu(menu); + //*/ + + + + endwin(); // Clean up curses + return 0; +} \ No newline at end of file diff --git a/src/screen.h b/src/screen.h new file mode 100644 index 0000000..7795336 --- /dev/null +++ b/src/screen.h @@ -0,0 +1,6 @@ +#ifndef __SLOTS__SCREEN_H__184802466018249 +#define __SLOTS__SCREEN_H__184802466018249 + +// + +#endif \ No newline at end of file -- cgit v1.2.3