News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

[Patch] Show only relevant items in Goods List and mini-map Factory Legend

Started by falconne, November 20, 2011, 12:03:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

falconne

My first attempt at a patch so suggestions are welcome. I did this mainly as an exercise to become familiar with the code.

This is a fairly simple patch that adds toggle buttons to the Goods List and the mini-map (when Show Industry is selected) that lets you filter the items listed to only the factories and goods that are currently in the game. That is, make the legend in the mini-map only show the factories that are in the current game world and the goods list only show goods produced by those factories. The lists are recalculated when the dialogs are opened.

The patch also makes the mini-map always show a tooltip when you hover over an industry square on the mini-map, telling you what it is, just like it does when you have "Factory links" toggled on.

This is how the dialogs look with the filters turned off: http://i.imgur.com/psolV.jpg
and this is how they look with the filters on: http://i.imgur.com/0fjmn.png
(I know "Gas Station" is listed twice but that's because I forgot to switch timeline on to make these screenshots... pak128 has 3 different "Gas Station" industries)

The reason I wanted this functionality is because I started off playing the game with pak128, which has some 65 industries and 37 goods or so... both the goods list and the factory legend on the mini-map were overwhelming. Since only a fraction of all that was actually in the game when you start off, it was quite distracting to have all that information cluttering the display when I'm trying to figure out what the most profitable lines would be. The mini-map legend was practically unusable since there are only a handful of distinguishable colours and it was impossible to relate the boxes you see on the map to that legend.

Edit: Uploaded an updated version that 1) sets the filter switch on the mini-map on by default and 2) lumps multiple industries with the same name, as can happen if a pack contains different versions of the same industry, into one entry in the legend.

Severous

I like that.  A nice game presentation improvement. Good job.  

Do patches like this get incorporated into standard simutrans?

Any other ideas falconne?

I noticed in my games that some industries are shown more than once on that display. That has happened in yours as well. Gas station is listed twice (was listed three times prior to your patch).

VS

That's because all types of gas station will show on their own, never mind that they have the same purpose and name. Same for all other factories. That could use some love, too... :)

Dwachs

falconne, impressive patch-to-post-number ratio :)

Patch looks nice. Maybe 'show current' should be enabled by default? Who wants to see non-existing factories on the minimap?

falconne

Thanks. I'm starting off simple though :)

I also think the filtering on the mini-map should be on by default. I might update the patch to do that. In fact, the only reason to show all  is in case new players think the only industries in the game are the ones they see at the start of their first game and not realise there're a lot more in the game. If there was another way for people to see future industries, there would be no need for a toggle button on the mini-map.

Quote from: Severous on November 20, 2011, 12:59:22 PM
I noticed in my games that some industries are shown more than once on that display. That has happened in yours as well. Gas station is listed twice (was listed three times prior to your patch).
Yes I only realised that after I posted the screenshots. The problem is as VS said. I had not seen this in my games before as I haven't played many games yet.

I can fix this with my patch too. I'll post an update.
Edit: Just uploaded a new version with the above changes. Gas station still appears twice though, because one model is named "Gas Station" and the other two "Gas station", but that should be fixed in the pak.

prissi

Problem is, those with identical translation could have different colors still ...

VS

Falconne, matching names won't help much, since it might make sense to merge Gas station and Modern gas station, too...

wlindley

Perhaps industries could be merged if they have:


  • the same map-color, and
  • at least one word in the name in common (ignoring case), and
  • at least one input in common (or else: both must have no inputs), and
  • at least one output in common (or else: both must have no outputs).

If no counter-example to that can be found, isn't that a safe enough set of circumstances to conclude that they are the same type of industry?

Fabio

Personally I would merge all those
1) with same color, and
2) same input(s) and output(s)

VS

Personally I think it would be better to define this in some pakset config file, rather than automagically making sense of that mess... You might want to give some good (more generic) name to the group, such as "coal mine" where the members are "surface coal mine" and "shaft coal mine" (real example from 128). That said, same in+out would help a lot of the issues.

falconne

I didn't realise there were that many versions of the same types of industries. It's easy enough to consider industries with the same inputs and outputs as the same type, but how would you pick a name to describe the combined item? In the above example "surface coal mine" and "shaft coal mine" are obviously "Coal mine", but trying to derive that by looking for a common phrase in the names of multiple industries in a language independent way is too messy in my opinion.

I think, as VS said, an optional "Industry Category" field is required to group similar industries and give them a name. The filtering code can be updated when that's available.

I think the simple filtering in the patch still makes the mini-map legend a bit more newbie friendly because if you start the game with the default options and the timeline on, you aren't likely to start with too many same category industries (aside from coal mines maybe). I think there's more that can be done though... several industries use the same or similar colours which make them hard to distinguish at a glance. I want to create a further patch later that allows you to click the name of an industry on the legend (by creating a "label" type component that can handle events) and it outlines the relevant industry squares on the mini-map for that selection with a bright yellow border. That should make it easier to make plans based on the layout of high value industries.

Fabio

Quote from: falconne on November 22, 2011, 02:37:21 AM
how would you pick a name to describe the combined item? In the above example "surface coal mine" and "shaft coal mine" are obviously "Coal mine", but trying to derive that by looking for a common phrase in the names of multiple industries in a language independent way is too messy in my opinion.

An option could be "Coal Producer" = The main output + "producer"
You could also return a translation string where you translate producer in the right order (e.g. "%n producer", "producteur de %n", "produttore di %n" etc...) and you pick the output product name and its existing translation from goods list.

falconne

Quote from: fabio on November 22, 2011, 08:14:44 AM
An option could be "Coal Producer" = The main output + "producer"
You could also return a translation string where you translate producer in the right order (e.g. "%n producer", "producteur de %n", "produttore di %n" etc...) and you pick the output product name and its existing translation from goods list.

The top end industries like Gas stations don't produce anything though. Also I think it would affect immersion if generic names were generated, even if it was only in a legend and only in case if duplicates; seeing "Coal producer" as an industry just doesn't seem right.

VS

Essentially, my idea is to load a file like this...



name[0] = Coal mine
color[0] = 123
items[0][0] = shaft_coal_mine
items[0][1] = shaft_coal_mine_small
items[0][2] = rmax_dragline

name[1] = Gas station
color[1] = 65
items[1][0] = TANKE1
items[1][1] = TANKE2



... and hide in listing the individual items mentioned here, displaying their groups instead.

Fabio

@VS: What would happen if a, say, addon coal mine were added to the pakset?
My concern is mostly the official pak, so it doesn't bother, but there are players who usually include addon industries...

wlindley

Quote from: fabio on November 22, 2011, 02:26:33 PM
What would happen if a, say, addon coal mine were added to the pakset?

VS's suggestion was that the pakset should describe which factories have one name: Instead, each factory should contain

canonical_name = Gas station

In that way, add-ons can appear within the same name.

VS


prissi

Lets do not get too distracted and focus on the first idea, only to show relevant industries and goods.

Severous

80/20 rule. Deliver 80% of something for 20% of the effort.  Often better to deliver benefit like this than try for 100%, spend a lot of time, and maybe even fail.  (bit like that inland fishing port problem recently which could have benefited from a simple solution rather than failing because checking for a shipping route was too complex)

falconne

Yeah I'm not keen to make more changes to this patch; it would increase the chance of breaking something. It's fairly simple right now and I think it does enough as it is. Also I think further work is required before people will actually find the legend useful anyway and I have a few ideas about that (like highlighting the industries on the map when you click a label on the legend). Those patches would build on top of this.

If there's any clean up required to the code before it can qualify for trunk let me know. I hadn't worried about submitting text for language files to begin with and I should really look that up before doing more coding. What's the procedure around that? I don't see an en.tab file under source control.

VS

Files such as en.tab are more like generated than sources. The way this is done is:
1) There are pseudo-objects with the strings for translation,
2) they are imported into SimuTranslator,
3) people translate,
4) then are exported the .tab files with actual translations.
The file with pseudo-objects looks a bit like a regular dat file, just isn't fed to makeobj :) You'll find it one directory above trunk, called base.tab

falconne

Ah I see. If that file is above trunk, I assume I don't need to change it? Presumably prissi does that for patches that get merged to trunk?

Dwachs

New strings have to be imported directly into the translator web site. The base.tab file is more or less some kind of reference, which strings have to be translated, but otherwise this file is not used.

VS

Ahhh... Nope, I think import is done with exactly this file. It would be very nice of you to provide a patch of it, too, or even just a part to append (since that's what is needed here).

falconne

Cool, thanks, I've attached a patch to base.tab in the first post and I'll do that for future patches too.

I'm working on a new patch that builds on top of this one to apply similar filtering to the depot "purchase" panel. Specifically, it adds a "Filter" drop down that lets you show only the vehicles relevant to transporting goods currently in the game, or for a specific good if you select it from the drop down (which is also kept down to relevant goods). I'll submit that separately as it's got other stuff going on and likely to need feedback and changes. It uses the code I've written for this patch however, so if this makes it into trunk I'll consolidate the code afterwards.

prissi

Filter only for goods sounds good, by for specific goods it might be rather too much. Also simutrans UI does not use dropdowns for mandantory choices, as those are modal dialogues and should be avoided. I would rather stick with a button of "hide unneeded" or so. But lets discuss this when the patch appears ...