The International Simutrans Forum

Development => Extension Requests => Topic started by: Yona-TYT on December 05, 2013, 02:21:33 PM

Title: Zoom in the position of the cursor
Post by: Yona-TYT on December 05, 2013, 02:21:33 PM



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 (https://maps.google.com/maps?)

Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 05, 2013, 02:50:36 PM
Wasn't this requested some time ago? I think it's easy to implement
Title: Re: Zoon in the position of the cursor
Post by: Yona-TYT on December 05, 2013, 03:15:01 PM
Never came to a consensus I guess :-[
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 05, 2013, 03:54:49 PM
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?
Title: Re: Zoon in the position of the cursor
Post by: 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 (http://tapatalk.com/m?id=1)
Title: Re: Zoon in the position of the cursor
Post by: Yona-TYT on December 05, 2013, 06:24:28 PM

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 (http://tapatalk.com/m?id=1)
That sounds good :thumbsup:
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 05, 2013, 06:27:52 PM
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.
Title: Re: Zoon in the position of the cursor
Post by: Yona-TYT on December 05, 2013, 06:36:09 PM
I really appreciate your time ;)
Title: Re: Zoon in the position of the cursor
Post by: IgorEliezer on December 06, 2013, 12:30:22 AM
Quote from: Yona-TYT on December 05, 2013, 06:36:09 PM
I really appreciate your time ;)
I really appreciate your patience. ;o)
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 07, 2013, 02:53:46 PM
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 (https://dl.dropboxusercontent.com/u/30024783/themes.zip)), 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

Title: Re: Zoon in the position of the cursor
Post by: Fabio on December 07, 2013, 03:01:15 PM
Could you make this behavior default but unselectable via simuconf and/or display options (like inverted scrolling)?


Sent from my iPhone using Tapatalk (http://tapatalk.com/m?id=1)
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 07, 2013, 03:10:01 PM
Yes I can,  but only if someone really wants the old behavior, no reason to keep code that no one uses in the game. ;)
Title: Re: Zoon in the position of the cursor
Post by: 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. 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.
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 07, 2013, 03:59:19 PM
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.
Title: Re: Zoon in the position of the cursor
Post by: captain crunch on December 07, 2013, 04:31:58 PM
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.
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 07, 2013, 04:53:59 PM
Seems the implementation it's not very popular, does anybody actually like this new zoom? :)
Title: Re: Zoon in the position of the cursor
Post by: 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.
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 07, 2013, 05:45:29 PM
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.
Title: Re: Zoon in the position of the cursor
Post by: Yona-TYT on December 07, 2013, 05:50:10 PM

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? ;)
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 07, 2013, 05:58:06 PM
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 (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 (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?
Title: Re: Zoon in the position of the cursor
Post by: Dwachs on December 07, 2013, 07:10:55 PM
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.
Title: Re: Zoon in the position of the cursor
Post by: Yona-TYT on December 07, 2013, 08:09:58 PM
It looks good, but the cursor moves a little :thumbsup:
Title: Re: Zoon in the position of the cursor
Post by: Dwachs on December 08, 2013, 04:33:34 PM
Here is my approach to the matter. Please test.

http://simutrans-germany.com/files/upload/simgdi-zoomtocursor.zip
Title: Re: Zoon in the position of the cursor
Post by: Yona-TYT on December 08, 2013, 05:07:15 PM

Quote from: Dwachs on December 08, 2013, 04:33:34 PM
Here is my approach to the matter. Please test.


http://simutrans-germany.com/files/upload/simgdi-zoomtocursor.zip (http://simutrans-germany.com/files/upload/simgdi-zoomtocursor.zip)
Does not start ???
(http://img440.imageshack.us/img440/6803/whcf.png)
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 08, 2013, 05:27:42 PM
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.
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 08, 2013, 05:28:40 PM
Try this one Yona

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

And update the themes directory
Title: Re: Zoon in the position of the cursor
Post by: Ters on December 08, 2013, 05:41:30 PM
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.
Title: Re: Zoon in the position of the cursor
Post by: Yona-TYT on December 08, 2013, 05:43:57 PM
Quote from: Markohs on December 08, 2013, 05:28:40 PM
Try this one Yona

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

And update the themes directory

Very nice, similar to google maps...jejeje
Title: Re: Zoon in the position of the cursor
Post by: Markohs on December 08, 2013, 06:13:45 PM
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 (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. :)
Title: Re: Zoom in the position of the cursor
Post by: 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
Title: Re: Zoom in the position of the cursor
Post by: An_dz on December 08, 2013, 06:55:24 PM
Wow, really good. This can surely replace the old code. And look that I was not in the supporting side when requested.
Title: Re: Zoom in the position of the cursor
Post by: Yona-TYT on December 08, 2013, 07:42:43 PM



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



(https://www.facebook.com/download/569114853176775/yiov.gif)

Title: Re: Zoom in the position of the cursor
Post by: Markohs on December 08, 2013, 10:15:39 PM
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
Title: Re: Zoom in the position of the cursor
Post by: Yona-TYT on December 08, 2013, 11:43:48 PM

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

(https://www.mediafire.com/convkey/9de5/6s4x7642aea9bl46g.jpg)
"I hope the picture look this time" :police: 
Title: Re: Zoom in the position of the cursor
Post by: Markohs on December 09, 2013, 12:02:52 AM
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?
Title: Re: Zoom in the position of the cursor
Post by: Yona-TYT on December 09, 2013, 12:27:04 AM
I suspect the problem is only present here

Anyways the coordinates are 380,1520
Title: Re: Zoom in the position of the cursor
Post by: Markohs on December 09, 2013, 09:43:20 AM
I linked the wrong binary, try this one:

https://dl.dropboxusercontent.com/u/30024783/simutrans-zoom-to-cursor-4.exe
Title: Re: Zoom in the position of the cursor
Post by: Yona-TYT on December 09, 2013, 02:41:10 PM
Thanks Markohs works fine for me :thumbsup:
Title: Re: Zoom in the position of the cursor
Post by: Dwachs on December 09, 2013, 07:06:56 PM
this is now in r6973. Thank you :)
Title: Re: Zoom in the position of the cursor
Post by: Markohs on December 09, 2013, 07:12:13 PM
Thx Dwachs!!!!

EN - Next time you say we ignore you, Yona, I'll hit you with a dirty sock in your face. ;)
ES - Como te vuelva a oir decir que te ignoramos, te voy a dar con un calcetín sucio en la cara, Yona. ;)
Title: Re: Zoom in the position of the cursor
Post by: Yona-TYT on December 09, 2013, 07:37:10 PM
Quote from: Markohs on December 09, 2013, 07:12:13 PM
Thx Dwachs!!!!


EN - Next time you say we ignore you, Yona, I'll hit you with a dirty sock in your face. ;)
ES - Como te vuelva a oir decir que te ignoramos, te voy a dar con un calcetín sucio en la cara, Yona. ;)


:o :o :o ...jejejeje
Title: Re: Zoom in the position of the cursor
Post by: IgorEliezer on December 09, 2013, 07:47:34 PM
Quote from: Markohs on December 09, 2013, 07:12:13 PMEN - Next time you say we ignore you, Yona, I'll hit you with a dirty sock in your face. ;)
I prefer a slimmy fish slap. (http://eelslap.com/)
Title: Re: Zoom in the position of the cursor
Post by: Markohs on December 09, 2013, 07:53:03 PM
hehe cool