00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef EGGFILE_H
00020 #define EGGFILE_H
00021
00022 #include "pandatoolbase.h"
00023
00024 #include "paletteGroups.h"
00025 #include "textureReference.h"
00026
00027 #include "filename.h"
00028 #include "namable.h"
00029 #include "typedWritable.h"
00030
00031 #include "pset.h"
00032
00033 class EggData;
00034 class TextureImage;
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 class EggFile : public TypedWritable, public Namable {
00045 public:
00046 EggFile();
00047
00048 void from_command_line(EggData *data,
00049 const Filename &source_filename,
00050 const Filename &dest_filename,
00051 const string &egg_comment);
00052
00053 void scan_textures();
00054 void get_textures(pset<TextureImage *> &result) const;
00055
00056 void pre_txa_file();
00057 void match_txa_groups(const PaletteGroups &groups);
00058 void post_txa_file();
00059
00060 const PaletteGroups &get_explicit_groups() const;
00061 PaletteGroup *get_default_group() const;
00062 const PaletteGroups &get_complete_groups() const;
00063 void clear_surprise();
00064 bool is_surprise() const;
00065
00066 void mark_stale();
00067 bool is_stale() const;
00068
00069 void build_cross_links();
00070 void apply_properties_to_source();
00071 void choose_placements();
00072
00073 bool has_data() const;
00074
00075 void update_egg();
00076 void remove_egg();
00077 bool read_egg();
00078 bool write_egg();
00079
00080 void write_description(ostream &out, int indent_level = 0) const;
00081 void write_texture_refs(ostream &out, int indent_level = 0) const;
00082
00083 private:
00084 void remove_backstage(EggGroupNode *node);
00085
00086 private:
00087 EggData *_data;
00088 Filename _current_directory;
00089 Filename _source_filename;
00090 Filename _dest_filename;
00091 string _egg_comment;
00092
00093 typedef pvector<TextureReference *> Textures;
00094 Textures _textures;
00095
00096 bool _first_txa_match;
00097 PaletteGroups _explicitly_assigned_groups;
00098 PaletteGroup *_default_group;
00099 PaletteGroups _complete_groups;
00100 bool _is_surprise;
00101 bool _is_stale;
00102
00103
00104
00105 public:
00106 static void register_with_read_factory();
00107 virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00108 virtual int complete_pointers(TypedWritable **p_list,
00109 BamReader *manager);
00110
00111 protected:
00112 static TypedWritable *make_EggFile(const FactoryParams ¶ms);
00113 void fillin(DatagramIterator &scan, BamReader *manager);
00114
00115 private:
00116
00117
00118 int _num_textures;
00119
00120 public:
00121 static TypeHandle get_class_type() {
00122 return _type_handle;
00123 }
00124 static void init_type() {
00125 TypedWritable::init_type();
00126 Namable::init_type();
00127 register_type(_type_handle, "EggFile",
00128 TypedWritable::get_class_type(),
00129 Namable::get_class_type());
00130 }
00131 virtual TypeHandle get_type() const {
00132 return get_class_type();
00133 }
00134
00135 private:
00136 static TypeHandle _type_handle;
00137 };
00138
00139 #endif
00140