@@ -172,78 +172,6 @@ GenericItemsMenu::max_cols(int n_items, NCursesMenuItem **items)
172172}
173173
174174
175- MachinePlacingMenu::MachinePlacingMenu (NCursesWindow *parent,
176- std::string machine, std::string puck,
177- bool can_be_placed_under_rfid, bool can_be_loaded_with)
178- : Menu(det_lines(can_be_placed_under_rfid, can_be_loaded_with), 30,
179- (parent->lines () - 5)/2, (parent->cols () - 30)/2)
180- {
181- valid_selected_ = false ;
182- place_under_rfid_ = false ;
183- s_under_rfid_ = " Place " + puck.substr (0 ,2 ) + " under RFID of " + machine;
184- s_loaded_with_ = " Load " + machine + " with " + puck.substr (0 ,2 );
185- s_cancel_ = " ** CANCEL **" ;
186- NCursesMenuItem **mitems = new NCursesMenuItem*[4 ];
187-
188- int idx = 0 ;
189-
190- if (can_be_placed_under_rfid) {
191- SignalItem *item = new SignalItem (s_under_rfid_);
192- item->signal ().connect (boost::bind (&MachinePlacingMenu::item_selected, this , true ));
193- mitems[idx++] = item;
194- }
195-
196- if (can_be_loaded_with) {
197- SignalItem *item = new SignalItem (s_loaded_with_);
198- item->signal ().connect (boost::bind (&MachinePlacingMenu::item_selected, this , false ));
199- mitems[idx++] = item;
200- }
201- mitems[idx++] = new SignalItem (s_cancel_);
202- mitems[idx++] = new NCursesMenuItem ();
203-
204-
205- set_mark (" " );
206- set_format (idx-1 , 1 );
207- InitMenu (mitems, true , true );
208- frame (" Placing" );
209- }
210-
211- int
212- MachinePlacingMenu::det_lines (bool can_be_placed_under_rfid, bool can_be_loaded_with)
213- {
214- int rv = 3 ;
215- if (can_be_placed_under_rfid) rv += 1 ;
216- if (can_be_loaded_with) rv += 1 ;
217- return rv;
218- }
219-
220- void
221- MachinePlacingMenu::item_selected (bool under_rfid)
222- {
223- valid_selected_ = true ;
224- place_under_rfid_ = under_rfid;
225- }
226-
227- bool
228- MachinePlacingMenu::place_under_rfid ()
229- {
230- return place_under_rfid_;
231- }
232-
233- void
234- MachinePlacingMenu::On_Menu_Init ()
235- {
236- bkgd (' ' |COLOR_PAIR (COLOR_DEFAULT));
237- // subWindow().bkgd(parent_->getbkgd());
238- refresh ();
239- }
240-
241- MachinePlacingMenu::operator bool () const
242- {
243- return valid_selected_;
244- }
245-
246-
247175TeamSelectMenu::TeamSelectMenu (NCursesWindow *parent,
248176 llsf_msgs::Team team,
249177 std::shared_ptr<llsf_msgs::GameInfo> gameinfo,
@@ -396,6 +324,78 @@ TeamColorSelectMenu::det_lines()
396324 return team_enum_desc->value_count ();
397325}
398326
327+ GameMenu::GameMenu (NCursesWindow *parent)
328+ : Menu(det_lines(), det_cols(), (parent->lines () - det_lines()) / 2, (parent->cols () - det_cols()) / 2),
329+ menu_selected_(false )
330+ {
331+ NCursesMenuItem **mitems = new NCursesMenuItem *[3 ];
332+ SignalItem * randomize_item = new SignalItem (s_randomize_);
333+ SignalItem * cancel_item = new SignalItem (s_cancel_);
334+ randomize_item->signal ().connect ([this ]() {
335+ next_menu_ = randomize;
336+ menu_selected_ = true ;
337+ });
338+ int idx = 0 ;
339+ mitems[idx++] = randomize_item;
340+ mitems[idx++] = cancel_item;
341+ mitems[idx++] = new NCursesMenuItem ();
342+ set_mark (" " );
343+ set_format (idx, 1 );
344+ InitMenu (mitems, true , true );
345+ }
346+
347+ void
348+ GameMenu::On_Menu_Init ()
349+ {
350+ bkgd (' ' | COLOR_PAIR (COLOR_DEFAULT));
351+ box ();
352+ attron (' ' | COLOR_PAIR (COLOR_BLACK_ON_BACK) | A_BOLD);
353+ addstr (0 , (width () - 6 ) / 2 , " GAME " );
354+ attroff (A_BOLD);
355+ refresh ();
356+ }
357+
358+ GameMenu::SubMenu
359+ GameMenu::get_next_menu () const
360+ {
361+ return next_menu_;
362+ }
363+
364+ GameMenu::operator bool () const
365+ {
366+ return menu_selected_;
367+ }
368+
369+
370+ RandomizeFieldMenu::RandomizeFieldMenu (NCursesWindow *parent)
371+ : Menu(det_lines(), det_cols(), (parent->lines () - det_lines()) / 2, (parent->cols () - det_cols()) / 2),
372+ confirmed_(false )
373+ {
374+ NCursesMenuItem **mitems = new NCursesMenuItem *[3 ];
375+ SignalItem * yes_item = new SignalItem (s_yes_);
376+ yes_item->signal ().connect ([this ]() { confirmed_ = true ; });
377+ SignalItem *no_item = new SignalItem (s_no_);
378+ no_item->signal ().connect ([this ]() { confirmed_ = false ; });
379+ int idy = 0 ;
380+ mitems[idy++] = yes_item;
381+ mitems[idy++] = no_item;
382+ mitems[idy++] = new NCursesMenuItem ();
383+ set_mark (" " );
384+ set_format (1 , idy - 1 );
385+ InitMenu (mitems, true , true );
386+ }
387+
388+ void
389+ RandomizeFieldMenu::On_Menu_Init ()
390+ {
391+ bkgd (' ' | COLOR_PAIR (COLOR_DEFAULT));
392+ box ();
393+ attron (' ' | COLOR_PAIR (COLOR_BLACK_ON_BACK) | A_BOLD);
394+ addstr (0 , (width () - 18 ) / 2 , " Randomize Field? " );
395+ attroff (A_BOLD);
396+ refresh ();
397+ }
398+
399399
400400RobotMaintenanceMenu::RobotMaintenanceMenu (NCursesWindow *parent, llsf_msgs::Team team,
401401 std::shared_ptr<llsf_msgs::RobotInfo> rinfo)
0 commit comments