pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/editor level_resizer.cxx,NONE,1.1 lev


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/editor level_resizer.cxx,NONE,1.1 level_resizer.hxx,NONE,1.1 Makefile.am,1.27,1.28 editor.cxx,1.40,1.41 editor_event.cxx,1.41,1.42 level_property_window.cxx,1.10,1.11 level_property_window.hxx,1.8,1.9 object_manager.cxx,1.37,1.38 object_manager.hxx,1.22,1.23 property_window.cxx,1.11,1.12 start_pos.hxx,1.9,1.10
Date: 29 Nov 2002 22:54:25 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/editor
In directory dark:/tmp/cvs-serv31004/editor

Modified Files:
        Makefile.am editor.cxx editor_event.cxx 
        level_property_window.cxx level_property_window.hxx 
        object_manager.cxx object_manager.hxx property_window.cxx 
        start_pos.hxx 
Added Files:
        level_resizer.cxx level_resizer.hxx 
Log Message:
- added drag&dropable level resizer


--- NEW FILE: level_resizer.cxx ---
//  $Id: level_resizer.cxx,v 1.1 2002/11/29 22:54:22 grumbel Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#include <ClanLib/Display/Font/font.h>
#include "../fonts.hxx"
#include "object_manager.hxx"
#include "level_resizer.hxx"

namespace EditorNS {

LevelResizer::LevelResizer(ObjectManager* m)
  : SpriteEditorObj("cursors/scroll_cur", "core", &pos), obj_manager (m), 
dragged(false)
{
  sprite.set_align_center();

  pos.x = obj_manager->get_width();
  pos.y = obj_manager->get_height();
}

void
LevelResizer::draw (EditorNS::EditorView* view)
{
  SpriteEditorObj::draw(view);

  if (dragged)
    {
      char str[64];
      snprintf(str, 64, "Level Size: %4dx%4d", obj_manager->get_width(), 
obj_manager->get_height());
      Fonts::pingus_small->print_left( 300, 200, str);
    }
}

void
LevelResizer::set_position_offset(const Vector& offset)
{
  SpriteEditorObj::set_position_offset(offset);
  obj_manager->set_width(int(pos.x));
  obj_manager->set_height(int(pos.y));
}

void
LevelResizer::drop() 
{
  dragged = false; 

  // Round the position to a multiple of 10
  //pos.x = int(pos.x)/10*10;
  //pos.y = int(pos.y)/10*10;
}
    
} // namespace EditorNS

/* EOF */

--- NEW FILE: level_resizer.hxx ---
//  $Id: level_resizer.hxx,v 1.1 2002/11/29 22:54:22 grumbel Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
// 
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#ifndef HEADER_PINGUS_EDITOR_LEVEL_RESIZER_HXX
#define HEADER_PINGUS_EDITOR_LEVEL_RESIZER_HXX

#include "../vector.hxx"
#include "sprite_editorobj.hxx"

namespace EditorNS {

class ObjectManager;

/** This class represents the little drag/drop icon that can be used
    to resize the level */
class LevelResizer : public SpriteEditorObj
{
private:
  Vector pos;
  ObjectManager* obj_manager;
  bool dragged;
public:  
  LevelResizer(ObjectManager* );

  void set_position_offset(const Vector& offset);
  void draw (EditorNS::EditorView *);

  void write_xml(std::ostream&) {}
  EditorObj* duplicate() { return 0; }
  PropertyFrame* get_gui_dialog(Editor*) { return 0; }

  void drag() { dragged = true; }
  void drop();

  float get_z_pos() { return 999999.0f; }

  /** LevelResizer can't be grabed with a rect, since in most
      situations that would be rather unnatural */
  bool is_in_rect(const CL_Rect& rect) { return false; }
private:
  LevelResizer (const LevelResizer&);
  LevelResizer& operator= (const LevelResizer&);
};

} // namespace EditorNS

#endif

/* EOF */

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/Makefile.am,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- Makefile.am 29 Nov 2002 00:17:05 -0000      1.27
+++ Makefile.am 29 Nov 2002 22:54:22 -0000      1.28
@@ -30,6 +30,7 @@
        groundpiece_window.cxx groundpiece_window.hxx \
         generic_property_frame.cxx generic_property_frame.hxx \
        level_property_window.cxx level_property_window.hxx \
+        level_resizer.hxx level_resizer.cxx \
        object_manager.cxx object_manager.hxx \
        object_selector.cxx object_selector.hxx \
        panel.cxx panel.hxx \

Index: editor.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor.cxx,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- editor.cxx  28 Nov 2002 20:09:54 -0000      1.40
+++ editor.cxx  29 Nov 2002 22:54:22 -0000      1.41
@@ -142,7 +142,7 @@
 }
 
 void
-Editor::update (const GameDelta&)
+Editor::update (const GameDelta& delta)
 {
   // Check if the current selection is different then the last one and
   // update the property window if necesarry
@@ -165,6 +165,8 @@
          std::cout << "EditorEvent::editor_show_object_properties (): error: 
multiple objects selected" << std::endl;
        }
     }  
+
+  object_manager->update(delta.get_time());
 
   move_objects();
 }

Index: editor_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor_event.cxx,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- editor_event.cxx    28 Nov 2002 20:09:54 -0000      1.41
+++ editor_event.cxx    29 Nov 2002 22:54:22 -0000      1.42
@@ -45,6 +45,7 @@
 #include "action_window.hxx"
 #include "property_window.hxx"
 #include "level_property_window.hxx"
+#include "level_resizer.hxx"
 #include "../screen_manager.hxx"
 
 namespace EditorNS {
@@ -466,7 +467,8 @@
       i != object_manager->editor_objs.end(); 
       ++i) 
     {
-      selection->add(*i);
+      if (dynamic_cast<LevelResizer*>(*i) == 0)
+        selection->add(*i);
     }
 }
 

Index: level_property_window.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/level_property_window.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- level_property_window.cxx   11 Sep 2002 12:45:58 -0000      1.10
+++ level_property_window.cxx   29 Nov 2002 22:54:22 -0000      1.11
@@ -80,7 +80,10 @@
                      get_client_area ()),
 
     comment_label (CL_Rect(10, 190, 90, 210), "Comment", get_client_area ()),
-    playable_checkbox (CL_Point(10, 210), "Playable", get_client_area ())
+    playable_checkbox (CL_Point(10, 210), "Playable", get_client_area ()),
+    
+    ok_button(CL_Rect(10, 200, 90, 220), "Ok", get_client_area()),
+    cancel_button(CL_Rect(110, 200, 190, 220), "Cancel", get_client_area())
 {
   if (manager->get_playable ())
     playable_checkbox.set_checked (true);

Index: level_property_window.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/level_property_window.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- level_property_window.hxx   27 Sep 2002 11:26:45 -0000      1.8
+++ level_property_window.hxx   29 Nov 2002 22:54:22 -0000      1.9
@@ -65,6 +65,9 @@
   CL_Label    comment_label;
   CL_CheckBox playable_checkbox;
 
+  CL_Button ok_button;
+  CL_Button cancel_button;
+
 public:
   LevelPropertyWindow (CL_Component* parent, ObjectManager*);
   ~LevelPropertyWindow ();

Index: object_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.cxx,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- object_manager.cxx  27 Nov 2002 20:05:42 -0000      1.37
+++ object_manager.cxx  29 Nov 2002 22:54:22 -0000      1.38
@@ -30,6 +30,7 @@
 #include "../worldobjsdata/worldobj_group_data.hxx"
 #include "../prefab.hxx"
 #include "start_pos.hxx"
+#include "level_resizer.hxx"
 #include "object_manager.hxx"
 #include "editor_view.hxx"
 
@@ -84,6 +85,7 @@
   
   delete_all_objs();
   editor_objs.push_back(new StartPos(50, 50));
+  editor_objs.push_back(new LevelResizer(this));
 
   // Set some default actions
   actions = default_actions;
@@ -154,11 +156,22 @@
   start_y_pos = plf->get_starty();
   actions     = plf->get_actions();
 
+  editor_objs.push_back(new LevelResizer(this));
+
   comment = plf->get_comment ();
   difficulty = plf->get_difficulty ();
   playable = plf->get_playable ();
   
   delete plf;
+}
+
+void
+ObjectManager::update(float delta)
+{
+  for (EditorObjIter i = editor_objs.begin(); i != editor_objs.end(); ++i) 
+    {
+      (*i)->update (delta);
+    }
 }
 
 void 

Index: object_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.hxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- object_manager.hxx  7 Oct 2002 13:12:47 -0000       1.22
+++ object_manager.hxx  29 Nov 2002 22:54:22 -0000      1.23
@@ -79,6 +79,7 @@
   /// Save the current level in an xml file
   void save_level_xml (const std::string & filename);
 
+  void update(float delta);
   void draw(EditorView * view);
 
   void delete_all_objs();

Index: property_window.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/property_window.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- property_window.cxx 28 Nov 2002 20:09:54 -0000      1.11
+++ property_window.cxx 29 Nov 2002 22:54:22 -0000      1.12
@@ -64,6 +64,7 @@
       else
        {
          label.show (true);
+         set_title("Property Dialog");
          std::cout << "No GUI" << std::endl;
          current_frame = 0;
          set_client_size (200, 20);

Index: start_pos.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/start_pos.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- start_pos.hxx       28 Nov 2002 20:09:54 -0000      1.9
+++ start_pos.hxx       29 Nov 2002 22:54:22 -0000      1.10
@@ -23,6 +23,7 @@
 #include "../vector.hxx"
 #include "sprite_editorobj.hxx"
 
+/** */
 class StartPos : public SpriteEditorObj
 {
 private:
@@ -31,8 +32,8 @@
 public:
   StartPos(int arg_x_pos, int arg_y_pos);
 
-  virtual void write_xml(std::ostream& xml);
-  virtual EditorObj* duplicate();
+  void write_xml(std::ostream& xml);
+  EditorObj* duplicate();
 
   EditorNS::PropertyFrame* get_gui_dialog(EditorNS::Editor*) { return 0; }  
 private:





reply via email to

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