From b9ef189d16681e624d6b354932df8db6ccd80645 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 4 Jul 2002 20:53:18 +0000 Subject: [PATCH] more enhancements --- pandaapp/src/indexify/Sources.pp | 4 +-- pandaapp/src/indexify/indexParameters.cxx | 1 + pandaapp/src/indexify/indexParameters.h | 2 ++ pandaapp/src/indexify/indexify.cxx | 6 ++++ pandaapp/src/indexify/rollDirectory.cxx | 35 +++++++++++++++++++++-- pandaapp/src/indexify/rollDirectory.h | 1 + 6 files changed, 45 insertions(+), 4 deletions(-) diff --git a/pandaapp/src/indexify/Sources.pp b/pandaapp/src/indexify/Sources.pp index c97e90064c..484be65e6e 100644 --- a/pandaapp/src/indexify/Sources.pp +++ b/pandaapp/src/indexify/Sources.pp @@ -1,5 +1,5 @@ #begin bin_target - #define USE_FREETYPE yes + #define USE_PACKAGES freetype #define TARGET indexify #define OTHER_LIBS \ @@ -21,7 +21,7 @@ #end bin_target #begin bin_target - #define USE_FREETYPE yes + #define USE_PACKAGES freetype #define TARGET font-samples #define OTHER_LIBS \ diff --git a/pandaapp/src/indexify/indexParameters.cxx b/pandaapp/src/indexify/indexParameters.cxx index 42bffde880..12f3a4c24d 100644 --- a/pandaapp/src/indexify/indexParameters.cxx +++ b/pandaapp/src/indexify/indexParameters.cxx @@ -47,6 +47,7 @@ bool format_rose = false; bool dummy_mode = false; bool draw_frames = false; bool omit_roll_headers = false; +DSearchPath cm_search; bool omit_full_links = false; bool caption_frame_numbers = false; diff --git a/pandaapp/src/indexify/indexParameters.h b/pandaapp/src/indexify/indexParameters.h index 8fed42bc8c..3bc8e0ab9d 100644 --- a/pandaapp/src/indexify/indexParameters.h +++ b/pandaapp/src/indexify/indexParameters.h @@ -22,6 +22,7 @@ #include "pandatoolbase.h" #include "filename.h" +#include "dSearchPath.h" // Some of these constants may be modified by command-line parameters // from the user. @@ -92,6 +93,7 @@ extern bool draw_frames; // with its own little header. This also ignored the roll.cm file if // it exists. extern bool omit_roll_headers; +extern DSearchPath cm_search; // True to omit links to the full-size source images. extern bool omit_full_links; diff --git a/pandaapp/src/indexify/indexify.cxx b/pandaapp/src/indexify/indexify.cxx index 3535c56b58..631aa0ebc0 100644 --- a/pandaapp/src/indexify/indexify.cxx +++ b/pandaapp/src/indexify/indexify.cxx @@ -134,6 +134,12 @@ Indexify() { "headers defined in roll.cm files.", &Indexify::dispatch_none, &omit_roll_headers); + add_option + ("cmdir", "director", 0, + "Searches in the named directory for .cm files before searching within " + "the source archive. This option may be repeated.", + &Indexify::dispatch_search_path, NULL, &cm_search); + add_option ("omit-full", "", 0, "Omits links to the full-size images.", diff --git a/pandaapp/src/indexify/rollDirectory.cxx b/pandaapp/src/indexify/rollDirectory.cxx index 9052a94cf6..3220502e03 100644 --- a/pandaapp/src/indexify/rollDirectory.cxx +++ b/pandaapp/src/indexify/rollDirectory.cxx @@ -178,7 +178,7 @@ scan(const string &extension) { if (_photos.empty()) { nout << _dir << " contains no photos.\n"; - return false; + // This is not an error, just a notice. } return true; @@ -194,6 +194,10 @@ collect_index_images() { // Don't call this twice. nassertv(_index_images.empty()); + if (is_empty()) { + return; + } + IndexImage *index_image = new IndexImage(this, _index_images.size()); _index_images.push_back(index_image); @@ -223,6 +227,17 @@ get_newest_contributing_filename() const { return _newest_contributing_filename; } +//////////////////////////////////////////////////////////////////// +// Function: RollDirectory::is_empty +// Access: Public +// Description: Returns true if the directory is empty (has no +// photos). +//////////////////////////////////////////////////////////////////// +bool RollDirectory:: +is_empty() const { + return _photos.empty(); +} + //////////////////////////////////////////////////////////////////// // Function: RollDirectory::get_num_photos // Access: Public @@ -274,6 +289,9 @@ get_index_image(int n) const { //////////////////////////////////////////////////////////////////// bool RollDirectory:: generate_images(const Filename &archive_dir, PNMTextMaker *text_maker) { + if (is_empty()) { + return true; + } nassertr(!_index_images.empty(), false); IndexImages::iterator ii; @@ -297,11 +315,24 @@ generate_images(const Filename &archive_dir, PNMTextMaker *text_maker) { bool RollDirectory:: generate_html(ostream &root_html, const Filename &archive_dir, const Filename &roll_dir_root) { + if (is_empty()) { + return true; + } nassertr(!_index_images.empty(), false); + root_html + << "\n"; + if (!omit_roll_headers) { - Filename cm_filename(_dir, _basename); + Filename cm_filename(_basename); cm_filename.set_extension("cm"); + if (cm_search.is_empty() || !cm_filename.resolve_filename(cm_search)) { + // If the cm file isn't found along the search path specified + // via -cmdir on the command line, then look for it in the + // appropriate source directory. + cm_filename = Filename(_dir, cm_filename); + } + if (cm_filename.exists()) { // If the comment file for the roll exists, insert its contents // here instead of the generic header. diff --git a/pandaapp/src/indexify/rollDirectory.h b/pandaapp/src/indexify/rollDirectory.h index f541a7d323..9cb589a59b 100644 --- a/pandaapp/src/indexify/rollDirectory.h +++ b/pandaapp/src/indexify/rollDirectory.h @@ -46,6 +46,7 @@ public: const Filename &get_newest_contributing_filename() const; + bool is_empty() const; int get_num_photos() const; Photo *get_photo(int n) const;