Difference for main/newmenu.c from version 1.9 to 1.10


version 1.9 version 1.10
Line 19
 
Line 19
  * Routines for menus.   * Routines for menus.
  *    *
  * $Log$   * $Log$
    * Revision 1.10  2000/10/27 09:25:09  donut
    * made newmenu_do3_real take fonts to use, and make newmenu_do3 and newmenu_do_fixedfont call that
    *
  * Revision 1.9  2000/10/27 02:58:00  donut   * Revision 1.9  2000/10/27 02:58:00  donut
  * menu background drawing correctly scaled at high res instead of being squished.  made nm_restore_background scale as well   * menu background drawing correctly scaled at high res instead of being squished.  made nm_restore_background scale as well
  *   *
Line 958
 
Line 961
  return newmenu_do3( title, subtitle, nitems, item, subfunction, citem, filename, -1, -1 );   return newmenu_do3( title, subtitle, nitems, item, subfunction, citem, filename, -1, -1 );
 }  }
   
 int newmenu_do3( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int citem, char * filename, int width, int height )  //Edited 2000/10/27 Matthew Mueller - made newmenu_do3 allow you to set the fonts used, thus allowing newmenu_do_fixedfont to be removed, saving a lot of duplication.
   int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int citem, char * filename, int width, int height, grs_font *title_font, grs_font *subtitle_font, grs_font *menu_font, grs_font *normal_font)
 {  {
  int old_keyd_repeat, done;   int old_keyd_repeat, done;
  int  choice,old_choice,i,j,x,y,w,h,aw, tw, th, twidth,fm,right_offset;   int  choice,old_choice,i,j,x,y,w,h,aw, tw, th, twidth,fm,right_offset;
Line 974
 
Line 978
  if (nitems < 1 )   if (nitems < 1 )
  return -1;   return -1;
   
 //changed 7/11/99 adb - otherwise d3d problems...  
 #ifdef D1XD3D  
  set_screen_mode(SCREEN_MENU);  
 #else  
 #ifdef OGL  
  set_screen_mode(SCREEN_MENU);   set_screen_mode(SCREEN_MENU);
 // ogl_set_screen_mode();  
 #endif  
 //killed 4/23/99 Matt Mueller - don't switch res for menus.. some menus like their own, but they would need editing to put text correctly and stuff anyway  
 //--killed--   set_screen_mode(SCREEN_MENU);  
 //end kill -MM  
 #endif  
 //end changes - adb  
   
 //NO_SOUND_PAUSE if ( Function_mode == FMODE_GAME ) {  //NO_SOUND_PAUSE if ( Function_mode == FMODE_GAME ) {
 //NO_SOUND_PAUSE digi_pause_all();  //NO_SOUND_PAUSE digi_pause_all();
Line 1006
 
Line 998
  tw = th = 0;   tw = th = 0;
   
  if ( title ) {   if ( title ) {
  grd_curcanv->cv_font = TITLE_FONT;   grd_curcanv->cv_font = title_font;
  gr_get_string_size(title,&string_width,&string_height,&average_width );   gr_get_string_size(title,&string_width,&string_height,&average_width );
  tw = string_width;   tw = string_width;
  th = string_height;   th = string_height;
  }   }
  if ( subtitle ) {   if ( subtitle ) {
  grd_curcanv->cv_font = SUBTITLE_FONT;   grd_curcanv->cv_font = subtitle_font;
  gr_get_string_size(subtitle,&string_width,&string_height,&average_width );   gr_get_string_size(subtitle,&string_width,&string_height,&average_width );
  if (string_width > tw )   if (string_width > tw )
  tw = string_width;   tw = string_width;
Line 1022
 
Line 1014
   
  th += 8; //put some space between titles & body   th += 8; //put some space between titles & body
   
  grd_curcanv->cv_font = NORMAL_FONT;   grd_curcanv->cv_font = normal_font;
   
  w = aw = 0;   w = aw = 0;
  h = th;   h = th;
Line 1164
 
Line 1156
  }   }
   
  // Save the background of the display   // Save the background of the display
 //changed 7/11/99 adb - otherwise d3d problems...  
 #ifdef D1XD3D  
  bg.menu_canvas = gr_create_sub_canvas( &grd_curscreen->sc_canvas, x, y, w, h );   bg.menu_canvas = gr_create_sub_canvas( &grd_curscreen->sc_canvas, x, y, w, h );
 #else  
       //edited 4/30/99 by Owen Evans to fix res-changing  
 //        bg.menu_canvas = gr_create_sub_canvas( &grd_curscreen->sc_canvas, x, y, w, h );  
         bg.menu_canvas = gr_create_sub_canvas(&VR_screen_pages[VR_current_page], x, y, w, h );  
       //end this section edit - OE  
 #endif  
  gr_set_current_canvas( bg.menu_canvas );   gr_set_current_canvas( bg.menu_canvas );
 //end changes - adb  
   
  if ( filename == NULL ) {   if ( filename == NULL ) {
  // Save the background under the menu...   // Save the background under the menu...
  bg.saved = gr_create_bitmap( w, h );   bg.saved = gr_create_bitmap( w, h );
  Assert( bg.saved != NULL );   Assert( bg.saved != NULL );
  gr_bm_bitblt(w, h, 0, 0, 0, 0, &grd_curcanv->cv_bitmap, bg.saved );   gr_bm_bitblt(w, h, 0, 0, 0, 0, &grd_curcanv->cv_bitmap, bg.saved );
 //changed 7/11/99 adb - otherwise d3d problems...  
 #ifdef D1XD3D  
  gr_set_current_canvas( NULL );   gr_set_current_canvas( NULL );
 #else  
       //edited 4/30/99 by Owen Evans to fix res-changing  
 //                gr_set_current_canvas( NULL );  
                 gr_set_current_canvas( &VR_screen_pages[VR_current_page] );  
       //end this section edit - OE  
 #endif  
 //end changes - adb  
  nm_draw_background(x,y,x+w-1,y+h-1);   nm_draw_background(x,y,x+w-1,y+h-1);
  if (GWIDTH > nm_background.bm_w || GHEIGHT > nm_background.bm_h){   if (GWIDTH > nm_background.bm_w || GHEIGHT > nm_background.bm_h){
  grs_bitmap sbg;   grs_bitmap sbg;
Line 1208
 
Line 1182
  bg.background = gr_create_bitmap( w, h );   bg.background = gr_create_bitmap( w, h );
  Assert( bg.background != NULL );   Assert( bg.background != NULL );
  gr_bm_bitblt(w, h, 0, 0, 0, 0, &grd_curcanv->cv_bitmap, bg.background );   gr_bm_bitblt(w, h, 0, 0, 0, 0, &grd_curcanv->cv_bitmap, bg.background );
    printf("hello #######\n");//##############
  }   }
   
 // ty = 15 + (yborder/4);  // ty = 15 + (yborder/4);
Line 1234
 
Line 1209
   
   
  if ( title ) {   if ( title ) {
  grd_curcanv->cv_font = TITLE_FONT;   grd_curcanv->cv_font = title_font;
  gr_set_fontcolor( GR_GETCOLOR(31,31,31), -1 );   gr_set_fontcolor( GR_GETCOLOR(31,31,31), -1 );
  gr_get_string_size(title,&string_width,&string_height,&average_width );   gr_get_string_size(title,&string_width,&string_height,&average_width );
  tw = string_width;   tw = string_width;
Line 1244
 
Line 1219
  }   }
   
  if ( subtitle ) {   if ( subtitle ) {
  grd_curcanv->cv_font = SUBTITLE_FONT;   grd_curcanv->cv_font = subtitle_font;
  gr_set_fontcolor( GR_GETCOLOR(21,21,21), -1 );   gr_set_fontcolor( GR_GETCOLOR(21,21,21), -1 );
  gr_get_string_size(subtitle,&string_width,&string_height,&average_width );   gr_get_string_size(subtitle,&string_width,&string_height,&average_width );
  tw = string_width;   tw = string_width;
Line 1253
 
Line 1228
  ty += th;   ty += th;
  }   }
   
  grd_curcanv->cv_font = NORMAL_FONT;   grd_curcanv->cv_font = normal_font;
    
  // Update all item's x & y values.   // Update all item's x & y values.
  for (i=0; i<nitems; i++ ) {   for (i=0; i<nitems; i++ ) {
Line 1598
 
Line 1573
    
 }  }
   
   int newmenu_do_fixedfont( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int citem, char * filename, int width, int height){
    return newmenu_do3_real( title, subtitle, nitems, item, subfunction, citem, filename, width,height, GAME_FONT, GAME_FONT, GAME_FONT, GAME_FONT);
   }
   
   int newmenu_do3( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int citem, char * filename, int width, int height){
    return newmenu_do3_real( title, subtitle, nitems, item, subfunction, citem, filename, width,height, TITLE_FONT, SUBTITLE_FONT, MENU_FONT, NORMAL_FONT);
   }
   
   
   
 int nm_messagebox1( char *title, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int nchoices, ... )  int nm_messagebox1( char *title, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int nchoices, ... )
 {  {
Line 2299
 
Line 2283
 }  }
   
 //added on 10/14/98 by Victor Rachels to attempt a fixedwidth font messagebox  //added on 10/14/98 by Victor Rachels to attempt a fixedwidth font messagebox
 int newmenu_do_fixedfont( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int citem, char * filename, int width, int height )  
 {  
  int old_keyd_repeat, done;  
  int  choice,old_choice,i,j,x,y,w,h,aw, tw, th, twidth,fm,right_offset;  
  int k, nmenus, nothers;  
  grs_canvas * save_canvas;  
  grs_font * save_font;  
  int string_width, string_height, average_width;  
  int ty;  
  bkg bg;  
  int all_text=0; //set true if all text items  
  int time_stopped=0;  
   
  if (nitems < 1 )  
  return -1;  
   
  set_screen_mode(SCREEN_MENU);  
   
 //NO_SOUND_PAUSE if ( Function_mode == FMODE_GAME ) {  
 //NO_SOUND_PAUSE digi_pause_all();  
 //NO_SOUND_PAUSE sound_stopped = 1;  
 //NO_SOUND_PAUSE }  
   
  if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )  
  {  
  time_stopped = 1;  
  stop_time();  
  }  
   
  save_canvas = grd_curcanv;  
  gr_set_current_canvas( NULL );   
  save_font = grd_curcanv->cv_font;  
   
  tw = th = 0;  
   
  if ( title ) {  
                 grd_curcanv->cv_font = GAME_FONT;  
  gr_get_string_size(title,&string_width,&string_height,&average_width );  
  tw = string_width;  
  th = string_height;  
  }  
  if ( subtitle ) {  
                 grd_curcanv->cv_font = GAME_FONT;  
  gr_get_string_size(subtitle,&string_width,&string_height,&average_width );  
  if (string_width > tw )  
  tw = string_width;  
  th += string_height;  
  }  
   
  th += 8; //put some space between titles & body  
   
         grd_curcanv->cv_font = GAME_FONT;  
   
  w = aw = 0;  
  h = th;  
  nmenus = nothers = 0;  
   
  // Find menu height & width (store in w,h)  
  for (i=0; i<nitems; i++ ) {  
  item[i].redraw=1;  
  item[i].y = h;  
  gr_get_string_size(item[i].text,&string_width,&string_height,&average_width );  
  item[i].right_offset = 0;  
   
  item[i].saved_text[0] = '\0';  
   
  if ( item[i].type == NM_TYPE_SLIDER ) {  
  int w1,h1,aw1;  
  nothers++;  
  sprintf( item[i].saved_text, "%s", SLIDER_LEFT );  
  for (j=0; j<(item[i].max_value-item[i].min_value+1); j++ ) {  
  sprintf( item[i].saved_text, "%s%s", item[i].saved_text,SLIDER_MIDDLE );  
  }  
  sprintf( item[i].saved_text, "%s%s", item[i].saved_text,SLIDER_RIGHT );  
  gr_get_string_size(item[i].saved_text,&w1,&h1,&aw1 );  
  string_width += w1 + aw;  
  }  
   
  if ( item[i].type == NM_TYPE_MENU ) {  
  nmenus++;  
  }  
   
  if ( item[i].type == NM_TYPE_CHECK ) {  
  int w1,h1,aw1;  
  nothers++;  
  gr_get_string_size(NORMAL_CHECK_BOX, &w1, &h1, &aw1  );  
  item[i].right_offset = w1;  
  gr_get_string_size(CHECKED_CHECK_BOX, &w1, &h1, &aw1  );  
  if (w1 > item[i].right_offset)  
  item[i].right_offset = w1;  
  }  
    
  if (item[i].type == NM_TYPE_RADIO ) {  
  int w1,h1,aw1;  
  nothers++;  
  gr_get_string_size(NORMAL_RADIO_BOX, &w1, &h1, &aw1  );  
  item[i].right_offset = w1;  
  gr_get_string_size(CHECKED_RADIO_BOX, &w1, &h1, &aw1  );  
  if (w1 > item[i].right_offset)  
  item[i].right_offset = w1;  
  }  
   
  if  (item[i].type==NM_TYPE_NUMBER ) {  
  int w1,h1,aw1;  
  char test_text[20];  
  nothers++;  
  sprintf( test_text, "%d", item[i].max_value );  
  gr_get_string_size( test_text, &w1, &h1, &aw1 );  
  item[i].right_offset = w1;  
  sprintf( test_text, "%d", item[i].min_value );  
  gr_get_string_size( test_text, &w1, &h1, &aw1 );  
  if ( w1 > item[i].right_offset)  
  item[i].right_offset = w1;  
  }  
   
  if ( item[i].type == NM_TYPE_INPUT ) {  
  Assert( strlen(item[i].text) < NM_MAX_TEXT_LEN );  
  strcpy(item[i].saved_text, item[i].text );  
  nothers++;  
  string_width = item[i].text_len*grd_curcanv->cv_font->ft_w+item[i].text_len;  
  if ( string_width > MAX_TEXT_WIDTH )   
  string_width = MAX_TEXT_WIDTH;  
  item[i].value = -1;  
  }  
   
  if ( item[i].type == NM_TYPE_INPUT_MENU ) {  
  Assert( strlen(item[i].text) < NM_MAX_TEXT_LEN );  
  strcpy(item[i].saved_text, item[i].text );  
  nmenus++;  
  string_width = item[i].text_len*grd_curcanv->cv_font->ft_w+item[i].text_len;  
  item[i].value = -1;  
  item[i].group = 0;  
  }  
   
  item[i].w = string_width;  
  item[i].h = string_height;  
   
  if ( string_width > w )  
  w = string_width; // Save maximum width  
  if ( average_width > aw )  
  aw = average_width;  
  h += string_height+1; // Find the height of all strings  
  }  
   
  right_offset=0;  
   
  if ( width > -1 )  
  w = width;  
   
  if ( height > -1 )  
  h = height;  
   
  for (i=0; i<nitems; i++ ) {  
  item[i].w = w;  
  if (item[i].right_offset > right_offset )  
  right_offset = item[i].right_offset;  
  }  
  if (right_offset > 0 )  
  right_offset += 3;  
    
  //mprintf( 0, "Right offset = %d\n", right_offset );  
   
  //gr_get_string_size("",&string_width,&string_height,&average_width );  
   
  w += right_offset;  
   
  twidth = 0;  
  if ( tw > w ) {  
  twidth = ( tw - w )/2;  
  w = tw;  
  }  
    
  // Find min point of menu border  
 // x = (grd_curscreen->sc_w-w)/2;  
 // y = (grd_curscreen->sc_h-h)/2;  
   
  w += 30;  
  h += 30;  
   
  if ( w > 320 ) w = 320;  
  if ( h > 200 ) h = 200;  
   
  x = (grd_curcanv->cv_bitmap.bm_w-w)/2;  
  y = (grd_curcanv->cv_bitmap.bm_h-h)/2;  
   
  if ( x < 0 ) x = 0;  
  if ( y < 0 ) y = 0;  
    
  if ( filename != NULL ) {  
  nm_draw_background1( filename );  
  }  
   
  // Save the background of the display  
  bg.menu_canvas = gr_create_sub_canvas( &grd_curscreen->sc_canvas, x, y, w, h );  
  gr_set_current_canvas( bg.menu_canvas );  
   
  if ( filename == NULL ) {  
  // Save the background under the menu...  
  bg.saved = gr_create_bitmap( w, h );  
  Assert( bg.saved != NULL );  
  gr_bm_bitblt(w, h, 0, 0, 0, 0, &grd_curcanv->cv_bitmap, bg.saved );  
  gr_set_current_canvas( NULL );  
  nm_draw_background(x,y,x+w-1,y+h-1);  
  if (GWIDTH > nm_background.bm_w || GHEIGHT > nm_background.bm_h){  
  grs_bitmap sbg;  
  gr_init_sub_bitmap(&sbg,&nm_background,0,0,w*(320.0/GWIDTH),h*(200.0/GHEIGHT));//use the correctly resized portion of the background instead of the whole thing -MPM  
  bg.background=gr_create_bitmap(w,h);  
  gr_bitmap_scale_to(&sbg,bg.background);  
  bg.background_is_sub=0;  
  }else{  
  bg.background = gr_create_sub_bitmap(&nm_background,0,0,w,h);  
  bg.background_is_sub=1;  
  }  
  gr_set_current_canvas( bg.menu_canvas );  
  } else {  
  bg.saved = NULL;  
  bg.background = gr_create_bitmap( w, h );  
  Assert( bg.background != NULL );  
  gr_bm_bitblt(w, h, 0, 0, 0, 0, &grd_curcanv->cv_bitmap, bg.background );  
  }  
   
 // ty = 15 + (yborder/4);  
   
  ty = 15;  
   
  if ( title ) {  
                 grd_curcanv->cv_font = GAME_FONT;  
  gr_set_fontcolor( GR_GETCOLOR(31,31,31), -1 );  
  gr_get_string_size(title,&string_width,&string_height,&average_width );  
  tw = string_width;  
  th = string_height;  
  gr_printf( 0x8000, ty, title );  
  ty += th;  
  }  
   
  if ( subtitle ) {  
                 grd_curcanv->cv_font = GAME_FONT;  
  gr_set_fontcolor( GR_GETCOLOR(21,21,21), -1 );  
  gr_get_string_size(subtitle,&string_width,&string_height,&average_width );  
  tw = string_width;  
  th = string_height;  
  gr_printf( 0x8000, ty, subtitle );  
  ty += th;  
  }  
   
         grd_curcanv->cv_font = GAME_FONT;  
    
  // Update all item's x & y values.  
  for (i=0; i<nitems; i++ ) {  
  item[i].x = 15 + twidth + right_offset;  
  item[i].y += 15;  
  if ( item[i].type==NM_TYPE_RADIO ) {  
  fm = -1; // find first marked one  
  for ( j=0; j<nitems; j++ ) {  
  if ( item[j].type==NM_TYPE_RADIO && item[j].group==item[i].group ) {  
  if (fm==-1 && item[j].value)  
  fm = j;  
  item[j].value = 0;  
  }  
  }  
  if ( fm>=0 )   
  item[fm].value=1;  
  else  
  item[i].value=1;  
  }  
  }  
   
  old_keyd_repeat = keyd_repeat;  
  keyd_repeat = 1;  
   
  if (citem==-1) {  
  choice = -1;  
  } else {  
  if (citem < 0 ) citem = 0;  
  if (citem > nitems-1 ) citem = nitems-1;  
  choice = citem;  
    
  while ( item[choice].type==NM_TYPE_TEXT ) {  
  choice++;  
  if (choice >= nitems ) {  
  choice=0;   
  }  
  if (choice == citem ) {  
  choice=0;   
  all_text=1;  
  break;   
  }  
  }  
  }   
  done = 0;  
         gr_update();  
  // Clear mouse, joystick to clear button presses.  
  game_flush_inputs();  
   
  while(!done) {  
  //network_listen();  
    
   
  k = key_inkey();  
   
  if (subfunction)  
  (*subfunction)(nitems,item,&k,choice);  
   
  if (!time_stopped) {  
  // Save current menu box  
  #ifdef NETWORK  
  if (multi_menu_poll() == -1)  
  k = -2;  
  #endif  
  }  
   
  if ( k<-1 ) {  
  choice = k;  
  k = -1;  
  done = 1;  
  }  
    
  switch (Config_control_type) {  
  case CONTROL_JOYSTICK:  
  case CONTROL_FLIGHTSTICK_PRO:  
  case CONTROL_THRUSTMASTER_FCS:  
  case CONTROL_GRAVIS_GAMEPAD:  
  for (i=0; i<4; i++ )   
  if (joy_get_button_down_cnt(i)>0) done=1;  
  break;  
  case CONTROL_MOUSE:  
  case CONTROL_CYBERMAN:  
  for (i=0; i<3; i++ )   
  if (mouse_button_down_count(i)>0) done=1;  
  break;  
  }  
    
   
 // if ( (nmenus<2) && (k>0) && (nothers==0) )  
 // done=1;  
   
  old_choice = choice;  
    
  switch( k ) {  
  case KEY_TAB + KEY_SHIFTED:  
  case KEY_UP:  
  case KEY_PAD8:  
  if (all_text) break;  
  do {  
  choice--;  
  if (choice >= nitems ) choice=0;  
  if (choice < 0 ) choice=nitems-1;  
  } while ( item[choice].type==NM_TYPE_TEXT );  
  if ((item[choice].type==NM_TYPE_INPUT) && (choice!=old_choice))   
  item[choice].value = -1;  
  if ((old_choice>-1) && (item[old_choice].type==NM_TYPE_INPUT_MENU) && (old_choice!=choice)) {  
  item[old_choice].group=0;  
  strcpy(item[old_choice].text, item[old_choice].saved_text );  
  item[old_choice].value = -1;  
  }  
  if (old_choice>-1)   
  item[old_choice].redraw = 1;  
  item[choice].redraw=1;  
  break;  
  case KEY_TAB:  
  case KEY_DOWN:  
  case KEY_PAD2:  
  if (all_text) break;  
  do {  
  choice++;  
  if (choice < 0 ) choice=nitems-1;  
  if (choice >= nitems ) choice=0;  
  } while ( item[choice].type==NM_TYPE_TEXT );  
  if ((item[choice].type==NM_TYPE_INPUT) && (choice!=old_choice))   
  item[choice].value = -1;  
  if ( (old_choice>-1) && (item[old_choice].type==NM_TYPE_INPUT_MENU) && (old_choice!=choice)) {  
  item[old_choice].group=0;  
  strcpy(item[old_choice].text, item[old_choice].saved_text );   
  item[old_choice].value = -1;  
  }  
  if (old_choice>-1)  
  item[old_choice].redraw=1;  
  item[choice].redraw=1;  
  break;  
  case KEY_SPACEBAR:  
  if ( choice > -1 ) {  
  switch( item[choice].type ) {  
  case NM_TYPE_MENU:  
  case NM_TYPE_INPUT:  
  case NM_TYPE_INPUT_MENU:  
  break;  
  case NM_TYPE_CHECK:  
  if ( item[choice].value )  
  item[choice].value = 0;  
  else  
  item[choice].value = 1;  
  item[choice].redraw=1;  
  break;  
  case NM_TYPE_RADIO:  
  for (i=0; i<nitems; i++ ) {  
  if ((i!=choice) && (item[i].type==NM_TYPE_RADIO) && (item[i].group==item[choice].group) && (item[i].value) ) {  
  item[i].value = 0;  
  item[i].redraw = 1;  
  }  
  }  
  item[choice].value = 1;  
  item[choice].redraw = 1;  
  break;  
  }   
  }  
  break;  
   
  case KEY_ENTER:  
  case KEY_PADENTER:  
  if ( (choice>-1) && (item[choice].type==NM_TYPE_INPUT_MENU) && (item[choice].group==0)) {  
  item[choice].group = 1;  
  item[choice].redraw = 1;  
  if ( !strncasecmp( item[choice].saved_text, TXT_EMPTY, strlen(TXT_EMPTY) ) ) {  
  item[choice].text[0] = 0;  
  item[choice].value = -1;  
  } else {   
  strip_end_whitespace(item[choice].text);  
  }  
  } else  
  done = 1;  
  break;  
   
  case KEY_ESC:  
  if ( (choice>-1) && (item[choice].type==NM_TYPE_INPUT_MENU) && (item[choice].group==1)) {  
  item[choice].group=0;  
  strcpy(item[choice].text, item[choice].saved_text );   
  item[choice].redraw=1;  
  item[choice].value = -1;  
  } else {  
  done = 1;  
  choice = -1;  
  }  
  break;  
   
  case KEY_PRINT_SCREEN: save_screen_shot(0); break;  
   
  #ifndef NDEBUG  
  case KEY_BACKSP:   
  if ( (choice>-1) && (item[choice].type!=NM_TYPE_INPUT)&&(item[choice].type!=NM_TYPE_INPUT_MENU))  
  Int3();   
  break;  
  #endif  
   
  }  
   
  if ( choice > -1 ) {  
  int ascii;  
   
  if ( ((item[choice].type==NM_TYPE_INPUT)||((item[choice].type==NM_TYPE_INPUT_MENU)&&(item[choice].group==1)) )&& (old_choice==choice) ) {  
  if ( k==KEY_LEFT || k==KEY_BACKSP || k==KEY_PAD4 ) {  
  if (item[choice].value==-1) item[choice].value = strlen(item[choice].text);  
  if (item[choice].value > 0)  
  item[choice].value--;  
  item[choice].text[item[choice].value] = 0;  
  item[choice].redraw = 1;   
  } else {  
  ascii = key_to_ascii(k);  
  if ((ascii < 255 ) && (item[choice].value < item[choice].text_len ))  
  {  
  int allowed;  
   
  if (item[choice].value==-1) {  
  item[choice].value = 0;  
  }  
   
  allowed = char_allowed(ascii);  
  if (!allowed && ascii==' ' && char_allowed('_')) {  
  ascii = '_';  
  allowed=1;  
  }  
   
  if (allowed) {  
  item[choice].text[item[choice].value++] = ascii;  
  item[choice].text[item[choice].value] = 0;  
  item[choice].redraw=1;   
  }  
  }  
  }  
  } else if ((item[choice].type!=NM_TYPE_INPUT) && (item[choice].type!=NM_TYPE_INPUT_MENU) ) {  
  ascii = key_to_ascii(k);  
  if (ascii < 255 ) {  
  int choice1 = choice;  
  ascii = toupper(ascii);  
  do {  
  int i,ch;  
  choice1++;  
  if (choice1 >= nitems ) choice1=0;  
  for (i=0;(ch=item[choice1].text[i])!=0 && ch==' ';i++);  
  if ( ( (item[choice1].type==NM_TYPE_MENU) ||  
  (item[choice1].type==NM_TYPE_CHECK) ||  
  (item[choice1].type==NM_TYPE_RADIO) ||  
  (item[choice1].type==NM_TYPE_NUMBER) ||  
  (item[choice1].type==NM_TYPE_SLIDER) )  
  && (ascii==toupper(ch)) ) {  
  k = 0;  
  choice = choice1;  
  if (old_choice>-1)  
  item[old_choice].redraw=1;  
  item[choice].redraw=1;  
  }  
  } while (choice1 != choice );  
  }   
  }  
   
  if ( (item[choice].type==NM_TYPE_NUMBER) || (item[choice].type==NM_TYPE_SLIDER)) {  
  int ov=item[choice].value;  
  switch( k ) {  
  case KEY_PAD4:  
    case KEY_LEFT:  
    case KEY_MINUS:  
  case KEY_MINUS+KEY_SHIFTED:  
  case KEY_PADMINUS:  
  item[choice].value -= 1;  
  break;  
    case KEY_RIGHT:  
  case KEY_PAD6:  
    case KEY_EQUAL:  
  case KEY_EQUAL+KEY_SHIFTED:  
  case KEY_PADPLUS:  
  item[choice].value++;  
  break;  
  case KEY_PAGEUP:  
  case KEY_PAD9:  
  case KEY_SPACEBAR:  
  item[choice].value += 10;  
  break;  
  case KEY_PAGEDOWN:  
  case KEY_BACKSP:  
  case KEY_PAD3:  
  item[choice].value -= 10;  
  break;  
  }  
  if (ov!=item[choice].value)  
  item[choice].redraw=1;  
  }  
    
  }  
   
  gr_set_current_canvas(bg.menu_canvas);  
  // Redraw everything...  
  for (i=0; i<nitems; i++ ) {  
  if (item[i].redraw) {  
                                 draw_item( &bg, &item[i], (i==choice && !all_text) );  
  item[i].redraw=0;  
  }  
  else if (i==choice && (item[i].type==NM_TYPE_INPUT || (item[i].type==NM_TYPE_INPUT_MENU && item[i].group)))  
  update_cursor( &item[i]);  
  }  
  gr_update();  
   
  if ( gr_palette_faded_out ) {  
  gr_palette_fade_in( gr_palette, 32, 0 );  
  }  
  }  
    
  // Restore everything...  
  gr_set_current_canvas(bg.menu_canvas);  
  if ( filename == NULL ) {  
  // Save the background under the menu...  
  gr_bitmap(0, 0, bg.saved);   
  gr_free_bitmap(bg.saved);  
  if (bg.background_is_sub)  
  gr_free_sub_bitmap( bg.background );  
  else  
  gr_free_bitmap( bg.background );  
 // free( bg.background );  
  } else {  
  gr_bitmap(0, 0, bg.background);   
  gr_free_bitmap(bg.background);  
  }  
   
  gr_free_sub_canvas( bg.menu_canvas );  
   
  gr_set_current_canvas( NULL );   
  grd_curcanv->cv_font = save_font;  
  gr_set_current_canvas( save_canvas );   
  keyd_repeat = old_keyd_repeat;  
   
  game_flush_inputs();  
   
  if (time_stopped)  
  start_time();  
   
 //NO_SOUND_PAUSE if ( sound_stopped )  
 //NO_SOUND_PAUSE digi_resume_all();  
   
  return choice;  
   
 }  
   
   
 int nm_messagebox_fixedfont( char *title, int nchoices, ... )  int nm_messagebox_fixedfont( char *title, int nchoices, ... )
 {  {
  int i;   int i;

Legend:
line(s) removed in v.1.9 
line(s) changed
 line(s) added in v.1.10