News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Industry images to use MapColor, via Player color logic

Started by wlindley, January 07, 2013, 01:22:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wlindley

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 ....?

prissi

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?

wlindley

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.

Ters

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).

wlindley

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...

wlindley

Quote from: Ters on January 08, 2013, 05:29:47 AM
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?

prissi

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.)

ӔO

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?
My Sketchup open project sources
various projects rolled up: http://dl.dropbox.com/u/17111233/Roll_up.rar

Colour safe chart: