The International Simutrans Forum

 

Author Topic: Invert Platform  (Read 2719 times)

0 Members and 1 Guest are viewing this topic.

Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Invert Platform
« on: February 21, 2018, 05:03:43 AM »
Hello, everyone.
I made a simple patch.
You can build platform on the other direction when you press shift key.
You can see video from this tweet and how does it work.
https://twitter.com/HyperSimu/status/966169948417486848

This patch will help you to build Bus Teminal or Station like the image attached.

.diff file is in attachment.
I hope you will like it.

Offline Leartin

  • Devotee
  • *
  • Posts: 1017
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Invert Platform
« Reply #1 on: February 21, 2018, 06:19:40 AM »
It's certainly useful to create some constellation not/hardly possible otherwise.
Though it bugs me that most of the time, there is no indication on which side the platform would be, so you don't easily know when to switch it, either.

Wouldn't it be a smarter implementation if there was a seperate turning tool you could use on platforms (and perhaps other buildings) that are already buildt? Would perhaps be more flexible, and get rid of the shift-key.


Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Re: Invert Platform
« Reply #2 on: February 21, 2018, 03:11:40 PM »
It's certainly useful to create some constellation not/hardly possible otherwise.
Though it bugs me that most of the time, there is no indication on which side the platform would be, so you don't easily know when to switch it, either.

Wouldn't it be a smarter implementation if there was a seperate turning tool you could use on platforms (and perhaps other buildings) that are already buildt? Would perhaps be more flexible, and get rid of the shift-key.

It sounds a good idea but there're some concerns.
How to call this tool?  Using some short cut or adding menu?
I think we have to make special cursor for that tool.
And doing two steps (build platform -> using turning tool) is not convenient.

However, I noticed a problem with this patch.
Building platform while pressing shift key will make strange layout station like the picture.
I want to listen to other's opinions.

Offline gauthier

  • Devotee
  • *
  • Posts: 3576
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: Invert Platform
« Reply #3 on: February 21, 2018, 05:10:18 PM »
Regarding how player should know what orientation will be built: I think the best way would be to display a transparent "shadow" station on the tile the cursor is on showing how it will be. Having shift pressed would shift the shadow.

Offline Leartin

  • Devotee
  • *
  • Posts: 1017
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Invert Platform
« Reply #4 on: February 21, 2018, 08:14:18 PM »
How to call this tool?
"Rotate Station" or "Rotate Building", depending on how expansive the functionality is. Though it doesn't really matter, since the name would be decided by translation files anyway.
Quote
Using some short cut or adding menu?
It would be "general_tool[?]", don't know which number we are at. From there, the menuconf of each pakset can configure a menu button and shortcuts for the tool.
Quote
I think we have to make special cursor for that tool.
General tools tend to have their own cursors, and icons for menus, yes. Don't you worry about that, I can provide them.
Quote
And doing two steps (build platform -> using turning tool) is not convenient.
No, it isn't. But as long as there is no preview, I feel like you will build half your station tiles twice anyway, since you don't really know whether to build them with or without shift. With your implementation, you would place it, and if it doesn't fit, shift-place it again. If you had a rotation tool, you might just build all the station tiles first and rotate them afterwards as needed. It's a different approach I guess.

Some more things to think about:
The bug you discovered with your approach will hardly be solvable as long as dragging the mouse already builds the stations like sucessive mouse clicks. Players will assume that, if click and drag builds one type of stations, shift-click and drag will build all the other types of stations. Which simply isn't true, since every station buildt during the drag influences the next. Even if you fix it with a workaround, if a player builds two tiles with shift pressed and they are the same, building over the same two tiles with shift pressed again would rotate them, since them existing means they are now the "proper" rotation.

A benefit of using a seperate rotation tool, besides potentially rotating other (square) buildings, would be that more 'rotations' could be possible. (I think we talked about having platforms on both sides of the track in the same object as one-sided station once before, this could be a way to access them. A bit hidden, but then not as much as a shift-functionality, and only for cosmetics anyways)

Though if your patch works, these ideas are not mutually exclusive - having a "rotate" tool in addition to a shift functionality could combine best of two worlds, quicker access with the shift-shortcut and touch-friendly additional tool.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9127
  • Languages: De,EN,JP
Re: Invert Platform
« Reply #5 on: February 22, 2018, 07:23:08 AM »
I think in the long run a transparent preview is much better than a static cursor. UIs have progressed since 1997 a bit indeed. However, a rotation tool could also be used to rotate factories and other buildings (as long as they are symmetric without holes), so it makes sense to have a dedicated tool for it.

Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Re: Invert Platform
« Reply #6 on: February 22, 2018, 05:42:33 PM »
I'm going to implement "Rotate platform tool" and improve shift-pressing construction.
Thank you for your opinions.

Regarding how player should know what orientation will be built: I think the best way would be to display a transparent "shadow" station on the tile the cursor is on showing how it will be. Having shift pressed would shift the shadow.
I think it is easy for players to understand, but I'm afraid that this will make simutrans much heavier.
Unforturnary, I don't know how to estimate it.
I think it should be done by the other's hand.

A benefit of using a seperate rotation tool, besides potentially rotating other (square) buildings, would be that more 'rotations' could be possible. (I think we talked about having platforms on both sides of the track in the same object as one-sided station once before, this could be a way to access them. A bit hidden, but then not as much as a shift-functionality, and only for cosmetics anyways)
It sounds interesting to me, but I think that is a little complicated.
I will implement it after basic feature are fully implemented.

Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Re: Invert Platform
« Reply #7 on: February 28, 2018, 09:53:15 AM »
I made "Rotate Platform Tool" that roughly works.
See this video and how it works.
(First, build station with shift key pressed, next demonstration of "Rotate Platform Tool")
https://twitter.com/HyperSimu/status/968776016708562944

However, there's a bug.
When I use this tool to a platform whose dim is under 16 (so, it is not oriented station), the platform disappears.
(You can see this phenomenon at the end of the video I showed.)

Here's my github repository and .diff file is in attachment.
Would you tell me what is wrong with this code?
https://github.com/HyperSimu/simutrans/tree/ReversePlatform

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9127
  • Languages: De,EN,JP
Re: Invert Platform
« Reply #8 on: March 01, 2018, 02:41:20 AM »
Of cause it diappears 0^=8 give either, but for something smaller than 16 there are at most 7 graphics. This only works with tables, and should be rather a general tool (rotate building) and handle also larger buildings. Since some rations may have anymations, I one has to explicitely set a new tile after roation. (But of that I am not so sure right now.)

Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Re: Invert Platform
« Reply #9 on: March 02, 2018, 05:38:32 PM »
I changed the code and works well.
Code: [Select]
if(  bd && bd->get_halt().is_bound()  ) {
const gebaeude_t* gb = bd->find<gebaeude_t>();
if(gb  &&  gb->get_tile()->get_desc()->get_all_layouts()>4  &&  (gb->get_tile()->get_desc()->get_type()>building_desc_t::dock  ||  gb->get_tile()->get_desc()->get_type()>building_desc_t::flat_dock)  ) {
layout = gb->get_tile()->get_layout();
if(  gb->get_tile()->get_desc()->get_all_layouts() == 16  ) {
layout ^= 8;
}
hausbauer_t::build_station_extension_depot(halt->get_owner(), bd->get_pos(), layout, gb->get_tile()->get_desc(), &halt);
}
delete gb;
}

But I can't understand why previous code doesn't work well.
I thought that "build_station_extention_depot" is not called if the dim of platform is less than 16.
Could you tell me what function deleted the platform?

I will implement other building rotation after platform rotation are successfully impletemted.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9127
  • Languages: De,EN,JP
Re: Invert Platform
« Reply #10 on: March 03, 2018, 02:07:32 PM »
For non-directional buildings I would just use the rotate90 function, and for directional ones or aszmmetric ones (w!=h) calling twice to rotate180. That will take care of any layouts without even bothering on layouts.

Offline Leartin

  • Devotee
  • *
  • Posts: 1017
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Invert Platform
« Reply #11 on: March 03, 2018, 06:19:05 PM »
For non-directional buildings I would just use the rotate90 function, and for directional ones or aszmmetric ones (w!=h) calling twice to rotate180. That will take care of any layouts without even bothering on layouts.
Multitile buildings in Simutrans can have shapes other then rectangles. An L-Shape, where the top right corner is occupied by a different building, should not rotate to an ˥-shape.
So either you check a building for whether all it's tiles are actually occupied by the building (making any non-rectangular shapes, even if they have rotational symmetry, non-rotatable) or you check the perimeter of the building (it's rectangular outline) for other objects, and only rotate if there are none.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9127
  • Languages: De,EN,JP
Re: Invert Platform
« Reply #12 on: March 09, 2018, 02:22:54 AM »
The rotate function does this. If such a thing exists the world rotation fails too.

Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Re: Invert Platform
« Reply #13 on: May 06, 2018, 02:27:30 AM »
I almost completed implementing rotate-building function.
You can rotate platforms, station buildings, city buildings, monuments, and factories.
You can only rotate square shaped buildings. (2x2, 3x3...)
I'm now considering about the cost and I want to discuss about it.

Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Re: Invert Platform
« Reply #14 on: May 18, 2018, 01:59:44 PM »
Hello, everyone.
Here's a beta version of this patch.
You can see how it works in this video.

Well, reversing platform or rotating building except station building is not difficult.
But rotating station building need some complemented steps and I cannot solve the problem so I need some help.

Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Re: Invert Platform
« Reply #15 on: May 18, 2018, 02:05:35 PM »
Sorry, I attached wrong file.

Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Re: Invert Platform
« Reply #16 on: May 30, 2018, 04:36:14 AM »
Hello, everyone.  I completed this patch.
To use this tool, add this line in menuconf.tab in your pak folder first.
Code: [Select]
general_tool[40]=,11,,iThen, press "i" key to call rotate-building function.
You don't have to pay for rotating buildings at all. (This might be a arguing point.)
Thank you.

Offline Vladki cz

  • Devotee
  • *
  • Posts: 2300
    • My addons, mostly roadsigns
  • Languages: EN, CS
Re: Invert Platform
« Reply #17 on: May 31, 2018, 05:33:02 PM »
Really nice I have to try it out.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9127
  • Languages: De,EN,JP
Re: Invert Platform
« Reply #18 on: June 02, 2018, 02:34:13 PM »
The patch had several problems, like factories lossing the factory properties. In r8481 there is mz version, which directly manipulates the tiles. This also prevents from showing the construction sites graphics.

Offline HyperSim

  • *
  • Posts: 95
  • Languages: EN, JP
Re: Invert Platform
« Reply #19 on: June 16, 2018, 02:56:35 PM »
I found a bug related to this patch.
When I rotate city buildings, the coordinates of the building are changed and it will cause crash after a while. (not at once)
So, we have to stop using "rotate90" and use same code as multi tile building.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9127
  • Languages: De,EN,JP
Re: Invert Platform
« Reply #20 on: June 20, 2018, 12:35:12 PM »
SHould be fixed in latest nightles