1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 #ifndef __MFDINT_H
20 #define __MFDINT_H
21 
22 /*
23  * $Source: r:/prj/cit/src/inc/RCS/mfdint.h $
24  * $Revision: 1.12 $
25  * $Author: tjs $
26  * $Date: 1994/09/10 23:48:52 $
27  *
28  * $Log: mfdint.h $
29  * Revision 1.12  1994/09/10  23:48:52  tjs
30  * proto panel_ref_unexpose.
31  *
32  * Revision 1.11  1994/09/10  04:18:45  mahk
33  * panel ref unexpose
34  *
35  * Revision 1.10  1994/08/26  00:49:11  mahk
36  * new mfd_string_shadow regime.
37  *
38  * Revision 1.9  1994/04/25  01:43:28  xemu
39  * color for unavails
40  *
41  * Revision 1.8  1994/04/18  04:09:35  tjs
42  * Added level overlays for map.
43  *
44  * Revision 1.7  1994/03/31  02:06:08  mahk
45  * Changed proto.
46  *
47  * Revision 1.6  1994/02/15  11:07:42  mahk
48  * Fixed a stupid typo.
49  *
50  * Revision 1.5  1994/02/07  23:43:58  mahk
51  * Hey, maybe you'll need this to compile.
52  *
53  * Revision 1.4  1994/02/07  16:12:29  mahk
54  * Transparent mfd stuff.
55  *
56  * Revision 1.3  1993/12/15  13:52:39  mahk
57  * Added mfd_string wrapping bool
58  *
59  * Revision 1.2  1993/12/08  10:50:17  mahk
60  * Added some useful stuff for mfdfunc.c
61  *
62  * Revision 1.1  1993/12/08  10:32:09  mahk
63  * Initial revision
64  *
65  *
66  */
67 
68 // Includes
69 #include "player.h"
70 
71 // ------
72 // MACROS
73 // ------
74 
75 #define visible_mask(m) ((m == MFD_LEFT) ? FULL_L_MFD_MASK : FULL_R_MFD_MASK)
76 
77 // ---------
78 // Constants
79 // ---------
80 
81 // Button colors
82 #define MFD_BTTN_EMPTY   0xcb
83 #define MFD_BTTN_ACTIVE  0xa2
84 #define MFD_BTTN_FLASH   0x35
85 #define MFD_BTTN_SELECT  0x77
86 #define MFD_BTTN_UNAVAIL 0xdd
87 
88 // Duration of a button flash
89 #define MFD_BTTN_FLASH_TIME 256
90 
91 // From the MFD art resource
92 #define MFD_ART_HUMAN 0
93 #define MFD_ART_TRIOP 1
94 #define MFD_ART_DRUGS 2
95 #define MFD_ART_CHIPS 3
96 #define MFD_ART_GRNDE 4
97 #define MFD_ART_WEAPN 5
98 #define MFD_ART_STATN 6
99 #define MFD_ART_LVL(x) (MFD_ART_STATN + 1 + (x))
100 
101 #define mfd_fdata player_struct.mfd_func_data
102 #define MFD_FONT RES_tinyTechFont
103 
104 extern ObjID panel_ref_unexpose(int mfd_id, int func);
105 
106 // ----------
107 // Structures
108 // ----------
109 
110 // An MFD points to an arbitrary number of slots, which can
111 // be shared by other MFD's.  A slot points to a expose/handler
112 // function pair, which can be shared by multiple slots.
113 
114 #define NUM_MFD_HANDLERS 4
115 
116 struct _mfd_handler;
117 struct _MFD;
118 
119 typedef uchar (*MFD_handlerProc)(struct _MFD *mfd, uiEvent *ev, struct _mfd_handler *mh);
120 typedef uchar (*MFD_SimpHandler)(struct _MFD *mfd, uiEvent *ev);
121 
122 typedef struct _mfd_handler {
123     LGRect r;             // Sub-rect of MFD I'm handling, in relative coordinates.
124     MFD_handlerProc proc; // Proc we call when we get in this
125                           // rect
126     void *data;           // proc-specific state.
127 } MFDhandler;
128 
129 // A button's state depends on the state of its associated slot for its
130 // MFD.  But: a button also keeps track of which is selected, but this
131 // is done through the code and not through the structure.
132 
133 typedef struct { // Button panel structure
134     LGRect rect;
135     LGRegion reg;
136     LGRegion reg2;
137 } MFD_bPanel;
138 
139 typedef struct _MFD {
140     ubyte id;
141     MFD_bPanel bttn; // The button panel
142     LGRect rect;
143     LGRegion reg;
144     LGRegion reg2;
145 } MFD;
146 
147 typedef struct _mfd_func {
148     //   ubyte      id;
149     void (*expose)(MFD *mfd, ubyte control);
150     MFD_SimpHandler simp; // Retained for compatibility.
151     errtype (*init)(struct _mfd_func *);
152     uchar priority; // one is highest, zero is infinitely low
153     // The following stuff is most likely to want to be zero.  so nyah
154     ubyte flags; // Static func-specific info
155     long last;   // Timestamp for incremental
156     int handler_count;
157     MFDhandler handlers[NUM_MFD_HANDLERS];
158 } MFD_Func;
159 
160 extern void init_mfd_funcs();
161 extern uchar mfd_view_callback_full(uiEvent *e, LGRegion *r, intptr_t udata);
162 extern uchar mfd_view_callback(uiEvent *e, LGRegion *r, intptr_t udata);
163 extern uchar mfd_button_callback(uiEvent *e, LGRegion *r, intptr_t udata);
164 extern uchar mfd_button_callback_kb(ushort keycode, uint32_t context, intptr_t data);
165 extern uchar mfd_update_current_slot(ubyte mfd_id, ubyte status, ubyte num_steps);
166 extern void mfd_init_funcs();
167 extern void mfd_set_cliprect(LGRect *r);
168 extern void set_mfd_func(int fnum, void *e, void *h, void *initf, ubyte flags);
169 extern LGPoint mfd_draw_string(char *s, short x, short y, long c, uchar DrawString);
170 extern LGPoint mfd_draw_font_string(char *s, short x, short y, long c, int font, uchar DrawString);
171 extern LGPoint mfd_full_draw_string(char *s, short x, short y, long c, int font, uchar DrawString, uchar transp);
172 extern void set_slot_to_func(ubyte snum, ubyte fnum, MFD_Status stat);
173 extern void mfd_draw_bitmap(grs_bitmap *bmp, short x, short y);
174 extern void mfd_partial_clear(LGRect *r);
175 extern void init_newmfd_button_cursors();
176 extern void mfd_update_display(MFD *m, short x0, short y0, short x1, short y1);
177 extern void mfd_clear_rects(void);
178 extern errtype mfd_add_rect(short x, short y, short x1, short y1);
179 extern void mfd_update_rects(MFD *m);
180 extern ubyte mfd_get_func(ubyte mfd_id, ubyte s);
181 
182 extern char *get_free_frame_buffer_bits(int);
183 #define MFD_EXTRACT_BUF (get_free_frame_buffer_bits(-1))
184 
185 // -------
186 // GLOBALS
187 // -------
188 extern MFD_Func mfd_funcs[MFD_NUM_FUNCS];
189 extern uchar mfd_string_wrap;
190 extern ubyte mfd_string_shadow;
191 
192 #define MFD_SHADOW_NEVER      0
193 #define MFD_SHADOW_ALWAYS     1
194 #define MFD_SHADOW_FULLSCREEN 2
195 
196 #ifdef __NEWMFD_SRC
197 grs_bitmap mfd_background;
198 grs_canvas *pmfd_canvas;
199 #endif
200 #ifndef __NEWMFD_SRC
201 extern grs_bitmap mfd_background;
202 extern grs_canvas *pmfd_canvas;
203 #endif
204 #ifndef __NEWMFD_SRC
205 extern uchar Flash;
206 #endif
207 
208 // ------
209 // Macros
210 // ------
211 
212 #define macro_region_create(parent, child, rect) \
213     region_create(parent, child, rect, 0, 0, REG_USER_CONTROLLED, NULL, NULL, NULL, NULL)
214 
215 #endif // __MFDINT_H
216