Debian Codegraph @

Descent3/TelComEffects.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
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 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/TelComEffects.h $
21 * $Revision: 27 $
22 * $Date: 4/20/99 12:46p $
23 * $Author: Jeff $
24 *
25 * TelCom Effect class defines
26 *
27 * $Log: /DescentIII/main/TelComEffects.h $
28 *
29 * 27 4/20/99 12:46p Jeff
30 * telcom main menu, mouse over button sets focus. if you go into telcom
31 * main menu, when you leave a system it will return you to main menu.
32 *
33 * 26 4/17/99 6:15p Samir
34 * replaced gr.h with grdefs.h and fixed resulting compile bugs.
35 *
36 * 25 4/14/99 3:57a Jeff
37 * fixed case mismatch in #includes
38 *
39 * 24 4/02/99 8:32p Jeff
40 * added system event queue. Arrow keys work in main menu and ship
41 * selection
42 *
43 * 23 2/17/99 6:55p Jeff
44 * added jump button type. Added no early render flag for bitmaps. Fixed
45 * color bug for type text
46 *
47 * 22 2/03/99 12:14a Jeff
48 * updated single player ship selection to full functional...needs effects
49 * added in. Had to add flag to buttons for gain focus to register as a
50 * click
51 *
52 * 21 2/01/99 4:52p Jeff
53 * screenshots work in telcom
54 *
55 * 20 10/12/98 8:32p Jeff
56 * changed the way focus is handled
57 *
58 * 19 9/17/98 2:29p Jeff
59 * added focus filenames to button effect
60 *
61 * 18 8/27/98 2:51p Jeff
62 * New TelCom finally checked in
63 *
64 * 17 7/11/98 9:17p Jeff
65 * moved wordwrap functions out so they can be used externally
66 *
67 * 16 6/17/98 4:15p Jeff
68 * adjusted scroll button positions
69 *
70 * 15 5/19/98 3:40p Jeff
71 * poly models functional
72 *
73 * 14 5/15/98 5:16p Jeff
74 * use regular draw chunk bitmap
75 *
76 * 13 5/11/98 6:21p Jeff
77 * fixed setting glitch offsets
78 *
79 * 12 5/07/98 3:31p Jeff
80 * various optimizations, removed Copy and similar functions
81 *
82 * 11 5/05/98 6:50p Jeff
83 * Telcom doesn't use rend_DrawLFBitmap anymore...more speed!
84 *
85 * 10 5/04/98 5:29p Jeff
86 * Added sounds to TelCom events
87 *
88 * 9 5/04/98 1:35p Jeff
89 * Changes made for mouse handling
90 *
91 * 8 5/04/98 11:01a Jeff
92 * added scroll parameter to text
93 *
94 * 7 5/03/98 7:57p Jeff
95 * Got scrolling textboxes working
96 *
97 * 6 5/01/98 2:17p Jeff
98 * Added sound effect support
99 *
100 * 5 4/29/98 4:36p Jeff
101 * added auto word wrap
102 *
103 * 4 4/28/98 6:58p Jeff
104 * Added new poly model effect driver
105 *
106 * 3 4/26/98 7:20p Jeff
107 * Added the rest of the effect drivers except for scrolling text. Added
108 * invert bitmaps and stretch bitmaps
109 *
110 * 2 4/26/98 2:54a Jeff
111 * Initial Creation
112 *
113 * 1 4/25/98 4:23p Jeff
114 *
115 * $NoKeywords: $
116 */
117
118 #ifndef __TELCOM_EFFECTS_H_
119 #define __TELCOM_EFFECTS_H_
120
121 #include "pstypes.h"
122 #include "renderer.h"
123 #include "grdefs.h"
124 #include "cinematics.h"
125 #include "TelComEfxStructs.h"
126 #include "TelCom.h"
127 #include "vecmat_external.h"
128
129 /*
130 ***************************************************************************************
131 Start of New TelCom
132 ***************************************************************************************
133 */
134
135 #define MAX_TCEFFECTS 256
136 #define MAX_EFFECT_EVENTS 5
137 #define INVALID_EFFECT_HANDLE 0xFFFFFFFF
138
139 // Effect types
140 #define EFX_NONE 0
141 #define EFX_TEXT_STATIC 1
142 #define EFX_TEXT_TYPE 2
143 #define EFX_TEXT_FADE 3
144 #define EFX_BMP_STATIC 4
145 #define EFX_BMP_BLUR 5
146 #define EFX_BMP_SCANLINE 6
147 #define EFX_BMP_INVERT 7
148 #define EFX_BMP_STRETCH 8
149 #define EFX_BACKGROUND 9
150 #define EFX_MOVIE 10
151 #define EFX_POLYMODEL 11
152 #define EFX_SOUND 12
153 #define EFX_BUTTON 13
154
155 // Events
156 #define TEVT_GAINFOCUS 0
157 #define TEVT_LOSTFOCUS 1
158 #define TEVT_MOUSEOVER 2
159 #define TEVT_MOUSECLICK 3
160 #define TEVT_MOUSEDOWN 4
161 #define TEVT_MOUSEUP 5
162 #define TEVT_TCQUIT 6
163 #define TEVT_TCNEXT 7
164 #define TEVT_TCPREV 8
165 #define TEVT_TCJUMP 9
166 #define TEVT_SCROLLDOWN 10
167 #define TEVT_SCROLLUP 11
168 #define TEVT_SCREENSHOT 12
169 #define TEVT_FAKEKEYPRESS 13
170 #define TEVT_MOUSEENTER 14
171
172 // others
173 #define BLUR_STAGE_MULTIPLE 0.12f
174 #define BLUR_STAGES 5
175 #define INVALID_EFFECT_ID 0x6FEFCD01
176
177 // Button types
178 #define BUTT_UPARROW 0
179 #define BUTT_DOWNARROW 1
180 #define BUTT_NEXTPAGE 2
181 #define BUTT_PREVPAGE 3
182 #define BUTT_QUIT 4
183 #define BUTT_INTERNAL 5
184 #define BUTT_JUMP 6
185
186 // Button Click types
187 #define CLICKTYPE_CLICKDOWN 0
188 #define CLICKTYPE_CLICKUP 1
189 #define CLICKTYPE_DOWN 2
190
191 struct tTextInfo {
192 float last_letter; // Last letter printed
193 int sound_index; // handle to sound for action
194 int font_index; // Font index
195 int line_index; // index of first text line (scrolling purposes)
196 bool scroll_u, scroll_d; // if the scrollup down buttons are appearing
197 bool scroll; // set to true if it should be allowed to scroll
198 };
199
200 struct tBitmapInfo {
201 int temp_bmhandle; // handle of temporary bitmap
202 float stage; // stage that bitmap effect is in
203 int *bitmaps; // array of bitmaps (for scale effect)
204 int bm_count; // how many bitmaps (for scale effect)
205 int bm_handle; // handle to the bitmap
206 chunked_bitmap chunk_bmp; // the chunk bitmap
207 };
208
209 struct tPolyInfo {
210 vector m_Rot; // current rotation
211 vector m_Pos; // current position
212 vector m_Ori; // current orientation
213 matrix m_mOrient; // orientation
214 int handle; // handle to polymodel
215 };
216
217 struct tMovieInfo {
218 tCinematic *handle; // handle to the movie
219 char *filename; // filename of the movie
220 float fps; // fps
221 };
222
223 struct tSoundInfo {
224 bool started; // has the sound started?
225 int handle; // handle of the sound
226 };
227
228 struct tButtonInfo {
229 bool flash_state; // Is the button glowing?
230 uint8_t click_type; // CLICKTYPE_DOWN or CLICKTYPE_CLICK (what the button responds to)
231 uint8_t button_type;
232 int sibling; // Sibling effect (for down/up arrows), -1 if none
233 int parent; // Parent effect (text for down/up arrows), -1 if it works with TelCom System
234 int bm_handle;
235 int bmfocus_handle;
236 int flash_handle;
237 int flashfocus_handle;
238 int real_x, real_y;
239 int jump_page;
240 float flash_time;
241 void (*internal)(int);
242 chunked_bitmap chunk_bmp;
243 chunked_bitmap chunkfocus_bmp;
244 chunked_bitmap flash_chunk;
245 chunked_bitmap flashfocus_chunk;
246 };
247
248 struct tceffect {
249 uint8_t type; // Type of effect
250 uint8_t monitor; // Which monitor it belongs to
251 uint8_t screen; // What screen the effect belongs to
252 bool tab_stop; // This effect can have focus
253 bool has_focus; // The effect currently has focus
254
255 int id; // user given ID of effect (should be unique)
256
257 char *text_buffer; // Pointer to allocated memory for text string
258
259 int flags; // flags for effect
260
261 int pos_x, pos_y; // Position of upper left corner
262 int w, h; // width and height
263 ddgr_color color; // Color of effect
264
265 float speed; // speed of effect
266 float alpha; // alpha of effect
267 float age; // current age of effect
268 float start_time; // how long until the effect starts
269
270 union {
271 tTextInfo textinfo;
272 tBitmapInfo bmpinfo;
273 tPolyInfo polyinfo;
274 tMovieInfo movieinfo;
275 tSoundInfo soundinfo;
276 tButtonInfo buttoninfo;
277 };
278
279 tTCEvent event_queue[MAX_EFFECT_EVENTS]; // event queue for an effect
280
281 int prev, next; // Links to previous and next effect
282 };
283
284 extern int glitch_dx, glitch_dy;
285
286 extern tceffect TCEffects[MAX_TCEFFECTS];
287 extern int Screen_roots[MAX_TELCOM_SCREENS];
288
289 /////////////////////////////////////////////////
290 // Prototypes
291
292 // Initializes the effects
293 void EfxInit(void);
294
295 // Shutdown of effects
296 void EfxClose(void);
297
298 // Creates an instance of an Effect
299 int EfxCreate(int type, int monitor, int screen, int id = INVALID_EFFECT_ID, bool is_tab_stop = false);
300
301 // Destroys all the screens
302 void EfxDestroyAllScreens(void);
303
304 // Destroys the screens within a monitor
305 void EfxDestroyScreen(int screen);
306
307 // Frees up any memory allocated for effect, sets type to EFX_NONE
308 void EfxFreeEffect(tceffect *tce);
309
310 // Initializes an effect based on it's type
311 void EfxInit(tceffect *tce, bool tab_stop, bool gets_focus);
312
313 // Renders a Monitor
314 void RenderScreen(int screen, tTelComInfo *tsys, float Frametime);
315
316 // Renders an effect
317 void RenderEffect(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
318
319 // Sends an event to an effect
320 void SendEventToEffect(int effect, int event, int parm1 = 0, int parm2 = 0);
321
322 // returns the efxnum of the button that contains the X,Y on the given monitor/screen, -1 if none
323 int FindButtonEffectByXY(int x, int y, int screen);
324
325 // Returns the efxnum given an id & screen, -1 if not found
326 int GetEfxNumFromID(int id, int screen);
327
328 // Pops off an event for processesing, returns -1 if no event available
329 bool PopEvent(tceffect *tce, tTCEvent *event);
330 void RenderTextStatic(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
331 void RenderTextType(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
332 void RenderTextFade(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
333 void RenderBmpStatic(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
334 void RenderBmpBlur(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
335 void RenderBmpScanline(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
336 void RenderBmpInvert(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
337 void RenderBmpStretch(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
338 void RenderBackground(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
339 void RenderMovie(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
340 void RenderPolyModel(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
341 void RenderSound(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
342 void RenderButton(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render);
343
344 bool CreateTextEffect(TCTEXTDESC* desc, const char *text, int monitor, int screen, int id = INVALID_EFFECT_ID);
345 bool CreateBitmapEffect(TCBMPDESC* desc, int monitor, int screen, int id = INVALID_EFFECT_ID);
346 bool CreateMovieEffect(TCMOVIEDESC* desc, int monitor, int screen, int id = INVALID_EFFECT_ID);
347 bool CreateBackgroundEffect(TCBKGDESC* desc, int monitor, int screen, int id = INVALID_EFFECT_ID);
348 bool CreatePolyModelEffect(TCPOLYDESC* desc, int monitor, int screen, int id = INVALID_EFFECT_ID);
349 bool CreateSoundEffect(TCSNDDESC* desc, int monitor, int screen, int id = INVALID_EFFECT_ID);
350 int CreateButtonEffect(TCBUTTONDESC* desc, int monitor, int screen, int id = INVALID_EFFECT_ID);
351 bool CreateTextStatic(tceffect *tce, const char *text);
352 bool CreateTextFade(tceffect *tce, const char *text);
353 bool CreateTextType(tceffect *tce, const char *text);
354 bool CreateBmpStatic(tceffect *tce, const char *filename);
355 bool CreateBmpBlur(tceffect *tce, const char *filename);
356 bool CreateBmpScanline(tceffect *tce, const char *filename);
357 bool CreateBmpInvert(tceffect *tce, const char *filename);
358 bool CreateBmpStretch(tceffect *tce, const char *filename);
359 bool CreateMovie(tceffect *tce, const char *filename);
360 bool CreateBackground(tceffect *tce);
361 bool CreateSound(tceffect *tce, const char *filename);
362
363 void BltBmpToScreen(int dx, int dy, chunked_bitmap *src_bmp);
364 void BltBmpToScreen(int dx, int dy, chunked_bitmap *src_bmp, int sx, int sy, int sw, int sh);
365 // forces a chunk bitmap to be uploaded
366 void UploadChunk(chunked_bitmap *bmp);
367
368 char *format(const char *format, ...);
369
370 #endif