Przeglądaj źródła

more enhancements

David Rose 23 lat temu
rodzic
commit
b9ef189d16

+ 2 - 2
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 \

+ 1 - 0
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;
 

+ 2 - 0
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;

+ 6 - 0
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.",

+ 33 - 2
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
+    << "<a name=\"" << _basename << "\">\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.

+ 1 - 0
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;