1 #ifndef _HUD_RENDERER_LUA_H_
2 #define _HUD_RENDERER_LUA_H_
3 /*
4 HUD_RENDERER_LUA.H
5 
6     Copyright (C) 2009 by Jeremiah Morris and the Aleph One developers
7 
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 3 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     This license is contained in the file "COPYING",
19     which is included with this source code; it is available online at
20     http://www.gnu.org/licenses/gpl.html
21 
22     Implements HUD helper class for Lua HUD themes
23 */
24 
25 #include "HUDRenderer.h"
26 
27 struct blip_info {
28 	short mtype;
29 	short intensity;
30 	world_distance distance;
31 	angle direction;
32 };
33 typedef struct blip_info blip_info;
34 
35 enum {
36 	_mask_disabled,
37 	_mask_enabled,
38 	_mask_drawing,
39 	_mask_erasing,
40 	NUMBER_OF_LUA_MASKING_MODES
41 };
42 
43 class FontSpecifier;
44 class Image_Blitter;
45 class Shape_Blitter;
46 
47 class HUD_Lua_Class : public HUD_Class
48 {
49 public:
HUD_Lua_Class()50 	HUD_Lua_Class() : m_drawing(false) {}
~HUD_Lua_Class()51 	~HUD_Lua_Class() {}
52 
53 	void update_motion_sensor(short time_elapsed);
54 	void clear_entity_blips(void);
55 	void add_entity_blip(short mtype, short intensity, short x, short y);
56 
57 	size_t entity_blip_count(void);
58 	blip_info entity_blip(size_t index);
59 
60 	void start_draw(void);
61 	void end_draw(void);
62 	void apply_clip(void);
63 
64 	short masking_mode(void);
65 	void set_masking_mode(short masking_mode);
66 	void clear_mask(void);
67 
68 	void fill_rect(float x, float y, float w, float h,
69 								 float r, float g, float b, float a);
70 	void frame_rect(float x, float y, float w, float h,
71 								  float r, float g, float b, float a,
72 									float t);
73 	void draw_text(FontSpecifier *font, const char *text,
74 	               float x, float y,
75 								 float r, float g, float b, float a,
76                    float scale);
77 	void draw_image(Image_Blitter *image, float x, float y);
78 	void draw_shape(Shape_Blitter *shape, float x, float y);
79 
80 protected:
81 	std::vector<blip_info> m_blips;
82 	bool m_drawing;
83 	bool m_opengl;
84 	SDL_Surface *m_surface;
85 	SDL_Rect m_wr;
86 	short m_masking_mode;
87 
88 	void start_using_mask(void);
89 	void end_using_mask(void);
90 	void start_drawing_mask(bool erase);
91 	void end_drawing_mask(void);
92 
93 	void render_motion_sensor(short time_elapsed);
94 	void draw_all_entity_blips(void);
draw_or_erase_unclipped_shape(short x,short y,shape_descriptor shape,bool draw)95 	void draw_or_erase_unclipped_shape(short x, short y, shape_descriptor shape, bool draw) {}
draw_entity_blip(point2d * location,shape_descriptor shape)96 	void draw_entity_blip(point2d *location, shape_descriptor shape) {}
97 
draw_message_area(short)98 	virtual void draw_message_area(short) {}
99 
DrawShape(shape_descriptor shape,screen_rectangle * dest,screen_rectangle * src)100 	void DrawShape(shape_descriptor shape, screen_rectangle *dest, screen_rectangle *src) {}
101 	void DrawShapeAtXY(shape_descriptor shape, short x, short y, bool transparency = false) {}
DrawText(const char * text,screen_rectangle * dest,short flags,short font_id,short text_color)102 	void DrawText(const char *text, screen_rectangle *dest, short flags, short font_id, short text_color) {}
FillRect(screen_rectangle * r,short color_index)103 	void FillRect(screen_rectangle *r, short color_index) {}
FrameRect(screen_rectangle * r,short color_index)104 	void FrameRect(screen_rectangle *r, short color_index) {}
105 
DrawTexture(shape_descriptor texture,short texture_type,short x,short y,int size)106 	void DrawTexture(shape_descriptor texture, short texture_type, short x, short y, int size) {}
107 
SetClipPlane(int x,int y,int c_x,int c_y,int radius)108 	void SetClipPlane(int x, int y, int c_x, int c_y, int radius) {}
DisableClipPlane(void)109 	void DisableClipPlane(void) {}
110 };
111 
112 HUD_Lua_Class *Lua_HUDInstance();
113 void Lua_DrawHUD(short time_elapsed);
114 
115 #endif
116