OpenTTD

Tasklist

FS#1199 - Patch : Speed limits tab in vehicle window

Attached to Project: OpenTTD
Opened by Sylvain Devidal (MagicBuzz) - Tuesday, 04 September 2007, 22:29 GMT
Last edited by andythenorth (andythenorth) - Monday, 14 August 2017, 20:10 GMT
Type Patch
Category Vehicles
Status Closed
Assigned To andythenorth (andythenorth)
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

Some trains sets use speed limit for wagons, and it's great. But when the vehicle is built, you know its global speed limit, but you can't figure out which wagons or engines are responsible of this limit.

So I just designed a very small patch in order to add a new tab in the vehicle info, to see the actual vehicle speed limit for each element of the train.

It remains just a small problem : The buttons are smaller now, so the labels should not fit with all languages.

r11042

Forum http://www.tt-forums.net/viewtopic.php?f=33&t=33941
This task depends upon

Closed by  andythenorth (andythenorth)
Monday, 14 August 2017, 20:10 GMT
Reason for closing:  Won't implement
Additional comments about closing:  Mass closure of patch tickets with no commentary for >5 years. Goal is to reduce patch queue as an experiment to see if it aids faster reviewing and rejection/acceptance (it may not). If this offends you and the patch is maintained and compiles with current trunk, discuss with andythenorth in irc. (andythenorth has no ability to review patches but can re-open tickets).
Comment by Benedikt Brüggemeier (skidd13) - Wednesday, 05 September 2007, 08:59 GMT
I like the idea of the patch.
I noticed 2 things:
- in "src/lang/english.txt" are a few spaces&tabs too much
- TrainDetailsSpeedsTab() should have some comments for the documentation. See http://wiki.openttd.org/index.php/Coding_style#Functions_2
Comment by Sylvain Devidal (MagicBuzz) - Wednesday, 05 September 2007, 10:10 GMT
Hello,
I just updated with some comments.
About the english.txt file, I can't see which spaces/tabs you are talking about (I uses VS2005 and it uses tab size to 4. The whole file seems to be correctly lined up with these settings)

Update to r11044
Comment by Sylvain Devidal (MagicBuzz) - Wednesday, 05 September 2007, 10:29 GMT
Variant of the patch, with right aligned speeds.
Same revision.
Comment by Benedikt Brüggemeier (skidd13) - Wednesday, 05 September 2007, 14:03 GMT
MagicBuzz: I can't see which spaces/tabs you are talking about
The problem IMO is you use tabs. The common way is to use spaces to align.
I just noticed it while reading the diff in Iceweasel.
Comment by Jean-Francois Claeys (Belugas) - Wednesday, 05 September 2007, 14:10 GMT
A picture is worth a thousand words. The red arrows are tabs. Unwanted. To be replaced by spaces, please.

Furthermore, I would strongly suggest that (while you are dealing with that gui) you should replace the widget index by enums. It will make the whole code less "magical"

I was wondering... instead of having the buttons been squeezed a little more, why not open up the gui by adding a new row of buttons?
Comment by Sylvain Devidal (MagicBuzz) - Wednesday, 05 September 2007, 15:29 GMT
Here are the corrections:
- Used space rather than tabs in english.txt
- Added a new button line in order to keep original size for the original buttons
- Used an enum TLW_* (for Train List Widgets) to name the widgets in the code instead of "magic numbers"

Still a minor bug:
- The original buttons are resized whan resizing the window. Mine doesn't, and I can't understand why...
Comment by Benedikt Brüggemeier (skidd13) - Wednesday, 05 September 2007, 19:01 GMT
I added a full enumification patch. This might be usefull for you.
Comment by Sylvain Devidal (MagicBuzz) - Thursday, 06 September 2007, 07:39 GMT
Well...
I was trying to update the patch with a complete enumeration (rien now I only updated the controls that were used in the code), but I just face to a problem I can't solve myself:

With the r11050, the vehicle detail window has been unified between all types of vehicles.
But the "Speed" tab will apply only for trains, then I don't know what to do...

I don't know how to hide/unhide some controls in a windows dynamically (for any vehicle but trains, the new line with the "speed" buttond shouldn't be displayed).
And I don't think that creating a new window definition especialy for the trains is a good idea.

Could someone help me ?
Comment by Benedikt Brüggemeier (skidd13) - Thursday, 06 September 2007, 12:44 GMT
The quick Idea I've got would be to add the speed button and the spacer in the global window descritpion and hide them at WE_CREATE for vehicle type != train. But it needs a bit more thinking. I'll see what I can do for you, when I'm back home.
A GUI that does similar things is the order_gui IIRC. Maybe have a look at the solution in there.
Comment by Sylvain Devidal (MagicBuzz) - Thursday, 06 September 2007, 19:29 GMT
Here is the update for r11050 (thank you and nycom for the tips!)

Thus now the button is correctly resized when window size changes.
I had to split my "end line" panel into 3 smaller pannels in order to make it works although. These 3 panels may be used for other new patches.
Comment by Benedikt Brüggemeier (skidd13) - Thursday, 06 September 2007, 20:43 GMT
Nice. :)
The 3 extra buttons could confuse beginners.
The GUI must defenetly care about beginners IMO.
A large panel should do a better job.
Comment by Sylvain Devidal (MagicBuzz) - Thursday, 06 September 2007, 21:13 GMT
That's what I did, but I have a problem with the "ResizeButton".
If I use a "big" panel and activate the resizing on the button, the button take 1/2 of the window width. It seems the ResizeButton function use the same witdh for any control rather than keeping correct ratio.
I think having a so big button for a so small patch is quite strange.
Anyway, I can change if you really think it's a better solution (or remove the resizing function)
Comment by Benedikt Brüggemeier (skidd13) - Thursday, 06 September 2007, 21:21 GMT
I'd do it this way:
- Vertical size of speed button and panel = 0
- Hide the size button and the panel allways.
- Resize and show them if a the window is for trains
Comment by Sylvain Devidal (MagicBuzz) - Friday, 07 September 2007, 09:54 GMT
I don't have any problem with showing/hiding these buttons.

The problem is that when you resize the windows (left/right) the tab buttons "cargo", "information", "capatity" and "total cargo" are resized also (ie when the window width is 400px, each button is 100px, when it's 600, the buttons are 150 :

1111222233334444 (400 px)
111111222222333333444444 (600 px)

This is done with the "ResizeButton" function. It resize the widget list you give in parameter. But the limitation of this function is that if a widget width is initialy 100px and the other one is 300px, after resizing the window, they do the same width : 200px each. The ResizeButton doesn't keep ratio.

1111222222222222 (initial size)
111111111111222222222222 (resized to 600px)

As a result, when I designed a small button followed by a big pannel (x3 place holder width), when resizing, by button was 2x button width and the panek was 2x button width.
That's why I created 3 small pannels rather than 1 big : button and pannels do the same size when resizing.

All that I could do is to stop using the ResizeButton function the the second line, but it won't be nice, as a resized window will loot at this :

===B1===|===B2===|===B3===|===B4===
=B5=|==============================

(B1, B2, B3, and B4 are the "cargo", "information", "capatity" and "total cargo" buttons and B5 is the "Speed" button).
Comment by Benedikt Brüggemeier (skidd13) - Friday, 07 September 2007, 11:46 GMT Comment by Benedikt Brüggemeier (skidd13) - Friday, 07 September 2007, 11:52 GMT
Another idea would be to use the event WE_RESIZE and sync values:
B5.right = B1.right;
Panel.left = B2.left;
Comment by Sylvain Devidal (MagicBuzz) - Friday, 07 September 2007, 16:17 GMT
Thank you.
The direct left and right properties update is not really "clean", but that was easy to do, so I used and it works perfectly.
Thanks a lot!

ResizeButtons(w, VLD_WIDGET_DETAILS1_CARGO_CARRIED, VLD_WIDGET_DETAILS1_TOTAL_CARGO);
ResizeButtons(w, VLD_WIDGET_DETAILS2_SPEEDS, VLD_WIDGET_DETAILS2_FREE3);

Becomes

ResizeButtons(w, VLD_WIDGET_DETAILS1_CARGO_CARRIED, VLD_WIDGET_DETAILS1_TOTAL_CARGO);
w->widget[VLD_WIDGET_DETAILS2_SPEEDS].right = w->widget[VLD_WIDGET_DETAILS1_CARGO_CARRIED].right;
w->widget[VLD_WIDGET_DETAILS2_ENDLINE].left = w->widget[VLD_WIDGET_DETAILS1_TRAIN_VEHICLES].left;

(VLD_WIDGET_DETAILS2_FREE1, 2 and 3 widgets gone, replaced by VLD_WIDGET_DETAILS2_ENDLINE).
Comment by Benedikt Brüggemeier (skidd13) - Wednesday, 19 September 2007, 16:50 GMT
Small update to keep the patch up2date
Comment by Benedikt Brüggemeier (skidd13) - Wednesday, 31 October 2007, 19:14 GMT
Update by me cause the author seems to be uninterested. Hope I fixed all style stuff.
Comment by Benedikt Brüggemeier (skidd13) - Thursday, 01 November 2007, 17:24 GMT
Fixed some typos.
Comment by Benedikt Brüggemeier (skidd13) - Thursday, 01 November 2007, 17:28 GMT
Sorry missed one mistake.
Comment by Patric Stout (TrueBrain) - Saturday, 03 November 2007, 21:19 GMT
I found it rather ugly in-game. Yet an other button. Isn't it possible to group together some of those items? Like Cargo and Total Cargo? Or maybe make one general window? It isn't that much information...
Comment by Benedikt Brüggemeier (skidd13) - Tuesday, 11 March 2008, 10:57 GMT
For the log:
the patch or the idea haven't died at all...
I've got the idea to merge the whole settings in a matrix window.
But since it is a lot of work and trunk is in feature freeze ATM it is deferred past 0.6.
Comment by Peter Nelson (peter1138) - Tuesday, 11 March 2008, 11:15 GMT
Why not simply show the speed limits in the 'Information' tab? There is a reasonable amount of space there...
Comment by Benedikt Brüggemeier (skidd13) - Tuesday, 11 March 2008, 12:19 GMT
I thought over merging the existing tabs to:
- a global / general tab
-- list view
-- about the whole train
-- used by all vehicle types
- a weagon tab
-- matrix view
-- about each weagon / engine
-- this could maybe used by ARVs too
- a economy tab
-- list view
-- with the informations like running costs, service intervall, etc.
-- used by all vehicle types
Comment by Sébastien Brissaud (sbr) - Saturday, 13 March 2010, 20:56 GMT
Show the max speed of the rail vehicle in the 'Information' tab of the details window.
The max speed isn't displayed for a rail wagon if 'wagon speed limit' is disabled or if it hasn't a speed limit.

Please find an attached patch against r19403.
Comment by Alberth (Alberth) - Sunday, 21 March 2010, 12:20 GMT
A nice and simple solution, perhaps a bit too simple. Please open the attached picture, and tell me in one glance (ie without actually reading each line) which parts of the train are the limiting factor.

I couldn't.

The reasons for that seem to be (I think):
1) The current picture is a mess, it takes a while before you understand what numbers are important to answer the question. The unpatched version was already pushing it, this is just a bit too much.
2) No highlighting. All numbers are in one colour, so I have to figure out what the lowest numbers are, and how many there are.

The fix for 1) *may* *be* to use columns. That would definitely help here (nowadays, the GUI code is much more flexible, it can take care of the sizing problems for you), but how that affects the other tabs is a question that needs some careful thought.
Perhaps other solutions are possible here, with less impact on the other tabs.

The fix for 2) would be to use a different colour either for the limiting number (but that would include the 160km/h in the top-panel too), or for the non-limiting numbers.

Loading...