pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3692 - in trunk/pingus/src: . components display


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3692 - in trunk/pingus/src: . components display
Date: Sat, 5 Jul 2008 10:00:11 +0200

Author: grumbel
Date: 2008-07-05 10:00:06 +0200 (Sat, 05 Jul 2008)
New Revision: 3692

Modified:
   trunk/pingus/src/components/playfield.cpp
   trunk/pingus/src/components/playfield.hpp
   trunk/pingus/src/display/drawing_context.cpp
   trunk/pingus/src/display/scene_context.cpp
   trunk/pingus/src/display/scene_context.hpp
   trunk/pingus/src/game_session.cpp
   trunk/pingus/src/game_session.hpp
Log:
Implemented basic resize handling for the Playfield

Modified: trunk/pingus/src/components/playfield.cpp
===================================================================
--- trunk/pingus/src/components/playfield.cpp   2008-07-05 07:22:11 UTC (rev 
3691)
+++ trunk/pingus/src/components/playfield.cpp   2008-07-05 08:00:06 UTC (rev 
3692)
@@ -26,7 +26,7 @@
 #include "../display/display.hpp"
 #include "../game_session.hpp"
 #include "playfield.hpp"
-
+
 Playfield::Playfield(Server* server_, GameSession* session_, const Rect& rect_)
   : RectComponent(rect_),
     server(server_),
@@ -48,7 +48,6 @@
 
 Playfield::~Playfield()
 {
-  delete scene_context;
 }
 
 void
@@ -91,7 +90,7 @@
     }
 
   state.pop(*scene_context);
-  gc.draw(new SceneContextDrawingRequest(scene_context, Vector3f(0,0,-10000)));
+  gc.draw(new SceneContextDrawingRequest(scene_context.get(), 
Vector3f(0,0,-10000)));
 }
 
 Pingu*
@@ -258,5 +257,12 @@
   state.set_pos(state.get_pos() + Vector2f((float)x, (float)y));
 }
 
-
+void
+Playfield::update_layout() 
+{
+  std::cout << rect.get_width() << ", " << rect.get_height() << std::endl;
+  state.set_size(rect.get_width(), rect.get_height());
+  scene_context->set_rect(rect);
+}
+
 /* EOF */

Modified: trunk/pingus/src/components/playfield.hpp
===================================================================
--- trunk/pingus/src/components/playfield.hpp   2008-07-05 07:22:11 UTC (rev 
3691)
+++ trunk/pingus/src/components/playfield.hpp   2008-07-05 08:00:06 UTC (rev 
3692)
@@ -17,6 +17,7 @@
 #ifndef HEADER_PINGUS_PLAYFIELD_HPP
 #define HEADER_PINGUS_PLAYFIELD_HPP
 
+#include <memory>
 #include "../graphic_context_state.hpp"
 #include "../gui/rect_component.hpp"
 #include "../capture_rectangle.hpp"
@@ -28,7 +29,7 @@
 class ButtonPanel;
 class Controller;
 class View;
-
+
 /** This class encapsulates all the different Views */
 class Playfield : public GUI::RectComponent
 {
@@ -42,7 +43,7 @@
 
   Vector2i scroll_center;
 
-  SceneContext* scene_context;
+  std::auto_ptr<SceneContext> scene_context;
   GraphicContextState state;
   CaptureRectangle capture_rectangle;
 
@@ -78,13 +79,12 @@
 
   bool is_at (int x, int y) { UNUSED_ARG(x); UNUSED_ARG(y); return true; }
   Rect get_rect() const { return rect; }
-  void update_layout() {}
+  void update_layout();
 private:
   Playfield (const Playfield&);
   Playfield& operator= (const Playfield&);
 };
-
-
+
 #endif
 
 /* EOF */

Modified: trunk/pingus/src/display/drawing_context.cpp
===================================================================
--- trunk/pingus/src/display/drawing_context.cpp        2008-07-05 07:22:11 UTC 
(rev 3691)
+++ trunk/pingus/src/display/drawing_context.cpp        2008-07-05 08:00:06 UTC 
(rev 3692)
@@ -391,8 +391,8 @@
 DrawingContext::get_world_clip_rect() const
 {
   return Rect(Vector2i(static_cast<int>(-translate_stack.back().x),
-                          static_cast<int>(-translate_stack.back().y)),
-                 Size((int)get_width(), (int)get_height()));
+                       static_cast<int>(-translate_stack.back().y)),
+              Size((int)get_width(), (int)get_height()));
 }
 
 void
@@ -479,5 +479,5 @@
   return pos + Vector2i(int(translate_stack.back().x + rect.left), 
                         int(translate_stack.back().y + rect.top));
 }
-
+
 /* EOF */

Modified: trunk/pingus/src/display/scene_context.cpp
===================================================================
--- trunk/pingus/src/display/scene_context.cpp  2008-07-05 07:22:11 UTC (rev 
3691)
+++ trunk/pingus/src/display/scene_context.cpp  2008-07-05 08:00:06 UTC (rev 
3692)
@@ -130,6 +130,14 @@
 }
 
 void
+SceneContext::set_rect(const Rect& rect)
+{
+  impl->color.set_rect(rect);
+  impl->light.set_rect(rect);
+  impl->highlight.set_rect(rect);
+}
+
+void
 SceneContext::set_cliprect(const Rect& rect)
 {
   impl->cliprect = rect;

Modified: trunk/pingus/src/display/scene_context.hpp
===================================================================
--- trunk/pingus/src/display/scene_context.hpp  2008-07-05 07:22:11 UTC (rev 
3691)
+++ trunk/pingus/src/display/scene_context.hpp  2008-07-05 08:00:06 UTC (rev 
3692)
@@ -66,6 +66,7 @@
   void pop_modelview();
   void reset_modelview();
 
+  void set_rect(const Rect& rect);
   void set_cliprect(const Rect& rect);
   void reset_cliprect();
 

Modified: trunk/pingus/src/game_session.cpp
===================================================================
--- trunk/pingus/src/game_session.cpp   2008-07-05 07:22:11 UTC (rev 3691)
+++ trunk/pingus/src/game_session.cpp   2008-07-05 08:00:06 UTC (rev 3692)
@@ -367,5 +367,19 @@
 {
   return pause;
 }
+
+void
+GameSession::resize(const Size& size)
+{
+  std::cout << "ReSize: " << size.width << ", " << size.height << std::endl;
+
+  int world_width  = server->get_world()->get_width();
+  int world_height = server->get_world()->get_height();
+  
+  playfield->set_rect(Rect(Vector2i(Math::max((Display::get_width()  - 
world_width)/2,  0),
+                                    Math::max((Display::get_height() - 
world_height)/2, 0)), 
+                           Size(Math::min(Display::get_width(),  world_width),
+                                Math::min(Display::get_height(), 
world_height))));
+}
 
 /* EOF */

Modified: trunk/pingus/src/game_session.hpp
===================================================================
--- trunk/pingus/src/game_session.hpp   2008-07-05 07:22:11 UTC (rev 3691)
+++ trunk/pingus/src/game_session.hpp   2008-07-05 08:00:06 UTC (rev 3692)
@@ -102,6 +102,7 @@
   void set_pause(bool value);
   bool get_pause() const;
 
+  void resize(const Size&);
 private:
   void process_scroll_event (const Input::ScrollEvent&);
   void process_axis_event (const Input::AxisEvent&);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]