Beispiel #1
0
int recruit_dialog(display& disp, std::vector< const unit_type* >& units, const std::vector< std::string >& items, int side, const std::string& title_suffix)
{
	dialogs::unit_types_preview_pane unit_preview(
		units, NULL, side);
	std::vector<gui::preview_pane*> preview_panes;
	preview_panes.push_back(&unit_preview);

	gui::menu::basic_sorter sorter;
	sorter.set_alpha_sort(1);

	gui::dialog rmenu(disp, _("Recruit") + title_suffix,
			  _("Select unit:") + std::string("\n"),
			  gui::OK_CANCEL,
			  gui::dialog::default_style);
	rmenu.add_button(new help::help_button(disp, "recruit_and_recall"),
		gui::dialog::BUTTON_HELP);

	gui::menu::imgsel_style units_display_style(gui::menu::bluebg_style);
	units_display_style.scale_images(font::relative_size(72), font::relative_size(72));

	gui::menu* units_menu = new gui::menu(disp.video(), items, false, -1,
		gui::dialog::max_menu_width, &sorter, &units_display_style, false);

	units_menu->sort_by(1); // otherwise it's unsorted by default

	rmenu.set_menu(units_menu);
	rmenu.set_panes(preview_panes);
	return rmenu.show();
}
Beispiel #2
0
main()
{
  char infix[100];
  char postfix[100];
  int choice,quit = 0;

  while(quit == 0)
    {
      choice = menu();
      switch(choice)
	{

	case 1:  printf("\nEnter infix: ");
                 scanf("%s",infix);
		 rmenu();
		 break;

	case 2: inFix_to_postFix(infix,postfix);
	        printf("\nPostfix: %s\n",postfix);
		rmenu();
		break;

	case 3: printf("\nResult: %.1f\n",caculate(postfix));
	        rmenu();
	        break;

	case 4: about();
	        rmenu();
	        break;

	case 5: printf("Have funny time!!\n");
                quit++;
	        break;

	default: printf("Please choose from 1 to 5.\n");

	}
    }
  return 0;
}
Beispiel #3
0
void mainmenu(void)
/* Executes the commands in the main menu */
{
 switch(getcommand(MENU, COMMAND))
 {
  case 0 :
   smenu();
   break;
  case 1 :
   formatcells();
   break;
  case 2 :
   deletecell(curcol, currow, UPDATE);
   printfreemem();
   if (autocalc)
    recalc();
   break;
  case 3 :
   gotocell();
   break;
  case 4 :
   cmenu();
   break;
  case 5 :
   rmenu();
   break;
  case 6 :
   editcell(curcell);
   break;
  case 7 :
   umenu();
   break;
  case 8 :
   changeautocalc(!autocalc);
   break;
  case 9 :
   checkforsave();
   stop = TRUE;
   break;
 } /* switch */
} /* mainmenu */
Beispiel #4
0
main()
{
  FILE *f;
  Llist *root,*root2;
  int quit = 0, choice;
  int i,n,k,k1,k2;
  ElmType *key;

  newLlist(&root);
  newLlist(&root2);

  while(quit == 0)
    {
      choice = menu();
      switch(choice)
	{
		 
	case 1:  if((f = fopen("NokiaDB.dat","rb")) == NULL)
                   printf("Cannot open file %s.\n","NokiaDB.dat");
		 else
		   { 
		     key = (ElmType*)malloc(MAX * sizeof(ElmType));
		     n = fread(key, sizeof(ElmType), MAX, f);
		     for(i = 0; i < n; i++)
		       addLast(&root,key[i]);
		     printf("\nRead data from file %s successfully!\n","NokiaDB.dat");
		   }
	         fclose(f);
		 free(key);
		 rmenu();
		 break;
		  
       	case 2:  printList(root);
	         rmenu();
	         break;

	case 3:  printf("Split from line: ");
                 scanf("%d",&k);
		 root2 = split(root,k);
		 printf("List 1:\n");
		 printList(root);
		 
		 printf("\nList 2:\n");
		 printList(root2);
		 rmenu();
		 break;
		 
	case 4: printf("Split from line: ");
                scanf("%d",&k1);
		printf("Split to line: ");
		scanf("%d",&k2);
	       
		root2 = divide(root,k1,k2,n);
		printf("List 1:\n");
		printList(root);
		printf("\nList 2:\n");
		printList(root2);
		rmenu();
		break;

	case 5: printf("Have funny time!!\n");
	        LlistFree(root);
                quit++;
                break;

	default:  printf("Wrong choice!\nChoose from 1 to 5.\n");

        }
    }
  return 0;
}
Beispiel #5
0
main()
{
  int i,n,k;
  int quit = 0,choice;
  ElmType key;
  char s[12];
  FILE *f1,*f2;
  Llist *root,*p;

  newLlist(&root);

  while(quit == 0)
    {
      choice = menu();
      switch(choice)
	{

	case 1:  printf("How may people do you want to add? ");
	         scanf("%d",&n);
	         for(i = 0; i < n; i++)
		   { 
		     key = makeData();
		     addLast(&root,key);
		   }
		 rmenu();
		 break;

	case 2:  printList(root);
                 rmenu();
	         break;
	
	case 3:  printf("The position you want to delete: ");
	         scanf("%d",&k);
		 if(k < n && k > 0)
		   delNode(&root,k);
		 else 
		   printf("\nEnter position k(k >0 and k< %d) again.\n",n);
		 rmenu();
		 break;

	case 4:  printf("The position you want to insert: ");
	         scanf("%d",&k);
		 if(k < n && k > 0)
		   {
		     key = makeData();
		     addBefore(&root,k,key);
		   }
		 else 
		   printf("\nEnter position k(k >0 and k<= %d)again.\n",n);
		 rmenu();
		 break;

	case 5:  printf("The number you want to find: ");
	         scanf("%s",s);
		 p = search(root,s);
		 if(p == NULL) printf("This number is n't in the list.\n");
		 else printf(" + Name: %s\n + Email: %s\n",p->key.name,p->key.mail);
		 rmenu();
		 break;
		 
	case 6: f1 = fopen("contact.txt","w");
	        f2 = fopen("contact.dat","wb");
		save_txt(root,f1);
		saveDat(root,f2);
		fclose(f1);
		fclose(f2);
		rmenu();
		break;
	  
	case 7:  LlistFree(root);
	         printf("Have funny times!!\n");
		 quit++;
		 break;
		 
	default: printf("Please choose from 1 to 7.\n");

	}
    }
  return 0;
}