Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ MUSHclient
➜ Lua
➜ Little confusion with movewindow?
Little confusion with movewindow?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Rivius
(99 posts) Bio
|
Date
| Sat 25 Jun 2011 07:05 PM (UTC) |
Message
| 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. | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #1 on Sat 25 Jun 2011 07:20 PM (UTC) |
Message
|
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. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Rivius
(99 posts) Bio
|
Date
| Reply #2 on Sat 25 Jun 2011 07:23 PM (UTC) Amended on Sat 25 Jun 2011 07:24 PM (UTC) by Rivius
|
Message
| 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. | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #3 on Sat 25 Jun 2011 07:26 PM (UTC) |
Message
| So why are you calling WindowCreate over and over? Just blank the space with WindowRectOp |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Rivius
(99 posts) Bio
|
Date
| Reply #4 on Sat 25 Jun 2011 07:31 PM (UTC) |
Message
| Wouldn't that become very slow over time? | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #5 on Sat 25 Jun 2011 07:40 PM (UTC) |
Message
| I'm confused by your question. What assumptions are you making here? |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #6 on Sat 25 Jun 2011 08:02 PM (UTC) Amended on Sat 25 Jun 2011 08:03 PM (UTC) by Twisol
|
Message
| 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. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Rivius
(99 posts) Bio
|
Date
| Reply #7 on Sat 25 Jun 2011 08:03 PM (UTC) |
Message
| 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? | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #8 on Sun 26 Jun 2011 12:11 AM (UTC) Amended on Sun 26 Jun 2011 12:14 AM (UTC) by Fiendish
|
Message
|
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. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #9 on Sun 26 Jun 2011 12:55 AM (UTC) |
Message
|
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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rivius
(99 posts) Bio
|
Date
| Reply #10 on Sun 26 Jun 2011 07:41 PM (UTC) |
Message
| 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? | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #11 on Sun 26 Jun 2011 09:49 PM (UTC) |
Message
| 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. |
- 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.
33,171 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top