📄 gui.h
字号:
/* $Header: /home/jcb/newmj/RCS/gui.h,v 11.29 2003/04/16 22:28:58 jcb Rel $ * gui.h * type defns and forward declarations for the gui module. *//****************** COPYRIGHT STATEMENT ********************** * This file is Copyright (c) 2000 by J. C. Bradfield. * * Distribution and use is governed by the LICENCE file that * * accompanies this file. * * The moral rights of the author are asserted. * * * ***************** DISCLAIMER OF WARRANTY ******************** * This code is not warranted fit for any purpose. See the * * LICENCE file for further information. * * * *************************************************************/#include <gtk/gtk.h>#include <gdk/gdkkeysyms.h>#include "lazyfixed.h"#include "vlazyfixed.h"#include "sysdep.h"#include <errno.h>#include "client.h"#include <math.h>/********************* TYPE DEFINITIONS*********************//* a tilesetbox is a TileSet and a widget that boxes it. The TileSet is stored to avoid unnecessary updating of the box*/typedef struct _TileSetBox { TileSet set; GtkWidget *widget; /* the widget itself */ GtkWidget *tiles[4]; /* the children buttons */} TileSetBox;/* This struct represents the display of a player. It gives access to relevant widgets without requiring excessive casting and pointer chasing.*/typedef struct _PlayerDisp { PlayerP player; /* pointer to the game player structure */ /* this is the whole box representing the player */ GtkWidget *widget; /* the orientation says which way round tiles go (equivalently, which player we are in the table). The tilepixmaps are those appropriate assuming that players look at their own tiles. If the players politely display their sets to be readable by the others, then the orientation of exposed tiles is flipped from these. that the orientations are: 0: upright (for our own tiles) 1: top to left: player to the right (south, when we're east) 2: upside down (player opposite) 3: top to right (north). */ int orientation; /* and accordingly the following macro can be used if concealed and exposed tiles are oriented differently */ /* # define flipori(ori) ((ori+2)%4) */#define flipori(ori) ori /* this is an array of buttons representing the concealed tiles. For initial size calculation, it should be filled with blanks. (Ideally, unmapped, but I can't see how to do that.) They appear from the left in the "concealed" row. */ GtkWidget *conc[MAX_CONCEALED]; /* This is an array representing the declared specials that have overflowed into the concealed row. Initially, exactly five of these should be shown: that makes the whole "concealed" row 19 tiles wide, which gives enough room for reasonable collections of specials, and makes the "exposed" row big enough for four kongs and a pair. They appear to the right of the concealed row. */ GtkWidget *extras[8]; /* These are the specials that have found room where we want them, at the end of the exposed row */ GtkWidget *spec[8]; /* each of these is a box representing a declared set. Each set is packed into the exposed row, from the left, with a 1/4 tile spacing between them (thus fitting 4 kongs and a pair in exactly). Size is determined by the concealed row, so there is no need to show these initially. */ /* This is the tong box. It appears to the right of the exposed row specials*/ GtkWidget *tongbox; TileSetBox esets[MAX_TILESETS]; /* each of these is a box representing a concealed set. They appear to the left of the concealed tile set, with the 1/4 tile spacing. They are initially hidden, and appear only in scoring. */ TileSetBox csets[MAX_TILESETS]; /* these is not actually in the player area, but to do with discards */ GtkWidget *discards[32]; /* buttons for this player's discards */ int dx[32], dy[32]; /* save calculated posns of discard tiles */ int num_discards; gint16 x,y; /* x and y for next discard */ int row; /* which row is next discard in */ gint16 xmin[5],xmax[5]; /* in each row, first point used, leftmost point free*/ int plane; /* if desperate, we start stacking tiles */ /* This is the window for pung! claims etc. */ GtkWidget *claimw; GtkWidget *claimlab; /* and the label inside it */ int claim_serial; /* the discard for which this window was popped up */ int claim_time; /* time popped up (in millisecs since start of program) */} PlayerDisp;/* This is a one use structure representing the dialog box used for claiming discards. It has two personalities: normally it shows buttons Noclaim Chow Pung Kong MahJong but after a mahjong claim it shows Eyes Chow Pung Special Hand*/typedef struct { GtkWidget *widget; /* the box itself */ GtkWidget *tilename; /* the label for the tile name */ GtkWidget *tiles[4]; /* the buttons for the tiles as discarded by each player. Element 0 is unused. */ /* the various buttons */ GtkWidget *noclaim; GtkWidget *eyes; GtkWidget *chow; GtkWidget *pung; GtkWidget *special; GtkWidget *kong; GtkWidget *mahjong; GtkWidget *robkong; int mode; /* 0 normally, 1 in mahjong mode, 2 for robbing kongs */} DiscardDialog;/* this is used by functions that display or remove tiles to pass back information to the animation routines. The structure contains information about the tiles.*/typedef struct { GtkWidget *target; /* the widget to which this information refers, if it is being newly displayed. In this case, the widget is not shown, and it is the animator's job to show it at the end of animation. If target is null, then the widget is being undisplayed. */ Tile t; /* the tile displayed by the widget */ int ori; /* and its orientation */ int x, y; /* x and y coordinates relative to the boardframe */} AnimInfo;/* enums used in the dialog popup function to specify position */typedef enum { DPCentred, /* centered over main window */ DPOnDiscard, /* bottom left corner in same place as discard dialog */ DPErrorPos, /* for error dialogs: centred over top of main window */ DPNone, /* don't touch the positioning at all */ DPCentredOnce, /* centre it on first popup, then don't fiddle */ DPOnDiscardOnce, /* on discard dialog first time, then don't fiddle */} DPPosn;/* Where to put the dialog boxes */typedef enum { DialogsUnspecified = 0, DialogsCentral = 1, DialogsBelow = 2, DialogsPopup = 3 } DialogPosition;/* The rcfile is used to store assorted persistent data. We often need to read or update only selected parts of it. This set of flag bits identifies the groups that can be independently read or updated. */typedef enum { XmjrcNone = 0x00, XmjrcDisplay = 0x01, /* preferences regarding the display */ XmjrcPlayer = 0x02, /* player option settings */ XmjrcGame = 0x04, /* game option preferences */ XmjrcMisc = 0x08, /* odds and sods */ XmjrcOpen = 0x10, /* sticky fields in the connection dialogs */ XmjrcPlaying = 0x20, /* playing preferences */ XmjrcAll = 0xFFFFFFFF /* everything */} XmjrcGroup;/* extra data in the game */typedef struct { int orig_live_end; /* value of wall.live_end at start of hand */} GameExtras;#define gextras(g) ((GameExtras *)(g->userdata))/***************** FORWARD DECLARATIONS*****************//* FUNCTIONS */void apply_game_prefs(void);GtkWidget *build_or_refresh_option_panel(GameOptionTable *got,GtkWidget *panel);GtkWidget *build_or_refresh_prefs_panel(GameOptionTable *got,GtkWidget *panel);void button_set_tile(GtkWidget *b, Tile t, int ori);void chow_dialog_init(void);void close_connection(void);void close_saving_posn(GtkWidget *w);void conc_callback(GtkWidget *w, gpointer data);void continue_dialog_init(void);void continue_dialog_popup(void);void create_dialogs(void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -