Implement shortcut/underscore for input button
This commit is contained in:
		
							parent
							
								
									bdaf4d6748
								
							
						
					
					
						commit
						a01e7eea69
					
				@ -1044,7 +1044,7 @@ void Button_Settings(int btn)
 | 
			
		||||
    // Button Close
 | 
			
		||||
  Window_set_normal_button(250,163, 51,14,"Close"        ,0,1,KEY_ESC); // 4
 | 
			
		||||
 | 
			
		||||
  panel=Window_set_special_button(10, 21, 272,SETTING_PER_PAGE*SETTING_HEIGHT); // 5
 | 
			
		||||
  panel=Window_set_special_button(10, 21, 272,SETTING_PER_PAGE*SETTING_HEIGHT,0); // 5
 | 
			
		||||
  Window_set_scroller_button(285,21,SETTING_PER_PAGE*SETTING_HEIGHT,SETTING_PAGES,1,current_page); // 6
 | 
			
		||||
  
 | 
			
		||||
  Update_window_area(0,0,Window_width, Window_height);
 | 
			
		||||
@ -1333,7 +1333,7 @@ void Button_Skins(int btn)
 | 
			
		||||
  // List of skins
 | 
			
		||||
  skin_list = Window_set_list_button(
 | 
			
		||||
  // Fileselector
 | 
			
		||||
  Window_set_special_button(8, FILESEL_Y + 1, 144, 80), // 2
 | 
			
		||||
  Window_set_special_button(8, FILESEL_Y + 1, 144, 80,0), // 2
 | 
			
		||||
    // Scroller for the fileselector
 | 
			
		||||
    (file_scroller = Window_set_scroller_button(155, FILESEL_Y - 1, 82,
 | 
			
		||||
    Skin_files_list.Nb_elements, 10, 0)), // 3
 | 
			
		||||
@ -1931,8 +1931,8 @@ void Button_Resolution(int btn)
 | 
			
		||||
  Window_set_normal_button(223, 18,67,14,"OK"      ,0,1,SDLK_RETURN); // 1
 | 
			
		||||
  Window_set_normal_button(223, 35,67,14,"Cancel"  ,0,1,KEY_ESC);  // 2
 | 
			
		||||
 | 
			
		||||
  Print_in_window( 12, 37,"Width:"          ,MC_Dark,MC_Light);
 | 
			
		||||
  input_width_button=Window_set_input_button( 60, 35,4);            // 3
 | 
			
		||||
  Print_in_window_underscore( 12, 37,"Width:",MC_Dark,MC_Light,1);
 | 
			
		||||
  input_width_button=Window_set_input_button_s( 60, 35,4,SDLK_w);     // 3
 | 
			
		||||
 | 
			
		||||
  Print_in_window(108, 37,"Height:"         ,MC_Dark,MC_Light);
 | 
			
		||||
  input_button_height=Window_set_input_button(164, 35,4);           // 4
 | 
			
		||||
@ -1948,7 +1948,7 @@ void Button_Resolution(int btn)
 | 
			
		||||
  Print_in_window( 62,170,"OK"              ,MC_Dark,MC_Light);
 | 
			
		||||
  Print_in_window(102,170,"Imperfect"       ,MC_Dark,MC_Light);
 | 
			
		||||
  Print_in_window(196,170,"Unsupported"     ,MC_Dark,MC_Light);
 | 
			
		||||
  Window_set_special_button(38,86,225,80);                       // 5
 | 
			
		||||
  Window_set_special_button(38,86,225,80,0);                       // 5
 | 
			
		||||
 | 
			
		||||
  selected_mode=Current_resolution;
 | 
			
		||||
  if (selected_mode>=MODELIST_LINES/2 && Nb_video_modes > MODELIST_LINES)
 | 
			
		||||
@ -4993,7 +4993,7 @@ void Button_Text(int btn)
 | 
			
		||||
  // Scroller des fontes
 | 
			
		||||
  font_scroller = Window_set_scroller_button(165,35,NB_FONTS*8,Nb_fonts,NB_FONTS,list_start); // 5
 | 
			
		||||
  // Liste des fontes disponibles
 | 
			
		||||
  font_list_button = Window_set_special_button(8,35,152,NB_FONTS*8); // 6
 | 
			
		||||
  font_list_button = Window_set_special_button(8,35,152,NB_FONTS*8,0); // 6
 | 
			
		||||
  Window_display_frame_in(7, 33, 154, NB_FONTS*8+4);
 | 
			
		||||
  
 | 
			
		||||
  // Taille texte
 | 
			
		||||
@ -5002,7 +5002,7 @@ void Button_Text(int btn)
 | 
			
		||||
  Window_set_repeatable_button(251,43,13,11,"+",0,1,SDLK_LAST); // 9
 | 
			
		||||
  
 | 
			
		||||
  // Preview
 | 
			
		||||
  preview_button = Window_set_special_button(8,106,273,50); // 10
 | 
			
		||||
  preview_button = Window_set_special_button(8,106,273,50,0); // 10
 | 
			
		||||
  Window_display_frame_in(7, 105, 275, 52);
 | 
			
		||||
  
 | 
			
		||||
  Window_set_normal_button(8,160,40,14,"OK",0,1,SDLK_RETURN); // 11
 | 
			
		||||
 | 
			
		||||
@ -1116,7 +1116,7 @@ void Button_Sieve_menu(void)
 | 
			
		||||
  Print_in_window( 23,120,"Width:" ,MC_Dark,MC_Light);
 | 
			
		||||
  Print_in_window( 15,136,"Height:",MC_Dark,MC_Light);
 | 
			
		||||
 | 
			
		||||
  Window_set_special_button(143,69,80,80);                     // 1
 | 
			
		||||
  Window_set_special_button(143,69,80,80,0);                     // 1
 | 
			
		||||
 | 
			
		||||
  Window_set_normal_button(175,157,51,14,"Cancel",0,1,KEY_ESC); // 2
 | 
			
		||||
  Window_set_normal_button(230,157,51,14,"OK"    ,0,1,SDLK_RETURN); // 3
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										30
									
								
								src/engine.c
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								src/engine.c
									
									
									
									
									
								
							@ -1753,7 +1753,7 @@ void Close_window(void)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//---------------- Dessiner un bouton normal dans une fenêtre ----------------
 | 
			
		||||
 | 
			
		||||
// undersc_letter is 0 for no underscore, 1-indexed array index otherwise
 | 
			
		||||
void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height,
 | 
			
		||||
                                    const char * title,byte undersc_letter,byte clickable)
 | 
			
		||||
{
 | 
			
		||||
@ -2006,7 +2006,7 @@ void Window_clear_input_button(T_Special_button * button)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//------ Rajout d'un bouton à la liste de ceux présents dans la fenêtre ------
 | 
			
		||||
 | 
			
		||||
// undersc_letter is 0 for no underscore, 1-indexed array index otherwise
 | 
			
		||||
T_Normal_button * Window_set_normal_button(word x_pos, word y_pos,
 | 
			
		||||
                                   word width, word height,
 | 
			
		||||
                                   const char * title, byte undersc_letter,
 | 
			
		||||
@ -2036,7 +2036,7 @@ T_Normal_button * Window_set_normal_button(word x_pos, word y_pos,
 | 
			
		||||
  return temp;
 | 
			
		||||
}
 | 
			
		||||
//------ Rajout d'un bouton à la liste de ceux présents dans la fenêtre ------
 | 
			
		||||
 | 
			
		||||
// undersc_letter is 0 for no underscore, 1-indexed array index otherwise
 | 
			
		||||
T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos,
 | 
			
		||||
                                   word width, word height,
 | 
			
		||||
                                   const char * title, byte undersc_letter,
 | 
			
		||||
@ -2134,7 +2134,7 @@ T_Scroller_button * Window_set_horizontal_scroller_button(word x_pos, word y_pos
 | 
			
		||||
  return temp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,word height)
 | 
			
		||||
T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,word height, word shortcut)
 | 
			
		||||
{
 | 
			
		||||
  T_Special_button * temp;
 | 
			
		||||
 | 
			
		||||
@ -2144,6 +2144,7 @@ T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,wo
 | 
			
		||||
  temp->Pos_Y    =y_pos;
 | 
			
		||||
  temp->Width    =width;
 | 
			
		||||
  temp->Height   =height;
 | 
			
		||||
  temp->Shortcut =shortcut;
 | 
			
		||||
 | 
			
		||||
  temp->Next=Window_special_button_list;
 | 
			
		||||
  Window_special_button_list=temp;
 | 
			
		||||
@ -2151,14 +2152,19 @@ T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,wo
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
T_Special_button * Window_set_input_button(word x_pos,word y_pos,word width_in_characters)
 | 
			
		||||
T_Special_button * Window_set_input_button_s(word x_pos,word y_pos,word width_in_characters, word shortcut)
 | 
			
		||||
{
 | 
			
		||||
  T_Special_button *temp;
 | 
			
		||||
  temp=Window_set_special_button(x_pos,y_pos,(width_in_characters<<3)+3,11);
 | 
			
		||||
  temp=Window_set_special_button(x_pos,y_pos,(width_in_characters<<3)+3,11,shortcut);
 | 
			
		||||
  Window_draw_input_bouton(x_pos,y_pos,width_in_characters);
 | 
			
		||||
  return temp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
T_Special_button * Window_set_input_button(word x_pos,word y_pos,word width_in_characters)
 | 
			
		||||
{
 | 
			
		||||
  return Window_set_input_button_s(x_pos, y_pos, width_in_characters, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,word height,word dropdown_width,const char *label,byte display_choice,byte display_centered,byte display_arrow,byte active_button, byte bottom_up)
 | 
			
		||||
{
 | 
			
		||||
  T_Dropdown_button *temp;
 | 
			
		||||
@ -3133,6 +3139,7 @@ short Window_get_clicked_button(void)
 | 
			
		||||
short Window_get_button_shortcut(void)
 | 
			
		||||
{
 | 
			
		||||
  T_Normal_button * temp;
 | 
			
		||||
  T_Special_button * temp2;
 | 
			
		||||
 | 
			
		||||
  if (Key & MOD_SHIFT)
 | 
			
		||||
    Window_attribute1=RIGHT_SIDE;
 | 
			
		||||
@ -3160,6 +3167,17 @@ short Window_get_button_shortcut(void)
 | 
			
		||||
    temp=temp->Next;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Scan for shortcut in special button list
 | 
			
		||||
  temp2=Window_special_button_list;
 | 
			
		||||
  while (temp2!=NULL)
 | 
			
		||||
  {
 | 
			
		||||
    if (temp2->Shortcut==Key)
 | 
			
		||||
    {
 | 
			
		||||
      return temp2->Number;
 | 
			
		||||
    }
 | 
			
		||||
    temp2=temp2->Next;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Si la recherche n'a pas été fructueuse ET que l'utilisateur appuyait sur
 | 
			
		||||
  // <Shift>, on regarde si un bouton ne pourrait pas réagir comme si <Shift>
 | 
			
		||||
  // n'était pas appuyé.
 | 
			
		||||
 | 
			
		||||
@ -73,8 +73,11 @@ T_Scroller_button * Window_set_horizontal_scroller_button(word x_pos, word y_pos
 | 
			
		||||
  word height, word nb_elements, word nb_elements_visible,
 | 
			
		||||
  word initial_position);
 | 
			
		||||
 | 
			
		||||
T_Special_button * Window_set_special_button(word x_pos, word y_pos, word width,
 | 
			
		||||
  word height);
 | 
			
		||||
T_Special_button * Window_set_special_button(word x_pos, word y_pos,
 | 
			
		||||
  word width, word height, word shortcut);
 | 
			
		||||
 | 
			
		||||
T_Special_button * Window_set_input_button_s(word x_pos,word y_pos,
 | 
			
		||||
  word width_in_characters, word shortcut);
 | 
			
		||||
 | 
			
		||||
T_Special_button * Window_set_input_button(word x_pos, word y_pos,
 | 
			
		||||
  word width_in_characters);
 | 
			
		||||
 | 
			
		||||
@ -2663,7 +2663,7 @@ void Button_Brush_Factory(void)
 | 
			
		||||
 | 
			
		||||
  Window_display_frame_in(6, FILESEL_Y - 2, NAME_WIDTH*8+4, 84); // File selector
 | 
			
		||||
  // Fileselector
 | 
			
		||||
  scriptarea=Window_set_special_button(8, FILESEL_Y + 0, NAME_WIDTH*8, 80); // 2
 | 
			
		||||
  scriptarea=Window_set_special_button(8, FILESEL_Y + 0, NAME_WIDTH*8, 80,0); // 2
 | 
			
		||||
  // Scroller for the fileselector
 | 
			
		||||
  scriptscroll = Window_set_scroller_button(NAME_WIDTH*8+14, FILESEL_Y - 1, 82,
 | 
			
		||||
      Scripts_selector.Nb_elements,10, 0); // 3
 | 
			
		||||
@ -2672,7 +2672,7 @@ void Button_Brush_Factory(void)
 | 
			
		||||
  Window_set_normal_button(10, 161, 67, 14, "Run", 0, 1, SDLK_RETURN); // 5
 | 
			
		||||
 | 
			
		||||
  Window_display_frame_in(6, FILESEL_Y + 88, DESC_WIDTH*6+4, 4*8+2); // Descr.
 | 
			
		||||
  Window_set_special_button(7, FILESEL_Y + 89+24,DESC_WIDTH*6,8); // 6
 | 
			
		||||
  Window_set_special_button(7, FILESEL_Y + 89+24,DESC_WIDTH*6,8,0); // 6
 | 
			
		||||
  
 | 
			
		||||
  // Box around path (slightly expands up left)
 | 
			
		||||
  Window_rectangle(8, FILESEL_Y - 13, DESC_WIDTH*6+2, 9, MC_Black);
 | 
			
		||||
 | 
			
		||||
@ -1613,7 +1613,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
 | 
			
		||||
  Window_display_frame_in(6,93,148,84);
 | 
			
		||||
 | 
			
		||||
  // Fileselector
 | 
			
		||||
  Window_set_special_button(9,95,144,80); // 4
 | 
			
		||||
  Window_set_special_button(9,95,144,80,0); // 4
 | 
			
		||||
 | 
			
		||||
  // Scroller du fileselector
 | 
			
		||||
  file_scroller = Window_set_scroller_button(160,94,82,1,10,0);               // 5
 | 
			
		||||
 | 
			
		||||
@ -537,7 +537,7 @@ void Window_help(int section, const char *sub_section)
 | 
			
		||||
  Window_set_normal_button( 9+6*8+4+8*8+4,154, 5*8,14,"Help",1,1,SDLK_h); // 5
 | 
			
		||||
  Window_set_normal_button(9+6*8+4+8*8+4+5*8+4,154, 8*8,14,"Credits",1,1,SDLK_c); // 6
 | 
			
		||||
 | 
			
		||||
  Window_set_special_button(9,18,272,130); // 7
 | 
			
		||||
  Window_set_special_button(9,18,272,130,0); // 7
 | 
			
		||||
 | 
			
		||||
  Display_help();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -988,7 +988,7 @@ int Window_Histogram(unsigned char block_start, unsigned char block_end, dword*
 | 
			
		||||
      1,
 | 
			
		||||
      old_height+1,MC_Black);
 | 
			
		||||
 | 
			
		||||
  histo = Window_set_special_button(3, 27, j*bar_width, 100); // 2
 | 
			
		||||
  histo = Window_set_special_button(3, 27, j*bar_width, 100,0); // 2
 | 
			
		||||
 | 
			
		||||
  Update_window_area(0,0,263,150);
 | 
			
		||||
  Display_cursor();
 | 
			
		||||
 | 
			
		||||
@ -468,7 +468,7 @@ int Menu_shade(void)
 | 
			
		||||
  Window_set_scroller_button(192,17,84,8,1,Shade_current);      // 2
 | 
			
		||||
 | 
			
		||||
  // Déclaration & tracé de la zone de définition des dégradés
 | 
			
		||||
  Window_set_special_button(8,127,256,53);                     // 3
 | 
			
		||||
  Window_set_special_button(8,127,256,53,0);                     // 3
 | 
			
		||||
 | 
			
		||||
  // Déclaration & tracé des boutons de sortie
 | 
			
		||||
  Window_set_normal_button(207,17,51,14,"Cancel",0,1,KEY_ESC);   // 4
 | 
			
		||||
 | 
			
		||||
@ -147,6 +147,7 @@ typedef struct T_Special_button
 | 
			
		||||
  word Pos_Y;                    ///< Coordinate for left of button, relative to the window, before scaling.
 | 
			
		||||
  word Width;                    ///< Width before scaling
 | 
			
		||||
  word Height;                   ///< Height before scaling
 | 
			
		||||
  word Shortcut;                 ///< Keyboard shortcut that will emulate a click on this button.
 | 
			
		||||
  struct T_Special_button * Next;///< Pointer to the next special button of current window.
 | 
			
		||||
} T_Special_button;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -955,8 +955,9 @@ void Print_in_window_limited(short x,short y,const char * str,byte size,byte tex
 | 
			
		||||
  Print_in_window(x, y, display_string, text_color, background_color);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Draws a string in a window
 | 
			
		||||
void Print_in_window(short x,short y,const char * str,byte text_color,byte background_color)
 | 
			
		||||
/// Draws a string in a window with underscore
 | 
			
		||||
/// undersc_letter is 0 for no underscore, 1-indexed array index otherwise
 | 
			
		||||
void Print_in_window_underscore(short x,short y,const char * str,byte text_color,byte background_color, byte undersc_letter)
 | 
			
		||||
{
 | 
			
		||||
  short x_pos = x;
 | 
			
		||||
  const unsigned char * p = (const unsigned char *)str;
 | 
			
		||||
@ -966,9 +967,18 @@ void Print_in_window(short x,short y,const char * str,byte text_color,byte backg
 | 
			
		||||
    Print_char_in_window(x,y,*p++,text_color,background_color);
 | 
			
		||||
    x+=8;
 | 
			
		||||
  }
 | 
			
		||||
  if (undersc_letter) {
 | 
			
		||||
    Window_rectangle(x_pos+((undersc_letter-1)<<3),y+8,8,1,text_color);
 | 
			
		||||
  }
 | 
			
		||||
  Update_window_area(x_pos,y,x-x_pos,8);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Draws a string in a window
 | 
			
		||||
void Print_in_window(short x,short y,const char * str,byte text_color,byte background_color)
 | 
			
		||||
{
 | 
			
		||||
  Print_in_window_underscore(x,y,str,text_color,background_color,0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Draws a string in a window
 | 
			
		||||
void Print_in_window_unicode(short x,short y,const word * str,byte text_color,byte background_color)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@ -67,6 +67,7 @@ word Palette_cells_Y(void);
 | 
			
		||||
 | 
			
		||||
void Print_general(short x,short y,const char * str,byte text_color,byte background_color);
 | 
			
		||||
void Print_general_unicode(short x,short y,const word * str,byte text_color,byte background_color);
 | 
			
		||||
void Print_in_window_underscore(short x,short y,const char * str,byte text_color,byte background_color, byte undersc_letter);
 | 
			
		||||
void Print_in_window(short x,short y,const char * str,byte text_color,byte background_color);
 | 
			
		||||
void Print_in_window_unicode(short x,short y,const word * str,byte text_color,byte background_color);
 | 
			
		||||
void Print_in_window_limited(short x,short y,const char * str,byte size,byte text_color,byte background_color);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user