ScummVM API documentation
ai_area.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  * Additional copyright for this file:
8  * Copyright (C) 1995-1997 Presto Studios, Inc.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24 
25 #ifndef PEGASUS_AI_AIAREA_H
26 #define PEGASUS_AI_AIAREA_H
27 
28 #include "pegasus/input.h"
29 #include "pegasus/movie.h"
30 #include "pegasus/timers.h"
31 #include "pegasus/ai/ai_rule.h"
32 
33 namespace Common {
34  class ReadStream;
35  class WriteStream;
36 }
37 
38 /*
39 
40  The AI area is the area at the bottom of the screen. There are three areas within
41  the AI area:
42  1) the inventory/AI help area
43  2) the middle area
44  3) the biochip display area
45 
46  Area 1 is used for displaying the current inventory item. When the player changes the
47  current item, either by selecting a new one in the inventory list or by picking
48  up a new item, area 1 updates to show the new item.
49 
50  If the AI decides to give a message, the AI's head temporarily takes over area 1
51  for the duration of the message, then goes away, returning the area to the current
52  inventory item.
53 
54  Area 2 is used to display the current inventory item's state, the current biochip's
55  state, and any extra information from the AI. The contention for this area is
56  resolved as follows:
57  -- If the AI needs to use the area while giving a message in area 1, it takes over
58  area 2 for the duration of its message.
59 *** This is not true.
60  -- If the player selects a new inventory item, the inventory item's state gets
61  displayed immediately.
62  -- If the player selects a new biochip, the biochip's state info gets displayed
63  immediately.
64  -- If any auto drawing is to occur, it seizes the area as soon as the drawing is
65  to occur. For example, the mapping biochip does auto drawing every time the
66  player takes a step. The only exception to this rule is if the AI is presenting
67  a warning. When the AI seizes areas 1 and 2, it preempts all other uses.
68  Some inventory items and biochips can cause arbitrary drawing to occur in this area
69  at arbitrary times. The map biochip is one example which causes drawing when the
70  player takes a step. Another example is the poison gas canister, which flashes in
71  this area to indicate a dangerous compound.
72 
73  Area 3 is used to display the current biochip. When the player changes the current
74  biochip, either by selecting a new one from the biochip list or by picking up a
75  new one, area 3 updates to show the new item. In addition, some biochips can play
76  animation in this area.
77 
78 */
79 
80 namespace Pegasus {
81 
82 class AIArea : public Surface, public Idler, public InputHandler {
83 public:
85  ~AIArea() override;
86 
87  void writeAIRules(Common::WriteStream *stream);
88  void readAIRules(Common::ReadStream *stream);
89 
90  void initAIArea();
91 
92  void saveAIState();
93  void restoreAIState();
94 
95  void handleInput(const Input &, const Hotspot *) override;
96  void activateHotspots() override;
97  void clickInHotspot(const Input &, const Hotspot *) override;
98 
99  void setAIVolume(const uint16);
100 
101  // There are only so many legal combinations of client/area.
102  // Here is the list of supported pairs:
103  // kInventorySignature kLeftAreaSignature
104  // kInventorySignature kMiddleAreaSignature
105  // kBiochipSignature kMiddleAreaSignature
106  // kBiochipSignature kRightAreaSignature
107  // kAISignature kLeftAreaSignature
108  // Further, the kAISignature never sets a static frame time in the left area,
109  // but only plays a sequence from the AI movie.
110  void setAIAreaToTime(const LowerClientSignature, const LowerAreaSignature, const TimeValue);
111 
112  // The "Play" functions play the requested sequence synchronously.
113  void playAIAreaSequence(const LowerClientSignature, const LowerAreaSignature, const TimeValue, const TimeValue);
114 
115  // For PlayAIMovie, it is assumed that the client is the AI itself.
116  // This is used to play AI messages as well as Optical Memory video.
117  // Returns true if the movie played all the way through, false if it was interrupted.
118  bool playAIMovie(const LowerAreaSignature, const Common::Path &movieName, bool keepLastFrame, const InputBits);
119 
120  // Loop the requested sequence indefinitely.
121  void loopAIAreaSequence(const LowerClientSignature, const LowerAreaSignature, const TimeValue, const TimeValue);
122 
123  void addAIRule(AIRule *);
124 
125  // Remove and delete all rules.
126  void removeAllRules();
127 
128  void lockAIOut();
129  void unlockAI();
130  void forceAIUnlocked();
131 
132  void checkMiddleArea();
133  void checkRules();
134 
135  LowerClientSignature getMiddleAreaOwner();
136  void toggleMiddleAreaOwner();
137 
138  TimeValue getBigInfoTime();
139  void getSmallInfoSegment(TimeValue &, TimeValue &);
140 
141 protected:
142  void useIdleTime() override;
143 
144  void setLeftMovieTime(const TimeValue);
145  void setMiddleMovieTime(const LowerClientSignature, const TimeValue);
146  void setRightMovieTime(const TimeValue);
147 
148  Movie _leftAreaMovie;
149  Movie _middleAreaMovie;
150  Movie _rightAreaMovie;
151  Movie _AIMovie;
152 
153  LowerClientSignature _leftAreaOwner;
154  LowerClientSignature _middleAreaOwner;
155  LowerClientSignature _rightAreaOwner;
156 
157  TimeValue _leftInventoryTime;
158  TimeValue _middleInventoryTime;
159  TimeValue _middleBiochipTime;
160  TimeValue _rightBiochipTime;
161 
162  AIRuleList _AIRules;
163 
164  uint _lockCount;
165 };
166 
167 extern AIArea *g_AIArea;
168 
169 } // End of namespace Pegasus
170 
171 #endif
Definition: timers.h:37
Definition: stream.h:77
Definition: movie.h:40
Definition: ai_area.h:82
Definition: path.h:52
Definition: hotspot.h:85
Definition: input.h:322
Definition: algorithm.h:29
Definition: ai_rule.h:43
Definition: stream.h:385
Definition: surface.h:50
Definition: ai_rule.h:74
Definition: input.h:410
Definition: ai_action.h:33