Little confusion with movewindow?

Posted by Rivius on Sat 25 Jun 2011 07:05 PM — 12 posts, 47,923 views.

#0
I managed to make my window moveable by using


winf = movewindow.install (win, miniwin.pos_center_right, 0)
movewindow.add_drag_handler (win, 0, 0, 300, 10, miniwin.cursor_both_arrow) 


and this makes it nice and draggable. The only thing is, I need to recreate the window every time I change rooms (it's for my mapper). This resets the window position.

How do I keep it saved in memory? I'm not sure I really understand the documentation in the movewindow lua file.
USA Global Moderator #1
Quote:
I need to recreate the window every time

You probably don't. :)
If you provide some more context of what the plugin is trying to do, we can try to advise on design.
#2
Ah, well I have it in a script file. Basically all it does it draws text " [ ] " for rooms and a few lines connecting them to represent the map. It updates on every room move.
Amended on Sat 25 Jun 2011 07:24 PM by Rivius
USA Global Moderator #3
So why are you calling WindowCreate over and over? Just blank the space with WindowRectOp
#4
Wouldn't that become very slow over time?
USA Global Moderator #5
I'm confused by your question. What assumptions are you making here?
USA #6
When you do things to a miniwindow, you're not creating objects like rectangles and text, if that's what you mean. MUSHclient only keeps the end result of the operation: the pixels you see onscreen. And since a miniwindow is always the same size, you always have the same amount of pixels. So drawing won't become slower "over time" because there's nothing building up over time.
Amended on Sat 25 Jun 2011 08:03 PM by Twisol
#7
Well, when you said blank the space with windowrectop I thought you meant drawing over the screen. But the things under it would still be there and take up memory right? Wouldn't that bog down over time?
USA Global Moderator #8
Quote:
But the things under it would still be there and take up memory right?

What things? If you have some pixels, and you make them white, and then you make them black, MUSHclient isn't storing the entire sequence of steps. There are no "under" or "over" pixels. At every refresh it doesn't go "Turn white! Now turn black!". Think of a miniwindow (unless you're using hotspots, but that's a slightly different discussion) as just a picture of some stuff that is stored in memory. When you draw a line on your miniwindow, you are not creating a line layer on top of that image that can be magically removed by some sort of "undo" function. It is just changing the color of each of the pixels in the image at the locations determined to be on the line.

Hotspots are of course a bit of a different issue, but so far it doesn't sound like that is your concern.
Amended on Sun 26 Jun 2011 12:14 AM by Fiendish
Australia Forum Administrator #9
Rivius said:

Well, when you said blank the space with windowrectop I thought you meant drawing over the screen. But the things under it would still be there and take up memory right? Wouldn't that bog down over time?


As the other two are trying to explain, the answer is no. Once you clear the screen with WindowRectOp (may as well get the capitalization right) then that simply throws away (overwrites) the underlying pixels.

In fact, recreating the window is arguably less efficient. The memory it used to occupy is returned to the operating system, and more allocated. This could cause memory fragmentation.

The mappers that Fiendish and I (and Twisol too I think) have been working on usually just re-use the same window. In fact there is even a WindowResize function in case you want to change its size.

The other problem with recreating windows if you change rooms is that you delete everything including the hotspots. So, if you happened to be mousing down, or over, a hotspot, and your room changes (maybe someone teleports you) then the thing gets confused, because you are clicking on a hotspot that has been yanked away from under you.
#10
Ah. I wasn't aware that things were drawn to the miniwindows that way. I thought perhaps that they were layered one over the other and the only way to "clear" the window would be to recreate it. With what you've told me, I'll redo how I handle them.

I actually do use hotspots for every room box, but I guess this can be handled by deleting all hotspots?

In any case, how would I go about saving the new window position if I wanted it to persist onto the next session?
Australia Forum Administrator #11
As documented here:

http://www.gammon.com.au/forum/?id=9594



function OnPluginSaveState ()
  -- save window current location for next time  
  movewindow.save_state (win)
end -- function OnPluginSaveState


And yes, you could delete all hotspots if you change rooms.