The International Simutrans Forum

 

Author Topic: Industry images to use MapColor, via Player color logic  (Read 1506 times)

0 Members and 1 Guest are viewing this topic.

Offline wlindley us

  • Devotee
  • *
  • Posts: 978
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Industry images to use MapColor, via Player color logic
« on: January 07, 2013, 01:22:37 AM »
Currently Industries (factories, Werke) have a MapColor defined in their dat files.  In the case of shops especially, it would be convenient -- and re-enforce the visual impact of color-coding -- if the already-reserved Player Colors in the png files could be used to paint the Map Color (and there would need to be a MapColor2 for the contrasting industry color, to again match the secondary player colors). 


That way, you could paint just one shop, and use the same image for all the consumer industries.  Or, in the spirit of the Modular (tile-by-tile) style of industry painting, you could draw a goods dock with a sign that could be re-used on many industries and would automatically take on the mapcolors of that industry.


I would be happy to add this feature, with a bit of guidance on which part of the code to adjust (simgraph16? or perhaps besch/bild_besch ....?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9568
  • Languages: De,EN,JP
Re: Industry images to use MapColor, via Player color logic
« Reply #1 on: January 08, 2013, 12:32:48 AM »
I fail to see the connection between the color in the minimap and the player color on the screen. If you replace the color for the public player, factories could get also other colors (if you used player colors). Also there are only 28 player colors.

Maybe you could repeat you request a little differently?

Offline wlindley us

  • Devotee
  • *
  • Posts: 978
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: Industry images to use MapColor, via Player color logic
« Reply #2 on: January 08, 2013, 02:56:48 AM »
I mean:   Take the 16 colors that are reserved in the PNG for player colors -- two sets of eight color gradations each as shown here.  For industries, instead of "player" colors, map them to gradations of the Industry mapcolor (for the Player1 colors), and a new mapcolor2 (for Player2 colors).



For example, at least in Pak128.Britain, the butcher's shop has a red-and-white awning to match its dot color on the minimap.  So the blue player1 colors in the PNG would be mapped to shades of red; and the yellow player2 colors to shades of grey to white.  Then the same shop graphic, when used in for the Hardware shop, would be shades of orange and white; for the clothes shop they would be shades of pink and purple, and so on. 

Thus a single shop graphic could be used in any industry chain.

This shouldn't require any (or much) code that isn't already there.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5543
  • Languages: EN, NO
Re: Industry images to use MapColor, via Player color logic
« Reply #3 on: January 08, 2013, 05:29:47 AM »
I suspect this won't be as trivial. The drawing routines don't know if the image they are about to render belongs to a factory or a train. It is likely easier to do this when making the pak. Simple stuff like this isn't really hard to do manually in any half-decent graphics program. It can perhaps even be scripted somehow (with the graphics program, not Simutrans).

Offline wlindley us

  • Devotee
  • *
  • Posts: 978
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: Industry images to use MapColor, via Player color logic
« Reply #4 on: January 08, 2013, 11:58:53 AM »
It's not the difficulty of drawing a pak, it's the proliferation of thousands of images that most concerns me.  If the color-replace code always gets called anyway, it's a waste of my time as a pak author, and a waste of disk and memory, to have for twelve shop-types, times two (regular + snow), times six different eras = 144 images, instead of twelve images (six eras regular, six images snow).   In Pak128, that's 1,769,472 bytes uncompressed (128 bits / 8 bits/byte * 3 bytes/color * 128 lines * 144 images * 4 rotations) compared to 147,456 bytes... and that's just for the shops!  A couple megabytes here, a couple megabytes there, and soon we're talking real space...

Offline wlindley us

  • Devotee
  • *
  • Posts: 978
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: Industry images to use MapColor, via Player color logic
« Reply #5 on: January 08, 2013, 03:42:25 PM »
The drawing routines don't know if the image they are about to render belongs to a factory or a train.

Right -- they just get a "player number" as a signed 8-bit integer.  That number is used as a lookup base in the player-colors table for any pixel whose compressed 16-bit value has the high bit set (0x8000).  So in the function that calls the drawing routine, which does know what it's drawing, we take the mapcolor, shift it right twice to get the base of the group-of-8 mapcolor spectrum -- thereby reducing mapcolors 0..223 to a map_color_group 0..55, and tell the drawing routine that the sprite belongs to player = map_color_group + max_player_offset... where we have already loaded the player color table with identical values from the mapcolor table:

http://simutrans-germany.com/wiki/wiki/tiki-index.php?page=en_FactoryDef

That's all it would take, I think... no?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9568
  • Languages: De,EN,JP
Re: Industry images to use MapColor, via Player color logic
« Reply #6 on: January 08, 2013, 11:02:08 PM »
Variation in houses is created this way in TTD; but honestly single shop factories are already hard to spot. Making them even more unique does not seem very user friendly to me.

The industry drawing code could easily overide the drawing routines for foreground color for factories. But the actual drawing of the background only cares for ownership. (I could image a hackish way around this, but that would never get into the code. We tried very hard to keep it as little hackish as possible.)

Offline ӔO

  • Devotees (Inactive)
  • *
  • Posts: 2345
  • Hopefully helpful
  • Languages: en, jp
Re: Industry images to use MapColor, via Player color logic
« Reply #7 on: January 08, 2013, 11:34:48 PM »
If two colours are allowed, like they are with player colours, that would allow a lot more variation without increasing the pallet.

I dunno, something like a border colour to go around the main colour may work?