Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

VideoAgent Class Reference

Inheritance diagram for VideoAgent:

Inheritance graph
[legend]
Collaboration diagram for VideoAgent:

Collaboration graph
[legend]

Detailed Description

Video agent initializes video mode and every cycle lets registered drawers to drawOn(screen).

Definition at line 18 of file VideoAgent.h.

Public Member Functions

virtual void receiveSimple (const SimpleMsg *msg)
 Handle incoming message.
virtual void receiveString (const StringMsg *msg)
 Handle incoming message.
void initVideoMode ()
 Init video mode along options.

Protected Member Functions

virtual void own_init ()
 Init SDL and grafic window.
virtual void own_update ()
 Draw all drawer from list.
virtual void own_shutdown ()
 Shutdown SDL.


Member Function Documentation

void VideoAgent::initVideoMode  ) 
 

Init video mode along options.

Change window only when necessary.

Exceptions:
SDLException when video mode cannot be made, the old video mode remain usable

Definition at line 95 of file VideoAgent.cpp.

00096 {
00097     OptionAgent *options = OptionAgent::agent();
00098     int screen_width = options->getAsInt("screen_width", 640);
00099     int screen_height = options->getAsInt("screen_height", 480);
00100 
00101     SysVideo::setCaption(options->getParam("caption", "A game"));
00102     if (NULL == m_screen
00103             || m_screen->w != screen_width
00104             || m_screen->h != screen_height)
00105     {
00106         changeVideoMode(screen_width, screen_height);
00107     }
00108 }

void VideoAgent::own_init  )  [protected, virtual]
 

Init SDL and grafic window.

Register watcher for "fullscren" and "screen_*" options.

Exceptions:
SDLException if there is no usuable video mode

Reimplemented from BaseAgent.

Definition at line 33 of file VideoAgent.cpp.

00034 {
00035     m_screen = NULL;
00036     m_fullscreen = false;
00037     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
00038         throw SDLException(ExInfo("Init"));
00039     }
00040     atexit(SDL_Quit);
00041 
00042     setIcon(Path::dataReadPath("images/icon.png"));
00043 
00044     registerWatcher("fullscreen");
00045     initVideoMode();
00046 }

void VideoAgent::own_shutdown  )  [protected, virtual]
 

Shutdown SDL.

Reimplemented from BaseAgent.

Definition at line 63 of file VideoAgent.cpp.

00064 {
00065     SDL_Quit();
00066 }

void VideoAgent::own_update  )  [protected, virtual]
 

Draw all drawer from list.

First will be drawed first.

Reimplemented from BaseAgent.

Definition at line 53 of file VideoAgent.cpp.

00054 {
00055     drawOn(m_screen);
00056     SDL_Flip(m_screen);
00057 }

void VideoAgent::receiveSimple const SimpleMsg msg  )  [virtual]
 

Handle incoming message.

Messages:

  • fullscreen ... toggle fullscreen

Exceptions:
UnknownMsgException 

Reimplemented from BaseListener.

Definition at line 181 of file VideoAgent.cpp.

00182 {
00183     if (msg->equalsName("fullscreen")) {
00184         OptionAgent *options = OptionAgent::agent();
00185         bool toggle = !(options->getAsBool("fullscreen"));
00186         options->setPersistent("fullscreen", toggle);
00187     }
00188     else {
00189         throw UnknownMsgException(msg);
00190     }
00191 }

void VideoAgent::receiveString const StringMsg msg  )  [virtual]
 

Handle incoming message.

Messages:

  • param_changed(fullscreen) ... handle fullscreen

Exceptions:
UnknownMsgException 

Reimplemented from BaseListener.

Definition at line 201 of file VideoAgent.cpp.

00202 {
00203     if (msg->equalsName("param_changed")) {
00204         std::string param = msg->getValue();
00205         if ("fullscreen" == param) {
00206             bool fs = OptionAgent::agent()->getAsBool("fullscreen");
00207             if (fs != m_fullscreen) {
00208                 toggleFullScreen();
00209             }
00210         }
00211         else {
00212             throw UnknownMsgException(msg);
00213         }
00214     }
00215     else {
00216         throw UnknownMsgException(msg);
00217     }
00218 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:57:10 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2