The International Simutrans Forum

 

Author Topic: Sort Vehicles in Depot Window  (Read 7126 times)

0 Members and 1 Guest are viewing this topic.

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #70 on: January 09, 2018, 04:58:05 PM »
Dates like that are problematic, since the month/year order and separators are different among cultures (e.g. Japan year/month versus Germany month.year). Thus there was one central routine to take care of dates.
Also it needsto deal with missing intro or retirement dates.

I've already solved this problem. Please check the post above.
Use the same format as the status bar to show intro. date and retire date. (depending on show_month in simuconf.tab)[/li][/list]

Quote
My suggestion to convert power and gear would be rather a multiplier shown to get the effective power.
Power: 88 kW (x2.0)
I like prissi's idea more than Leartin's idea, but considering the sorting, sort by "effective power", not "power" would be better...

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9099
  • Languages: De,EN,JP
Re: Sort Vehicles in Depot Window
« Reply #71 on: January 10, 2018, 01:11:51 AM »
No, you did not. You wrote 2012/01 but for Germany we need 10.2012 and for Japan 2012年1月, which are apparently not the same. Also we need to indicate missing entry of retire dates.

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #72 on: January 10, 2018, 03:08:52 PM »
No, you did not. You wrote 2012/01 but for Germany we need 10.2012 and for Japan 2012年1月, which are apparently not the same. Also we need to indicate missing entry of retire dates.

I understand.
So, if show_month is 2 or 5, the text should be "Available: 2000年1月 - 2012年1月".
If show_month is 3 or 6, the text should be "Available: January 2000 - January 2012".
If show_month is 4 or 7, the text should be "Available: 01.2000 - 01.2012".

The text will be "Available: January 2000 -" for missing entry of retire dates in my plan and I think it is the best way.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9099
  • Languages: De,EN,JP
Re: Sort Vehicles in Depot Window
« Reply #73 on: January 10, 2018, 11:31:01 PM »
But there are countries that use "-" as delimiter between month and year. Maybe better a text or a symbol "*" for undefined dates? Or just the current text string as it is.

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #74 on: January 11, 2018, 07:55:51 AM »
But there are countries that use "-" as delimiter between month and year. Maybe better a text or a symbol "*" for undefined dates? Or just the current text string as it is.

In simutrans "-" is not used for delimiter, so I don't think it may cause misunderstanding.
Or show "Available: January 2000 - Forever" or something?

Offline Leartin

  • Devotee
  • *
  • Posts: 1002
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Sort Vehicles in Depot Window
« Reply #75 on: January 11, 2018, 02:11:47 PM »
But there are countries that use "-" as delimiter between month and year. Maybe better a text or a symbol "*" for undefined dates? Or just the current text string as it is.

That deliminator would be an ISO8601 conform hyphen, like in Lithuania. For an interval, ISO8601 mainly uses a solidus, but the standard allows for a double hyphen. That somewhat conforms to what it used in normal writing, which isn't a hyphen (-)  but a slightly longer en-dash (–) for intervals, and for full dates usually spaced on both sides.
"2000-01 – 2012-01" doesn't seem like a problem to me, so neither does "2000-01 –", though a placeholder "2000-01 – *" looks even better – especially if it's the other way around in  "* – 2012-01"

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #76 on: January 12, 2018, 01:51:37 AM »
I refined the window layout and adopted this discussion.
  • Merge Power and Gear.
  • Merge Intro. and Retire date.
  • Use appropriate format to show date. (depot_win_show_month.png)
  • If the retire date is not defined, show "*" instead of the date. (vehicle_without_retire_date.png)

I adopted number instead of month name to show date because there's not enough space in some cases. (problem.png)
I wanted to use short month names (Jan., Feb., Mar. ...) but we have to add translation if I use them.

.diff file based on r8365 is in attachment.


By the way, I found a typo in simuconf.tab in line 568.
Code: [Select]
# 5>=show no season but everything else in japan format=5, us format=5, german=6This should be
Code: [Select]
# 5>=show no season but everything else in japan format=5, us format=6, german=7

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #77 on: January 12, 2018, 01:58:56 AM »
Sorry, I found some mistakes in .diff file.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1283
Re: Sort Vehicles in Depot Window
« Reply #78 on: January 12, 2018, 02:40:49 AM »
IMHO only show_month = 3 or 4 gives a workable long date string in the status line (December 6 1922, 6 December 1922). However the both 12/1922 and 12.1922 for short dates are gibberish - show_month = 2 for 1922/12 is ok, but then gives garbage for long format.  Hence, if the short date strings are being added, they need their own config setting.

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #79 on: January 15, 2018, 05:49:51 AM »
IMHO only show_month = 3 or 4 gives a workable long date string in the status line (December 6 1922, 6 December 1922). However the both 12/1922 and 12.1922 for short dates are gibberish - show_month = 2 for 1922/12 is ok, but then gives garbage for long format.  Hence, if the short date strings are being added, they need their own config setting.

I replaced short month name instead of number.  It's not difficult.

However, I think adding new config settings should be discussed in a new topic because we should prepare so many options.
I consdered what option we might pepare.
  • show month or not (show_month=0, 1)
  • which format to use (Japan style, US style, German style)
  • use number, long name or short name
So, we should prepare 2 + 3*3 = 11 options.
I want to listen to other opinions.
« Last Edit: January 15, 2018, 06:01:03 AM by HyperSim »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9099
  • Languages: De,EN,JP
Re: Sort Vehicles in Depot Window
« Reply #80 on: January 16, 2018, 03:26:56 AM »
Online game info window uses a simpler hack for short dates with "/" only. Maybe we should rather get a rountine from translator.

tranlator::get_short_date( year, month );

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #81 on: January 17, 2018, 02:30:37 PM »
Online game info window uses a simpler hack for short dates with "/" only. Maybe we should rather get a rountine from translator.

tranlator::get_short_date( year, month );

That sounds nice. I think this routine enables displaying "2000年1月" style. (In english, there are no "年" in date.)

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #82 on: January 28, 2018, 06:39:53 PM »
I'm struggling to implement "get_short_date" these days.
I wrote this code below, but the translator does not work well.  (See the picture attached)
The text should be "XXXX年XX月 - XXXX年XX月" but it is "À - À".
I don't know what is wrong.  Please help me.

Code: [Select]
const char *translator::get_short_month_name(uint16 month)
{
static const char *const short_month_names[] = {
"Jan.",
"Feb.",
"Mar.",
"Apr.",
"May",
"June",
"July",
"Aug.",
"Sept.",
"Oct.",
"Nov.",
"Dec."
};
return translate(short_month_names[month % lengthof(short_month_names)]);
}

const char *translator::get_short_date(uint16 year, uint16 month)
{
cbuffer_t buf;
char const* const month_ = get_short_month_name(month);
switch (env_t::show_month) {
case env_t::DATE_FMT_JAPANESE:
case env_t::DATE_FMT_JAPANESE_NO_SEASON:
buf.printf(translate("%4d/%s"), year, month_ );
break;
case env_t::DATE_FMT_GERMAN:
case env_t::DATE_FMT_GERMAN_NO_SEASON:
case env_t::DATE_FMT_US:
case env_t::DATE_FMT_US_NO_SEASON:
default:
buf.printf( "%s %04d", month_, year);
break;
}
return buf.get_str();
}

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9099
  • Languages: De,EN,JP
Re: Sort Vehicles in Depot Window
« Reply #83 on: January 29, 2018, 01:28:27 PM »
The buffer is no longer valid after return. You can return either a cstring or use a static cbuffer_t. The proper way would be probably the cstring.

And I would not enforce the space. Just %s%04d%s or for japanese order %04d%s%s with inputs short months, year, year symbol (if there) respective months last for japanese (and other CJK languages). That way the translator can favour Jan/2014 or 1/2014 or 1.1.2017 or whatever by just supplying different translations for the short month string.

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #84 on: February 05, 2018, 07:44:32 AM »
Here's new version of this patch.
There would be some modifies but I think you will be satisfied.

New features (see the picture attached)
  • Add "YEAR_SYMBOL" and "DAY_SYMBOL" to show "年(year)" and "日(day)" in Japanese style date (or the other language).
  • Depot window, vehicle info window, timebar(left-down side) and server info window are changed.

.diff file for r8374 is in attachment.
I attach a translation file of Japanese for this patch.
We had to add these words to each translation file...

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #85 on: February 22, 2018, 05:30:18 PM »
Hello, everyone.
I fixed some bugs and I completed this patch.
New features
-If there's no "YEAR_SYMBOL" or "DAY_SYMBOL" translation in translate file, the program automatically omit these symbol string.
 (So, you don't have to add "YEAR_SYMBOL" and "DAY_SYMBOL" in translation file.)

.diff file for r8374 is in attachment.
I want to listen to other's opinion.
Any questions and ideas to improve this patch are welcome!

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #86 on: March 22, 2018, 07:48:43 AM »
A month have passed since last post.
Is there no opinions?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9099
  • Languages: De,EN,JP
Re: Sort Vehicles in Depot Window
« Reply #87 on: March 23, 2018, 12:55:34 PM »
This in next or nextnext on my todo list of thigns to include before a release. Please be patient.

TO elaborate more: My new laptop at home in unable to produce a working binary that cn save or load files with MSVC 2012, 2015 or 2017, despite using the same (verbatim) folder of the old laptop. I suspect a problem with the brand new atom processor there. I redownloaded/reinstalled everything many times, to no avail. Hence most development and testing is done on an ancient eeePC, which is rellly slow. The desktop development computer needs a free desktop, a monitor, and a 100V capable power supply, which are also on my todo list. (I moved three times in the last year).

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #88 on: March 23, 2018, 03:08:15 PM »
This in next or nextnext on my todo list of thigns to include before a release. Please be patient.

TO elaborate more: My new laptop at home in unable to produce a working binary that cn save or load files with MSVC 2012, 2015 or 2017, despite using the same (verbatim) folder of the old laptop. I suspect a problem with the brand new atom processor there. I redownloaded/reinstalled everything many times, to no avail. Hence most development and testing is done on an ancient eeePC, which is rellly slow. The desktop development computer needs a free desktop, a monitor, and a 100V capable power supply, which are also on my todo list. (I moved three times in the last year).

Oh, that's too bad.
I didn't mean to rush you.
I'm patiently waiting for the progress.

Offline HyperSim

  • *
  • Posts: 90
  • Languages: EN, JP
Re: Sort Vehicles in Depot Window
« Reply #89 on: June 30, 2018, 01:35:49 AM »
The algorithmic program should be improved because current version of this patch may make the game slow and I update this patch now.

My friend reported that sorting vehicles makes simutrans too slow.
He plays simutrans with so many addons and when he push a button on depot window, the game freeze for a few seconds.
I cannot reproduce this phenomenon, but I understood this code is not good because whenever a button is pressed, the program start sorting.

The list of vehicles are now stored with pre-sorted in all kinds of keys.
Please check it.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5169
  • Languages: EN, NO
Re: Sort Vehicles in Depot Window
« Reply #90 on: June 30, 2018, 08:09:19 AM »
Apart from perhaps sorting by name, there would have to be thousands or millions of vehicles for sorting to take seconds.