36 |
|
|
37 |
#include <string> |
#include <string> |
38 |
#include <vector> |
#include <vector> |
39 |
|
#include <iosfwd> |
40 |
|
|
41 |
namespace enigma |
namespace enigma |
42 |
{ |
{ |
43 |
|
|
44 |
using std::string; |
using std::string; |
45 |
using std::vector; |
using std::vector; |
|
} |
|
46 |
|
|
47 |
namespace enigma |
|
|
{ |
|
48 |
enum Direction { |
enum Direction { |
49 |
NODIR = -1, |
NODIR = -1, |
50 |
NORTH = 3, |
NORTH = 3, |
72 |
inline bool has_dir(DirectionBits db, Direction dir) { |
inline bool has_dir(DirectionBits db, Direction dir) { |
73 |
return db & to_bits(dir); |
return db & to_bits(dir); |
74 |
} |
} |
|
} |
|
75 |
|
|
76 |
namespace enigma |
|
|
{ |
|
77 |
/* |
/* |
78 |
* GridPos |
** GridPos |
79 |
*/ |
*/ |
80 |
struct GridPos { |
struct GridPos { |
81 |
int x, y; |
int x, y; |
82 |
explicit GridPos(int xx=0, int yy=0) : x(xx), y(yy) {} |
explicit GridPos(int xx=0, int yy=0) : x(xx), y(yy) {} |
128 |
|
|
129 |
GridLoc(GridLayer l,GridPos p) : pos(p), layer(l) {} |
GridLoc(GridLayer l,GridPos p) : pos(p), layer(l) {} |
130 |
}; |
}; |
|
} |
|
131 |
|
|
132 |
namespace enigma |
/* |
133 |
{ |
* Output stream for logging messages |
134 |
|
*/ |
135 |
|
extern std::ostream Log; |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
std::string GetDataPath(); |
std::string GetDataPath(); |
140 |
void SetDataPath(const std::string &p); |
void SetDataPath(const std::string &p); |
141 |
|
|
143 |
directories. The filename may include subdirectory names. |
directories. The filename may include subdirectory names. |
144 |
|
|
145 |
FindDataFile("graphics/bomb.png") |
FindDataFile("graphics/bomb.png") |
146 |
-> "/usr/local/share/enigma/graphics/bomb.png" |
-> "/usr/local/share/enigma/graphics/bomb.png" |
147 |
or "/home/user/.enigma/graphics/bomb.png" |
or "/home/user/.enigma/graphics/bomb.png" |
148 |
*/ |
*/ |
149 |
string FindDataFile(const string &filename); |
string FindDataFile(const string &filename); |
150 |
string FindDataFile(const string &path, const string &filename); |
string FindDataFile(const string &path, const string &filename); |
151 |
} |
|
152 |
|
bool FindFile (const string &fname, string &dst_fname); |
153 |
|
|
154 |
//---------------------------------------- |
//---------------------------------------- |
155 |
// Resource management |
// Resource management |
156 |
//---------------------------------------- |
//---------------------------------------- |
|
namespace enigma |
|
|
{ |
|
157 |
px::Font *GetFont(const char *name); |
px::Font *GetFont(const char *name); |
158 |
px::Font *LoadFont(const char *name); |
px::Font *LoadFont(const char *name); |
159 |
|
|
160 |
px::Surface *LoadImage(const char *name); |
px::Surface *LoadImage(const char *name); |
161 |
px::Surface *GetImage(const char *name); |
px::Surface *GetImage(const char *name); |
|
} |
|
162 |
|
|
163 |
//---------------------------------------- |
//====================================================================== |
164 |
// Level management |
// GAME STATE |
165 |
//---------------------------------------- |
//====================================================================== |
166 |
|
|
167 |
namespace enigma |
/* |
168 |
{ |
** Enigma can run its own levels but also emulate various versions of |
169 |
|
** Oxyd. All these games behave similarly, but there are also quite a |
170 |
|
** few differences in object behaviour, visual appearance, etc. The |
171 |
|
** game type is set at program startup and cannot be changed during |
172 |
|
** the game. |
173 |
|
*/ |
174 |
|
enum GameType { |
175 |
|
GAMET_ENIGMA, |
176 |
|
GAMET_OXYD1, |
177 |
|
GAMET_PEROXYD, |
178 |
|
GAMET_OXYDEXTRA, |
179 |
|
GAMET_OXYDMAGNUM |
180 |
|
}; |
181 |
|
|
182 |
|
/* |
183 |
|
** This datastructure contains information about single levels |
184 |
|
*/ |
185 |
struct LevelInfo |
struct LevelInfo |
186 |
{ |
{ |
187 |
LevelInfo(const string &fn, const string &n, const string &a, int par_time=99*60+59) |
LevelInfo(const string &fn, const string &n, const string &a, int par_time=99*60+59) |
212 |
|
|
213 |
void AddLevelPack (const char *init_file, const char *name); |
void AddLevelPack (const char *init_file, const char *name); |
214 |
|
|
215 |
extern vector<LevelPack *> enigma::LevelPacks; |
extern vector<LevelPack *> LevelPacks; |
216 |
extern unsigned enigma::CurrentLevelPack; |
extern unsigned CurrentLevelPack; |
217 |
} |
} |
218 |
|
|
219 |
//---------------------------------------- |
//---------------------------------------- |
221 |
//---------------------------------------- |
//---------------------------------------- |
222 |
namespace enigma |
namespace enigma |
223 |
{ |
{ |
224 |
extern bool ConserveLevel; |
extern bool ConserveLevel; // True: do not reset level when player dies |
225 |
extern int Difficulty; // Current difficulty level (0=easy,1=hard) |
extern int Difficulty; // Current difficulty level (0=easy,1=hard) |
226 |
|
|
227 |
void StartGame (LevelPack *lp, unsigned levelidx); |
void StartGame (LevelPack *lp, unsigned levelidx); |