mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-26 19:39:31 +00:00

There is a new global interface draw_manager which handles drawing, and a new abstract base class top_level_drawable (TLD) to indicate that an object is something that has a place on the screen and should be drawn. Basic usage is fairly straightforward. Top-level objects (such as windows) inherit from top_level_drawable. They must implement the functions layout(), screen_location(), and expose(). layout() should ensure that screen location and animations are current. screen_location() should return the current draw location on screen. expose() should do the actual drawing. The draw manager keeps track of what regions of the screen, if any, need to be redrawn. Regions must be invalidated by calling invalidate_region(rect). This can be done at any time other than during expose(). It must not be called during expose(). The draw manager has one main callable function, sparkle(). This may be renamed at some point. It manages calling the TLD functions on all TLDs in the correct order. It also manages loop delay and vsync. The standard game loop now becomes: 1. events::pump() 2. draw_manager::sparkle()