1 /* ScummVM - Graphic Adventure Engine
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.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #ifndef INNOCENT_GRAPHICS_H
27 #define INNOCENT_GRAPHICS_H
31 #include "common/rect.h"
32 #include "common/singleton.h"
35 #include "innocent/types.h"
36 #include "innocent/value.h"
47 Common::Point
&operator+=(Common::Point
&p1
, const Common::Point
&p2
);
48 Common::Point
&operator-=(Common::Point
&p1
, const Common::Point
&p2
);
50 class Graphics
: public Common::Singleton
<Graphics
> {
54 void setEngine(Engine
*engine
);
57 * Load interface image and palette; sets the palette.
65 * Paint the interface to proper portion of the screen.
67 void paintInterface();
68 void paintAnimations();
71 void prepareInterfacePalette();
73 void push(Paintable
*p
);
74 void pop(Paintable
*p
);
75 void hookAfterRepaint(CodePointer
&p
);
77 void setBackdrop(uint16 id
);
84 void willFadein(FadeFlags f
= kFullFade
);
85 bool fadeOut(FadeFlags f
= kFullFade
);
87 void say(const byte
*text
, uint16
, uint16 frames
= 50);
88 void runWhenSaid(const CodePointer
&p
);
90 uint16
ask(uint16 left
, uint16 top
, byte width
, byte height
, byte
*string
);
91 Common::Rect
paintText(uint16 left
, uint16 top
, byte colour
, const byte
*string
) {
92 return paintText(left
, top
, colour
, string
, _framebuffer
.get());
95 Common::Rect
textMetrics(const byte
*string
, uint16
*lines
= 0, uint16 left
= 0, uint16 top
= 0) {
96 return paintText(left
, top
, 235, string
, 0, lines
);
98 Common::Rect
paintText(uint16 left
, uint16 top
, byte colour
, const byte
*string
, Surface
*s
, uint16
*lines
= 0, uint8 firstLineExtraIndent
= 0);
100 void paintSpeechBubbleColumn(Sprite
*top
, Sprite
*fill
, Common::Point
&point
, uint8 fill_tiles
, Surface
*dest
);
101 Common::Rect
paintSpeechInBubble(Common::Point pos
, byte colour
, const byte
*string
, Surface
*dest
);
103 void paintRect(const Common::Rect
&r
, byte colour
= 235);
107 kPaintPositionIsTop
= 1,
108 kPaintSemiTransparent
= 2
110 void paint(const Sprite
*sprite
, Common::Point pos
, int flags
= kPaintNormal
) const {
111 paint(sprite
, pos
, _framebuffer
.get(), flags
);
113 void paint(const Sprite
*sprite
, uint16 left
, uint16 top
, Surface
*dest
, int flags
= kPaintNormal
) const {
114 paint(sprite
, Common::Point(left
, top
), dest
, flags
);
116 void paint(const Sprite
*sprite
, Common::Point pos
, Surface
*s
, int flags
= kPaintNormal
) const;
118 Common::Point
cursorPosition() const;
123 void setPalette(const byte
*colours
, uint start
, uint num
);
125 /** Go fullscreen. This will hide the interface. */
132 static byte
clampChar(byte ch
);
133 uint16
calculateLineWidth(const byte
*string
) const;
134 uint16
getGlyphWidth(byte ch
) const;
135 Sprite
*getGlyph(byte ch
) const;
138 * paint a character on screen
139 * @returns char width
141 uint16
paintChar(uint16 left
, uint16 top
, byte colour
, byte character
, Surface
*s
) const;
144 Resources
*_resources
;
146 std::auto_ptr
<Surface
> _backdrop
, _framebuffer
;
148 static const char _charwidths
[];
151 void clearPalette(int start
= 0, int count
= 256);
152 void fadeIn(const byte
*colours
= 0, uint start
= 0, uint num
= 256);
154 Common::List
<Paintable
*> _paintables
;
155 Common::List
<CodePointer
> _afterRepaintHooks
;
158 FadeFlags _fadeFlags
;
159 byte _interfacePalette
[0x400];
160 byte _tintedPalette
[256];
163 uint16 _speechFramesLeft
;
164 CodePointer _speechDoneCallback
;
168 #define Graf Graphics::instance()
170 } // End of namespace Innocent
172 #endif // INNOCENT_GRAPHICS_H