Gump.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2000 The Exult Team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifndef _GUMP_H_
00020 #define _GUMP_H_
00021 
00022 #include "exceptions.h"
00023 #include "rect.h"
00024 #include "shapeid.h"
00025 
00026 class Checkmark_button;
00027 class Container_game_object;
00028 class Game_object;
00029 class Game_window;
00030 class Gump_button;
00031 class Gump_manager;
00032 
00033 /*
00034  *  A gump contains an image of an open container from "gumps.vga".
00035  */
00036 class Gump : public ShapeID, public Paintable
00037 {
00038   UNREPLICATABLE_CLASS(Gump);
00039 
00040 protected:
00041   Gump() : ShapeID() {   };
00042   Container_game_object *container;// What this gump shows.
00043   int x, y;     // Location on screen.
00044   unsigned char shapenum;
00045   Rectangle object_area;    // Area to paint objects in, rel. to
00046           // Where the 'checkmark' goes.
00047   Checkmark_button *check_button;
00048   void set_object_area(Rectangle area, int checkx = 8, int checky = 64);
00049 public:
00050   Gump(Container_game_object *cont, int initx, int inity, int shnum,
00051                 ShapeFile shfile = SF_GUMPS_VGA);
00052           // Create centered.
00053   Gump(Container_game_object *cont, int shnum, ShapeFile shfile = SF_GUMPS_VGA);
00054   virtual ~Gump();
00055   int get_x()     // Get coords.
00056     { return x; }
00057   int get_y()
00058     { return y; }
00059   void set_pos(int newx, int newy)// Set new spot on screen.
00060     {
00061     x = newx;
00062     y = newy;
00063     }
00064   void set_pos();     // Set centered.
00065   Container_game_object *get_container()
00066     { return container; }
00067   virtual Container_game_object *find_actor(int mx, int my)
00068     { return 0; }
00069   inline Container_game_object *get_cont_or_actor(int mx, int my)
00070   {
00071     Container_game_object *ret = find_actor(mx, my);
00072     if (ret) return ret;
00073     return get_container();
00074   }
00075           // Get screen rect. of obj. in here.
00076   Rectangle get_shape_rect(Game_object *obj);
00077           // Get screen loc. of object.
00078   void get_shape_location(Game_object *obj, int& ox, int& oy);
00079           // Find obj. containing mouse point.
00080   virtual Game_object *find_object(int mx, int my);
00081   virtual Rectangle get_dirty();    // Get dirty rect. for gump+contents.
00082   virtual Game_object *get_owner();// Get object this belongs to.
00083           // Is a given point on a button?
00084   virtual Gump_button *on_button(int mx, int my);
00085           // Paint button.
00086   virtual int add(Game_object *obj, int mx = -1, int my = -1,
00087       int sx = -1, int sy = -1, bool dont_check = false,
00088             bool combine = false);
00089   virtual void remove(Game_object *obj);
00090           // Paint it and its contents.
00091   virtual void paint();
00092           // Close (and delete).
00093   virtual void close();
00094           // update the gump, if required
00095   virtual void update_gump () { }
00096           // Can be dragged with mouse
00097   virtual bool is_draggable() const { return true; }
00098           // Close on end_gump_mode
00099   virtual bool is_persistent() const { return false; }
00100   virtual bool is_modal() const { return false; }
00101           // Show the hand cursor
00102   virtual bool no_handcursor() const { return false; }
00103 
00104   virtual bool has_point(int x, int y);
00105   virtual Rectangle get_rect();
00106 
00107 };
00108 
00109 /*
00110  *  A generic gump used by generic containers:
00111  */
00112 class Container_gump : public Gump
00113 {
00114   UNREPLICATABLE_CLASS(Container_gump);
00115 
00116   void initialize(int shnum);   // Initialize object_area.
00117 
00118 public:
00119   Container_gump(Container_game_object *cont, int initx, int inity, int shnum,
00120       ShapeFile shfile = SF_GUMPS_VGA)
00121     : Gump(cont, initx, inity, shnum, shfile)
00122   {
00123     initialize(shnum);
00124   }
00125           // Create centered.
00126   Container_gump(Container_game_object *cont, int shnum, ShapeFile shfile = SF_GUMPS_VGA)
00127     : Gump(cont, shnum, shfile)
00128   {
00129     initialize(shnum);
00130   }
00131 
00132 };
00133 
00134 #endif

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