News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Sortable table

Started by [C] Ranran, January 05, 2023, 06:04:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

[C] Ranran

This is an experimental patch with major UI improvements.
Also ex-15 branch can make great use of this. So I was testing this by merging it into my ex-15 branch, but be aware that it was unintentionally already merged into the main ex-15 branch.


The big goal of this patch is to convert all lists into sortable tables.
I think this would greatly improve usability and appearance.

As a start, only the vehicle list was made compatible with this.
You can test it on this branch.
https://github.com/Ranran-the-JuicyPork/simutrans-exp/tree/2301-sortable-vehiclelist
The latest executable is available at:
https://github.com/Ranran-the-JuicyPork/simutrans-exp/actions/runs/3848930099

Sortable tables are such a commonplace design these days that players will immediately understand their functionality at first glance.


Overview:
- Color scheme of sortable table can be changed by theme
- A sortable table can be sorted by clicking on the header cell. Click again to change the sort order.
- Column header cells with sorting enabled display an arrow indicating the sorting direction.
- Columns are highlighted for filtered items
- The selected item is highlighted in the horizontal row. (The color different from filter's one)
- These changes obsolete the sort options combo box and the sort direction button.
- Avoid repeating the same labels by listing them in rows in a table format. For example, if it has 1000 vehicles, you would previously see 1000 "Maximum speed:" labels, taking up wasted space.
- Having numbers in columns greatly improves visibility and makes it easier to compare values.


Vehicle list changes:
- Added name filter.
- Vehicle image changed to side view. This is to keep the line height down and allow more vehicles to be displayed at once. It also makes it easier to check the length of the vehicle. However, it does not support hacked large vehicles such as planes and ships. because it's a hack.
- Due to the width of the list, side view and name display are switched.
- You can always check the vehicle name by hovering over it.
- Consider truncating header labels if they become too long to reduce dead space. I wonder if all of this should have their own translations. Anyway, I think that the tractive force is too long for English, so I have assigned the text for shortening. Any opinions on this would be appreciated.
- The list display has been reorganized into major sortable items. For example painted by, please check the vehicle details window from now on.
- Class indications are indicated by yellow dots. It also supports cases where a vehicle has multiple classes. However, if the pakset has too many classes and the vehicle has too many accommodations, the display will be truncated.
- By clicking on the row, the vehicle details window will open so you can check the details.

- the filter is disassembled
For example, only old vehicles can be displayed. Until now, it was sometimes difficult to narrow down the target vehicle because the list was so large that active vehicles were always displayed.
- Timeline filters are now colored buttons. This is linked to the color of the color bar, and I think the player can operate the filter intuitively.
- However, it should be noted that being upgrade-only is a timeline and another factor. At first glance, this behavior may be a little difficult to understand.
- When the timeline filter button is enabled, the number of hits is displayed on the button.


Vehicle details dialog:
- This vehicle detail component is intended to be shared with several dialogs in the ex-15 branch.
- A vehicle detail can switch to one vehicle if it can only be connected to that vehicle.
- You can check whether the front or rear connection is possible.
- Upgradable vehicles can be switched to an upgrade origin or upgrade destination.


You should check the save revision before merging this.

This kind of change is applicable to all lists. That is, I believe that similar updates can be applied to existing list windows.
I'm new to programming and unprofessional, so the code may have some points that need improvement. (´・ω・`)
It's just an existing way of arranging by colored cells. However, one row is one component, as existing methods had many size calculation and positioning issues.

Anyway, I hope this modification will lead to improvement. I would appreciate your feedback.

See you at the next dinner(´・ω・`)らんらん♪

jamespetts

Thank you for this. I have attempted to test this, but unfortunately get merge conflicts with the Ex-15 branch.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

[C] Ranran

Quote from: jamespetts on January 14, 2023, 04:25:28 PMThank you for this. I have attempted to test this, but unfortunately get merge conflicts with the Ex-15 branch.
https://github.com/Ranran-the-JuicyPork/simutrans-exp/tree/ex15-sortable
Please check this branch.

jamespetts

Excellent, thank you for that. I have now managed to merge this and test it. Feedback so far as is follows.

  • Generally, the concept and implementation is very good: it is much easier to see the available vehicles in the list and understand their relative qualities.
  • Whenever I click one of the column headers, I get an address sanitiser crash (complaining of use of deallocated memory) in line 227 of gui_container.cc.
  • Even when "show_side_view" is selected, the column header is still "name"
  • The various status filters may need more thought: it is not obvious what the buttons do when they say "off" "12" "off" "off" "off" and "off". Also, for gameplay reasons, it is probably better to exclude the future button entirely.
  • The search function is excellent.

Thank you again for your work on this.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

[C] Ranran

Thank you for testing it.

Quote from: jamespetts on January 18, 2023, 10:55:05 PM
  • Whenever I click one of the column headers, I get an address sanitiser crash (complaining of use of deallocated memory) in line 227 of gui_container.cc.
I believe this is the same kind of problem that recently fixed in another patch. I think I have fixed it.
https://github.com/Ranran-the-JuicyPork/simutrans-exp/tree/ex15-sortable-2
Please check this branch.

Quote
  • Even when "show_side_view" is selected, the column header is still "name"
Note that clicking it will sort by name even when in side view mode. Even in side view mode, the name can be checked by hovering over the row.
Sorting by name is an important sorting option, and sorting suitable for side view is probably length, but I wonder if it's necessary. IMO it's not so important that it's worth the extra effort to break the consistency of the table.


Quote
  • The various status filters may need more thought: it is not obvious what the buttons do when they say "off" "12" "off" "off" "off" and "off".
Changed the preceding text to "Status filter(count):". I think we can imply that by changing the translation.
I don't speak English, so it might be better to say found than count.

QuoteAlso, for gameplay reasons, it is probably better to exclude the future button entirely.
Future vehicles, like other dialogs, will only show up to one year in the future if the show future mode is turned off. Therefore, I think there is no problem.
Rather, the player can experience the ease of checking announcements of new product releases by manufacturers.

jamespetts

Thank you for this. On testing in the ex-15 branch, however, I am now getting a new crash when clicking the column headers (for the second time): a crash in line 206 of gui_scrolled_list.cc. I should note that I was sorting by the name header when this occurred.

Edit: Also, even with show_future_vehicle_information = 0 set in the pakset's simuconf.tab, I still see vehicles far into the future when testing this in 1900.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

[C] Ranran

Quote from: jamespetts on January 22, 2023, 11:00:15 AMAlso, even with show_future_vehicle_information = 0 set in the pakset's simuconf.tab, I still see vehicles far into the future when testing this in 1900
Thank you for pointing this out. The judgment of show_future_vehicle_information was reversed. I think now I have fixed it.

Quote from: jamespetts on January 22, 2023, 11:00:15 AMOn testing in the ex-15 branch
Does this mean the ex15-sortable-2 branch?
I cannot reproduce this crash.

jamespetts

Quote from: [C] Ranran on January 22, 2023, 11:44:06 AMThank you for pointing this out. The judgment of show_future_vehicle_information was reversed. I think now I have fixed it.

Excellent, thank you. This is now working as expected.

QuoteDoes this mean the ex15-sortable-2 branch?
I cannot reproduce this crash.

Yes, that is the branch. I can still reproduce it. It only appears to occur on the second click on the column header, i.e., to sort ascending rather than descending.

The error appears initially by way of an assert failure in the STD library when the code calls std::sort() in line 204 of gui_scrolled_list.cc - the error appears to be described as an invalid comparator error. Ignoring the assert failure leads to a crash in line 206 of gui_scrolled_list.cc.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

[C] Ranran

Quote from: jamespetts on January 22, 2023, 03:11:57 PMYes, that is the branch. I can still reproduce it. It only appears to occur on the second click on the column header, i.e., to sort ascending rather than descending.

The error appears initially by way of an assert failure in the STD library when the code calls std::sort() in line 204 of gui_scrolled_list.cc - the error appears to be described as an invalid comparator error. Ignoring the assert failure leads to a crash in line 206 of gui_scrolled_list.cc.
Thanks for the clarification. It looks like the problem below.
https://stackoverflow.com/questions/32263560/errorinvalid-comparator-when-sorting-using-custom-comparison-function

I made a fix and would appreciate it if you could confirm that it avoids the crash.

jamespetts

Quote from: [C] Ranran on January 23, 2023, 09:09:45 AMThanks for the clarification. It looks like the problem below.
https://stackoverflow.com/questions/32263560/errorinvalid-comparator-when-sorting-using-custom-comparison-function

I made a fix and would appreciate it if you could confirm that it avoids the crash.

Thank you very much for this. Unfortunately, however, this does not appear to fix the problem - the original issue can be reproduced exactly as before.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

[C] Ranran

Quote from: jamespetts on January 23, 2023, 07:28:46 PMThank you very much for this. Unfortunately, however, this does not appear to fix the problem - the original issue can be reproduced exactly as before.
thank you for making sure.

[C] Ranran

I believe I have fixed this issue. Please confirm.

jamespetts

Quote from: [C] Ranran on January 24, 2023, 11:20:30 AMI believe I have fixed this issue. Please confirm.

Excellent, thank you. This is indeed now fixed. I have re-fixed the problem with future vehicle filtering and an additional issue with translation for a window title text and now incorporated this into the ex-15 branch.

Thank you for your work on this.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

[C] Ranran