1 /* -*- Mode: C++; c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil -*- 2 * 3 * Quadra, an action puzzle game 4 * Copyright (C) 1998-2000 Ludus Design 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 #ifndef _HEADER_PANE 22 #define _HEADER_PANE 23 24 #include <vector> 25 26 #include "inter.h" 27 #include "listbox.h" 28 #include "overmind.h" 29 #include "video.h" 30 #include "zone_list.h" 31 #include "net_stuff.h" 32 #include "score.h" 33 #include "notify.h" 34 35 class Multi_player; 36 class Pane_option; 37 class Canvas; 38 39 class Pane_info { 40 public: 41 Font *font2; 42 Inter *inter; 43 const int x, y, w, h; 44 Multi_player *mp; 45 Bitmap* fond; 46 Byte quel_pane; 47 Pane_info(Bitmap* bit, Font* f2, Inter* in, int j, Multi_player* pmp); 48 virtual ~Pane_info(); 49 }; 50 51 class Pane: public Zone, public Module { 52 friend class Multi_player; 53 protected: 54 Zone_list list; 55 Video_bitmap *screen; 56 bool hiden; 57 Zone *clicked; 58 const Pane_info π 59 bool draw_background,draw_bottom; 60 void hidecall(Module *m); 61 void hideexec(Module *m); 62 void set_net_pane(int i); 63 void ifdone(); 64 public: 65 Pane(const Pane_info &p, bool dback=true, bool dbottom=false); 66 virtual ~Pane(); 67 void hide(); 68 void show(); 69 virtual void hide_item(); 70 virtual void show_item(); 71 virtual void step(); 72 virtual void draw(); 73 }; 74 75 class Pane_option: public Pane, public Notifyable { 76 public: 77 Zone *player_info, *block_info, *combo_info, *select_scheme; 78 Zone *chat_window, *server, *quit; 79 Zone_text_button *player[3]; 80 Pane_option(const Pane_info &p); 81 virtual ~Pane_option(); 82 virtual void init(); 83 virtual void step(); 84 virtual void notify(); 85 }; 86 87 class Pane_singleplayer: public Pane { 88 public: 89 Zone *player[3]; 90 Pane_singleplayer(const Pane_info &p); 91 virtual void step(); 92 }; 93 94 class Pane_close: public Pane { 95 private: 96 Dword seconds; 97 Zone *clock; 98 static bool global_clock_visible; 99 bool clock_visible; 100 void update_clock(); 101 void show_clock(); 102 protected: 103 Zone *close; 104 public: 105 Pane_close(const Pane_info &p, bool dback=true, bool dbottom=false); 106 virtual ~Pane_close(); 107 virtual void step(); 108 virtual void hide_item(); 109 virtual void show_item(); 110 void allow_clock(); 111 }; 112 113 class Pane_selectscheme: public Pane_close { 114 Bitmap *bit; 115 Palette *pal; 116 Zone *level[10]; 117 Zone *debugscheme; 118 public: 119 Pane_selectscheme(const Pane_info &p); 120 virtual ~Pane_selectscheme(); 121 virtual void step(); 122 }; 123 124 class Pane_playerinfo: public Pane_close, public Notifyable { 125 Zone_text *player[MAXPLAYERS], *show_button, *auto_button; 126 int o_show_val; 127 bool auto_watch; 128 int show_quoi; 129 int tagged[4]; 130 int total0[MAXTEAMS], total1[MAXTEAMS]; 131 void add_name(Canvas *c, int i, int x2, int y2); 132 void add_total(int team, int x2, int y2); 133 int quel_stat() const; 134 void tag(int q); 135 void clear_tag(); 136 void activate_auto_watch(); 137 void deactivate_auto_watch(); 138 public: 139 Pane_playerinfo(const Pane_info &p); 140 virtual ~Pane_playerinfo(); 141 void refresh(); 142 virtual void notify(); 143 virtual void process(); 144 virtual void step(); 145 virtual void draw(); 146 void auto_watch_closed(); 147 bool auto_watch_started(); 148 }; 149 150 class Pane_server: public Pane_close { 151 class Zone_update_rate: public Zone_text_input { 152 char port_st[3]; 153 public: 154 Zone_update_rate(Inter* in, const Palette &pal, int px, int py, int pw); 155 void lost_focus(int cancel); 156 }; 157 158 Zone *drop_player, *drop_connection, *accept_player, *accept_connection; 159 Zone *test_ping, *check_ip; 160 public: 161 Pane_server(const Pane_info &p); 162 virtual ~Pane_server(); 163 virtual void step(); 164 }; 165 166 class Pane_server_drop_player: public Pane_close, public Notifyable { 167 class List_player: public Listable { 168 public: 169 Byte player; List_player(const char * s,Byte p,Font * f)170 List_player(const char *s, Byte p, Font *f): Listable(s, f) { 171 player = p; 172 } 173 }; 174 Zone_listbox *list_player; 175 Zone *b_drop; 176 int selected_player; 177 public: 178 Pane_server_drop_player(const Pane_info &p); 179 virtual ~Pane_server_drop_player(); 180 virtual void step(); 181 virtual void notify(); 182 }; 183 184 class Pane_server_drop_connection: public Pane_close, public Notifyable { 185 class List_connection: public Listable { 186 public: 187 Net_connection *c; Listable(s,f)188 List_connection(const char *s, Net_connection *p, Font *f=NULL): Listable(s, f) { 189 c = p; 190 } 191 }; 192 Zone_listbox *list_connection; 193 Zone *b_drop; 194 int selected; 195 public: 196 Pane_server_drop_connection(const Pane_info &p); 197 virtual ~Pane_server_drop_connection(); 198 virtual void step(); 199 virtual void notify(); 200 }; 201 202 class Pane_server_ping: public Pane_close, Net_callable { 203 void send_test(); 204 Dword last_frame; 205 int pingtime; 206 int moyenne, total, nombre; 207 int test_delay; 208 public: 209 Pane_server_ping(const Pane_info &p); 210 virtual ~Pane_server_ping(); 211 virtual void step(); 212 virtual void net_call(Packet *p2); 213 }; 214 215 class Pane_server_ip: public Pane_close { 216 public: 217 Pane_server_ip(const Pane_info &p); 218 }; 219 220 class Chat_interface: public Zone, public Notifyable { 221 class Zone_chat_input: public Zone_text_input { 222 Chat_interface *parent; 223 public: 224 Zone_chat_input(Chat_interface *p, const Palette &pal, Inter* in, char* s, int mlen, int px, int py, int pw); 225 virtual void lost_focus(int cancel); 226 }; 227 friend class Zone_chat_input; 228 229 class Zone_to_team: public Zone_state_text { 230 public: 231 Zone_to_team(Inter *in, int *val, int px, int py); 232 virtual void clicked(int quel); 233 }; 234 235 Zone_list list; 236 Zone_chat_input *zinput; 237 char buf[256]; 238 bool delete_screen; 239 int y_offset; 240 Video_bitmap *screen; 241 SDL_Surface* const back; 242 SDL_Rect back_clip; 243 Zone_state_text *z_from; 244 public: 245 Chat_interface(Inter *in, const Palette &pal, SDL_Surface* bit, int px, int py, int pw, int ph, Video_bitmap *scr=NULL); 246 virtual ~Chat_interface(); 247 virtual void draw(); 248 virtual void process(); 249 virtual void notify(); 250 void set_screen_offset(int o, Video_bitmap *vb); 251 }; 252 253 class Pane_scoreboard: public Pane_close, public Notifyable { 254 Zone_text_button *b_show_frag; 255 std::vector<Zone*> zlist_frag; 256 bool show_frag; 257 Score score; 258 Byte potato_team; 259 Word old_size; 260 protected: 261 Word size; 262 virtual void activate_frag(); 263 virtual void deactivate_frag(bool temp); 264 void scoreboard_invisible(); 265 public: 266 Pane_scoreboard(const Pane_info &p, bool control_button, bool dback=true, bool dbottom=false); 267 virtual ~Pane_scoreboard(); 268 virtual void step(); 269 virtual void notify(); 270 virtual void process(); 271 }; 272 273 class Pane_chat: public Pane_scoreboard { 274 Chat_interface *chat; 275 Zone *b_quit; 276 Word old_y; 277 virtual void activate_frag(); 278 virtual void deactivate_frag(bool temp); 279 public: 280 Pane_chat(const Pane_info &p); 281 virtual ~Pane_chat(); 282 virtual void step(); 283 }; 284 285 class Bloc; 286 287 class Pane_blockinfo: public Pane_close, public Notifyable { 288 Bloc *bloc[7]; 289 int px; 290 void block_info(Canvas *can, int dx); 291 int gauche, droite, old_gauche, old_droite; 292 public: 293 Pane_blockinfo(const Pane_info &p); 294 virtual ~Pane_blockinfo(); 295 virtual void draw(); 296 virtual void step(); 297 virtual void notify(); 298 void add_info(); 299 }; 300 301 class Pane_comboinfo: public Pane_close, public Notifyable { 302 void combo_info(Canvas *can, int dx); 303 int gauche, droite, old_gauche, old_droite; 304 public: 305 Pane_comboinfo(const Pane_info &p); 306 virtual ~Pane_comboinfo(); 307 virtual void step(); 308 virtual void notify(); 309 void add_info(); 310 }; 311 312 class Pane_playerstartup: public Pane_close, public Notifyable { 313 Zone_listbox *list_player; 314 Zone_state_text *list_team; 315 Zone_state_text *list_handicap; 316 Zone *b_start, *color_team; 317 int qplayer; 318 int color; 319 int handicap; 320 public: 321 Pane_playerstartup(const Pane_info &p, int q); 322 virtual ~Pane_playerstartup(); 323 virtual void notify(); 324 virtual void step(); 325 void update_player(); 326 }; 327 328 class Pane_playerjoin: public Pane_close, public Net_callable { 329 bool got_answer; 330 int qplayer; 331 Exec_ping *eping; 332 Zone_text *status; 333 public: 334 Pane_playerjoin(const Pane_info &p, int q); 335 virtual ~Pane_playerjoin(); 336 virtual void step(); 337 virtual void net_call(Packet *p2); 338 }; 339 340 class Pane_startgame: public Pane_close, public Notifyable { 341 int qplayer; 342 int num_player; 343 bool delete_zone; 344 void create_zone(); 345 public: 346 Canvas *canvas; 347 Pane_startgame(const Pane_info &p, int q, Canvas *c=NULL, int pos=-1); 348 virtual ~Pane_startgame(); 349 virtual void step(); 350 virtual void notify(); 351 }; 352 353 class Pane_pre_start: public Pane { 354 int qplayer; 355 public: 356 Pane_pre_start(const Pane_info &p, int q); 357 virtual ~Pane_pre_start(); 358 virtual void init(); 359 }; 360 361 class Watch_canvas { 362 Zone_list list; 363 bool small_watch; 364 public: 365 Canvas *c; 366 int play, x, y; 367 Watch_canvas(int player, bool s=false); 368 void stop(); 369 void start(); 370 void small_canvas(const Pane_info &pi, int tx, int ty); 371 }; 372 373 class Pane_startwatch: public Pane_startgame { 374 Watch_canvas *watch; 375 Pane_playerinfo *pinfo; 376 public: 377 bool auto_watch; 378 Pane_startwatch(const Pane_info &p, int player, Pane_playerinfo *ppinfo); 379 virtual ~Pane_startwatch(); 380 virtual void step(); 381 virtual void notify(); 382 }; 383 384 class Pane_smallwatch: public Pane_scoreboard { 385 Watch_canvas *watch[4]; 386 int compte; 387 Pane_playerinfo *pinfo; 388 public: 389 bool auto_watch; 390 Pane_smallwatch(const Pane_info &p, int tagged[], Pane_playerinfo *ppinfo); 391 virtual ~Pane_smallwatch(); 392 virtual void notify(); 393 virtual void draw(); 394 }; 395 396 #endif 397