StartTournamentWindow Class Reference

#include <StartTournamentWindow.h>

Collaboration diagram for StartTournamentWindow:

Collaboration graph
[legend]

Public Types

enum  min_max_full_t { MMF_MIN, MMF_MAX, MMF_FULL_ROUND, MMF_ALL_ARENAS }
enum  start_tournament_button_t {
  START_TORUNAMENT_REMOVE = 0, START_TORUNAMENT_SELECT_ALL_TOURNAMENT = 1, START_TORUNAMENT_UNSELECT_ALL_TOURNAMENT = 2, START_TORUNAMENT_ADD = 3,
  START_TORUNAMENT_SELECT_ALL_DIRECTORY = 4, START_TORUNAMENT_UNSELECT_ALL_DIRECTORY = 5
}

Public Member Functions

 StartTournamentWindow (const int default_width=-1, const int default_height=-1, const int default_x_pos=-1, const int default_y_pos=-1)
 ~StartTournamentWindow ()
GtkWidgetget_window_p ()
void new_tournament (const List< start_tournament_info_t > &robotfilename_list, const List< start_tournament_info_t > &arenafilename_list, const int robots_p_game, const int games_p_sequence, const int n_o_sequences)
bool get_tournament_started_flag ()
void set_tournament_started_flag (bool started)

Static Public Member Functions

void delete_event_occured (GtkWidget *widget, GdkEvent *event, class StartTournamentWindow *stw_p)
void cancel_new_tournament (GtkWidget *widget, class StartTournamentWindow *stw_p)
void set_entry (GtkWidget *widget, struct min_max_full_buttons_t *mmf_p)
void kill_and_start_new_tournament (GtkWidget *widget, class StartTournamentWindow *stw_p)
void start (GtkWidget *widget, class StartTournamentWindow *stw_p)
void load_tournament_selected (GtkWidget *widget, class StartTournamentWindow *stw_p)
void load_file_selected (GtkWidget *widget, class StartTournamentWindow *stw_p)
void save_tournament_selected (GtkWidget *widget, class StartTournamentWindow *stw_p)
void save_file_selected (GtkWidget *widget, class StartTournamentWindow *stw_p)
void destroy_filesel (GtkWidget *widget, class StartTournamentWindow *stw_p)
void button_selected (GtkWidget *widget, struct select_buttons_t *button)
void selection_made (GtkWidget *clist, gint row, gint column, GdkEventButton *event, class StartTournamentWindow *stw_p)
void new_tournament_from_tournament_file (const List< start_tournament_info_t > &robotfilename_list, const List< start_tournament_info_t > &arenafilename_list, const int robots_p_game, const int games_p_sequence, const int n_o_sequences, StartTournamentWindow *stw_p)
void dummy_result (int result)

Private Member Functions

void add_clist (GtkWidget *clist, GtkWidget *box)
void change_all_selection (const bool robots, const bool dir, const bool all)
void add_all_selected (const bool robots)
void remove_all_selected (const bool robots)
start_tournament_info_tfind_row_in_clist (const int row, List< start_tournament_info_t > *info_list)
void load_tournament_file (const String &full_filename, bool display_fail_message)
void save_tournament_file (const String &full_filename, bool display_file_fail_message, bool display_tour_fail_message)
GtkWidgetget_filesel ()
void set_filesel (GtkWidget *fs)
GtkWidget ** get_entries ()
List< start_tournament_info_t > * get_selected_robot_tournament ()
List< start_tournament_info_t > * get_selected_robot_directory ()
List< start_tournament_info_t > * get_selected_arena_tournament ()
List< start_tournament_info_t > * get_selected_arena_directory ()
GtkWidgetget_robots_in_tournament_clist ()
GtkWidgetget_robots_in_directory_clist ()
GtkWidgetget_arenas_in_tournament_clist ()
GtkWidgetget_arenas_in_directory_clist ()

Private Attributes

GtkWidgetwindow_p
GtkWidgetentries [3]
GtkWidgetfilesel
GtkWidgetrobots_in_tournament_clist
GtkWidgetrobots_in_directory_clist
GtkWidgetarenas_in_tournament_clist
GtkWidgetarenas_in_directory_clist
List< start_tournament_info_tselected_robot_tournament
List< start_tournament_info_tselected_robot_directory
List< start_tournament_info_tselected_arena_tournament
List< start_tournament_info_tselected_arena_directory
bool tournament_started_flag

Member Enumeration Documentation

enum StartTournamentWindow::min_max_full_t
 

Enumeration values:
MMF_MIN 
MMF_MAX 
MMF_FULL_ROUND 
MMF_ALL_ARENAS 

Definition at line 44 of file StartTournamentWindow.h.

00044 { MMF_MIN, MMF_MAX, MMF_FULL_ROUND, MMF_ALL_ARENAS };

enum StartTournamentWindow::start_tournament_button_t
 

Enumeration values:
START_TORUNAMENT_REMOVE 
START_TORUNAMENT_SELECT_ALL_TOURNAMENT 
START_TORUNAMENT_UNSELECT_ALL_TOURNAMENT 
START_TORUNAMENT_ADD 
START_TORUNAMENT_SELECT_ALL_DIRECTORY 
START_TORUNAMENT_UNSELECT_ALL_DIRECTORY 

Definition at line 45 of file StartTournamentWindow.h.


Constructor & Destructor Documentation

StartTournamentWindow::StartTournamentWindow const int  default_width = -1,
const int  default_height = -1,
const int  default_x_pos = -1,
const int  default_y_pos = -1
 

Definition at line 60 of file StartTournamentWindow.cc.

References _, add_clist(), arenas_in_directory_clist, arenas_in_tournament_clist, button_selected(), cancel_new_tournament(), String::chars(), check_if_filename_is_arena(), check_if_filename_is_robot(), delete_event_occured(), dirent, entries, entry_handler(), ENTRY_INT, filesel, List< T >::first(), Gui::get_bg_gdk_colour_p(), Gui::get_fg_gdk_colour_p(), Options::get_s(), gpointer, GtkWidget, List< T >::insert_last(), load_tournament_file(), load_tournament_selected(), MMF_ALL_ARENAS, MMF_FULL_ROUND, MMF_MAX, MMF_MIN, ListIterator< T >::ok(), OPTION_TMP_RTB_DIR, read_dirs_from_system(), robots_in_directory_clist, robots_in_tournament_clist, save_tournament_selected(), set_entry(), start(), START_TORUNAMENT_REMOVE, the_gui, the_opts, tournament_started_flag, and window_p.

00064 {
00065   
00066   tournament_started_flag = false;
00067 
00068   filesel = NULL;
00069 
00070   // The window widget
00071 
00072   window_p = gtk_window_new( GTK_WINDOW_TOPLEVEL );
00073   gtk_widget_set_name( window_p, "RTB StartTournament" );
00074 
00075   gtk_window_set_title( GTK_WINDOW( window_p ),
00076                         _("Start New Tournament") );
00077 
00078   gtk_container_border_width( GTK_CONTAINER( window_p ), 12 );
00079 
00080   if( default_width != -1 && default_height != -1 )
00081     gtk_window_set_default_size( GTK_WINDOW( window_p ),
00082                                  default_width, default_height );
00083 
00084   if( default_x_pos != -1 && default_y_pos != -1 )
00085     gtk_widget_set_uposition( window_p, default_x_pos, default_y_pos );
00086 
00087   gtk_signal_connect( GTK_OBJECT( window_p ), "delete_event",
00088                       (GtkSignalFunc) StartTournamentWindow::delete_event_occured,
00089                       (gpointer) this );
00090 
00091   // Lists for clists
00092 
00093   List<String> robotdirs;
00094   List<String> arenadirs;
00095 
00096   read_dirs_from_system( robotdirs, arenadirs );
00097 
00098   // Main box
00099 
00100   GtkWidget* vbox = gtk_vbox_new( FALSE, 10 );
00101   gtk_container_add( GTK_CONTAINER( window_p ), vbox );
00102   gtk_widget_show( vbox );
00103 
00104   // Clists and buttons for selecting robots
00105 
00106   for( int j = 0; j < 2; j++ )
00107     {
00108       List<start_tournament_info_t>* tour_list;
00109       List<start_tournament_info_t>* dir_list;
00110       GtkWidget* tour_clist;
00111       GtkWidget* dir_clist;
00112       char** tour_title;
00113       char** dir_title;
00114       bool robot;
00115 
00116       if( j == 0 )
00117         {
00118           tour_list = &selected_robot_tournament;
00119           dir_list  = &selected_robot_directory;
00120           tour_clist = robots_in_tournament_clist;
00121           dir_clist  = robots_in_directory_clist;
00122           tour_title = new char*( _("Robots in Tournament") );
00123           dir_title  = new char*( _("Robots in Directory") );
00124           robot = true;
00125         }
00126       else
00127         {
00128           tour_list = &selected_arena_tournament;
00129           dir_list  = &selected_arena_directory;
00130           tour_clist = arenas_in_tournament_clist;
00131           dir_clist  = arenas_in_directory_clist;
00132           tour_title = new char*( _("Arenas in Tournament") );
00133           dir_title  = new char*( _("Arenas in Directory") );
00134           robot = false;
00135 
00136           // Make a horizontal ruler between robots and arenas
00137           GtkWidget* hsep = gtk_hseparator_new();
00138           gtk_box_pack_start( GTK_BOX( vbox ), hsep, FALSE, TRUE, 0 );
00139           gtk_widget_show( hsep );
00140 
00141         }
00142 
00143       GtkWidget* hbox = gtk_hbox_new( FALSE, 10 );
00144       gtk_container_add( GTK_CONTAINER( vbox ), hbox );
00145       gtk_widget_show( hbox );
00146 
00147       tour_clist = gtk_clist_new_with_titles( 1, tour_title );
00148 
00149       add_clist( tour_clist, hbox );
00150 
00151       char* button_labels[] = { _(" Remove "), _(" Select All "),
00152                                 _(" Unselect All "), _(" Add "),
00153                                 _(" Select All "), _(" Unselect All ") };
00154 
00155       GtkWidget* vbox2 = NULL;
00156 
00157       for( int i=START_TORUNAMENT_REMOVE;
00158            i<= START_TORUNAMENT_UNSELECT_ALL_DIRECTORY; i++ )
00159         {
00160           if( i == START_TORUNAMENT_REMOVE ||
00161               i == START_TORUNAMENT_ADD )
00162             {
00163               vbox2 = gtk_vbox_new( FALSE, 10 );
00164               gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 0 );
00165               gtk_widget_show( vbox2 );
00166         
00167             }
00168           GtkWidget* button = gtk_button_new_with_label( button_labels[i] );
00169           struct select_buttons_t* s_button;
00170           
00171           s_button = new select_buttons_t( robot, i, this );
00172           gtk_signal_connect( GTK_OBJECT( button ), "clicked",
00173                               (GtkSignalFunc) StartTournamentWindow::button_selected,
00174                               (gpointer) s_button );
00175           gtk_box_pack_start( GTK_BOX( vbox2 ), button, TRUE, FALSE, 0 );
00176           gtk_widget_show( button );
00177         }
00178 
00179       dir_clist = gtk_clist_new_with_titles( 1, dir_title );
00180 
00181       add_clist( dir_clist, hbox );
00182 
00183       ListIterator<String> li;
00184 
00185       if( robot )
00186         robotdirs.first(li);
00187       else
00188         arenadirs.first(li);
00189 
00190       for( ; li.ok() ; li++ )
00191         {
00192                 
00193           String* current_dir = li();
00194           DIR* dir;
00195           
00196           
00197           if( dir = opendir(current_dir->chars()) )
00198             {
00199               struct dirent * entry;
00200               while (NULL != ( entry = readdir( dir ) ) )
00201                 {
00202                   String full_file_name = *current_dir + entry->d_name;
00203                   if( ( robot && check_if_filename_is_robot( full_file_name ) ) ||
00204                       ( !robot && check_if_filename_is_arena( full_file_name ) ) )
00205                     {
00206                       char* lst[] = { entry->d_name };
00207 
00208                       int row = gtk_clist_append( GTK_CLIST( dir_clist ), lst );
00209                       gtk_clist_set_foreground( GTK_CLIST( dir_clist ), row, 
00210                                                 the_gui.get_fg_gdk_colour_p());
00211                       gtk_clist_set_background( GTK_CLIST( dir_clist ), row, 
00212                                                 the_gui.get_bg_gdk_colour_p());
00213 
00214                       start_tournament_info_t* info;
00215                       info = new start_tournament_info_t
00216                         ( row, false,
00217                           entry->d_name,
00218                           current_dir->chars() );
00219                       dir_list->insert_last( info );
00220                     }
00221                 }
00222               closedir( dir );
00223             }
00224         }
00225 
00226       if( j == 0 )
00227         {
00228           robots_in_tournament_clist = tour_clist;
00229           robots_in_directory_clist = dir_clist;
00230         }
00231       else
00232         {
00233           arenas_in_tournament_clist = tour_clist;
00234           arenas_in_directory_clist = dir_clist;
00235           robot = false;
00236         }
00237     }
00238 
00239   GtkWidget* hsep = gtk_hseparator_new();
00240   gtk_box_pack_start( GTK_BOX( vbox ), hsep, FALSE, FALSE, 0 );
00241   gtk_widget_show( hsep );
00242 
00243   // Choose Number of games per sequence, Number of robots per sequence
00244   // and Number of sequences
00245 
00246   char * label_titles[] = { _("Games per sequence"), _("Robots per sequence"),
00247                             _("Number of sequences") };
00248 
00249   GtkWidget * hbox2 = gtk_hbox_new (FALSE, 10);
00250   gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
00251   gtk_widget_show (hbox2);
00252 
00253   GtkWidget * internal_hbox = gtk_hbox_new( FALSE, 10 );
00254   gtk_box_pack_start (GTK_BOX (hbox2), internal_hbox, TRUE, FALSE, 0);
00255   gtk_widget_show (internal_hbox);
00256 
00257   GtkWidget * description_table = gtk_table_new( 3, 1, TRUE );
00258   GtkWidget * entry_table = gtk_table_new( 3, 1, TRUE );
00259   GtkWidget * button_table = gtk_table_new( 3, 12, TRUE );
00260   gtk_box_pack_start (GTK_BOX (internal_hbox), description_table,
00261                       FALSE, FALSE, 0);
00262   gtk_box_pack_start (GTK_BOX (internal_hbox), entry_table,
00263                       FALSE, FALSE, 0);
00264   gtk_box_pack_start (GTK_BOX (internal_hbox), button_table,
00265                       FALSE, FALSE, 0);
00266 
00267   for( int i=0;i<3;i++ )
00268     {
00269       GtkWidget * internal_hbox = gtk_hbox_new( FALSE, 10 );
00270       gtk_table_attach_defaults( GTK_TABLE( description_table ),
00271                                  internal_hbox, 0, 1, i, i + 1 );
00272       gtk_widget_show (internal_hbox);
00273 
00274       GtkWidget * label = gtk_label_new(label_titles[i]);
00275       gtk_box_pack_start (GTK_BOX (internal_hbox), label, FALSE, FALSE, 0);
00276       gtk_widget_show(label);
00277 
00278       entries[i] = gtk_entry_new_with_max_length(4);
00279 
00280       switch(i)
00281         {
00282         case 0:
00283         case 2:
00284           gtk_entry_set_text( GTK_ENTRY( entries[i] ), "1" );
00285           break;
00286         case 1:
00287           gtk_entry_set_text( GTK_ENTRY( entries[i] ), "2" );
00288           break;
00289         }
00290 
00291       entry_t * info = new entry_t( ENTRY_INT, false );
00292 
00293       gtk_signal_connect(GTK_OBJECT(entries[i]), "changed",
00294                          (GtkSignalFunc) entry_handler, info);
00295       gtk_table_attach_defaults( GTK_TABLE( entry_table ),
00296                                  entries[i], 0, 1, i, i + 1 );
00297       gtk_widget_set_usize(entries[i], 36,18);
00298       gtk_widget_show(entries[i]);
00299 
00300       GtkWidget * button;
00301       int add = 0;
00302       if( i == 1 ) add = 3;
00303 
00304       button = gtk_button_new_with_label (_(" Min "));
00305 
00306       min_max_full_buttons_t* mmf_button;
00307       mmf_button = new min_max_full_buttons_t( i, MMF_MIN, this );
00308       gtk_signal_connect (GTK_OBJECT (button), "clicked",
00309                           (GtkSignalFunc) StartTournamentWindow::set_entry,
00310                           (gpointer) mmf_button );
00311       gtk_table_attach_defaults( GTK_TABLE( button_table ), button, 0, 3 + add, i, i + 1 );
00312       gtk_widget_show (button);
00313 
00314       if( i == 0 )
00315         {
00316           button = gtk_button_new_with_label (_(" All Arenas "));
00317           mmf_button = new min_max_full_buttons_t( i, MMF_ALL_ARENAS,
00318                                                    this );
00319           gtk_signal_connect (GTK_OBJECT (button), "clicked",
00320                               (GtkSignalFunc) StartTournamentWindow::set_entry,
00321                               (gpointer) mmf_button );
00322           gtk_table_attach_defaults( GTK_TABLE( button_table ), button, 3, 9, i, i + 1 );
00323           gtk_widget_show (button);
00324         }
00325 
00326       if( i == 2 )
00327         {
00328           button = gtk_button_new_with_label (_(" Full Round "));
00329           mmf_button = new min_max_full_buttons_t( i, MMF_FULL_ROUND,
00330                                                    this );
00331           gtk_signal_connect( GTK_OBJECT( button ), "clicked",
00332                               (GtkSignalFunc) StartTournamentWindow::set_entry,
00333                               (gpointer) mmf_button );
00334           gtk_table_attach_defaults( GTK_TABLE( button_table ), button, 3, 9, i, i + 1 );
00335           gtk_widget_show( button );
00336         }
00337 
00338       button = gtk_button_new_with_label (_(" Max "));
00339       mmf_button = new min_max_full_buttons_t( i, MMF_MAX, this );
00340       gtk_signal_connect (GTK_OBJECT (button), "clicked",
00341                           (GtkSignalFunc) StartTournamentWindow::set_entry,
00342                           (gpointer) mmf_button );
00343       gtk_table_attach_defaults( GTK_TABLE( button_table ), button, 9 - add, 12, i, i + 1 );
00344       gtk_widget_show (button);
00345     }
00346 
00347   gtk_table_set_row_spacings( GTK_TABLE( description_table ) , 5 );
00348   gtk_table_set_col_spacings( GTK_TABLE( description_table ) , 5 );
00349   gtk_table_set_row_spacings( GTK_TABLE( entry_table ) , 5 );
00350   gtk_table_set_col_spacings( GTK_TABLE( entry_table ) , 5 );
00351   gtk_table_set_row_spacings( GTK_TABLE( button_table ) , 5 );
00352   gtk_table_set_col_spacings( GTK_TABLE( button_table ) , 5 );
00353   gtk_widget_show( description_table );
00354   gtk_widget_show( entry_table );
00355   gtk_widget_show( button_table );
00356 
00357   GtkWidget* vsep = gtk_vseparator_new();
00358   gtk_box_pack_start( GTK_BOX( hbox2 ), vsep, FALSE, FALSE, 0 );
00359   gtk_widget_show( vsep );
00360 
00361   GtkWidget* vbox2 = gtk_vbox_new( FALSE, 10 );
00362   gtk_box_pack_start( GTK_BOX(hbox2), vbox2, TRUE, FALSE, 0);
00363   gtk_widget_show (vbox2);
00364 
00365   {
00366     char * button_labels[] = { _(" Load tournament "), _(" Save tournament ") };
00367     for(int i=0;i<2;i++)
00368       {
00369         GtkWidget* button = gtk_button_new_with_label( button_labels[i] );
00370         if(i==0)
00371           gtk_signal_connect( GTK_OBJECT( button ), "clicked",
00372                               (GtkSignalFunc) StartTournamentWindow::load_tournament_selected,
00373                               (gpointer) this );          
00374         if(i==1)
00375           gtk_signal_connect( GTK_OBJECT( button ), "clicked",
00376                               (GtkSignalFunc) StartTournamentWindow::save_tournament_selected,
00377                               (gpointer) this );
00378         gtk_box_pack_start( GTK_BOX(vbox2), button, TRUE, FALSE, 0);
00379         gtk_widget_show( button );
00380       }
00381   }  
00382 
00383   vbox2 = gtk_vbox_new( FALSE, 10 );
00384   gtk_box_pack_end( GTK_BOX(hbox2), vbox2, TRUE, FALSE, 0);
00385   gtk_widget_show (vbox2);
00386 
00387   {
00388     char * button_labels[] = { _(" Start "), _(" Cancel ") };
00389     for(int i=0;i<2;i++)
00390       {
00391         GtkWidget* button = gtk_button_new_with_label( button_labels[i] );
00392         if(i==0)
00393           gtk_signal_connect( GTK_OBJECT( button ), "clicked",
00394                               (GtkSignalFunc) StartTournamentWindow::start,
00395                               (gpointer) this );          
00396         if(i==1)
00397           gtk_signal_connect( GTK_OBJECT( button ), "clicked",
00398                               (GtkSignalFunc) StartTournamentWindow::cancel_new_tournament,
00399                               (gpointer) this );
00400         gtk_box_pack_start( GTK_BOX(vbox2), button, TRUE, FALSE, 0);
00401         gtk_widget_show( button );
00402       }
00403   }  
00404 
00405   load_tournament_file( the_opts.get_s( OPTION_TMP_RTB_DIR ) +
00406                         tmp_tournament_file, false );
00407   gtk_widget_show( window_p );
00408   
00409 }

Here is the call graph for this function:

StartTournamentWindow::~StartTournamentWindow  ) 
 

Definition at line 411 of file StartTournamentWindow.cc.

References window_p.

00412 {
00413   gtk_widget_destroy( window_p );
00414 }


Member Function Documentation

void StartTournamentWindow::add_all_selected const bool  robots  )  [private]
 

Definition at line 930 of file StartTournamentWindow.cc.

References String::chars(), start_tournament_info_t::directory, start_tournament_info_t::filename, List< T >::first(), get_arenas_in_tournament_clist(), Gui::get_bg_gdk_colour_p(), Gui::get_fg_gdk_colour_p(), get_robots_in_tournament_clist(), get_selected_arena_directory(), get_selected_arena_tournament(), get_selected_robot_directory(), get_selected_robot_tournament(), GtkWidget, List< T >::insert_last(), String::non_const_chars(), ListIterator< T >::ok(), start_tournament_info_t::selected, and the_gui.

Referenced by button_selected().

00931 {
00932   ListIterator<start_tournament_info_t> li;
00933   List<start_tournament_info_t>* info_dir_list;
00934   List<start_tournament_info_t>* info_tourn_list;
00935   GtkWidget * clist_tourn;
00936 
00937   if(robots)
00938     {
00939       info_dir_list = get_selected_robot_directory();
00940       info_tourn_list = get_selected_robot_tournament();
00941       clist_tourn = get_robots_in_tournament_clist();
00942     }
00943   else
00944     {
00945       info_dir_list = get_selected_arena_directory();
00946       info_tourn_list = get_selected_arena_tournament();
00947       clist_tourn = get_arenas_in_tournament_clist();
00948     }
00949 
00950   for( info_dir_list->first(li) ; li.ok() ; li++ )
00951     {
00952       start_tournament_info_t* info_dir_p = li();
00953       if( info_dir_p->selected )
00954         {
00955           char * list[] = { "" };
00956           
00957           int row = gtk_clist_append( GTK_CLIST( clist_tourn ), list );
00958           gtk_clist_set_foreground( GTK_CLIST( clist_tourn ), row,
00959                                     the_gui.get_fg_gdk_colour_p() );
00960           gtk_clist_set_background( GTK_CLIST( clist_tourn ), row,
00961                                     the_gui.get_bg_gdk_colour_p() );
00962 
00963 
00964           gtk_clist_set_text( GTK_CLIST( clist_tourn ), row, 0,
00965                               info_dir_p->filename.non_const_chars() );
00966       
00967           start_tournament_info_t* info_tourn_p;
00968           String full_filename;
00969           if(robots)
00970             full_filename = info_dir_p->directory + info_dir_p->filename;
00971           else
00972             full_filename = info_dir_p->directory + info_dir_p->filename;
00973 
00974           info_tourn_p = new start_tournament_info_t
00975             ( row, false, full_filename.chars(), info_dir_p->directory );
00976           info_tourn_list->insert_last( info_tourn_p );
00977         }
00978     }
00979 }

Here is the call graph for this function:

void StartTournamentWindow::add_clist GtkWidget clist,
GtkWidget box
[private]
 

Definition at line 417 of file StartTournamentWindow.cc.

References Gui::get_bg_gdk_colour_p(), Gui::get_fg_gdk_colour_p(), GtkWidget, make_gdk_colour(), selection_made(), the_gui, and window_p.

Referenced by StartTournamentWindow().

00418 {
00419   int all_clists_width=150;
00420   int all_clists_height= 150;
00421 
00422   GtkObject* hadj = gtk_adjustment_new( 0.0, 0.0, 100.0, 1.0, 1.0, 1.0 );
00423   GtkObject* vadj = gtk_adjustment_new( 0.0, 0.0, 100.0, 1.0, 1.0, 1.0 );
00424   GtkWidget* scrolled_win =
00425     gtk_scrolled_window_new( GTK_ADJUSTMENT ( hadj ),
00426                              GTK_ADJUSTMENT ( vadj ) );
00427   gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ),
00428                                   GTK_POLICY_AUTOMATIC,
00429                                   GTK_POLICY_AUTOMATIC );
00430   gtk_box_pack_start( GTK_BOX( box ), scrolled_win, TRUE, TRUE, 5 );
00431   gtk_widget_show( scrolled_win );
00432 
00433   gtk_clist_set_selection_mode( GTK_CLIST( clist ),
00434                                 GTK_SELECTION_MULTIPLE );
00435   gtk_clist_set_column_width( GTK_CLIST( clist ), 0, 90 );
00436   gtk_clist_set_column_justification( GTK_CLIST( clist ),
00437                                       0, GTK_JUSTIFY_LEFT);
00438   gtk_clist_column_titles_passive( GTK_CLIST( clist ) );
00439   gtk_signal_connect( GTK_OBJECT( clist ), "select_row",
00440                       (GtkSignalFunc) StartTournamentWindow::selection_made, this );
00441   gtk_signal_connect( GTK_OBJECT( clist ), "unselect_row",
00442                       (GtkSignalFunc) StartTournamentWindow::selection_made, this );
00443 
00444   gtk_clist_set_shadow_type( GTK_CLIST( clist ),
00445                              GTK_SHADOW_IN );
00446   gtk_widget_set_usize( clist, all_clists_width,
00447                         all_clists_height );
00448   gtk_container_add( GTK_CONTAINER( scrolled_win ),
00449                      clist );
00450 
00451   GtkStyle* clist_style = gtk_rc_get_style(window_p);
00452   if( clist_style == NULL )
00453     clist_style = gtk_style_new();
00454   else
00455   clist_style = gtk_style_copy(clist_style);
00456   clist_style->base[GTK_STATE_NORMAL] = *(the_gui.get_bg_gdk_colour_p());
00457   clist_style->base[GTK_STATE_ACTIVE] = make_gdk_colour( 0xffffff );
00458   clist_style->bg[GTK_STATE_SELECTED] = make_gdk_colour( 0xf0d2b4 );
00459   clist_style->fg[GTK_STATE_SELECTED] = *(the_gui.get_fg_gdk_colour_p());
00460   gtk_widget_set_style( clist, clist_style );
00461   gtk_widget_show( clist );
00462 }

Here is the call graph for this function:

void StartTournamentWindow::button_selected GtkWidget widget,
struct select_buttons_t button
[static]
 

Definition at line 857 of file StartTournamentWindow.cc.

References add_all_selected(), StartTournamentWindow::select_buttons_t::button_nr, change_all_selection(), remove_all_selected(), StartTournamentWindow::select_buttons_t::robot, START_TORUNAMENT_ADD, START_TORUNAMENT_REMOVE, START_TORUNAMENT_SELECT_ALL_DIRECTORY, START_TORUNAMENT_SELECT_ALL_TOURNAMENT, START_TORUNAMENT_UNSELECT_ALL_DIRECTORY, START_TORUNAMENT_UNSELECT_ALL_TOURNAMENT, and StartTournamentWindow::select_buttons_t::stw_p.

Referenced by StartTournamentWindow().

00859 {
00860   switch( button->button_nr )
00861     {
00862     case START_TORUNAMENT_REMOVE:
00863       button->stw_p->remove_all_selected( button->robot );
00864       break;
00865     case START_TORUNAMENT_SELECT_ALL_TOURNAMENT:
00866       button->stw_p->change_all_selection( button->robot,false,true );
00867       break;
00868     case START_TORUNAMENT_UNSELECT_ALL_TOURNAMENT:
00869       button->stw_p->change_all_selection( button->robot,false,false );
00870       break;
00871     case START_TORUNAMENT_ADD:
00872       button->stw_p->add_all_selected( button->robot );
00873       break;
00874     case START_TORUNAMENT_SELECT_ALL_DIRECTORY:
00875       button->stw_p->change_all_selection( button->robot,true,true );
00876       break;
00877     case START_TORUNAMENT_UNSELECT_ALL_DIRECTORY:
00878       button->stw_p->change_all_selection( button->robot,true,false );
00879       break;
00880     }
00881 }

Here is the call graph for this function:

void StartTournamentWindow::cancel_new_tournament GtkWidget widget,
class StartTournamentWindow stw_p
[static]
 

Definition at line 473 of file StartTournamentWindow.cc.

References Gui::close_starttournamentwindow(), and the_gui.

Referenced by StartTournamentWindow().

00475 {
00476   the_gui.close_starttournamentwindow();
00477 }

Here is the call graph for this function:

void StartTournamentWindow::change_all_selection const bool  robots,
const bool  dir,
const bool  all
[private]
 

Definition at line 884 of file StartTournamentWindow.cc.

References List< T >::first(), get_arenas_in_directory_clist(), get_arenas_in_tournament_clist(), get_robots_in_directory_clist(), get_robots_in_tournament_clist(), get_selected_arena_directory(), get_selected_arena_tournament(), get_selected_robot_directory(), get_selected_robot_tournament(), GtkWidget, ListIterator< T >::ok(), start_tournament_info_t::row, and start_tournament_info_t::selected.

Referenced by button_selected().

00887 {
00888   ListIterator<start_tournament_info_t> li;
00889   List<start_tournament_info_t>* info_list = NULL;
00890   GtkWidget * clist = NULL;
00891 
00892 
00893   if( robots && dir )
00894     {
00895       info_list = get_selected_robot_directory();
00896       clist = get_robots_in_directory_clist();
00897     }
00898   else if(robots && !dir)
00899     {
00900       info_list = get_selected_robot_tournament();
00901       clist = get_robots_in_tournament_clist();
00902     }
00903   else if(!robots && dir)
00904     {
00905       info_list = get_selected_arena_directory();
00906       clist = get_arenas_in_directory_clist();
00907     }
00908   else if(!robots && !dir)
00909     {
00910       info_list = get_selected_arena_tournament();
00911       clist = get_arenas_in_tournament_clist();
00912     }
00913   for( info_list->first(li); li.ok() ; li++ )
00914     {
00915       start_tournament_info_t* info_p = li();
00916       if( all )
00917         {
00918           info_p->selected = true;
00919           gtk_clist_select_row( GTK_CLIST( clist ), info_p->row, 0);
00920         }
00921       else
00922         {
00923           info_p->selected = false;
00924           gtk_clist_unselect_row( GTK_CLIST( clist ), info_p->row, 0);
00925         }
00926     }
00927 }

Here is the call graph for this function:

void StartTournamentWindow::delete_event_occured GtkWidget widget,
GdkEvent event,
class StartTournamentWindow stw_p
[static]
 

Definition at line 465 of file StartTournamentWindow.cc.

References Gui::close_starttournamentwindow(), and the_gui.

Referenced by StartTournamentWindow().

00468 {
00469   the_gui.close_starttournamentwindow();
00470 }

Here is the call graph for this function:

void StartTournamentWindow::destroy_filesel GtkWidget widget,
class StartTournamentWindow stw_p
[static]
 

Definition at line 548 of file StartTournamentWindow.cc.

Referenced by load_file_selected(), load_tournament_selected(), save_file_selected(), and save_tournament_selected().

00550 {
00551   gtk_widget_destroy( stw_p->get_filesel() );
00552   stw_p->set_filesel( NULL );
00553 }

void StartTournamentWindow::dummy_result int  result  )  [inline, static]
 

Definition at line 126 of file StartTournamentWindow.h.

Referenced by load_tournament_file(), save_tournament_file(), and start().

00126 {}

start_tournament_info_t * StartTournamentWindow::find_row_in_clist const int  row,
List< start_tournament_info_t > *  info_list
[private]
 

Definition at line 1047 of file StartTournamentWindow.cc.

References List< T >::first(), ListIterator< T >::ok(), and start_tournament_info_t::row.

01049 {
01050   ListIterator<start_tournament_info_t> li;
01051   for( info_list->first(li); li.ok() ; li++ )
01052     {
01053       start_tournament_info_t* info_p = li();
01054       if( info_p->row == row )
01055         return info_p;
01056     }
01057   return NULL;
01058 }

Here is the call graph for this function:

GtkWidget* StartTournamentWindow::get_arenas_in_directory_clist  )  [inline, private]
 

Definition at line 165 of file StartTournamentWindow.h.

References GtkWidget.

Referenced by change_all_selection().

00166     { return arenas_in_directory_clist; }

GtkWidget* StartTournamentWindow::get_arenas_in_tournament_clist  )  [inline, private]
 

Definition at line 163 of file StartTournamentWindow.h.

References GtkWidget.

Referenced by add_all_selected(), change_all_selection(), and remove_all_selected().

00164     { return arenas_in_tournament_clist; }

GtkWidget** StartTournamentWindow::get_entries  )  [inline, private]
 

Definition at line 148 of file StartTournamentWindow.h.

References GtkWidget.

Referenced by save_tournament_file(), and set_entry().

00148 { return entries; }

GtkWidget* StartTournamentWindow::get_filesel  )  [inline, private]
 

Definition at line 145 of file StartTournamentWindow.h.

References GtkWidget.

00145 { return filesel; }

GtkWidget* StartTournamentWindow::get_robots_in_directory_clist  )  [inline, private]
 

Definition at line 161 of file StartTournamentWindow.h.

References GtkWidget.

Referenced by change_all_selection().

00162     { return robots_in_directory_clist; }

GtkWidget* StartTournamentWindow::get_robots_in_tournament_clist  )  [inline, private]
 

Definition at line 159 of file StartTournamentWindow.h.

References GtkWidget.

Referenced by add_all_selected(), change_all_selection(), and remove_all_selected().

00160     { return robots_in_tournament_clist; }

List<start_tournament_info_t>* StartTournamentWindow::get_selected_arena_directory  )  [inline, private]
 

Definition at line 156 of file StartTournamentWindow.h.

Referenced by add_all_selected(), and change_all_selection().

00157     { return &selected_arena_directory; };

List<start_tournament_info_t>* StartTournamentWindow::get_selected_arena_tournament  )  [inline, private]
 

Definition at line 154 of file StartTournamentWindow.h.

Referenced by add_all_selected(), change_all_selection(), remove_all_selected(), and set_entry().

00155     { return &selected_arena_tournament; };

List<start_tournament_info_t>* StartTournamentWindow::get_selected_robot_directory  )  [inline, private]
 

Definition at line 152 of file StartTournamentWindow.h.

Referenced by add_all_selected(), and change_all_selection().

00153     { return &selected_robot_directory; };

List<start_tournament_info_t>* StartTournamentWindow::get_selected_robot_tournament  )  [inline, private]
 

Definition at line 150 of file StartTournamentWindow.h.

Referenced by add_all_selected(), change_all_selection(), remove_all_selected(), save_tournament_file(), and set_entry().

00151     { return &selected_robot_tournament; };

bool StartTournamentWindow::get_tournament_started_flag  )  [inline]
 

Definition at line 122 of file StartTournamentWindow.h.

00122 { return tournament_started_flag; }

GtkWidget* StartTournamentWindow::get_window_p  )  [inline]
 

Definition at line 81 of file StartTournamentWindow.h.

References GtkWidget.

00081 { return window_p; }

void StartTournamentWindow::kill_and_start_new_tournament GtkWidget widget,
class StartTournamentWindow stw_p
[static]
 

void StartTournamentWindow::load_file_selected GtkWidget widget,
class StartTournamentWindow stw_p
[static]
 

Definition at line 503 of file StartTournamentWindow.cc.

References destroy_filesel().

00505 {
00506   stw_p->load_tournament_file
00507     ( String( gtk_file_selection_get_filename
00508               ( GTK_FILE_SELECTION( stw_p->get_filesel() ) ) ),
00509       true );
00510   destroy_filesel( stw_p->get_filesel(), stw_p );
00511 }

Here is the call graph for this function:

void StartTournamentWindow::load_tournament_file const String full_filename,
bool  display_fail_message
[private]
 

Definition at line 556 of file StartTournamentWindow.cc.

References _, DialogFunction, dummy_result(), List< T >::insert_last(), new_tournament_from_tournament_file(), parse_tournament_file(), and StartTournamentFunction.

Referenced by StartTournamentWindow().

00558 {
00559   if(!parse_tournament_file( full_filename,
00560                              (StartTournamentFunction)
00561                              StartTournamentWindow::new_tournament_from_tournament_file,
00562                              this, false ) && display_fail_message )
00563     {
00564       String error_msg( _("Error in specified tournament file.") );
00565       List<String> button_list;
00566       button_list.insert_last( new String( _(" Ok ") ) );
00567       String info_text = (String)_("Tournament could not be loaded.") + String('\n')
00568         + error_msg;
00569       Dialog( info_text, button_list, 
00570               (DialogFunction) StartTournamentWindow::dummy_result );
00571     }
00572 }

Here is the call graph for this function:

void StartTournamentWindow::load_tournament_selected GtkWidget widget,
class StartTournamentWindow stw_p
[static]
 

Definition at line 480 of file StartTournamentWindow.cc.

References _, destroy_filesel(), gpointer, and GtkWidget.

Referenced by StartTournamentWindow().

00482 {
00483   if( stw_p->get_filesel() != NULL )
00484     return;
00485 
00486   GtkWidget* fs = gtk_file_selection_new( _("Choose a tournament file to load") );
00487   gtk_signal_connect( GTK_OBJECT( fs ), "destroy",
00488                       (GtkSignalFunc) StartTournamentWindow::destroy_filesel,
00489                       (gpointer) stw_p );
00490   gtk_signal_connect
00491     ( GTK_OBJECT( GTK_FILE_SELECTION( fs )->cancel_button ), "clicked",
00492       (GtkSignalFunc) StartTournamentWindow::destroy_filesel,
00493       (gpointer) stw_p );
00494   gtk_signal_connect
00495     ( GTK_OBJECT( GTK_FILE_SELECTION( fs )->ok_button ), "clicked",
00496       (GtkSignalFunc) StartTournamentWindow::load_file_selected,
00497       (gpointer) stw_p );
00498   gtk_widget_show( fs );
00499   stw_p->set_filesel( fs );
00500 }

Here is the call graph for this function:

void StartTournamentWindow::new_tournament const List< start_tournament_info_t > &  robotfilename_list,
const List< start_tournament_info_t > &  arenafilename_list,
const int  robots_p_game,
const int  games_p_sequence,
const int  n_o_sequences
 

Definition at line 587 of file StartTournamentWindow.cc.

References String::chars(), List< T >::delete_list(), start_tournament_info_t::directory, entries, start_tournament_info_t::filename, String::find(), List< T >::first(), Gui::get_bg_gdk_colour_p(), Gui::get_fg_gdk_colour_p(), get_segment(), GtkWidget, List< T >::insert_last(), ListIterator< T >::ok(), start_tournament_info_t::row, start_tournament_info_t::selected, and the_gui.

00592 {
00593 
00594   for( int i = 0; i<2; i++ )
00595     {
00596       GtkWidget* tour_clist;
00597       List<start_tournament_info_t>* tour_list;
00598       bool robot;
00599       if( i == 0 )
00600         {
00601           tour_list = &selected_robot_tournament;
00602           tour_clist = robots_in_tournament_clist;
00603           robot = true;
00604         }
00605       else
00606         {
00607           tour_list = &selected_arena_tournament;
00608           tour_clist = arenas_in_tournament_clist;
00609           robot = false;
00610         }
00611 
00612       gtk_clist_clear( GTK_CLIST( tour_clist ) );
00613       tour_list->delete_list();
00614 
00615       ListIterator<start_tournament_info_t> li;
00616       for( ( robot ? robotfilename_list.first(li) : arenafilename_list.first(li) );
00617              li.ok(); li++ )
00618         {
00619           start_tournament_info_t* info = li();
00620 
00621           char* lst[] = { "" };
00622 
00623           int row = gtk_clist_append( GTK_CLIST( tour_clist ), lst );
00624           gtk_clist_set_foreground( GTK_CLIST( tour_clist ), row, 
00625                                     the_gui.get_fg_gdk_colour_p());
00626           gtk_clist_set_background( GTK_CLIST( tour_clist ), row, 
00627                                     the_gui.get_bg_gdk_colour_p());
00628 
00629       
00630           String fname = info->filename;
00631           fname = get_segment( fname, fname.find( '/', 0, true ) + 1, -1 );
00632       
00633           gtk_clist_set_text( GTK_CLIST( tour_clist ),
00634                               row, 0, fname.chars() );
00635           info->selected = false;
00636           info->row = row;
00637           tour_list->insert_last( new start_tournament_info_t
00638                                   ( info->row, false, info->filename, info->directory ) );
00639         }
00640     }
00641   gtk_entry_set_text( GTK_ENTRY( entries[1] ), String(robots_p_game).chars() );
00642   gtk_entry_set_text( GTK_ENTRY( entries[0] ), String(games_p_sequence).chars() );
00643   gtk_entry_set_text( GTK_ENTRY( entries[2] ), String(n_o_sequences).chars() );
00644 }

Here is the call graph for this function:

void StartTournamentWindow::new_tournament_from_tournament_file const List< start_tournament_info_t > &  robotfilename_list,
const List< start_tournament_info_t > &  arenafilename_list,
const int  robots_p_game,
const int  games_p_sequence,
const int  n_o_sequences,
StartTournamentWindow stw_p
[static]
 

Definition at line 576 of file StartTournamentWindow.cc.

Referenced by load_tournament_file().

00580 {
00581   stw_p->new_tournament( robotfilename_list, arenafilename_list, robots_p_game,
00582                          games_p_sequence, n_o_sequences );
00583 }

void StartTournamentWindow::remove_all_selected const bool  robots  )  [private]
 

Definition at line 982 of file StartTournamentWindow.cc.

References List< T >::first(), get_arenas_in_tournament_clist(), get_robots_in_tournament_clist(), get_selected_arena_tournament(), get_selected_robot_tournament(), GtkWidget, ListIterator< T >::ok(), List< T >::remove(), start_tournament_info_t::row, and start_tournament_info_t::selected.

Referenced by button_selected().

00983 {
00984   ListIterator<start_tournament_info_t> li;
00985   ListIterator<start_tournament_info_t> li2;
00986   List<start_tournament_info_t>* info_dir_list;
00987   GtkWidget * clist_tourn;
00988 
00989   if(robots)
00990     {
00991       info_dir_list = get_selected_robot_tournament();
00992       clist_tourn = get_robots_in_tournament_clist();
00993     }
00994   else
00995     {
00996       info_dir_list = get_selected_arena_tournament();
00997       clist_tourn = get_arenas_in_tournament_clist();
00998     }
00999 
01000   for( info_dir_list->first(li) ; li.ok(); li++ )
01001     {
01002       start_tournament_info_t* info_p = li();
01003 
01004       if( info_p->selected )
01005         {
01006           gtk_clist_remove(GTK_CLIST(clist_tourn), info_p->row);
01007           
01008           for( info_dir_list->first(li2); li2.ok(); li2++ )
01009             {
01010               start_tournament_info_t* info2_p = li2();
01011               if(info2_p->row > info_p->row)
01012                 info2_p->row = info2_p->row - 1;
01013             }
01014           info_dir_list->remove(li);
01015         }
01016     }
01017 }

Here is the call graph for this function:

void StartTournamentWindow::save_file_selected GtkWidget widget,
class StartTournamentWindow stw_p
[static]
 

Definition at line 537 of file StartTournamentWindow.cc.

References destroy_filesel().

00539 {
00540   stw_p->save_tournament_file
00541     ( String( gtk_file_selection_get_filename
00542              ( GTK_FILE_SELECTION( stw_p->get_filesel() ) ) ),
00543       true, true );
00544   destroy_filesel( stw_p->get_filesel(), stw_p );
00545 }

Here is the call graph for this function:

void StartTournamentWindow::save_tournament_file const String full_filename,
bool  display_file_fail_message,
bool  display_tour_fail_message
[private]
 

Definition at line 647 of file StartTournamentWindow.cc.

References _, String::chars(), DialogFunction, dummy_result(), List< T >::first(), get_entries(), Options::get_l(), get_selected_robot_tournament(), List< T >::insert_last(), List< T >::is_empty(), max, min, List< T >::number_of_elements(), ListIterator< T >::ok(), OPTION_MAX_ROBOTS_ALLOWED, selected_arena_tournament, selected_robot_tournament, str2int(), and the_opts.

00650 {
00651   int value[3];
00652   int robot_number = get_selected_robot_tournament()->number_of_elements();
00653 
00654   for( int i = 0; i < 3; i++ )
00655     {
00656       int min_value;
00657       int max_value;
00658 
00659       if(i != 1)
00660         max_value = 10000;
00661       else
00662         {
00663           max_value = min( the_opts.get_l( OPTION_MAX_ROBOTS_ALLOWED ),robot_number);
00664         }
00665       if(i != 1)
00666         min_value = 1;
00667       else
00668         min_value = 2;
00669 
00670       value[i] = str2int( gtk_entry_get_text( GTK_ENTRY( get_entries()[i] ) ) );
00671 
00672       value[i] = min( max_value, value[i] );
00673       value[i] = max( min_value, value[i] );
00674     }
00675 
00676   ofstream file(full_filename.chars(), ios::out);
00677   if( robot_number > 1 && file &&
00678       !( selected_arena_tournament.is_empty() ) )
00679     {
00680       file << "Robots: " << endl;
00681       ListIterator<start_tournament_info_t> li;
00682       for( selected_robot_tournament.first(li); li.ok(); li++ )
00683         file << li()->filename << " " << endl;
00684 
00685       file << "Arenas: " << endl;
00686       for( selected_arena_tournament.first(li); li.ok(); li++ )
00687         file << li()->filename << " " << endl;
00688 
00689       file << "Robots/Sequence: " << value[1] << endl;
00690       file << "Games/Sequence: " << value[0] << endl;
00691       file << "Sequences: " << value[2] << endl;
00692     }
00693   else if( display_file_fail_message || display_tour_fail_message )
00694     {
00695       String error_msg( "" );
00696       if( display_tour_fail_message )
00697         {
00698           if( robot_number <= 1 )
00699             error_msg += String('\n') + _("There are too few robots in the tournament.");
00700           if( selected_arena_tournament.is_empty() )
00701             error_msg += String('\n') + _("There are no arenas in the tournament.");
00702         }
00703       if( display_file_fail_message && !file )
00704         error_msg += String('\n') + _("Could not open file.");
00705 
00706       if( error_msg != "" )
00707         {
00708           List<String> button_list;
00709           button_list.insert_last( new String( _(" Ok ") ) );
00710           String info_text = (String)_("Tournament could not be saved.") + error_msg;
00711           Dialog( info_text, button_list, 
00712                   (DialogFunction) StartTournamentWindow::dummy_result );
00713         }
00714     }
00715 }

Here is the call graph for this function:

void StartTournamentWindow::save_tournament_selected GtkWidget widget,
class StartTournamentWindow stw_p
[static]
 

Definition at line 514 of file StartTournamentWindow.cc.

References _, destroy_filesel(), gpointer, and GtkWidget.

Referenced by StartTournamentWindow().

00516 {
00517   if( stw_p->get_filesel() != NULL )
00518     return;
00519 
00520   GtkWidget* fs = gtk_file_selection_new( _("Choose file to save tournament into") );
00521   gtk_signal_connect( GTK_OBJECT( fs ), "destroy",
00522                       (GtkSignalFunc) StartTournamentWindow::destroy_filesel,
00523                       (gpointer) stw_p );
00524   gtk_signal_connect
00525     ( GTK_OBJECT( GTK_FILE_SELECTION( fs )->cancel_button ), "clicked",
00526       (GtkSignalFunc) StartTournamentWindow::destroy_filesel,
00527       (gpointer) stw_p );
00528   gtk_signal_connect
00529     ( GTK_OBJECT( GTK_FILE_SELECTION( fs )->ok_button ), "clicked",
00530       (GtkSignalFunc) StartTournamentWindow::save_file_selected,
00531       (gpointer) stw_p );
00532   gtk_widget_show( fs );
00533   stw_p->set_filesel( fs );
00534 }

Here is the call graph for this function:

void StartTournamentWindow::selection_made GtkWidget clist,
gint  row,
gint  column,
GdkEventButton event,
class StartTournamentWindow stw_p
[static]
 

Definition at line 1020 of file StartTournamentWindow.cc.

References start_tournament_info_t::selected.

Referenced by add_clist().

01023 {
01024   if( event == NULL )
01025     return;
01026 
01027   List<start_tournament_info_t>* info_list = NULL;
01028 
01029   if(clist == stw_p->get_robots_in_tournament_clist() )
01030     info_list = stw_p->get_selected_robot_tournament();
01031   else if(clist == stw_p->get_robots_in_directory_clist() )
01032     info_list = stw_p->get_selected_robot_directory();
01033   else if(clist == stw_p->get_arenas_in_tournament_clist() )
01034     info_list = stw_p->get_selected_arena_tournament();
01035   else if(clist == stw_p->get_arenas_in_directory_clist() )
01036     info_list = stw_p->get_selected_arena_directory();
01037 
01038   start_tournament_info_t* info_p;
01039   info_p = stw_p->find_row_in_clist( row, info_list );
01040   if( info_p->selected )
01041     info_p->selected = false;
01042   else 
01043     info_p->selected = true;
01044 }

void StartTournamentWindow::set_entry GtkWidget widget,
struct min_max_full_buttons_t mmf_p
[static]
 

Definition at line 718 of file StartTournamentWindow.cc.

References binomial(), StartTournamentWindow::min_max_full_buttons_t::entry, get_entries(), Options::get_l(), get_selected_arena_tournament(), get_selected_robot_tournament(), min, MMF_ALL_ARENAS, MMF_FULL_ROUND, MMF_MAX, MMF_MIN, List< T >::number_of_elements(), OPTION_MAX_ROBOTS_ALLOWED, str2int(), StartTournamentWindow::min_max_full_buttons_t::stw_p, the_opts, and StartTournamentWindow::min_max_full_buttons_t::type.

Referenced by StartTournamentWindow().

00720 {
00721   switch( mmf_p->type )
00722     {
00723     case MMF_MIN:
00724       {
00725         if( mmf_p->entry != 1 )
00726           gtk_entry_set_text( GTK_ENTRY( mmf_p->stw_p->get_entries()[mmf_p->entry] ), "1" );
00727         else
00728           gtk_entry_set_text( GTK_ENTRY( mmf_p->stw_p->get_entries()[mmf_p->entry] ), "2" );
00729       }
00730       break;
00731     case MMF_MAX:
00732       {
00733         if( mmf_p->entry != 1 )
00734           gtk_entry_set_text( GTK_ENTRY( mmf_p->stw_p->get_entries()[mmf_p->entry] ), "9999" );
00735         else
00736           {
00737             int number_of_robots = mmf_p->stw_p->
00738               get_selected_robot_tournament()->number_of_elements();
00739             if( number_of_robots > the_opts.get_l( OPTION_MAX_ROBOTS_ALLOWED ) )
00740               number_of_robots = the_opts.get_l( OPTION_MAX_ROBOTS_ALLOWED );
00741             gtk_entry_set_text
00742               ( GTK_ENTRY( mmf_p->stw_p->get_entries()[mmf_p->entry] ),
00743                 String(number_of_robots).chars() );
00744           }
00745       }
00746       break;
00747     case MMF_FULL_ROUND:
00748       {
00749         int number_of_robots = mmf_p->stw_p->
00750           get_selected_robot_tournament()->number_of_elements();
00751 
00752         int robots_per_sequence = 
00753           str2int( gtk_entry_get_text
00754                    ( GTK_ENTRY( mmf_p->stw_p->get_entries()[1] ) ) );
00755 
00756         if( number_of_robots < robots_per_sequence )
00757           robots_per_sequence = number_of_robots;
00758         if( robots_per_sequence > the_opts.get_l( OPTION_MAX_ROBOTS_ALLOWED ) )
00759           robots_per_sequence = the_opts.get_l( OPTION_MAX_ROBOTS_ALLOWED );
00760         if( robots_per_sequence < 2 )
00761           robots_per_sequence = 2;
00762         gtk_entry_set_text
00763           ( GTK_ENTRY( mmf_p->stw_p->get_entries()[mmf_p->entry] ),
00764             String( min ( 9999, binomial( number_of_robots,
00765                                           robots_per_sequence) ) ).chars() );
00766       }
00767       break;
00768     case MMF_ALL_ARENAS:
00769       {
00770         int number_of_arenas = mmf_p->stw_p->
00771           get_selected_arena_tournament()->number_of_elements();
00772 
00773         if( number_of_arenas > the_opts.get_l( OPTION_MAX_ROBOTS_ALLOWED ) )
00774           number_of_arenas = the_opts.get_l( OPTION_MAX_ROBOTS_ALLOWED );
00775         if( number_of_arenas < 1 )
00776           number_of_arenas = 1;
00777         gtk_entry_set_text
00778           ( GTK_ENTRY( mmf_p->stw_p->get_entries()[mmf_p->entry] ),
00779             String(number_of_arenas).chars() );
00780       }
00781       break;
00782     }
00783 }

Here is the call graph for this function:

void StartTournamentWindow::set_filesel GtkWidget fs  )  [inline, private]
 

Definition at line 146 of file StartTournamentWindow.h.

00146 { filesel = fs; } 

void StartTournamentWindow::set_tournament_started_flag bool  started  )  [inline]
 

Definition at line 123 of file StartTournamentWindow.h.

00124     { tournament_started_flag = started; }

void StartTournamentWindow::start GtkWidget widget,
class StartTournamentWindow stw_p
[static]
 

Definition at line 786 of file StartTournamentWindow.cc.

References _, Gui::close_starttournamentwindow(), create_tmp_rtb_dir(), DialogFunction, dummy_result(), Options::get_l(), Options::get_s(), List< T >::insert_last(), ArenaController::is_started(), max, min, NOT_STARTED, OPTION_MAX_ROBOTS_ALLOWED, OPTION_TMP_RTB_DIR, realtime_arena, ArenaController::start_realtime_arena(), str2int(), the_arena, the_arena_controller, the_gui, and the_opts.

Referenced by StartTournamentWindow().

00788 {
00789   if( stw_p->get_tournament_started_flag() == true )
00790     return;
00791 
00792   if( the_arena_controller.is_started() )
00793     if( the_arena.get_state() != NOT_STARTED && the_arena.get_state() != FINISHED )
00794       return;
00795 
00796   int value[3];
00797   int robot_number = stw_p->get_selected_robot_tournament()->number_of_elements();
00798 
00799   for( int i = 0; i < 3; i++ )
00800     {
00801       int min_value;
00802       int max_value;
00803 
00804       if(i != 1)
00805         max_value = 10000;
00806       else
00807         {
00808           max_value = min(the_opts.get_l( OPTION_MAX_ROBOTS_ALLOWED ),robot_number);
00809         }
00810       if(i != 1)
00811         min_value = 1;
00812       else
00813         min_value = 2;
00814 
00815       value[i] = str2int( gtk_entry_get_text( GTK_ENTRY( stw_p->get_entries()[i] ) ) );
00816 
00817       value[i] = min( max_value, value[i] );
00818       value[i] = max( min_value, value[i] );
00819     }
00820   if( robot_number > 1 &&
00821       !( stw_p->get_selected_arena_tournament()->is_empty() ) )
00822     {
00823       stw_p->set_tournament_started_flag( true );
00824       the_arena_controller.start_realtime_arena();
00825       realtime_arena.start_tournament( *( stw_p->get_selected_robot_tournament() ),
00826                                        *( stw_p->get_selected_arena_tournament() ),
00827                                        value[1], value[0], value[2] );
00828 
00829       // create the tmp rtb dir if it exists and save the current tournament there
00830       create_tmp_rtb_dir();
00831       stw_p->save_tournament_file( the_opts.get_s( OPTION_TMP_RTB_DIR ) +
00832                                    tmp_tournament_file, false, false );
00833 
00834       // close down StartTournamentWindow
00835       the_gui.close_starttournamentwindow();
00836     }
00837   else
00838     {
00839       String error_msg( "" );
00840       if( robot_number <= 1 )
00841         error_msg += String('\n') + _("There must be at least two robots in the tournament.");
00842       if( stw_p->selected_arena_tournament.is_empty() )
00843         error_msg += String('\n') + _("There are no arenas in the tournament.");
00844 
00845       if( error_msg != "" )
00846         {
00847           List<String> button_list;
00848           button_list.insert_last( new String( _(" Ok ") ) );
00849           String info_text = _("Tournament could not be started.") + error_msg;
00850           Dialog( info_text, button_list, 
00851                   (DialogFunction) StartTournamentWindow::dummy_result );
00852         }
00853     }
00854 }

Here is the call graph for this function:


Field Documentation

GtkWidget* StartTournamentWindow::arenas_in_directory_clist [private]
 

Definition at line 176 of file StartTournamentWindow.h.

Referenced by StartTournamentWindow().

GtkWidget* StartTournamentWindow::arenas_in_tournament_clist [private]
 

Definition at line 175 of file StartTournamentWindow.h.

Referenced by StartTournamentWindow().

GtkWidget* StartTournamentWindow::entries[3] [private]
 

Definition at line 170 of file StartTournamentWindow.h.

Referenced by new_tournament(), and StartTournamentWindow().

GtkWidget* StartTournamentWindow::filesel [private]
 

Definition at line 171 of file StartTournamentWindow.h.

Referenced by StartTournamentWindow().

GtkWidget* StartTournamentWindow::robots_in_directory_clist [private]
 

Definition at line 174 of file StartTournamentWindow.h.

Referenced by StartTournamentWindow().

GtkWidget* StartTournamentWindow::robots_in_tournament_clist [private]
 

Definition at line 173 of file StartTournamentWindow.h.

Referenced by StartTournamentWindow().

List<start_tournament_info_t> StartTournamentWindow::selected_arena_directory [private]
 

Definition at line 181 of file StartTournamentWindow.h.

List<start_tournament_info_t> StartTournamentWindow::selected_arena_tournament [private]
 

Definition at line 180 of file StartTournamentWindow.h.

Referenced by save_tournament_file().

List<start_tournament_info_t> StartTournamentWindow::selected_robot_directory [private]
 

Definition at line 179 of file StartTournamentWindow.h.

List<start_tournament_info_t> StartTournamentWindow::selected_robot_tournament [private]
 

Definition at line 178 of file StartTournamentWindow.h.

Referenced by save_tournament_file().

bool StartTournamentWindow::tournament_started_flag [private]
 

Definition at line 183 of file StartTournamentWindow.h.

Referenced by StartTournamentWindow().

GtkWidget* StartTournamentWindow::window_p [private]
 

Definition at line 168 of file StartTournamentWindow.h.

Referenced by add_clist(), StartTournamentWindow(), and ~StartTournamentWindow().


The documentation for this class was generated from the following files:
Generated on Fri Oct 15 15:51:22 2004 for Real Time Battle by  doxygen 1.3.9.1