home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2611 / panel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-23  |  3.3 KB  |  186 lines

  1. #ifndef lint
  2. static    char    sccsid[] = "@(#)panel.c 1.2 92/05/28 SMI" ;
  3.     /* from panel.c 1.2 88/10/19 SMI */
  4. #endif
  5.  
  6. /*
  7.  * Copyright (c) 1986 by Sun Microsystems, Inc.
  8.  */
  9.  
  10. #include <stdio.h>
  11. #ifdef XV
  12. #include <xview/xview.h>
  13. #include <xview/panel.h>
  14. #else
  15. #include <suntool/sunview.h>
  16. #include <suntool/panel.h>
  17. #endif XV
  18. #include "dstar.h"
  19. #include "object_types.h"
  20.  
  21.     float        missile_speed, missile_feedback, missile_turn,
  22.             missile_slew ;
  23.  
  24. static    Panel        panel ;
  25. static    Panel_item    kill_but ;
  26. static    Panel_item    debug_toggle ;
  27. static    Panel_item    my_speed_slider ;
  28. static    Panel_item    speed_slider ;
  29. static    Panel_item    feedback_slider ;
  30. static    Panel_item    turn_slider ;
  31. static    Panel_item    slew_slider ;
  32.  
  33. static    void        kill_proc() ;
  34. static    void        set_debug() ;
  35. static    void        my_speed_proc() ;
  36. static    void        speed_proc() ;
  37. static    void        feedback_proc() ;
  38. static    void        turn_proc() ;
  39. static    void        slew_proc() ;
  40.  
  41. init_panel(frame)
  42.     Frame    frame ;
  43. {
  44.     panel = window_create(frame, PANEL, 0) ;
  45.     if(panel == NULL)
  46.       exit(1) ;
  47.  
  48.     missile_speed = MISSILE_SPEED ;
  49.     missile_feedback = MISSILE_GAIN ;
  50.     missile_turn = MISSILE_TURN ;
  51.     missile_slew = MISSILE_SLEW ;
  52.  
  53.     kill_but = panel_create_item(panel, PANEL_BUTTON,
  54.         PANEL_LABEL_IMAGE,
  55.             panel_button_image(panel, "kill missile", 0, 0),
  56.         PANEL_NOTIFY_PROC, kill_proc,
  57.         0 ) ;
  58.  
  59.     debug_toggle = panel_create_item(panel, PANEL_TOGGLE,
  60.         PANEL_CHOICE_STRINGS, "debug", 0,
  61.         PANEL_TOGGLE_VALUE, 0, FALSE,
  62.         PANEL_NOTIFY_PROC, set_debug,
  63.         0 ) ;
  64.  
  65.     my_speed_slider = panel_create_item(panel, PANEL_SLIDER,
  66.         PANEL_LABEL_STRING, "my speed",
  67.         PANEL_NOTIFY_PROC, my_speed_proc,
  68.         PANEL_MAX_VALUE, 50,
  69.         PANEL_VALUE, (int) Me->Speed,
  70.         0 ) ;
  71.  
  72.     speed_slider = panel_create_item(panel, PANEL_SLIDER,
  73.         PANEL_LABEL_STRING, "speed",
  74.         PANEL_NOTIFY_PROC, speed_proc,
  75.         PANEL_MAX_VALUE, 100,
  76.         PANEL_VALUE, (int) missile_speed,
  77.         0 ) ;
  78.  
  79.     feedback_slider = panel_create_item(panel, PANEL_SLIDER,
  80.         PANEL_LABEL_STRING, "feedback",
  81.         PANEL_NOTIFY_PROC, feedback_proc,
  82.         PANEL_MAX_VALUE, 100,
  83.         PANEL_VALUE, (int) (missile_feedback*10.0),
  84.         0 ) ;
  85.  
  86.     turn_slider = panel_create_item(panel, PANEL_SLIDER,
  87.         PANEL_LABEL_STRING, "max turn",
  88.         PANEL_NOTIFY_PROC, turn_proc,
  89.         PANEL_MAX_VALUE, 200,
  90.         PANEL_VALUE, (int) (missile_turn*100.0),
  91.         0 ) ;
  92.  
  93.     slew_slider = panel_create_item(panel, PANEL_SLIDER,
  94.         PANEL_LABEL_STRING, "slew rate",
  95.         PANEL_NOTIFY_PROC, slew_proc,
  96.         PANEL_MAX_VALUE, 200,
  97.         PANEL_VALUE, (int) (missile_slew * 100.0),
  98.         0 ) ;
  99.  
  100.  
  101.     window_fit_height(panel) ;
  102. }
  103.  
  104.  
  105.  
  106. static    void
  107. kill_proc(item, event)
  108.     Panel_item    item ;
  109.     Event        *event ;
  110. {
  111.     if(missiles[0] != NULL)
  112.       missiles[0]->time = 0.0 ;
  113. }
  114.  
  115.  
  116.  
  117.  
  118. static    void
  119. set_debug(item, value, event)
  120.     Panel_item    item ;
  121.     unsigned int    value ;
  122.     Event        *event ;
  123. {
  124.     debug_level = (value & 1) ;
  125. }
  126.  
  127.  
  128.  
  129.  
  130. static    void
  131. my_speed_proc(item, value, event)
  132.     Panel_item    item ;
  133.     int        value ;
  134.     Event        *event ;
  135. {
  136.     Me->Speed = value ;
  137. }
  138.  
  139.  
  140.  
  141.  
  142. static    void
  143. speed_proc(item, value, event)
  144.     Panel_item    item ;
  145.     int        value ;
  146.     Event        *event ;
  147. {
  148.     missile_speed = value ;
  149. }
  150.  
  151.  
  152.  
  153.  
  154. static    void
  155. feedback_proc(item, value, event)
  156.     Panel_item    item ;
  157.     int        value ;
  158.     Event        *event ;
  159. {
  160.     missile_feedback = value*0.1 ;
  161. }
  162.  
  163.  
  164.  
  165.  
  166. static    void
  167. turn_proc(item, value, event)
  168.     Panel_item    item ;
  169.     int        value ;
  170.     Event        *event ;
  171. {
  172.     missile_turn = value*0.01 ;
  173. }
  174.  
  175.  
  176.  
  177.  
  178. static    void
  179. slew_proc(item, value, event)
  180.     Panel_item    item ;
  181.     int        value ;
  182.     Event        *event ;
  183. {
  184.     missile_slew = value*0.01 ;
  185. }
  186.