Added Ok and Cancel buttons in value requester. Don't do anything in palette screen if user enters strange value, not even a reduction to 256 as this drops unused colors.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1100 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									2a67c9bdce
								
							
						
					
					
						commit
						b0aa1dcbab
					
				
							
								
								
									
										49
									
								
								palette.c
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								palette.c
									
									
									
									
									
								
							@ -1466,36 +1466,39 @@ void Button_Palette(void)
 | 
				
			|||||||
				reduce_colors_number
 | 
									reduce_colors_number
 | 
				
			||||||
					= Requester_window("Enter the max. number of colors",
 | 
										= Requester_window("Enter the max. number of colors",
 | 
				
			||||||
						reduce_colors_number);
 | 
											reduce_colors_number);
 | 
				
			||||||
				if (reduce_colors_number < 2 || reduce_colors_number > 256)
 | 
									if (reduce_colors_number < 2 || reduce_colors_number >= 256)
 | 
				
			||||||
					reduce_colors_number = 256;
 | 
										reduce_colors_number = -1;
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!image_is_backed_up)
 | 
							if (reduce_colors_number > 0)
 | 
				
			||||||
        {
 | 
							{
 | 
				
			||||||
          Backup();
 | 
								if (!image_is_backed_up)
 | 
				
			||||||
          image_is_backed_up = 1;
 | 
								{
 | 
				
			||||||
        }
 | 
									Backup();
 | 
				
			||||||
 | 
									image_is_backed_up = 1;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Reduce_palette(&used_colors, reduce_colors_number, working_palette,
 | 
								Reduce_palette(&used_colors, reduce_colors_number, working_palette,
 | 
				
			||||||
			color_usage);
 | 
										color_usage);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((Config.Safety_colors) && (used_colors<4))
 | 
								if ((Config.Safety_colors) && (used_colors<4))
 | 
				
			||||||
        {
 | 
								{
 | 
				
			||||||
          memcpy(temp_palette, Main_palette, sizeof(T_Palette));
 | 
									memcpy(temp_palette, Main_palette, sizeof(T_Palette));
 | 
				
			||||||
          memcpy(Main_palette, working_palette, sizeof(T_Palette));
 | 
									memcpy(Main_palette, working_palette, sizeof(T_Palette));
 | 
				
			||||||
          Set_nice_menu_colors(color_usage, 0);
 | 
									Set_nice_menu_colors(color_usage, 0);
 | 
				
			||||||
          memcpy(working_palette, Main_palette, sizeof(T_Palette));
 | 
									memcpy(working_palette, Main_palette, sizeof(T_Palette));
 | 
				
			||||||
          memcpy(Main_palette, temp_palette, sizeof(T_Palette));
 | 
									memcpy(Main_palette, temp_palette, sizeof(T_Palette));
 | 
				
			||||||
        }
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Set_palette(working_palette); // On définit la nouvelle palette
 | 
								Set_palette(working_palette); // On définit la nouvelle palette
 | 
				
			||||||
        Draw_all_palette_sliders(red_slider, green_slider, blue_slider,
 | 
								Draw_all_palette_sliders(red_slider, green_slider, blue_slider,
 | 
				
			||||||
			working_palette, block_start, block_end);
 | 
										working_palette, block_start, block_end);
 | 
				
			||||||
        memcpy(temp_palette, working_palette, sizeof(T_Palette));
 | 
								memcpy(temp_palette, working_palette, sizeof(T_Palette));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        End_of_modification();
 | 
								End_of_modification();
 | 
				
			||||||
        need_to_remap = 1;
 | 
								need_to_remap = 1;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      case 12: // Undo
 | 
					      case 12: // Undo
 | 
				
			||||||
 | 
				
			|||||||
@ -856,8 +856,10 @@ int Requester_window(char* message, int initial_value)
 | 
				
			|||||||
	Print_in_window((window_width>>1)-(strlen(message)<<2), 20, message,
 | 
						Print_in_window((window_width>>1)-(strlen(message)<<2), 20, message,
 | 
				
			||||||
		MC_Black, MC_Light);
 | 
							MC_Black, MC_Light);
 | 
				
			||||||
	sprintf(str, "%d", initial_value);
 | 
						sprintf(str, "%d", initial_value);
 | 
				
			||||||
	Window_set_input_button((window_width / 3) - 20, 37, 10); // 1
 | 
						Window_set_input_button(10, 37, 4); // 1
 | 
				
			||||||
	Print_in_window((window_width / 3) - 18, 39, str, MC_Black, MC_Light);
 | 
						Print_in_window(11, 39, str, MC_Black, MC_Light);
 | 
				
			||||||
 | 
						Window_set_normal_button(60 ,37,40,14,"OK",1,1,SDLK_y); // 2
 | 
				
			||||||
 | 
						Window_set_normal_button(130,37,60,14,"Cancel" ,1,1,SDLK_n); // 3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Update_rect(Window_pos_X, Window_pos_Y, Menu_factor_X * window_width,
 | 
						Update_rect(Window_pos_X, Window_pos_Y, Menu_factor_X * window_width,
 | 
				
			||||||
		Menu_factor_Y * 60);
 | 
							Menu_factor_Y * 60);
 | 
				
			||||||
@ -867,7 +869,7 @@ int Requester_window(char* message, int initial_value)
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		clicked_button = Window_clicked_button();
 | 
							clicked_button = Window_clicked_button();
 | 
				
			||||||
		if (clicked_button == 1)
 | 
							if (clicked_button == 1)
 | 
				
			||||||
			Readline((window_width / 3) - 18, 39, str, 10, 1);
 | 
								Readline(11, 39, str, 4, 1);
 | 
				
			||||||
		if (Key == SDLK_ESCAPE) clicked_button = 2;
 | 
							if (Key == SDLK_ESCAPE) clicked_button = 2;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	while (clicked_button <= 0);
 | 
						while (clicked_button <= 0);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user