1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
/*
* $Source: /cvsroot/cgoban1/cgoban1/src/goban.h,v $
* $Revision: 1.2 $
* $Date: 2002/02/28 03:34:35 $
*
* src/goban.h, part of Complete Goban (game program)
* Copyright (C) 1995 William Shubert.
* See "configure.h.in" for more copyright information.
*/
#ifndef _GOBAN_H_
#define _GOBAN_H_ 1
#ifndef _ABUT_TERM_H_
#include <abut/term.h>
#endif
#ifndef _GOGAME_H_
#include "goGame.h"
#endif
#ifndef _GOPIC_H_
#include "goPic.h"
#endif
#ifndef _GOSCORE_H_
#include "goScore.h"
#endif
#ifndef _ABUT_MSG_H_
#include <abut/msg.h>
#endif
/**********************************************************************
* Data types
**********************************************************************/
typedef enum {
gobanOut_draw, gobanOut_noDraw, gobanOut_err
} GobanOut;
typedef struct GobanActions_struct {
/*
* Callbacks when buttons are pressed. Returns TRUE if you have to
* update the grid afterwards.
*/
GobanOut (*gridPressed)(void *packet, int loc);
GobanOut (*quitPressed)(void *packet);
GobanOut (*passPressed)(void *packet);
GobanOut (*rewPressed)(void *packet);
GobanOut (*backPressed)(void *packet);
GobanOut (*fwdPressed)(void *packet);
GobanOut (*ffPressed)(void *packet);
GobanOut (*donePressed)(void *packet);
GobanOut (*disputePressed)(void *packet);
GobanOut (*savePressed)(void *packet);
GobanOut (*editPressed)(void *packet);
GobanOut (*gameInfoPressed)(void *packet);
Help *helpInfo;
/*
* Called when goban_destroy is called with propagate set to TRUE, or
* when the window is suddenly destroyed.
*/
void (*destroyCallback)(void *packet);
/* Returns TRUE if the specified button should be pressable. */
bool (*rewOk)(void *packet);
bool (*backOk)(void *packet);
bool (*fwdOk)(void *packet);
bool (*ffwdOk)(void *packet);
} GobanActions;
typedef struct GobanPlayerInfo_struct {
But *box, *stones[5], *capsLabel, *capsOut, *timeLabel, *timeOut;
But *capsBox, *timeBox;
} GobanPlayerInfo;
typedef struct Goban_struct {
Cgoban *cg;
const GobanActions *actions;
void *packet;
bool propagateDestroy;
GoGame *game;
GoTimer timers[2];
GoStone activeTimer;
GoScore score;
int ingTimePenalties[2];
int lastMove;
float lastScores[2];
ClpEntry *bProp, *bPropW, *clpX, *clpY;
ButWin *win;
But *bg;
But *labelBox, *labelText;
But *infoText;
But *gameInfo;
But *help;
AbutTerm *comments;
But *kibIn, *kibType, *kibSay, *kibBoth, *kibKib;
GobanOut (*newKib)(void *packet, const char *txt);
But *pass;
But *resume;
But *done;
GobanPlayerInfo playerInfos[2];
But *save;
But *edit;
But *quit;
But *rew, *back, *fwd, *ff;
GoPic *pic;
But *boardBox;
ButWin *iWin;
But *iBg, *iBoard, *iDec1, *iDec2; /* Icon Decorations. */
AbutMsg *msgBox;
ButTimer *clock;
MAGIC_STRUCT
} Goban;
/**********************************************************************
* Functions
**********************************************************************/
extern Goban *goban_create(Cgoban *cg, const GobanActions *actions,
void *packet, GoGame *game, const char *bPropName,
const char *title);
#define goban_setTitle(g, n) butText_set((g)->labelText, (n))
#define goban_getComments(g) abutTerm_get((g)->comments)
#define goban_setComments(g, c) abutTerm_set((g)->comments, (c))
#define goban_catComments(g, c) butTbin_insert((g)->comments->tbin, (c))
extern void goban_destroy(Goban *g, bool propagate);
extern void goban_message(Goban *g, const char *message);
extern void goban_noMessage(Goban *g);
extern void goban_update(Goban *g);
extern void goban_startTimer(Goban *g, GoStone whose);
/* stopTimer returns TRUE if there is still time left. */
extern bool goban_stopTimer(Goban *g);
#define goban_setHold(g, h) goPic_setButHold((g)->pic, h)
#define goban_score(g, p) ((g)->score.scores[p] - (g)->ingTimePenalties[p])
#define goban_dame(g) ((g)->score.dame)
#define goban_territory(g, p) ((g)->score.territories[p])
#define goban_livingStones(g, p) ((g)->score.livingStones[p])
#define goban_caps(g, p) (goGame_caps((g)->game, p) + \
(g)->score.deadStones[p])
extern void goban_setKibitz(Goban *g, GobanOut (*newKib)(void *packet,
const char *txt),
int kibVal);
#define goban_kibType(g) butRadio_get((g)->kibType)
extern void goban_updateTimeReadouts(Goban *g);
#endif /* _GOBAN_H_ */
|