2003-11-01 06:35:29 +01:00
|
|
|
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
|
|
|
/*
|
|
|
|
* Copyright 1997 - 2000 by Eric House (fixin@peak.org). All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BOARDP_H_
|
|
|
|
#define _BOARDP_H_
|
|
|
|
|
|
|
|
#include "comtypes.h"
|
|
|
|
#include "model.h"
|
|
|
|
#include "board.h"
|
2004-06-15 03:56:01 +02:00
|
|
|
#include "engine.h"
|
2003-11-01 06:35:29 +01:00
|
|
|
#include "mempool.h" /* debug only */
|
|
|
|
|
|
|
|
#ifdef CPLUS
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct TileDragState {
|
|
|
|
XP_Bool dragInProgress;
|
|
|
|
|
|
|
|
XP_Bool wasHilited;
|
|
|
|
TileBit selectionAtStart;
|
|
|
|
XP_Bool movePending;
|
|
|
|
TileBit prevIndex;
|
|
|
|
} TileDragState;
|
|
|
|
|
|
|
|
typedef struct DividerDragState {
|
|
|
|
XP_Bool dragInProgress;
|
|
|
|
} DividerDragState;
|
|
|
|
|
|
|
|
typedef struct BoardArrow { /* gets flipped along with board */
|
|
|
|
XP_U8 col;
|
|
|
|
XP_U8 row;
|
|
|
|
XP_Bool vert;
|
|
|
|
XP_Bool visible;
|
|
|
|
} BoardArrow;
|
|
|
|
|
|
|
|
#ifdef KEYBOARD_NAV
|
|
|
|
typedef struct BdCursorLoc {
|
|
|
|
XP_U8 col;
|
|
|
|
XP_U8 row;
|
|
|
|
} BdCursorLoc;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* We only need two of these, one for the value hint and the other for the
|
|
|
|
trading window. There's never more than of the former since it lives only
|
|
|
|
as long as the pen is down. There are, in theory, as many trading windows
|
|
|
|
as there are (local) players, but they can all use the same window. */
|
|
|
|
typedef struct MiniWindowStuff {
|
|
|
|
void* closure;
|
|
|
|
unsigned char* text;
|
|
|
|
XP_Rect rect;
|
|
|
|
} MiniWindowStuff;
|
|
|
|
|
|
|
|
enum { MINIWINDOW_VALHINT, MINIWINDOW_TRADING };
|
|
|
|
typedef XP_U16 MiniWindowType; /* one of the two above */
|
|
|
|
|
|
|
|
struct BoardCtxt {
|
|
|
|
/* BoardVTable* vtable; */
|
|
|
|
ModelCtxt* model;
|
|
|
|
ServerCtxt* server;
|
|
|
|
DrawCtx* draw;
|
|
|
|
XW_UtilCtxt* util;
|
|
|
|
|
|
|
|
struct CurGameInfo* gi;
|
|
|
|
|
|
|
|
XP_U16 boardHScale;
|
|
|
|
XP_U16 boardVScale;
|
|
|
|
XP_U16 yOffset;
|
|
|
|
XP_U16 preHideYOffset;
|
|
|
|
XP_U16 prevYScrollOffset; /* represents where the last draw took place;
|
|
|
|
used to see if bit scrolling can be used */
|
|
|
|
XP_U16 penDownX;
|
|
|
|
XP_U16 penDownY;
|
|
|
|
|
|
|
|
XP_U32 timerStoppedTime;
|
|
|
|
XP_U16 timerSaveCount;
|
|
|
|
#ifdef DEBUG
|
|
|
|
XP_S16 timerStoppedTurn;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
XP_U16 redrawFlags[MAX_ROWS];
|
|
|
|
|
|
|
|
XP_Rect boardBounds;
|
|
|
|
|
|
|
|
XP_Time penDownTime;
|
|
|
|
BoardObjectType penDownObject;
|
|
|
|
|
|
|
|
XP_Bool needsDrawing;
|
|
|
|
XP_Bool isFlipped;
|
|
|
|
XP_Bool showGrid;
|
|
|
|
XP_Bool gameOver;
|
|
|
|
XP_Bool leftHanded;
|
|
|
|
XP_Bool badWordRejected;
|
|
|
|
XP_Bool timerPending;
|
|
|
|
XP_Bool disableArrow;
|
|
|
|
|
|
|
|
XP_Bool tradeInProgress[MAX_NUM_PLAYERS];
|
|
|
|
XP_Bool eraseTray;
|
|
|
|
XP_Bool boardObscuresTray;
|
|
|
|
XP_Bool scoreSplitHor; /* how to divide the scoreboard? */
|
|
|
|
|
|
|
|
XP_U16 star_row;
|
|
|
|
|
|
|
|
/* Unless KEYBOARD_NAV is defined, this does not change */
|
|
|
|
BoardObjectType focussed;
|
|
|
|
|
|
|
|
BoardArrow boardArrow[MAX_NUM_PLAYERS];
|
|
|
|
#ifdef KEYBOARD_NAV
|
|
|
|
BdCursorLoc bdCursor[MAX_NUM_PLAYERS];
|
|
|
|
#endif
|
|
|
|
XP_U8 dividerLoc[MAX_NUM_PLAYERS]; /* 0 means left of 0th tile, etc. */
|
|
|
|
|
|
|
|
XP_U8 scoreDims[MAX_NUM_PLAYERS];
|
|
|
|
|
|
|
|
/* scoreboard state */
|
|
|
|
XP_Rect scoreBdBounds;
|
|
|
|
XP_Rect timerBounds;
|
|
|
|
XP_U8 selPlayer; /* which player is selected (!= turn) */
|
|
|
|
XP_U8 remDim; /* width (or ht) of the "rem:" string in scoreboard */
|
|
|
|
|
|
|
|
/* tray state */
|
|
|
|
XP_U8 trayScaleH;
|
|
|
|
XP_U8 trayScaleV;
|
|
|
|
XP_Rect trayBounds;
|
|
|
|
XP_U8 dividerWidth; /* 0 would mean invisible */
|
|
|
|
XP_Bool dividerInvalid;
|
|
|
|
|
|
|
|
XP_Bool scoreBoardInvalid;
|
|
|
|
TileDragState tileDragState;
|
|
|
|
DividerDragState divDragState;
|
|
|
|
|
|
|
|
MiniWindowStuff miniWindowStuff[2];
|
|
|
|
XP_Bool tradingMiniWindowInvalid;
|
|
|
|
|
|
|
|
TileBit trayInvalBits;
|
|
|
|
TileBit traySelBits[MAX_NUM_PLAYERS];
|
|
|
|
#ifdef KEYBOARD_NAV
|
|
|
|
XP_U8 trayCursorLoc[MAX_NUM_PLAYERS];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
XW_TrayVisState trayVisState;
|
|
|
|
XP_Bool penTimerFired;
|
|
|
|
XP_Bool showCellValues;
|
|
|
|
XP_Bool showColors;
|
|
|
|
|
2004-06-15 03:56:01 +02:00
|
|
|
#ifdef XWFEATURE_SEARCHLIMIT
|
|
|
|
XP_U16 hintDragStartCol, hintDragStartRow;
|
|
|
|
XP_U16 hintDragCurCol, hintDragCurRow;
|
|
|
|
XP_Bool hintDragInProgress;
|
|
|
|
|
2004-06-16 06:06:02 +02:00
|
|
|
XP_Bool hasHintRect[MAX_NUM_PLAYERS];
|
|
|
|
HintLimits limits[MAX_NUM_PLAYERS];
|
2004-06-15 03:56:01 +02:00
|
|
|
#endif
|
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
MPSLOT
|
|
|
|
};
|
|
|
|
|
|
|
|
#define valHintMiniWindowActive( board ) \
|
|
|
|
((XP_Bool)((board)->miniWindowStuff[MINIWINDOW_VALHINT].text != NULL))
|
|
|
|
#define MY_TURN(b) ((b)->selPlayer == server_getCurrentTurn( (b)->server ))
|
|
|
|
#define TRADE_IN_PROGRESS(b) ((b)->tradeInProgress[(b)->selPlayer]==XP_TRUE)
|
|
|
|
|
|
|
|
/* tray-related functions */
|
|
|
|
XP_Bool handlePenDownInTray( BoardCtxt* board, XP_U16 x, XP_U16 y );
|
|
|
|
XP_Bool handlePenUpTray( BoardCtxt* board, XP_U16 x, XP_U16 y, XP_Time when );
|
|
|
|
void drawTray( BoardCtxt* board, XP_Bool focussed );
|
|
|
|
TileBit continueTileDrag( BoardCtxt* board, XP_U16 x, XP_U16 y );
|
|
|
|
XP_Bool endTileDrag( BoardCtxt* board, XP_U16 x, XP_U16 y );
|
|
|
|
XP_Bool continueDividerDrag( BoardCtxt* board, XP_U16 x, XP_U16 y );
|
|
|
|
XP_Bool endDividerDrag( BoardCtxt* board, XP_U16 x, XP_U16 y );
|
|
|
|
XP_Bool moveTileToArrowLoc( BoardCtxt* board, XP_U8 index );
|
|
|
|
XP_U16 indexForBits( XP_U8 bits );
|
2004-03-02 06:58:15 +01:00
|
|
|
XP_Bool rectContainsPt( XP_Rect* rect1, XP_S16 x, XP_S16 y );
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_Bool checkRevealTray( BoardCtxt* board );
|
2004-02-12 05:19:27 +01:00
|
|
|
void invalTilesUnderRect( BoardCtxt* board, XP_Rect* rect );
|
|
|
|
XP_Bool rectsIntersect( XP_Rect* rect1, XP_Rect* rect2 );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
#ifdef KEYBOARD_NAV
|
|
|
|
XP_Bool tray_moveCursor( BoardCtxt* board, XP_Key cursorKey );
|
|
|
|
XP_Bool tray_keyAction( BoardCtxt* board );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CPLUS
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|