2003-11-01 06:35:29 +01:00
|
|
|
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
|
|
|
/*
|
2010-04-08 06:14:34 +02:00
|
|
|
* Copyright 1997 - 2010 by Eric House (xwords@eehouse.org). All rights reserved.
|
2003-11-01 06:35:29 +01:00
|
|
|
*
|
|
|
|
* 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 __BOARD_H__
|
|
|
|
#define __BOARD_H__
|
|
|
|
|
|
|
|
#include "comtypes.h"
|
|
|
|
#include "model.h"
|
2013-11-03 21:12:25 +01:00
|
|
|
#include "gameinfo.h"
|
2003-11-01 06:35:29 +01:00
|
|
|
#include "server.h"
|
|
|
|
#include "draw.h"
|
|
|
|
#include "xwstream.h"
|
|
|
|
|
|
|
|
#ifdef CPLUS
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
/* keep these three together: for the cursor */
|
2007-01-06 18:32:08 +01:00
|
|
|
XP_KEY_NONE = 0,
|
2006-11-17 14:41:13 +01:00
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_CURSOR_KEY_DOWN,
|
2006-11-17 14:41:13 +01:00
|
|
|
XP_CURSOR_KEY_ALTDOWN,
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_CURSOR_KEY_RIGHT,
|
2006-11-17 14:41:13 +01:00
|
|
|
XP_CURSOR_KEY_ALTRIGHT,
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_CURSOR_KEY_UP,
|
2006-11-17 14:41:13 +01:00
|
|
|
XP_CURSOR_KEY_ALTUP,
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_CURSOR_KEY_LEFT,
|
2006-11-17 14:41:13 +01:00
|
|
|
XP_CURSOR_KEY_ALTLEFT,
|
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_CURSOR_KEY_DEL,
|
2006-11-09 07:05:40 +01:00
|
|
|
XP_RAISEFOCUS_KEY,
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_RETURN_KEY,
|
2020-01-27 07:12:36 +01:00
|
|
|
XP_ALTRETURN_KEY,
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
XP_KEY_LAST
|
|
|
|
} XP_Key;
|
|
|
|
|
2008-05-31 05:26:16 +02:00
|
|
|
#define BONUS_HINT_INTERVAL 15 /* stolen from xwords.c */
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
/* typedef struct BoardCtxt BoardCtxt; */
|
|
|
|
|
2020-04-26 20:28:18 +02:00
|
|
|
BoardCtxt* board_make( MPFORMAL XWEnv xwe, ModelCtxt* model, ServerCtxt* server,
|
2006-11-03 07:23:54 +01:00
|
|
|
DrawCtx* draw, XW_UtilCtxt* util );
|
2020-04-26 20:28:18 +02:00
|
|
|
BoardCtxt* board_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
2003-11-01 06:35:29 +01:00
|
|
|
ModelCtxt* model, ServerCtxt* server,
|
|
|
|
DrawCtx* draw, XW_UtilCtxt* util,
|
|
|
|
XP_U16 nPlayers );
|
2020-04-26 20:28:18 +02:00
|
|
|
void board_setCallbacks( BoardCtxt* board, XWEnv xwe );
|
2020-04-25 23:19:23 +02:00
|
|
|
void board_setDraw( BoardCtxt* board, XWEnv xwe, DrawCtx* draw );
|
2016-08-05 18:42:55 +02:00
|
|
|
DrawCtx* board_getDraw( const BoardCtxt* board );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2020-04-26 20:28:18 +02:00
|
|
|
void board_destroy( BoardCtxt* board, XWEnv xwe, XP_Bool ownsUtil );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2012-03-12 02:28:14 +01:00
|
|
|
void board_writeToStream( const BoardCtxt* board, XWStreamCtxt* stream );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2020-04-26 20:28:18 +02:00
|
|
|
void board_reset( BoardCtxt* board, XWEnv xwe );
|
2013-11-03 21:12:25 +01:00
|
|
|
|
2020-04-25 23:19:23 +02:00
|
|
|
void board_drawSnapshot( const BoardCtxt* board, XWEnv xwe, DrawCtx* dctx,
|
2016-08-05 19:23:39 +02:00
|
|
|
XP_U16 width, XP_U16 height );
|
|
|
|
|
2013-11-03 21:12:25 +01:00
|
|
|
/* Layout. Either done internally or by client */
|
|
|
|
#ifdef COMMON_LAYOUT
|
|
|
|
|
|
|
|
typedef struct _BoardDims {
|
2013-11-16 05:46:22 +01:00
|
|
|
/* The whole board */
|
2013-11-03 21:12:25 +01:00
|
|
|
XP_U16 left, top;
|
|
|
|
XP_U16 width, height;
|
2014-07-18 06:31:17 +02:00
|
|
|
|
2013-11-16 05:46:22 +01:00
|
|
|
/* board */
|
|
|
|
XP_U16 boardWidth, boardHt;
|
2014-07-18 06:31:17 +02:00
|
|
|
|
|
|
|
/* scoreboard */
|
|
|
|
XP_U16 scoreLeft, scoreWidth, scoreHt;
|
|
|
|
|
2014-07-17 17:01:00 +02:00
|
|
|
/* tray */
|
|
|
|
XP_U16 trayLeft, trayTop, trayWidth, trayHt;
|
2021-07-16 20:50:05 +02:00
|
|
|
XP_U16 traySize;
|
2014-07-18 06:31:17 +02:00
|
|
|
|
2013-11-16 05:46:22 +01:00
|
|
|
/* other */
|
2013-11-03 21:12:25 +01:00
|
|
|
XP_U16 cellSize, maxCellSize;
|
|
|
|
XP_U16 timerWidth;
|
|
|
|
} BoardDims;
|
|
|
|
|
2020-04-26 20:28:18 +02:00
|
|
|
void board_figureLayout( BoardCtxt* board, XWEnv xwe, const CurGameInfo* gi,
|
|
|
|
XP_U16 bLeft, XP_U16 bTop, XP_U16 bWidth, XP_U16 bHeight,
|
2016-09-16 05:37:29 +02:00
|
|
|
XP_U16 colPctMax, XP_U16 scorePct, XP_U16 trayPct,
|
|
|
|
XP_U16 scoreWidth, XP_U16 fontWidth, XP_U16 fontHt,
|
|
|
|
XP_Bool squareTiles, /* out */ BoardDims* dimsp );
|
2020-04-26 20:28:18 +02:00
|
|
|
void board_applyLayout( BoardCtxt* board, XWEnv xwe, const BoardDims* dims );
|
2013-11-03 21:12:25 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* These four aren't needed if COMMON_LAYOUT defined */
|
2024-01-02 00:56:41 +01:00
|
|
|
#ifndef COMMON_LAYOUT
|
2020-04-26 20:28:18 +02:00
|
|
|
void board_setPos( BoardCtxt* board, XWEnv xwe, XP_U16 left, XP_U16 top,
|
2010-06-02 06:58:32 +02:00
|
|
|
XP_U16 width, XP_U16 height, XP_U16 maxCellSize,
|
|
|
|
XP_Bool leftHanded );
|
2013-11-03 21:12:25 +01:00
|
|
|
void board_setScoreboardLoc( BoardCtxt* board,
|
|
|
|
XP_U16 scoreLeft, XP_U16 scoreTop,
|
|
|
|
XP_U16 scoreWidth, XP_U16 scoreHeight,
|
|
|
|
XP_Bool divideHorizontally );
|
2020-04-26 20:28:18 +02:00
|
|
|
void board_setTrayLoc( BoardCtxt* board, XWEnv xwe,
|
|
|
|
XP_U16 trayLeft, XP_U16 trayTop,
|
2021-07-16 20:50:05 +02:00
|
|
|
XP_U16 trayWidth, XP_U16 trayHeight, XP_U16 nTiles );
|
2024-01-02 00:56:41 +01:00
|
|
|
#endif
|
2013-11-03 21:12:25 +01:00
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
/* Vertical scroll support; offset is in rows, not pixels */
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_setYOffset( BoardCtxt* board, XWEnv xwe, XP_U16 newOffset );
|
2008-03-29 21:23:27 +01:00
|
|
|
XP_U16 board_getYOffset( const BoardCtxt* board );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2011-10-05 15:36:01 +02:00
|
|
|
XP_Bool board_curTurnSelected( const BoardCtxt* board );
|
2010-07-08 15:38:51 +02:00
|
|
|
XP_U16 board_visTileCount( const BoardCtxt* board );
|
2020-04-26 02:47:07 +02:00
|
|
|
void board_pause( BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg );
|
|
|
|
void board_unpause( BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg );
|
2010-07-02 03:55:49 +02:00
|
|
|
XP_Bool board_canShuffle( const BoardCtxt* board );
|
2013-11-17 22:54:21 +01:00
|
|
|
XP_Bool board_canHideRack( const BoardCtxt* board );
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_canTrade( BoardCtxt* board, XWEnv xwe );
|
2010-07-03 20:38:37 +02:00
|
|
|
XP_Bool board_canTogglePending( const BoardCtxt* board );
|
2010-07-08 03:47:02 +02:00
|
|
|
XP_Bool board_canHint( const BoardCtxt* board );
|
2021-03-24 23:58:25 +01:00
|
|
|
#ifdef XWFEATURE_CHAT
|
2020-04-26 02:47:07 +02:00
|
|
|
void board_sendChat( const BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg );
|
2021-03-24 23:58:25 +01:00
|
|
|
#endif
|
2010-06-05 05:40:23 +02:00
|
|
|
/* zoomBy: >0: zoom in; < 0: zoom out; 0: query only */
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_zoom( BoardCtxt* board, XWEnv xwe, XP_S16 zoomBy, XP_Bool* canInOut );
|
2010-04-08 06:14:14 +02:00
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
void board_invalAll( BoardCtxt* board );
|
2005-01-23 09:17:37 +01:00
|
|
|
void board_invalRect( BoardCtxt* board, XP_Rect* rect );
|
2013-10-28 05:51:30 +01:00
|
|
|
#ifdef XWFEATURE_ACTIVERECT
|
2013-10-29 15:50:12 +01:00
|
|
|
XP_Bool board_getActiveRect( const BoardCtxt* board, XP_Rect* rect,
|
|
|
|
XP_U16* nCols, XP_U16* nRows );
|
2013-10-28 05:51:30 +01:00
|
|
|
#endif
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2020-04-25 23:19:23 +02:00
|
|
|
XP_Bool board_draw( BoardCtxt* board, XWEnv xwe );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2008-11-10 17:01:46 +01:00
|
|
|
XP_Bool board_get_flipped( const BoardCtxt* board );
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_Bool board_flip( BoardCtxt* board );
|
2011-09-10 04:04:25 +02:00
|
|
|
XP_Bool board_inTrade( const BoardCtxt* board, XP_Bool* anySelected );
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_replaceTiles( BoardCtxt* board, XWEnv xwe );
|
|
|
|
XP_Bool board_redoReplacedTiles( BoardCtxt* board, XWEnv xwe );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2016-03-06 15:34:49 +01:00
|
|
|
XP_U16 board_getSelPlayer(const BoardCtxt* board );
|
|
|
|
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_passwordProvided( BoardCtxt* board, XWEnv xwe,
|
|
|
|
XP_U16 player, const XP_UCHAR* pass );
|
2017-02-17 15:23:44 +01:00
|
|
|
|
2020-04-25 23:19:23 +02:00
|
|
|
XP_Bool board_requestHint( BoardCtxt* board, XWEnv xwe,
|
2004-06-25 08:47:35 +02:00
|
|
|
#ifdef XWFEATURE_SEARCHLIMIT
|
|
|
|
XP_Bool useTileLimits,
|
|
|
|
#endif
|
2010-07-07 14:27:57 +02:00
|
|
|
XP_Bool usePrev, XP_Bool* workRemainsP );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2015-07-07 05:23:22 +02:00
|
|
|
XP_Bool board_prefsChanged( BoardCtxt* board, const CommonPrefs* cp );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
BoardObjectType board_getFocusOwner( BoardCtxt* board );
|
|
|
|
|
2020-04-25 23:19:23 +02:00
|
|
|
void board_hiliteCellAt( BoardCtxt* board, XWEnv xwe, XP_U16 col, XP_U16 row );
|
2017-02-19 04:16:32 +01:00
|
|
|
XP_Bool board_setBlankValue( BoardCtxt* board, XP_U16 XP_UNUSED(player),
|
|
|
|
XP_U16 col, XP_U16 row, XP_U16 tileIndex );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
void board_resetEngine( BoardCtxt* board );
|
|
|
|
|
2020-04-26 02:47:07 +02:00
|
|
|
XP_Bool board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed,
|
2017-03-10 05:36:14 +01:00
|
|
|
XP_Bool turnConfirmed, TrayTileSet* newTiles );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2020-04-26 20:28:18 +02:00
|
|
|
void board_pushTimerSave( BoardCtxt* board, XWEnv xwe );
|
|
|
|
void board_popTimerSave( BoardCtxt* board, XWEnv xwe );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2020-04-26 20:28:18 +02:00
|
|
|
void board_formatRemainingTiles( BoardCtxt* board, XWEnv xwe,
|
|
|
|
XWStreamCtxt* stream );
|
2004-11-06 03:54:25 +01:00
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
#ifdef POINTER_SUPPORT
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_handlePenDown( BoardCtxt* board, XWEnv xwe, XP_U16 xx,
|
|
|
|
XP_U16 yy, XP_Bool* handled );
|
|
|
|
XP_Bool board_handlePenMove( BoardCtxt* board, XWEnv xwe, XP_U16 x, XP_U16 y );
|
2020-04-26 02:47:07 +02:00
|
|
|
XP_Bool board_handlePenUp( BoardCtxt* board, XWEnv xwe, XP_U16 x, XP_U16 y );
|
2016-08-16 02:26:10 +02:00
|
|
|
XP_Bool board_containsPt( const BoardCtxt* board, XP_U16 xx, XP_U16 yy );
|
2003-11-01 06:35:29 +01:00
|
|
|
#endif
|
|
|
|
|
2007-01-07 02:01:20 +01:00
|
|
|
#ifdef KEY_SUPPORT
|
2020-04-26 02:47:07 +02:00
|
|
|
XP_Bool board_handleKey( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2020-04-26 02:47:07 +02:00
|
|
|
XP_Bool board_handleKeyUp( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled );
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_handleKeyDown( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled );
|
2020-04-26 02:47:07 +02:00
|
|
|
XP_Bool board_handleKeyRepeat( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled );
|
2010-07-09 15:49:32 +02:00
|
|
|
# ifdef KEYBOARD_NAV
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_focusChanged( BoardCtxt* board, XWEnv xwe, BoardObjectType typ,
|
2006-11-03 07:23:54 +01:00
|
|
|
XP_Bool gained );
|
2007-01-07 02:01:20 +01:00
|
|
|
# endif
|
2003-11-01 06:35:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/******************** Tray methods ********************/
|
|
|
|
#define NO_TILES ((TileBit)0)
|
|
|
|
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_hideTray( BoardCtxt* board, XWEnv xwe );
|
|
|
|
XP_Bool board_showTray( BoardCtxt* board, XWEnv xwe );
|
2008-11-10 17:01:46 +01:00
|
|
|
XW_TrayVisState board_getTrayVisState( const BoardCtxt* board );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
void board_invalTrayTiles( BoardCtxt* board, TileBit what );
|
2020-04-26 20:28:18 +02:00
|
|
|
XP_Bool board_juggleTray( BoardCtxt* board, XWEnv xwe );
|
|
|
|
XP_Bool board_beginTrade( BoardCtxt* board, XWEnv xwe );
|
2011-03-11 03:13:56 +01:00
|
|
|
XP_Bool board_endTrade( BoardCtxt* board );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2008-10-11 18:46:08 +02:00
|
|
|
#if defined FOR_GREMLINS
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_Bool board_moveDivider( BoardCtxt* board, XP_Bool right );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CPLUS
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|