Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Mudlet Remember mapper zoom amount between sessions. #2388

Closed
Jieiku opened this issue Mar 5, 2019 · 13 comments · Fixed by #6615
Closed

Feature Request: Mudlet Remember mapper zoom amount between sessions. #2388

Jieiku opened this issue Mar 5, 2019 · 13 comments · Fixed by #6615
Assignees
Labels
bounty-50 see https://wiki.mudlet.org/w/Bounty_Process bounty-paid This bounty has been completed & paid out good first issue

Comments

@Jieiku
Copy link
Contributor

Jieiku commented Mar 5, 2019

Brief summary of issue / Description of requested feature:

Every time I close and relaunch Mudlet I zoom my mapper out to my desired preference using the mouse wheel.

if you hover your mouse cursor over the mapper and then use your mouse wheel you can zoom the mapper out or in.

What I would really love is if Mudlet could remember my last used zoom amount between sessions.

If you wanted to get REALLY fancy, you could have it remember the zoom settings per Area. That would actually be the ultimate feature!

Because some areas you just really want different zoom settings.

@vadi2
Copy link
Member

vadi2 commented Mar 6, 2019

I foresee setting zoom per-area being a massive amount of pain since it'll reset between areas on the first time and so on. Remembering zoom between restarts would be nice, meanwhile just throwing https://wiki.mudlet.org/w/Manual:Mapper_Functions#setMapZoom into a script is a trivial workaround for it!

@SlySven
Copy link
Member

SlySven commented Mar 6, 2019

💡 Don't forget that there is Area User Data nowadays so it is possible to store per-Area data - see setAreaUserData(...) and getAreaUserData(...) !

@takilara
Copy link

takilara commented Dec 5, 2020

Old request, but ill chime in.
I agree that setMapZoom combined with setAreaUserData and getAreaUserData will help, however without a "getMapZoom" or a similar way to "get" the current zoom level, it will be somewhat arbitrarily or manually controlled. If i can detect change in the zoom level, then store it in areaUserData, then set it whenever map loads or areas changes, that would be perfect

@SlySven
Copy link
Member

SlySven commented Dec 6, 2020

The map zoom level is, unfortunately controlled in more than one way that do not communicate with each other. in the 2D map you have the (vertical) mouse wheel and the setMapZoom() which I guess can be made to work with each other. However the 3D mapper is a right dog's breakfast. You have the (vertical) mouse wheel and the "Scale" control (the left most slider) which again sort of work together - but there are three other controls that set the eye/camera-coordinate positions and those collectively {in order left to right: z, y, x!} (via a sqrt(x^2 + y^2 + z^2) i.e. Pythagorus's famous formula) also control the effective zoom as well. working out the overall effect is not currently predictable... AFAICT

@Jieiku
Copy link
Contributor Author

Jieiku commented Dec 6, 2020

hahahaha currently I only use the 2D mapper so that would work ok for me :)

@takilara
Copy link

takilara commented Dec 6, 2020

3d mapping?? i didn't even know about that :D I also just use the 2d map.
(makes a note to investigate the 3d mapper :D)

but with additional "get" methods for current zoom level (for 2d) and for positions and scale for 3d, im sure ppl would quickly make areas have persistent zoom and viewpoints :)

Might need an event for the mouse wheel if there isnt one also.

(this isnt a big deal for me though, as it only takes about 2 sec to scroll whatever area i enter to the correct scale anyways, and i could probably play around with setMapZoom to persist this, just would feel "clunky" having to set that manually, and not just persist whatever i zoomed to last time i visited that area)

@SlySven
Copy link
Member

SlySven commented Dec 9, 2020

.... just would feel "clunky" having to set that manually, and not just persist whatever i zoomed to last time i visited that area

So you would want:

  • a sysMapperAreaViewedEvent implemented as sysMapAreaChanged that would fire as the area was changed (returning the old and new area IDs) and for it to fire just before the view was switched away from the old area.
  • something to return the current view mode {2D/3D view, current centre of view coordinates, implemented 2D map (zoom only) or 3D map (zoom/scale setting and eye position coordinates)}

🤔

Probably also need Lua API means to setup all of those details as well...

@takilara
Copy link

takilara commented Dec 9, 2020

Yes to the sysMapperAreaViewedEvent and its returns.
(needed to detect the change, store old zoom for old area, grab new zoom for new area)

For getting all of the "viewmode" properties, i am not 100% sure you need to go full tilt initially. There is currently only the one "setMapZoom(zoom)" setter, meaning one could start with "getMapZoom()" getter. (meaning this would only work "properly" for 2D view mode initially.

This could of course be expanded with 3d support, area granularity, storing zoom level in the map itself, or building in persistency into the application. However this could likely wait until there is a demand?
(normally i would advocate "doing things right" at the beginning, however I don't know the size of the demand for 3d, and I foresee enabling getters for those features would logically drive a demand for setters for changing mode and viewmode properties)

(I don't know the overhead of setting up a new function in Mudlet, though i can envision that it is quite a bit (code, testing, documentation etc). As stated, this is not a critically needed feature for me. I have wanted to start taking a look at the code myself, could potentially be a motivator for me to get coding again :D) (I have to say i truly love Mudlet. It has brought joy of mudding back to me)

@vadi2
Copy link
Member

vadi2 commented Dec 9, 2020

I think at this point it would make sense for us to just build it in as a Mudlet feature, instead of making everyone re-code it themselves. We could store the map zoom per-area as an area userdata feature.

@Kebap
Copy link
Contributor

Kebap commented Feb 7, 2021

I foresee setting zoom per-area being a massive amount of pain since it'll reset between areas on the first time and so on.

If you enter a new area for the first time that does not have a zoom setting yet, start with the previous area's one.

@Kebap Kebap added the bounty-50 see https://wiki.mudlet.org/w/Bounty_Process label Feb 17, 2023
@SlySven
Copy link
Member

SlySven commented Feb 18, 2023

Is the bounty just for the 2D mapper (:relaxed:) or something that also works for the 3D one (:scream:)?

@vadi2
Copy link
Member

vadi2 commented Feb 18, 2023

We can start with 2D for now.

@SlySven SlySven self-assigned this Feb 23, 2023
SlySven added a commit to SlySven/Mudlet that referenced this issue Mar 8, 2023
This is intended to close Mudlet#2388.

This enables the 2D (only) map zoom amounts for each map area to be save
independently and restored when switching between areas in the mapper. It
also saves the data between session.

It extends the existing `setMapZoom(...)` API to take an optional second
argument to specify the map area ID to set the zoom (which is a floating
point number) for any existing area, not just the current one.

It also adds a `getMapZoom(...)` function that, without any arguments,
returns the currently used 2D map zoom value for the area currently being
shown in the 2D mapper. If an area ID is provided it instead returns the
value that was last used for that area - or the default value that is used
initially on starting the profile or for an area that has not been viewed
before.

Importantly when switching between the areas in the 2D mapper the values
are retained and applied so that one area can be zoomed in and another
zoomed out and switching from the first to the second and back to the first
means that the zoom level used in the first is reused when it is returned
to. Deleting an area will forget the stored zoom level so if it is reused
it starts from scratch.

Code to save the zoom level for each area has also been implemented within
the C++ core. It saves it in the Area User Data for current map formats
(but removes it on loading so the user never sees it there) under a
`system.fallback_XXXX` key but will save it directly in the binary data
(which is more efficient) in the next format version whenever it is
enabled.

A new Mudlet event, which has been called `mapAreaViewedChangeEvent` has
been added with two additional arguments being the area ID changed to
followed by the one that it was changed from. I originally thought I
would need it to handle saving the zoom level for each area via the Lua
system but I found that that was not practicable. I'll leave it in for
now but it could be removed if peer-review finds it not to be of use.

Also, in refactoring `T2DMap::paintEvent(...)` I:
Removed/combined some locals:
* `(TArea*) playerArea` and `(TArea*) pPlayerArea` ==> `pArea`
* `(TRoom*) playerRoom` ==> `pPlayerRoom`
Remove unneeded (refactored out):
* `(qreal) ox`
* `(qreal) oy`

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
SlySven added a commit to SlySven/Mudlet that referenced this issue Mar 8, 2023
This is intended to close Mudlet#2388.

This enables the 2D (only) map zoom amounts for each map area to be save
independently and restored when switching between areas in the mapper. It
also saves the data between session.

It extends the existing `setMapZoom(...)` API to take an optional second
argument to specify the map area ID to set the zoom (which is a floating
point number) for any existing area, not just the current one.

It also adds a `getMapZoom(...)` function that, without any arguments,
returns the currently used 2D map zoom value for the area currently being
shown in the 2D mapper. If an area ID is provided it instead returns the
value that was last used for that area - or the default value that is used
initially on starting the profile or for an area that has not been viewed
before.

Importantly when switching between the areas in the 2D mapper the values
are retained and applied so that one area can be zoomed in and another
zoomed out and switching from the first to the second and back to the first
means that the zoom level used in the first is reused when it is returned
to. Deleting an area will forget the stored zoom level so if it is reused
it starts from scratch.

Code to save the zoom level for each area has also been implemented within
the C++ core. It saves it in the Area User Data for current map formats
(but removes it on loading so the user never sees it there) under a
`system.fallback_map2DZoom` key but will save it directly in the binary
data (which is more efficient) in the next format version whenever it is
enabled.

A new Mudlet event, which has been called `mapAreaViewedChangeEvent` has
been added with two additional arguments being the area ID changed to
followed by the one that it was changed from. I originally thought I
would need it to handle saving the zoom level for each area via the Lua
system but I found that that was not practicable. I'll leave it in for
now but it could be removed if peer-review finds it not to be of use.

Also, in refactoring `T2DMap::paintEvent(...)` I:
Removed/combined some locals:
* `(TArea*) playerArea` and `(TArea*) pPlayerArea` ==> `pArea`
* `(TRoom*) playerRoom` ==> `pPlayerRoom`
Remove unneeded (refactored out):
* `(qreal) ox`
* `(qreal) oy`

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
SlySven added a commit to SlySven/Mudlet that referenced this issue Mar 8, 2023
This is intended to close Mudlet#2388.

This enables the 2D (only) map zoom amounts for each map area to be save
independently and restored when switching between areas in the mapper. It
also saves the data between session.

It extends the existing `setMapZoom(...)` API to take an optional second
argument to specify the map area ID to set the zoom (which is a floating
point number) for any existing area, not just the current one.

It also adds a `getMapZoom(...)` function that, without any arguments,
returns the currently used 2D map zoom value for the area currently being
shown in the 2D mapper. If an area ID is provided it instead returns the
value that was last used for that area - or the default value that is used
initially on starting the profile or for an area that has not been viewed
before.

Importantly when switching between the areas in the 2D mapper the values
are retained and applied so that one area can be zoomed in and another
zoomed out and switching from the first to the second and back to the first
means that the zoom level used in the first is reused when it is returned
to. Deleting an area will forget the stored zoom level so if it is reused
it starts from scratch.

Code to save the zoom level for each area has also been implemented within
the C++ core. It saves it in the Area User Data for current map formats
(but removes it on loading so the user never sees it there) under a
`system.fallback_map2DZoom` key but will save it directly in the binary
data (which is more efficient) in the next format version whenever it is
enabled.

A new Mudlet event, which has been called `mapAreaViewedChangeEvent` has
been added with two additional arguments being the area ID changed to
followed by the one that it was changed from. I originally thought I
would need it to handle saving the zoom level for each area via the Lua
system but I found that that was not practicable. I'll leave it in for
now but it could be removed if peer-review finds it not to be of use.

Also, in refactoring `T2DMap::paintEvent(...)` I:
Removed/combined some locals:
* `(TArea*) playerArea` and `(TArea*) pPlayerArea` ==> `pArea`
* `(TRoom*) playerRoom` ==> `pPlayerRoom`

Remove unneeded (refactored out):
* `(qreal) ox`
* `(qreal) oy`

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
SlySven added a commit to SlySven/Mudlet that referenced this issue Mar 8, 2023
This is intended to close Mudlet#2388.

This enables the 2D (only) map zoom amounts for each map area to be save
independently and restored when switching between areas in the mapper. It
also saves the data between session.

It extends the existing `setMapZoom(...)` API to take an optional second
argument to specify the map area ID to set the zoom (which is a floating
point number) for any existing area, not just the current one.

It also adds a `getMapZoom(...)` function that, without any arguments,
returns the currently used 2D map zoom value for the area currently being
shown in the 2D mapper. If an area ID is provided it instead returns the
value that was last used for that area - or the default value that is used
initially on starting the profile or for an area that has not been viewed
before.

Importantly when switching between the areas in the 2D mapper the values
are retained and applied so that one area can be zoomed in and another
zoomed out and switching from the first to the second and back to the first
means that the zoom level used in the first is reused when it is returned
to. Deleting an area will forget the stored zoom level so if it is reused
it starts from scratch.

Code to save the zoom level for each area has also been implemented within
the C++ core. It saves it in the Area User Data for current map formats
(but removes it on loading so the user never sees it there) under a
`system.fallback_map2DZoom` key but will save it directly in the binary
data (which is more efficient) in the next format version whenever it is
enabled.

A new Mudlet event, which has been called `mapAreaViewedChangeEvent` has
been added with two additional arguments being the area ID changed to
followed by the one that it was changed from. I originally thought I
would need it to handle saving the zoom level for each area via the Lua
system but I found that that was not practicable. I'll leave it in for
now but it could be removed if peer-review finds it not to be of use.

Also, in refactoring `T2DMap::paintEvent(...)` I:
Removed/combined some locals:
* `(TArea*) playerArea` and `(TArea*) pPlayerArea` ==> `pArea`
* `(TRoom*) playerRoom` ==> `pPlayerRoom`

Remove unneeded (refactored out):
* `(qreal) ox`
* `(qreal) oy`

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
SlySven added a commit that referenced this issue Mar 16, 2023
This is intended to close #2388.

This enables the 2D (only) map zoom amounts for each map area to be save
independently and restored when switching between areas in the mapper.
It also saves the data between session.

It extends the existing `setMapZoom(...)` API to take an optional second
argument to specify the map area ID to set the zoom (which is a floating
point number) for any existing area, not just the current one.

It also adds a `getMapZoom(...)` function that, without any arguments,
returns the currently used 2D map zoom value for the area currently
being shown in the 2D mapper. If an area ID is provided it instead
returns the value that was last used for that area - or the default
value that is used initially on starting the profile or for an area that
has not been viewed before.

Importantly when switching between the areas in the 2D mapper the values
are retained and applied so that one area can be zoomed in and another
zoomed out and switching from the first to the second and back to the
first means that the zoom level used in the first is reused when it is
returned to. Deleting an area will forget the stored zoom level so if it
is reused it starts from scratch.

Code to save the zoom level for each area has also been implemented
within the C++ core. It saves it in the Area User Data for current map
formats (but removes it on loading so the user never sees it there)
under a `system.fallback_map2DZoom` key but will save it directly in the
binary data (which is more efficient) in the next format version
whenever it is enabled.

A new Mudlet event, which has been called `sysMapAreaChanged` has
been added with two additional arguments being the area ID changed to
followed by the one that it was changed from. I originally thought I
would need it to handle saving the zoom level for each area via the Lua
system but I found that that was not practicable.

Also, in refactoring `T2DMap::paintEvent(...)` I:
Removed/combined some locals:
* `(TArea*) playerArea` and `pPlayerArea` and `pArea`==> `pDrawnArea`
* `(TRoom*) playerRoom` ==> `pPlayerRoom`

Remove unneeded (refactored out):
* `(qreal) ox`
* `(qreal) oy`

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@Jieiku
Copy link
Contributor Author

Jieiku commented Mar 16, 2023

Awesome!

@vadi2 vadi2 added the bounty-paid This bounty has been completed & paid out label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty-50 see https://wiki.mudlet.org/w/Bounty_Process bounty-paid This bounty has been completed & paid out good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants