News:

Beta test the new forum at https://simutrans.forum/
Want to praise Simutrans?
Your feedback is important for us ;D.

obj_xxx_details

Started by Andarix, June 01, 2024, 06:28:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andarix

QuoteRevision: 11148
Autor: prissi
Datum: Donnerstag, 25. April 2024 05:34:41
Meldung:
ADD: obj_xxx_details in translation will display some more details on an obj, especially vehciles
----

@prissi

Can you please tell us which objects this applies to and which ones it doesn't?

prissi

Ask makie, but it should work on any object. Ways are handled differently as they are displayed via the ground info window.

makie

#2
Quote from: prissi on June 01, 2024, 01:59:20 PMAsk makie, but it should work on any object.
That's what I thought too.
It's in the program and it worked in my tests, but I just tried it out today.

Quote--- obj_info.cc    (Revision 10444)
+++ obj_info.cc    (Revision 11148)
@@ -24,6 +24,10 @@
 void obj_infowin_t::fill_buffer()
 {
    buf.clear();
+    if(  const char *translated_detail = translator::translate_obj_details(get_obj()->get_name())  ) {
+        buf.append( translated_detail );
+        buf.append("\n\n");
+    }
    get_obj()->info(buf);
 }
that doesn't work, I don't know why
-------------------------
what works and used in pak128.german:
way (road, rail) (not working way - power(tested))
vehicle
-------------------------------------------
it doesn't work because get_obj()->get_name() delivers:
Gebaeude, Leitung, Sehenswuerdigkeit

*grml*
gebaeude.cc -->
Quoteconst char *gebaeude_t::get_name() const
{
    if(is_factory  &&  ptr.fab) {
        return ptr.fab->get_name();
    }
    switch(tile->get_desc()->get_type()) {
                case building_desc_t::attraction_city:  return "Besonderes Gebaeude";
                case building_desc_t::attraction_land:  return "Sehenswuerdigkeit";
                case building_desc_t::monument:          return "Denkmal";
                case building_desc_t::townhall:          return "Rathaus";
                default: break;
    }
    return "Gebaeude";
I love c++  :-[

===========================================================================================
OK, the function get_name() is overloaded in "weg.h". Then the changed code in "obj_info.cc" only works for way and because ways now run differently, the code above in "obj_info.cc" is unnecessary because it doesn't work with other objects.

Sorry for this erroneous assumption
------------------------------------------
This is where the meaningless names in the window headers come from.

Andarix

Quote from: prissi on June 01, 2024, 01:59:20 PMAsk makie, but it should work on any object. ...

mmh, r11258 tree not work

Screenshot 2024-06-01 220713.png

makie

Quote from: makie on June 01, 2024, 03:28:28 PMthat doesn't work, I don't know why
-------------------------
what works and used in pak128.german:
way (road, rail) (not working way - power(tested))
vehicle
Way and vehicle work.

all other don´t work, sorry

prissi

I changed the code and it should work for most objects in r11261.

Andarix

r11264 not compile all OS

Quote2024-06-02T07:41:43.3213624Z In file included from /home/runner/work/simutrans/simutrans/src/simutrans/builder/goods_manager.cc:12:
2024-06-02T07:41:43.3233407Z /home/runner/work/simutrans/simutrans/src/simutrans/builder/../dataobj/translator.h:124:21: error: extra qualification 'translator::' on member 'get_obj_info' [-fpermissive]
2024-06-02T07:41:43.3235844Z   124 |  static const char* translator::get_obj_info(cbuffer_t &buf, const char *name);
2024-06-02T07:41:43.3236940Z       |                     ^~~~~~~~~~
2024-06-02T07:41:43.3779691Z make[2]: *** [CMakeFiles/simutrans.dir/build.make:104: CMakeFiles/simutrans.dir/src/simutrans/builder/goods_manager.cc.o] Error 1

makie

Quote from: prissi on June 02, 2024, 03:22:24 AMI changed the code and it should work for most objects in r11261.
Test with r11267
vehicle --- rail ---> work

way - road ---> work
way - rail ---> work
way - water --> work
way - air  ---> work
way - power --> now work !!!

tree        ---> work

bridge   (all) ---> not work
tunnel   (all) ---> not work
building (all) ---> not work (r11267)

crossing  --> the detail text of the road was shown
I think it was better to give crossing there own translations and details

pedestrian
these could also get translations and detailed texts

citycar ---> not work

prissi

Tunnel and bridge are intended to not get detail texts. Can be changed.
Normal buildings should work if there is a translation for the name (but they are pretty useless as the normal long text works fine for them). (No details for factories etc.)

How to enter detail-texts into the translator? I added some for pak128 as unnecessary text for a tree. But then it is not exported ...

Also the specific help files for paks need a special logic on the translator.

makie

#9
Quote from: prissi on June 02, 2024, 12:39:05 PMHow to enter detail-texts into the translator? I added some for pak128 as unnecessary text for a tree. But then it is not exported ...

no no! please no additional object!
simple here



prissi

Thank you.

Can we have the boxes a little smaller and side by side so does not have to scroll so much when checking the translations in more than one language?

Also, it would be cool if linebreaks would work in the fields, entering them as \n\n is quite cumbersome.

makie

I is possible to hide empty languages.

Regular this makes the list a lot smaller.

prissi

When I want to add new translations (or copy from some text I received), hiding would be not so helpful though ... But it is ok, my screen at work is large enough.

Leartin

The 'classic' way for descriptions is in the objects name, seperated with a newline character. What's the plan going forward? Will they still exist and work indefinitely, or will those need to be brought into the new format eventually? If the later, will the Translater provide a function to 'convert' old descs?

Even though this was only intended for vehicles at first, I suppose it makes sense to have a single system for all objects, including buildings.

prissi

It should already work for buildings but of course it is not extensively tested. Ideally, the long description goes to the details texts.

Before doing this automatically, there are lots of buildings with ONLY a long text. That is currently not handled in Stmutrans (but adding this would be easy).

I would be very much in favour to enforce a short single line name for everything and anything longer goes into the details.

makie

Quote from: Leartin on June 04, 2024, 08:16:33 AMThe 'classic' way for descriptions is in the objects name, seperated with a newline character.
The classic way don´t work for "way" in Version 123.x
Because we have texte for way in pak128.german i investigate.
https://www.simutrans-forum.de/mybb/showthread.php?tid=9534

In version 124.x the classic function for 'way' is restored.
I think it stay in future because there are old paks that has no support.

But the new detail text handled in a different kind.
--------------------
No building don´t work.
Quotebridge  (all) ---> not work
tunnel  (all) ---> not work
building (all) ---> not work (r11267)

crossing  --> the detail text of the road was shown
I think it was better to give crossing there own translations and details

pedestrian
these could also get translations and detailed texts

citycar ---> not work

Leartin

Quote from: makie on June 04, 2024, 08:37:12 AMThe classic way don´t work for "way" in Version 123.x
I know it does not work for everything, but up until now everything that had descriptions had them as part of their name, aside factories.

What I'm saying is:
A) I don't think there should be two different ways to do it (=> please make it work for buildings too)
B) Once all objects can have dedicated detail texts, the 'old' way should be deprecated*.
This is what I think Simutrans should do. But that's not all:

C) Split names with newlines into name and description.
D) Combine name and description with a newline as seperator for all objects which can deal with that.
This is what a tool outside the game needs to provide. The Translator seems ideal - the first option to "update" to the new descriptions, and the second option to still be able to download translation files for older Simutrans versions.



*I'm not saying that the classic way should be cut off artificially, but rather it should be marked for "no need to keep", so future development has one less thing to think about.



Also, a question: IIRC the factory details allowed some basic formating? Is that the case for these new detail texts, or was that abandoned?

makie

Quote from: Leartin on June 04, 2024, 02:14:45 PMAlso, a question: IIRC the factory details allowed some basic formating? Is that the case for these new detail texts, or was that abandoned?
current situation:

factory details ---> some simple html comand

all other details ---> text wraps around + new line '\n' for a new paragraph

QuoteC) Split names with newlines into name and description.
May be the translator (or i) can support this in coordination with the pak maintainer,
but not automatic over all paks because there need some manual rework.