[0.18.10] Bug with recipe vs technology icon scaling?

Place to get help with not working mods / modding interface.
Honktown
Smart Inserter
Smart Inserter
Posts: 1058
Joined: Thu Oct 03, 2019 7:10 am
Contact:

[0.18.10] Bug with recipe vs technology icon scaling?

Post by Honktown »

I'm trying to port Dark Matter Replicators (well port a port of it, from 17 to 18):
https://mods.factorio.com/mod/dark-matter-replicators-R

The first error is it has type "particle" instead of type "optimized-particle". Changed the particle type and it loaded instantly, but icons were badly sized.

Explicitly sized the icons (many in 18 seemed to go to 64x64, not 32x32), but I cannot get the recipe and technology icons to render the same.

In __MOD__/prototypes/repltable/process-actual-creation.lua, the author passes over data, makes the icons, and then re-uses the recipe icons for technology.

I can serpent and see the tables are exactly the same in the recipe and technology:

Code: Select all

   8.747 Script @__dark-matter-replicators-18__/prototypes/repltable/process-actual-creation.lua:93: serpent of recipe icon: {
  {
    icon = "__base__/graphics/icons/iron-ore.png",
    icon_size = 64
  },
  {
    icon = "__dark-matter-replicators-18__/graphics/icons/borders/repl-ore.png",
    icon_size = 32
  }
}
   8.747 Script @__dark-matter-replicators-18__/prototypes/repltable/process-actual-creation.lua:131: serpent of tech icons: {
  {
    icon = "__base__/graphics/icons/iron-ore.png",
    icon_size = 64
  },
  {
    icon = "__dark-matter-replicators-18__/graphics/icons/borders/repl-ore.png",
    icon_size = 32
  }
}
Result good recipe icon in crafting menu, undersized in technology:
bad_scale1.jpg
bad_scale1.jpg (51.21 KiB) Viewed 1398 times
If I add a scale to the table:

Code: Select all

   8.644 Script @__dark-matter-replicators-18__/prototypes/repltable/process-actual-creation.lua:96: serpent of recipe icon: {
  {
    icon = "__base__/graphics/icons/iron-ore.png",
    icon_size = 64
  },
  {
    icon = "__dark-matter-replicators-18__/graphics/icons/borders/repl-ore.png",
    icon_size = 32,
    scale = 2
  }
}
   8.644 Script @__dark-matter-replicators-18__/prototypes/repltable/process-actual-creation.lua:134: serpent of tech icons: {
  {
    icon = "__base__/graphics/icons/iron-ore.png",
    icon_size = 64
  },
  {
    icon = "__dark-matter-replicators-18__/graphics/icons/borders/repl-ore.png",
    icon_size = 32,
    scale = 2
  }
}
bad_scale2.jpg
bad_scale2.jpg (54.77 KiB) Viewed 1398 times
I have a 2560x1440 screen with 150% scaling.

Mod itself:
https://mods.factorio.com/mod/dark-matt ... icators-18
I have mods! I guess!
Link
posila
Former Staff
Former Staff
Posts: 5448
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.18.10] Bug with recipe vs technology icon scaling?

Post by posila »

Unfortunatelly, icon definition is hot mess and I don't see how to fix it without breaking every single mod. Given how much hassle it was for modders when we made icon_size mandatory, it's not path I am willing to take. I am moving this to Modding help, so it's not lost in Minor issues.

For completeness, I'll link following thread, but it is mostly unrelated to the issue you are seeing: viewtopic.php?p=434010#p434010

So back to your issue.

There is inconsistency between how item and technology icons are treated. Item icons have some expected size (32x32px) and if scale is not provided explicitly, it is calculated such that given layer is scaled to 32x32px (for each layer independently!!!). Technology icons don't have expected size, so if scale is not specified, it will default to 1.

So to fix your problem, either be explicit with scale in both layers (the first layer scale 0.5 and the second layer 1, so that recipe icon has correct size in alt mode overlay), or ommit scale in both layers and for the second layer use image which matches icon size of the first layer.
Honktown
Smart Inserter
Smart Inserter
Posts: 1058
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: [0.18.10] Bug with recipe vs technology icon scaling?

Post by Honktown »

posila wrote: Thu Mar 05, 2020 12:16 pm Unfortunatelly, icon definition is hot mess and I don't see how to fix it without breaking every single mod. Given how much hassle it was for modders when we made icon_size mandatory, it's not path I am willing to take. I am moving this to Modding help, so it's not lost in Minor issues.

For completeness, I'll link following thread, but it is mostly unrelated to the issue you are seeing: viewtopic.php?p=434010#p434010

So back to your issue.

There is inconsistency between how item and technology icons are treated. Item icons have some expected size (32x32px) and if scale is not provided explicitly, it is calculated such that given layer is scaled to 32x32px (for each layer independently!!!). Technology icons don't have expected size, so if scale is not specified, it will default to 1.

So to fix your problem, either be explicit with scale in both layers (the first layer scale 0.5 and the second layer 1, so that recipe icon has correct size in alt mode overlay), or ommit scale in both layers and for the second layer use image which matches icon size of the first layer.
Thanks. I was concerned that if I hard-coded a work-around then it could change and I'd have to revert it. Ironically, fixing it for technology (in my case) is rather straightforward: grab the first icons size, and scale the 32 icon to that size. Not sure if I should go by 'largest' icon, but there's only one other icon in this case, so it works. For the recipe I assigned no scale, and yeah, a 64 icon and 32 icon are rescaled to whatever size.
I have mods! I guess!
Link
Post Reply

Return to “Modding help”