Editor canvas modification bugfix, selected tile preview fix
This commit is contained in:
		
							parent
							
								
									e1bfd4f7f5
								
							
						
					
					
						commit
						bb53c2787b
					
				| 
						 | 
				
			
			@ -151,14 +151,18 @@ end
 | 
			
		|||
function DrawSelectingPaletteTile()
 | 
			
		||||
  if selecting_tile ~= nil and selecting_tile ~= 0 then
 | 
			
		||||
 | 
			
		||||
    local mouse_x = tileProperties.width * math.floor((love.mouse.getX()/game.scale) / tileProperties.width) - Camera.pos.x % tileProperties.width
 | 
			
		||||
    local mouse_y = tileProperties.height * math.floor((love.mouse.getY()/game.scale) / tileProperties.height) - Camera.pos.y % tileProperties.height
 | 
			
		||||
    local mouse_x = love.mouse.getX()
 | 
			
		||||
    local mouse_y = love.mouse.getY()
 | 
			
		||||
    local horizontal = math.floor(((mouse_x/game.scale) / tileProperties.width) + (Camera.pos.x / tileProperties.width))
 | 
			
		||||
    local vertical = math.floor(((mouse_y/game.scale) / tileProperties.height) + (Camera.pos.y / tileProperties.height))
 | 
			
		||||
    local draw_x = tileProperties.width * horizontal - Camera.pos.x
 | 
			
		||||
    local draw_y = tileProperties.height * vertical - Camera.pos.y
 | 
			
		||||
 | 
			
		||||
    love.graphics.draw(
 | 
			
		||||
  		LevelData.tileset,
 | 
			
		||||
      TileIndex[selecting_tile],
 | 
			
		||||
      mouse_x,
 | 
			
		||||
      mouse_y
 | 
			
		||||
      draw_x,
 | 
			
		||||
      draw_y
 | 
			
		||||
    )
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,8 @@ end
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
function LevelExpandCanvas(horizontal,vertical)
 | 
			
		||||
	local horizontal = horizontal or 0
 | 
			
		||||
	local vertical = vertical or 0
 | 
			
		||||
	local h = LevelGetTileWidth()
 | 
			
		||||
	local v = LevelGetTileHeight()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -51,7 +53,7 @@ function LevelExpandCanvas(horizontal,vertical)
 | 
			
		|||
	-- get data from old canvas to new canvas
 | 
			
		||||
	for i = 1, #LevelTiles do
 | 
			
		||||
		for j = 1, #LevelTiles[i] do
 | 
			
		||||
			ExpandedLevel[i+expand_v][j+expand_h] = InstanceTile(LevelTiles[i][j])
 | 
			
		||||
			ExpandedLevel[i+expand_v][j+expand_h] = InstanceTile(LevelTiles[i][j].id)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -61,6 +63,8 @@ end
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
function LevelReduceCanvas(horizontal,vertical)
 | 
			
		||||
	local horizontal = horizontal or 0
 | 
			
		||||
	local vertical = vertical or 0
 | 
			
		||||
	local h = LevelGetTileWidth()
 | 
			
		||||
	local v = LevelGetTileHeight()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -91,12 +95,14 @@ function LevelReduceCanvas(horizontal,vertical)
 | 
			
		|||
	-- get data from old canvas to new canvas
 | 
			
		||||
	for i = 1, #ExpandedLevel do
 | 
			
		||||
		for j = 1, #ExpandedLevel[i] do
 | 
			
		||||
			ExpandedLevel[i][j] = InstanceTile(LevelTiles[i+expand_v][j+expand_h])
 | 
			
		||||
			ExpandedLevel[i][j] = InstanceTile(LevelTiles[i+expand_v][j+expand_h].id)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	-- use new canvas
 | 
			
		||||
	LevelTiles = ExpandedLevel
 | 
			
		||||
 | 
			
		||||
	LevelExpandCanvas()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function LevelGetTileData()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue