Fix checking of Maximum layers in Add_layer()
This commit is contained in:
		
							parent
							
								
									f655d7f7c9
								
							
						
					
					
						commit
						973c8e65da
					
				@ -106,9 +106,9 @@ void Layer_activate(int layer, short side)
 | 
			
		||||
  Display_cursor();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int Layers_max(void)
 | 
			
		||||
int Layers_max(enum IMAGE_MODES mode)
 | 
			
		||||
{
 | 
			
		||||
  switch (Main.backups->Pages->Image_mode)
 | 
			
		||||
  switch (mode)
 | 
			
		||||
  {
 | 
			
		||||
    case IMAGE_MODE_LAYERED:
 | 
			
		||||
      return MAX_NB_LAYERS;
 | 
			
		||||
@ -125,7 +125,7 @@ void Button_Layer_add(int btn)
 | 
			
		||||
{
 | 
			
		||||
  Hide_cursor();
 | 
			
		||||
 | 
			
		||||
  if (Main.backups->Pages->Nb_layers < Layers_max())
 | 
			
		||||
  if (Main.backups->Pages->Nb_layers < Layers_max(Main.backups->Pages->Image_mode))
 | 
			
		||||
  {
 | 
			
		||||
    // Backup with unchanged layers
 | 
			
		||||
    Backup_layers(LAYER_NONE);
 | 
			
		||||
@ -149,7 +149,7 @@ void Button_Layer_duplicate(int btn)
 | 
			
		||||
{
 | 
			
		||||
  Hide_cursor();
 | 
			
		||||
 | 
			
		||||
  if (Main.backups->Pages->Nb_layers < Layers_max())
 | 
			
		||||
  if (Main.backups->Pages->Nb_layers < Layers_max(Main.backups->Pages->Image_mode))
 | 
			
		||||
  {
 | 
			
		||||
    // Backup with unchanged layers
 | 
			
		||||
    Backup_layers(LAYER_NONE);
 | 
			
		||||
 | 
			
		||||
@ -22,6 +22,7 @@
 | 
			
		||||
#ifndef LAYERS_H__
 | 
			
		||||
#define LAYERS_H__
 | 
			
		||||
 | 
			
		||||
int Layers_max(enum IMAGE_MODES mode);
 | 
			
		||||
void Button_Layer_add(int);
 | 
			
		||||
void Button_Layer_duplicate(int);
 | 
			
		||||
void Button_Layer_remove(int);
 | 
			
		||||
 | 
			
		||||
@ -35,6 +35,7 @@
 | 
			
		||||
#include "windows.h"
 | 
			
		||||
#include "tiles.h"
 | 
			
		||||
#include "graph.h"
 | 
			
		||||
#include "layers.h"
 | 
			
		||||
 | 
			
		||||
// -- Layers data
 | 
			
		||||
 | 
			
		||||
@ -1315,7 +1316,6 @@ void End_of_modification(void)
 | 
			
		||||
/// Add a new layer to latest page of a list. Returns 0 on success.
 | 
			
		||||
byte Add_layer(T_List_of_pages *list, int layer)
 | 
			
		||||
{
 | 
			
		||||
  int max[] = {MAX_NB_LAYERS, MAX_NB_FRAMES, 5};
 | 
			
		||||
  T_Page * source_page;
 | 
			
		||||
  T_Page * new_page;
 | 
			
		||||
  byte * new_image;
 | 
			
		||||
@ -1324,7 +1324,7 @@ byte Add_layer(T_List_of_pages *list, int layer)
 | 
			
		||||
  
 | 
			
		||||
  source_page = list->Pages;
 | 
			
		||||
 | 
			
		||||
  if (list->Pages->Nb_layers >= max[list->Pages->Image_mode]) // MAX_NB_LAYERS
 | 
			
		||||
  if (list->Pages->Nb_layers >= Layers_max(list->Pages->Image_mode)) // MAX_NB_LAYERS
 | 
			
		||||
    return 1;
 | 
			
		||||
   
 | 
			
		||||
  // Keep the position reasonable
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user