Debian Codegraph @

editor/ObjCScript.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/editor/ObjCScript.h $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:38 $
23 * $Author: kevinb $
24 *
25 * Osiris Script loader for editor
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 19 6/23/98 3:04p Samir
30 * sped up script list generation.
31 *
32 * 18 5/04/98 3:22p Samir
33 * ability to select which scripts you want to generate scriptwiz info
34 * for.
35 *
36 * 17 2/25/98 4:06p Samir
37 * Added function to generate a table of all scripts on disk.
38 *
39 * 16 1/22/98 6:22p Samir
40 * Parse script parameters now.
41 *
42 * 15 9/25/97 5:28p Samir
43 * Even newer script code due to more changes in ObjCScript.cpp
44 *
45 * 14 9/24/97 2:57p Samir
46 * New ScriptWizard functionality, without extra commenting in files.
47 *
48 * 13 9/22/97 5:59p Samir
49 * Changed ObjCScript system, so everything is broken, but it shouldn't
50 * crash the game.
51 *
52 * 12 9/12/97 4:15p Samir
53 * Upped number of mappable events.
54 *
55 * 11 9/10/97 2:00p Samir
56 * Changed prototype of AddScriptBlock
57 *
58 * 10 9/09/97 1:04p Samir
59 * Added code to create new script and save level script name.
60 *
61 * 9 9/08/97 4:29p Samir
62 * Added EVT_DESTROYED support to editing code.
63 *
64 * 8 8/21/97 6:00p Samir
65 * A whole lot of script editing stuff added for ScriptWizard.
66 *
67 * 7 8/18/97 12:14p Samir
68 * Added function to get the index of a script name in the script list.
69 *
70 * 6 8/15/97 6:32p Samir
71 * Use a more generic editor script interface instead of specifying
72 * default scripts, etc.
73 *
74 * 5 8/13/97 5:39p Samir
75 * Use CompileScript to compile a script now, and we compile default
76 * script at startup of editor.
77 *
78 * 4 8/06/97 10:40a Samir
79 * Added FreeLevelScript.
80 *
81 * 3 8/04/97 4:17p Samir
82 * Added externals for scripts in editor.
83 *
84 * $NoKeywords: $
85 */
86
87 #ifndef OBJCSCRIPT_H
88 #define OBJCSCRIPT_H
89
90 #include "pstypes.h"
91 #include "objscript.h"
92
93 #define MAX_SCRIPTS 256
94 #define MAX_SCRNAME 32
95 #define MAX_EVTNAME 32
96 #define MAX_SCRFILENAME 64
97 #define DEFAULT_SCRIPT_NAME "default.scr"
98 #define LEVEL_SCRIPT_NAME "level.scr"
99
100 #define DEFAULT_SCRIPT_MASK 0x01
101 #define CUSTOM_SCRIPT_MASK 0x02
102 #define ALL_SCRIPT_MASK 0xff
103
104 struct tD3XProgram;
105
106 #define MAX_SCRPARAMS 256 // icecoldduke fix - getting to compile, not correct.
107
108 // Data structure for a default script name.
109 // There exists a list of these names too.
110 struct tScriptName {
111 // script info.
112 char name[MAX_SCRNAME];
113 uint16_t type;
114 uint16_t line;
115 bool iscustom;
116 bool used;
117
118 // parameters
119 int nparms;
120 char *paramtypes[MAX_SCRPARAMS];
121 char *parameters[MAX_SCRPARAMS];
122
123 tScriptName() {
124 for (int i = 0; i < MAX_SCRPARAMS; i++) {
125 parameters[i] = NULL;
126 paramtypes[i] = NULL;
127 }
128 used = false;
129 nparms = 0;
130 }
131 ~tScriptName() {
132 free_parameters();
133 used = false;
134 };
135
136 void add_parameter(const char *type, const char *parm);
137 void free_parameters();
138 };
139
140 // per level script.
141 extern char Level_script_name[];
142
143 // Currently loaded script file
144 extern char *Default_script_source;
145 extern char *Level_script_source;
146
147 // Table of scripts within script file
148 extern tScriptName Script_names[];
149
150 // Script event names
151 extern char *Script_evt_names[];
152 extern uint16_t Script_evt_ids[];
153
154 bool NewScript(const char *filename);
155 char *LoadScript(const char *filename);
156 void SaveScript(const char *filename, char *script);
157 void FreeScript(char *script);
158
159 // resets script list.
160 void ResetScriptList();
161
162 // enumerates through script files.
163 char *StartScriptFileList();
164 char *GetNextScriptFile();
165 void EndScriptFileList();
166
167 // identify indices into script names array from the name.
168 int FindScriptIDFromName(const char *name);
169
170 // find event id from it's name or vice-versa
171 char *FindEventNameFromID(int id);
172 int FindEventIDFromName(const char *name);
173
174 // these functions add ScriptWizard formatting
175 char *AddScriptBlockToScript(char *script, const char *newname, const char *type_str);
176 char *AddEventBlockToScript(char *script, const char *evtname, const char *scriptname);
177
178 // generates script list from all script files.
179 void GenerateScriptListFromAllFiles(int mask = ALL_SCRIPT_MASK);
180
181 // generates script list from one file
182 void GenerateScriptListFromFile(const char *fname);
183
184 // This function generates ScriptWizard comment header information for script files
185 // if it doesn't already have it. This should be called whenever a script file is loaded and compiled
186 // via script wizard.
187 bool GenerateScriptWizardInfo(tD3XProgram *prog, bool custom);
188
189 // This function actually tries to go throught the script source to find script names.
190 // to find a script name we use the following algorithmn
191 bool GenerateScriptWizardInfo(char *script, bool custom);
192
193 // Generates a program from a script
194 bool CompileScript(tD3XProgram *program, char *script);
195 void SaveScriptCode(const char *filename, tD3XProgram *program);
196
197 #endif