The International Simutrans Forum

 

Author Topic: Zoom in the position of the cursor  (Read 11164 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Zoom in the position of the cursor
« 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

« Last Edit: December 19, 2013, 06:39:15 PM by Yona-TYT »

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #1 on: December 05, 2013, 02:50:36 PM »
Wasn't this requested some time ago? I think it's easy to implement

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoon in the position of the cursor
« Reply #2 on: December 05, 2013, 03:15:01 PM »
Never came to a consensus I guess :-[

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #3 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?

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Zoon in the position of the cursor
« Reply #4 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

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoon in the position of the cursor
« Reply #5 on: December 05, 2013, 06:24:28 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:

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #6 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoon in the position of the cursor
« Reply #7 on: December 05, 2013, 06:36:09 PM »
I really appreciate your time ;)

Offline IgorEliezer br

  • Devotee
  • Administrator
  • *
  • Posts: 4085
  • Cake recipes are cool... REALLY!
    • Igor Eliezer Architect and Urban Planner/Arquiteto e Urbanista
  • Languages: PT, EN, AutoLISP, Python
Re: Zoon in the position of the cursor
« Reply #8 on: December 06, 2013, 12:30:22 AM »
I really appreciate your time ;)
I really appreciate your patience. ;o)

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #9 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), 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


Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Zoon in the position of the cursor
« Reply #10 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

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #11 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. ;)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4587
  • Languages: EN, DE, AT
Re: Zoon in the position of the cursor
« Reply #12 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.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #13 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.

Offline captain crunch

  • *
  • Posts: 114
Re: Zoon in the position of the cursor
« Reply #14 on: December 07, 2013, 04:31:58 PM »
I agree with
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.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #15 on: December 07, 2013, 04:53:59 PM »
Seems the implementation it's not very popular, does anybody actually like this new zoom? :)

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5523
  • Languages: EN, NO
Re: Zoon in the position of the cursor
« Reply #16 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.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #17 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoon in the position of the cursor
« Reply #18 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? ;)

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #19 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

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?
« Last Edit: December 07, 2013, 06:07:55 PM by Markohs »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4587
  • Languages: EN, DE, AT
Re: Zoon in the position of the cursor
« Reply #20 on: December 07, 2013, 07:10:55 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:
Code: [Select]
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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoon in the position of the cursor
« Reply #21 on: December 07, 2013, 08:09:58 PM »
It looks good, but the cursor moves a little :thumbsup:

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4587
  • Languages: EN, DE, AT
Re: Zoon in the position of the cursor
« Reply #22 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

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoon in the position of the cursor
« Reply #23 on: December 08, 2013, 05:07:15 PM »

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #24 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.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #25 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

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5523
  • Languages: EN, NO
Re: Zoon in the position of the cursor
« Reply #26 on: December 08, 2013, 05:41:30 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoon in the position of the cursor
« Reply #27 on: December 08, 2013, 05:43:57 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

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoon in the position of the cursor
« Reply #28 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

 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. :)

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoom in the position of the cursor
« Reply #29 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

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2891
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Zoom in the position of the cursor
« Reply #30 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoom in the position of the cursor
« Reply #31 on: December 08, 2013, 07:42:43 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






Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoom in the position of the cursor
« Reply #32 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
« Last Edit: December 08, 2013, 10:23:13 PM by Markohs »

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoom in the position of the cursor
« Reply #33 on: December 08, 2013, 11:43:48 PM »

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


"I hope the picture look this time" :police: 
« Last Edit: January 02, 2014, 01:40:20 PM by Yona-TYT »

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoom in the position of the cursor
« Reply #34 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?

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoom in the position of the cursor
« Reply #35 on: December 09, 2013, 12:27:04 AM »
I suspect the problem is only present here

Anyways the coordinates are 380,1520

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoom in the position of the cursor
« Reply #36 on: December 09, 2013, 09:43:20 AM »

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoom in the position of the cursor
« Reply #37 on: December 09, 2013, 02:41:10 PM »
Thanks Markohs works fine for me :thumbsup:

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4587
  • Languages: EN, DE, AT
Re: Zoom in the position of the cursor
« Reply #38 on: December 09, 2013, 07:06:56 PM »
this is now in r6973. Thank you :)

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoom in the position of the cursor
« Reply #39 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. ;)

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1193
    • Simutrans-BLOG
  • Languages: ES
Re: Zoom in the position of the cursor
« Reply #40 on: December 09, 2013, 07:37:10 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

Offline IgorEliezer br

  • Devotee
  • Administrator
  • *
  • Posts: 4085
  • Cake recipes are cool... REALLY!
    • Igor Eliezer Architect and Urban Planner/Arquiteto e Urbanista
  • Languages: PT, EN, AutoLISP, Python
Re: Zoom in the position of the cursor
« Reply #41 on: December 09, 2013, 07:47:34 PM »
EN - 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.

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotees (Inactive)
  • *
  • Posts: 1559
  • Languages: EN,ES,CAT
Re: Zoom in the position of the cursor
« Reply #42 on: December 09, 2013, 07:53:03 PM »
hehe cool