add role to newgame dialog

This commit is contained in:
ehouse 2005-09-05 05:31:11 +00:00
parent 7bc8d22739
commit 479805ee08
2 changed files with 43 additions and 0 deletions

View file

@ -83,6 +83,19 @@ nplayers_menu_select( GtkWidget* item, GtkNewGameState* state )
state->nPlayers = newNPlayers;
} /* 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
size_menu_select( GtkWidget* item, GtkNewGameState* state )
{
@ -210,17 +223,44 @@ makeNewGameDialog( GtkNewGameState* state )
GtkWidget* vbox;
GtkWidget* hbox;
GtkWidget* item;
GtkWidget* roleMenu;
GtkWidget* nPlayersMenu;
GtkWidget* boardSizeMenu;
GtkWidget* opt;
CurGameInfo* gi;
short i;
char* roles[] = { "Standalone", "Host", "Guest" };
dialog = gtk_dialog_new();
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
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 );
gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Number of players"),
FALSE, TRUE, 0 );

View file

@ -30,8 +30,11 @@ typedef struct GtkNewGameState {
GtkWidget* playerEntries[MAX_NUM_PLAYERS];
gboolean revert;
gboolean cancelled;
Connectedness role;
short nPlayers;
short nCols;
GtkWidget* roleMenuItems[3];
} GtkNewGameState;
gboolean newGameDialog( GtkAppGlobals* globals/* , GtkGameInfo* gameInfo */ );