1 #ifndef INNOCENT_GRAPHICS_H
2 #define INNOCENT_GRAPHICS_H
6 #include "common/rect.h"
7 #include "common/singleton.h"
10 #include "innocent/types.h"
11 #include "innocent/value.h"
22 Common::Point
&operator+=(Common::Point
&p1
, const Common::Point
&p2
);
24 class Graphics
: public Common::Singleton
<Graphics
> {
28 void setEngine(Engine
*engine
);
31 * Load interface image and palette; sets the palette.
39 * Paint the interface to proper portion of the screen.
41 void paintInterface();
42 void paintAnimations();
45 void prepareInterfacePalette();
47 void push(Paintable
*p
);
48 void pop(Paintable
*p
);
49 void hookAfterRepaint(CodePointer
&p
);
51 void setBackdrop(uint16 id
);
58 void willFadein(FadeFlags f
= kFullFade
);
59 void fadeOut(FadeFlags f
= kFullFade
);
61 void say(const byte
*text
, uint16
, uint16 frames
= 50);
62 void runWhenSaid(const CodePointer
&p
);
64 uint16
ask(uint16 left
, uint16 top
, byte width
, byte height
, byte
*string
);
65 Common::Rect
paintText(uint16 left
, uint16 top
, byte colour
, byte
*string
) {
66 return paintText(left
, top
, colour
, string
, _framebuffer
.get());
68 Common::Rect
paintText(uint16 left
, uint16 top
, byte colour
, byte
*string
, Surface
*s
);
69 void paintRect(const Common::Rect
&r
, byte colour
= 235);
71 void paint(const Sprite
*sprite
, Common::Point pos
) const {
72 paint(sprite
, pos
, _framebuffer
.get());
74 void paint(const Sprite
*sprite
, uint16 left
, uint16 top
, Surface
*dest
) const {
75 paint(sprite
, Common::Point(left
, top
), dest
);
77 void paint(const Sprite
*sprite
, Common::Point pos
, Surface
*s
) const;
79 Common::Point
cursorPosition() const;
84 void setPalette(const byte
*colours
, uint start
, uint num
);
90 static byte
clampChar(byte ch
);
91 uint16
calculateLineWidth(byte
*string
) const;
92 uint16
getGlyphWidth(byte ch
) const;
93 Sprite
*getGlyph(byte ch
) const;
96 * paint a character on screen
99 uint16
paintChar(uint16 left
, uint16 top
, byte colour
, byte character
, Surface
*s
) const;
100 byte _interface
[0x3c00];
102 Resources
*_resources
;
104 std::auto_ptr
<Surface
> _backdrop
, _framebuffer
;
106 static const char _charwidths
[];
109 void clearPalette(int start
= 0, int count
= 256);
110 void fadeIn(const byte
*colours
= 0, uint start
= 0, uint num
= 256);
112 Common::List
<Paintable
*> _paintables
;
113 Common::List
<CodePointer
> _afterRepaintHooks
;
116 FadeFlags _fadeFlags
;
117 byte _interfacePalette
[0x400];
120 uint16 _speechFramesLeft
;
121 CodePointer _speechDoneCallback
;
124 #define Graf Graphics::instance()
126 } // End of namespace Innocent
128 #endif // INNOCENT_GRAPHICS_H