Possible to hook into mapper rightclick menu?

All and any discussion and development of the Mudlet Mapper.
InTheWorks
Posts: 18
Joined: Sat Sep 10, 2011 7:37 am

Possible to hook into mapper rightclick menu?

Post by InTheWorks » Mon Nov 28, 2011 10:28 am

As the title says, is it possible to get notification in my mapping script when a user changes the location using the right click menu "Set Location Here". Is there an event mechanism? I know I can get the roomId via the recently added getMapVar() function so I can keep a copy and check to see that it's changed before I use it. An event or callback would be much nicer though.

I'd also like to know if it's possible to add a menu item to the right click menu when two (and only two) rooms are selected in order to merge them. Frequently, the rooms I've mapped don't all end up on the same grid. So when I encounter a room that I know I've been in and it doesn't line up on the map I have to delete the room and edit the exits manually. It would be nice to be able to select two rooms and click "merge", or better yet, drag the duplicate room and drop it onto the "correct" room and have them merge.

Knowing nothing about the mapper internals, are these difficult things to add?

Added so far in chris' branch:
addMapEvent("menu entry name", "event name to be raised") - when the entry is clicked, it'll raise an event with the selected room / rooms highlighted as a list of arguments.
addMapEvent("menu entry name", "event name to be raised", "menu parent") - same as above, but adds inside a menu created with addMapMenu().
addMapMenu("additional menu name") - adds a new menu> to the main right-click menu in the mapper
addMapMenu("additional menu name", "parent name") - adds a new menu> to the menu parent in the right-click menu in the mapper

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Possible to hook into mapper rightclick menu?

Post by chris » Wed Nov 30, 2011 4:13 am

Adding an event for the set location is a good idea and something I'll add. The merge one just needs to be fleshed out as to how you do it. Should all exits be included or only ones shared between the rooms? Also, what room should be the merged one (I'd guess the one you right click on). It isn't too difficult but some discussion on it is needed first.

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: Possible to hook into mapper rightclick menu?

Post by Omit » Wed Nov 30, 2011 7:07 am

a script to merge rooms is going to be mud specific.... I like the idea of a merge option in the right click menu(on the map) but it should not do anything except tigger an event. (an event that we can make run our own script)

InTheWorks
Posts: 18
Joined: Sat Sep 10, 2011 7:37 am

Re: Possible to hook into mapper rightclick menu?

Post by InTheWorks » Wed Nov 30, 2011 8:32 am

So I'll try to illustrate the merge scenario I've run into so far. Typically I'm mapping an area and I get to a room that I know I've already been into, but the map doesn't actually lead into this room. Consider this picture:
Selection_001.png
Selection_001.png (1.97 KiB) Viewed 3500 times
The highlighted room (roomId 49) is actually the same room as the room in the top left corner of the map (roomId 1). For my use case, there would only ever be one established exit (ie linked in both directions) with which to merge. In the scenario above, we'd need to add an exit from room 48 to room 1 (and the inverse exit as well). Perhaps this could be a simple check to do an automatic merge, otherwise reject the request to merge.

Consider dragging room 49 and dropping it onto room 1. In that case we could probably assume that the one being dragged has the one new exit to add to the room it's being dropped on to. Room 1 should have all the "good" exits and merging room 49 should simply add one exit.

To me drag and drop seems most intuitive (even if a modifier key must be used), but if that's hard to do or undesirable for some reason, then I suppose I'd select room 49 first, then select room 1 and then right click for the option to merge.

I can't come up with a use case for merging rooms with multiple exits. I would imagine that the majority of exits in both rooms would be the same though (if they really are the same room). So there should be no "collisions" where the same exit in each room leads to a different room. Any collisions should abort the merge. Any exits that exist in one and not the other can probably be safely added. Same could work for dealing with special exits.

It would probably be best to ignore exit stubs for the merge or at least consider that room 1 has the correct exit stubs and ignore any of room 49's exit stubs. The only time there would be a difference is if an exit is hidden.

However, having said all this, there's a case that could be tricky to handle: one way exits. I'm thinking in particular about a simple case where you have several rooms side by side (east to west) where moving north drops you into the same common room. In this case, moving north in one of the east-west rooms would create a new room that you would probably like to drag and drop onto the common room. I haven't had the opportunity to map such an area with mudlet yet, but I imagine the one-way rooms need to be created by hand by removing the inverse exit after the room is created. In that case, the room being dragged would only map an exit into the common room. I'll have to give that one some more thought.

I plan to prototype room merges in a lua script so perhaps I'll give the above a spin and see how it works out. Adding an event for merging rooms that can be handled by a lua script is also a good idea for starters. I'm not convinced the merging is necessarily mud specific though.

If merging can be done, then what will be required next is a way to rearrange the map so that the rooms fall on proper grids. In the above picture, the top row of rooms and the right column of rooms needs to be "stretched" somehow to make a nice grid. Otherwise, after the merge, mudlet will happily draw an exit between rooms 1 and 48, but then going north from room 1 would actually move to the room on the right which is a tad annoying. I've also been thinking about prototyping this with a lua script, but perhaps it's worth some discussion too. Any comments?

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: Possible to hook into mapper rightclick menu?

Post by Omit » Wed Nov 30, 2011 6:28 pm

InTheWorks wrote:I can't come up with a use case for merging rooms with multiple exits. I would imagine that the majority of exits in both rooms would be the same though (if they really are the same room). So there should be no "collisions" where the same exit in each room leads to a different room.
I can.... (you assume that all the mapping scripts work the same way, they don't... we would all have to argee what the "correct" method for mapping is in order to build merge rooms into Mudlets Map)

Example: I use roomID's 1-13 for any unmapped exit in a room. (why? you ask.... it allows exits to unmapped rooms to be displayed with the mapper, these rooms have no location and are not assigned to an area, the exits are updated when they are used and the destination has been mapped.)

So.... my medge script will need to first delete all the exits from both rooms with destination id's <= 13, combine the remaining exits and assign them to one of the rooms, delete the other room, and then add the remaining unmapped exits to the merdged room.

I am quite certain that your process of merging rooms will be similar but is very unlikely to be the same.

User avatar
Vadi
Posts: 4727
Joined: Sat Mar 14, 2009 3:13 pm

Re: Possible to hook into mapper rightclick menu?

Post by Vadi » Thu Dec 01, 2011 1:43 am

I think the best solution would be to drag rooms on top of each other (select room and move, you can already do that), and if there is more than 1 room at a coordinate, a right-click option of 'merge' will become available on the menu - clicking on it will merge the rooms and be unrestrictive about exits (so if rooma links to roomc, roomb links to roomd, and we merge rooma+roomb, rooma will have an exit to roomc and roomd, and roomb is deleted. Same with userdata, weight will be highest, locked/unlocked will favour locked if any are).

If there's more than room to merge at a location, I guess a dialog should ask which would you like to merge.

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Possible to hook into mapper rightclick menu?

Post by chris » Thu Dec 01, 2011 3:27 am

I think an event call with the rooms selected is the way to go here. There is too much variability in mapper implementations and styles. I'm been thinking about how I could let users add their own menus to the mapper right click and have it hook to an event which will return the room/rooms right clicked on.

InTheWorks
Posts: 18
Joined: Sat Sep 10, 2011 7:37 am

Re: Possible to hook into mapper rightclick menu?

Post by InTheWorks » Thu Dec 01, 2011 4:18 am

I can.... (you assume that all the mapping scripts work the same way, they don't... we would all have to argee what the "correct" method for mapping is in order to build merge rooms into Mudlets Map)

Example: I use roomID's 1-13 for any unmapped exit in a room. (why? you ask.... it allows exits to unmapped rooms to be displayed with the mapper, these rooms have no location and are not assigned to an area, the exits are updated when they are used and the destination has been mapped.)
You'll have to pardon my ignorance, but isn't that better solved with the recently added exit stubs?

InTheWorks
Posts: 18
Joined: Sat Sep 10, 2011 7:37 am

Re: Possible to hook into mapper rightclick menu?

Post by InTheWorks » Thu Dec 01, 2011 4:25 am

chris wrote:I think an event call with the rooms selected is the way to go here. There is too much variability in mapper implementations and styles. I'm been thinking about how I could let users add their own menus to the mapper right click and have it hook to an event which will return the room/rooms right clicked on.
As long as I can tell which room was dragged vs dropped in my script, that would work fine. Though would it be outrageous to suggest a default implementation "built-in" which could be overridden with a user's script? Could register the user's callback at startup, otherwise use the default implementation. Seems to me that there shouldn't be such variability in the maps themselves. Omit's implementation seems to be a workaround for features lacking in the mapper?

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: Possible to hook into mapper rightclick menu?

Post by Omit » Thu Dec 01, 2011 4:44 am

InTheWorks wrote:
I can.... (you assume that all the mapping scripts work the same way, they don't... we would all have to argee what the "correct" method for mapping is in order to build merge rooms into Mudlets Map)

Example: I use roomID's 1-13 for any unmapped exit in a room. (why? you ask.... it allows exits to unmapped rooms to be displayed with the mapper, these rooms have no location and are not assigned to an area, the exits are updated when they are used and the destination has been mapped.)
You'll have to pardon my ignorance, but isn't that better solved with the recently added exit stubs?
Maybe I am the one that is ignorant, I have been using mudlet for mapping even before there was support for it. Sometimes that means I am doing things my own way to achive the functionality I have needed to map. (Have done many rewrites to use mudlets api as new features have been added.... but am not up to date on all the changes that have happened in the last 8 months or so.) Looks like I need to look into the "stubs" and how they work. :P

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests