allow icon_size for each icon in icons

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

allow icon_size for each icon in icons

Post 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,
Last edited by Optera on Wed Jan 24, 2018 12:40 pm, edited 1 time in total.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: allow icon_size for each icon in icons

Post 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
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: allow icon_size for each icon in icons

Post 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.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: allow icon_size for each icon in icons

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: allow icon_size for each icon in icons

Post by Rseding91 »

Ok, I added support for setting icon_size per icon layer for the next version of 0.16.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: allow icon_size for each icon in icons

Post 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 = ???
Post Reply

Return to “Implemented mod requests”