| Message |
The first thing to think about is the difference between Redraw () and Repaint ().
Redraw schedules an update of the whole MUSHclient window next time the Windows event loop is otherwise empty (eg. no outstanding keystrokes or mouseclicks). In practice, MUSHclient calls Redraw internally when new output arrives from the MUD (and is placed on the screen), and you do a WindowShow, and at various other spots.
There is no particular harm in calling Redraw hundreds of times, they simply will result in a single screen update when there is nothing else to do. Usually this results in a quite responsive screen update.
However Repaint () causes a screen update now. And if a dozen plugins all call Repaint () then you get a dozen screen updates. Now this is likely to slow things down, what with all the text drawing, copying of miniwindow images etc.
Having said that, there might be a case for calling Repaint. In another thread recently it was pointed out that the mapper "seemed unresponsive" as you quickly speedwalked from one place to another, because this caused so much incoming data to arrive, that the redrawing of the screen was deferred so much that the mapper seemed jerky.
I definitely don't think every plugin should call Repaint "just to make sure" its changes are seen. This is likely to cause major slowdowns. However OTOH not calling it at all may make the system seem slow to respond.
If you are implementing sprites, then you probably need to call Repaint to make sure the sprites are actually visibly moved around. Bear in mind that repainting the screen 25 times a second might impose quite a load on the system.
One possible approach might be to make sure that Repaint is called at least a few times a second (eg. every 5th time through the tick callback) and at other times call Redraw. That way you are guaranteed that at least some sprite movements will be drawn, and with luck, more will be.
Remember, on a slower PC, forcing 25 repaints a second might actually be using so much of the CPU that there is none left for actually doing something useful. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|