forked from exult/exult
-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.h
162 lines (144 loc) · 4.23 KB
/
game.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* Copyright (C) 2000-2013 The Exult Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef GAME_H
#define GAME_H
#include <string>
#include <vector>
#include "hash_utils.h"
#include "exult_constants.h"
#include "palette.h"
#include "vgafile.h"
#include "singles.h"
class Game_window;
class Image_window8;
class Image_buffer8;
class Mouse;
class Configuration;
class BaseGameInfo;
class Shape_frame;
struct str_int_pair {
const char *str;
int num;
};
#define GAME_BG (Game::get_game_type() == BLACK_GATE)
#define GAME_SI (Game::get_game_type() == SERPENT_ISLE)
#define GAME_FOV (Game::get_game_type()==BLACK_GATE && Game::has_expansion())
#define GAME_SS (Game::get_game_type()==SERPENT_ISLE && Game::has_expansion())
class Game : public Game_singletons {
private:
static bool new_game_flag;
static Exult_Game game_type;
static bool expansion;
#ifndef DONT_HAVE_HASH_MAP
typedef unordered_map<const char *, int, hashstr, eqstr> shapes_map;
typedef unordered_map<const char *, str_int_pair, hashstr, eqstr> rsc_map;
#else /* !HAVE_HASH_MAP */
typedef std::map<const char *, int, ltstr> shapes_map;
typedef std::map<const char *, str_int_pair, ltstr> rsc_map;
#endif
shapes_map shapes;
rsc_map resources;
Configuration *xml; /* Shapes/resources from XML file. */
std::vector<const char *> xmlstrings;
Mouse *menu_mouse;
static std::string gametitle;
static std::string modtitle;
static unsigned int ticks;
protected:
static bool editing_flag;
int topx, topy, centerx, centery;
Vga_file menushapes;
bool jive;
public:
Game_window *gwin;
Image_window8 *win;
Image_buffer8 *ibuf;
// Palette pal;
Game();
virtual ~Game();
static void set_new_game() {
new_game_flag = true;
}
static bool is_new_game() {
return new_game_flag;
}
static bool is_editing() {
return editing_flag;
}
static Game *create_game(BaseGameInfo *mygame);
static Exult_Game get_game_type() {
return game_type;
}
static bool has_expansion() {
return expansion;
}
static const char *get_avname();
static int get_avsex();
static int get_avskin();
static void set_avname(const char *name);
static void set_avsex(int sex);
static void set_avskin(int skin);
static void clear_avname();
static void clear_avsex();
static void clear_avskin();
static std::string get_gametitle() {
return gametitle;
}
static std::string get_modtitle() {
return modtitle;
}
virtual void play_intro() = 0;
virtual void end_game(bool success) = 0;
virtual void top_menu() = 0;
virtual void show_quotes() = 0;
virtual void show_credits() = 0;
virtual bool new_game(Vga_file &shapes) = 0;
virtual int get_start_tile_x() = 0;
virtual int get_start_tile_y() = 0;
virtual void show_journey_failed() = 0;
virtual Shape_frame *get_menu_shape() = 0;
void play_flic(const char *archive, int index);
void add_shape(const char *name, int shapenum);
int get_shape(const char *name);
void add_resource(const char *name, const char *str, int num);
const str_int_pair &get_resource(const char *name);
void write_game_xml();
bool read_game_xml(const char *name1 = 0);
bool show_menu(bool skip = false);
void journey_failed_text();
void set_jive() {
jive = true;
}
void clear_jive() {
jive = false;
}
inline static unsigned int get_ticks() {
return ticks;
}
inline static void set_ticks(unsigned int t) {
ticks = t;
}
void disable_direct_gl_render();
void enable_direct_gl_render();
void non_gl_blit();
void gl_clear_win();
};
extern Game *game;
extern int wait_delay(int ms, int startcol = 0, int ncol = 0, int rotspd = 100);
extern Exult_Game exult_menu(Game_window *gwin);
#endif