[AD] Grabber addition: Update selection

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hi!

Here is a patch to allow the grabber to update only part of a loaded
DATAFILE. This is useful (for me at least) when several graphics come from
a single file, and most of them are being autocropped after that.
When you change a single sprite, all are then updated, which forces me to
re-autocrop those (not such a big deal, ok), and it takes some time for
large DATAFILEs.

Also, do you think this would be useful:
When autocropping a sprite, add a XCRP, YCRP that would hold the DX and DY
that was removed from left and top of sprite respectively.  This would be
useful to know what deltas to add when drawing the sprite so it stays at
the same location on the screen.
Update the XPOS, YPOS, XSIZ, YSIZ would break if the new sprite was larger,
so I think new vars are necessary here.
I am not sure this modification would be useful to someone else than me, so
I thought I'd ask...

-- 
Vincent Penquerc'h
Windows NT - Nuke That !

--- grabber.c.old	Tue Feb 15 17:31:12 2000
+++ grabber.c	Tue Feb 15 17:42:00 2000
@@ -77,6 +77,7 @@
 static int saver(void);
 static int strip_saver(void);
 static int updater(void);
+static int sel_updater(void);
 static int force_updater(void);
 static int reader(void);
 static int viewer(void);
@@ -108,6 +109,7 @@
    { "Save S&tripped",              strip_saver,      NULL,       0, NULL  },
    { "&Merge",                      merger,           NULL,       0, NULL  },
    { "&Update\t(ctrl+U)",           updater,          NULL,       0, NULL  },
+   { "Update s&election",           sel_updater,      NULL,       0, NULL  },
    { "&Force Update",               force_updater,    NULL,       0, NULL  },
    { "",                            NULL,             NULL,       0, NULL  },
    { "&Read Bitmap\t(ctrl+R)",      reader,           NULL,       0, NULL  },
@@ -1839,6 +1841,47 @@
 }
 
 
+
+/* handle the update_selection command */
+static int sel_updater()
+{
+   int c;
+   int nowhere;
+   int err = FALSE;
+
+   CHECK_MENU_HOOK("Update selection", DATEDIT_MENU_FILE);
+
+   box_start();
+
+   set_mouse_sprite(my_busy_pointer);
+   busy_mouse = TRUE;
+
+   for (c=1; c<data_count; c++) {
+      if ((c==SELECTED_ITEM) || data_sel[c]) {
+         if (data[c].dat->type != DAT_FILE) {
+	    if (!datedit_update(data[c].dat, FALSE, &nowhere)) {
+	       err = TRUE;
+	       break;
+	    }
+	    datedit_sort_properties(data[c].dat->prop);
+         }
+      }
+   }
+
+   set_mouse_sprite(my_mouse_pointer);
+   busy_mouse = FALSE;
+
+   if (!err) {
+      box_out("Done!");
+      box_eol();
+   }
+
+   box_end(!err);
+
+   select_property(DAT_NAME);
+
+   return D_REDRAW;
+}
 
 /* handle the force_update command */
 static int force_updater()


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/