mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
add role to newgame dialog
This commit is contained in:
parent
7bc8d22739
commit
479805ee08
2 changed files with 43 additions and 0 deletions
|
@ -83,6 +83,19 @@ nplayers_menu_select( GtkWidget* item, GtkNewGameState* state )
|
||||||
state->nPlayers = newNPlayers;
|
state->nPlayers = newNPlayers;
|
||||||
} /* nplayers_menu_select */
|
} /* nplayers_menu_select */
|
||||||
|
|
||||||
|
static void
|
||||||
|
role_menu_select( GtkWidget* item, GtkNewGameState* state )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for ( i = 0; i < 3; ++i ) {
|
||||||
|
if ( item == state->roleMenuItems[i] ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XP_ASSERT( i < 3 ); /* did we not find it? */
|
||||||
|
state->role = (Connectedness)i;
|
||||||
|
} /* role_menu_select */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
size_menu_select( GtkWidget* item, GtkNewGameState* state )
|
size_menu_select( GtkWidget* item, GtkNewGameState* state )
|
||||||
{
|
{
|
||||||
|
@ -210,17 +223,44 @@ makeNewGameDialog( GtkNewGameState* state )
|
||||||
GtkWidget* vbox;
|
GtkWidget* vbox;
|
||||||
GtkWidget* hbox;
|
GtkWidget* hbox;
|
||||||
GtkWidget* item;
|
GtkWidget* item;
|
||||||
|
GtkWidget* roleMenu;
|
||||||
GtkWidget* nPlayersMenu;
|
GtkWidget* nPlayersMenu;
|
||||||
GtkWidget* boardSizeMenu;
|
GtkWidget* boardSizeMenu;
|
||||||
GtkWidget* opt;
|
GtkWidget* opt;
|
||||||
CurGameInfo* gi;
|
CurGameInfo* gi;
|
||||||
short i;
|
short i;
|
||||||
|
char* roles[] = { "Standalone", "Host", "Guest" };
|
||||||
|
|
||||||
dialog = gtk_dialog_new();
|
dialog = gtk_dialog_new();
|
||||||
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
|
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
|
||||||
|
|
||||||
vbox = gtk_vbox_new( FALSE, 0 );
|
vbox = gtk_vbox_new( FALSE, 0 );
|
||||||
|
|
||||||
|
/* Role menu */
|
||||||
|
state->role = state->globals->cGlobals.params->serverRole;
|
||||||
|
|
||||||
|
hbox = gtk_hbox_new( FALSE, 0 );
|
||||||
|
gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Role:"),
|
||||||
|
FALSE, TRUE, 0 );
|
||||||
|
opt = gtk_option_menu_new();
|
||||||
|
roleMenu = gtk_menu_new();
|
||||||
|
|
||||||
|
for ( i = 0; i < sizeof(roles)/sizeof(roles[0]); ++i ) {
|
||||||
|
item = make_menu_item( roles[i], GTK_SIGNAL_FUNC(role_menu_select),
|
||||||
|
state );
|
||||||
|
state->roleMenuItems[i] = item;
|
||||||
|
gtk_menu_append( GTK_MENU(roleMenu), item );
|
||||||
|
if ( i == state->role ) {
|
||||||
|
gtk_menu_set_active( GTK_MENU(roleMenu), i );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_option_menu_set_menu( GTK_OPTION_MENU(opt), roleMenu );
|
||||||
|
gtk_widget_show( opt );
|
||||||
|
gtk_box_pack_start( GTK_BOX(hbox), opt, FALSE, TRUE, 0 );
|
||||||
|
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
|
||||||
|
|
||||||
|
/* NPlayers menu */
|
||||||
hbox = gtk_hbox_new( FALSE, 0 );
|
hbox = gtk_hbox_new( FALSE, 0 );
|
||||||
gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Number of players"),
|
gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Number of players"),
|
||||||
FALSE, TRUE, 0 );
|
FALSE, TRUE, 0 );
|
||||||
|
|
|
@ -30,8 +30,11 @@ typedef struct GtkNewGameState {
|
||||||
GtkWidget* playerEntries[MAX_NUM_PLAYERS];
|
GtkWidget* playerEntries[MAX_NUM_PLAYERS];
|
||||||
gboolean revert;
|
gboolean revert;
|
||||||
gboolean cancelled;
|
gboolean cancelled;
|
||||||
|
Connectedness role;
|
||||||
short nPlayers;
|
short nPlayers;
|
||||||
short nCols;
|
short nCols;
|
||||||
|
|
||||||
|
GtkWidget* roleMenuItems[3];
|
||||||
} GtkNewGameState;
|
} GtkNewGameState;
|
||||||
|
|
||||||
gboolean newGameDialog( GtkAppGlobals* globals/* , GtkGameInfo* gameInfo */ );
|
gboolean newGameDialog( GtkAppGlobals* globals/* , GtkGameInfo* gameInfo */ );
|
||||||
|
|
Loading…
Reference in a new issue