ScummVM API documentation
cameraaction.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 NANCY_ACTION_CAMERAACTION_H
23 #define NANCY_ACTION_CAMERAACTION_H
24 
25 #include "engines/nancy/commontypes.h"
26 #include "engines/nancy/action/actionrecord.h"
27 
28 namespace Nancy {
29 namespace Action {
30 
31 // The photo album of the Nancy14 camera (AR 133): shows one picture at a time,
32 // with controls to take another, delete this one, and page back and forth. The
33 // interface art is part of the scene background, so this only draws the display
34 // area and the sprite of a control being pressed.
36 public:
38  virtual ~CameraAction() {}
39 
40  void init() override;
41 
42  void readData(Common::SeekableReadStream &stream) override;
43  void execute() override;
44  void handleInput(NancyInput &input) override;
45 
46  bool isViewportRelative() const override { return true; }
47 
48 protected:
49  Common::String getRecordTypeName() const override { return "CameraAction"; }
50 
51  // kPrevious and kNext double as Yes and No while a deletion is confirmed.
52  enum Control { kTakePicture = 0, kDelete = 1, kPrevious = 2, kNext = 3, kNumControls = 4 };
53 
54  enum Screen { kEmpty = 0, kCameraFull = 1, kViewing = 2, kConfirmDelete = 3, kDeleted = 4 };
55 
56  struct Button {
57  Common::Rect destRect; // on-screen hotspot, and where the sprite is drawn
58  Common::Rect srcRect; // pressed sprite inside the interface image
59  };
60 
61  // The control under the cursor, or -1 if there is none or it is disabled.
62  int buttonAtCursor(const Common::Point &mousePos) const;
63  bool isButtonEnabled(uint button) const;
64  void pressButton(uint button);
65 
66  // Drops any message and selects the newest picture.
67  void resetToBrowsing();
68  void showMessage(Screen screen);
69  void deleteCurrentPicture();
70  void redraw();
71 
72  // -- File data --
73  Common::Path _imageName; // 0x00 - sprite & message sheet
74  uint16 _buttonCursorType = 0; // 0x21 - cursor over an enabled control
75  Button _buttons[kNumControls]; // 0x23
76  Common::Rect _pictureRect; // 0xa3 - where a picture is displayed
77  Common::Rect _cameraFullRect; // 0xb3
78  Common::Rect _confirmDeleteRect; // 0xc3
79  Common::Rect _deletedRect; // 0xd3
80  RandomSoundBlock _buttonSound; // 0xe3
81 
82  Common::Rect _exitHotspot;
83  uint16 _exitCursorType = 0;
84  SceneChangeDescription _exitScene;
85  FlagDescription _exitFlag;
86 
87  // -- Runtime state --
89  Screen _screen = kEmpty;
90  int _pictureIndex = -1;
91  Common::Rect _messageRect; // plate currently shown, if any
92  uint32 _messageEndTime = 0;
93  int _pendingButton = -1; // pressed, not yet acted on
94  uint32 _pendingTime = 0;
95  bool _takePictureRequested = false;
96  bool _exitRequested = false;
97 };
98 
99 } // End of namespace Action
100 } // End of namespace Nancy
101 
102 #endif // NANCY_ACTION_CAMERAACTION_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: commontypes.h:179
Definition: rect.h:536
Definition: path.h:52
Definition: atari-screen.h:58
Definition: stream.h:745
Definition: input.h:41
Definition: actionrecord.h:169
Definition: commontypes.h:314
Definition: cameraaction.h:56
Definition: rect.h:144
Definition: cameraaction.h:35
Definition: commontypes.h:194
Definition: actionmanager.h:32