Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ Mapper module questions
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Magoo
(5 posts) Bio
|
| Date
| Tue 29 May 2012 09:18 AM (UTC) |
| Message
| Hello, I was wondering if it would be possible to extend the mapper functionality in order to drag the mapper "view" around via movedrag hotspot(s)? Would it also be possible to add text labels to maps that can scale with the current zoom functions? I'm asking this in advance, as to avoid a headache with trying to implement things that aren't really possible.
Thanks | | Top |
|
| Posted by
| Fiendish
USA (2,551 posts) Bio
Global Moderator |
| Date
| Reply #1 on Tue 29 May 2012 12:40 PM (UTC) Amended on Tue 29 May 2012 12:46 PM (UTC) by Fiendish
|
| Message
| | Yes and yes. And probably yes to anything else you ask about too. Miniwindows and hotspots give you pretty much complete access to the fundamental display and interaction layer of the client, so you can do anything that you can do, if you get my drift. |
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Magoo
(5 posts) Bio
|
| Date
| Reply #2 on Wed 30 May 2012 09:49 AM (UTC) |
| Message
| | Any suggestions on how to go about measuring mouse movement in order to tell the difference between dragging up or down etc..? At the moment, i'm storing the initial mouse coordinates on mousedown and then determining the difference between the initial coordinates and any subsequent movement to update the coordinates of the 'view', but this isn't very reliable. Also, will hotspot creation keep up with repaint() or is it linked to redraw() somehow? | | Top |
|
| Posted by
| Fiendish
USA (2,551 posts) Bio
Global Moderator |
| Date
| Reply #3 on Wed 30 May 2012 01:08 PM (UTC) Amended on Wed 30 May 2012 01:21 PM (UTC) by Fiendish
|
| Message
|
Quote: Any suggestions on how to go about measuring mouse movement in order to tell the difference between dragging up or down etc..? The moving around problem was solved for you a long time ago by the movewindow.lua file.
require "movewindow" at the top of your plugin and then see http://www.gammon.com.au/forum/bbshowpost.php?id=9594&page=2
The lines containing "movewindow" and "windowinfo" are the important ones.
Though if you want to get adventurous and start adding things like resizing, you can try something like...
Add a drag handler to a small hotspot in the lower-right corner like so:
-- Add handler for resizing
WindowAddHotspot(win, "resize", width-10, height-10, width, height, "MouseOver", "CancelMouseOver", "MouseDown", "", "MouseUp", "", 6, 0)
WindowDragHandler(win, "resize", "ResizeMoveCallback", "ResizeReleaseCallback", 0)
and then use callbacks like the following:
MIN_SIZE = 50
-- called when the resize drag widget is moved
function ResizeMoveCallback()
posx, posy = WindowInfo (win, 17), WindowInfo (win, 18)
width = width + posx - startx
startx = posx
if (width < MIN_SIZE) then
width = MIN_SIZE
startx = windowinfo.window_left+width
elseif (windowinfo.window_left+width > GetInfo(281)) then
width = GetInfo(281)-windowinfo.window_left
startx = GetInfo(281)
end
height = height + posy - starty
starty = posy
if (height < MIN_SIZE) then
height = MIN_SIZE
starty = windowinfo.window_top+height
elseif (windowinfo.window_top+height > GetInfo(280)) then
height = GetInfo(280)-windowinfo.window_top
starty = GetInfo(280)
end
if (utils.timer() - lastRefresh > 0.0333) then
--- RECONSTRUCT AND DRAW THE WINDOW WITH THE NEW HEIGHT AND WIDTH HERE
lastRefresh = utils.timer()
end
end
lastRefresh = 0
-- Called after the resize widget is released.
function ResizeReleaseCallback()
--- RECONSTRUCT AND DRAW THE WINDOW WITH THE NEW HEIGHT AND WIDTH HERE
end
-- Called when mouse button is pressed on hotspot.
function MouseDown(flags, hotspot_id)
if (hotspot_id == "resize") then
startx, starty = WindowInfo (win, 17), WindowInfo (win, 18)
end
end
Quote: Also, will hotspot creation keep up with repaint() or is it linked to redraw() somehow
Repaint is just like Redraw but with greater conviction (NOW! instead of SOON). To my knowledge neither is required for hotspot creation. |
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Magoo
(5 posts) Bio
|
| Date
| Reply #4 on Fri 01 Jun 2012 06:51 AM (UTC) |
| Message
| Ah, well thanks for that, but I think I didn't make myself very clear about what I was trying to accomplish. Basically, I am not trying to move the entire miniwindow, but scroll around in it in order to see other parts of the map that aren't specifically in a 100 room radius of the current room. I have managed to, more or less, get it to do that - but I'm having a couple of issues here:
view_pos_x = 0;
view_pos_y = 0;
lastRefresh = 0;
function mouse_down ( flags, hotspot_id )
view_pos_x = WindowInfo( win, 17 );
view_pos_y = WindowInfo( win, 18 );
end
function drag_move ( flags, hotspot_id )
local posx = WindowInfo( win, 17 );
local posy = WindowInfo( win, 18 );
if ( view_pos_x > posx ) then
view_x = view_x - 0.5;
end
if ( view_pos_x < posx ) then
view_x = view_x + 0.5;
end
if ( view_pos_y > posy ) then
view_y = view_y - 0.5;
end
if ( view_pos_y < posy ) then
view_y = view_y + 0.5;
end
if ( utils.timer() - lastRefresh > 0.0333 ) then
draw( current_room );
lastRefresh = utils.timer();
end
return 0;
end
The draw function is using Repaint(), as Redraw() is very bad for animations. The problem is that, without using a refresh setting of 0.03333, it fails to keep up with almost all hotspot creation - which is unfortunate as hotspots differ for each room in the view. Another problem I have is how to really go about using the mouse click coordinates to move the mapper around with simultaneous x-y dragging. I suppose I am missing something in my movement formula - because it does 'work' when I only allow the modification of a single axis at a time. | | Top |
|
| Posted by
| Fiendish
USA (2,551 posts) Bio
Global Moderator |
| Date
| Reply #5 on Sat 02 Jun 2012 03:44 AM (UTC) |
| Message
|
Magoo said:
Basically, I am not trying to move the entire miniwindow, but scroll around in it The math should be the same regardless. All you need to do is keep track of the mouse's motion delta between callbacks. What you do with that information will depend on purpose.
Quote: The draw function is using Repaint(), as Redraw() is very bad for animations. Ah, yes. That problem.
I use this:
http://code.google.com/p/aardwolfclientpackage/wiki/RepaintBuffer
Quote: I suppose I am missing something in my movement formula I gave you a movement formula that works. You just have to modify it. |
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #6 on Sat 02 Jun 2012 09:20 AM (UTC) |
| Message
| I suggest that Fiendish is the most expert person that I know of, for making the miniwindows work quickly.
I would follow his advice.
@Fiendish: thanks for your prompt support on this forum of such questions. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Fiendish
USA (2,551 posts) Bio
Global Moderator |
| Date
| Reply #7 on Sat 02 Jun 2012 01:20 PM (UTC) Amended on Sat 02 Jun 2012 01:21 PM (UTC) by Fiendish
|
| Message
|
Magoo said: I suppose I am missing something in my movement formula
To elaborate further, yes, you are. You don't actually use the posx,posy data in your dragmove callback. You look at it, and then you pick some arbitrary 0.5 value. And then you never update the mouse's "old" position between events. What you should be doing is looking at it, looking at the difference from where the mouse was last time, and then applying that value.
Where I have
posx, posy = WindowInfo (win, 17), WindowInfo (win, 18)
width = width + posx - startx
startx = posx
I believe you need
local posx = WindowInfo( win, 17 )
local posy = WindowInfo( win, 18 )
view_x = view_x + posx - view_pos_x
view_pos_x = posx
...
|
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Magoo
(5 posts) Bio
|
| Date
| Reply #8 on Mon 04 Jun 2012 11:50 AM (UTC) |
| Message
| | Thanks, I managed to fix a lot of things up with your help. Any idea which is faster for animating: using an image or using something like windowcircleop? | | Top |
|
| Posted by
| Fiendish
USA (2,551 posts) Bio
Global Moderator |
| Date
| Reply #9 on Mon 04 Jun 2012 11:58 PM (UTC) |
| Message
|
Magoo said:
Thanks, I managed to fix a lot of things up with your help. Any idea which is faster for animating: using an image or using something like windowcircleop?
I think it kind of depends on what you're doing. I can tell you that gradient rects tend to be really slow, though. |
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Magoo
(5 posts) Bio
|
| Date
| Reply #10 on Tue 05 Jun 2012 01:43 AM (UTC) Amended on Tue 05 Jun 2012 04:02 AM (UTC) by Magoo
|
| Message
| Basically deciding between premade images for rooms in the mapper or drawing them using windowcircleop. The way the mapper does them now, if you see a fair number of rooms on the screen at any given time it is extremely slow.
I'd also like to stress the point that I am actually updating several room coordinates very quickly in order to 'scroll' the mapper view, but I am starting to realise that regardless of which method of drawing I use - miniwindows may simply be just too slow for any real-time animation on a large scale. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #11 on Tue 05 Jun 2012 05:55 AM (UTC) |
| Message
| | What you might be able to do is pre-render them (within reason) into an off-screen window, and then just blit the portion you want onto the visible window. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
35,390 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top