windstille-devel
[Top][All Lists]
Advanced

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

[Windstille-devel] rev 339 - trunk/src


From: Ingo Ruhnke
Subject: [Windstille-devel] rev 339 - trunk/src
Date: Mon, 17 May 2004 03:35:18 +0200

Author: grumbel
Date: 2004-05-17 03:35:18 +0200 (Mon, 17 May 2004)
New Revision: 339

Added:
   trunk/src/simpleeditor.py
Modified:
   trunk/src/gui_manager.cxx
   trunk/src/layer.cxx
   trunk/src/layer.hxx
   trunk/src/shared_ptr.hxx
   trunk/src/supertux.py
   trunk/src/tile.cxx
   trunk/src/tile.hxx
   trunk/src/tile_selector.cxx
   trunk/src/tile_selector.hxx
   trunk/src/tileset.cxx
   trunk/src/tileset.hxx
Log:
- stuff, still not working

Modified: trunk/src/gui_manager.cxx
===================================================================
--- trunk/src/gui_manager.cxx   2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/gui_manager.cxx   2004-05-17 01:35:18 UTC (rev 339)
@@ -66,6 +66,7 @@
 void
 GUIManager::run()
 {
+  std::cout << "Waiting one second for debugger" << std::endl;
   manager->run();
 }
 

Modified: trunk/src/layer.cxx
===================================================================
--- trunk/src/layer.cxx 2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/layer.cxx 2004-05-17 01:35:18 UTC (rev 339)
@@ -23,18 +23,35 @@
 
 Layer::Layer()
 {
-  std::cout << "Layer()" << std::endl;
+  std::cout << "Layer(empty: " << impl.get() << ")" << std::endl;
 }
 
+Layer::Layer(const Layer& copy)
+  : impl(copy.impl)
+{
+  std::cout << "Layer(copy: " << impl.get() << ")" << std::endl;
+}
+
+Layer&
+Layer::operator=(const Layer& copy)
+{
+  if (this != &copy)
+    {
+      std::cout << "Layer:operator=: old: " << impl.get() << " new: " << 
copy.impl.get() << std::endl;
+      impl = copy.impl;
+    }
+  return *this;
+}
+
 Layer::Layer(SharedPtr<LayerImpl> i)
   : impl(i)
 {
-  std::cout << "Layer(" << this << ")" << std::endl;
+  std::cout << "Layer(#" << impl.get() << ")" << std::endl;
 }
 
 Layer::~Layer()
 {
-  std::cout << "~Layer()" << std::endl;
+  std::cout << "~Layer(" << impl.get() << ")" << std::endl;
 }
 
 void

Modified: trunk/src/layer.hxx
===================================================================
--- trunk/src/layer.hxx 2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/layer.hxx 2004-05-17 01:35:18 UTC (rev 339)
@@ -36,9 +36,12 @@
 private:
 public:
   Layer();
+  Layer(const Layer& copy);
   Layer(SharedPtr<LayerImpl> i);
   ~Layer();
 
+  Layer& operator=(const Layer& copy);
+
   void draw(EditorMapComponent* parent);
   bool has_bounding_rect() const;
   CL_Rect get_bounding_rect();

Modified: trunk/src/shared_ptr.hxx
===================================================================
--- trunk/src/shared_ptr.hxx    2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/shared_ptr.hxx    2004-05-17 01:35:18 UTC (rev 339)
@@ -19,6 +19,9 @@
 
 #ifndef HEADER_SHARED_PTR_HXX
 #define HEADER_SHARED_PTR_HXX
+
+#include <iostream>
+#include <typeinfo>
  
 template<class T>
 class SharedPtrDeleter
@@ -45,7 +48,7 @@
   }  
 
   void del() {
-    delete ptr;
+    //delete ptr;
     ptr = 0;
   }
 
@@ -62,28 +65,23 @@
   int* ref_count;
 
   void inc() {
-    if (ref_count)
-      {
-        *ref_count += 1;
-      }
+    *ref_count += 1;
   }
   
   void dec() {
-    if (ref_count) 
-      {
-        *ref_count -= 1;
-        if (*ref_count == 0) {
-          //deleter->del();
-          delete ref_count;
-          ref_count = 0;
-        }
-      }
+    *ref_count -= 1;
+    if (*ref_count == 0) {
+      std::cout << "SharedPtr: deleting: " << typeid(deleter->ptr).name() << 
std::endl;
+      deleter->del();
+      delete ref_count;
+    }
   }
 public:
   template<class Base> friend class SharedPtr;
 
   SharedPtr()
-    : deleter(0), ref_count(0)
+    : deleter(new SharedPtrDeleterImpl<T>(0)), 
+      ref_count(new int(1))
   {}
 
   template<typename D>
@@ -105,7 +103,7 @@
   SharedPtr<T>& operator= (const SharedPtr<Base>& copy) 
   {
     dec();
-    delete deleter;
+    //delete deleter;
     deleter   = new SharedPtrDeleterImpl<T>(copy.deleter->ptr);
     ref_count = copy.ref_count;
     inc();

Added: trunk/src/simpleeditor.py
===================================================================
--- trunk/src/simpleeditor.py   2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/simpleeditor.py   2004-05-17 01:35:18 UTC (rev 339)
@@ -0,0 +1,47 @@
+##  $Id$
+## 
+##  Flexlay - A Generic 2D Game Editor
+##  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.
+
+from flexlay import *
+
+flexlay = Flexlay()
+
+flexlay.init()
+
+editor = Editor()
+gui = editor.get_gui_manager()
+
+def get_data():
+    print "I got clicked"
+
+button = CL_Button(CL_Rect(CL_Point(50, 150), CL_Size(150, 25)),
+                   "Get Data", gui.get_component())
+connect(button.sig_clicked(), get_data)
+
+def do_quit():
+    gui.quit()
+    
+quit = CL_Button(CL_Rect(CL_Point(50, 250), CL_Size(150, 25)),
+                   "Do Quit", gui.get_component())
+connect(quit.sig_clicked(), do_quit)
+    
+gui.run()
+
+flexlay.deinit()
+
+# EOF #

Modified: trunk/src/supertux.py
===================================================================
--- trunk/src/supertux.py       2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/supertux.py       2004-05-17 01:35:18 UTC (rev 339)
@@ -19,7 +19,10 @@
 
 from flexlay import *
 from sexpr   import *
+import time
 
+time.sleep(1)
+
 def load_game_tiles(tileset, filename):
     "Load game tiles from filename into tileset"
     tree = sexpr_read_from_file(filename)
@@ -110,16 +113,26 @@
 tileset = Tileset(32)
 load_game_tiles(tileset, 
"/home/ingo/cvs/supertux/supertux/data/images/tilesets/supertux.stgt")
 
-window = CL_Window(CL_Rect(50, 50, 350, 300), "My Window", gui.get_component())
-
-tileselector_window = CL_Window(CL_Rect(CL_Point(150, 150), CL_Size(210, 210)),
-                                     "Tile Selector", gui.get_component())
-tileselector = TileSelector(5, 3, gui.get_component())
+# tileselector_window = CL_Window(CL_Rect(CL_Point(150, 150), CL_Size(210, 
210)),
+#                                     "Tile Selector", gui.get_component())
+# tileselector = TileSelector(5, 3, tileselector_window.get_client_area())
 # tileselector.set_tileset(tileset)
-# tileselector.set_tiles(range(1,100))
+#tileselector.set_tiles(range(1,100))
         
 # supertux_gui = SuperTuxGUI()
 
+editor_map = EditorMapComponent(CL_Rect(0, 0, 799, 599), gui.get_component())
+workspace  = Workspace(799, 599)
+editor_map.set_workspace(workspace)
+
+m = EditorMap()
+workspace.set_current_map(m)
+
+tilemap = TilemapLayer(tileset, 20, 10)
+m.add_layer(tilemap.to_layer())
+
+window = CL_Window(CL_Rect(50, 50, 350, 300), "My Window", gui.get_component())
+    
 print "Launching GUI"
 gui.run()
 

Modified: trunk/src/tile.cxx
===================================================================
--- trunk/src/tile.cxx  2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/tile.cxx  2004-05-17 01:35:18 UTC (rev 339)
@@ -29,7 +29,7 @@
 
 extern CL_ResourceManager* resources;
 
-Tile::Tile(const std::string& filename_, 
+Tile::Tile(std::string filename_, 
            const CL_Color& color_, 
            const CL_Color& attribute_color_, 
            unsigned char* arg_colmap)

Modified: trunk/src/tile.hxx
===================================================================
--- trunk/src/tile.hxx  2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/tile.hxx  2004-05-17 01:35:18 UTC (rev 339)
@@ -46,7 +46,7 @@
 
   /** @param filename Surface to use 
    *  @param arg_colmap a 8 char long array */
-  Tile(const std::string& filename, 
+  Tile(std::string filename, 
        const CL_Color& color, 
        const CL_Color& attribute_color, 
        unsigned char* arg_colmap = NULL);

Modified: trunk/src/tile_selector.cxx
===================================================================
--- trunk/src/tile_selector.cxx 2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/tile_selector.cxx 2004-05-17 01:35:18 UTC (rev 339)
@@ -45,6 +45,11 @@
   offset = 0;
 }
 
+TileSelector::~TileSelector()
+{
+  std::cout << "~TileSelector()" << std::endl;
+}
+
 void
 TileSelector::mouse_up(const CL_InputEvent& event)
 {
@@ -105,6 +110,7 @@
 void 
 TileSelector::draw()
 {
+  std::cout << "TileSelector::draw()" << std::endl;
   CL_Display::push_modelview();
   CL_Display::add_translate(0, -offset);
 

Modified: trunk/src/tile_selector.hxx
===================================================================
--- trunk/src/tile_selector.hxx 2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/tile_selector.hxx 2004-05-17 01:35:18 UTC (rev 339)
@@ -48,14 +48,12 @@
 
   Tileset tileset;
 
-#ifdef SWIGPYTHON
-  ~TileSelector();
-#endif
 public:
   /** width and height in number of tiles */
   TileSelector(int width, int height, CL_Component* parent);
+  
+  ~TileSelector();
 
-
   void set_tileset(Tileset t);
   void set_tiles(const Tiles& t);
   

Modified: trunk/src/tileset.cxx
===================================================================
--- trunk/src/tileset.cxx       2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/tileset.cxx       2004-05-17 01:35:18 UTC (rev 339)
@@ -35,6 +35,19 @@
 class TilesetImpl 
 {
 public:
+  TilesetImpl()
+  {
+  }
+
+  ~TilesetImpl()
+  {
+    std::cout << "Tileset: destroy" << std::endl;
+    for(Tiles::iterator i = tiles.begin(); i != tiles.end(); ++i)
+      {
+        delete *i;
+      }
+  }
+
   Tiles tiles;
   int tile_size;
 };
@@ -54,13 +67,13 @@
   impl->tile_size = tile_size_;
 }
 
+Tileset::Tileset(const Tileset& copy)
+  : impl(copy.impl)
+{
+}
+
 Tileset::~Tileset()
 {
-  std::cout << "Tileset: destroy" << std::endl;
-  for(Tiles::iterator i = impl->tiles.begin(); i != impl->tiles.end(); ++i)
-    {
-      delete *i;
-    }
 }
 
 void

Modified: trunk/src/tileset.hxx
===================================================================
--- trunk/src/tileset.hxx       2004-05-16 23:48:30 UTC (rev 338)
+++ trunk/src/tileset.hxx       2004-05-17 01:35:18 UTC (rev 339)
@@ -39,6 +39,8 @@
       scripting to it */
   explicit Tileset(int tile_size_);
 
+  Tileset(const Tileset& copy);
+
   ~Tileset();
 
   /** Check if the tile is already loaded and return it. If it is not





reply via email to

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