30 |
namespace display |
namespace display |
31 |
{ |
{ |
32 |
using px::V2; |
using px::V2; |
|
typedef px::Rect ScreenArea; |
|
|
typedef px::Rect WorldArea; |
|
33 |
|
|
34 |
class DisplayLayer; |
class DisplayLayer; |
35 |
class StatusBarImpl; |
class StatusBarImpl; |
36 |
|
|
37 |
struct Field { |
typedef px::Rect ScreenArea; |
38 |
Field() {layers[0] = layers[1] = layers[2] = 0;} |
typedef px::Rect WorldArea; |
|
Model* layers[3]; |
|
|
}; |
|
|
|
|
|
typedef px::Array2<Field> FieldArray; |
|
39 |
typedef std::list<Model*> ModelList; |
typedef std::list<Model*> ModelList; |
40 |
|
|
|
|
|
|
struct Field2 { |
|
|
Field2() { updatep=redrawp=false; } |
|
|
|
|
|
bool updatep; |
|
|
bool redrawp; |
|
|
}; |
|
|
typedef px::Array2<Field2> Field2Array; |
|
|
|
|
41 |
//---------------------------------------- |
//---------------------------------------- |
42 |
// Display engine |
// Display engine |
43 |
//---------------------------------------- |
//---------------------------------------- |
44 |
|
|
45 |
class DisplayEngine { |
class DisplayEngine { |
46 |
public: |
public: |
47 |
DisplayEngine (px::Screen *scr); |
DisplayEngine (px::Screen *scr, int tilew, int tileh); |
48 |
~DisplayEngine(); |
~DisplayEngine(); |
49 |
|
|
50 |
/* |
/* |
87 |
*/ |
*/ |
88 |
void mark_redraw_screen(); |
void mark_redraw_screen(); |
89 |
void mark_redraw_area (const WorldArea &wa); |
void mark_redraw_area (const WorldArea &wa); |
|
void mark_update_world(); |
|
|
void mark_update_area (const WorldArea &wa); |
|
90 |
|
|
91 |
void redraw_screen_area (const ScreenArea &a); |
void redraw_screen_area (const ScreenArea &a); |
92 |
void redraw_world_area (const WorldArea &a); |
void redraw_world_area (const WorldArea &a); |
94 |
void update_screen(); |
void update_screen(); |
95 |
void draw_all (px::GC &gc); |
void draw_all (px::GC &gc); |
96 |
|
|
|
Field2 &get_field (int x, int y) { return m_fields(x,y); } |
|
|
|
|
97 |
private: |
private: |
98 |
|
|
99 |
void draw_field (px::GC &gc, int x, int y); |
void draw_field (px::GC &gc, int x, int y); |
100 |
|
|
|
|
|
101 |
/* |
/* |
102 |
** Variables |
** Variables |
103 |
*/ |
*/ |
109 |
// Offset of screen |
// Offset of screen |
110 |
px::V2 m_offset; |
px::V2 m_offset; |
111 |
|
|
112 |
// Area on the screen |
// Screen area occupied by level display |
113 |
px::Rect m_area; |
px::Rect m_area; |
114 |
|
|
115 |
// Width and height of the world in tiles |
// Width and height of the world in tiles |
116 |
int m_width, m_height; |
int m_width, m_height; |
117 |
|
|
118 |
Field2Array m_fields; |
px::Array2<bool> m_redrawp; |
119 |
}; |
}; |
120 |
|
|
121 |
//---------------------------------------- |
//---------------------------------------- |
189 |
void new_world (int w, int h); |
void new_world (int w, int h); |
190 |
void draw (px::GC &gc, const WorldArea &a, int x, int y); |
void draw (px::GC &gc, const WorldArea &a, int x, int y); |
191 |
|
|
192 |
void mark_update (int x, int y); |
void mark_redraw (int x, int y); |
193 |
|
|
194 |
// ModelLayer interface |
// ModelLayer interface |
195 |
virtual bool is_sprite_layer() const { return false; } |
virtual bool is_sprite_layer() const { return false; } |
262 |
// Shadow layer |
// Shadow layer |
263 |
//---------------------------------------- |
//---------------------------------------- |
264 |
|
|
|
class ShadowLayer { |
|
|
public: |
|
|
virtual ~ShadowLayer() {} |
|
|
virtual void new_world(int w, int h) {} |
|
|
virtual void update (int x, int y) = 0; |
|
|
virtual void draw (px::GC &gc, int xpos, int ypos, int x, int y) = 0; |
|
|
}; |
|
|
|
|
265 |
struct StoneShadowCache; |
struct StoneShadowCache; |
266 |
|
|
267 |
class DL_Shadows : public DisplayLayer { |
class DL_Shadows : public DisplayLayer { |
269 |
DL_Shadows(DL_Grid *grid, DL_Sprites *sprites); |
DL_Shadows(DL_Grid *grid, DL_Sprites *sprites); |
270 |
~DL_Shadows(); |
~DL_Shadows(); |
271 |
|
|
|
void set_model (int x, int y, Model *m); |
|
|
|
|
272 |
void new_world(int w, int h); |
void new_world(int w, int h); |
|
void update (int x, int y); |
|
273 |
void draw (px::GC &gc, int xpos, int ypos, int x, int y); |
void draw (px::GC &gc, int xpos, int ypos, int x, int y); |
274 |
|
|
275 |
void draw (px::GC &gc, const WorldArea &a, int x, int y); |
void draw (px::GC &gc, const WorldArea &a, int x, int y); |
296 |
// px::Surface *shadow_surface; |
// px::Surface *shadow_surface; |
297 |
Uint32 shadow_ckey; // Color key |
Uint32 shadow_ckey; // Color key |
298 |
px::Surface *buffer; |
px::Surface *buffer; |
|
|
|
|
// px::Array2<bool> has_shadow; |
|
|
// px::Array2<px::Surface *> m_gridcache; |
|
299 |
}; |
}; |
300 |
|
|
301 |
//---------------------------------------- |
//---------------------------------------- |
363 |
Model *yield_model (const GridLoc &l); |
Model *yield_model (const GridLoc &l); |
364 |
|
|
365 |
void set_floor (int x, int y, Model *m); |
void set_floor (int x, int y, Model *m); |
366 |
|
void set_item (int x, int y, Model *m); |
367 |
|
void set_stone (int x, int y, Model *m); |
368 |
|
|
369 |
DisplayEngine *get_engine() const { return m_engine; } |
DisplayEngine *get_engine() const { return m_engine; } |
370 |
|
|