home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume11
/
reve
/
patch3i
/
patches03f
Wrap
Text File
|
1991-01-03
|
52KB
|
1,737 lines
------- xview.c -------
*** /tmp/da07695 Sun Dec 9 15:22:04 1990
--- xview.c Fri Dec 7 16:49:50 1990
***************
*** 27,32 ****
--- 27,37 ----
#include "color.h"
#include "extern.h"
#include "images.h"
+ #include <errno.h>
+ #include <sys/ioctl.h>
+ #include <sys/param.h>
+ #include <sys/wait.h>
+
#include <xview/xview.h>
#include <xview/canvas.h>
#include <xview/panel.h>
***************
*** 35,47 ****
#include <xview/svrimage.h>
#include <xview/xv_xrect.h>
#include <X11/Xlib.h>
! enum gr_type gtype = GXVIEW ; /* Graphics type. */
enum popup_pos {P_BELOW, P_RIGHT } ; /* Positions relative to main frame. */
#define FRAME_BORDER_SIZE 7
#define FRAME_LABEL_SIZE 30
#define XV_CREATE (void) xv_create
#define XV_SET (void) xv_set
--- 40,58 ----
#include <xview/svrimage.h>
#include <xview/xv_xrect.h>
#include <X11/Xlib.h>
+ #include <X11/Xresource.h>
! extern int errno ;
+ enum gr_type gtype = GXVIEW ; /* Graphics type. */
+
enum popup_pos {P_BELOW, P_RIGHT } ; /* Positions relative to main frame. */
+ #define CLIENT_NO 10
+ #define DEPTH_MENU_ENTRY 9
#define FRAME_BORDER_SIZE 7
#define FRAME_LABEL_SIZE 30
+ #define K_PROPS 3 /* Props key (L3). */
#define XV_CREATE (void) xv_create
#define XV_SET (void) xv_set
***************
*** 53,74 ****
Canvas canvas ;
Canvas_paint_window cpw ;
Event *cur_event ;
- Frame cframe ; /* Frame for Reve game board. */
Frame frame ; /* Frame for control panel. */
- Frame ls_frame ; /* Frame for load/save pop-up window. */
Icon creve_icon ; /* Icon for game board. */
Icon reve_icon ; /* Icon for control panel. */
Panel panel ; /* Xview interface panel. */
Frame ls_frame ; /* Frame for load/save pop-up window. */
Panel ls_panel ; /* Panel for load/save operations. */
Panel_item ls_button ; /* Button to start load/save operation. */
Panel_item ls_text ; /* Load/Save text filename item. */
! Panel_item mes_items[4] ; /* Four generic message items. */
! Panel_setting start_load_save() ;
! Menu game_menu ; /* Menu for 'New Game' button. */
! Menu menus[MAXMENUS] ;
! Notify_value quit_proc() ;
Panel_item black_item ;
Panel_item white_item ;
Server_image hglass_pr, nocur_pr ;
--- 64,95 ----
Canvas canvas ;
Canvas_paint_window cpw ;
Event *cur_event ;
Frame frame ; /* Frame for control panel. */
Icon creve_icon ; /* Icon for game board. */
Icon reve_icon ; /* Icon for control panel. */
Panel panel ; /* Xview interface panel. */
+ Notify_client client = (Notify_client) CLIENT_NO ;
+
Frame ls_frame ; /* Frame for load/save pop-up window. */
Panel ls_panel ; /* Panel for load/save operations. */
Panel_item ls_button ; /* Button to start load/save operation. */
Panel_item ls_text ; /* Load/Save text filename item. */
!
! Frame d_frame ; /* Frame for depth pop-up window. */
! Panel d_panel ; /* Panel for depth operations. */
! Panel_item d_button ; /* Button to start depth operation. */
! Panel_item d_text ; /* Depth numeric text item. */
!
! Frame props_frame ; /* Frame for property window */
! Panel props_panel ; /* Panel for property operations. */
! Panel_item props_computer ; /* Computer plays: choice. */
! Panel_item props_button ; /* Button to start property operation */
! Panel_item props_reset_button ; /* Button to reset properties */
! Panel_item props_choices ; /* non-exclusive choices for properties */
!
! Panel_item mes_items[4] ; /* Four generic message items. */
! Panel_setting start_load_save(), set_profmax(), set_props(), reset_props() ;
Panel_item black_item ;
Panel_item white_item ;
Server_image hglass_pr, nocur_pr ;
***************
*** 84,89 ****
--- 105,111 ----
Window root ;
XFontStruct *font[MAXFONTS] ; /* Xlib handles to the fonts. */
XGCValues gc_val ; /* Used to setup graphics context values. */
+ XrmDatabase reve_DB[MAXDPY] ; /* Combined resources database. */
int gc_flags ; /* Used to set up graphics context flags. */
int screen ; /* Default graphics display screen. */
unsigned long backgnd ; /* Default background color. */
***************
*** 92,106 ****
unsigned long palette[OTH_COLORSIZE] ; /* Xlib color palette. */
int opvals[3] ; /* Pixrect rasterop values. */
int started ; /* Set just before window is displayed. */
void destroy_frame() ;
! static void menu_proc(), new_game_proc(), pop_props(), set_depth() ;
! static void set_player(), unimplemented(), xv_load_game(), xv_save_game() ;
- extern int mnb ; /* Number of current move */
-
void
batch(state) /* Turn graphics batching on or off. */
enum bltype state ;
--- 114,130 ----
unsigned long palette[OTH_COLORSIZE] ; /* Xlib color palette. */
int opvals[3] ; /* Pixrect rasterop values. */
+ int pid ; /* Process id of the reve_proc process. */
+ int pipe_io[2][2] ;
+ int reve_player ; /* Player making the computer move (black/white). */
int started ; /* Set just before window is displayed. */
+ Notify_value read_from_reve(), sigchldcatcher() ;
void destroy_frame() ;
! static void menu_proc(), set_depth(), set_player() ;
! static void xv_load_game(), xv_new_game(), xv_save_game(), xv_set_props() ;
void
batch(state) /* Turn graphics batching on or off. */
enum bltype state ;
***************
*** 116,127 ****
Event *event ;
{
if (!started) return ;
! cur_event = event ;
! process_event() ; /* Determine what kind of event it is. */
handle_event() ; /* And do the appropriate action. */
! if (nextc == LEFT_UP || nextc == MIDDLE_UP || nextc == RIGHT_UP)
! XV_SET(frame, FRAME_BUSY, FALSE, 0) ;
}
--- 140,160 ----
Event *event ;
{
if (!started) return ;
! cur_event = event ; /* Determine what kind of event it is. */
! XAllowEvents(dpy, AsyncBoth, CurrentTime) ;
handle_event() ; /* And do the appropriate action. */
+ }
!
! void
! change_depth(depth)
! int depth ;
! {
! struct reve_in in ;
!
! in.type = M_PROFMAX ;
! in.level = depth ;
! WRITE(pipe_io[0][1], (char *) &in, sizeof(struct reve_in)) ;
}
***************
*** 132,139 ****
}
void
! color_area(x, y, width, height, color)
int x, y, width, height, color ;
{
int d ;
--- 165,174 ----
}
+ /*ARGSUSED*/
void
! color_area(wtype, x, y, width, height, color)
! enum win_type wtype ;
int x, y, width, height, color ;
{
int d ;
***************
*** 154,179 ****
void
! create_menu(mtype, values) /* Create popup menus for cycle items. */
! enum panel_type mtype ;
! char *values[] ;
{
! int i = 0 ;
! int menuno ; /* Current menu number. */
! int more = 1 ; /* Cleared when current menu is complete.*/
!
! menuno = (int) mtype - (int) BLACK_PLAYS ;
! menus[menuno] = xv_create(XV_NULL, MENU_COMMAND_MENU,
! MENU_NOTIFY_PROC, menu_proc,
! 0) ;
! do
! {
! if (values[i] != NULL)
! XV_SET(menus[menuno], MENU_STRING_ITEM, values[i], i+1, 0) ;
! else more = 0 ;
! i++ ;
! }
! while (more) ;
}
--- 189,199 ----
void
! connect_to_reve(pid)
! int pid ;
{
! notify_set_input_func(client, read_from_reve, pipe_io[1][0]) ;
! notify_set_wait3_func(client, sigchldcatcher, pid) ;
}
***************
*** 181,208 ****
destroy_frame() /* Destroy reve window. */
{
xv_destroy_safe(frame) ;
! xv_destroy_safe(cframe) ;
exit(0) ;
}
! do_menu(mtype) /* Popup appropriate cycle menu and get value. */
! enum item_type mtype ;
{
- int menuno ;
-
- menuno = (int) mtype - (int) BLACK_PLAYS ;
- menu_show(menus[menuno], canvas, cur_event, 0) ;
- return(0) ;
}
/*ARGSUSED*/
void
! draw_button(item, color, image) /* **DUMMY ROUTINE** */
enum panel_type item ;
int color ;
- enum image_type image ;
{
}
--- 201,228 ----
destroy_frame() /* Destroy reve window. */
{
xv_destroy_safe(frame) ;
! KILL(pid, SIGKILL) ;
exit(0) ;
}
! /*ARGSUSED*/
! void
! draw_button(wtype, item, color, image) /* **DUMMY ROUTINE** */
! enum win_type wtype ;
! enum panel_type item ;
! int color ;
! enum image_type image ;
{
}
/*ARGSUSED*/
void
! draw_choice(wtype, item, color) /* **DUMMY ROUTINE** */
! enum win_type wtype ;
enum panel_type item ;
int color ;
{
}
***************
*** 209,215 ****
/*ARGSUSED*/
void
! draw_cycle(item, color, image) /* **DUMMY ROUTINE** */
enum panel_type item ;
int color ;
enum image_type image ;
--- 229,236 ----
/*ARGSUSED*/
void
! draw_cycle(wtype, item, color, image) /* **DUMMY ROUTINE** */
! enum win_type wtype ;
enum panel_type item ;
int color ;
enum image_type image ;
***************
*** 217,224 ****
}
void
! draw_image(x, y, width, height, image)
int x, y, width, height ;
enum image_type image ;
{
--- 238,247 ----
}
+ /*ARGSUSED*/
void
! draw_image(wtype, x, y, width, height, image)
! enum win_type wtype ;
int x, y, width, height ;
enum image_type image ;
{
***************
*** 231,238 ****
}
void
! draw_line(x1, y1, x2, y2, op, color)
int x1, y1, x2, y2, color ;
enum optype op ;
{
--- 254,263 ----
}
+ /*ARGSUSED*/
void
! draw_line(wtype, x1, y1, x2, y2, op, color)
! enum win_type wtype ;
int x1, y1, x2, y2, color ;
enum optype op ;
{
***************
*** 251,258 ****
}
void
! draw_stencil(x, y, width, height, op, color, stencil, image)
int x, y, width, height, color ;
enum optype op ;
enum image_type stencil, image ;
--- 276,285 ----
}
+ /*ARGSUSED*/
void
! draw_stencil(wtype, x, y, width, height, op, color, stencil, image)
! enum win_type wtype ;
int x, y, width, height, color ;
enum optype op ;
enum image_type stencil, image ;
***************
*** 277,284 ****
}
void
! draw_text(x, y, ftype, color, str)
enum font_type ftype ;
int x, y, color ;
char *str ;
--- 304,313 ----
}
+ /*ARGSUSED*/
void
! draw_text(wtype, x, y, ftype, color, str)
! enum win_type wtype ;
enum font_type ftype ;
int x, y, color ;
char *str ;
***************
*** 305,327 ****
}
! static Notify_value
! frame_event(frame, event, arg, type)
! Frame frame ;
! Event *event ;
! Notify_arg arg ;
! Notify_event_type type ;
{
! int action ;
! action = event_action(event) ;
! if (action == ACTION_CLOSE) XV_SET(cframe, XV_SHOW, FALSE, 0) ;
! if (action == WIN_RESIZE)
{
! position_popup(frame, cframe, P_BELOW) ;
! XV_SET(cframe, XV_SHOW, TRUE, 0) ;
}
! return(notify_next_event_func(frame, event, arg, type)) ;
}
--- 334,375 ----
}
! /*ARGSUSED*/
! void
! draw_toggle(wtype, item, color)
! enum win_type wtype ;
! enum panel_type item ;
! int color ;
{
! }
!
! fork_child()
! {
! int i ;
!
! PIPE(pipe_io[0]) ; /* Setup input pipe. */
! PIPE(pipe_io[1]) ; /* Setup output pipe. */
! switch (pid = fork())
{
! case -1 : CLOSE(pipe_io[0][0]) ;
! CLOSE(pipe_io[0][1]) ;
! CLOSE(pipe_io[1][0]) ;
! CLOSE(pipe_io[1][1]) ;
! perror("reve fork failed") ;
! exit(1) ;
! case 0 : DUP2(pipe_io[0][0], 0) ; /* Child. */
! DUP2(pipe_io[1][1], 1) ;
! DUP2(pipe_io[1][1], 2) ;
! for (i = getdtablesize(); i > 2; i--) CLOSE(i) ;
! for (i = 0; i < NSIG; i++) SIGNAL(i, SIG_DFL) ;
! execlp("reve_proc", "reve_proc", edgefile, (char *) NULL) ;
! perror("reve child exec") ;
! _exit(-1) ;
! default : CLOSE(pipe_io[0][0]) ; /* Parent. */
! CLOSE(pipe_io[1][1]) ;
}
! return(pid) ;
}
***************
*** 347,352 ****
--- 395,420 ----
}
+ char *
+ get_resource(rtype) /* Get Reve resource from merged databases. */
+ enum res_type rtype ;
+ {
+ char cstr[MAXLINE], nstr[MAXLINE], str[MAXLINE] ;
+ char *str_type[20] ;
+ int d ;
+ XrmValue value ;
+
+ d = (int) cur_dpyno ;
+ STRCPY(str, resources[(int) rtype]) ;
+ SPRINTF(nstr, "reve.%s", str) ;
+ if (islower(str[0])) str[0] = toupper(str[0]) ;
+ SPRINTF(cstr, "Reve.%s", str) ;
+ if (XrmGetResource(reve_DB[d], nstr, cstr, str_type, &value) == NULL)
+ return((char *) NULL) ;
+ else return(value.addr) ;
+ }
+
+
get_strwidth(ftype, str) /* Get width in pixels of string value. */
enum font_type ftype ;
char *str ;
***************
*** 367,378 ****
}
init_ws_type()
{
! show_notes = TRUE ; /* Override generic value for XView version. */
move_delta = 10 ;
cur_dpyno = DPY1 ;
! started = 0 ; /* Kludge to correctly handle repaints. */
return 0 ;
}
--- 435,457 ----
}
+ init_graphics(argc, argv)
+ int *argc ;
+ char *argv[] ;
+ {
+ xv_init(XV_INIT_ARGC_PTR_ARGV, argc, argv, 0) ;
+ frame = (Frame) xv_create(XV_NULL, FRAME, 0) ;
+ dpy = (Display *) xv_get(frame, XV_DISPLAY) ;
+ reve_DB[(int) DPY1] = NULL ;
+ }
+
+
init_ws_type()
{
! SHOW_NOTES = TRUE ; /* Override generic value for XView version. */
move_delta = 10 ;
cur_dpyno = DPY1 ;
! started = 0 ; /* Kludge to correctly handle repaints. */
return 0 ;
}
***************
*** 406,412 ****
--- 485,550 ----
}
+ /* Get the resource databases. These are looked for in the following ways:
+ *
+ * Classname file in the app-defaults directory. In this case, Classname
+ * is Reve.
+ *
+ * Classname file in the directory specified by the XUSERFILESEARCHPATH
+ * or XAPPLRESDIR environment variable.
+ *
+ * Property set using xrdb, accessible through the XResourceManagerString
+ * macro or, if that is empty, the ~/.Xdefaults file.
+ *
+ * XENVIRONMENT environment variable or, if not set, .Xdefaults-hostname
+ * file.
+ */
+
void
+ load_resources()
+ {
+ XrmDatabase db ;
+ char *home, name[MAXPATHLEN], *ptr ;
+ int d, len ;
+
+ d = (int) cur_dpyno ;
+ home = getenv("HOME") ;
+ XrmInitialize() ;
+ STRCPY(name, "/usr/lib/X11/app-defaults/Reve") ;
+
+ /* Get applications defaults file, if any. */
+
+ db = XrmGetFileDatabase(name) ;
+ XrmMergeDatabases(db, &reve_DB[d]) ;
+
+ /* Merge server defaults, created by xrdb. If nor defined, use ~/.Xdefaults. */
+
+ if (XResourceManagerString(dpy) != NULL)
+ db = XrmGetStringDatabase(XResourceManagerString(dpy)) ;
+ else
+ {
+ SPRINTF(name, "%s/.Xdefaults", home) ;
+ db = XrmGetFileDatabase(name) ;
+ }
+ XrmMergeDatabases(db, &reve_DB[d]) ;
+
+ /* Open XENVIRONMENT file or, if not defined, the .Xdefaults, and merge
+ * into existing database.
+ */
+
+ if ((ptr = getenv("XENVIRONMENT")) == NULL)
+ {
+ SPRINTF(name, "%s/.Xdefaults-", home) ;
+ len = strlen(name) ;
+ GETHOSTNAME(name+len, 1024-len) ;
+ db = XrmGetFileDatabase(name) ;
+ }
+ else db = XrmGetFileDatabase(ptr) ;
+ XrmMergeDatabases(db, &reve_DB[d]) ;
+ }
+
+
+ void
lock_screen(state) /* Turn graphics locking on or off - null routine. */
enum bltype state ;
{}
***************
*** 415,429 ****
void
make_canvas() /* Create canvas for game board. */
{
! cframe = xv_create(XV_NULL, FRAME,
! XV_SHOW, FALSE,
! FRAME_ICON, creve_icon,
! FRAME_NO_CONFIRM, TRUE,
! WIN_ERROR_MSG, "Reve: Can't create window.",
! FRAME_SHOW_RESIZE_CORNER, FALSE,
! FRAME_SHOW_HEADER, FALSE,
! 0) ;
! canvas = xv_create(cframe, CANVAS,
CANVAS_RETAINED, FALSE,
OPENWIN_AUTO_CLEAR, FALSE,
XV_HEIGHT, TOTAL_HEIGHT,
--- 553,563 ----
void
make_canvas() /* Create canvas for game board. */
{
! int pid ;
!
! canvas = xv_create(frame, CANVAS,
! WIN_BELOW, panel,
! XV_X, 0,
CANVAS_RETAINED, FALSE,
OPENWIN_AUTO_CLEAR, FALSE,
XV_HEIGHT, TOTAL_HEIGHT,
***************
*** 432,439 ****
WIN_CONSUME_EVENTS,
MS_LEFT, MS_MIDDLE, MS_RIGHT,
WIN_ASCII_EVENTS, KBD_USE, KBD_DONE,
! LOC_MOVE, LOC_DRAG,
! LOC_WINENTER, LOC_WINEXIT,
WIN_LEFT_KEYS, WIN_TOP_KEYS,
WIN_RIGHT_KEYS, WIN_REPAINT,
0,
--- 566,572 ----
WIN_CONSUME_EVENTS,
MS_LEFT, MS_MIDDLE, MS_RIGHT,
WIN_ASCII_EVENTS, KBD_USE, KBD_DONE,
! LOC_DRAG, LOC_WINENTER, LOC_WINEXIT,
WIN_LEFT_KEYS, WIN_TOP_KEYS,
WIN_RIGHT_KEYS, WIN_REPAINT,
0,
***************
*** 440,447 ****
WIN_EVENT_PROC, canvas_proc,
0,
0) ;
! window_fit(cframe) ;
! notify_interpose_destroy_func(cframe, quit_proc) ;
cpw = canvas_paint_window(canvas) ;
cursor[(int) CANVASCUR] = xv_get(cpw, WIN_CURSOR, NULL) ;
--- 573,579 ----
WIN_EVENT_PROC, canvas_proc,
0,
0) ;
! window_fit(frame) ;
cpw = canvas_paint_window(canvas) ;
cursor[(int) CANVASCUR] = xv_get(cpw, WIN_CURSOR, NULL) ;
***************
*** 486,499 ****
--- 618,635 ----
images[(int) P_WHITE] = make_server_image(white_image) ;
images[(int) P_BLACK] = make_server_image(black_image) ;
+ pid = fork_child() ;
+ connect_to_reve(pid) ;
}
+ /*ARGSUSED*/
void
make_frame(argc, argv) /* Create frame and the panel, buttons, menus. */
int argc ;
char *argv[] ;
{
+ int val ;
Menu_item item ;
opvals[(int) RCLR] = GXclear ;
***************
*** 502,570 ****
/* Create the frame and the control panel */
! xv_init(XV_INIT_ARGS, argc, argv, 0) ;
! frame = xv_create(XV_NULL, FRAME,
! FRAME_ICON, reve_icon,
! FRAME_LABEL, line,
! FRAME_NO_CONFIRM, TRUE,
! FRAME_SHOW_RESIZE_CORNER, FALSE,
! WIN_ERROR_MSG, "Reve: Can't create window.",
! NULL) ;
panel = (Panel) xv_create(frame, PANEL, 0) ;
- /* Menu for the 'new game' button */
-
- game_menu = (Menu) xv_create(XV_NULL, MENU,
- MENU_NOTIFY_PROC, new_game_proc,
- MENU_STRINGS,
- "Human (black) vs. Computer (white)",
- "Computer (black) vs. Human (white)",
- "Human (black) vs. Human (white)",
- 0,
- 0) ;
-
/* Create the buttons and other controls. */
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 0),
PANEL_ITEM_Y, xv_row(panel, 0),
! PANEL_LABEL_STRING, "New Game",
! PANEL_ITEM_MENU, game_menu,
0) ;
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 15),
PANEL_ITEM_Y, xv_row(panel, 0),
! PANEL_LABEL_STRING, "Load Game...",
! PANEL_NOTIFY_PROC, xv_load_game,
0) ;
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 30),
PANEL_ITEM_Y, xv_row(panel, 0),
! PANEL_LABEL_STRING, "Save Game...",
! PANEL_NOTIFY_PROC, xv_save_game,
0) ;
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 45),
PANEL_ITEM_Y, xv_row(panel, 0),
! PANEL_LABEL_STRING, " Help ",
! PANEL_NOTIFY_PROC, unimplemented,
0) ;
!
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 0),
PANEL_ITEM_Y, xv_row(panel, 1),
! PANEL_LABEL_STRING, " Moves? ",
! PANEL_NOTIFY_PROC, show_all_moves,
0) ;
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 15),
PANEL_ITEM_Y, xv_row(panel, 1),
! PANEL_LABEL_STRING, " Suggest ",
PANEL_NOTIFY_PROC, suggest,
0) ;
--- 638,693 ----
/* Create the frame and the control panel */
! XV_SET(frame,
! FRAME_ICON, reve_icon,
! FRAME_LABEL, line,
! FRAME_NO_CONFIRM, TRUE,
! FRAME_SHOW_RESIZE_CORNER, FALSE,
! 0) ;
panel = (Panel) xv_create(frame, PANEL, 0) ;
/* Create the buttons and other controls. */
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 0),
PANEL_ITEM_Y, xv_row(panel, 0),
! PANEL_LABEL_STRING, "Load Game...",
! PANEL_NOTIFY_PROC, xv_load_game,
0) ;
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 15),
PANEL_ITEM_Y, xv_row(panel, 0),
! PANEL_LABEL_STRING, " Moves? ",
! PANEL_NOTIFY_PROC, show_all_moves,
0) ;
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 30),
PANEL_ITEM_Y, xv_row(panel, 0),
! PANEL_NOTIFY_PROC, xv_new_game,
! PANEL_LABEL_STRING, " New Game ",
0) ;
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 45),
PANEL_ITEM_Y, xv_row(panel, 0),
! PANEL_LABEL_STRING, " Props... ",
! PANEL_NOTIFY_PROC, xv_set_props,
0) ;
!
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 0),
PANEL_ITEM_Y, xv_row(panel, 1),
! PANEL_LABEL_STRING, "Save Game...",
! PANEL_NOTIFY_PROC, xv_save_game,
0) ;
XV_CREATE(panel, PANEL_BUTTON,
PANEL_ITEM_X, xv_col(panel, 15),
PANEL_ITEM_Y, xv_row(panel, 1),
! PANEL_LABEL_STRING, " Suggest ",
PANEL_NOTIFY_PROC, suggest,
0) ;
***************
*** 582,670 ****
PANEL_NOTIFY_PROC, destroy_frame,
0) ;
! XV_CREATE(panel, PANEL_CHECK_BOX,
PANEL_ITEM_X, xv_col(panel, 0),
! PANEL_ITEM_Y, xv_row(panel, 4),
! PANEL_LABEL_STRING, "Show Info ",
! PANEL_NOTIFY_PROC, pop_props,
! PANEL_VALUE, 1,
0) ;
!
! black_item = xv_create(panel, PANEL_CHOICE_STACK,
! PANEL_ITEM_X, xv_col(panel, 0),
! PANEL_ITEM_Y, xv_row(panel, 2),
! PANEL_LABEL_STRING, "Black:",
! PANEL_CHOICE_STRINGS,
! "human",
! "computer",
! 0,
! PANEL_NOTIFY_PROC, set_player,
! PANEL_VALUE, items[(int) BLACK_PLAYS].value,
0) ;
! white_item = xv_create(panel, PANEL_CHOICE_STACK,
! PANEL_ITEM_X, xv_col(panel, 0),
! PANEL_ITEM_Y, xv_row(panel, 3),
! PANEL_LABEL_STRING, "White:",
! PANEL_CHOICE_STRINGS,
! "human",
! "computer",
! 0,
! PANEL_NOTIFY_PROC, set_player,
! PANEL_VALUE, items[(int) WHITE_PLAYS].value,
0) ;
! mes_items[(int) (TURN_MES - PANEL_MES)] = xv_create(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 30),
! PANEL_ITEM_Y, xv_row(panel, 2),
! PANEL_LABEL_STRING, "Black to move",
! 0) ;
!
! mes_items[(int) (SCORE_MES - PANEL_MES)] = xv_create(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 30),
PANEL_ITEM_Y, xv_row(panel, 3),
PANEL_LABEL_STRING, "",
0) ;
!
mes_items[(int) (EVAL_MES - PANEL_MES)] = xv_create(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 30),
PANEL_ITEM_Y, xv_row(panel, 4),
PANEL_LABEL_STRING, "",
0) ;
!
!
! mes_items[(int) (PANEL_MES - PANEL_MES)] = xv_create(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 30),
PANEL_ITEM_Y, xv_row(panel, 5),
PANEL_LABEL_STRING, "",
0) ;
-
- XV_CREATE(panel, PANEL_CHOICE_STACK,
- PANEL_ITEM_X, xv_col(panel, 0),
- PANEL_ITEM_Y, xv_row(panel, 5),
- PANEL_LABEL_STRING, "Difficulty: ",
- PANEL_CHOICE_STRINGS,
- " Instant",
- " 1 Minute",
- " 3 Minutes",
- " 5 Minutes",
- "10 Minutes",
- "15 Minutes",
- "20 Minutes",
- "Tournament (30)",
- "60 MInutes",
- 0,
- PANEL_NOTIFY_PROC, set_depth,
- PANEL_VALUE, 0,
- 0) ;
window_fit(panel) ;
- window_fit(frame) ;
- notify_interpose_event_func(frame, frame_event, NOTIFY_SAFE) ;
- notify_interpose_destroy_func(frame, quit_proc) ;
ls_frame = xv_create(frame, FRAME_CMD,
- FRAME_LABEL, "Name your Game ...",
FRAME_CMD_PUSHPIN_IN, TRUE,
0) ;
--- 705,764 ----
PANEL_NOTIFY_PROC, destroy_frame,
0) ;
! XV_CREATE(panel, PANEL_MESSAGE,
PANEL_ITEM_X, xv_col(panel, 0),
! PANEL_ITEM_Y, xv_row(panel, 2),
! PANEL_LABEL_BOLD, TRUE,
! PANEL_LABEL_STRING, "Black:",
0) ;
! val = items[(int) BLACK_PLAYS].value ;
! black_item = xv_create(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 7),
! PANEL_ITEM_Y, xv_row(panel, 2),
! PANEL_LABEL_BOLD, FALSE,
! PANEL_LABEL_STRING, player_values[val],
0) ;
! XV_CREATE(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 30),
! PANEL_ITEM_Y, xv_row(panel, 2),
! PANEL_LABEL_BOLD, TRUE,
! PANEL_LABEL_STRING, "White:",
! 0) ;
! val = items[(int) WHITE_PLAYS].value ;
! white_item = xv_create(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 37),
! PANEL_ITEM_Y, xv_row(panel, 2),
! PANEL_LABEL_BOLD, FALSE,
! PANEL_LABEL_STRING, player_values[val],
0) ;
! mes_items[(int) (PANEL_MES - PANEL_MES)] = xv_create(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 0),
PANEL_ITEM_Y, xv_row(panel, 3),
PANEL_LABEL_STRING, "",
0) ;
!
mes_items[(int) (EVAL_MES - PANEL_MES)] = xv_create(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 0),
PANEL_ITEM_Y, xv_row(panel, 4),
PANEL_LABEL_STRING, "",
0) ;
!
! mes_items[(int) (SCORE_MES - PANEL_MES)] = xv_create(panel, PANEL_MESSAGE,
! PANEL_ITEM_X, xv_col(panel, 0),
PANEL_ITEM_Y, xv_row(panel, 5),
PANEL_LABEL_STRING, "",
0) ;
+ mes_items[(int) (TURN_MES - PANEL_MES)] = xv_create(panel, PANEL_MESSAGE,
+ PANEL_ITEM_X, xv_col(panel, 30),
+ PANEL_ITEM_Y, xv_row(panel, 5),
+ PANEL_LABEL_STRING, "Black to move",
+ 0) ;
window_fit(panel) ;
ls_frame = xv_create(frame, FRAME_CMD,
FRAME_CMD_PUSHPIN_IN, TRUE,
0) ;
***************
*** 673,679 ****
ls_text = XV_CREATE(ls_panel, PANEL_TEXT,
PANEL_ITEM_X, xv_col(ls_panel, 0),
PANEL_ITEM_Y, xv_row(ls_panel, 0),
! PANEL_LABEL_STRING, "Load File: ",
PANEL_VALUE, gamefile,
PANEL_VALUE_DISPLAY_LENGTH, 30,
PANEL_VALUE_STORED_LENGTH, 255,
--- 767,773 ----
ls_text = XV_CREATE(ls_panel, PANEL_TEXT,
PANEL_ITEM_X, xv_col(ls_panel, 0),
PANEL_ITEM_Y, xv_row(ls_panel, 0),
! PANEL_LABEL_STRING, "Load File:",
PANEL_VALUE, gamefile,
PANEL_VALUE_DISPLAY_LENGTH, 30,
PANEL_VALUE_STORED_LENGTH, 255,
***************
*** 680,686 ****
0) ;
ls_button = xv_create(ls_panel, PANEL_BUTTON,
! PANEL_LABEL_STRING, "Load",
PANEL_NOTIFY_PROC, start_load_save,
XV_X, xv_col(ls_panel, 18),
XV_Y, xv_row(ls_panel, 1),
--- 774,780 ----
0) ;
ls_button = xv_create(ls_panel, PANEL_BUTTON,
! PANEL_LABEL_STRING, "Apply",
PANEL_NOTIFY_PROC, start_load_save,
XV_X, xv_col(ls_panel, 18),
XV_Y, xv_row(ls_panel, 1),
***************
*** 688,693 ****
--- 782,906 ----
window_fit(ls_panel) ;
window_fit(ls_frame) ;
+ d_frame = xv_create(frame, FRAME_CMD,
+ FRAME_LABEL, "Set Search Depth",
+ FRAME_CMD_PUSHPIN_IN, TRUE,
+ 0) ;
+
+ d_panel = (Panel) xv_get(d_frame, FRAME_CMD_PANEL) ;
+
+ d_text = XV_CREATE(d_panel, PANEL_NUMERIC_TEXT,
+ PANEL_VALUE_X, xv_col(d_panel, 10),
+ XV_Y, xv_row(d_panel, 0),
+ PANEL_LABEL_STRING, "Depth: ",
+ PANEL_VALUE, INIT_DEPTH,
+ PANEL_VALUE_DISPLAY_LENGTH, 2,
+ PANEL_VALUE_STORED_LENGTH, 2,
+ PANEL_MIN_VALUE, 1,
+ PANEL_MAX_VALUE, MAX_PROFMAX,
+ 0) ;
+
+ d_button = xv_create(d_panel, PANEL_BUTTON,
+ PANEL_LABEL_STRING, "Apply",
+ PANEL_NOTIFY_PROC, set_profmax,
+ XV_X, xv_col(d_panel, 7),
+ XV_Y, xv_row(d_panel, 1),
+ 0) ;
+ window_fit(d_panel) ;
+ window_fit(d_frame) ;
+
+
+ props_frame = xv_create(frame, FRAME_CMD,
+ FRAME_LABEL, "Reve Properties",
+ FRAME_CMD_PUSHPIN_IN, TRUE,
+ 0) ;
+
+ props_panel = (Panel) xv_get(props_frame, FRAME_CMD_PANEL) ;
+
+ if (dtype == XBLACK) val = CP_WHITE ;
+ else if (dtype == XWHITE) val = CP_BLACK ;
+ else if (dtype == XBOTH || dtype == XTWO) val = CP_NEITHER ;
+
+ props_computer = xv_create(props_panel, PANEL_CHOICE,
+ PANEL_LABEL_STRING, "Computer plays:",
+ PANEL_LABEL_BOLD, TRUE,
+ PANEL_VALUE_X, xv_col(props_panel, 15),
+ XV_Y, xv_row(props_panel, 0),
+ PANEL_CHOICE_STRINGS,
+ "White",
+ "Black",
+ "Neither",
+ "Both",
+ 0,
+ PANEL_VALUE, val,
+ 0) ;
+
+ XV_CREATE(props_panel, PANEL_CHOICE_STACK,
+ PANEL_VALUE_X, xv_col(props_panel, 15),
+ XV_Y, xv_row(props_panel, 1),
+ PANEL_LABEL_STRING, "Difficulty: ",
+ PANEL_CHOICE_STRINGS,
+ " Instant",
+ " 1 Minute",
+ " 3 Minutes",
+ " 5 Minutes",
+ "10 Minutes",
+ "15 Minutes",
+ "20 Minutes",
+ "Tournament (30)",
+ "60 MInutes",
+ "Depth...",
+ 0,
+ PANEL_NOTIFY_PROC, set_depth,
+ PANEL_VALUE, items[(int) DIFF_CHOICE].value,
+ 0) ;
+
+ XV_CREATE(props_panel, PANEL_MESSAGE,
+ XV_X, xv_col(props_panel, 7),
+ XV_Y, xv_row(props_panel, 2),
+ PANEL_LABEL_BOLD, TRUE,
+ PANEL_LABEL_STRING, "Options:",
+ 0) ;
+
+ val = ((ANIMATION & 0x1) << 0) +
+ ((DO_BESTMOVE & 0x1) << 1) +
+ ((DO_LAST & 0x1) << 2) +
+ ((SHOW_NOTES & 0x1) << 3) +
+ ((DO_NUMBER & 0x1) << 4) +
+ ((QUICKGAME & 0x1) << 5) ;
+
+ props_choices = xv_create(props_panel, PANEL_CHECK_BOX,
+ PANEL_LAYOUT, PANEL_VERTICAL,
+ PANEL_CHOOSE_ONE, FALSE,
+ PANEL_CHOICE_STRINGS,
+ "Animate Move",
+ "Show Current Best Move",
+ "Show Last Move",
+ "Show Evaluation Info.",
+ "Number Last Move",
+ "Don't Show Flip",
+ 0,
+ PANEL_VALUE_X, xv_col(props_panel, 15),
+ PANEL_VALUE_Y, xv_row(props_panel, 2),
+ PANEL_VALUE, val,
+ 0) ;
+
+ props_button = xv_create(props_panel, PANEL_BUTTON,
+ PANEL_LABEL_STRING, "Apply",
+ PANEL_NOTIFY_PROC, set_props,
+ XV_X, xv_col(props_panel, 13),
+ XV_Y, xv_row(props_panel, 8),
+ 0) ;
+
+ props_reset_button = xv_create(props_panel, PANEL_BUTTON,
+ PANEL_LABEL_STRING, "Reset",
+ PANEL_NOTIFY_PROC, reset_props,
+ XV_X, xv_col(props_panel, 23),
+ XV_Y, xv_row(props_panel, 8),
+ 0) ;
+ window_fit(props_panel) ;
+ window_fit(props_frame) ;
+
iscolor[(int) cur_dpyno] = ((int) xv_get(frame, WIN_DEPTH) > 1) ? 1 : 0 ;
}
***************
*** 717,724 ****
void
! make_panel() /* **DUMMY ROUTINE** */
{
}
--- 930,938 ----
void
! make_panel()
{
+ panel_paint(panel, PANEL_CLEAR) ;
}
***************
*** 758,808 ****
}
! static void
! new_game_proc(menu, menu_item)
! Menu menu ;
! Menu_item menu_item ;
{
- switch((int) xv_get(menu_item, MENU_VALUE))
- {
- case 1 : items[(int) BLACK_PLAYS].value = HUMAN ;
- items[(int) WHITE_PLAYS].value = COMPUTER ;
- cmode = WHITE_START ;
- dtype = XBLACK ;
- break ;
-
- case 2 : items[(int) BLACK_PLAYS].value = COMPUTER ;
- items[(int) WHITE_PLAYS].value = HUMAN ;
- cmode = BLACK_START ;
- dtype = XWHITE ;
- break ;
-
- case 3 : items[(int) BLACK_PLAYS].value = HUMAN ;
- items[(int) WHITE_PLAYS].value = HUMAN ;
- cmode = BLACK_START ;
- dtype = XBOTH ;
- }
- XV_SET(black_item, PANEL_VALUE, items[(int) BLACK_PLAYS].value) ;
- XV_SET(white_item, PANEL_VALUE, items[(int) WHITE_PLAYS].value) ;
- new_game() ;
}
! /* Callback for the check box to show/hide evaluation and score. */
!
! static void
! pop_props(item, value, event)
{
- show_notes = !show_notes ;
- if (!show_notes)
- {
- XV_SET(mes_items[(int) (EVAL_MES - PANEL_MES)],
- PANEL_LABEL_STRING, "",
- 0) ;
- XV_SET(mes_items[(int) (SCORE_MES - PANEL_MES)],
- PANEL_LABEL_STRING, "",
- 0) ;
- }
}
--- 972,987 ----
}
! void
! open_frame(wtype) /* **DUMMY ROUTINE** */
! enum win_type wtype ;
{
}
! void
! paint_prop_sheet() /* **DUMMY ROUTINE** */
{
}
***************
*** 839,844 ****
--- 1018,1024 ----
{
int id ;
+ nextc = IGNORE_EVENT ;
id = (event_id(cur_event)) ;
curx = event_x(cur_event) ;
cury = event_y(cur_event) ;
***************
*** 845,851 ****
if (id == KBD_DONE || id == LOC_WINEXIT) nextc = EXIT_WINDOW ;
else if (id == LOC_WINENTER) nextc = ENTER_WINDOW ;
! else if (id == LOC_MOVE || id == LOC_DRAG) nextc = MOUSE_MOVING ;
else if (id == WIN_REPAINT || id == WIN_RESIZE) nextc = FRAME_REPAINT ;
else if (id == WIN_REPAINT || id == WIN_RESIZE) nextc = FRAME_REPAINT ;
else if (event_is_button(cur_event) && event_is_down(cur_event))
--- 1025,1031 ----
if (id == KBD_DONE || id == LOC_WINEXIT) nextc = EXIT_WINDOW ;
else if (id == LOC_WINENTER) nextc = ENTER_WINDOW ;
! else if (id == LOC_DRAG) nextc = MOUSE_MOVING ;
else if (id == WIN_REPAINT || id == WIN_RESIZE) nextc = FRAME_REPAINT ;
else if (id == WIN_REPAINT || id == WIN_RESIZE) nextc = FRAME_REPAINT ;
else if (event_is_button(cur_event) && event_is_down(cur_event))
***************
*** 859,865 ****
if (id == MS_LEFT) nextc = LEFT_UP ;
else if (id == MS_MIDDLE) nextc = MIDDLE_UP ;
else if (id == MS_RIGHT) nextc = RIGHT_UP ;
- XV_SET(frame, FRAME_BUSY, TRUE, 0) ;
}
else if (event_is_ascii(cur_event))
{
--- 1039,1044 ----
***************
*** 866,886 ****
cur_ch = id ;
nextc = KEYBOARD ;
}
}
! static Notify_value
! quit_proc(frame, status)
! Frame frame ;
Destroy_status status ;
{
! if (status == DESTROY_PROCESS_DEATH || status == DESTROY_CLEANUP)
{
! xv_destroy_safe(frame) ;
! xv_destroy_safe(cframe) ;
! exit(0) ;
}
! return(notify_next_destroy_func(frame, status)) ;
}
--- 1045,1109 ----
cur_ch = id ;
nextc = KEYBOARD ;
}
+ if (processing)
+ {
+ if (nextc == FRAME_REPAINT) return ;
+ else
+ {
+ if (event_action(cur_event) == ACTION_SELECT)
+ XUngrabPointer(dpy, 0) ;
+ nextc = IGNORE_EVENT ;
+ window_bell(frame) ;
+ message(PANEL_MES, "It's not your turn.") ;
+ }
+ }
}
! Notify_value
! quit_proc(client, status)
! Notify_client client ;
Destroy_status status ;
{
! if (status == DESTROY_CHECKING) KILL(pid, SIGKILL) ;
! return(notify_next_destroy_func(client, status)) ;
! }
!
!
! Notify_value
! read_from_reve(client, fd)
! Notify_client client ;
! register int fd ;
! {
! struct reve_out out ;
! int bytes, sout ;
!
! if (!started) return(NOTIFY_DONE) ;
! sout = sizeof(struct reve_out) ;
! if (ioctl(fd, FIONREAD, &bytes) == 0)
{
! if (read(fd, (char *) &out, sout) > 0)
! {
! profmax = out.depth ;
! if (out.type == M_BEST) show_best(out.move, out.note) ;
! else if (out.type == M_MOVE)
! {
! set_cursor(CANVASCUR) ;
! XV_SET(frame, FRAME_BUSY, TRUE, 0) ;
! move = out.move ;
! note = out.note ;
! do_computer_move(reve_player) ;
! XV_SET(frame, FRAME_BUSY, FALSE, 0) ;
! processing = FALSE ;
! }
! else if (out.type == M_SUGGESTION)
! {
! do_suggest(reve_player, out.move, out.note, IS_ON) ;
! processing = FALSE ;
! }
! }
}
! return(NOTIFY_DONE) ;
}
***************
*** 890,896 ****
--- 1113,1154 ----
}
+ Panel_setting
+ reset_props(item, event)
+ Panel_item item ;
+ Event *event ;
+ {
+ int val ;
+
+ if (dtype == XBLACK) val = CP_WHITE ;
+ else if (dtype == XWHITE) val = CP_BLACK ;
+ else if (dtype == XBOTH || dtype == XTWO) val = CP_NEITHER ;
+ XV_SET(props_computer, PANEL_VALUE, val, 0) ;
+
+ val = ((ANIMATION & 0x1) << 0) +
+ ((DO_BESTMOVE & 0x1) << 1) +
+ ((DO_LAST & 0x1) << 2) +
+ ((SHOW_NOTES & 0x1) << 3) +
+ ((DO_NUMBER & 0x1) << 4) +
+ ((QUICKGAME & 0x1) << 5) ;
+ XV_SET(props_choices, PANEL_VALUE, val, 0) ;
+ return(PANEL_NONE) ;
+ }
+
+
void
+ reset_time(timeleft)
+ time_t timeleft ;
+ {
+ struct reve_in in ;
+
+ in.type = M_TIME ;
+ in.timeleft = timeleft ;
+ WRITE(pipe_io[0][1], (char *) &in, sizeof(struct reve_in)) ;
+ }
+
+
+ void
set_cursor(ctype)
enum curtype ctype ;
{
***************
*** 902,908 ****
/*ARGSUSED*/
void
! set_cycle(mtype, str) /* **DUMMY ROUTINE** */
enum panel_type mtype ;
char *str ;
{
--- 1160,1167 ----
/*ARGSUSED*/
void
! set_cycle(wtype, mtype, str) /* **DUMMY ROUTINE** */
! enum win_type wtype ;
enum panel_type mtype ;
char *str ;
{
***************
*** 915,971 ****
int value ;
Event *event ;
{
! level = value + 1 ;
! items[(int) DIFFICULTY].value = level - 1 ;
}
! static void
! set_player(item, value, event) /* Callback to set black/white player. */
Panel_item item ;
- int value ;
Event *event ;
{
! char *label ;
! enum panel_type this, other ;
! int curi, curo ;
! label = (char *) xv_get(item, PANEL_LABEL_STRING) ;
! if (EQUAL(label, "Black"))
{
! this = BLACK_PLAYS ;
! other = WHITE_PLAYS ;
}
! else
{
! this = WHITE_PLAYS ;
! other = BLACK_PLAYS ;
! }
! curi = items[(int) this].value = value ;
! curo = items[(int) other].value ;
!
! if (curi == COMPUTER && curo == COMPUTER)
{
! curi = HUMAN ;
! XV_SET(item, PANEL_VALUE, curi, 0) ;
! items[(int) this].value = curi ;
! message(PANEL_MES, "Computer can't play both players.") ;
}
! if (curi == HUMAN && curo == COMPUTER)
! dtype = (this == BLACK_PLAYS) ? XBLACK : XWHITE ;
! else if (curi == COMPUTER && curo == HUMAN)
! dtype = (this == BLACK_PLAYS) ? XWHITE : XBLACK ;
! else if (curi == HUMAN && curo == HUMAN)
! dtype = (dtype == XTWO) ? XTWO : XBOTH ;
!
if (curi == COMPUTER)
! if ((this == BLACK_PLAYS && cmode == BLACK_START) ||
! (this == WHITE_PLAYS && cmode == WHITE_START))
computer_move(next_player) ;
}
Panel_setting
start_load_save(item, event)
Panel_item item ;
--- 1174,1287 ----
int value ;
Event *event ;
{
! if (value == DEPTH_MENU_ENTRY)
! {
! position_popup(frame, d_frame, P_RIGHT) ;
! XV_SET(d_frame, XV_SHOW, TRUE, 0) ;
! }
! else
! {
! level = value + 1 ;
! change_depth(1) ;
! XV_SET(d_text, PANEL_VALUE, 1, 0) ;
! items[(int) DIFF_CHOICE].value = level - 1 ;
! }
}
! Panel_setting
! set_profmax(item, event)
Panel_item item ;
Event *event ;
{
! XV_SET(d_frame, XV_SHOW, FALSE, 0) ;
! change_depth((int) xv_get(d_text, PANEL_VALUE)) ;
! level = 1 ;
! return(PANEL_NONE) ;
! }
!
! Panel_setting
! set_props(item, event)
! Panel_item item ;
! Event *event ;
! {
! int curi, oldval, val ;
!
! if (dtype == XBLACK) oldval = CP_WHITE ;
! else if (dtype == XWHITE) oldval = CP_BLACK ;
! else if (dtype == XBOTH || dtype == XTWO) oldval = CP_NEITHER ;
!
! val = (int) xv_get(props_computer, PANEL_VALUE, 0) ;
! if (val == CP_WHITE)
{
! dtype = XBLACK ;
! play_computer = TRUE ;
! items[(int) BLACK_PLAYS].value = HUMAN ;
! items[(int) WHITE_PLAYS].value = COMPUTER ;
}
! else if (val == CP_BLACK)
{
! dtype = XWHITE ;
! play_computer = TRUE ;
! items[(int) BLACK_PLAYS].value = COMPUTER ;
! items[(int) WHITE_PLAYS].value = HUMAN ;
! }
! else if (val == CP_NEITHER)
{
! dtype = XTWO ;
! play_computer = FALSE ;
! items[(int) BLACK_PLAYS].value = HUMAN ;
! items[(int) WHITE_PLAYS].value = HUMAN ;
}
! else if (val == CP_BOTH)
! {
! XV_SET(props_computer, PANEL_VALUE, oldval, 0) ;
! message(PANEL_MES, "Computer plays both is not implemented yet.") ;
! }
!
! val = items[(int) BLACK_PLAYS].value ;
! XV_SET(black_item, PANEL_VALUE, player_values[val], 0) ;
! val = items[(int) WHITE_PLAYS].value ;
! XV_SET(white_item, PANEL_VALUE, player_values[val], 0) ;
!
! if (next_player == BLACK) curi = items[(int) BLACK_PLAYS].value ;
! else curi = items[(int) WHITE_PLAYS].value ;
if (curi == COMPUTER)
! if ((next_player == BLACK && cmode == BLACK_START) ||
! (next_player == WHITE && cmode == WHITE_START))
computer_move(next_player) ;
+
+ val = (int) xv_get(props_choices, PANEL_VALUE, 0) ;
+ ANIMATION = (val >> 0) & 0x1 ;
+ DO_BESTMOVE = (val >> 1) & 0x1 ;
+ DO_LAST = (val >> 2) & 0x1 ;
+ SHOW_NOTES = (val >> 3) & 0x1 ;
+ DO_NUMBER = (val >> 4) & 0x1 ;
+ QUICKGAME = (val >> 5) & 0x1 ;
+
+ XV_SET(props_frame, XV_SHOW, FALSE, 0) ;
+ return(PANEL_NONE) ;
}
+ Notify_value
+ sigchldcatcher(client, pid, status, rusage)
+ Notify_client client ;
+ int pid ;
+ union wait *status ;
+ struct rusage *rusage ;
+ {
+ if (WIFEXITED(*status))
+ {
+ notify_set_input_func(client, NOTIFY_FUNC_NULL, pipe_io[1][0]) ;
+ return(NOTIFY_DONE) ;
+ }
+ return(NOTIFY_IGNORED) ;
+ }
+
+
Panel_setting
start_load_save(item, event)
Panel_item item ;
***************
*** 973,979 ****
{
char *label ;
! XV_SET(ls_frame, XV_SHOW, FALSE, NULL) ;
STRCPY(gamefile, (char *) xv_get(ls_text, PANEL_VALUE)) ;
label = (char *) xv_get(ls_button, PANEL_LABEL_STRING) ;
if (EQUAL(label, "Load")) load_game() ;
--- 1289,1295 ----
{
char *label ;
! XV_SET(ls_frame, XV_SHOW, FALSE, 0) ;
STRCPY(gamefile, (char *) xv_get(ls_text, PANEL_VALUE)) ;
label = (char *) xv_get(ls_button, PANEL_LABEL_STRING) ;
if (EQUAL(label, "Load")) load_game() ;
***************
*** 988,1004 ****
enum disp_type dtype ;
{
started = 1 ;
xv_main_loop(frame) ;
}
! static void /* Dummy function for unimplemented callbacks */
! unimplemented()
{
! message(PANEL_MES, "Not implemented yet.\n") ;
}
static void
xv_load_game(item, value, event) /* Callback for loading a game button. */
Panel_item item ;
--- 1304,1335 ----
enum disp_type dtype ;
{
started = 1 ;
+ notify_interpose_destroy_func(frame, quit_proc) ;
xv_main_loop(frame) ;
}
! /*ARGSUSED*/
! void
! write_to_reve(mtype, reve_board, player, level, reve_move, note)
! enum move_type mtype ;
! int *reve_board, player, level, *reve_move ;
! long *note ;
{
! int i ;
! struct reve_in in ;
!
! for (i = 0; i < 64; i++) in.board[i] = reve_board[i] ;
! in.player = player ;
! in.level = level ;
! in.type = mtype ;
! reve_player = player ;
! processing = TRUE ;
! WRITE(pipe_io[0][1], (char *) &in, sizeof(struct reve_in)) ;
}
+ /*ARGSUSED*/
static void
xv_load_game(item, value, event) /* Callback for loading a game button. */
Panel_item item ;
***************
*** 1006,1017 ****
Event *event ;
{
position_popup(frame, ls_frame, P_RIGHT) ;
! XV_SET(ls_text, PANEL_LABEL_STRING, "Load File: ", 0) ;
! XV_SET(ls_button, PANEL_LABEL_STRING, "Load", 0) ;
! XV_SET(ls_frame, XV_SHOW, TRUE, NULL) ;
}
static void
xv_save_game(item, value, event) /* Callback load saving a game button. */
Panel_item item ;
--- 1337,1360 ----
Event *event ;
{
position_popup(frame, ls_frame, P_RIGHT) ;
! XV_SET(ls_frame, FRAME_LABEL, "Load Game", 0) ;
! XV_SET(ls_text, PANEL_LABEL_STRING, "Load File: ", 0) ;
! XV_SET(ls_frame, XV_SHOW, TRUE, 0) ;
}
+ /*ARGSUSED*/
+ static void
+ xv_new_game(item, value, event) /* Callback for starting a new game. */
+ Panel_item item ;
+ int value ;
+ Event *event ;
+ {
+ new_game() ;
+ }
+
+
+ /*ARGSUSED*/
static void
xv_save_game(item, value, event) /* Callback load saving a game button. */
Panel_item item ;
***************
*** 1019,1025 ****
Event *event ;
{
position_popup(frame, ls_frame, P_RIGHT) ;
! XV_SET(ls_text, PANEL_LABEL_STRING, "Save File: ", 0) ;
! XV_SET(ls_button, PANEL_LABEL_STRING, "Save", 0) ;
! XV_SET(ls_frame, XV_SHOW, TRUE, NULL) ;
}
--- 1362,1380 ----
Event *event ;
{
position_popup(frame, ls_frame, P_RIGHT) ;
! XV_SET(ls_frame, FRAME_LABEL, "Save Game", 0) ;
! XV_SET(ls_text, PANEL_LABEL_STRING, "Save File: ", 0) ;
! XV_SET(ls_frame, XV_SHOW, TRUE, 0) ;
! }
!
!
! /*ARGSUSED*/
! static void
! xv_set_props(item, value, event) /* Callback props button. */
! Panel_item item ;
! int value ;
! Event *event ;
! {
! position_popup(frame, props_frame, P_RIGHT) ;
! XV_SET(props_frame, XV_SHOW, TRUE, 0) ;
}