shapegroup.h

Go to the documentation of this file.
00001 
00007 #ifndef INCL_SHAPEGROUP
00008 #define INCL_SHAPEGROUP 1
00009 
00010 /*
00011 Copyright (C) 2002 The Exult Team
00012 
00013 This program is free software; you can redistribute it and/or
00014 modify it under the terms of the GNU General Public License
00015 as published by the Free Software Foundation; either version 2
00016 of the License, or (at your option) any later version.
00017 
00018 This program is distributed in the hope that it will be useful,
00019 but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 GNU General Public License for more details.
00022 
00023 You should have received a copy of the GNU General Public License
00024 along with this program; if not, write to the Free Software
00025 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00026 */
00027 
00028 #include <vector>
00029 #include <string>
00030 
00031 class Shape_group_file;
00032 
00033 /*
00034  *  A group of shape/chunk #'s:
00035  */
00036 class Shape_group : std::vector<int>    // Not public on purpose.
00037   {
00038   std::string name;   // What this group is called.
00039   Shape_group_file *file;   // Where this comes from.
00040 public:
00041   friend class Shape_group_file;
00042   Shape_group(const char *nm, Shape_group_file *f);
00043   ~Shape_group() {  }
00044   Shape_group_file *get_file()
00045     { return file; }
00046   const char *get_name() const
00047     { return name.c_str(); }
00048   void set_name(char *nm)
00049     { name = nm; }
00050   int size()
00051     { return std::vector<int>::size(); }
00052   int& operator[](int i)
00053     { return std::vector<int>::operator[](i); }
00054   void del(int i);
00055   void swap(int i);   // Swap entries i and i+1.
00056   void add(int id);   // Add ID, checking for duplicate 1st.
00057   };
00058 
00059 /*
00060  *  This class represents the file containing groups for a given shape
00061  *  or chunks file.  It is read from the 'patch' or 'static' directory,
00062  *  and saved to the 'patch' directory.
00063  */
00064 class Shape_group_file
00065   {
00066   std::string name;   // Base filename.
00067   std::vector<Shape_group *> groups;// List of groups from the file.
00068   bool modified;      // Changed since last save.
00069 public:
00070   friend class Shape_group;
00071   Shape_group_file(const char *nm);
00072   ~Shape_group_file();
00073   int size()
00074     { return groups.size(); }
00075   Shape_group *get(int i)
00076     { return groups[i]; }
00077   void clear()      // Clears list (but doesn't delete).
00078     { groups.resize(0); }
00079   void add(Shape_group *grp)  // Add a new group.
00080     { groups.push_back(grp); modified = true; }
00081   void set(Shape_group *grp, int i)
00082     { groups[i] = grp; modified = true; }
00083   void insert(Shape_group *grp, int i)
00084     { groups.insert(groups.begin() + i, grp); modified = true; }
00085   bool is_modified()
00086     { return modified; }
00087   int find(const char *nm); // Find group with given name.
00088           // Remove and delete group.
00089   void remove(int index, bool del = true);
00090   void write();     // Write out (to 'patch' directory).
00091   };
00092 
00093 #endif

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