1 /* 2 3 eboard - chess client 4 http://www.bergo.eng.br/eboard 5 https://github.com/fbergo/eboard 6 Copyright (C) 2000-2016 Felipe Bergo 7 fbergo/at/gmail/dot/com 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 23 */ 24 25 #ifndef EBOARD_H 26 #define EBOARD_H 1 27 28 #include <iostream> 29 #include <gtk/gtk.h> 30 #include "config.h" 31 32 #define EMPTY 0x00 33 #define BLACK 0x10 34 #define WHITE 0x20 35 36 #define ROOK 0x01 37 #define KNIGHT 0x02 38 #define BISHOP 0x03 39 #define QUEEN 0x04 40 #define KING 0x05 41 #define PAWN 0x06 42 43 // to keep track of promoted pieces in zhouse 44 #define WASPAWN 0x40 45 46 // Not A Piece -- I mean it :-) 47 #define NotAPiece 0x0e 48 49 #define PIECE_MASK 0x0f 50 #define COLOR_MASK 0x30 51 #define CUTFLAGS 0x3f 52 53 typedef short int piece; 54 typedef unsigned char * rgbptr; 55 typedef unsigned char hati; 56 57 class Protocol; 58 class EngineProtocol; 59 class EngineBookmark; 60 class NetConnection; 61 62 class PieceProvider { 63 public: 64 virtual piece getPiece()=0; 65 }; 66 67 class InputHandler { 68 public: 69 virtual void setPasswordMode(int pm)=0; 70 virtual void userInput(const char *text)=0; 71 virtual void peekKeys(GtkWidget *who)=0; 72 virtual int keyPressed(int keyval, int state)=0; 73 virtual void updatePrefix()=0; 74 }; 75 76 class ConnectionHandler { 77 public: 78 virtual void openServer(const char *host,int port, 79 Protocol *protocol,const char *helper)=0; 80 virtual void openServer(NetConnection *conn, Protocol *protocol)=0; 81 virtual void openEngine(EngineProtocol *protocol, EngineBookmark *bm)=0; 82 }; 83 84 class UpdateInterface { 85 public: 86 virtual void update()=0; 87 }; 88 89 class IONotificationInterface { 90 public: 91 virtual void readAvailable(int handle)=0; 92 virtual void writeAvailable(int handle)=0; 93 }; 94 95 class MoveListListener { 96 public: 97 virtual void moveListClosed()=0; 98 }; 99 100 class GameListListener { 101 public: 102 virtual void gameListClosed()=0; 103 }; 104 105 class StockListListener { 106 public: 107 virtual void stockListClosed()=0; 108 }; 109 110 class AdListListener { 111 public: 112 virtual void adListClosed()=0; 113 }; 114 115 class ConsoleListener { 116 public: 117 virtual void consoleClosed()=0; 118 }; 119 120 class GameListConsumer { 121 public: 122 virtual void appendGame(int gamenum, char *desc)=0; 123 virtual void endOfList()=0; 124 }; 125 126 class PaneChangeListener { 127 public: 128 virtual void paneChanged(int pgseq,int pgid)=0; 129 }; 130 131 class SigChildHandler { 132 public: 133 virtual void ZombieNotification(int pid)=0; 134 }; 135 136 class BookmarkListener { 137 public: 138 virtual void updateBookmarks()=0; 139 }; 140 141 class PieceChangeListener { 142 public: 143 virtual void pieceSetChanged()=0; 144 }; 145 146 typedef enum { 147 REGULAR, 148 CRAZYHOUSE, 149 SUICIDE, 150 BUGHOUSE, 151 WILD, 152 LOSERS, 153 GIVEAWAY, 154 ATOMIC, 155 WILDFR, 156 WILDCASTLE, 157 WILDNOCASTLE, 158 } variant; 159 160 #define IS_WILD(v) (((v)==WILD)||((v)==WILDFR)||((v)==WILDCASTLE)||((v)==WILDNOCASTLE)) 161 #define IS_NOT_WILD(v) (((v)!=WILD)&&((v)!=WILDFR)&&((v)!=WILDCASTLE)&&((v)!=WILDNOCASTLE)) 162 163 typedef enum { 164 WHITE_WIN, 165 BLACK_WIN, 166 DRAW, 167 UNDEF 168 } GameResult; 169 170 typedef enum { 171 IM_ZERO=0, 172 IM_IGNORE=1, 173 IM_NORMAL=2, 174 IM_PERSONAL=3, 175 IM_TOP=4, 176 IM_RESET=5, 177 } Importance; 178 179 #define CLOCK_UNCHANGED (-100000000) 180 181 // number of configurable fonts 182 #define NFONTS 5 183 184 #define DEFAULT_FONT_CLOK "Sans Bold 26" 185 #define DEFAULT_FONT_PLYR "Sans 14" 186 #define DEFAULT_FONT_INFO "Sans 10" 187 #define DEFAULT_FONT_CONS "Bitstream Vera Sans Mono 10" 188 #define DEFAULT_FONT_SEEK "Sans 10" 189 190 191 typedef enum { 192 EF_PlayerFont, 193 EF_ClockFont, 194 EF_InfoFont 195 } EboardFont; 196 197 typedef enum { 198 GS_PGN_File, 199 GS_ICS, 200 GS_Engine, 201 GS_Other=99 202 } GameSource; 203 204 typedef enum { 205 TC_SPM = 0, /* seconds per move */ 206 TC_ICS = 1, /* time+increment */ 207 TC_XMOVES = 2, /* X moves in Y minutes */ 208 TC_NONE = 99, /* don't set, use engine's default */ 209 } TimeControlMode; 210 211 #define N_SOUND_EVENTS 10 212 213 /* i18n placeholders in case gettext isn't available*/ 214 215 #ifdef ENABLE_NLS 216 #include "langs.h" 217 #define _(s) langs_translate(s) 218 #define N_(s) (s) 219 #define eboard_gettext(s) langs_translate(s) 220 #else 221 #define _(s) (s) 222 #define N_(s) (s) 223 #define eboard_gettext(x) (x) 224 #endif 225 226 // gtk simplifications (code looks cleaner this way, especially dlg_prefs.cc) 227 228 #define gshow gtk_widget_show 229 #define gtset gtk_toggle_button_set_active 230 #define gtget gtk_toggle_button_get_active 231 #define grnew gtk_radio_button_new_with_label 232 #define grg gtk_radio_button_group 233 #define gmiset gtk_check_menu_item_set_active 234 235 #endif 236