[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Little confusion with movewindow?

Little confusion with movewindow?

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Rivius   (99 posts)  [Biography] 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.
[Go to top] top

Posted by Fiendish   USA  (2,517 posts)  [Biography] 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
[Go to top] top

Posted by Rivius   (99 posts)  [Biography] 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.
[Go to top] top

Posted by Fiendish   USA  (2,517 posts)  [Biography] 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
[Go to top] top

Posted by Rivius   (99 posts)  [Biography] bio
Date Reply #4 on Sat 25 Jun 2011 07:31 PM (UTC)
Message
Wouldn't that become very slow over time?
[Go to top] top

Posted by Fiendish   USA  (2,517 posts)  [Biography] 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
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] 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
[Go to top] top

Posted by Rivius   (99 posts)  [Biography] 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?
[Go to top] top

Posted by Fiendish   USA  (2,517 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (23,000 posts)  [Biography] 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
[Go to top] top

Posted by Rivius   (99 posts)  [Biography] 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?
[Go to top] top

Posted by Nick Gammon   Australia  (23,000 posts)  [Biography] 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
[Go to top] 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.


31,311 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]