xwords/xwords4/wasm/main.h

87 lines
2.6 KiB
C
Raw Normal View History

/* -*- compile-command: "cd ../wasm && make main.html -j3"; -*- */
/*
* Copyright 2021 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 _MAIN_H_
#define _MAIN_H_
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include "game.h"
#include "dictmgr.h"
2021-02-02 22:49:27 +01:00
typedef struct _TimerState {
void* closure;
XWTimerReason why;
XWTimerProc proc;
time_t when;
} TimerState;
2021-02-03 04:20:26 +01:00
typedef XP_Bool (*IdleProc)(void* closure);
2021-02-02 23:52:25 +01:00
2021-02-19 04:41:18 +01:00
typedef struct _GameState {
CurGameInfo gi;
XWGame game;
XW_UtilCtxt* util;
XP_U16 saveToken;
char gameKey[64];
} GameState;
typedef struct _Globals {
SDL_Window* window;
SDL_Renderer* renderer;
2021-02-19 04:41:18 +01:00
GameState gs;
VTableMgr* vtMgr;
XW_DUtilCtxt* dutil;
DrawCtx* draw;
DictionaryCtxt* dict;
TransportProcs procs;
CommonPrefs cp;
DictMgrCtxt* dictMgr;
2021-02-10 23:16:22 +01:00
#ifdef MEM_DEBUG
MemPoolCtx* mpool;
2021-02-10 23:16:22 +01:00
#endif
} Globals;
2021-02-02 22:49:27 +01:00
void main_set_timer( Globals* globals, XWTimerReason why, XP_U16 when,
XWTimerProc proc, void* closure );
2021-02-07 21:48:06 +01:00
void main_clear_timer( Globals* globals, XWTimerReason why );
2021-02-02 22:49:27 +01:00
2021-02-02 23:52:25 +01:00
typedef void (*QueryProc)(void* closure, XP_Bool confirmed);
void main_query( Globals* globals, const XP_UCHAR* query,
QueryProc proc, void* closure );
2021-02-03 04:20:26 +01:00
void main_set_idle( Globals* globals, IdleProc proc, void* closure );
2021-02-02 22:49:27 +01:00
2021-02-03 04:20:26 +01:00
void main_alert( Globals* globals, const XP_UCHAR* msg );
2021-02-07 21:48:06 +01:00
void main_gameFromInvite( Globals* globals, const NetLaunchInfo* invite );
void main_onGameMessage( Globals* globals, XP_U32 gameID,
const CommsAddrRec* from, XWStreamCtxt* stream );
2021-02-07 21:48:06 +01:00
void main_sendOnClose( XWStreamCtxt* stream, XWEnv env, void* closure );
2021-02-10 23:16:22 +01:00
void main_playerScoreHeld( Globals* globals, XP_U16 player );
2021-02-13 21:16:09 +01:00
void main_showGameOver( Globals* globals );
2021-02-17 02:22:50 +01:00
void main_showRemaining( Globals* globals );
2021-02-18 03:58:46 +01:00
void main_pickBlank( Globals* globals, int playerNum, int col, int row,
const char** tileFaces, int nTiles );
2021-02-07 21:48:06 +01:00
#endif