2006-06-07 03:26:04 +02:00
|
|
|
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
|
|
|
/*
|
|
|
|
* Copyright 1997 - 2006 by Eric House (xwords@eehouse.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 _NWGAMEST_H_
|
|
|
|
#define _NWGAMEST_H_
|
|
|
|
|
|
|
|
/* The new game/game info dialog is complicated, especially in non
|
|
|
|
* XWFEATURE_STANDALONE_ONLY case. The number of rows must be changed
|
|
|
|
* as the number of players changes, and whether the password field is
|
|
|
|
* enabled changes with the robot status etc. This file encapsulates
|
|
|
|
* all that logic, reducint the platform's role to reporting UI events
|
|
|
|
* and reflecting state changes, as reported by callbacks, in the
|
|
|
|
* platform's widgets.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "comtypes.h"
|
|
|
|
EXTERN_C_START
|
|
|
|
|
|
|
|
#include "mempool.h"
|
|
|
|
#include "server.h"
|
|
|
|
#include "comms.h"
|
2006-06-10 07:45:53 +02:00
|
|
|
#include "util.h"
|
2006-06-07 03:26:04 +02:00
|
|
|
#include "game.h"
|
|
|
|
|
|
|
|
typedef struct NewGameCtx NewGameCtx;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
2006-06-08 03:51:34 +02:00
|
|
|
NG_COL_REMOTE,
|
2006-06-07 03:26:04 +02:00
|
|
|
#endif
|
2006-06-08 03:51:34 +02:00
|
|
|
NG_COL_NAME
|
2006-06-07 03:26:04 +02:00
|
|
|
,NG_COL_ROBOT
|
|
|
|
,NG_COL_PASSWD
|
|
|
|
} NewGameColumn;
|
|
|
|
|
|
|
|
typedef enum {
|
2006-06-10 07:45:53 +02:00
|
|
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
|
|
|
NG_ATTR_ROLE,
|
2009-03-08 20:54:14 +01:00
|
|
|
NG_ATTR_CANCONFIG,
|
2006-06-10 07:45:53 +02:00
|
|
|
NG_ATTR_REMHEADER,
|
|
|
|
#endif
|
2006-06-07 03:26:04 +02:00
|
|
|
NG_ATTR_NPLAYERS
|
2006-06-10 07:45:53 +02:00
|
|
|
,NG_ATTR_NPLAYHEADER
|
2006-06-18 21:02:47 +02:00
|
|
|
,NG_ATTR_CANJUGGLE
|
2006-06-07 03:26:04 +02:00
|
|
|
} NewGameAttr;
|
|
|
|
|
|
|
|
typedef union NGValue {
|
|
|
|
const XP_UCHAR* ng_cp;
|
|
|
|
XP_U16 ng_u16;
|
|
|
|
XP_Bool ng_bool;
|
2007-02-02 09:34:37 +01:00
|
|
|
DeviceRole ng_role;
|
2006-06-07 03:26:04 +02:00
|
|
|
} NGValue;
|
|
|
|
|
|
|
|
/* Enable or disable (show or hide) controls */
|
|
|
|
typedef void (*NewGameEnableColProc)( void* closure, XP_U16 player,
|
2006-10-28 15:21:32 +02:00
|
|
|
NewGameColumn col, XP_TriEnable enable );
|
2006-06-07 03:26:04 +02:00
|
|
|
typedef void (*NewGameEnableAttrProc)( void* closure, NewGameAttr attr,
|
2006-10-28 15:21:32 +02:00
|
|
|
XP_TriEnable enable );
|
2006-06-07 03:26:04 +02:00
|
|
|
/* Get the contents of a control. Type of param "value" is either
|
|
|
|
boolean or char* */
|
2006-06-07 03:45:03 +02:00
|
|
|
typedef void (*NgCpCallbk)( NGValue value, const void* cpClosure );
|
2006-06-07 03:26:04 +02:00
|
|
|
typedef void (*NewGameGetColProc)( void* closure, XP_U16 player,
|
2006-06-07 03:45:03 +02:00
|
|
|
NewGameColumn col,
|
|
|
|
NgCpCallbk cpcb, const void* cbClosure );
|
2006-06-07 03:26:04 +02:00
|
|
|
/* Set the contents of a control. Type of param "value" is either
|
|
|
|
boolean or char* */
|
|
|
|
typedef void (*NewGameSetColProc)( void* closure, XP_U16 player,
|
|
|
|
NewGameColumn col, const NGValue value );
|
|
|
|
|
|
|
|
typedef void (*NewGameSetAttrProc)(void* closure, NewGameAttr attr,
|
|
|
|
const NGValue value );
|
|
|
|
|
|
|
|
|
2006-06-07 03:45:03 +02:00
|
|
|
NewGameCtx* newg_make( MPFORMAL XP_Bool isNewGame,
|
2006-06-10 07:45:53 +02:00
|
|
|
XW_UtilCtxt* util,
|
2006-06-07 03:45:03 +02:00
|
|
|
NewGameEnableColProc enableColProc,
|
|
|
|
NewGameEnableAttrProc enableAttrProc,
|
|
|
|
NewGameGetColProc getColProc,
|
|
|
|
NewGameSetColProc setColProc,
|
|
|
|
NewGameSetAttrProc setAttrProc,
|
|
|
|
void* closure );
|
|
|
|
void newg_destroy( NewGameCtx* ngc );
|
2006-06-07 03:26:04 +02:00
|
|
|
|
2006-06-07 03:45:03 +02:00
|
|
|
void newg_load( NewGameCtx* ngc, const CurGameInfo* gi );
|
2008-01-04 15:47:52 +01:00
|
|
|
XP_Bool newg_store( NewGameCtx* ngc, CurGameInfo* gi, XP_Bool warn );
|
2006-06-07 03:26:04 +02:00
|
|
|
|
2006-08-16 15:44:44 +02:00
|
|
|
void newg_colChanged( NewGameCtx* ngc, XP_U16 player );
|
2006-06-07 03:45:03 +02:00
|
|
|
void newg_attrChanged( NewGameCtx* ngc, NewGameAttr attr,
|
|
|
|
NGValue value );
|
2006-06-07 03:26:04 +02:00
|
|
|
|
2006-06-29 05:38:25 +02:00
|
|
|
/** newg_juggle: Return XP_TRUE if a juggle happened, XP_FALSE if randomness
|
|
|
|
* dictated that all players stay put. Platforms can call repeatedly until
|
|
|
|
* true if they want to force change.
|
|
|
|
*/
|
|
|
|
XP_Bool newg_juggle( NewGameCtx* ngc );
|
2006-06-07 03:26:04 +02:00
|
|
|
|
|
|
|
EXTERN_C_END
|
|
|
|
|
|
|
|
#endif /* _NWGAMEST_H_ */
|