src/Graphics/GameView.cc
branchnew_graphics
changeset 411 106aaf6eadfe
parent 410 41fd46cffc52
child 412 721c60072091
--- a/src/Graphics/GameView.cc	Wed Jan 21 01:57:24 2009 +0200
+++ b/src/Graphics/GameView.cc	Wed Jan 21 03:33:35 2009 +0200
@@ -1,9 +1,34 @@
 
 #include "GameView.hh"
+#include "Graphics.hh"
+
+#include <cassert>
 
 namespace graphics
 {
 
+GameView::GameView (GameState &state, LocalPlayer *player) :
+    View(PixelArea(0, 0, graphics->display.get_width, graphics->display.get_height)),
+    state(state), player(NULL), info_view(NULL), message_view(getMessageViewArea())
+{
+    // have player?
+    if (player)
+        setPlayer(player);
+
+    // insert message
+    message_view.add_message("Hello World!");
+}
+
+void GameView::setPlayer (LocalPlayer *player) {
+    assert(!this->player && player);
+    
+    // remember it
+    this->player = player;
+
+    // build the info_view as well
+    info_view = new PlayerInfoView(getInfoViewArea(), player);
+}
+
 
 void GameView::draw (Display *display) {
     CL_GraphicContext *gc = display->get_gc();
@@ -35,14 +60,26 @@
     // Draw the game
     state.draw(this, camera, flags & GUI_INPUT_DISPLAY_WEAPON);
     
-    // draw player info box
-    if (player != NULL) {
-        draw_player_info(gc, player);
-    }
-    
+    // draw info view?
+    if (info_view)
+        info_view->draw(display);
+
     // draw messages
     message_view.draw(this);
 }
 
+void GameView::resize (const PixelArea &new_area) {
+    View::resize(new_area);
+    
+    // resize subcomponents
+    if (info_view)
+        info_view->resize(getInfoViewArea());
+    
+    message_view.resize(getMessageViewArea());
 
-};
+    // log message
+    message_view.add_message(CL_Color::yellow, CL_String::format("[ Resized window to %1 x %2 ]", getWidth(), getHeight()));
+}
+
+
+}