windstille-devel
[Top][All Lists]
Advanced

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

[Windstille-devel] rev 342 - trunk/src


From: Ingo Ruhnke
Subject: [Windstille-devel] rev 342 - trunk/src
Date: Tue, 18 May 2004 21:35:23 +0200

Author: grumbel
Date: 2004-05-18 21:35:22 +0200 (Tue, 18 May 2004)
New Revision: 342

Modified:
   trunk/src/clanlib.i
   trunk/src/flexlay.cxx
   trunk/src/globals.cxx
   trunk/src/globals.hxx
   trunk/src/gui_manager.cxx
   trunk/src/shared_ptr.hxx
   trunk/src/sharedptrtest.cxx
   trunk/src/simpleed.cxx
   trunk/src/simpleeditor.py
   trunk/src/supertux.py
   trunk/src/tile.cxx
   trunk/src/tile_editor.cxx
   trunk/src/tile_editor.hxx
   trunk/src/tile_selector.cxx
Log:
- replaced shared_ptr with a non-deleting one, finally working again

Modified: trunk/src/clanlib.i
===================================================================
--- trunk/src/clanlib.i 2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/clanlib.i 2004-05-18 19:35:22 UTC (rev 342)
@@ -1,3 +1,5 @@
+%include "std_string.i"
+
 class CL_Size
 {
 public:

Modified: trunk/src/flexlay.cxx
===================================================================
--- trunk/src/flexlay.cxx       2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/flexlay.cxx       2004-05-18 19:35:22 UTC (rev 342)
@@ -20,6 +20,8 @@
 #include <config.h>
 #include <ClanLib/core.h>
 #include <ClanLib/display.h>
+#include <ClanLib/gui.h>
+#include <ClanLib/guistylesilver.h>
 #include <ClanLib/gl.h>
 #include "globals.hxx"
 #include "flexlay.hxx"
@@ -48,13 +50,12 @@
   CL_SetupGL::init();
 #endif
   CL_SetupDisplay::init();
-
+  CL_SetupGUI::init();
+  
   datadir = "../data/";
 
   window = new CL_DisplayWindow(PACKAGE_STRING,
                                 screen_width, screen_height, fullscreen, 
allow_resize);
-
-  resources = new CL_ResourceManager();
 }
 
 void

Modified: trunk/src/globals.cxx
===================================================================
--- trunk/src/globals.cxx       2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/globals.cxx       2004-05-18 19:35:22 UTC (rev 342)
@@ -25,6 +25,4 @@
 
 int  debug = 0;
 
-CL_ResourceManager* resources = 0;
-
 /* EOF */

Modified: trunk/src/globals.hxx
===================================================================
--- trunk/src/globals.hxx       2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/globals.hxx       2004-05-18 19:35:22 UTC (rev 342)
@@ -32,8 +32,6 @@
 /** homedir => /home/juser/.windstille/ */
 extern std::string homedir;
 
-extern CL_ResourceManager* resources;
-
 extern int   debug;
 
 #endif

Modified: trunk/src/gui_manager.cxx
===================================================================
--- trunk/src/gui_manager.cxx   2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/gui_manager.cxx   2004-05-18 19:35:22 UTC (rev 342)
@@ -42,9 +42,10 @@
 GUIManager::GUIManager()
   : impl(new GUIManagerImpl())
 {
+  std::cout << "Creating GUIManager: " << datadir + "gui/gui.xml" << std::endl;
   impl->slot_container = new CL_SlotContainer();
   impl->resources = new CL_ResourceManager(datadir + "gui/gui.xml", false);
-  impl->style     = new CL_StyleManager_Silver(resources);
+  impl->style     = new CL_StyleManager_Silver(impl->resources);
   impl->manager   = new CL_GUIManager(impl->style);
   current_  = this;
 

Modified: trunk/src/shared_ptr.hxx
===================================================================
--- trunk/src/shared_ptr.hxx    2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/shared_ptr.hxx    2004-05-18 19:35:22 UTC (rev 342)
@@ -20,226 +20,31 @@
 #ifndef HEADER_SHARED_PTR_HXX
 #define HEADER_SHARED_PTR_HXX
 
-#if 1
-#include <boost/shared_ptr.hpp>
-#define SharedPtr boost::shared_ptr
-#else
-#include <iostream>
-#include <typeinfo>
- 
-template<class T>
-class SharedPtrDeleter
-{
-public:
-  T* ptr; 
+#include <assert.h>
 
-  SharedPtrDeleter(T* p) : ptr(p) {}
-  virtual ~SharedPtrDeleter() {}
-  
-  virtual void del() =0;
-};
-
-template<class T>
-class SharedPtrDeleterImpl : public SharedPtrDeleter<T>
-{
-public:
-  SharedPtrDeleterImpl(T* p)
-    : SharedPtrDeleter<T>(p) {}
-
-  ~SharedPtrDeleterImpl()
-  {
-  }  
-
-  void del() {
-    if (ptr)
-      delete ptr;
-    ptr = 0;
-  }
-};
-
-template<class T>
+/** */
+template<typename T>
 class SharedPtr
 {
 private:
-  SharedPtrDeleter<T>* deleter;
-  int* ref_count;
-
-  void inc() {
-    std::cout << "inc: " << (ref_count ? *ref_count : -45) << std::endl;
-
-    if (ref_count)
-      {
-        *ref_count += 1;
-      }
-  }
-  
-  void dec() {
-    std::cout << "dec: " << (ref_count ? *ref_count : -45) << std::endl;
-
-    if (ref_count)
-      {
-        *ref_count -= 1;
-        if (*ref_count == 0) {
-          std::cout << "SharedPtr: deleting: type: "
-                    << typeid(deleter->ptr).name()
-                    << " ptr: " << deleter->ptr
-                    << std::endl;
-          deleter->del();
-          
-          delete ref_count; ref_count = 0;
-          delete deleter;   deleter   = 0;
-        }
-      }
-    else
-      {
-        std::cout << "SharedPtr: null delete" << std::endl;
-      }
-  }
+  T* ptr;
 public:
-  template<class Base> friend class SharedPtr;
+  template<typename Parent> friend class SharedPtr;
 
-  // Constructors
-  SharedPtr()
-    : deleter(0),
-      ref_count(0)
-  {
-    std::cout << "SharedPtr: ctor null" << std::endl;
-  }
-
-  template<typename D>
-  SharedPtr(D* p)
-    : deleter(new SharedPtrDeleterImpl<T>(p)), 
-      ref_count(new int(1))
-  {
-    std::cout << "SharedPtr: ctor: type: "
-              << typeid(deleter->ptr).name()
-              << " ptr: " << deleter->ptr
-              << std::endl;
-  }
+  SharedPtr() : ptr(0) {}
+  SharedPtr(T* p) : ptr(p) {}
   
-  template<class Base>
-  SharedPtr(const SharedPtr<Base>& copy)
-    : deleter(0), ref_count(0)
-  {
-    if (copy.deleter)
-      {
-        deleter   = new SharedPtrDeleterImpl<T>(copy.deleter->ptr);
-        ref_count = copy.ref_count;
-        inc();
-      }
+  template <typename Parent>
+  SharedPtr(const SharedPtr<Parent>& p) : ptr(p.ptr) {}
 
-    if (deleter)
-      {
-        std::cout << "SharedPtr: copy-ctor template: type: "
-                  << typeid(deleter->ptr).name()
-                  << " ptr: " << deleter->ptr
-                  << std::endl;
-      }
-    else
-      {
-        std::cout << "SharedPtr: copy-ctor template null" << std::endl;
-      }
-  }
+  T& operator*() { assert(ptr); return *ptr; }
+  T const& operator*() const { assert(ptr); return *ptr; }
 
-  // Assign
-  template<class Base>
-  SharedPtr<T>& operator= (const SharedPtr<Base>& copy) 
-  {
-    std::cout << "SharedPtr<T>& operator= (const SharedPtr<Base>& copy)" << 
std::endl;
-    if (ref_count != copy.ref_count)
-      {
-        dec();
+  T* operator->() { return ptr; }
+  T const* operator->() const { return ptr; }
 
-        if (copy.deleter)
-          {
-            deleter   = new SharedPtrDeleterImpl<T>(copy.deleter->ptr);
-            ref_count = copy.ref_count;
-            inc();
-          }
-
-        if (deleter)
-          {
-            std::cout << "SharedPtr: assign template: type: "
-                      << typeid(deleter->ptr).name()
-                      << " ptr: " << deleter->ptr
-                      << std::endl;
-          }
-        else
-          {
-            std::cout << "SharedPtr: assign template: null: " << std::endl;
-          }
-      }
-
-    return *this;
-  }
-
-  SharedPtr<T>& operator= (const SharedPtr<T>& copy) 
-  {
-    if (this != &copy)
-      {
-        dec();
-
-        if (copy.deleter)
-          {
-            deleter   = new SharedPtrDeleterImpl<T>(copy.deleter->ptr);
-            ref_count = copy.ref_count;
-            inc();
-          }
-
-        if (deleter)
-          {
-            std::cout << "SharedPtr: assign normal: type: "
-                      << typeid(deleter->ptr).name()
-                      << " ptr: " << deleter->ptr
-                      << std::endl;
-          }
-        else
-          {
-            std::cout << "SharedPtr: assign normal null" << std::endl;
-          }
-      }
-    else
-      {
-        if (deleter)
-          {
-            std::cout << "SharedPtr: self assin: type: "
-                      << typeid(deleter->ptr).name()
-                      << " ptr: " << deleter->ptr
-                      << std::endl;
-          }
-        else
-          {
-            std::cout << "SharedPtr: assign normal null" << std::endl;
-          }
-      }
-
-    return *this;
-  }
-  
-  ~SharedPtr()
-  {
-    dec();
-  }
-
-  //: Dereferencing operator.
-  T& operator*() { return *deleter->ptr; }
-
-  T const& operator*() const { return *deleter->ptr; }
-       
-  //: Indirect member access operator.
-  T* operator->() { return deleter->ptr; }
-
-  T const* operator->() const { return deleter->ptr; }
-
-  T* get() const 
-  {
-    if (deleter) 
-      return deleter->ptr;
-    else
-      return 0; 
-  }
+  T* get() const { return ptr; }
 };
-#endif
 
 #endif
 

Modified: trunk/src/sharedptrtest.cxx
===================================================================
--- trunk/src/sharedptrtest.cxx 2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/sharedptrtest.cxx 2004-05-18 19:35:22 UTC (rev 342)
@@ -78,7 +78,7 @@
   std::cout << "\nInteresting part: " << std::endl;
   {
     std::cout << "### SharedPtr<A> p1;" << std::endl;
-    SharedPtr<B> p1;
+    SharedPtr<A> p1;
     {
       std::cout << "### SharedPtr<A> p(new A());" << std::endl;
       SharedPtr<A> p(new A());

Modified: trunk/src/simpleed.cxx
===================================================================
--- trunk/src/simpleed.cxx      2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/simpleed.cxx      2004-05-18 19:35:22 UTC (rev 342)
@@ -39,31 +39,26 @@
 
   GUIManager* gui = editor.get_gui_manager();
 
+  CL_Button* button = new CL_Button(CL_Rect(CL_Point(50, 50), 
+                                            CL_Size(100, 25)),
+                                    "Hello World", gui->get_component());
+
   EditorMap m;
   Tileset tileset(32);
+  TilemapLayer tilemap(tileset, 20, 10);
+  
+  m.add_layer(tilemap.to_layer());
 
-    std::cout << "\nTilemapLayer: start" << std::endl;
-    TilemapLayer tilemap(tileset, 20, 10);
-    std::cout << "bound1: " << tilemap.get_bounding_rect() << std::endl;
-    Layer l = tilemap.to_layer();
-    Layer l2 = l;
-    std::cout << "bound2: " << l2.get_bounding_rect() << std::endl;
-    std::cout << "adding layer " << std::endl;
-    m.add_layer(l2);
-    std::cout << "layer added" << std::endl;
-    std::cout << "bound4: " << l.get_bounding_rect() << std::endl;
+  TilemapLayer::set_current(tilemap);
 
-  std::cout << "TilemapLayer: end\n" << std::endl;
-
-
   EditorMapComponent editor_map(CL_Rect(0, 0, 799, 599), gui->get_component());
   Workspace workspace(799, 599);
   editor_map.set_workspace(workspace);
   workspace.set_current_map(m);
  
-  CL_Button* button = new CL_Button(CL_Rect(CL_Point(50, 50), 
-                                            CL_Size(100, 25)),
-                                    "Hello World", gui->get_component());
+  CL_Button* button2 = new CL_Button(CL_Rect(CL_Point(50, 150), 
+                                             CL_Size(100, 25)),
+                                     "Quit", gui->get_component());
 
   gui->run();
  

Modified: trunk/src/simpleeditor.py
===================================================================
--- trunk/src/simpleeditor.py   2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/simpleeditor.py   2004-05-18 19:35:22 UTC (rev 342)
@@ -29,6 +29,18 @@
 def get_data():
     print "I got clicked"
 
+m = EditorMap();
+tileset = Tileset(32);
+tilemap = TilemapLayer(tileset, 20, 10);
+m.add_layer(tilemap.to_layer())
+
+TilemapLayer_set_current(tilemap)
+  
+editor_map = EditorMapComponent(CL_Rect(0, 0, 799, 599), gui.get_component())
+workspace = Workspace(799, 599)
+editor_map.set_workspace(workspace)
+workspace.set_current_map(m)
+
 button = CL_Button(CL_Rect(CL_Point(50, 150), CL_Size(150, 25)),
                    "Get Data", gui.get_component())
 connect(button.sig_clicked(), get_data)
@@ -39,7 +51,7 @@
 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()

Modified: trunk/src/supertux.py
===================================================================
--- trunk/src/supertux.py       2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/supertux.py       2004-05-18 19:35:22 UTC (rev 342)
@@ -112,15 +112,7 @@
 
 tileset = Tileset(32)
 load_game_tiles(tileset, 
"/home/ingo/cvs/supertux/supertux/data/images/tilesets/supertux.stgt")
-
-# 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))
-        
-# supertux_gui = SuperTuxGUI()
-
+    
 editor_map = EditorMapComponent(CL_Rect(0, 0, 799, 599), gui.get_component())
 workspace  = Workspace(799, 599)
 editor_map.set_workspace(workspace)
@@ -132,7 +124,9 @@
 m.add_layer(tilemap.to_layer())
 
 window = CL_Window(CL_Rect(50, 50, 350, 300), "My Window", gui.get_component())
-    
+
+supertux_gui = SuperTuxGUI()
+
 print "Launching GUI"
 gui.run()
 

Modified: trunk/src/tile.cxx
===================================================================
--- trunk/src/tile.cxx  2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/tile.cxx  2004-05-18 19:35:22 UTC (rev 342)
@@ -27,8 +27,6 @@
 #include "string_converter.hxx"
 #include "tile.hxx"
 
-extern CL_ResourceManager* resources;
-
 class TileImpl
 {
 public:
@@ -103,7 +101,7 @@
           }
         else
           {
-            impl->sur = CL_Sprite(impl->filename, resources);
+            assert(0);  //impl->sur = CL_Sprite(impl->filename, resources);
           }
         return impl->sur;
       } catch (CL_Error& err) {
@@ -125,8 +123,9 @@
       }
     else
       {
-        CL_SpriteDescription descr(impl->filename, resources);
-        impl->pixelbuffer = 
CL_PixelBuffer(*(descr.get_frames().begin()->first));
+        //CL_SpriteDescription descr(impl->filename, resources);
+        //impl->pixelbuffer = 
CL_PixelBuffer(*(descr.get_frames().begin()->first));
+        assert(0);
       }
     return impl->pixelbuffer;
   }

Modified: trunk/src/tile_editor.cxx
===================================================================
--- trunk/src/tile_editor.cxx   2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/tile_editor.cxx   2004-05-18 19:35:22 UTC (rev 342)
@@ -31,12 +31,6 @@
                                  CL_Size(w, h))), // FIXME: make this editable 
via script
                  parent)
 {
-  try {
-    no_tile = CL_Sprite("tiles/notile", resources);
-  } catch (CL_Error& err) {
-    std::cout << "Fatal Error: Couldn't load 'tiles/notile'" << std::endl;
-  }
-
   tile = 0;
   slots.connect(sig_paint(),      this, &TileEditor::draw);
   slots.connect(sig_mouse_move(), this, &TileEditor::mouse_move);
@@ -51,7 +45,8 @@
 void
 TileEditor::draw()
 {
-  no_tile.draw(0, 0);
+  //no_tile.draw(0, 0);
+  CL_Display::fill_rect(CL_Rect(0, 0, 32, 32), CL_Color(155, 0, 155));
 
   if (tile)
     {

Modified: trunk/src/tile_editor.hxx
===================================================================
--- trunk/src/tile_editor.hxx   2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/tile_editor.hxx   2004-05-18 19:35:22 UTC (rev 342)
@@ -30,7 +30,6 @@
 class TileEditor : public CL_Component
 {
 private:
-  CL_Sprite no_tile;
   Tile* tile;
   CL_SlotContainer slots;
   CL_Point mouse_pos;

Modified: trunk/src/tile_selector.cxx
===================================================================
--- trunk/src/tile_selector.cxx 2004-05-17 15:06:24 UTC (rev 341)
+++ trunk/src/tile_selector.cxx 2004-05-18 19:35:22 UTC (rev 342)
@@ -110,7 +110,6 @@
 void 
 TileSelector::draw()
 {
-  std::cout << "TileSelector::draw()" << std::endl;
   CL_Display::push_modelview();
   CL_Display::add_translate(0, -offset);
 





reply via email to

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