Fix bug with >16 paintbrushes
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1482 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									a84a9b7e66
								
							
						
					
					
						commit
						d00a5cfcd4
					
				@ -5028,14 +5028,26 @@ void Store_brush(int index)
 | 
			
		||||
void Select_paintbrush(int index)
 | 
			
		||||
{
 | 
			
		||||
  int x_pos,y_pos;
 | 
			
		||||
  
 | 
			
		||||
  Paintbrush_shape=Paintbrush[index].Shape;
 | 
			
		||||
  Paintbrush_width=Paintbrush[index].Width;
 | 
			
		||||
  Paintbrush_height=Paintbrush[index].Height;
 | 
			
		||||
  Paintbrush_offset_X=Paintbrush[index].Offset_X;
 | 
			
		||||
  Paintbrush_offset_Y=Paintbrush[index].Offset_Y;
 | 
			
		||||
  for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
 | 
			
		||||
    for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
 | 
			
		||||
      Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=Paintbrush[index].Sprite[y_pos][x_pos];
 | 
			
		||||
  
 | 
			
		||||
  if (Paintbrush[index].Width<=PAINTBRUSH_WIDTH &&
 | 
			
		||||
    Paintbrush[index].Height<=PAINTBRUSH_HEIGHT)
 | 
			
		||||
  {
 | 
			
		||||
    Paintbrush_width=Paintbrush[index].Width;
 | 
			
		||||
    Paintbrush_height=Paintbrush[index].Height;
 | 
			
		||||
    Paintbrush_offset_X=Paintbrush[index].Offset_X;
 | 
			
		||||
    Paintbrush_offset_Y=Paintbrush[index].Offset_Y;
 | 
			
		||||
    
 | 
			
		||||
    for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
 | 
			
		||||
      for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
 | 
			
		||||
        Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=Paintbrush[index].Sprite[y_pos][x_pos];
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    // Too big to read from the preview: need re-generate it
 | 
			
		||||
    Set_paintbrush_size(Paintbrush[index].Width,Paintbrush[index].Height);
 | 
			
		||||
  }
 | 
			
		||||
  Change_paintbrush_shape(Paintbrush[index].Shape);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -5045,7 +5057,7 @@ byte Store_paintbrush(int index)
 | 
			
		||||
  // Store a mono brush
 | 
			
		||||
  if (Paintbrush_shape <= PAINTBRUSH_SHAPE_MISC)
 | 
			
		||||
  {
 | 
			
		||||
    int x_pos,y_pos;
 | 
			
		||||
    int x_pos,y_pos, x_off=0, y_off=0;
 | 
			
		||||
    
 | 
			
		||||
    Paintbrush[index].Shape=Paintbrush_shape;
 | 
			
		||||
    Paintbrush[index].Width=Paintbrush_width;
 | 
			
		||||
@ -5053,29 +5065,32 @@ byte Store_paintbrush(int index)
 | 
			
		||||
    Paintbrush[index].Offset_X=Paintbrush_offset_X;
 | 
			
		||||
    Paintbrush[index].Offset_Y=Paintbrush_offset_Y;
 | 
			
		||||
    
 | 
			
		||||
    for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
 | 
			
		||||
      for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
 | 
			
		||||
        Paintbrush[index].Sprite[y_pos][x_pos]=Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos];
 | 
			
		||||
    if (Paintbrush_width>PAINTBRUSH_WIDTH)
 | 
			
		||||
      x_off=(Paintbrush_width-PAINTBRUSH_WIDTH)/2;
 | 
			
		||||
    if (Paintbrush_height>PAINTBRUSH_HEIGHT)
 | 
			
		||||
      y_off=(Paintbrush_height-PAINTBRUSH_HEIGHT)/2;
 | 
			
		||||
    
 | 
			
		||||
    for (y_pos=0; y_pos<Paintbrush_height && y_pos<PAINTBRUSH_HEIGHT; y_pos++)
 | 
			
		||||
      for (x_pos=0; x_pos<Paintbrush_width && x_pos<PAINTBRUSH_WIDTH; x_pos++)
 | 
			
		||||
        Paintbrush[index].Sprite[y_pos][x_pos]=Paintbrush_sprite[((y_pos+y_off)*MAX_PAINTBRUSH_SIZE)+(x_pos+x_off)];
 | 
			
		||||
    
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  else if ((Paintbrush_shape == PAINTBRUSH_SHAPE_MONO_BRUSH || 
 | 
			
		||||
    Paintbrush_shape == PAINTBRUSH_SHAPE_COLOR_BRUSH) &&
 | 
			
		||||
    Brush_width <= PAINTBRUSH_WIDTH &&
 | 
			
		||||
    Brush_height <= PAINTBRUSH_HEIGHT)
 | 
			
		||||
    Paintbrush_shape == PAINTBRUSH_SHAPE_COLOR_BRUSH))
 | 
			
		||||
  {
 | 
			
		||||
    // Color brush transformed into a real mono paintbrush
 | 
			
		||||
    int x_pos,y_pos;
 | 
			
		||||
    
 | 
			
		||||
    Paintbrush[index].Shape=PAINTBRUSH_SHAPE_MISC;
 | 
			
		||||
    Paintbrush[index].Width=Brush_width;
 | 
			
		||||
    Paintbrush[index].Height=Brush_height;
 | 
			
		||||
    Paintbrush[index].Offset_X=Brush_offset_X;
 | 
			
		||||
    Paintbrush[index].Offset_Y=Brush_offset_Y;
 | 
			
		||||
    Paintbrush[index].Width=Min(Brush_width,PAINTBRUSH_WIDTH);
 | 
			
		||||
    Paintbrush[index].Height=Min(Brush_height,PAINTBRUSH_HEIGHT);
 | 
			
		||||
    Paintbrush[index].Offset_X=Brush_offset_X*Paintbrush[index].Width/Brush_width;
 | 
			
		||||
    Paintbrush[index].Offset_Y=Brush_offset_Y*Paintbrush[index].Height/Brush_height;
 | 
			
		||||
    
 | 
			
		||||
    for (y_pos=0; y_pos<Brush_height; y_pos++)
 | 
			
		||||
      for (x_pos=0; x_pos<Brush_width; x_pos++)
 | 
			
		||||
    for (y_pos=0; y_pos<Brush_height&&y_pos<PAINTBRUSH_HEIGHT; y_pos++)
 | 
			
		||||
      for (x_pos=0; x_pos<Brush_width&&x_pos<PAINTBRUSH_WIDTH; x_pos++)
 | 
			
		||||
        Paintbrush[index].Sprite[y_pos][x_pos]=Brush[(y_pos*Brush_width)+x_pos]!=Back_color;
 | 
			
		||||
        
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								src/const.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/const.h
									
									
									
									
									
								
							@ -210,9 +210,17 @@ enum PAINTBRUSH_SHAPES
 | 
			
		||||
  PAINTBRUSH_SHAPE_DIAMOND,
 | 
			
		||||
  PAINTBRUSH_SHAPE_SIEVE_ROUND,
 | 
			
		||||
  PAINTBRUSH_SHAPE_SIEVE_SQUARE,
 | 
			
		||||
  PAINTBRUSH_SHAPE_RESERVED1,   ///< Reserved for future use
 | 
			
		||||
  PAINTBRUSH_SHAPE_RESERVED2,   ///< Reserved for future use
 | 
			
		||||
  PAINTBRUSH_SHAPE_RESERVED3,   ///< Reserved for future use
 | 
			
		||||
  PAINTBRUSH_SHAPE_RESERVED4,   ///< Reserved for future use
 | 
			
		||||
  PAINTBRUSH_SHAPE_RESERVED5,   ///< Reserved for future use
 | 
			
		||||
  PAINTBRUSH_SHAPE_RESERVED6,   ///< Reserved for future use
 | 
			
		||||
  PAINTBRUSH_SHAPE_RESERVED7,   ///< Reserved for future use
 | 
			
		||||
  PAINTBRUSH_SHAPE_RESERVED8,   ///< Reserved for future use
 | 
			
		||||
  PAINTBRUSH_SHAPE_MISC,        ///< A raw monochrome bitmap, can't be resized. This must be the last of the preset paintbrush types.
 | 
			
		||||
  PAINTBRUSH_SHAPE_POINT,       ///< Used to reduce the paintbrush to a single pixel, during operations like floodfill.
 | 
			
		||||
  PAINTBRUSH_SHAPE_NONE, ///< Used to display no cursor at all (colorpicker)
 | 
			
		||||
  PAINTBRUSH_SHAPE_NONE,        ///< Used to display no cursor at all (colorpicker)
 | 
			
		||||
  PAINTBRUSH_SHAPE_COLOR_BRUSH, ///< User's brush, in color mode
 | 
			
		||||
  PAINTBRUSH_SHAPE_MONO_BRUSH,  ///< User's brush, in mono mode
 | 
			
		||||
  PAINTBRUSH_SHAPE_MAX          ///< Upper limit.
 | 
			
		||||
 | 
			
		||||
@ -1278,6 +1278,8 @@ void Display_paintbrush_in_window(word x,word y,int number)
 | 
			
		||||
  int y_size;
 | 
			
		||||
  word origin_x;
 | 
			
		||||
  word origin_y;
 | 
			
		||||
  word width;
 | 
			
		||||
  word height;
 | 
			
		||||
 | 
			
		||||
  x_size=Menu_factor_X/Pixel_height;
 | 
			
		||||
  if (x_size<1)
 | 
			
		||||
@ -1286,11 +1288,14 @@ void Display_paintbrush_in_window(word x,word y,int number)
 | 
			
		||||
  if (y_size<1)
 | 
			
		||||
    y_size=1;
 | 
			
		||||
 | 
			
		||||
  origin_x = (x + 8)*Menu_factor_X - (Paintbrush[number].Offset_X)*x_size+Window_pos_X;
 | 
			
		||||
  origin_y = (y + 8)*Menu_factor_Y - (Paintbrush[number].Offset_Y)*y_size+Window_pos_Y;
 | 
			
		||||
  width=Min(Paintbrush[number].Width,PAINTBRUSH_WIDTH);
 | 
			
		||||
  height=Min(Paintbrush[number].Height,PAINTBRUSH_WIDTH);
 | 
			
		||||
  
 | 
			
		||||
  origin_x = (x + 8)*Menu_factor_X - (width/2)*x_size+Window_pos_X;
 | 
			
		||||
  origin_y = (y + 8)*Menu_factor_Y - (height/2)*y_size+Window_pos_Y;
 | 
			
		||||
 | 
			
		||||
  for (window_y_pos=0,y_pos=0; y_pos<Paintbrush[number].Height; window_y_pos++,y_pos++)
 | 
			
		||||
    for (window_x_pos=0,x_pos=0; x_pos<Paintbrush[number].Width; window_x_pos++,x_pos++)
 | 
			
		||||
  for (window_y_pos=0,y_pos=0; y_pos<height; window_y_pos++,y_pos++)
 | 
			
		||||
    for (window_x_pos=0,x_pos=0; x_pos<width; window_x_pos++,x_pos++)
 | 
			
		||||
      if (Paintbrush[number].Sprite[y_pos][x_pos])
 | 
			
		||||
        Block(origin_x+window_x_pos*x_size,origin_y+window_y_pos*y_size,x_size,y_size,MC_Black);
 | 
			
		||||
  // On n'utilise pas Pixel_in_window() car on ne dessine pas
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user