1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 // ////////////////////////////////////////////////////////////////////////// //
16 function monsTypeToString (mt: Byte): AnsiString;
17 begin
18 case mt of
19 MONSTER_NONE: begin result := 'none'; exit; end;
20 MONSTER_DEMON: begin result := 'demon'; exit; end;
21 MONSTER_IMP: begin result := 'imp'; exit; end;
22 MONSTER_ZOMBY: begin result := 'zombie'; exit; end;
23 MONSTER_SERG: begin result := 'serg'; exit; end;
24 MONSTER_CYBER: begin result := 'cyber'; exit; end;
25 MONSTER_CGUN: begin result := 'cgun'; exit; end;
26 MONSTER_BARON: begin result := 'baron'; exit; end;
27 MONSTER_KNIGHT: begin result := 'knight'; exit; end;
28 MONSTER_CACO: begin result := 'caco'; exit; end;
29 MONSTER_SOUL: begin result := 'soul'; exit; end;
30 MONSTER_PAIN: begin result := 'pain'; exit; end;
31 MONSTER_SPIDER: begin result := 'spider'; exit; end;
32 MONSTER_BSP: begin result := 'bsp'; exit; end;
33 MONSTER_MANCUB: begin result := 'mancubus'; exit; end;
34 MONSTER_SKEL: begin result := 'skel'; exit; end;
35 MONSTER_VILE: begin result := 'vile'; exit; end;
36 MONSTER_FISH: begin result := 'fish'; exit; end;
37 MONSTER_BARREL: begin result := 'barrel'; exit; end;
38 MONSTER_ROBO: begin result := 'robo'; exit; end;
39 MONSTER_MAN: begin result := 'man'; exit; end;
40 end;
41 result := 'unknown';
42 end;
45 function monsBehToString (bt: Byte): AnsiString;
46 begin
47 case bt of
48 BH_NORMAL: begin result := 'normal'; exit; end;
49 BH_KILLER: begin result := 'killer'; exit; end;
50 BH_MANIAC: begin result := 'maniac'; exit; end;
51 BH_INSANE: begin result := 'insane'; exit; end;
52 BH_CANNIBAL: begin result := 'cannibal'; exit; end;
53 BH_GOOD: begin result := 'good'; exit; end;
54 end;
55 result := 'unknown';
56 end;
59 function monsStateToString (st: Byte): AnsiString;
60 begin
61 case st of
62 MONSTATE_SLEEP: begin result := 'sleep'; exit; end;
63 MONSTATE_GO: begin result := 'go'; exit; end;
64 MONSTATE_RUN: begin result := 'run'; exit; end;
65 MONSTATE_CLIMB: begin result := 'climb'; exit; end;
66 MONSTATE_DIE: begin result := 'die'; exit; end;
67 MONSTATE_DEAD: begin result := 'dead'; exit; end;
68 MONSTATE_ATTACK: begin result := 'attack'; exit; end;
69 MONSTATE_SHOOT: begin result := 'shoot'; exit; end;
70 MONSTATE_PAIN: begin result := 'pain'; exit; end;
71 MONSTATE_WAIT: begin result := 'wait'; exit; end;
72 MONSTATE_REVIVE: begin result := 'revive'; exit; end;
73 MONSTATE_RUNOUT: begin result := 'runout'; exit; end;
74 end;
75 result := 'unknown';
76 end;
79 // ////////////////////////////////////////////////////////////////////////// //
80 function typeKind2Str (t: TTypeKind): AnsiString;
81 begin
82 case t of
83 tkUnknown: result := 'Unknown';
84 tkInteger: result := 'Integer';
85 tkChar: result := 'Char';
86 tkEnumeration: result := 'Enumeration';
87 tkFloat: result := 'Float';
88 tkSet: result := 'Set';
89 tkMethod: result := 'Method';
90 tkSString: result := 'SString';
91 tkLString: result := 'LString';
92 tkAString: result := 'AString';
93 tkWString: result := 'WString';
94 tkVariant: result := 'Variant';
95 tkArray: result := 'Array';
96 tkRecord: result := 'Record';
97 tkInterface: result := 'Interface';
98 tkClass: result := 'Class';
99 tkObject: result := 'Object';
100 tkWChar: result := 'WChar';
101 tkBool: result := 'Bool';
102 tkInt64: result := 'Int64';
103 tkQWord: result := 'QWord';
104 tkDynArray: result := 'DynArray';
105 tkInterfaceRaw: result := 'InterfaceRaw';
106 tkProcVar: result := 'ProcVar';
107 tkUString: result := 'UString';
108 tkUChar: result := 'UChar';
109 tkHelper: result := 'Helper';
110 tkFile: result := 'File';
111 tkClassRef: result := 'ClassRef';
112 tkPointer: result := 'Pointer';
113 else result := '<unknown>';
114 end;
115 end;
118 procedure dumpPublishedProperties (obj: TObject);
119 var
120 pt: PTypeData;
121 pi: PTypeInfo;
122 i, j: Integer;
123 pp: PPropList;
124 begin
125 if (obj = nil) then exit;
126 e_LogWritefln('Object of type ''%s'':', [obj.ClassName]);
127 pi := obj.ClassInfo;
128 pt := GetTypeData(pi);
129 e_LogWritefln('property count: %s', [pt.PropCount]);
130 GetMem(pp, pt^.PropCount*sizeof(Pointer));
131 try
132 j := GetPropList(pi, [tkInteger, tkBool, tkSString, tkLString, tkAString, tkSet, tkEnumeration], pp);
133 //e_LogWritefln('ordinal property count: %s', [j]);
134 for i := 0 to j-1 do
135 begin
136 if (typinfo.PropType(obj, pp^[i].name) in [tkSString, tkLString, tkAString]) then
137 begin
138 e_LogWritefln(' #%s: <%s>; type: %s; value: <%s>', [i+1, pp^[i].name, typeKind2Str(typinfo.PropType(obj, pp^[i].name)), GetStrProp(obj, pp^[i])]);
139 end
140 else if (typinfo.PropType(obj, pp^[i].name) = tkSet) then
141 begin
142 e_LogWritefln(' #%s: <%s>; type: %s; value: %s', [i+1, pp^[i].name, typeKind2Str(typinfo.PropType(obj, pp^[i].name)), GetSetProp(obj, pp^[i], true)]);
143 end
144 else if (typinfo.PropType(obj, pp^[i].name) = tkEnumeration) then
145 begin
146 e_LogWritefln(' #%s: <%s>; type: %s; value: <%s>', [i+1, pp^[i].name, typeKind2Str(typinfo.PropType(obj, pp^[i].name)), GetEnumProp(obj, pp^[i])]);
147 end
148 else
149 begin
150 e_LogWritefln(' #%s: <%s>; type: %s; value: %s', [i+1, pp^[i].name, typeKind2Str(typinfo.PropType(obj, pp^[i].name)), GetOrdProp(obj, pp^[i])]);
151 end;
152 end;
153 finally
154 FreeMem(pp);
155 end;
156 end;
159 //FIXME: autogenerate
160 function trigType2Str (ttype: Integer): AnsiString;
161 begin
162 result := '<unknown>';
163 case ttype of
164 TRIGGER_NONE: result := 'none';
165 TRIGGER_EXIT: result := 'exit';
166 TRIGGER_TELEPORT: result := 'teleport';
167 TRIGGER_OPENDOOR: result := 'opendoor';
168 TRIGGER_CLOSEDOOR: result := 'closedoor';
169 TRIGGER_DOOR: result := 'door';
170 TRIGGER_DOOR5: result := 'door5';
171 TRIGGER_CLOSETRAP: result := 'closetrap';
172 TRIGGER_TRAP: result := 'trap';
173 TRIGGER_PRESS: result := 'press';
174 TRIGGER_SECRET: result := 'secret';
175 TRIGGER_LIFTUP: result := 'liftup';
176 TRIGGER_LIFTDOWN: result := 'liftdown';
177 TRIGGER_LIFT: result := 'lift';
178 TRIGGER_TEXTURE: result := 'texture';
179 TRIGGER_ON: result := 'on';
180 TRIGGER_OFF: result := 'off';
181 TRIGGER_ONOFF: result := 'onoff';
182 TRIGGER_SOUND: result := 'sound';
183 TRIGGER_SPAWNMONSTER: result := 'spawnmonster';
184 TRIGGER_SPAWNITEM: result := 'spawnitem';
185 TRIGGER_MUSIC: result := 'music';
186 TRIGGER_PUSH: result := 'push';
187 TRIGGER_SCORE: result := 'score';
188 TRIGGER_MESSAGE: result := 'message';
189 TRIGGER_DAMAGE: result := 'damage';
190 TRIGGER_HEALTH: result := 'health';
191 TRIGGER_SHOT: result := 'shot';
192 TRIGGER_EFFECT: result := 'effect';
193 TRIGGER_SCRIPT: result := 'script';
194 end;
195 end;