| 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 | |
| 19 | #ifndef __TELCOM_H_ |
| 20 | #define __TELCOM_H_ |
| 21 | |
| 22 | #include "hotspotmap.h" |
| 23 | #include "gamefont.h" |
| 24 | #include "bitmap.h" |
| 25 | |
| 26 | // TelCom Briefing System Header File |
| 27 | |
| 28 | // TelCom Function Prototypes |
| 29 | // these are the functions that can/should be called outside of TelCom*.cpp |
| 30 | |
| 31 | // inits the Telcom system...needs to be called before anything else, only needs to be called once |
| 32 | void TelComInit(void); |
| 33 | |
| 34 | // handles input processing, etc |
| 35 | void TelComDefer(void); |
| 36 | |
| 37 | // Pages in all the necessary bitmaps, textures & sounds for the TelCom so that they are in memory |
| 38 | void TelcomPageAllIn(void); |
| 39 | |
| 40 | // Cleanup crew, don't worry about calling this guy, it's an atexit() in the init |
| 41 | void TelComFree(); |
| 42 | |
| 43 | // actually displays the Telcom system, if you specify a system it will display showing that system, |
| 44 | // else it will display the last used system |
| 45 | // returns true on success |
| 46 | |
| 47 | bool TelComShow(bool ingame = true, bool ShipSelect = false); |
| 48 | bool TelComShow(int system, bool ingame = true, bool ShipSelect = false); |
| 49 | |
| 50 | // deactivates the TelCom system if it is running |
| 51 | void TelComDeactivate(void); |
| 52 | |
| 53 | #define HOTSPOT_DISPLAY "TelComon.HSM" // string name for the HotSpot map |
| 54 | |
| 55 | #define TELCOM_DISPLAY_TGA "TelComOff.TGA" // string name for the TGA file that needs to be converted |
| 56 | #define TELCOM_DISPLAY_OGF "TelComOff.OGF" // converted OGF filename |
| 57 | #define TELCOM_DISPLAY_OGF_ON "TelComOn.OGF" // TelCom in the on state file |
| 58 | #define BACKGROUND_COLOR GR_RGB(49, 29, 150) |
| 59 | |
| 60 | /* |
| 61 | $$TABLE_GAMEFILE "TelComon.HSM" |
| 62 | $$TABLE_GAMEFILE "TelComOff.OGF" |
| 63 | $$TABLE_GAMEFILE "TelComOn.OGF" |
| 64 | */ |
| 65 | |
| 66 | extern chunked_bitmap Telcom_bitmap; |
| 67 | extern int TC_cursor; |
| 68 | extern float last_frametime; |
| 69 | |
| 70 | /* |
| 71 | // Note for above: In TelCom.h there is a section of defines which give names to the above files |
| 72 | // for use when calling a function like DisplayStillScreen() |
| 73 | |
| 74 | */ |
| 75 | // NOTE: The following #defines MUST match up with Sean's alpha values |
| 76 | // TelCom Systems |
| 77 | |
| 78 | #define TS_POWER 1 |
| 79 | #define TS_OFF -3 // The TelCom is powered on...but nothing selected |
| 80 | |
| 81 | #define POWER_BUTTON 1 |
| 82 | #define NEON_LIGHT 2 |
| 83 | |
| 84 | #define NUMBER_OF_SYSTEMS 5 // Total number of systems listed below |
| 85 | #define TS_MAINMENU TS_OFF |
| 86 | #define TS_MISSION 1 // Mission Objective system |
| 87 | #define TS_CARGO 2 // Inventory system |
| 88 | #define TS_MAP 3 // Automap system |
| 89 | #define TS_SHIPSELECT 4 // SinglePlayer Ship Selection |
| 90 | #define TS_GOALS 5 // Goal status |
| 91 | |
| 92 | // Windows (=alpha value-MAX_HOTSPOTS) used internally |
| 93 | #define MAX_TELCOM_SCREENS 20 |
| 94 | #define MAX_TELCOM_EVENTS 10 |
| 95 | #define DUMMY_SCREEN MAX_TELCOM_SCREENS - 1 |
| 96 | |
| 97 | // Monitors |
| 98 | #define MONITOR_MAIN 0 |
| 99 | #define MONITOR_TOP 1 |
| 100 | #define MAX_MONITOR 2 |
| 101 | |
| 102 | // Telcom keys |
| 103 | #define TCSYS_TAB 0 |
| 104 | #define TCSYS_UP 1 |
| 105 | #define TCSYS_DOWN 2 |
| 106 | #define TCSYS_LEFT 3 |
| 107 | #define TCSYS_RIGHT 4 |
| 108 | #define TCSYS_ENTER 5 |
| 109 | #define TCSYS_SPACE 6 |
| 110 | #define TCSYS_Q 7 |
| 111 | #define TCSYS_F1 8 |
| 112 | #define TCSYS_F2 9 |
| 113 | #define TCSYS_F3 10 |
| 114 | #define TCSYS_PRINTSCRN 11 |
| 115 | #define TCSYS_1 12 |
| 116 | #define TCSYS_2 13 |
| 117 | #define TCSYS_3 14 |
| 118 | #define TCSYS_4 15 |
| 119 | #define TCSYS_5 16 |
| 120 | #define TCSYS_6 17 |
| 121 | #define TCSYS_7 18 |
| 122 | #define TCSYS_8 19 |
| 123 | #define TCSYS_REVERSETAB 20 |
| 124 | |
| 125 | #define TCSYS_MAXKEYS 21 |
| 126 | // Screen states |
| 127 | #define SS_EMPTY 0 |
| 128 | #define SS_BEING_MADE 1 |
| 129 | #define SS_READY 2 |
| 130 | |
| 131 | // Telcom system states |
| 132 | #define TCS_POWEROFF 0 |
| 133 | #define TCS_POWERON 1 |
| 134 | |
| 135 | // A cleanup function, freeing up memory used for the monitor windows |
| 136 | void FreeViewports(); |
| 137 | |
| 138 | // Initializes the system buttons for use |
| 139 | void InitSystems(); |
| 140 | |
| 141 | // This function 'compresses' the on-state background, to save space |
| 142 | void CompressTelComOnImage(int bitmap, chunked_bitmap *array); |
| 143 | // frees up on-state bitmaps |
| 144 | void FreeTelComOnBitmaps(chunked_bitmap *array); |
| 145 | |
| 146 | // returns the screen coordinates of a hotspot |
| 147 | int HotSpotW(int hotspot); |
| 148 | int HotSpotH(int hotspot); |
| 149 | int HotSpotL(int hotspot); |
| 150 | int HotSpotR(int hotspot); |
| 151 | int HotSpotT(int hotspot); |
| 152 | int HotSpotB(int hotspot); |
| 153 | /* |
| 154 | void TCStartPowerupSound(void); |
| 155 | void TCStopPowerupSound(void); |
| 156 | void TCStartPowerDownSound(void); |
| 157 | void TCStopPowerDownSound(void); |
| 158 | void TCStartRunningSound(void); |
| 159 | void TCStopRunningSound(void); |
| 160 | void TCStartStaticSound(float amp); |
| 161 | */ |
| 162 | void TCStartBulbSound(void); |
| 163 | void DoCursor(void); |
| 164 | |
| 165 | extern hotspotmap_t hotspotmap; |
| 166 | extern windowmap_t windowmap; |
| 167 | extern bool TelCom_running; // Used within TelComMain(), when POWER button is pressed become false |
| 168 | |
| 169 | // structure for a bounding box (used when getting a hotspot bounding box) |
| 170 | struct box { |
| 171 | int top, bottom, left, right; |
| 172 | }; |
| 173 | |
| 174 | struct tTCEvent { |
| 175 | int id; |
| 176 | int parms[2]; |
| 177 | }; |
| 178 | |
| 179 | struct tTelComInfo { |
| 180 | box Monitor_coords[MAX_MONITOR]; |
| 181 | uint8_t Screen_state[MAX_TELCOM_SCREENS]; |
| 182 | tTCEvent Telcom_event_queue[MAX_TELCOM_EVENTS]; // Event queue for TelCom System |
| 183 | int TranslateSysKey[TCSYS_MAXKEYS]; |
| 184 | int current_status; |
| 185 | bool Telcom_systemkey_states[TCSYS_MAXKEYS]; |
| 186 | float Telcom_mouse_downtime; |
| 187 | uint8_t state; |
| 188 | int TelComSysKeyEnable; |
| 189 | }; |
| 190 | extern tTelComInfo Telcom_system; |
| 191 | |
| 192 | // This is the function called by TelCom to choose a ship |
| 193 | void TelComSingleShipSelect(tTelComInfo *tcs); |
| 194 | |
| 195 | //********************************************** |
| 196 | // TelCom Rendering Functions |
| 197 | //********************************************** |
| 198 | // Initializes the Telcom rendering engine |
| 199 | void TelcomRenderInit(void); |
| 200 | // Closes down the Telcom rendering engine |
| 201 | void TelcomRenderClose(void); |
| 202 | // Renders the current screen for 1 frame |
| 203 | void TelcomRenderScreen(bool poweron = true, bool powerup = false, uint8_t power_effect = 1); |
| 204 | // Sets what screen should be drawn by the Telcom |
| 205 | void TelcomRenderSetScreen(int screen); |
| 206 | // Sets the callback of the Render. This will get called after Effects are drawn, before the screen overlays |
| 207 | void TelcomRenderSetCallback(void (*callback)()); |
| 208 | // Creates a placeholder screen that can be used if no screens are available |
| 209 | void TelcomCreateDummyScreen(void); |
| 210 | // Creates a placeholder screen that can be used for startup |
| 211 | void TelcomCreateStartupScreen(void); |
| 212 | // Creates a placeholder screen that can be used for shutdown |
| 213 | void TelcomCreateShutdownScreen(void); |
| 214 | // Enables Static on the Telcom main screen, setting is the probability of static happening |
| 215 | void TelcomEnableStatic(float setting); |
| 216 | // Disables static on the Telcom main screen |
| 217 | void TelcomDisableStatic(void); |
| 218 | // Enables glitching on the Telcom main screen |
| 219 | void TelcomEnableGlitch(float setting); |
| 220 | // Disables glitching on the TelCom |
| 221 | void TelcomDisableGlitch(void); |
| 222 | |
| 223 | /*************************************************** |
| 224 | * TelCom Screen Control |
| 225 | *************************************************** |
| 226 | * |
| 227 | */ |
| 228 | // Initializes the TelCom Screens so they're ready for input |
| 229 | void InitAllScreens(void); |
| 230 | // Destroys and clears all screens of the TelCom |
| 231 | void DestroyAllScreens(bool remove_dummy = false); |
| 232 | // Starts a TelCom screen so it can be created |
| 233 | void TelcomStartScreen(int screen); |
| 234 | // Ends a TelCom screen. Calling this enables the screen to be displayed |
| 235 | void TelcomEndScreen(void); |
| 236 | // Advances to the next screen |
| 237 | // returns true is there is no screen (it's not being made, nor ready) |
| 238 | bool TelcomAdvanceScreen(void); |
| 239 | // Backs up a screen |
| 240 | // returns true is there is no screen (it's not being made, nor ready) |
| 241 | bool TelcomBackupScreen(void); |
| 242 | // Jumps to a screen |
| 243 | // returns true if there is no screen (not being made, nor ready) |
| 244 | bool TelComJumpScreen(int screen); |
| 245 | |
| 246 | /*************************************************** |
| 247 | * TelCom Event Handling |
| 248 | *************************************************** |
| 249 | */ |
| 250 | |
| 251 | // Prototypes |
| 252 | /* |
| 253 | * Initializes the TelCom Event manager system |
| 254 | * Call this as soon as possible |
| 255 | * You can call it whenever the events need to be flushed |
| 256 | */ |
| 257 | void TelComInitEventManager(void); |
| 258 | /* |
| 259 | * Calling this sends an event message to the TelCom, adding it to it's event queue |
| 260 | * |
| 261 | */ |
| 262 | void TelComSendEvent(int event_num, int parm1 = 0, int parm2 = 0); |
| 263 | /* |
| 264 | * Call this when handling the TelCom system events, returns true if there is an event waiting, it will then fill |
| 265 | * in the passed struct. You should call this repeatedly until a value of false is returned, signaling no more |
| 266 | * events in the queue |
| 267 | */ |
| 268 | bool TelComPopEvent(tTCEvent *evt); |
| 269 | |
| 270 | // Similar to the TelCom's main system event queue, these are for use by individual systems |
| 271 | void TelCom_ClearSystemQueue(void); |
| 272 | void TelCom_SendSystemEvent(int event_num, int parm1 = -1, int parm2 = -1); |
| 273 | bool TelCom_PopSystemEvent(tTCEvent *evt); |
| 274 | |
| 275 | /* |
| 276 | Handles a possible custom key event |
| 277 | */ |
| 278 | void TelCom_ProcessCustomKeyEvent(int key_id); |
| 279 | /* |
| 280 | Removes any custom key event translation masks |
| 281 | */ |
| 282 | void TelCom_ClearCustomKeyEvents(void); |
| 283 | /* |
| 284 | Adds a custom key event translation mask |
| 285 | */ |
| 286 | void TelCom_AddCustomKeyEvent(int key_id, int event_id); |
| 287 | |
| 288 | /* |
| 289 | * This should be called once a frame, it will handle all events in the TelCom system and send off any system |
| 290 | * events to the effects/buttons |
| 291 | */ |
| 292 | void TelComHandleAllEvents(tTelComInfo *tcs); |
| 293 | /* |
| 294 | * Given the key that has been pressed, or being held down, it processes the event depending on what key |
| 295 | * it is. |
| 296 | * |
| 297 | */ |
| 298 | void TelComHandleKeyPress(int key, bool click, int screen_id); |
| 299 | /* |
| 300 | * Enables/Disables a TelCom system key, pass in TCSYS_MAXKEYS to enable/disable all keys |
| 301 | * |
| 302 | */ |
| 303 | void TelComEnableSystemKey(int key, bool enable); |
| 304 | |
| 305 | /* |
| 306 | * Forces an effect to have focus (if is allowed to have focus) |
| 307 | * |
| 308 | */ |
| 309 | void TelComSetFocusOnEffect(int efxnum); |
| 310 | |
| 311 | /* |
| 312 | **************************************************************** |
| 313 | * TelCom Sound Functions * |
| 314 | **************************************************************** |
| 315 | * |
| 316 | */ |
| 317 | |
| 318 | #define TCSND_STARTUP 0 |
| 319 | #define TCSND_STATIC 1 |
| 320 | #define TCSND_SHUTDOWN 2 |
| 321 | #define TCSND_RUNNING 3 |
| 322 | #define TCSND_LIGHTBULB 4 |
| 323 | #define TCSND_TYPING 5 |
| 324 | #define TCSND_CLICK 6 |
| 325 | #define TCSND_SOUNDCOUNT 7 |
| 326 | |
| 327 | // Initalizes the Telcom sound sytem |
| 328 | void TelcomInitSounds(void); |
| 329 | // Closes down the Telcom sound system |
| 330 | void TelcomCloseSounds(void); |
| 331 | // Starts a sound playing (if it isn't already) |
| 332 | void TelcomStartSound(int sid); |
| 333 | // Stops a sound playing |
| 334 | void TelcomStopSound(int sid); |
| 335 | |
| 336 | extern bool Telcom_called_from_game; |
| 337 | |
| 338 | #endif |