News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

Sort Vehicles in Depot Window

Started by HyperSim, October 15, 2017, 05:14:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HyperSim

Quote from: prissi on January 09, 2018, 07:05:40 AM
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.
Quote from: HyperSim on December 12, 2017, 02:19:40 AM
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...

prissi

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.

HyperSim

Quote from: prissi 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.

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.

prissi

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.

HyperSim

Quote from: prissi 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.

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

Leartin

Quote from: prissi 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.

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"

HyperSim

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.
# 5>=show no season but everything else in japan format=5, us format=5, german=6
This should be
# 5>=show no season but everything else in japan format=5, us format=6, german=7

HyperSim

Sorry, I found some mistakes in .diff file.

TurfIt

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.

HyperSim

#79
Quote from: TurfIt 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.

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.

prissi

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

HyperSim

Quote from: prissi 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 );

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

HyperSim

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.


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();
}

prissi

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.

HyperSim

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

HyperSim

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!

HyperSim

A month have passed since last post.
Is there no opinions?

prissi

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

HyperSim

Quote from: prissi 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).

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

HyperSim

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.

Ters

Apart from perhaps sorting by name, there would have to be thousands or millions of vehicles for sorting to take seconds.

prissi