add ui_checkbox_check
authorChris Taylor <chris@icculus.org>
Fri, 1 Jul 2005 09:52:29 +0000 (09:52 +0000)
committerChris Taylor <chris@icculus.org>
Fri, 1 Jul 2005 09:52:29 +0000 (09:52 +0000)
ChangeLog
include/ui.h
main/editor/centers.c
main/editor/eswitch.c
main/editor/medwall.c
ui/checkbox.c

index eed3a5c..8548769 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-07-01  Chris Taylor  <chris@icculus.org>
+
+       * include/ui.h, main/editor/centers.c, main/editor/eswitch.c,
+       main/editor/medwall.c, ui/checkbox.c: add ui_checkbox_check
+
 2005-06-23  Chris Taylor  <chris@icculus.org>
 
        * installation.txt: describe new directory system
index f831cd4..abbac10 100644 (file)
@@ -295,6 +295,7 @@ extern void ui_radio_do( UI_GADGET_RADIO * radio, int keypress );
 extern void ui_draw_checkbox( UI_GADGET_CHECKBOX * checkbox );
 extern UI_GADGET_CHECKBOX * ui_add_gadget_checkbox( UI_WINDOW * wnd, short x, short y, short w, short h, short group, char * text );
 extern void ui_checkbox_do( UI_GADGET_CHECKBOX * checkbox, int keypress );
+extern void ui_checkbox_check(UI_GADGET_CHECKBOX * checkbox, sbyte check);
 
 extern UI_GADGET * ui_gadget_get_prev( UI_GADGET * gadget );
 extern UI_GADGET * ui_gadget_get_next( UI_GADGET * gadget );
index f299900..6340daf 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: centers.c,v 1.6 2005-01-24 22:05:14 schaffner Exp $ */
+/* $Id: centers.c,v 1.7 2005-07-01 09:52:29 chris Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -19,7 +19,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  */
 
 #ifdef RCS
-static char rcsid[] = "$Id: centers.c,v 1.6 2005-01-24 22:05:14 schaffner Exp $";
+static char rcsid[] = "$Id: centers.c,v 1.7 2005-07-01 09:52:29 chris Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -158,11 +158,7 @@ void do_centers_window()
                        robot_flags = RobotCenters[Curseg2p->matcen_num].robot_flags[i];
                        while (robot_flags)
                        {
-                               RobotMatFlag[i]->status = 1;    // Tells ui to redraw button
-                               if (robot_flags & 1)
-                                       RobotMatFlag[i]->flag = 1;  // Tells ui that this button is checked
-                               else
-                                       RobotMatFlag[i]->flag = 0;  // Tells ui that this button is not checked
+                               ui_checkbox_check(RobotMatFlag[i], robot_flags & 1);
                                robot_flags >>= 1;
                                robot_index++;
                        }
index 1628194..387308b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: eswitch.c,v 1.5 2005-02-26 06:25:37 chris Exp $ */
+/* $Id: eswitch.c,v 1.6 2005-07-01 09:52:29 chris Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -19,7 +19,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  */
 
 #ifdef RCS
-static char rcsid[] = "$Id: eswitch.c,v 1.5 2005-02-26 06:25:37 chris Exp $";
+static char rcsid[] = "$Id: eswitch.c,v 1.6 2005-07-01 09:52:29 chris Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -418,33 +418,22 @@ void do_trigger_window()
                trigger_num = Walls[Markedwall].trigger;
        else trigger_num = -1;
 
-       if (old_trigger_num != trigger_num ) {
-               for (   i=0; i < NUM_TRIGGER_FLAGS; i++ )       {
-                       TriggerFlag[i]->flag = 0;                               // Tells ui that this button isn't checked
-                       TriggerFlag[i]->status = 1;                             // Tells ui to redraw button
-               }
-
-               if (trigger_num != -1) {
-                       if (Triggers[trigger_num].flags & TRIGGER_CONTROL_DOORS)
-                               TriggerFlag[0]->flag = 1;
-                       if (Triggers[trigger_num].flags & TRIGGER_SHIELD_DAMAGE)
-                               TriggerFlag[1]->flag = 1;
-                       if (Triggers[trigger_num].flags & TRIGGER_ENERGY_DRAIN)
-                               TriggerFlag[2]->flag = 1;
-                       if (Triggers[trigger_num].flags & TRIGGER_EXIT)
-                               TriggerFlag[3]->flag = 1;
-                       if (Triggers[trigger_num].flags & TRIGGER_ONE_SHOT)
-                               TriggerFlag[4]->flag = 1;
-                       if (Triggers[trigger_num].flags & TRIGGER_ILLUSION_ON)
-                               TriggerFlag[5]->flag = 1;
-                       if (Triggers[trigger_num].flags & TRIGGER_ILLUSION_OFF)
-                               TriggerFlag[6]->flag = 1;
-                       if (Triggers[trigger_num].flags & TRIGGER_ON)
-                               TriggerFlag[7]->flag = 1;
-                       if (Triggers[trigger_num].flags & TRIGGER_MATCEN)
-                               TriggerFlag[8]->flag = 1;
-                       if (Triggers[trigger_num].flags & TRIGGER_SECRET_EXIT)
-                               TriggerFlag[9]->flag = 1;
+       if (old_trigger_num != trigger_num)
+       {
+               if (trigger_num != -1)
+               {
+                       trigger *trig = &Triggers[trigger_num];
+
+                       ui_checkbox_check(TriggerFlag[0], trig->flags & TRIGGER_CONTROL_DOORS);
+                       ui_checkbox_check(TriggerFlag[1], trig->flags & TRIGGER_SHIELD_DAMAGE);
+                       ui_checkbox_check(TriggerFlag[2], trig->flags & TRIGGER_ENERGY_DRAIN);
+                       ui_checkbox_check(TriggerFlag[3], trig->flags & TRIGGER_EXIT);
+                       ui_checkbox_check(TriggerFlag[4], trig->flags & TRIGGER_ONE_SHOT);
+                       ui_checkbox_check(TriggerFlag[5], trig->flags & TRIGGER_ILLUSION_ON);
+                       ui_checkbox_check(TriggerFlag[6], trig->flags & TRIGGER_ILLUSION_OFF);
+                       ui_checkbox_check(TriggerFlag[7], trig->flags & TRIGGER_ON);
+                       ui_checkbox_check(TriggerFlag[8], trig->flags & TRIGGER_MATCEN);
+                       ui_checkbox_check(TriggerFlag[9], trig->flags & TRIGGER_SECRET_EXIT);
                }
        }
        
@@ -497,12 +486,9 @@ void do_trigger_window()
                        trigger_remove_flag_from_Markedside(TRIGGER_SECRET_EXIT);
 
        } else
-               for (   i=0; i < NUM_TRIGGER_FLAGS; i++ )
-                       if (TriggerFlag[i]->flag == 1) { 
-                               TriggerFlag[i]->flag = 0;                                       // Tells ui that this button isn't checked
-                               TriggerFlag[i]->status = 1;                             // Tells ui to redraw button
-                       }
-       
+               for (i = 0; i < NUM_TRIGGER_FLAGS; i++ )
+                       ui_checkbox_check(TriggerFlag[i], 0);
+
        //------------------------------------------------------------
        // Draw the wall in the little 64x64 box
        //------------------------------------------------------------
index 806dfda..63d406c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: medwall.c,v 1.7 2005-01-25 19:36:27 schaffner Exp $ */
+/* $Id: medwall.c,v 1.8 2005-07-01 09:52:29 chris Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -19,7 +19,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  */
 
 #ifdef RCS
-static char rcsid[] = "$Id: medwall.c,v 1.7 2005-01-25 19:36:27 schaffner Exp $";
+static char rcsid[] = "$Id: medwall.c,v 1.8 2005-07-01 09:52:29 chris Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -432,7 +432,8 @@ void do_wall_window()
        // If we change walls, we need to reset the ui code for all
        // of the checkboxes that control the wall flags.  
        //------------------------------------------------------------
-       if (old_wall_num != Cursegp->sides[Curside].wall_num) {
+       if (old_wall_num != Cursegp->sides[Curside].wall_num)
+       {
                for (   i=0; i < 3; i++ )       {
                        DoorFlag[i]->flag = 0;          // Tells ui that this button isn't checked
                        DoorFlag[i]->status = 1;        // Tells ui to redraw button
@@ -442,13 +443,13 @@ void do_wall_window()
                        KeyFlag[i]->status = 1;         // Tells ui to redraw button
                }
 
-               if ( Cursegp->sides[Curside].wall_num != -1) {
-                       if (Walls[Cursegp->sides[Curside].wall_num].flags & WALL_DOOR_LOCKED)                   
-                               DoorFlag[0]->flag = 1;  // Mark this button as checked
-                       if (Walls[Cursegp->sides[Curside].wall_num].flags & WALL_DOOR_AUTO)
-                               DoorFlag[1]->flag = 1;  // Mark this button as checked
-                       if (Walls[Cursegp->sides[Curside].wall_num].flags & WALL_ILLUSION_OFF)
-                               DoorFlag[2]->flag = 1;  // Mark this button as checked
+               if ( Cursegp->sides[Curside].wall_num != -1)
+               {
+                       wall *w = &Walls[Cursegp->sides[Curside].wall_num];
+
+                       ui_checkbox_check(DoorFlag[0], w->flags & WALL_DOOR_LOCKED);
+                       ui_checkbox_check(DoorFlag[1], w->flags & WALL_DOOR_AUTO);
+                       ui_checkbox_check(DoorFlag[2], w->flags & WALL_ILLUSION_OFF);
 
                        if (Walls[Cursegp->sides[Curside].wall_num].keys & KEY_NONE)
                                KeyFlag[0]->flag = 1;
@@ -487,11 +488,8 @@ void do_wall_window()
                        }
                }
        } else {
-               for (   i=0; i < 2; i++ )       
-                       if (DoorFlag[i]->flag == 1) { 
-                               DoorFlag[i]->flag = 0;          // Tells ui that this button isn't checked
-                               DoorFlag[i]->status = 1;        // Tells ui to redraw button
-                       }
+               for (i = 0; i < 2; i++)
+                       ui_checkbox_check(DoorFlag[i], 0);
                for (   i=0; i < 4; i++ )       {
                        if ( KeyFlag[i]->flag == 1 ) {
                                KeyFlag[i]->flag = 0;           
index f9bc241..c4439f0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: checkbox.c,v 1.5 2005-02-26 09:50:36 chris Exp $ */
+/* $Id: checkbox.c,v 1.6 2005-07-01 09:52:29 chris Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -13,7 +13,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 
 #ifdef RCS
-static char rcsid[] = "$Id: checkbox.c,v 1.5 2005-02-26 09:50:36 chris Exp $";
+static char rcsid[] = "$Id: checkbox.c,v 1.6 2005-07-01 09:52:29 chris Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -129,3 +129,13 @@ void ui_checkbox_do( UI_GADGET_CHECKBOX * checkbox, int keypress )
        ui_draw_checkbox( checkbox );
 
 }
+
+void ui_checkbox_check(UI_GADGET_CHECKBOX * checkbox, sbyte check)
+{
+       check = check != 0;
+       if (checkbox->flag == check)
+               return;
+       
+       checkbox->flag = check;
+       checkbox->status = 1;   // redraw
+}