ScummVM API documentation
viewport.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_UI_VIEWPORT_H
23 #define NANCY_UI_VIEWPORT_H
24 
25 #include "engines/nancy/time.h"
26 #include "engines/nancy/commontypes.h"
27 #include "engines/nancy/movieplayer.h"
28 
29 #include "engines/nancy/renderobject.h"
30 
31 namespace Common {
32 class String;
33 }
34 
35 namespace Nancy {
36 
37 class Scene;
38 struct NancyInput;
39 
40 namespace UI {
41 
42 class Viewport : public RenderObject {
43 public:
44  Viewport() :
45  RenderObject(6),
46  _movementLastFrame(0),
47  _edgesMask(0),
48  _currentFrame(0),
49  _videoFormat(kLargeVideoFormat),
50  _stickyCursorPos(-1, -1),
51  _panningType(kPanNone),
52  _autoMove(false) {}
53 
54  virtual ~Viewport() { _decoder.close(); _fullFrame.free(); }
55 
56  void init() override;
57  void handleInput(NancyInput &input);
58 
59  void loadVideo(const Common::Path &filename, uint frameNr = 0, uint verticalScroll = 0, byte panningType = kPanNone, uint16 format = 2, const Common::Path &palette = Common::Path());
60 
61  void setFrame(uint frameNr);
62  void setNextFrame();
63  void setPreviousFrame();
64 
65  void setVerticalScroll(uint scroll);
66  void scrollUp(uint delta);
67  void scrollDown(uint delta);
68 
69  uint16 getFrameCount() const { return _decoder.getFrameCount(); }
70  uint16 getCurFrame() const { return _currentFrame; }
71  uint16 getCurVerticalScroll() const { return _drawSurface.getOffsetFromOwner().y; }
72  uint16 getMaxScroll() const;
73 
74  // The currently-visible scene background, in viewport-local coords. Used by
75  // puzzles that composite additively over the background (e.g. MirrorLight).
76  const Graphics::ManagedSurface &getBackground() const { return _drawSurface; }
77 
78  Common::Rect convertViewportToScreen(const Common::Rect &viewportRect) const;
79  Common::Rect convertScreenToViewport(const Common::Rect &viewportRect) const;
80 
81  void disableEdges(byte edges);
82  void enableEdges(byte edges);
83 
84 protected:
85  void setEdgesSize(uint16 upSize, uint16 downSize, uint16 leftSize, uint16 rightSize);
86 
87  Common::Rect _nonScrollZone;
88  byte _edgesMask;
89 
90  byte _movementLastFrame;
91  Time _nextMovementTime;
92 
93  byte _panningType;
94 
95  MoviePlayer _decoder;
96  uint16 _currentFrame;
97  uint16 _videoFormat;
98  Graphics::ManagedSurface _fullFrame;
99  Common::Rect _format1Bounds;
100  Common::Rect _format2Bounds;
101  Common::Point _stickyCursorPos;
102 
103  bool _autoMove;
104 };
105 
106 } // End of namespace UI
107 } // End of namespace Nancy
108 
109 #endif // NANCY_UI_VIEWPORT_H
Definition: managed_surface.h:51
Definition: viewport.h:42
Definition: time.h:30
Definition: movieplayer.h:56
Definition: rect.h:536
Definition: path.h:52
Definition: input.h:41
Definition: soundequalizerpuzzle.h:27
Definition: renderobject.h:36
Definition: algorithm.h:29
Definition: rect.h:144
Definition: actionmanager.h:32