[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 340 - trunk/src
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 340 - trunk/src |
Date: |
Mon, 17 May 2004 16:07:36 +0200 |
Author: grumbel
Date: 2004-05-17 16:07:36 +0200 (Mon, 17 May 2004)
New Revision: 340
Added:
trunk/src/sharedptrtest.cxx
trunk/src/sharedptrtest.hxx
trunk/src/simpleed.cxx
Modified:
trunk/src/SConstruct
trunk/src/gui_manager.cxx
trunk/src/gui_manager.hxx
trunk/src/minimap.cxx
trunk/src/object_selector.cxx
trunk/src/shared_ptr.hxx
trunk/src/supertux.py
trunk/src/tile.cxx
trunk/src/tile.hxx
Log:
- fixed up sharedptrs
- added little c++ based editor for testing, since python crashes randomly
Modified: trunk/src/SConstruct
===================================================================
--- trunk/src/SConstruct 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/SConstruct 2004-05-17 14:07:36 UTC (rev 340)
@@ -34,6 +34,55 @@
env.Program('sharedptrtest', 'sharedptrtest.cxx',
CPPPATH=['/home/ingo/run/ClanLib-0.7-current//include/ClanLib-0.7/'])
+env.Program('simpleed',
+ ['simpleed.cxx',
+ 'blitter.cxx',
+ 'command_group.cxx',
+ 'editor.cxx',
+ 'editor_map.cxx',
+ 'editor_map_component.cxx',
+ 'flexlay.cxx',
+ 'globals.cxx',
+ 'layer.cxx',
+ 'graphic_context_state.cxx',
+ 'gui_manager.cxx',
+ 'minimap.cxx',
+ 'object_layer.cxx',
+ 'object_add_command.cxx',
+ 'object_brush.cxx',
+ 'object_delete_command.cxx',
+ 'object_move_command.cxx',
+ 'object_selector.cxx',
+ 'object_transform_command.cxx',
+ 'objmap_object.cxx',
+ 'objmap_select_tool.cxx',
+ 'objmap_sprite_object.cxx',
+ 'paint_command.cxx',
+ 'popup_menu.cxx',
+ 'lispreader.cxx',
+ 'tile.cxx',
+ 'tile_brush.cxx',
+ 'tile_editor.cxx',
+ 'tile_selection.cxx',
+ 'tile_selector.cxx',
+ 'tilemap_paint_tool.cxx',
+ 'tilemap_select_tool.cxx',
+ 'tilemap_tool.cxx',
+ 'tilemap_layer.cxx',
+ 'tileset.cxx',
+ 'tool_manager.cxx',
+ 'workspace.cxx',
+ 'zoom_tool.cxx'],
+ CPPPATH=['..',
'/home/ingo/run/ClanLib-0.7-current//include/ClanLib-0.7/'],
+ LIBPATH=['.', '/home/ingo/run/ClanLib-0.7-current//lib/'],
+ LIBS=['clanCore',
+ 'clanDisplay',
+ 'clanGL',
+ 'clanSignals',
+ 'clanGUI',
+ 'clanGUIStyleSilver'])
+
+
env.SharedLibrary(
target = '_flexlay.so',
source = [
@@ -81,7 +130,7 @@
'workspace.cxx',
'zoom_tool.cxx'],
CPPPATH=['/home/ingo/run/ClanLib-0.7-current//include/ClanLib-0.7/',
- '/usr/include/python2.2/',
+ '/usr/include/python2.3/',
'..'],
LIBPATH=['/home/ingo/run/ClanLib-0.7-current//lib/'],
LIBS=['clanCore',
Modified: trunk/src/gui_manager.cxx
===================================================================
--- trunk/src/gui_manager.cxx 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/gui_manager.cxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -28,33 +28,45 @@
GUIManager* GUIManager::current_ = 0;
+class GUIManagerImpl
+{
+public:
+ std::stack<CL_Component*> components;
+
+ CL_GUIManager* manager;
+ CL_StyleManager* style;
+ CL_ResourceManager* resources;
+ CL_SlotContainer* slot_container;
+};
+
GUIManager::GUIManager()
+ : impl(new GUIManagerImpl())
{
- slot_container = new CL_SlotContainer();
- resources = new CL_ResourceManager(datadir + "gui/gui.xml", false);
- style = new CL_StyleManager_Silver(resources);
- manager = new CL_GUIManager(style);
+ impl->slot_container = new CL_SlotContainer();
+ impl->resources = new CL_ResourceManager(datadir + "gui/gui.xml", false);
+ impl->style = new CL_StyleManager_Silver(resources);
+ impl->manager = new CL_GUIManager(impl->style);
current_ = this;
// Make the manager the first component on the stack
- push_component(manager);
+ push_component(impl->manager);
}
GUIManager::~GUIManager()
{
- gui_pop_component();
+ pop_component();
- delete manager;
+ delete impl->manager;
//delete style; FIXME: Memory hole?!
//delete resources; FIXME: Memory hole?!
- delete slot_container;
+ delete impl->slot_container;
}
void
GUIManager::draw()
{
- if (manager->is_input_enabled())
- manager->show();
+ if (impl->manager->is_input_enabled())
+ impl->manager->show();
}
void
@@ -67,45 +79,57 @@
GUIManager::run()
{
std::cout << "Waiting one second for debugger" << std::endl;
- manager->run();
+ impl->manager->run();
}
CL_Component*
GUIManager::get_component()
{
- return components.top();
+ return impl->components.top();
}
CL_SlotContainer*
GUIManager::get_slot_container()
{
- return slot_container;
+ return impl->slot_container;
}
void
GUIManager::hide()
{
- if (manager->is_input_enabled())
- manager->disable_input();
+ if (impl->manager->is_input_enabled())
+ impl->manager->disable_input();
}
void
GUIManager::show()
{
- if (!manager->is_input_enabled())
- manager->enable_input();
+ if (!impl->manager->is_input_enabled())
+ impl->manager->enable_input();
}
bool
GUIManager::is_visible()
{
- return manager->is_input_enabled();
+ return impl->manager->is_input_enabled();
}
void
GUIManager::quit()
{
- manager->quit();
+ impl->manager->quit();
}
+void
+GUIManager::push_component(CL_Component* c)
+{
+ impl->components.push(c);
+}
+
+void
+GUIManager::pop_component()
+{
+ impl->components.pop();
+}
+
/* EOF */
Modified: trunk/src/gui_manager.hxx
===================================================================
--- trunk/src/gui_manager.hxx 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/gui_manager.hxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -20,24 +20,14 @@
#ifndef HEADER_GUI_MANAGER_HXX
#define HEADER_GUI_MANAGER_HXX
-#include <stack>
+#include "shared_ptr.hxx"
-class CL_GUIManager;
-class CL_StyleManager;
-class CL_ResourceManager;
-class CL_SlotContainer;
+class GUIManagerImpl;
/** */
class GUIManager
{
private:
- std::stack<CL_Component*> components;
-
- CL_GUIManager* manager;
- CL_StyleManager* style;
- CL_ResourceManager* resources;
- CL_SlotContainer* slot_container;
-
static GUIManager* current_;
public:
static GUIManager* current() { return current_; }
@@ -51,8 +41,8 @@
void run();
void quit();
- void push_component(CL_Component* c) { components.push(c); }
- void pop_component() { components.pop(); }
+ void push_component(CL_Component* c);
+ void pop_component();
void hide();
void show();
@@ -60,6 +50,9 @@
CL_Component* get_component();
CL_SlotContainer* get_slot_container();
+
+private:
+ SharedPtr<GUIManagerImpl> impl;
};
#endif
Modified: trunk/src/minimap.cxx
===================================================================
--- trunk/src/minimap.cxx 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/minimap.cxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -21,7 +21,6 @@
#include <ClanLib/Display/display.h>
#include <ClanLib/Display/pixel_format.h>
#include <ClanLib/Display/pixel_buffer.h>
-#include "scripting/editor.hxx"
#include "editor.hxx"
#include "tile.hxx"
#include "tileset.hxx"
Modified: trunk/src/object_selector.cxx
===================================================================
--- trunk/src/object_selector.cxx 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/object_selector.cxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -22,7 +22,6 @@
#include <ClanLib/display.h>
#include "editor_map.hxx"
#include "editor_map_component.hxx"
-#include "scripting/editor.hxx"
#include "object_selector.hxx"
#include "editor.hxx"
#include "object_add_command.hxx"
Modified: trunk/src/shared_ptr.hxx
===================================================================
--- trunk/src/shared_ptr.hxx 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/shared_ptr.hxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -33,7 +33,6 @@
virtual ~SharedPtrDeleter() {}
virtual void del() =0;
- virtual SharedPtrDeleter* clone() =0;
};
template<class T>
@@ -48,13 +47,9 @@
}
void del() {
- //delete ptr;
+ delete ptr;
ptr = 0;
}
-
- SharedPtrDeleter<T>* clone() {
- return new SharedPtrDeleterImpl<T>(ptr);
- }
};
template<class T>
@@ -65,56 +60,156 @@
int* ref_count;
void inc() {
- *ref_count += 1;
+ if (ref_count)
+ {
+ *ref_count += 1;
+ }
}
void dec() {
- *ref_count -= 1;
- if (*ref_count == 0) {
- std::cout << "SharedPtr: deleting: " << typeid(deleter->ptr).name() <<
std::endl;
- deleter->del();
- delete ref_count;
- }
+ 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;
+ }
}
public:
template<class Base> friend class SharedPtr;
+ // Constructors
SharedPtr()
- : deleter(new SharedPtrDeleterImpl<T>(0)),
- ref_count(new int(1))
- {}
+ : 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;
}
template<class Base>
SharedPtr(const SharedPtr<Base>& copy)
+ : deleter(), ref_count(0)
{
- deleter = new SharedPtrDeleterImpl<T>(copy.deleter->ptr);
- ref_count = copy.ref_count;
- inc();
+ if (copy.deleter)
+ {
+ deleter = new SharedPtrDeleterImpl<T>(copy.deleter->ptr);
+ ref_count = copy.ref_count;
+ inc();
+ }
+
+ 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;
+ }
}
+ // Assign
template<class Base>
SharedPtr<T>& operator= (const SharedPtr<Base>& copy)
{
- dec();
- //delete deleter;
- deleter = new SharedPtrDeleterImpl<T>(copy.deleter->ptr);
- ref_count = copy.ref_count;
- inc();
+ if (ref_count != copy.ref_count)
+ {
+ dec();
+ 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;
}
+#if 0
+ SharedPtr<T>& operator= (const SharedPtr<T>& copy)
+ {
+ if (this != ©)
+ {
+ 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;
+ }
+#endif
~SharedPtr()
{
dec();
- //delete deleter;
}
//: Dereferencing operator.
@@ -127,7 +222,13 @@
T const* operator->() const { return deleter->ptr; }
- T* get() const { return deleter->ptr; }
+ T* get() const
+ {
+ if (deleter)
+ return deleter->ptr;
+ else
+ return 0;
+ }
};
#endif
Added: trunk/src/sharedptrtest.cxx
===================================================================
--- trunk/src/sharedptrtest.cxx 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/sharedptrtest.cxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -0,0 +1,66 @@
+// $Id$
+//
+// 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 <iostream>
+#include <ClanLib/Core/System/sharedptr.h>
+#include "sharedptrtest.hxx"
+
+class B
+{
+public:
+ B() { std::cout << "B(" << this << ")" << std::endl; }
+ virtual ~B() { std::cout << "~B(" << this << ")" << std::endl; }
+};
+
+class A : public B
+{
+public:
+ A() { std::cout << "A(" << this << ")" << std::endl; }
+ virtual ~A() { std::cout << "~A(" << this << ")" << std::endl; }
+};
+
+class C;
+
+int main()
+{
+ SharedPtr<A> p0_;
+ SharedPtr<A> p1_;
+ SharedPtr<B> p2_(p0_);
+ SharedPtr<B> p3_(p1_);
+
+ SharedPtr<B> p0(new B());
+ {
+ SharedPtr<B> ptr0(new A());
+ }
+ {
+ SharedPtr<A> aptr0(new A());
+ {
+ p0_ = p1_;
+ SharedPtr<B> ptr1(new B());
+ {
+ SharedPtr<B> ptr2 = ptr1;
+ SharedPtr<B> ptr1 = ptr2;
+ ptr1 = aptr0;
+ p0 = aptr0;
+ }
+ }
+ }
+}
+
+/* EOF */
Added: trunk/src/sharedptrtest.hxx
===================================================================
--- trunk/src/sharedptrtest.hxx 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/sharedptrtest.hxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -0,0 +1,27 @@
+// $Id$
+//
+// 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_SHAREDPTRTEST_HXX
+#define HEADER_SHAREDPTRTEST_HXX
+
+#include "shared_ptr.hxx"
+
+#endif
+
+/* EOF */
Added: trunk/src/simpleed.cxx
===================================================================
--- trunk/src/simpleed.cxx 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/simpleed.cxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -0,0 +1,45 @@
+// $Id$
+//
+// 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 <string>
+#include <ClanLib/core.h>
+#include <ClanLib/gui.h>
+#include "editor.hxx"
+#include "gui_manager.hxx"
+#include "flexlay.hxx"
+
+int main()
+{
+ Flexlay flexlay;
+ flexlay.init();
+
+ Editor editor;
+
+ 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());
+
+ gui->run();
+
+ flexlay.deinit();
+}
+
+/* EOF */
Modified: trunk/src/supertux.py
===================================================================
--- trunk/src/supertux.py 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/supertux.py 2004-05-17 14:07:36 UTC (rev 340)
@@ -131,7 +131,7 @@
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())
+# 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-17 01:35:18 UTC (rev 339)
+++ trunk/src/tile.cxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -29,23 +29,43 @@
extern CL_ResourceManager* resources;
+class TileImpl
+{
+public:
+ CL_Sprite sur;
+ CL_PixelBuffer pixelbuffer;
+
+ /** Color used for the minimap to represent this tile */
+ CL_Color color;
+
+ /** Color used on 'Show Attributes', ie. to represent walkable areas
+ and such */
+ CL_Color attribute_color;
+
+ unsigned char colmap[8];
+
+ std::string filename;
+};
+
Tile::Tile(std::string filename_,
const CL_Color& color_,
const CL_Color& attribute_color_,
unsigned char* arg_colmap)
- : color(color_),
- attribute_color(attribute_color_),
- filename(filename_)
+ : impl(new TileImpl())
{
+ impl->color = color_;
+ impl->attribute_color = attribute_color_;
+ impl->filename = filename_;
+
// FIXME: Kind of evil singular value
- if (color == CL_Color(254, 254, 254, 254))
+ if (impl->color == CL_Color(254, 254, 254, 254))
{
- color = calc_color();
+ impl->color = calc_color();
}
//sur.set_alignment(origin_center, 0, 0);
if (arg_colmap)
- memcpy(colmap, arg_colmap, 8);
+ memcpy(impl->colmap, arg_colmap, 8);
}
Tile::~Tile()
@@ -55,37 +75,37 @@
CL_Color
Tile::get_color()
{
- return color;
+ return impl->color;
}
CL_Color
Tile::get_attribute_color()
{
- return attribute_color;
+ return impl->attribute_color;
}
CL_Sprite&
Tile::get_sprite()
{
- if (sur)
+ if (impl->sur)
{
- return sur;
+ return impl->sur;
}
else
{
try {
//std::cout << "Loading Tile: " << filename << std::endl;
- if (has_suffix(filename, ".png") || has_suffix(filename, ".jpg"))
+ if (has_suffix(impl->filename, ".png") || has_suffix(impl->filename,
".jpg"))
{
CL_SpriteDescription desc;
desc.add_frame(new CL_PixelBuffer(get_pixelbuffer()), true);
- sur = CL_Sprite(desc);
+ impl->sur = CL_Sprite(desc);
}
else
{
- sur = CL_Sprite(filename, resources);
+ impl->sur = CL_Sprite(impl->filename, resources);
}
- return sur;
+ return impl->sur;
} catch (CL_Error& err) {
std::cout << "Tile: CL_Error: " << err.message << std::endl;
assert(0);
@@ -96,19 +116,19 @@
CL_PixelBuffer
Tile::get_pixelbuffer()
{
- if (pixelbuffer)
- return pixelbuffer;
+ if (impl->pixelbuffer)
+ return impl->pixelbuffer;
{
- if (has_suffix(filename, ".png") || has_suffix(filename, ".jpg"))
+ if (has_suffix(impl->filename, ".png") || has_suffix(impl->filename,
".jpg"))
{
- pixelbuffer = CL_PixelBuffer(*CL_ProviderFactory::load(filename));
+ impl->pixelbuffer =
CL_PixelBuffer(*CL_ProviderFactory::load(impl->filename));
}
else
{
- CL_SpriteDescription descr(filename, resources);
- pixelbuffer = CL_PixelBuffer(*(descr.get_frames().begin()->first));
+ CL_SpriteDescription descr(impl->filename, resources);
+ impl->pixelbuffer =
CL_PixelBuffer(*(descr.get_frames().begin()->first));
}
- return pixelbuffer;
+ return impl->pixelbuffer;
}
}
@@ -168,4 +188,29 @@
static_cast<int>(alpha / len));
}
+bool
+Tile::get_col(unsigned char x, unsigned char y)
+{
+ assert(x < 8);
+ assert(y < 8);
+ return (impl->colmap[y] & (1 << (7-x)));
+}
+
+void
+Tile::set_col(unsigned char x, unsigned char y, bool val)
+{
+ assert(x < 8);
+ assert(y < 8);
+ if (val)
+ impl->colmap[y] |= (1 << (7-x));
+ else
+ impl->colmap[y] &= ~(1 << (7-x));
+}
+
+std::string
+Tile::get_filename() const
+{
+ return impl->filename;
+}
+
/* EOF */
Modified: trunk/src/tile.hxx
===================================================================
--- trunk/src/tile.hxx 2004-05-17 01:35:18 UTC (rev 339)
+++ trunk/src/tile.hxx 2004-05-17 14:07:36 UTC (rev 340)
@@ -23,27 +23,15 @@
#include <assert.h>
#include <ClanLib/Display/sprite.h>
#include <ClanLib/Display/pixel_buffer.h>
+#include "shared_ptr.hxx"
+class TileImpl;
+
/** A Tile is a surface or sprite together with meta information for
collision (aka colmap), walkability or such. */
class Tile
{
-private:
- CL_Sprite sur;
- CL_PixelBuffer pixelbuffer;
-
- /** Color used for the minimap to represent this tile */
- CL_Color color;
-
- /** Color used on 'Show Attributes', ie. to represent walkable areas
- and such */
- CL_Color attribute_color;
-
- std::string filename;
-
public:
- unsigned char colmap[8];
-
/** @param filename Surface to use
* @param arg_colmap a 8 char long array */
Tile(std::string filename,
@@ -62,26 +50,15 @@
CL_Color get_color();
CL_Color get_attribute_color();
- std::string get_filename() const { return filename; }
+ std::string get_filename() const;
- inline bool get_col(unsigned char x, unsigned char y)
- {
- assert(x < 8);
- assert(y < 8);
- return (colmap[y] & (1 << (7-x)));
- }
+ bool get_col(unsigned char x, unsigned char y);
+ void set_col(unsigned char x, unsigned char y, bool val);
- inline void set_col(unsigned char x, unsigned char y, bool val)
- {
- assert(x < 8);
- assert(y < 8);
- if (val)
- colmap[y] |= (1 << (7-x));
- else
- colmap[y] &= ~(1 << (7-x));
- }
-
CL_Color calc_color();
+
+private:
+ SharedPtr<TileImpl> impl;
};
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 340 - trunk/src,
Ingo Ruhnke <=