Paperdoll_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 _PAPERDOLL_GUMP_H_
00020 #define _PAPERDOLL_GUMP_H_
00021 
00022 #include "Gump.h"
00023 
00024 class Heart_button;
00025 class Disk_button;
00026 class Combat_button;
00027 class Halo_button;
00028 class Cstats_button;
00029 class Combat_mode_button;
00030 
00031 //
00032 // For best viewing use Tab size = 4
00033 //
00034 
00035 class Paperdoll_gump : public Gump 
00036 {
00037 public:
00038   enum Object_type
00039   {
00040     OT_Normal = 0,
00041     OT_Single = 1,
00042     OT_Double = 2,
00043     OT_Staff = 3,
00044     OT_Bow = 4,
00045     OT_Crossbow = 5,
00046     OT_Shield = 6,
00047     OT_Helm = 7,
00048     OT_Musket = 8
00049   };
00050 
00051   // This contains info on how to render an item when it's in a certain spot
00052   struct Paperdoll_item
00053   {
00054     int     world_shape;      // Shape in the world
00055     int     world_frame;      // Frame in the world (-1 for all)
00056     int     spot;       // Spot placed in
00057 
00058     Object_type   type;       // What type of object is this
00059     
00060     bool      gender;       // Is this object gender specific
00061 
00062     ShapeFile   file;       // Which  VGA file is the shape in
00063     int     shape;        // The shape (if -1 use world shape and frame)
00064     int     frame;        // The frame
00065     int     frame2;       // Second Frame (if used)
00066     int     frame3;       // Second Frame (if used)
00067     int     frame4;       // Second Frame (if used)
00068   };
00069 
00070   // This contain Information about NPC rendering
00071   struct  Paperdoll_npc
00072   {
00073     int     npc_shape;      // Choose the NPC based on shape, not NPC number
00074     bool      is_female;      // Is the NPC Female (or more specifically not male)
00075     ShapeFile   file;       // Which VGA file the head shape is in
00076 
00077     // Body info
00078     int     body_shape;     // Body Shape
00079     int     body_frame;     // Body Frame
00080 
00081     int     head_shape;     // Head Shape
00082     int     head_frame;     // Normal Head Frame
00083     int     head_frame_helm;    // Frame when wearing a helm
00084 
00085     int     arms_shape;     // Shape for Arms
00086     int     arms_frame;     // Normal Arms Frame
00087     int     arms_frame_2h;      // Frame when holding a two handed weapon
00088     int     arms_frame_staff;   // Frame when holding staff style weapon
00089   };
00090 
00091 private:
00092   UNREPLICATABLE_CLASS(Paperdoll_gump);
00093 
00094 protected:
00095 
00096   // Statics
00097 
00098   // Serpent Isle
00099   static Paperdoll_npc Characters[];  // NPC information
00100   static Paperdoll_item Items[];    // Item Information
00101 
00102   // Black Gate (it's a hack I tell you)
00103   static Paperdoll_npc Characters_BG[]; // NPC information
00104   static Paperdoll_item Items_BG[]; // Item Information
00105 
00106   static short coords[36];    // Coords. of where to draw things,
00107   static short coords_blue[36];   // indexed by spot # (0-17).
00108   static short shapes_blue[36];
00109   static short coords_hot[36];    // Hot spots
00110     
00111   static short diskx, disky;    // Where to show 'diskette' button.
00112   static short heartx, hearty;    // Where to show 'stats' button.
00113   static short combatx, combaty;    // Combat button.
00114   static short cstatx, cstaty;    // Combat mode.
00115   static short halox, haloy;  // "Protected" halo.
00116   static short cmodex, cmodey;  // Combat mode.
00117 
00118   static short bodyx, bodyy;    // Body
00119   static short headx, heady;    // Head
00120   static short beltfx, beltfy;    // Female Belt
00121   static short neckfx, neckfy;    // Female Neck
00122   static short beltmx, beltmy;    // Male Belt
00123   static short neckmx, neckmy;    // Male Neck
00124   static short legsx, legsy;    // Legs
00125   static short feetx, feety;    // Feet
00126   static short handsx, handsy;    // Hands
00127   static short lhandx, lhandy;    // Left Hand
00128   static short rhandx, rhandy;    // Right Hand
00129   static short ahandx, ahandy;    // Ammo in Left Hand
00130   static short ammox, ammoy;    // Quiver
00131 
00132   static short backfx, backfy;    // Female Back
00133   static short backmx, backmy;    // Male Back
00134   static short back2fx, back2fy;    // Female Back Weapon
00135   static short back2mx, back2my;    // Male Back Weapon
00136   static short shieldfx, shieldfy;  // Female Back Shield
00137   static short shieldmx, shieldmy;  // Male Back Shield
00138 
00139 
00140   // Non Statics
00141 
00142   Heart_button *heart_button;   // For bringing up stats.
00143   Disk_button *disk_button;   // For bringing up 'save' box. (Avatar Only)
00144   Combat_button *combat_button;   // Combat Toggle (Avatar Only)
00145   Cstats_button *cstats_button;   // Combat Stats (Not BG)
00146   Halo_button *halo_button;   // Halo (protection) (BG Only)
00147   Combat_mode_button *cmode_button; // Combat Modes (BG Only)
00148 
00149 
00150   // Statics
00151 
00152   // Get the X and Y from a spot
00153   static int spotx(int i) { return coords[2*i]; }
00154   static int spoty(int i) { return coords[2*i + 1]; }
00155 
00156   // Non Statics
00157 
00158   // Find index of closest spot to the mouse pointer
00159   int find_closest(int mx, int my, int only_empty = 0);
00160   
00161   // Set to location of an object a spot
00162   void set_to_spot(Game_object *obj, int index);
00163 
00164 public:
00165 
00166   // Statics
00167 
00168   inline static bool IsObjectAllowed(int shape, int frame, int spot)
00169     { return GetItemInfo(shape, frame, spot)!=NULL?true:false; }
00170 
00171   inline static int GetFaceShape(int shape, int frame, int spot)
00172     { return GetItemInfo(shape, frame, spot)!=NULL?true:false; }
00173 
00174   inline static bool IsNPCFemale(int shape)
00175   { return GetCharacterInfo(shape)?GetCharacterInfoSafe(shape)->is_female:true; }
00176 
00177   // Retrieve info about an item or NPC
00178   static Paperdoll_npc *GetCharacterInfoSafe(int shape);
00179   static Paperdoll_npc *GetCharacterInfo(int shape);
00180   static Paperdoll_item *GetItemInfo(int shape, int frame = -1, int spot = -1);
00181 
00182   // Non Statics
00183 
00184   Paperdoll_gump(Container_game_object *cont, int initx, int inity, 
00185                 int shnum);
00186 
00187   ~Paperdoll_gump();
00188 
00189   // Is a given point on a button?
00190   virtual Gump_button *on_button(int mx, int my);
00191 
00192   // Find the object the mouse is over
00193   virtual Game_object *find_object(int mx, int my);
00194 
00195   // Add object.
00196   virtual int add(Game_object *obj, int mx = -1, int my = -1, 
00197       int sx = -1, int sy = -1, bool dont_check = false,
00198             bool combine = false);
00199 
00200   // Paint it and its contents.
00201   virtual void paint();
00202 
00203 
00204   //
00205   // Painting Helpers
00206   //
00207 
00208   // Generic Paint Object Method
00209   void paint_object(const Rectangle &box, Paperdoll_npc *info, int spot,
00210             int sx, int sy, int frame = 0, int itemtype = -1, int checkspot = -1, int checktype = -1);
00211 
00212   // Generic Paint Object Method for something that is armed dependant
00213   void paint_object_arms(const Rectangle &box, Paperdoll_npc *info, int spot,
00214             int sx, int sy, int start = 0, int itemtype = -1);
00215 
00216   // Special 'Constant' Paint Methods
00217   void paint_body (const Rectangle &box, Paperdoll_npc *info);
00218   void paint_belt (const Rectangle &box, Paperdoll_npc *info);
00219   void paint_head (const Rectangle &box, Paperdoll_npc *info);
00220   void paint_arms (const Rectangle &box, Paperdoll_npc *info);
00221 
00222   // What are we holding?
00223   Object_type get_arm_type (void);
00224 
00225 
00226   //
00227   // Finding Helpers
00228   //
00229 
00230   // Generic Check Object Method
00231   Game_object *check_object (int mx, int my, Paperdoll_npc *info, int spot,
00232             int sx, int sy, int frame = 0, int itemtype = -1, int checkspot = -1, int checktype = -1);
00233 
00234 
00235   // Generic Check Object Method for something that is armed dependant
00236   Game_object *check_object_arms (int mx, int my, Paperdoll_npc *info, int spot,
00237             int sx, int sy, int start = 0, int itemtype = -1);
00238 
00239   // Special 'Constant' Check Methods
00240   bool check_body (int mx, int my, Paperdoll_npc *info);
00241   bool check_belt (int mx, int my, Paperdoll_npc *info);
00242   bool check_head (int mx, int my, Paperdoll_npc *info);
00243   bool check_arms (int mx, int my, Paperdoll_npc *info);
00244 
00245   // Generic Method to check a shape
00246   bool check_shape (int px, int py, int shape, int frame, ShapeFile file);
00247 
00248   virtual Container_game_object *find_actor(int mx, int my);
00249 };
00250 
00251 #endif

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