Gui drawing

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
Yogibear
Retired Developer
Posts: 1086
Joined: September 16th, 2005, 5:44 am
Location: Hamburg, Germany

Gui drawing

Post by Yogibear »

I am a little bit unsure if i understand the mechanisms of gui drawing right. And it would take me quite some time to find out all by myself, so any help here is much appreciated :) .

The central method for updating the window seems to be display::draw. If i understood right from some comment it is supposed only to update the parts of the window that have changed.

I noticed that there is also methods like "redraw_everything", "invalidate_all" as well as the possibility to raise a draw-event. Probably it locks other gui drawings or event handling.

So: Suppose i am moving, recruiting, attacking whatever and i want to see the results.

Do i have to raise a draw event prior to calling draw? It's done most of the time but not always throughout the code.

Do i have to call invalidate-methods or is that handled mostly automatically?

When is redraw_everything meant to be used?

Edit:
Within the mouse_motion code there is a passage to show possible moves for a unit:

if(un != units_.end() && un->second.side() != player_number &&
current_paths_.routes.empty() && !(*gui_).fogged(un->first.x,un->first.y)) {
. . .
(*gui_).set_paths(&current_paths_);
enemy_paths_ = true;
}

Is there any reason why this is restricted to enemy moves (second if-criterion)? Does it have something to do with enemy_paths and what is the background about that?


Is there anything else i should know?


I need this for my replay code.

Thanks in advance for any helpful comments.
Smart persons learn out of their mistakes, wise persons learn out of others mistakes!
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

display::draw() is called regularly and is meant to redraw anything that has been changed (i.e. invalidated).

display::invalidate() invalidates a single tile (i.e. schedules it for redrawing next time display::draw() is called).

display::invalidate_all() invalidates all tiles.

display::redraw_everything() redraws everything on-screen, all tiles and all other widgets and so forth.

Functions that move units about are generally expected to call invalidate functions correctly to make sure tiles are redrawn.

Hope that helps.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Yogibear
Retired Developer
Posts: 1086
Joined: September 16th, 2005, 5:44 am
Location: Hamburg, Germany

Post by Yogibear »

Yes, thanks Dave, that helps a lot.

What about that draw event, which is often raised before calling display::draw()? What is its primary objective?
Smart persons learn out of their mistakes, wise persons learn out of others mistakes!
Post Reply