Re: [AD] grabber indexing patch

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


Silly me - forgot to attach the patch
Patch really attached this time ;-)
--- grabber_orig2.c	Thu Sep 26 15:36:02 2002
+++ grabber.c	Thu Sep 26 16:47:19 2002
@@ -69,8 +69,6 @@
 static int list_proc(int, DIALOG *, int);
 static int prop_proc(int, DIALOG *, int);
 static int droplist_proc(int, DIALOG *, int);
-static int colorconv_proc(int, DIALOG *, int);
-static int sort_proc(int, DIALOG *, int);
 static int custkey_proc(int, DIALOG *, int);
 static int edit_mod_proc(int, DIALOG *, int);
 static int droplist_mod_proc(int, DIALOG *, int);
@@ -78,6 +76,9 @@
 static char *pack_getter(int, int *);
 static char *prop_getter(int, int *);
 
+static void colorconv_proc(int, int);
+static void sort_proc(int);
+
 static int loader(void);
 static int merger(void);
 static int saver(void);
@@ -101,6 +102,10 @@
 static int property_insert(void);
 static int property_change(void);
 static int new_object(void);
+static int toggle_backup(void);
+static int toggle_dither(void);
+static int toggle_sort(void);
+static int toggle_trans(void);
 
 static int add_new(int type);
 
@@ -108,6 +113,15 @@
 
 
 
+static MENU opt_menu[32] =
+{
+   { "&Backup Datafiles",           toggle_backup,    NULL, 0,          NULL  },
+   { "&Dither Images",              toggle_dither,    NULL, 0,          NULL  },
+   { "&Sort Objects",               toggle_sort,      NULL, D_SELECTED, NULL  },
+   { "Preserve &Transparency",      toggle_trans,     NULL, D_SELECTED, NULL  },
+   { NULL,                          NULL,             NULL, 0,          NULL  }
+};
+
 static MENU file_menu[32] =
 {
    { "&Load\t(ctrl+L)",             loader,           NULL,       0, NULL  },
@@ -163,6 +177,7 @@
 { 
    { "&File",                       NULL,             file_menu,  0, NULL  },
    { "&Object",                     NULL,             objc_menu,  0, NULL  },
+   { "O&ptions",                    NULL,             opt_menu,   0, NULL  },
    { "&Help",                       NULL,             help_menu,  0, NULL  },
    { NULL,                          NULL,             NULL,       0, NULL  }
 };
@@ -200,14 +215,10 @@
    { edit_mod_proc,     100,  54,   320,  8,    0,    0,    0,       0,          255,           0,       prefix_string,    NULL, NULL  },
    { d_text_proc,       20,   66,   0,    0,    0,    0,    0,       0,          0,             0,       "Password:",      NULL, NULL  },
    { edit_mod_proc,     100,  66,   320,  8,    0,    0,    0,       0,          255,           0,       password,         NULL, NULL  },
-   { d_text_proc,       200,  10,   0,    0,    0,    0,    0,       0,          0,             0,       "X-grid:",        NULL, NULL  },
-   { d_edit_proc,       264,  10,   40,   8,    0,    0,    0,       0,          4,             0,       xgrid_string,     NULL, NULL  },
-   { d_text_proc,       315,  10,   0,    0,    0,    0,    0,       0,          0,             0,       "Y-grid:",        NULL, NULL  },
-   { d_edit_proc,       379,  10,   40,   8,    0,    0,    0,       0,          4,             0,       ygrid_string,     NULL, NULL  },
-   { d_check_proc,      430,  8,    83,   13,   0,    0,    0,       0,          0,             0,       "Backups:",       NULL, NULL  },
-   { colorconv_proc,    550,  8,    75,   13,   0,    0,    0,       0,          0,             0,       "Dither:",        NULL, NULL  },
-   { sort_proc,         430,  24,   59,   13,   0,    0,    0,       D_SELECTED, 0,             1,       "Sort:",          NULL, NULL  },
-   { colorconv_proc,    502,  24,   123,  13,   0,    0,    0,       0,          0,             1,       "Transparency:",  NULL, NULL  },
+   { d_text_proc,       200,  16,   0,    0,    0,    0,    0,       0,          0,             0,       "X-grid:",        NULL, NULL  },
+   { d_edit_proc,       264,  16,   40,   8,    0,    0,    0,       0,          4,             0,       xgrid_string,     NULL, NULL  },
+   { d_text_proc,       315,  16,   0,    0,    0,    0,    0,       0,          0,             0,       "Y-grid:",        NULL, NULL  },
+   { d_edit_proc,       379,  16,   40,   8,    0,    0,    0,       0,          4,             0,       ygrid_string,     NULL, NULL  },
    { droplist_mod_proc, 430,  48,   195,  28,   0,    0,    0,       0,          0,             0,       pack_getter,      NULL, NULL  },
    { prop_proc,         260,  86,   365,  107,  0,    0,    0,       D_EXIT,     0,             0,       prop_getter,      NULL, NULL  },
    { d_keyboard_proc,   0,    0,    0,    0,    0,    0,    C('l'),  0,          0,             0,       loader,           NULL, NULL  },
@@ -253,15 +264,17 @@
 #define DLG_PASSWORD          9
 #define DLG_XGRIDSTRING       11
 #define DLG_YGRIDSTRING       13
-#define DLG_BACKUPCHECK       14
-#define DLG_DITHERCHECK       15
-#define DLG_SORTCHECK         16
-#define DLG_TRANSCHECK        17
-#define DLG_PACKLIST          18
-#define DLG_PROP              19
-#define DLG_FIRSTWHITE        20
-#define DLG_LIST              50
-#define DLG_VIEW              51
+#define DLG_PACKLIST          14
+#define DLG_PROP              15
+#define DLG_FIRSTWHITE        16
+#define DLG_LIST              46
+#define DLG_VIEW              47
+
+#define MENU_BACKUP           0
+#define MENU_DITHER           1
+#define MENU_SORT             2
+#define MENU_TRANS            3
+
 
 
 #define SELECTED_ITEM         main_dlg[DLG_LIST].d1
@@ -283,6 +296,33 @@
 
 
 
+static int toggle_backup(void)
+{
+   opt_menu[MENU_BACKUP].flags ^= D_SELECTED;
+   return D_O_K;
+}
+
+static int toggle_dither(void)
+{
+   opt_menu[MENU_DITHER].flags ^= D_SELECTED;
+   colorconv_proc(opt_menu[MENU_SORT].flags, 0);
+   return D_O_K;
+}
+
+static int toggle_sort(void)
+{
+   opt_menu[MENU_SORT].flags ^= D_SELECTED;
+   sort_proc(opt_menu[MENU_SORT].flags);
+   return D_O_K;
+}
+
+static int toggle_trans(void)
+{
+   opt_menu[MENU_TRANS].flags ^= D_SELECTED;
+   colorconv_proc(opt_menu[MENU_SORT].flags, 1);
+   return D_O_K;
+}
+
 /* updates the window title */
 static void update_title(void)
 {
@@ -1001,20 +1041,18 @@
 
 
 /* dialog procedure for setting the color conversion mode */
-static int colorconv_proc(int msg, DIALOG *d, int c)
+static void colorconv_proc(int flags, int what)
 {
    static int current[2] = {-1, -1};
-   int ret, mode, wanted[2];
-
-   ret = d_check_proc(msg, d, c);
+   int mode, wanted[2];
 
-   if (d->flags & D_SELECTED)
-      wanted[d->d2] = 1;
+   if (flags & D_SELECTED)
+      wanted[what] = 1;
    else
-      wanted[d->d2] = 0;
+      wanted[what] = 0;
 
-   if (wanted[d->d2] != current[d->d2]) {
-      current[d->d2] = wanted[d->d2];
+   if (wanted[what] != current[what]) {
+      current[what] = wanted[what];
 
       mode = (current[0] ? COLORCONV_DITHER : 0) | (current[1] ? COLORCONV_KEEP_TRANS : 0);
       if (mode)
@@ -1022,21 +1060,17 @@
       else
          set_color_conversion(COLORCONV_NONE);
    } 
-
-   return ret;
 }
 
 
 
 /* dialog procedure for toggling sort mode on and off */
-static int sort_proc(int msg, DIALOG *d, int c)
+static void sort_proc(int flags)
 {
    static int current = -1;
-   int ret, wanted;
-
-   ret = d_check_proc(msg, d, c);
-
-   if (d->flags & D_SELECTED)
+   int wanted;
+   
+   if (flags & D_SELECTED)
       wanted = 1;
    else
       wanted = 0;
@@ -1050,8 +1084,6 @@
 
       current = wanted;
    } 
-
-   return ret;
 }
 
 
@@ -1303,7 +1335,7 @@
 
    if (type == DAT_NAME) {
       check_valid_name(val);
-      if (main_dlg[DLG_SORTCHECK].flags & D_SELECTED)
+      if (opt_menu[MENU_SORT].flags & D_SELECTED)
          datedit_sort_datafile(*dat->parent);
       rebuild_list(old, TRUE);
    }
@@ -1635,16 +1667,16 @@
    datedit_set_property(&datedit_info, DAT_YGRD, ygrid_string);
 
    datedit_set_property(&datedit_info, DAT_BACK, 
-		  (main_dlg[DLG_BACKUPCHECK].flags & D_SELECTED) ? "y" : "n");
+		  (opt_menu[MENU_BACKUP].flags & D_SELECTED) ? "y" : "n");
 
    datedit_set_property(&datedit_info, DAT_DITH, 
-		  (main_dlg[DLG_DITHERCHECK].flags & D_SELECTED) ? "y" : "n");
+		  (opt_menu[MENU_DITHER].flags & D_SELECTED) ? "y" : "n");
 
    datedit_set_property(&datedit_info, DAT_TRAN, 
-		  (main_dlg[DLG_TRANSCHECK].flags & D_SELECTED) ? "y" : "n");
+		  (opt_menu[MENU_TRANS].flags & D_SELECTED) ? "y" : "n");
 
    datedit_set_property(&datedit_info, DAT_SORT, 
-		  (main_dlg[DLG_SORTCHECK].flags & D_SELECTED) ? "y" : "n");
+		  (opt_menu[MENU_SORT].flags & D_SELECTED) ? "y" : "n");
 
    sprintf(buf, "%d", main_dlg[DLG_PACKLIST].d1);
    datedit_set_property(&datedit_info, DAT_PACK, buf);
@@ -1735,24 +1767,24 @@
    retrieve_property(DLG_YGRIDSTRING, DAT_YGRD, "16");
 
    if (utolower(*get_datafile_property(&datedit_info, DAT_BACK)) == 'y')
-      main_dlg[DLG_BACKUPCHECK].flags |= D_SELECTED;
+      opt_menu[MENU_BACKUP].flags |= D_SELECTED;
    else
-      main_dlg[DLG_BACKUPCHECK].flags &= ~D_SELECTED;
+      opt_menu[MENU_BACKUP].flags &= ~D_SELECTED;
 
    if (utolower(*get_datafile_property(&datedit_info, DAT_DITH)) == 'y')
-      main_dlg[DLG_DITHERCHECK].flags |= D_SELECTED;
+      opt_menu[MENU_DITHER].flags |= D_SELECTED;
    else
-      main_dlg[DLG_DITHERCHECK].flags &= ~D_SELECTED;
+      opt_menu[MENU_DITHER].flags &= ~D_SELECTED;
 
    if (utolower(*get_datafile_property(&datedit_info, DAT_TRAN)) == 'y')
-      main_dlg[DLG_TRANSCHECK].flags |= D_SELECTED;
+      opt_menu[MENU_TRANS].flags |= D_SELECTED;
    else
-      main_dlg[DLG_TRANSCHECK].flags &= ~D_SELECTED;
+      opt_menu[MENU_TRANS].flags &= ~D_SELECTED;
 
    if (sort)
-      main_dlg[DLG_SORTCHECK].flags |= D_SELECTED;
+      opt_menu[MENU_SORT].flags |= D_SELECTED;
    else
-      main_dlg[DLG_SORTCHECK].flags &= ~D_SELECTED;
+      opt_menu[MENU_SORT].flags &= ~D_SELECTED;
 
    main_dlg[DLG_PACKLIST].d1 = atoi(get_datafile_property(&datedit_info, DAT_PACK));
    pack_getter(-1, &items_num);
@@ -1832,8 +1864,8 @@
       main_dlg[DLG_FILENAME].d2 = strlen(data_file);
 
       update_info();
-
-      if (!datedit_save_datafile(datafile, data_file, strip, NULL, -1, -1, TRUE, FALSE, (main_dlg[DLG_BACKUPCHECK].flags & D_SELECTED), password))
+   
+      if (!datedit_save_datafile(datafile, data_file, strip, NULL, -1, -1, TRUE, FALSE, (opt_menu[MENU_BACKUP].flags & D_SELECTED), password))
 	 err = TRUE;
       else
 	 set_modified(FALSE);
@@ -2814,7 +2846,7 @@
 	    df = dat->parent;
 
 	 *df = datedit_insert(*df, NULL, prop_value_string, type, v, size);
-	 if (main_dlg[DLG_SORTCHECK].flags & D_SELECTED)
+	 if (opt_menu[MENU_SORT].flags & D_SELECTED)
 	    datedit_sort_datafile(*df);
 	 rebuild_list(v, TRUE);
 	 select_property(DAT_NAME);
@@ -3269,12 +3301,9 @@
       main_dlg[DLG_YGRIDSTRING-1].x -= 64;
       main_dlg[DLG_YGRIDSTRING].x -= 104;
 
-      main_dlg[DLG_BACKUPCHECK].x = main_dlg[DLG_BACKUPCHECK].x * SCREEN_W / 640;
-      main_dlg[DLG_BACKUPCHECK].y += 20;
-
-      main_dlg[DLG_DITHERCHECK].flags |= (D_HIDDEN | D_DISABLED);
-      main_dlg[DLG_TRANSCHECK].flags |= (D_HIDDEN | D_DISABLED);
-      main_dlg[DLG_SORTCHECK].flags |= (D_HIDDEN | D_DISABLED);
+      opt_menu[MENU_DITHER].flags |= (D_HIDDEN | D_DISABLED);
+      opt_menu[MENU_TRANS].flags |= (D_HIDDEN | D_DISABLED);
+      opt_menu[MENU_SORT].flags |= (D_HIDDEN | D_DISABLED);
 
       main_dlg[DLG_PACKLIST].x = main_dlg[DLG_PACKLIST].x * SCREEN_W / 640;
       main_dlg[DLG_PACKLIST].w = main_dlg[DLG_PACKLIST].w * SCREEN_W / 640;
@@ -3299,7 +3328,7 @@
       while (main_dlg[DLG_LIST].y + main_dlg[DLG_LIST].h >= SCREEN_H)
 	 main_dlg[DLG_LIST].h -= 8;
 
-      for (i=DLG_BACKUPCHECK; main_dlg[i].proc; i++) {
+      for (i=DLG_PACKLIST; main_dlg[i].proc; i++) {
 	 if (i != DLG_LIST)
 	    main_dlg[i].x = main_dlg[i].x * SCREEN_W / 640;
 	 main_dlg[i].w = main_dlg[i].w * SCREEN_W / 640;
@@ -3393,24 +3422,24 @@
       sprintf(ygrid_string, "%d", get_config_int("grabber", "ygrid", 16));
 
       if (strpbrk(get_config_string("grabber", "backups", ""), "yY1"))
-         main_dlg[DLG_BACKUPCHECK].flags |= D_SELECTED;
+         opt_menu[MENU_BACKUP].flags |= D_SELECTED;
       else
-         main_dlg[DLG_BACKUPCHECK].flags &= ~D_SELECTED;
+         opt_menu[MENU_BACKUP].flags &= ~D_SELECTED;
 
       if (strpbrk(get_config_string("grabber", "dither", ""), "yY1"))
-         main_dlg[DLG_DITHERCHECK].flags |= D_SELECTED;
+         opt_menu[MENU_DITHER].flags |= D_SELECTED;
       else
-         main_dlg[DLG_DITHERCHECK].flags &= ~D_SELECTED;
+         opt_menu[MENU_DITHER].flags &= ~D_SELECTED;
 
       if (strpbrk(get_config_string("grabber", "sort", ""), "yY1"))
-         main_dlg[DLG_SORTCHECK].flags |= D_SELECTED;
+         opt_menu[MENU_SORT].flags |= D_SELECTED;
       else
-         main_dlg[DLG_SORTCHECK].flags &= ~D_SELECTED;
+         opt_menu[MENU_SORT].flags &= ~D_SELECTED;
 
       if (strpbrk(get_config_string("grabber", "transparency", ""), "yY1"))
-         main_dlg[DLG_TRANSCHECK].flags |= D_SELECTED;
+         opt_menu[MENU_TRANS].flags |= D_SELECTED;
       else
-         main_dlg[DLG_TRANSCHECK].flags &= ~D_SELECTED;
+         opt_menu[MENU_TRANS].flags &= ~D_SELECTED;
    }
 
    do_dialog(main_dlg, DLG_LIST);
@@ -3430,22 +3459,22 @@
    set_config_string("grabber", "xgrid", xgrid_string);
    set_config_string("grabber", "ygrid", ygrid_string);
 
-   if (main_dlg[DLG_BACKUPCHECK].flags & D_SELECTED)
+   if (opt_menu[MENU_BACKUP].flags & D_SELECTED)
       set_config_string("grabber", "backups", "y");
    else
       set_config_string("grabber", "backups", "n");
 
-   if (main_dlg[DLG_DITHERCHECK].flags & D_SELECTED)
+   if (opt_menu[MENU_DITHER].flags & D_SELECTED)
       set_config_string("grabber", "dither", "y");
    else
       set_config_string("grabber", "dither", "n");
 
-   if (main_dlg[DLG_SORTCHECK].flags & D_SELECTED)
+   if (opt_menu[MENU_SORT].flags & D_SELECTED)
       set_config_string("grabber", "sort", "y");
    else
       set_config_string("grabber", "sort", "n");
 
-   if (main_dlg[DLG_TRANSCHECK].flags & D_SELECTED)
+   if (opt_menu[MENU_TRANS].flags & D_SELECTED)
       set_config_string("grabber", "transparency", "y");
    else
       set_config_string("grabber", "transparency", "n");


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