00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GAME_H
00020 #define GAME_H
00021
00022 #include <string>
00023 #include <vector>
00024
00025 #include "hash_utils.h"
00026 #include "exult_constants.h"
00027 #include "palette.h"
00028 #include "vgafile.h"
00029 #include "singles.h"
00030
00031 class Game_window;
00032 class Image_window8;
00033 class Image_buffer8;
00034 class Mouse;
00035
00036 struct str_int_pair
00037 {
00038 const char *str;
00039 int num;
00040 };
00041
00042 enum Exult_Game {
00043 NONE,
00044 BLACK_GATE,
00045 SERPENT_ISLE,
00046 EXULT_DEVEL_GAME
00047 };
00048
00049 #define GAME_BG (Game::get_game_type() == BLACK_GATE)
00050 #define GAME_SI (Game::get_game_type() == SERPENT_ISLE)
00051 #define GAME_FOV (Game::get_game_type()==BLACK_GATE && Game::has_expansion())
00052 #define GAME_SS (Game::get_game_type()==SERPENT_ISLE && Game::has_expansion())
00053
00054 class Game : public Game_singletons {
00055 private:
00056 static bool new_game_flag;
00057 static Exult_Game game_type;
00058 static bool expansion;
00059 #ifndef DONT_HAVE_HASH_MAP
00060 hash_map<const char*, int, hashstr, eqstr> shapes;
00061 hash_map<const char*, str_int_pair, hashstr, eqstr> resources;
00062 #else
00063 std::map<const char*, int, ltstr> shapes;
00064 std::map<const char*, str_int_pair, ltstr> resources;
00065 #endif
00066 Mouse *menu_mouse;
00067 static std::string gametitle;
00068 static unsigned int ticks;
00069 protected:
00070 static bool editing_flag;
00071 int topx, topy, centerx, centery;
00072 Vga_file menushapes;
00073 bool jive;
00074
00075 public:
00076 Game_window *gwin;
00077 Image_window8 *win;
00078 Image_buffer8 *ibuf;
00079
00080
00081 Game();
00082 virtual ~Game();
00083
00084 static void set_new_game() { new_game_flag = true; }
00085 static bool is_new_game() { return new_game_flag; }
00086 static bool is_editing() { return editing_flag; }
00087 static Game *create_game(Exult_Game mygame, const char *title = 0);
00088 static Exult_Game get_game_type() { return game_type; }
00089 static bool has_expansion() { return expansion; }
00090
00091 static const char *get_avname ();
00092 static int get_avsex ();
00093 static int get_avskin ();
00094 static void set_avname (char *name);
00095 static void set_avsex (int sex);
00096 static void set_avskin (int skin);
00097 static void clear_avname ();
00098 static void clear_avsex ();
00099 static void clear_avskin ();
00100
00101 static std::string get_gametitle() { return gametitle; }
00102
00103 virtual void play_intro() =0;
00104 virtual void end_game(bool success) =0;
00105 virtual void top_menu() =0;
00106 virtual void show_quotes() =0;
00107 virtual void show_credits() =0;
00108 virtual bool new_game(Vga_file &shapes) =0;
00109 virtual int get_start_tile_x() =0;
00110 virtual int get_start_tile_y() =0;
00111 virtual void show_journey_failed() = 0;
00112
00113 void play_flic(const char *archive, int index);
00114 void play_audio(const char *archive, int index);
00115 void play_midi(int track, bool repeat = false);
00116
00117 void add_shape(const char *name, int shapenum);
00118 int get_shape(const char *name);
00119 void add_resource(const char *name, const char *str, int num);
00120 str_int_pair get_resource(const char *name);
00121
00122 bool show_menu(bool skip = false);
00123 void journey_failed_text();
00124 void set_jive () {jive = true;}
00125 void clear_jive () {jive = false;}
00126
00127 inline static unsigned int get_ticks() { return ticks; }
00128 inline static void set_ticks(unsigned int t) { ticks = t; }
00129 };
00130
00131 extern Game *game;
00132 extern int wait_delay(int ms, int startcol = 0, int ncol = 0);
00133 extern Exult_Game exult_menu(Game_window *gwin);
00134
00135 #endif