Great simplification of Main/Spare page flipping
This commit is contained in:
		
							parent
							
								
									353b494617
								
							
						
					
					
						commit
						5ab93eb7fd
					
				@ -1550,64 +1550,24 @@ void Button_Skins(void)
 | 
			
		||||
void Button_Page(void)
 | 
			
		||||
{
 | 
			
		||||
  byte   factor_index;
 | 
			
		||||
  char   Temp_buffer[256];
 | 
			
		||||
  T_Document temp_doc;
 | 
			
		||||
  
 | 
			
		||||
  Hide_cursor();
 | 
			
		||||
 | 
			
		||||
  if (Config.Sync_views)
 | 
			
		||||
    Copy_view_to_spare();
 | 
			
		||||
 | 
			
		||||
  // On dégrossit le travail avec les infos des listes de pages
 | 
			
		||||
  Exchange_main_and_spare();
 | 
			
		||||
  // First update the page descriptors before swapping them
 | 
			
		||||
  Upload_infos_page(&Main);
 | 
			
		||||
  Upload_infos_page(&Spare);
 | 
			
		||||
 | 
			
		||||
  // Tilemap info
 | 
			
		||||
  Swap_tilemap();
 | 
			
		||||
  
 | 
			
		||||
  // On fait le reste du travail "à la main":
 | 
			
		||||
// TODO
 | 
			
		||||
  SWAP_PBYTES(Main.visible_image.Image,Spare.visible_image.Image)
 | 
			
		||||
  SWAP_WORDS (Main.visible_image.Width,Spare.visible_image.Width)
 | 
			
		||||
  SWAP_WORDS (Main.visible_image.Height,Spare.visible_image.Height)
 | 
			
		||||
  SWAP_SHORTS(Main.offset_X,Spare.offset_X)
 | 
			
		||||
  SWAP_SHORTS(Main.offset_Y,Spare.offset_Y)
 | 
			
		||||
  SWAP_SHORTS(Main.separator_position,Spare.separator_position)
 | 
			
		||||
  SWAP_SHORTS(Main.X_zoom,Spare.X_zoom)
 | 
			
		||||
  SWAP_FLOATS(Main.separator_proportion,Spare.separator_proportion)
 | 
			
		||||
  SWAP_BYTES (Main.magnifier_mode,Spare.magnifier_mode)
 | 
			
		||||
  // SWAP
 | 
			
		||||
  memcpy(&temp_doc, &Main, sizeof(T_Document));
 | 
			
		||||
  memcpy(&Main, &Spare, sizeof(T_Document));
 | 
			
		||||
  memcpy(&Spare, &temp_doc, sizeof(T_Document));
 | 
			
		||||
 | 
			
		||||
  Pixel_preview=(Main.magnifier_mode)?Pixel_preview_magnifier:Pixel_preview_normal;
 | 
			
		||||
 | 
			
		||||
  SWAP_WORDS (Main.magnifier_factor,Spare.magnifier_factor)
 | 
			
		||||
  SWAP_WORDS (Main.magnifier_height,Spare.magnifier_height)
 | 
			
		||||
  SWAP_WORDS (Main.magnifier_width,Spare.magnifier_width)
 | 
			
		||||
  SWAP_SHORTS(Main.magnifier_offset_X,Spare.magnifier_offset_X)
 | 
			
		||||
  SWAP_SHORTS(Main.magnifier_offset_Y,Spare.magnifier_offset_Y)
 | 
			
		||||
  // Swap du booléen "Image modifiée"
 | 
			
		||||
  SWAP_BYTES (Main.image_is_modified,Spare.image_is_modified)
 | 
			
		||||
 | 
			
		||||
  // Swap fileselector data
 | 
			
		||||
  SWAP_BYTES (Main.selector.Format_filter,Spare.selector.Format_filter)
 | 
			
		||||
  SWAP_WORDS (Main.selector.Position,Spare.selector.Position)
 | 
			
		||||
  SWAP_WORDS (Main.selector.Offset,Spare.selector.Offset)
 | 
			
		||||
  strcpy(Temp_buffer            ,Spare.selector.Directory);
 | 
			
		||||
  strcpy(Spare.selector.Directory,Main.selector.Directory);
 | 
			
		||||
  strcpy(Main.selector.Directory,Temp_buffer             );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  SWAP_BYTES (Main.current_layer,Spare.current_layer)
 | 
			
		||||
  SWAP_DWORDS(Main.layers_visible,Spare.layers_visible)
 | 
			
		||||
  SWAP_DWORDS(Main.layers_visible_backup,Spare.layers_visible_backup)
 | 
			
		||||
  
 | 
			
		||||
  SWAP_DWORDS(Main.safety_number,Spare.safety_number)
 | 
			
		||||
  SWAP_DWORDS(Main.edits_since_safety_backup,Spare.edits_since_safety_backup)
 | 
			
		||||
  SWAP_BYTES(Main.safety_backup_prefix,Spare.safety_backup_prefix)
 | 
			
		||||
  {
 | 
			
		||||
    Uint32 a;
 | 
			
		||||
    a=Main.time_of_safety_backup;
 | 
			
		||||
    Main.time_of_safety_backup=Spare.time_of_safety_backup;
 | 
			
		||||
    Spare.time_of_safety_backup=a;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //Redraw_layered_image();
 | 
			
		||||
  // replaced by
 | 
			
		||||
  Update_buffers(Main.image_width, Main.image_height);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										32
									
								
								src/pages.c
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								src/pages.c
									
									
									
									
									
								
							@ -1275,38 +1275,6 @@ void Free_current_page(void)
 | 
			
		||||
  End_of_modification();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Exchange_main_and_spare(void)
 | 
			
		||||
{
 | 
			
		||||
  T_List_of_pages * temp_list;
 | 
			
		||||
 | 
			
		||||
  // On commence par mettre à jour dans les descripteurs les infos sur les
 | 
			
		||||
  // pages qu'on s'apprête à échanger, pour qu'on se retrouve pas avec de
 | 
			
		||||
  // vieilles valeurs qui datent de mathuzalem.
 | 
			
		||||
  Upload_infos_page(&Main);
 | 
			
		||||
  Upload_infos_page(&Spare);
 | 
			
		||||
 | 
			
		||||
  // On inverse les listes de pages
 | 
			
		||||
//TODO
 | 
			
		||||
  temp_list=Main.backups;
 | 
			
		||||
  Main.backups=Spare.backups;
 | 
			
		||||
  Spare.backups=temp_list;
 | 
			
		||||
 | 
			
		||||
  // On extrait ensuite les infos sur les nouvelles pages courante, brouillon
 | 
			
		||||
  // et backup.
 | 
			
		||||
 | 
			
		||||
  /* SECTION GROS CACA PROUT PROUT */
 | 
			
		||||
  // Auparavant on ruse en mettant déjà à jour les dimensions de la
 | 
			
		||||
  // nouvelle page courante. Si on ne le fait pas, le "Download" va détecter
 | 
			
		||||
  // un changement de dimensions et va bêtement sortir du mode loupe, alors
 | 
			
		||||
  // que lors d'un changement de page, on veut bien conserver l'état du mode
 | 
			
		||||
  // loupe du brouillon.
 | 
			
		||||
  Main.image_width=Main.backups->Pages->Width;
 | 
			
		||||
  Main.image_height=Main.backups->Pages->Height;
 | 
			
		||||
 | 
			
		||||
  Download_infos_page_main(Main.backups->Pages);
 | 
			
		||||
  Download_infos_page_spare(Spare.backups->Pages);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void End_of_modification(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -115,7 +115,6 @@ void Backup_layers(int layer);
 | 
			
		||||
void Undo(void);
 | 
			
		||||
void Redo(void);
 | 
			
		||||
void Free_current_page(void); // 'Kill' button
 | 
			
		||||
void Exchange_main_and_spare(void);
 | 
			
		||||
void End_of_modification(void);
 | 
			
		||||
 | 
			
		||||
void Update_depth_buffer(void);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								src/tiles.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/tiles.c
									
									
									
									
									
								
							@ -362,23 +362,6 @@ void Tilemap_update(void)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// This exchanges the tilemap settings of the main and spare, it should
 | 
			
		||||
/// be called when swapping pages.
 | 
			
		||||
void Swap_tilemap(void)
 | 
			
		||||
{
 | 
			
		||||
//TODO
 | 
			
		||||
  SWAP_BYTES(Main.tilemap_mode, Spare.tilemap_mode)
 | 
			
		||||
  {
 | 
			
		||||
    T_Tile * a;
 | 
			
		||||
    a=Main.tilemap;
 | 
			
		||||
    Main.tilemap=Spare.tilemap;
 | 
			
		||||
    Spare.tilemap=a;
 | 
			
		||||
  }
 | 
			
		||||
  SWAP_SHORTS(Main.tilemap_width, Spare.tilemap_width)
 | 
			
		||||
  SWAP_SHORTS(Main.tilemap_height, Spare.tilemap_height)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// Clears all tilemap data and settings
 | 
			
		||||
/// Safe to call again.
 | 
			
		||||
 | 
			
		||||
@ -32,11 +32,6 @@ void Tilemap_update(void);
 | 
			
		||||
/// similar tiles of the layer, visible on the screen or not.
 | 
			
		||||
void Tilemap_draw(word x, word y, byte color);
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// This exchanges the tilemap settings of the main and spare, it should
 | 
			
		||||
/// be called when swapping pages.
 | 
			
		||||
void Swap_tilemap(void);
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// Clears all tilemap data and settings
 | 
			
		||||
/// Safe to call again.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user