From 2e59c1755f94458bf465326e192239b98fad16fb Mon Sep 17 00:00:00 2001 From: VMan_2002 <29513846+VMan-2002@users.noreply.github.com> Date: Fri, 17 Jul 2026 14:40:31 +1000 Subject: [PATCH 1/4] Auto2x --- src/game_object.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/game_object.lua b/src/game_object.lua index 4dfd9157c..fd66a357c 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -462,8 +462,22 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. 'assets/' .. G.SETTINGS.GRAPHICS.texture_scaling .. 'x/' .. file_path local file_data = assert(NFS.newFileData(self.full_path), ('Failed to collect file data for Atlas %s'):format(self.key)) - self.image_data = assert(love.image.newImageData(file_data), - ('Failed to initialize image data for Atlas %s'):format(self.key)) + if file_data then + self.image_data = assert(love.image.newImageData(file_data), + ('Failed to initialize image data for Atlas %s'):format(self.key)) + else + self.full_path = string.gsub(self.full_path, "assets/2x/", "assets/1x/", 1) + file_data = assert(NFS.newFileData(self.full_path), + ('Failed to collect file data for Atlas %s'):format(self.key)) + self.image_data = assert(love.image.newImageData(file_data), + ('Failed to initialize image data for Atlas %s'):format(self.key)) + local imageData2 = love.image.newImageData(bit.lshift(self.image_data:getWidth(), 1), bit.lshift(self.image_data:getHeight(), 1), self.image_data:getFormat()) + imageData2:mapPixel(function(x, y) + return self.image_data:getPixel(bit.rshift(x, 1), bit.rshift(y, 1)) + end) + self.image_data:release() + self.image_data = imageData2 + end self.image = love.graphics.newImage(self.image_data, { mipmaps = true, dpiscale = G.SETTINGS.GRAPHICS.texture_scaling }) G[self.atlas_table][self.key_noloc or self.key] = self From 8fcec1bad2dfcf94c646d8258eb12bb70ca5e94a Mon Sep 17 00:00:00 2001 From: VMan_2002 <29513846+VMan-2002@users.noreply.github.com> Date: Sun, 19 Jul 2026 09:36:19 +1000 Subject: [PATCH 2/4] auto1x --- src/game_object.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/game_object.lua b/src/game_object.lua index fd66a357c..6dbea5e21 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -466,15 +466,23 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. self.image_data = assert(love.image.newImageData(file_data), ('Failed to initialize image data for Atlas %s'):format(self.key)) else - self.full_path = string.gsub(self.full_path, "assets/2x/", "assets/1x/", 1) + self.full_path = string.gsub(self.full_path, "assets/" .. G.SETTINGS.GRAPHICS.texture_scaling .. "x/", "assets/"..(3 - G.SETTINGS.GRAPHICS.texture_scaling) .. "x/", 1) file_data = assert(NFS.newFileData(self.full_path), ('Failed to collect file data for Atlas %s'):format(self.key)) self.image_data = assert(love.image.newImageData(file_data), ('Failed to initialize image data for Atlas %s'):format(self.key)) - local imageData2 = love.image.newImageData(bit.lshift(self.image_data:getWidth(), 1), bit.lshift(self.image_data:getHeight(), 1), self.image_data:getFormat()) - imageData2:mapPixel(function(x, y) - return self.image_data:getPixel(bit.rshift(x, 1), bit.rshift(y, 1)) - end) + local imageData2 + if G.SETTINGS.GRAPHICS.texture_scaling == 2 then + imageData2 = love.image.newImageData(bit.lshift(self.image_data:getWidth(), 1), bit.lshift(self.image_data:getHeight(), 1), self.image_data:getFormat()) + imageData2:mapPixel(function(x, y) + return self.image_data:getPixel(bit.rshift(x, 1), bit.rshift(y, 1)) + end) + else + imageData2 = love.image.newImageData(bit.rshift(self.image_data:getWidth(), 1), bit.rshift(self.image_data:getHeight(), 1), self.image_data:getFormat()) + imageData2:mapPixel(function(x, y) + return self.image_data:getPixel(bit.lshift(x, 1), bit.lshift(y, 1)) + end) + end self.image_data:release() self.image_data = imageData2 end From d9feebe5eba190b1444a201cd9c06e96ede14b4e Mon Sep 17 00:00:00 2001 From: VMan_2002 <29513846+VMan-2002@users.noreply.github.com> Date: Sun, 19 Jul 2026 09:42:46 +1000 Subject: [PATCH 3/4] that wouldve still errored (for auto2x) --- src/game_object.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/game_object.lua b/src/game_object.lua index 6dbea5e21..2173a7830 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -460,8 +460,7 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. if not self.language and (self.obj_table[('%s_%s'):format(self.key, G.SETTINGS.language)] or self.obj_table[('%s_%s'):format(self.key, G.SETTINGS.real_language)]) then return end self.full_path = (self.path_mod or self.mod or SMODS).path .. 'assets/' .. G.SETTINGS.GRAPHICS.texture_scaling .. 'x/' .. file_path - local file_data = assert(NFS.newFileData(self.full_path), - ('Failed to collect file data for Atlas %s'):format(self.key)) + local file_data = NFS.newFileData(self.full_path) if file_data then self.image_data = assert(love.image.newImageData(file_data), ('Failed to initialize image data for Atlas %s'):format(self.key)) From 36166e8f06fdc64c3f8dd5436540062d8b2d5d94 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Mon, 20 Jul 2026 18:14:36 +0200 Subject: [PATCH 4/4] Remove unnecessary duplicate code --- src/game_object.lua | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/game_object.lua b/src/game_object.lua index 2173a7830..67b97f590 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -470,18 +470,16 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. ('Failed to collect file data for Atlas %s'):format(self.key)) self.image_data = assert(love.image.newImageData(file_data), ('Failed to initialize image data for Atlas %s'):format(self.key)) - local imageData2 - if G.SETTINGS.GRAPHICS.texture_scaling == 2 then - imageData2 = love.image.newImageData(bit.lshift(self.image_data:getWidth(), 1), bit.lshift(self.image_data:getHeight(), 1), self.image_data:getFormat()) - imageData2:mapPixel(function(x, y) - return self.image_data:getPixel(bit.rshift(x, 1), bit.rshift(y, 1)) - end) - else - imageData2 = love.image.newImageData(bit.rshift(self.image_data:getWidth(), 1), bit.rshift(self.image_data:getHeight(), 1), self.image_data:getFormat()) - imageData2:mapPixel(function(x, y) - return self.image_data:getPixel(bit.lshift(x, 1), bit.lshift(y, 1)) - end) - end + local shifts = { bit.rshift, bit.lshift } + local shift_dim, shift_pixel = shifts[G.SETTINGS.GRAPHICS.texture_scaling], shifts[3-G.SETTINGS.GRAPHICS.texture_scaling] + local imageData2 = love.image.newImageData( + shift_dim(self.image_data:getWidth(), 1), + shift_dim(self.image_data:getHeight(), 1), + self.image_data:getFormat() + ) + imageData2:mapPixel(function(x, y) + return self.image_data:getPixel(shift_pixel(x, 1), shift_pixel(y, 1)) + end) self.image_data:release() self.image_data = imageData2 end