Gump_manager.h

Go to the documentation of this file.
00001 /*
00002  *  Gump_manager.h - Object that manages all available gumps
00003  *
00004  *  Copyright (C) 2001-2003  The Exult Team
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #ifndef GUMP_MANAGER_INCLUDED
00022 #define GUMP_MANAGER_INCLUDED
00023 
00024 #include "singles.h"
00025 #include "mouse.h"
00026 #include "SDL_events.h"
00027 
00028 class Gump;
00029 class Game_object;
00030 class Game_window;
00031 class Modal_gump;
00032 class Paintable;
00033 
00034 class  Gump_manager : public Game_singletons
00035 {
00036   struct Gump_list
00037   {
00038     Gump    *gump;
00039     Gump_list *next;
00040 
00041     Gump_list() : gump(0), next(0) { }
00042     Gump_list(Gump *g) : gump(g), next(0) { }
00043   };
00044 
00045   Gump_list *open_gumps;
00046   int   non_persistent_count;   // So we can test for 'gump mode' quickly.
00047   int modal_gump_count;
00048   bool  right_click_close;
00049   bool  dont_pause_game;      // NEVER EVER SET THIS MANUALLY! YOU MUST CALL set_gumps_dont_pause_game
00050 public:
00051   void add_gump(Gump *gump);      // Add a single gump to screen
00052   void add_gump(Game_object *obj, int shapenum);  // Show a gump for object obj
00053 
00054   bool remove_gump(Gump *gump);     // Detatch a gump from the list
00055   bool close_gump(Gump *gump);      // Close a gump
00056   void close_all_gumps(bool pers = false);  // Close all gumps
00057 
00058   bool showing_gumps(bool no_pers = false) const; // Are gumps showing?
00059   bool gump_mode() const        // Fast check.
00060     { return non_persistent_count > 0; }
00061   bool modal_gump_mode() const // displaying a modal gump?
00062     { return modal_gump_count > 0; }
00063 
00064   Gump *find_gump(int x, int y, bool pers = true);    // Find gump x,y is in
00065   Gump *find_gump(Game_object *obj);    // Find gump that object is in
00066   Gump *find_gump(Game_object *obj, int shapenum);  // Find gump for object obj
00067 
00068   void update_gumps();
00069   void paint();
00070 
00071   bool double_clicked(int x, int y, Game_object *&obj);
00072 
00073   inline bool can_right_click_close() { return right_click_close; }
00074   inline void set_right_click_close(bool r) { right_click_close = r; }
00075 
00076   inline bool gumps_dont_pause_game() { return dont_pause_game; }
00077   void set_gumps_dont_pause_game(bool p);
00078 
00079   int okay_to_quit();
00080   int prompt_for_number(int minval, int maxval, int step, int def,
00081               Paintable *paint = 0);
00082   int do_modal_gump(Modal_gump *, Mouse::Mouse_shapes, 
00083               Paintable *paint = 0);
00084   void paint_num(int num, int x, int y);
00085 
00086   Gump_manager();
00087   ~Gump_manager() { close_all_gumps(true); }
00088 
00089  private:
00090   int handle_modal_gump_event(Modal_gump *gump, SDL_Event& event);
00091 };
00092 
00093 #endif // GUMP_MANAGER_INCLUDED

Generated on Mon Jul 9 14:42:46 2007 for ExultEngine by  doxygen 1.5.1