diff --git a/lib/metas/technology.lua b/lib/metas/technology.lua index 6b3e0e4..953718f 100644 --- a/lib/metas/technology.lua +++ b/lib/metas/technology.lua @@ -11,7 +11,9 @@ local metas = {} ---@field public remove_pack fun(self: pYdata.TechnologyPrototype, science_pack_name: data.ItemID): pYdata.TechnologyPrototype, boolean ---@field public add_pack fun(self: pYdata.TechnologyPrototype, science_pack_name: data.ItemID): pYdata.TechnologyPrototype, boolean ---wraps the given icon with the border taken from the same mod (graphics/technology/border.png) ----strips any numbers from the end of the mod name +---strips any numbers from the end of the mod name +---scales the icon to the prototype's icon_size or 128 +---if you want to adjust the icon manually, pass an empty sprite as the path and the icon as the second argument ---@field public create_icons fun(self: pYdata.TechnologyPrototype, icon_path: string?, ...: data.IconData): pYdata.TechnologyPrototype TECHNOLOGY = setmetatable(data.raw.technology, { __call = function(self, technology) @@ -34,13 +36,15 @@ TECHNOLOGY = setmetatable(data.raw.technology, { end }) -metas.create_icons = function(self, icon_path, ...) +metas.create_icons = function(self, icon_path, ...) + local icon_size = self.icon_size or 128 if type(self.icons) == "string" then icon_path = self.icons end if not icon_path then error("provide a icon path for " .. self.name) end local base_mod = string.gsub(icon_path, "%d*__/.*", "__") + log(self.name .. ": " .. icon_size) self.icons = { {icon = base_mod .. "/graphics/technology/border.png", icon_size = 128}, - {icon = icon_path, icon_size = 128, scale = 0.8}, + {icon = icon_path, icon_size = icon_size, scale = 0.7 * 128 / icon_size}, } for _, icon in pairs{...} do table.insert(self.icons, icon)