summaryrefslogtreecommitdiff
path: root/src/screen.h
blob: 25cd8fa93e1c3e3aea78f21799ed4ee076daa0ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef __SLOTS__SCREEN_H__184802466018249
#define __SLOTS__SCREEN_H__184802466018249

#include <menu.h>
#include <curses.h>

#define STATIC_ARRSIZE(arr) (sizeof((arr)) / sizeof((arr)[0]))

#define RGB_MIN 0
#define RGB_MAX 255
#define CURSESCOLOR_MIN 0
#define CURSESCOLOR_MAX 1000

#define FUCKED_UP_ENTER 10

enum custom_colors {
    // Unspecified color
    CC_UNSPEC = -1,

    /* The standard curses colors are defined here as to prevent custom colors from reusing pre-existing 
    // colors, in case the defaults are to be used */

    CURSES_BLACK    = COLOR_BLACK,      // ncurses' default black
    CURSES_RED      = COLOR_RED,        // ncurses' default red
    CURSES_GREEN    = COLOR_GREEN,      // ncurses' default green
    CURSES_YELLOW   = COLOR_YELLOW,     // ncurses' default yellow
    CURSES_BLUE     = COLOR_BLUE,       // ncurses' default blue
    CURSES_MAGENTA  = COLOR_MAGENTA,    // ncurses' default magenta
    CURSES_CYAN     = COLOR_CYAN,       // ncurses' default cyan
    CURSES_WHITE    = COLOR_WHITE,      // ncurses' default white

    /* Start custom color definitions */

    CC_RED,     // RGB: 255,    0,      0
    CC_ORANGE,  // RGB: 255,    128,    0
    CC_YELLOW,  // RGB: 255,    255,    0
    CC_GREEN,   // RGB: 0,      255,    0
    CC_BLUE,    // RGB: 0,      0,      255
    CC_PURPLE,  // RGB: 155,    0,      255
    CC_MAGENTA, // RGB: 255,    0,      255
    CC_WHITE,   // RGB: 255,    255,    255
    CC_BLACK,   // RGB: 0,      0,      0

    CC_WINNING,    // RGB: 232,     185,    35

    // This isn't actually a color, even if you try to use it as one
    CC_TOOBIG
};

enum customcolor_pairs {
    CCP_UNDEFINED = -1,

    CCP_CURSES_DEFAULT = 0,

    CCP_TESTING,    // Text: White, BG: Red
    CCP_BANNER,     // Text: White, BG: Curses' Blue

    CCP_RED,        // Text: White, BG: Red
    CCP_ORANGE,     // Text: Black, BG: Orange
    CCP_YELLOW,     // Text: Black, BG: Yellow
    CCP_GREEN,      // Text: Black, BG: Green
    CCP_BLUE,       // Text: White, BG: Blue
    CCP_PURPLE,     // Text: White, BG: Purple
    CCP_MAGENTA,    // Text: White, BG: Magenta
    CCP_WHITE,      // Text: Black, BG: White

    CCP_WINNING1,   // Text: White, BG: Gold
    CCP_WINNING2,   // Text: Gold,  BG: White 

    CCP_TOOBIG
};
#define NUMCOLORCYCLE 4
#define COLORWIDTH (CCP_WHITE - CCP_RED)
#define NUMCOLORPAIRS (COLORWIDTH + 1)

struct slotholder {
    WINDOW *slotwin;
    int slotx;
    int sloty;
    
    WINDOW *subslot[3];
    char slotchar[3][3];
};

struct funcholder {
    int (*callback)(void*);
    enum type {
        FH_UNSPEC,

        FH_SPIN,
        FH_BUY,
        FH_QUIT,

        FH_TOOBIG
    } type;
};

struct params {
    // Previously spinp
    WINDOW *bannerwin;
    struct slotholder *slots;

    WINDOW *menuholder;
    MENU *menu;
        
    // Previously buyp
    unsigned int price;
    int numspins;
} params;

// 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);

int spin(void *params);
int buy(void *params);
int quit(void *params);

#endif