ScummVM API documentation
grammar.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef HYPNO_GRAMMAR_H
23#define HYPNO_GRAMMAR_H
24
25#include "common/array.h"
26#include "common/hash-ptr.h"
27#include "common/hash-str.h"
28#include "common/list.h"
29#include "common/queue.h"
30#include "common/rect.h"
31#include "common/str.h"
32
33#include "video/smk_decoder.h"
34
35namespace Hypno {
36
37typedef Common::String Filename;
38typedef Common::List<Filename> Filenames;
39
41public:
42 bool loadStream(Common::SeekableReadStream *stream) override;
43
44protected:
45 uint32 getSignatureVersion(uint32 signature) const override;
46};
47
48class MVideo {
49public:
50 MVideo(Filename, Common::Point, bool, bool, bool);
51 Filename path;
52 Common::Point position;
53 bool scaled;
54 bool transparent;
55 bool loop;
56 HypnoSmackerDecoder *decoder;
57};
58
60
61enum HotspotType {
62 MakeMenu,
63 MakeHotspot
64};
65
66enum ActionType {
67 MiceAction,
68 TimerAction,
69 PaletteAction,
70 BackgroundAction,
71 HighlightAction,
72 OverlayAction,
73 EscapeAction,
74 SaveAction,
75 LoadAction,
76 LoadCheckpointAction,
77 QuitAction,
78 CutsceneAction,
79 PlayAction,
80 IntroAction,
81 AmbientAction,
82 WalNAction,
83 GlobalAction,
84 TalkAction,
85 SwapPointerAction,
86 SoundAction,
87 ChangeLevelAction
88};
89
90class Action {
91public:
92 virtual ~Action() {} // needed to make Action polymorphic
93 ActionType type;
94};
95
97
98class Hotspot;
99
103
104class Hotspot {
105public:
106 Hotspot(HotspotType type_, Common::Rect rect_ = Common::Rect(0, 0, 0, 0)) {
107 type = type_;
108 rect = rect_;
109 smenu = nullptr;
110 }
111 HotspotType type;
112 Common::String flags[3];
113 Common::Rect rect;
114 Common::String setting;
115 Filename background;
116 Frames backgroundFrames;
117 Actions actions;
118 Hotspots *smenu;
119};
120
121class Mice : public Action {
122public:
123 Mice(Filename path_, uint32 index_) {
124 type = MiceAction;
125 path = path_;
126 index = index_;
127 }
128 Filename path;
129 uint32 index;
130};
131
132class SwapPointer : public Action {
133public:
134 SwapPointer(uint32 index_) {
135 type = SwapPointerAction;
136 index = index_;
137 }
138 uint32 index;
139};
140
141class Timer : public Action {
142public:
143 Timer(uint32 delay_, Common::String flag_) {
144 type = TimerAction;
145 delay = delay_;
146 flag = flag_;
147 }
148 uint32 delay;
149 Common::String flag;
150};
151
152class Palette : public Action {
153public:
154 Palette(Filename path_) {
155 type = PaletteAction;
156 path = path_;
157 }
158 Filename path;
159};
160
161class Highlight : public Action {
162public:
163 Highlight(Common::String condition_) {
164 type = HighlightAction;
165 condition = condition_;
166 }
167 Common::String condition;
168};
169
170class Background : public Action {
171public:
172 Background(Filename path_, Common::Point origin_, Common::String condition_, Common::String flag1_, Common::String flag2_) {
173 type = BackgroundAction;
174 path = path_;
175 origin = origin_;
176 condition = condition_;
177 flag1 = flag1_;
178 flag2 = flag2_;
179 }
180 Filename path;
181 Common::Point origin;
182 Common::String condition;
183 Common::String flag1;
184 Common::String flag2;
185};
186
187class Overlay : public Action {
188public:
189 Overlay(Filename path_, Common::Point origin_, Common::String flag_) {
190 type = OverlayAction;
191 path = path_;
192 origin = origin_;
193 flag = flag_;
194 }
195 Filename path;
196 Common::Point origin;
197 Common::String flag;
198};
199
200class Escape : public Action {
201public:
202 Escape() {
203 type = EscapeAction;
204 }
205};
206
207class Save : public Action {
208public:
209 Save() {
210 type = SaveAction;
211 }
212};
213
214class Load : public Action {
215public:
216 Load() {
217 type = LoadAction;
218 }
219};
220
221class LoadCheckpoint : public Action {
222public:
224 type = LoadCheckpointAction;
225 }
226};
227
228class Quit : public Action {
229public:
230 Quit() {
231 type = QuitAction;
232 }
233};
234
235class Cutscene : public Action {
236public:
237 Cutscene(Filename path_) {
238 type = CutsceneAction;
239 path = path_;
240 }
241 Filename path;
242};
243
244class Sound : public Action {
245public:
246 Sound(Filename path_) {
247 type = SoundAction;
248 path = path_;
249 }
250 Filename path;
251};
252
253class Intro : public Action {
254public:
255 Intro(Filename path_) {
256 type = IntroAction;
257 path = path_;
258 }
259 Filename path;
260};
261
262class Play : public Action {
263public:
264 Play(Filename path_, Common::Point origin_, Common::String condition_, Common::String flag_) {
265 type = PlayAction;
266 path = path_;
267 origin = origin_;
268 condition = condition_;
269 flag = flag_;
270 }
271 Filename path;
272 Common::Point origin;
273 Common::String condition;
274 Common::String flag;
275};
276
277class Ambient : public Action {
278public:
279 Ambient(Filename path_, Common::Point origin_, Common::String flag_) {
280 type = AmbientAction;
281 path = path_;
282 origin = origin_;
283 flag = flag_;
284 fullscreen = false;
285 frameNumber = 0;
286 }
287 Filename path;
288 Common::Point origin;
289 Common::String flag;
290 uint32 frameNumber;
291 bool fullscreen;
292};
293
294class WalN : public Action {
295public:
296 WalN(Common::String wn_, Filename path_, Common::Point origin_, Common::String condition_, Common::String flag_) {
297 wn = wn_;
298 type = WalNAction;
299 path = path_;
300 origin = origin_;
301 condition = condition_;
302 flag = flag_;
303 }
305 Filename path;
306 Common::Point origin;
307 Common::String condition;
308 Common::String flag;
309};
310
311class Global : public Action {
312public:
313 Global(Common::String variable_, Common::String command_) {
314 type = GlobalAction;
315 variable = variable_;
316 command = command_;
317 }
318 Common::String variable;
319 Common::String command;
320};
321
323public:
324 Common::String command;
325 Common::String variable;
326 Filename path;
327 uint32 num;
328 Common::Point position;
329};
330
332
333class Talk : public Action {
334public:
335 Talk() {
336 type = TalkAction;
337 boxPos = Common::Point(0, 0);
338 escape = false;
339 active = true;
340 }
341
342 Talk(Talk *t) {
343 *this = *t;
344 }
345
346 TalkCommands commands;
347 bool active;
348 bool escape;
349 Common::Point introPos;
350 Filename intro;
351 Common::Point boxPos;
352 Filename background;
353 Common::Point backgroundPos;
354 Common::Rect rect;
355 Filename second;
356 Common::Point secondPos;
357};
358
359class ChangeLevel : public Action {
360public:
361 ChangeLevel(Filename level_) {
362 type = ChangeLevelAction;
363 level = level_;
364 }
365 Filename level;
366};
367
368enum LevelType {
369 TransitionLevel,
370 SceneLevel,
371 ArcadeLevel,
372 CodeLevel
373};
374
375class Level {
376public:
377 Level() {
378 type = CodeLevel;
379 musicRate = 22050;
380 playMusicDuringIntro = false;
381 musicStereo = false;
382 }
383 virtual ~Level() {} // needed to make Level polymorphic
384 LevelType type;
385 Filenames intros;
386 Filename prefix;
387 Filename levelIfWin;
388 Filename levelIfLose;
389 bool playMusicDuringIntro;
390 Filename music;
391 uint32 musicRate;
392 bool musicStereo;
393};
394
395class Scene : public Level {
396public:
397 Scene() {
398 type = SceneLevel;
399 resolution = "640x480";
400 }
401 Common::String resolution;
402 Hotspots hots;
403};
404
406public:
407 FrameInfo(uint32 start_, uint32 length_) {
408 start = start_;
409 length = length_;
410 }
411
412 uint32 lastFrame() {
413 return start + length;
414 }
415 uint32 start;
416 uint32 length;
417};
418
419enum ScriptMode {
420 Interactive = 1,
421 NonInteractive,
422};
423
425public:
426 ScriptInfo(uint32 time_, uint32 mode_, uint32 actor_, uint32 cursor_) {
427 time = time_;
428 mode = ScriptMode(mode_);
429 actor = actor_;
430 cursor = cursor_;
431 }
432 uint32 time;
433 ScriptMode mode;
434 uint32 actor;
435 uint32 cursor;
436};
437
439
440class Shoot {
441public:
442 Shoot() {
443 destroyed = false;
444 video = nullptr;
445 timesToShoot = 1;
446 pointsToShoot = 0;
447 attackWeight = 0;
448 paletteOffset = 0;
449 paletteSize = 0;
450 missedAnimation = 0;
451 objKillsCount = 0;
452 objMissesCount = 0;
453 animation = "NONE";
454 explosionAnimation = "";
455 startFrame = 0;
456 lastFrame = 1024;
457 interactionFrame = 0;
458 noEnemySound = false;
459 enemySoundRate = 22050;
460 isAnimal = false;
461 nonHostile = false;
462 playInteractionAudio = false;
463 animalSound = "";
464 jumpToTimeAfterKilled = 0;
465 warningVideoIdx = 0;
466 waitForClickAfterInteraction = 0;
467 direction = 0;
468 }
469 Common::String name;
470 Filename animation;
471 Filename startSound;
472 Common::Point position;
473 Common::Point deathPosition;
474
475
476 uint32 timesToShoot;
477 uint32 pointsToShoot;
478 uint32 attackWeight;
479
480 // Objectives
481 uint32 objKillsCount;
482 uint32 objMissesCount;
483
484 // Palette
485 uint32 paletteOffset;
486 uint32 paletteSize;
487
488 // Missed animation
489 uint32 missedAnimation;
490
491 // Sounds
492 Filename enemySound;
493 uint32 enemySoundRate;
494 Filename deathSound;
495 Filename hitSound;
496 Filename animalSound;
497
498 MVideo *video;
499 Common::List<uint32> attackFrames;
500 Common::Array<FrameInfo> bodyFrames;
501 Common::Array<FrameInfo> explosionFrames;
502 uint32 startFrame;
503 uint32 lastFrame;
504 uint32 interactionFrame;
505 Filename explosionAnimation;
506 Filename additionalVideo;
507 bool playInteractionAudio;
508 bool destroyed;
509 bool noEnemySound;
510
511 // Soldier Boyz specific
512 bool nonHostile;
513 bool isAnimal;
514 Common::String checkIfDestroyed;
515 int jumpToTimeAfterKilled;
516 char direction;
517 uint32 waitForClickAfterInteraction;
518 uint32 warningVideoIdx;
519};
520
522
524public:
525 Common::String name;
526 uint32 timestamp;
527};
528
530
532public:
533 SegmentShoots() {
534 segmentRepetition = 0;
535 }
536 ShootSequence shootSequence;
537 uint32 segmentRepetition;
538};
539
542
543enum SegmentType {
544 Straight,
545 Select3,
546 TurnLeft3,
547 Straight3,
548 TurnRight3,
549 Select2,
550 TurnLeft2,
551 TurnRight2,
552};
553
554class Segment {
555public:
556 Segment(byte type_, uint32 start_, uint32 size_) {
557 type = type_;
558 start = start_;
559 size = size_;
560 end = false;
561 }
562
563 byte type;
564 uint32 start;
565 uint32 size;
566 bool end;
567};
568
570
572public:
573 ArcadeTransition(Filename video_, Filename palette_, Filename sound_, uint32 soundRate_, uint32 time_) {
574 video = video_;
575 palette = palette_;
576 sound = sound_;
577 soundRate = soundRate_;
578 soundStereo = false;
579 loseLevel = false;
580 winLevel = false;
581 selection = false;
582 jumpToTime = 0;
583 time = time_;
584 }
585
586 Filename video;
587 Filename palette;
588 Filename sound;
589 uint32 soundRate;
590 bool soundStereo;
591 bool loseLevel;
592 bool winLevel;
593 bool selection;
594 uint32 jumpToTime;
595 uint32 time;
596};
597
599
600class ArcadeShooting : public Level {
601public:
603 type = ArcadeLevel;
604 health = 100;
605 id = 0;
606 objKillsRequired[0] = 0;
607 objKillsRequired[1] = 0;
608 objMissesAllowed[0] = 0;
609 objMissesAllowed[1] = 0;
610 mouseBox = Common::Rect(0, 0, 320, 200);
611 frameDelay = 0;
612 targetSoundRate = 0; // TODO: unused
613 shootSoundRate = 0;
614 enemySoundRate = 0;
615 hitSoundRate = 0;
616 additionalSoundRate = 0;
617 noAmmoSoundRate = 0;
618 }
619 void clear() {
620 nextLevelVideo.clear();
621 postStatsVideo.clear();
622 backgroundVideo.clear();
623 transitions.clear();
624 maskVideo.clear();
625 player.clear();
626 shoots.clear();
627 intros.clear();
628 defeatNoEnergyFirstVideo.clear();
629 defeatMissBossVideo.clear();
630 defeatNoEnergySecondVideo.clear();
631 missBoss1Video.clear();
632 missBoss2Video.clear();
633 hitBoss1Video.clear();
634 hitBoss2Video.clear();
635 beforeVideo.clear();
636 briefingVideo.clear();
637 additionalVideo.clear();
638 additionalSound.clear();
639 noAmmoSound.clear();
640 segments.clear();
641 script.clear();
642 objKillsRequired[0] = 0;
643 objKillsRequired[1] = 0;
644 objMissesAllowed[0] = 0;
645 objMissesAllowed[1] = 0;
646 mouseBox = Common::Rect(0, 0, 320, 200);
647 anchor = Common::Point(0, 0);
648 targetSoundRate = 0;
649 shootSoundRate = 0;
650 enemySoundRate = 0;
651 hitSoundRate = 0;
652 noAmmoSoundRate = 0;
653 }
654
655 uint32 id;
656 uint32 frameDelay;
657 Common::String mode;
658 Common::Rect mouseBox;
659 Common::Point anchor;
660 ArcadeTransitions transitions;
661 Segments segments;
662
663 // Objectives
664 uint32 objKillsRequired [2];
665 uint32 objMissesAllowed [2];
666
667 // Script
668 Script script;
669
670 // Videos
671 Filename nextLevelVideo;
672 Filename postStatsVideo;
673 Filename defeatNoEnergyFirstVideo;
674 Filename defeatNoEnergySecondVideo;
675 Filename defeatMissBossVideo;
676 Filename hitBoss1Video;
677 Filename missBoss1Video;
678 Filename hitBoss2Video;
679 Filename missBoss2Video;
680 Filename beforeVideo;
681 Filename additionalVideo;
682 Filename briefingVideo;
683
684 Filename backgroundVideo;
685 Filename backgroundPalette;
686 Filename maskVideo;
687 Filename player;
688 int health;
689 Shoots shoots;
690 SegmentShootsSequence shootSequence;
691
692 // Sounds
693 Filename targetSound;
694 uint32 targetSoundRate;
695 Filename shootSound;
696 uint32 shootSoundRate;
697 Filename enemySound;
698 uint32 enemySoundRate;
699 Filename hitSound;
700 uint32 hitSoundRate;
701 Filename additionalSound;
702 uint32 additionalSoundRate;
703 Filename noAmmoSound;
704 uint32 noAmmoSoundRate;
705};
706
707class Transition : public Level {
708public:
710 type = TransitionLevel;
711 nextLevel = level;
712 levelEasy = "";
713 levelHard = "";
714 frameNumber = 0;
715 frameImage = "";
716 }
717
719 type = TransitionLevel;
720 levelEasy = easy;
721 levelHard = hard;
722 frameNumber = 0;
723 frameImage = "";
724 }
725 Common::String nextLevel;
726 Common::String levelEasy;
727 Common::String levelHard;
728 Filename frameImage;
729 uint32 frameNumber;
730};
731
732class Code : public Level {
733public:
734 Code(Common::String name_) {
735 type = CodeLevel;
736 name = name_;
737 }
738 Common::String name;
739};
740
742extern Hotspots *g_parsedHots;
743extern ArcadeShooting *g_parsedArc;
744
746 public:
747 ArcadeStats() {
748 livesUsed = 0;
749 shootsFired = 0;
750 enemyHits = 0;
751 enemyTargets = 0;
752 targetsDestroyed = 0;
753 targetsMissed = 0;
754 friendliesEncountered = 0;
755 infoReceived = 0;
756 }
757 uint32 livesUsed;
758 uint32 shootsFired;
759 uint32 enemyHits;
760 uint32 enemyTargets;
761 uint32 targetsDestroyed;
762 uint32 targetsMissed;
763 uint32 friendliesEncountered;
764 uint32 infoReceived;
765};
766
767} // End of namespace Hypno
768
769#endif
770
void clear()
Definition: array.h:321
void clear()
Definition: list.h:245
Definition: stream.h:745
Definition: str.h:59
Definition: grammar.h:90
Definition: grammar.h:277
Definition: grammar.h:600
Definition: grammar.h:745
Definition: grammar.h:571
Definition: grammar.h:170
Definition: grammar.h:359
Definition: grammar.h:732
Definition: grammar.h:235
Definition: grammar.h:200
Definition: grammar.h:405
Definition: grammar.h:311
Definition: grammar.h:161
Definition: grammar.h:104
Definition: grammar.h:40
bool loadStream(Common::SeekableReadStream *stream) override
Definition: grammar.h:253
Definition: grammar.h:375
Definition: grammar.h:221
Definition: grammar.h:214
Definition: grammar.h:48
Definition: grammar.h:121
Definition: grammar.h:187
Definition: grammar.h:152
Definition: grammar.h:262
Definition: grammar.h:228
Definition: grammar.h:207
Definition: grammar.h:395
Definition: grammar.h:424
Definition: grammar.h:554
Definition: grammar.h:531
Definition: grammar.h:440
Definition: grammar.h:523
Definition: grammar.h:244
Definition: grammar.h:132
Definition: grammar.h:322
Definition: grammar.h:333
Definition: grammar.h:141
Definition: grammar.h:707
Definition: grammar.h:294
Definition: dc.h:41
Definition: smk_decoder.h:77
Definition: rect.h:144
Definition: rect.h:536