0x9a
[scummvm-innocent.git] / engines / innocent / graphics.h
blob8dd6460cdbf41890f9584c8fb49c81babeeb5408
1 #ifndef INNOCENT_GRAPHICS_H
2 #define INNOCENT_GRAPHICS_H
4 #include <memory>
6 #include "common/rect.h"
7 #include "common/singleton.h"
8 #include "config.h"
10 #include "innocent/types.h"
11 #include "innocent/value.h"
13 class OSystem;
15 namespace Innocent {
17 class Engine;
18 class Resources;
19 class Surface;
20 class Sprite;
22 Common::Point &operator+=(Common::Point &p1, const Common::Point &p2);
24 class Graphics : public Common::Singleton<Graphics> {
25 public:
26 Graphics() {}
28 void setEngine(Engine *engine);
30 /**
31 * Load interface image and palette; sets the palette.
33 void loadInterface();
35 void init();
36 void paint();
38 /**
39 * Paint the interface to proper portion of the screen.
41 void paintInterface();
42 void paintAnimations();
43 void paintExits();
44 void paintSpeech();
45 void prepareInterfacePalette();
47 void push(Paintable *p);
48 void pop(Paintable *p);
49 void hookAfterRepaint(CodePointer &p);
51 void setBackdrop(uint16 id);
52 void paintBackdrop();
54 enum FadeFlags {
55 kFullFade = 0,
56 kPartialFade = 1
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;
80 void showCursor();
81 void hideCursor();
83 void updateScreen();
84 void setPalette(const byte *colours, uint start, uint num);
86 private:
87 enum {
88 kLineHeight = 12
90 static byte clampChar(byte ch);
91 uint16 calculateLineWidth(byte *string) const;
92 uint16 getGlyphWidth(byte ch) const;
93 Sprite *getGlyph(byte ch) const;
95 /**
96 * paint a character on screen
97 * @returns char width
99 uint16 paintChar(uint16 left, uint16 top, byte colour, byte character, Surface *s) const;
100 byte _interface[0x3c00];
101 Engine *_engine;
102 Resources *_resources;
103 OSystem *_system;
104 std::auto_ptr<Surface> _backdrop, _framebuffer;
106 static const char _charwidths[];
108 private:
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;
115 bool _willFadein;
116 FadeFlags _fadeFlags;
117 byte _interfacePalette[0x400];
119 byte *_speech;
120 uint16 _speechFramesLeft;
121 CodePointer _speechDoneCallback;
124 #define Graf Graphics::instance()
126 } // End of namespace Innocent
128 #endif // INNOCENT_GRAPHICS_H