forked from fuzzie/unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphics.h
95 lines (70 loc) · 2.48 KB
/
graphics.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef UNITY_GRAPHICS_H
#define UNITY_GRAPHICS_H
#include "unity.h"
#include "sprite_player.h"
#include "common/rect.h"
namespace Graphics {
class Font;
}
namespace Unity {
class SpritePlayer;
struct Image {
unsigned int width;
unsigned int height;
byte *data;
};
struct MRGFile {
Common::Array<uint16> widths, heights;
Common::Array<byte *> data;
~MRGFile() {
for (unsigned int i = 0; i < data.size(); i++)
delete[] data[i];
}
};
class Graphics {
public:
Graphics(UnityEngine *engine);
~Graphics();
void init();
void setCursor(unsigned int id, bool wait);
void setBackgroundImage(Common::String filename);
void loadMRG(Common::String filename, MRGFile *mrg);
::Graphics::Font *getFont(unsigned int id) const;
void drawString(uint x, uint y, const Common::String &text, uint font) const;
uint getFontHeight(uint font) const;
uint getStringWidth(const Common::String &text, uint font) const;
void drawMRG(MRGFile *mrg, unsigned int entry, unsigned int x, unsigned int y);
void drawBackgroundImage();
void drawSprite(SpritePlayer *sprite, int x, int y, unsigned int scale = 256);
void drawBackgroundPolys(Common::Array<struct ScreenPolygon> &polys);
void renderPolygonEdge(Common::Array<Common::Point> &points, byte colour);
void fillRect(byte colour, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2);
void playMovie(Common::String filename);
protected:
void loadPalette();
void loadCursors();
void loadFonts();
void blit(byte *data, int x, int y, unsigned int width, unsigned int height, byte transparent = COLOUR_BLANK);
UnityEngine *_vm;
byte *_basePalette, *_palette;
Image _background;
Common::Array<Image> _cursors;
Common::Array<Image> _waitCursors;
Common::Array< ::Graphics::Font *> _fonts;
};
}
#endif