1 //----------------------------------------------------------------------------
2 //  EDGE Data Definition File Code (Styles)
3 //----------------------------------------------------------------------------
4 //
5 //  Copyright (c) 1999-2008  The EDGE Team.
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License
9 //  as published by the Free Software Foundation; either version 2
10 //  of the License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 //
17 //----------------------------------------------------------------------------
18 
19 #ifndef __DDF_STYLE_H__
20 #define __DDF_STYLE_H__
21 
22 #include "epi/utility.h"
23 
24 #include "types.h"
25 
26 class fontdef_c;
27 class colourmap_c;
28 
29 //
30 // -AJA- 2004/11/14 Styles.ddf
31 //
32 class backgroundstyle_c
33 {
34 public:
35 	backgroundstyle_c();
36 	backgroundstyle_c(const backgroundstyle_c& rhs);
37 	~backgroundstyle_c();
38 
39 	void Default();
40 	backgroundstyle_c& operator= (const backgroundstyle_c& rhs);
41 
42 	rgbcol_t colour;
43 	percent_t translucency;
44 
45 	epi::strent_c image_name;
46 
47 	float scale;
48 	float aspect;
49 };
50 
51 class textstyle_c
52 {
53 public:
54 	textstyle_c();
55 	textstyle_c(const textstyle_c& rhs);
56 	~textstyle_c();
57 
58 	void Default();
59 	textstyle_c& operator= (const textstyle_c& rhs);
60 
61 	const colourmap_c *colmap;
62 
63 	percent_t translucency;
64 
65 	fontdef_c *font;
66 
67 	float scale;
68 	float aspect;
69 
70 	// FIXME: horizontal and vertical alignment
71 };
72 
73 class soundstyle_c
74 {
75 public:
76 	soundstyle_c();
77 	soundstyle_c(const soundstyle_c& rhs);
78 	~soundstyle_c();
79 
80 	void Default();
81 	soundstyle_c& operator= (const soundstyle_c& rhs);
82 
83 	struct sfx_s *begin;
84 	struct sfx_s *end;
85 	struct sfx_s *select;
86 	struct sfx_s *back;
87 	struct sfx_s *error;
88 	struct sfx_s *move;
89 	struct sfx_s *slider;
90 
91 };
92 
93 typedef enum
94 {
95 	SYLSP_Tiled = 0x0001,  // bg image should tile (otherwise covers whole area)
96 	SYLSP_TiledNoScale = 0x0002,  // bg image should tile (1:1 pixels)
97 }
98 style_special_e;
99 
100 class styledef_c
101 {
102 public:
103 	styledef_c();
104 	~styledef_c();
105 
106 public:
107 	void Default(void);
108 	void CopyDetail(const styledef_c &src);
109 
110 	// Member vars....
111 	epi::strent_c name;
112 
113 	backgroundstyle_c bg;
114 
115 	// the four text styles
116 	enum
117 	{
118 		T_TEXT = 0, // main text style
119 		T_ALT,      // alternative text style
120 		T_TITLE,    // title style
121 		T_HELP,     // for help messages
122 
123 		NUM_TXST
124 	};
125 
126 	textstyle_c text[NUM_TXST];
127 
128 	soundstyle_c sounds;
129 
130 	style_special_e special;
131 
132 private:
133 	// disable copy construct and assignment operator
styledef_c(styledef_c & rhs)134 	explicit styledef_c(styledef_c &rhs) { }
135 	styledef_c& operator=(styledef_c &rhs) { return *this; }
136 };
137 
138 
139 // Our styledefs container
140 class styledef_container_c : public epi::array_c
141 {
142 public:
styledef_container_c()143 	styledef_container_c() : epi::array_c(sizeof(styledef_c*)) {}
~styledef_container_c()144 	~styledef_container_c() { Clear(); }
145 
146 private:
147 	void CleanupObject(void *obj);
148 
149 public:
GetSize()150 	int GetSize() {	return array_entries; }
Insert(styledef_c * a)151 	int Insert(styledef_c *a) { return InsertObject((void*)&a); }
152 	styledef_c* operator[](int idx) { return *(styledef_c**)FetchObject(idx); }
153 
154 	// Search Functions
155 	styledef_c* Lookup(const char* refname);
156 };
157 
158 extern styledef_container_c styledefs;
159 extern styledef_c *default_style;
160 
161 bool DDF_ReadStyles(void *data, int size);
162 
163 #endif  /*__DDF_STYLE_H__*/
164 
165 //--- editor settings ---
166 // vi:ts=4:sw=4:noexpandtab
167