Author Topic: Way info window  (Read 505 times)

0 Members and 1 Guest are viewing this topic.

Offline Ves

Way info window
« on: March 31, 2017, 08:52:09 PM »
Well, I could not resist but to try and make a button in the way info window that sets the viewpoint to the train which currently has reserved the track. It has succeded, so the button now exists and is workable, I have one issue though:

The button which is used to focus the view to the vehicle should appear and disappear automatically, also when the window is open. It is however not the case:
When the window is open while there is no reservation, the button will not appear even though the track gets reserved. If you close and reopen the window, you will see the button, but when the train has passed on, the button does not disappear but stays fixed in the window.

I have used is_reserved() to check wether the track is reserved or not.

How can I make the button appear and disappear automatically?

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 14971
  • Total likes: 335
  • Helpful: 148
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Way info window
« Reply #1 on: March 31, 2017, 10:16:15 PM »
I have not looked into this dialogue recently at all, so I should have to do as much detective work as you to work it out; but one guess would be that this window does not automatically update (or, if it does, your code is not called from the update for some reason).
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.

Offline Ves

Re: Way info window
« Reply #2 on: March 31, 2017, 11:30:07 PM »
Thanks, I am digging into the ::draw parts as I think this is where it is done. I have succeded in making the button disappear and reappear, but oddly enough only after some time, as if the window only gets updated at certain intervals. Have not just yet wrapped my head around it properly to understand exactly how I can get the buttons to reliably appear and disappear. Any input from anyone is most appreciated!

Anyway, here is a development picture of the way window, which I hope you would consider implement:



New information:
- A button next to the reserving vehicle name, centering the map onto the vehicle (and follows it too).
- Type of reservation. If directional reservation, then also which direction, ie heading, the track is reserved. I have also added the not yet existing reservation type "priority". When that is implemented, there maybe can be some other juicy information extractable to put in the "heading" part.
- Distance to the reserving vehicle, following the same decimal convention as the signals distance meter.

Also, I added a line of text if the track is not reserved by any vehicle.

One thing I would like to add is under which working method the track is reserved. I have not yet figured out how to convert the convoi_t (which the schiene_t gets its information from) to rail_vehicle_t, where the get_working_method() is located.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 14971
  • Total likes: 335
  • Helpful: 148
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Way info window
« Reply #3 on: April 01, 2017, 12:02:51 AM »
To answer your latter question, you need to take the front vehicle of the convoy (cnv->front()), and, only if you can be sure that it is a rail vehicle, cast it to rail_vehicle_t before calling a rail vehicle specific method on it.

As to the distance to vehicle, hopefully this does not involve any significant computational overhead?

Otherwise, looking good!
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.

Offline Ves

Re: Way info window
« Reply #4 on: April 01, 2017, 12:55:08 AM »
As to what I can see, I don't notice any difference in performance. It is exactly the same code that finds the distance between signals and their boxes, and it should only be computed when the window is open and there is a reservation. Have not tried having multiple windows open though.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 14971
  • Total likes: 335
  • Helpful: 148
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Way info window
« Reply #5 on: April 01, 2017, 10:01:21 AM »
If it is only run when the window is open, this should not be a problem.
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.

Offline fam621

Re: Way info window
« Reply #6 on: April 01, 2017, 10:11:08 AM »
Noice.

Online Vladki

Re: Way info window
« Reply #7 on: April 02, 2017, 08:42:14 PM »
Great idea Ves. I often struggle to find out which train has some forgotten reservation.




Offline Ves

Re: Way info window
« Reply #8 on: April 04, 2017, 07:25:55 PM »
Great idea Ves. I often struggle to find out which train has some forgotten reservation.
Me to, hence the idea to this patch!  :D

I cannot get my head to wrap around the ::draw section of the code. When that is included, the button does not work and the entire point with it is gone, as well as it does not update reliably.
Would you mind if I completely amend that, and the button will stay visible all the time? I think that with some practice from other parts of the code, I can revisit this at a later day to make it function correctly.

edit:

But appart from that, I think that the reservation section is finish. It currently looks like this:



What is new/changed:
* Name and button to the vehicle
* The current working method of the train
* What type of reservation, HOWEVER, only if it is not normal reservation (called "Block" reservation). Reasons for its exclusion is that it felt too obvious and also it could be misguiding. Ie, time interval has no "blocks", neither do drive by sight.
* If the reservation type is "Directional reservation", the direction in which the track is reserved is also shown.
* Distance to vehicle, along with its current speed and current direction. I included the speed to easier see if the train was operating, and its current heading to give the player an approximation from which direction it will come (as it is only the directional reservation that will show the direction of reservation otherwise). I think it should be clear the way the last three bits of information is presented?
AND, the button is visible at all times!

If you like it, you can pull from here: https://github.com/VictorErik/Simutrans-Experimental-Ves/tree/track-finds-reservationtrains
Otherwise, tell me what I can do better!  :)


I would also like to rearrange some of the information in the rest of the dialog also if you dont mind?
Additional usefull information could be:
montlhy costs
which directions it has
Maybe a text that tells you if you may use the way (because of restrictions from other player)
....
Some more suggestions?
« Last Edit: April 04, 2017, 10:34:11 PM by Ves »

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 14971
  • Total likes: 335
  • Helpful: 148
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Way info window
« Reply #9 on: April 06, 2017, 12:47:43 AM »
That is splendid - thank you. I have now incorporated this: I should be grateful for any feedback from testing.

Can you let me know when you think that the .dat file for the texts is unlikely to be altered furhter in the immediate future so that I can upload it to Simutranslator? Once you so notify me, you will need to start a new translation text file.
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.

Offline Ves

Re: Way info window
« Reply #10 on: April 21, 2017, 09:48:33 PM »
I was thinking of having these maintenance numbers visible:

Maintenance per tile
Maintenance per km

- if also containing a wayobj: -
Maintenance per km + wayobj maintenance pr km

However, that means that there will be three maintenance numbers visible if the way has ie a catenary, and that might be too excessive.
Which numbers would you guys suggest? What do you think is important?

Also, what about the visibility to other players. Do you think it matters to show the costs to other players? It might be confusing, but at the same time its informing and you can already see the vehicle income from other player I think.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 14971
  • Total likes: 335
  • Helpful: 148
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Way info window
« Reply #11 on: April 22, 2017, 12:37:21 AM »
I can see that it would be useful to show these things; and perhaps also the cost of renewing the way tile with the selected renewal way? Thank you for all your work on the UI - it is much appreciated.
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.

Offline Ves

Re: Way info window
« Reply #12 on: April 22, 2017, 12:53:28 AM »
That was a very good idea! :)


edit:
Looking into this, I have found this you have done which appears to get the price of upgrading:

Code: [Select]
const sint64 price = desc->get_upgrade_group() == replacement_way->get_upgrade_group() ? replacement_way->get_way_only_cost() : replacement_way->get_value();
However, when taking the value "price" and show it, it shows the upgrade costs for two tiles of way not one. It is easy enough to get around, I will just divide by two, however I just want to make sure that I am not making bad assumtions by doing that?

--
another edit:
Is there a good replacement word for the word "wayobject"? I want to specify that the way object is making some alterations to the way, but the word "wayobject" is bugging me. I cant call it catenaries, as it technically might not be catenaries. Also, calling it by its name is way too long. Any suggestions?
« Last Edit: April 22, 2017, 05:57:21 PM by Ves »

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 14971
  • Total likes: 335
  • Helpful: 148
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Way info window
« Reply #13 on: April 24, 2017, 08:18:31 PM »
I am a little confused in relation to the price being for upgrading two tiles of way: this exact number (that given in "price") is what is actually booked as the cost of upgrading a single tile of way. Can you elaborate on how you reach the conclusion that this refers to upgrading two tiles of way?

In relation to "wayobject", that is not an English word, but there is no clear alternative description but to use the two separate English words from which that composite was defined, "way object".
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.

Offline Ves

Re: Way info window
« Reply #14 on: April 25, 2017, 04:29:28 PM »
I have made a commit that will show what I mean here: https://github.com/VictorErik/Simutrans-Experimental-Ves/commits/track-finds-reservationtrains
However, do not incorporate it into the game yet (you should compile from the branch, if possible) as it is not in a finish state, yet all the translations are missing.

* In the code, open the weg.cc and look at line 641, there you can see that I have copied a line from another place in the code (namely, line 1264 in the same file) and divided it by 100.
* Compile the game and press on a waytile in the game. There, the costs of the upgrade are shown under the "to be renewed with" section, first the cost per tile, below, the cost per km.
* Build the oldest, badest waytype possible and specify that it should be renewed with the newest waytype (shiftdragging). The infowindow should now update with some more information. Pay attention to the upgrade cost section.
* Now, manually upgrade the piece of way with the same waytype as you specified it should upgrade to. Look at the cost of doing so. you will see that the number in the information window matches the cost for two tiles of way upgrading, not one tile. Likewise, the upgradecost per km will show how much it costs to upgrade two km.

But as I said, it is no problem for me, I can just divide the cost by two. I just wanted to point out in case something is not working as it is supposed to do.

Offline Ves

Re: Way info window
« Reply #15 on: April 27, 2017, 11:29:01 PM »
There is a problem with this patch that I have big problems with:
Try open a runway info window, it will show a text stating that the track is not reserved yet and the "go to vehicle" button will be visible underneath. When an airplane enters the runway, or try to land on it, the game crashes.
I assumed it was because it would try to locate the working method of the airplane and have therefore tried to make some "if air_wt...." to make sure that it did not search for that information, but I have failed in doing so. The game keeps crashing no matter what I do. On top of this, I simply fail to create a debug build so I could debug it myself, so I would like to ask you if it would be possible if you could take a look when you have time to somehow see if there is an easy solution to this?

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 14971
  • Total likes: 335
  • Helpful: 148
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Way info window
« Reply #16 on: Today at 12:59:24 AM »
I think that I have managed to fix this - would you be able to re-test? I should be most grateful.
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.