pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3100 - in trunk/pingus/src: display editor


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3100 - in trunk/pingus/src: display editor
Date: Thu, 6 Sep 2007 22:41:55 +0200

Author: grumbel
Date: 2007-09-06 22:41:54 +0200 (Thu, 06 Sep 2007)
New Revision: 3100

Modified:
   trunk/pingus/src/display/drawing_context.cpp
   trunk/pingus/src/editor/editor_level.cpp
   trunk/pingus/src/editor/editor_level.hpp
   trunk/pingus/src/editor/editor_screen.cpp
   trunk/pingus/src/editor/editor_viewport.cpp
   trunk/pingus/src/editor/editor_viewport.hpp
Log:
- switched EditorViewport from SceneContext to DrawingContext

Modified: trunk/pingus/src/display/drawing_context.cpp
===================================================================
--- trunk/pingus/src/display/drawing_context.cpp        2007-09-06 19:04:54 UTC 
(rev 3099)
+++ trunk/pingus/src/display/drawing_context.cpp        2007-09-06 20:41:54 UTC 
(rev 3100)
@@ -185,7 +185,8 @@
 }
 
 DrawingContext::DrawingContext()
-  : rect(0, 0, Display::get_width(), Display::get_height())
+  : rect(0, 0, Display::get_width(), Display::get_height()),
+    do_clipping(false)
 {
   translate_stack.push_back(Vector3f(0, 0));
 }
@@ -193,14 +194,14 @@
 DrawingContext::~DrawingContext()
 {
   if (drawingrequests.size() > 0) 
-               clear();
+    clear();
 }
 
 void
 DrawingContext::render(SDL_Surface* screen, const Rect& parent_rect)
 {
   Rect this_rect(Math::max(rect.left   + parent_rect.left, parent_rect.left),
-                 Math::max(rect.top    + parent_rect.top,  parent_rect.left),
+                 Math::max(rect.top    + parent_rect.top,  parent_rect.top),
                  Math::min(rect.right  + parent_rect.left, parent_rect.right),
                  Math::min(rect.bottom + parent_rect.top,  
parent_rect.bottom));
 

Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp    2007-09-06 19:04:54 UTC (rev 
3099)
+++ trunk/pingus/src/editor/editor_level.cpp    2007-09-06 20:41:54 UTC (rev 
3100)
@@ -29,21 +29,27 @@
 #include "../sexpr_file_writer.hpp"
 
 namespace Editor {
-
+
 // Default constructor
 EditorLevel::EditorLevel() :
   impl(new LevelImpl())
 {
 
 }
-
+
 // Default Destructor
 EditorLevel::~EditorLevel()
 {
   if (impl)
     delete impl;
 }
-
+
+Size
+EditorLevel::get_size() const
+{
+  return impl->size;
+}
+
 /** Verify that level is valid:
     Level should contain the following attributes in order to be "valid":
     -----------
@@ -64,7 +70,7 @@
   else
     return false;
 }
-
+
 // Save the level to a file.  Returns true if successful
 bool EditorLevel::save_level(const std::string& filename)
 {
@@ -117,7 +123,7 @@
 
   return true;
 }
-
+
 // Load an existing level from a file
 void EditorLevel::load_level(const Pathname& pathname)
 {
@@ -126,33 +132,33 @@
   impl = new LevelImpl();
 
   // Load the level from the file - we don't care what it's res_name is.
-  PingusLevel existing_level(pathname);
+  PingusLevel level(pathname);
        
   // Assign all of the level information to our LevelImpl
-  impl->levelname        = existing_level.get_levelname();
-  impl->description      = existing_level.get_description();
-  impl->ambient_light    = existing_level.get_ambient_light();
-  impl->size             = existing_level.get_size();
-  impl->number_of_pingus = existing_level.get_number_of_pingus();
-  impl->number_to_save   = existing_level.get_number_to_save();
-  impl->actions          = existing_level.get_actions();
-  impl->time             = existing_level.get_time();
-  impl->difficulty       = existing_level.get_difficulty();
-  impl->author           = existing_level.get_author();
-  impl->music            = existing_level.get_music();
+  impl->levelname        = level.get_levelname();
+  impl->description      = level.get_description();
+  impl->ambient_light    = level.get_ambient_light();
+  impl->size             = level.get_size();
+  impl->number_of_pingus = level.get_number_of_pingus();
+  impl->number_to_save   = level.get_number_to_save();
+  impl->actions          = level.get_actions();
+  impl->time             = level.get_time();
+  impl->difficulty       = level.get_difficulty();
+  impl->author           = level.get_author();
+  impl->music            = level.get_music();
        
   // Temporary objects
   unsigned attribs;
   Vector3f p;
-  Color tmp_color;
+  Color    tmp_color;
   ResDescriptor desc;
-  std::string tmp_str;
-  int tmp_int;
+  std::string   tmp_str;
+  int   tmp_int;
   float tmp_float;
-  bool tmp_bool;
+  bool  tmp_bool;
 
   // Get the objects
-  std::vector<FileReader> objs = existing_level.get_objects();
+  std::vector<FileReader> objs = level.get_objects();
   for (std::vector<FileReader>::const_iterator i = objs.begin(); i != 
objs.end(); i++)
     {
       // Create new object
@@ -240,13 +246,13 @@
   // Sort by Z coordinate
   impl->sort_objs();
 }
-
+
 void
 EditorLevel::add_object(LevelObj* obj)
 {
   impl->objects.push_back(obj);
 }
+
+} // namespace Editor
 
-}      // Editor namespace
-
 /* EOF */

Modified: trunk/pingus/src/editor/editor_level.hpp
===================================================================
--- trunk/pingus/src/editor/editor_level.hpp    2007-09-06 19:04:54 UTC (rev 
3099)
+++ trunk/pingus/src/editor/editor_level.hpp    2007-09-06 20:41:54 UTC (rev 
3100)
@@ -53,6 +53,8 @@
        
   /** Add an object to the level */
   void add_object(LevelObj* obj);
+
+  Size get_size() const;
        
   /** Return LevelImpl */
   LevelImpl* get_level_impl() { return impl; }

Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp   2007-09-06 19:04:54 UTC (rev 
3099)
+++ trunk/pingus/src/editor/editor_screen.cpp   2007-09-06 20:41:54 UTC (rev 
3100)
@@ -109,7 +109,6 @@
 {
   close_dialog = true;
   plf->save_level(file);
-  //panel->set_selected_button(0);
 }
 
 // Load a new level
@@ -119,7 +118,6 @@
   close_dialog = true;
   plf->load_level(file);
   viewport->refresh();
-  //panel->set_selected_button(0);
 }
 
 // Draw the background and components

Modified: trunk/pingus/src/editor/editor_viewport.cpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.cpp 2007-09-06 19:04:54 UTC (rev 
3099)
+++ trunk/pingus/src/editor/editor_viewport.cpp 2007-09-06 20:41:54 UTC (rev 
3100)
@@ -37,7 +37,7 @@
 // Constructor
 EditorViewport::EditorViewport(EditorScreen* e) :
   state(Display::get_width(), Display::get_height()),
-  scene_context(new SceneContext()),
+  drawing_context(new DrawingContext(Rect(48, 38 + 48, Display::get_width() - 
248 - 48, 600 - 48))),
   editor(e),
   autoscroll(false),
   highlighted_area(0,0,0,0),
@@ -45,15 +45,12 @@
   snap_to(false),
   current_action(NOTHING)
 {
-  // FIXME: Hardcoded values should be determined by level size
-  state.set_limit(Rect(-30, -50, 1600, 1300));
-  state.set_pos(Vector2f(0, 0));
 }
 
 // Destructor
 EditorViewport::~EditorViewport ()
 {
-  delete scene_context;
+  delete drawing_context;
 }
 
 void
@@ -222,22 +219,22 @@
 void
 EditorViewport::draw(DrawingContext &gc)
 {
-  scene_context->clear();
-  state.push(*scene_context);
+  drawing_context->clear();
+  state.push(*drawing_context);
        
   // Now, draw all of the objects
 
   // Draw the level objects
   for (unsigned i = 0; i < objs.size(); i++)
-    objs[i]->draw(scene_context->color());
+    objs[i]->draw(*drawing_context);
 
   if (current_action == HIGHLIGHTING)
     gc.draw_rect((float)highlighted_area.left, (float)highlighted_area.top, 
                  (float)highlighted_area.right, 
(float)highlighted_area.bottom, 
                  Color(255,0,255));
 
-  state.pop(*scene_context);
-  gc.draw(new SceneContextDrawingRequest(scene_context, Vector3f(0, 0, -150)));
+  state.pop(*drawing_context);
+  gc.draw(*drawing_context, -150);
 }
 
 // Returns true if the viewport is at the x,y coordinate
@@ -306,6 +303,10 @@
 EditorViewport::refresh()
 {
   objs = editor->get_level()->get_objects();
+  //state.set_limit(Rect(Vector2i(0, 0), editor->get_level()->get_size()));
+  std::cout << editor->get_level()->get_size().width << ", "
+            << editor->get_level()->get_size().height 
+            << std::endl;
 }
 
 void 

Modified: trunk/pingus/src/editor/editor_viewport.hpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.hpp 2007-09-06 19:04:54 UTC (rev 
3099)
+++ trunk/pingus/src/editor/editor_viewport.hpp 2007-09-06 20:41:54 UTC (rev 
3100)
@@ -44,7 +44,7 @@
 {
 private:       
   GraphicContextState state;
-  SceneContext* scene_context;
+  DrawingContext* drawing_context;
 
   /** The EditorScreen to which this viewport belongs */
   EditorScreen* editor;





reply via email to

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