News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Zoom in the position of the cursor

Started by Yona-TYT, December 05, 2013, 02:21:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT




I would like to make map management a little nicer ie by placing the cursor on a specific quadrant always will maintain that position as we get closer....  The same effect is seen in google maps


Markohs

Wasn't this requested some time ago? I think it's easy to implement

Yona-TYT


Markohs

mmm... didn't find any topic regading this.

Some questions arise, what happens if the mouse is not over the map (it's outside the map), or is over a window? We don't zoom?

Fabio

I think zoom should be context sensitive. If you zoom on map, zoom the map. If you zoom on minimap, zoom the minimap. If you zoom on a dialogue or outside a zoom able element, don't zoom at all.


Sent from my iPhone using Tapatalk

Yona-TYT


Quote from: Fabio on December 05, 2013, 05:53:24 PM
I think zoom should be context sensitive. If you zoom on map, zoom the map. If you zoom on minimap, zoom the minimap. If you zoom on a dialogue or outside a zoom able element, don't zoom at all.




Sent from my iPhone using Tapatalk
That sounds good :thumbsup:

Markohs

mmm.... Let's see, I think this is a easy one, I'll se what can I do. :)

But btw, Yona, I don't like reading you we ignore your requests. Have in mind we all code in our free time, and do our best. Your last request I can remember was semi-rejected for some solid reasoning. You can always code it yourself. ;)

But well, I thik I can implement this one, wait a bit.



Markohs

This was not a hard change. I don't know if the whole community will prefer this behaviour over the old one, I think this one is better, but who knows.

So, I post the patch here and a binary, and if no one is against this change I'll submit the change, feel free to have your say.

Patch:

https://dl.dropboxusercontent.com/u/30024783/zoom_on_cursor.patch

Binary (remember to update your themes directory, last simutrans versions require a new one, this one), you also might need http://www.microsoft.com/en-us/download/details.aspx?id=30679

https://dl.dropboxusercontent.com/u/30024783/simutrans-zomm_to_cursor.exe


Fabio

Could you make this behavior default but unselectable via simuconf and/or display options (like inverted scrolling)?


Sent from my iPhone using Tapatalk

Markohs

Yes I can,  but only if someone really wants the old behavior, no reason to keep code that no one uses in the game. ;)

Dwachs

Tbh, I do not like this behavior. Imho the cursor should be on the same tile after zoom than before. With the patch if you zoom in and then out again without moving the cursor will move the center of the screen, which seems counter-intuitive.
Parsley, sage, rosemary, and maggikraut.

Markohs

what about warping the mouse to the center after the zoom in then. It's that or I just allow the old way of zooming, making it customizable from the menu. What do you think?

Anyway I understand what you say, you just need to get used I think, this new feature allows you as a player to decide where exactly to zoom in, I think it's better, once you get used to it.

captain crunch

I agree with
Quote from: Dwachs on December 07, 2013, 03:54:03 PM
Tbh, I do not like this behavior. Imho the cursor should be on the same tile after zoom than before.
and want to add that the client should not change behaviour if this patch is included, but make the new behaviour optional.

Markohs

Seems the implementation it's not very popular, does anybody actually like this new zoom? :)

Ters

Isn't keeping the cursor on the same tile what the request was about? That's how I understood it.

Markohs

mmm... well, the request asked to zoom to the cursor, didn't asked to move the mouse to the center of screen afterwards.

But you got a point, it's the next step, maybe that will be very convenient, I'll get my hands on it.

Yona-TYT


Es-> Centrar y al mismo tiempo mantener el cursor en un cuadrante fijo sería más agradable, ¿no cree usted Markohs? ;)

En-> Centering while keeping the cursor in a fixed quadrant would be more nice, do not you think you Markohs? ;)

Markohs

#19
Yes, adding that. Let's see. :)

EDIT: Done.

Well, I accidentally overwrited the previous patch, new binary:

https://dl.dropboxusercontent.com/u/30024783/simutrans-zoom-to-cursor-2.exe

And the patch:

https://dl.dropboxusercontent.com/u/30024783/zoom_on_cursor.patch

Try this again, please.

EDIT2: I see there is a slight error on mouse coords, it doesn't move eaxtly to the desred spot, just close. But that's the idea(I'll fix the bug, it's related to tool offsets, I think), do you like it more this way?

Dwachs

Quote from: Ters on December 07, 2013, 05:06:57 PM
Isn't keeping the cursor on the same tile what the request was about? That's how I understood it.
This is what I expected to see, too. Such that the cursor position does not change and after zooming also the same tile is marked as before. (try this in google maps) This would require to change the world view offset.

Pseudocode:

delta = cursor_pos - viewport->world_position
// zoom
...
// rescale delta to center
delta = (delta * new_rasterwidth) / old_rasterwidth
view_port->set_world_position( cursor_pos - delta)

will try this tomorrow.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

It looks good, but the cursor moves a little :thumbsup:

Dwachs

Parsley, sage, rosemary, and maggikraut.


Markohs

Continuous zoom-in/zoom-out still shows a tendency to move the view sightly, but behaves way better than my solution, I like it.

Let's make this the new zoom? Removing the old one completely, imho.

I'm having a look to viewport_t::calc_offsets. I'd choose a more descriptive name, and try to re-use code from the rest of the class. Having it a look if you don't mind.

Markohs


Ters

Quote from: Markohs on December 08, 2013, 05:27:42 PM
Let's make this the new zoom? Removing the old one completely, imho.

I assume one gets (at least an approximation of) the old behaviour if one zooms with the cursor in the center. Also, if this is Google Maps emulation, zooming with the zoom buttons would still be independent of cursor position.


Markohs

Well, too much transformations on your code for me to follow them, I have the intuition we could re-use more code from the class but we'd need to add new functions, so it's not really worth it I think.

I changed the function name to another polymorphic version of change_world_position, I think it makes much more sense this way, since it just moves the camera, but with extra restrictions.

This is ready for inclussion, imho. :)

https://dl.dropboxusercontent.com/u/30024783/zoom_on_cursor-2.patch

It's pretty cool we managed to implement this without touching simworld.cc/h , makes me feel the rearrangement I made months ago was worth something. :)

Yona-TYT


Es-> Hay un error al hacer zoom en los mapas grandes
Genere un mapa de 896x1536 y pruebe a ver


En-> There is an error when zooming on large maps
Generate a map 896x1536 and try to see

An_dz

Wow, really good. This can surely replace the old code. And look that I was not in the supporting side when requested.

Yona-TYT




Quote from: Yona-TYT on December 08, 2013, 06:36:10 PM
Es-> Hay un error al hacer zoom en los mapas grandes
Genere un mapa de 896x1536 y pruebe a ver


En-> There is an error when zooming on large maps
Generate a map 896x1536 and try to see






Markohs

#32
can't see your SS, yona, but I've been able to reproduce the bug.

Precision in 16 bit integers is overflowing, fixing it.

EDIT: Fixed, if someone detects new bugs, just tell us:

https://dl.dropboxusercontent.com/u/30024783/zoom_on_cursor-3.patch
https://dl.dropboxusercontent.com/u/30024783/simutrans-zoom-to-cursor-3.exe

Yona-TYT

#33

QuoteGenerate a map 896x1536 and try to see
This is another error I guess


"I hope the picture look this time" :police: 

Markohs

If you give more details on how to reproduce that it would be more helpful :)

savegame and coordinates on the screen where are you zooming?