Page 1 of 1

allow icon_size for each icon in icons

Posted: Tue Jan 23, 2018 4:41 pm
by Optera
I'm currently having a problem where I want to add an overlay icon to identify automatically generated items/signals.e.g. power poles with integrated lamps.

Could icons be expanded to allow icon_size per given icon?

Code: Select all

icons =
{
  { 
    icon = large-icon.png,
    icon_size = 128
  },
  { 
    icon = small-icon.png,
    icon_size = 32
  }
}
That way overlays could be created without including overlay icons of all possible icon sizes, which isn't reliable to begin with,

Re: allow icon_size for each icon in icons

Posted: Wed Jan 24, 2018 9:39 am
by bobingabout
I don't get the issue. Can't you just use the scale = tag?

An extract of some code

Code: Select all

local function generate_barrel_item_icons(fluid)
  return
  {
    {
      icon = "__boblibrary__/graphics/icons/cylinder/gas-canister.png",
    },
    {
      icon = "__boblibrary__/graphics/icons/cylinder/cylinder-top.png",
      tint = fluid.flow_color
    },
    {
      icon = "__boblibrary__/graphics/icons/cylinder/cylinder-mid.png",
      tint = fluid.base_color
    }
  }
end

-- Generates the icons definition for a fill-barrel recipe with the provided barrel name and fluid definition
local function generate_fill_barrel_icons(fluid)
  local icon = generate_barrel_item_icons(fluid)
  table.insert(icon, { icon = fluid.icon, scale = 0.5, shift = {4, -8}})
  return icon 
end

-- Generates the icons definition for a empty-barrel recipe with the provided barrel name and fluid definition
local function generate_empty_barrel_icons(fluid)
  local icon = generate_barrel_item_icons(fluid)
  table.insert(icon, {icon = fluid.icon, scale = 0.5, shift = {7, 8}})
  return icon 
end

Re: allow icon_size for each icon in icons

Posted: Wed Jan 24, 2018 12:39 pm
by Optera
I need a way to combine 32x32 with 128x128 or whatever other mods use.

Does scale and shift allow icons of different sizes being combined without throwing this error?
Image

Edit:
Just tested it. Scale and shift don't allow merging different sized icons.

Re: allow icon_size for each icon in icons

Posted: Thu Jan 25, 2018 1:41 am
by eradicator
Optera wrote:That way overlays could be created without including overlay icons of all possible icon sizes, which isn't reliable to begin with,
Why is this not reliable?
I need to do something similar down the line in my mod and so far i assumed that nobody would use anything but the three sizes 32/64/128.

Reliability aside it would of course be nice if layering images of different sizes became possible... so +1 for that.

Re: allow icon_size for each icon in icons

Posted: Thu Jan 25, 2018 6:03 am
by Rseding91
Ok, I added support for setting icon_size per icon layer for the next version of 0.16.

Re: allow icon_size for each icon in icons

Posted: Thu Jan 25, 2018 6:53 am
by Optera
Thanks, for the fast implementation.

How will a entity.icon_size interact with differeing sizes/icon?
Will it still be required or ignored?
Will all icons be resized to fit that value or will they be cropped to smallest size inside the list?

Code: Select all

icons =
{
  {
    icon = large-icon.png,
    icon_size = 128
  },
  {
    icon = small-icon.png,
    icon_size = 32
  }
}
icon_size = ???