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. |
|
Init video mode along options. Change window only when necessary.
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 }
|
|
Init SDL and grafic window. Register watcher for "fullscren" and "screen_*" options.
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 }
|
|
Shutdown SDL.
Reimplemented from BaseAgent. Definition at line 63 of file VideoAgent.cpp. 00064 { 00065 SDL_Quit(); 00066 }
|
|
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 }
|
|
Handle incoming message. Messages:
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 }
|
|
Handle incoming message. Messages:
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 }
|