refactored plugin api; refactored callback library; added signals library
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@44 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
@@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "math/curve.h"
|
||||
#include "stream/stringstream.h"
|
||||
#include "signal/signal.h"
|
||||
#include "selectionlib.h"
|
||||
#include "render.h"
|
||||
#include "stringio.h"
|
||||
@@ -339,8 +340,7 @@ const int NURBS_degree = 3;
|
||||
|
||||
class NURBSCurve
|
||||
{
|
||||
typedef std::set<Callback> Callbacks;
|
||||
Callbacks m_curveChanged;
|
||||
Signal0 m_curveChanged;
|
||||
Callback m_boundsChanged;
|
||||
public:
|
||||
ControlPoints m_controlPoints;
|
||||
@@ -354,18 +354,18 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void attach(const Callback& curveChanged)
|
||||
SignalHandlerId connect(const SignalHandler& curveChanged)
|
||||
{
|
||||
m_curveChanged.insert(curveChanged);
|
||||
curveChanged();
|
||||
return m_curveChanged.connectLast(curveChanged);
|
||||
}
|
||||
void detach(const Callback& curveChanged)
|
||||
void disconnect(SignalHandlerId id)
|
||||
{
|
||||
m_curveChanged.erase(curveChanged);
|
||||
m_curveChanged.disconnect(id);
|
||||
}
|
||||
void notify()
|
||||
{
|
||||
std::for_each(m_curveChanged.begin(), m_curveChanged.end(), CallbackInvoke());
|
||||
m_curveChanged();
|
||||
}
|
||||
|
||||
void tesselate()
|
||||
@@ -437,8 +437,7 @@ public:
|
||||
|
||||
class CatmullRomSpline
|
||||
{
|
||||
typedef std::set<Callback> Callbacks;
|
||||
Callbacks m_curveChanged;
|
||||
Signal0 m_curveChanged;
|
||||
Callback m_boundsChanged;
|
||||
public:
|
||||
ControlPoints m_controlPoints;
|
||||
@@ -450,18 +449,18 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void attach(const Callback& curveChanged)
|
||||
SignalHandlerId connect(const SignalHandler& curveChanged)
|
||||
{
|
||||
m_curveChanged.insert(curveChanged);
|
||||
curveChanged();
|
||||
return m_curveChanged.connectLast(curveChanged);
|
||||
}
|
||||
void detach(const Callback& curveChanged)
|
||||
void disconnect(SignalHandlerId id)
|
||||
{
|
||||
m_curveChanged.erase(curveChanged);
|
||||
m_curveChanged.disconnect(id);
|
||||
}
|
||||
void notify()
|
||||
{
|
||||
std::for_each(m_curveChanged.begin(), m_curveChanged.end(), CallbackInvoke());
|
||||
m_curveChanged();
|
||||
}
|
||||
|
||||
void tesselate()
|
||||
|
||||
@@ -96,7 +96,9 @@ class Doom3Group :
|
||||
|
||||
public:
|
||||
NURBSCurve m_curveNURBS;
|
||||
SignalHandlerId m_curveNURBSChanged;
|
||||
CatmullRomSpline m_curveCatmullRom;
|
||||
SignalHandlerId m_curveCatmullRomChanged;
|
||||
private:
|
||||
mutable AABB m_curveBounds;
|
||||
|
||||
@@ -522,8 +524,8 @@ public:
|
||||
m_curveCatmullRom(m_contained.m_curveCatmullRom.m_controlPointsTransformed, SelectionChangedComponentCaller(*this))
|
||||
{
|
||||
m_contained.instanceAttach(Instance::path());
|
||||
m_contained.m_curveNURBS.attach(CurveEdit::CurveChangedCaller(m_curveNURBS));
|
||||
m_contained.m_curveCatmullRom.attach(CurveEdit::CurveChangedCaller(m_curveCatmullRom));
|
||||
m_contained.m_curveNURBSChanged = m_contained.m_curveNURBS.connect(CurveEdit::CurveChangedCaller(m_curveNURBS));
|
||||
m_contained.m_curveCatmullRomChanged = m_contained.m_curveCatmullRom.connect(CurveEdit::CurveChangedCaller(m_curveCatmullRom));
|
||||
|
||||
StaticRenderableConnectionLines::instance().attach(*this);
|
||||
}
|
||||
@@ -531,8 +533,8 @@ public:
|
||||
{
|
||||
StaticRenderableConnectionLines::instance().detach(*this);
|
||||
|
||||
m_contained.m_curveCatmullRom.detach(CurveEdit::CurveChangedCaller(m_curveCatmullRom));
|
||||
m_contained.m_curveNURBS.detach(CurveEdit::CurveChangedCaller(m_curveNURBS));
|
||||
m_contained.m_curveCatmullRom.disconnect(m_contained.m_curveCatmullRomChanged);
|
||||
m_contained.m_curveNURBS.disconnect(m_contained.m_curveNURBSChanged);
|
||||
m_contained.instanceDetach(Instance::path());
|
||||
}
|
||||
void renderSolid(Renderer& renderer, const VolumeTest& volume) const
|
||||
|
||||
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "entitylib.h"
|
||||
#include <map>
|
||||
|
||||
class KeyObserverMap : public EntityKeyValues::Observer
|
||||
class KeyObserverMap : public Entity::Observer
|
||||
{
|
||||
typedef std::multimap<const char*, KeyObserver, RawStringLess> KeyObservers;
|
||||
KeyObservers m_keyObservers;
|
||||
@@ -34,14 +34,14 @@ public:
|
||||
{
|
||||
m_keyObservers.insert(KeyObservers::value_type(key, observer));
|
||||
}
|
||||
void insert(const char* key, EntityKeyValues::Value& value)
|
||||
void insert(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
for(KeyObservers::const_iterator i = m_keyObservers.find(key); i != m_keyObservers.end() && string_equal((*i).first, key); ++i)
|
||||
{
|
||||
value.attach((*i).second);
|
||||
}
|
||||
}
|
||||
void erase(const char* key, EntityKeyValues::Value& value)
|
||||
void erase(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
for(KeyObservers::const_iterator i = m_keyObservers.find(key); i != m_keyObservers.end() && string_equal((*i).first, key); ++i)
|
||||
{
|
||||
|
||||
@@ -48,11 +48,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
typedef MemberCaller1<KeyValue, const char*, &KeyValue::assign> KeyValueAssignCaller;
|
||||
typedef MemberCaller1<KeyValue, const KeyObserver&, &KeyValue::attach> KeyValueAttachCaller;
|
||||
typedef MemberCaller1<KeyValue, const KeyObserver&, &KeyValue::detach> KeyValueDetachCaller;
|
||||
typedef MemberCaller1<EntityKeyValue, const char*, &EntityKeyValue::assign> KeyValueAssignCaller;
|
||||
typedef MemberCaller1<EntityKeyValue, const KeyObserver&, &EntityKeyValue::attach> KeyValueAttachCaller;
|
||||
typedef MemberCaller1<EntityKeyValue, const KeyObserver&, &EntityKeyValue::detach> KeyValueDetachCaller;
|
||||
|
||||
class NameKeys : public EntityKeyValues::Observer, public Namespaced
|
||||
class NameKeys : public Entity::Observer, public Namespaced
|
||||
{
|
||||
Namespace* m_namespace;
|
||||
EntityKeyValues& m_entity;
|
||||
@@ -60,10 +60,10 @@ class NameKeys : public EntityKeyValues::Observer, public Namespaced
|
||||
NameKeys(const NameKeys& other);
|
||||
NameKeys& operator=(const NameKeys& other);
|
||||
|
||||
typedef std::map<CopiedString, EntityKeyValues::Value*> KeyValues;
|
||||
typedef std::map<CopiedString, EntityKeyValue*> KeyValues;
|
||||
KeyValues m_keyValues;
|
||||
|
||||
void insertName(const char* key, EntityKeyValues::Value& value)
|
||||
void insertName(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
if(m_namespace != 0 && m_keyIsName(key))
|
||||
{
|
||||
@@ -71,7 +71,7 @@ class NameKeys : public EntityKeyValues::Observer, public Namespaced
|
||||
m_namespace->attach(KeyValueAssignCaller(value), KeyValueAttachCaller(value));
|
||||
}
|
||||
}
|
||||
void eraseName(const char* key, EntityKeyValues::Value& value)
|
||||
void eraseName(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
if(m_namespace != 0 && m_keyIsName(key))
|
||||
{
|
||||
@@ -114,12 +114,12 @@ public:
|
||||
m_keyIsName = keyIsName;
|
||||
insertAll();
|
||||
}
|
||||
void insert(const char* key, EntityKeyValues::Value& value)
|
||||
void insert(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
m_keyValues.insert(KeyValues::value_type(key, &value));
|
||||
insertName(key, value);
|
||||
}
|
||||
void erase(const char* key, EntityKeyValues::Value& value)
|
||||
void erase(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
eraseName(key, value);
|
||||
m_keyValues.erase(key);
|
||||
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class TargetKeys : public EntityKeyValues::Observer
|
||||
class TargetKeys : public Entity::Observer
|
||||
{
|
||||
TargetingEntities m_targetingEntities;
|
||||
Callback m_targetsChanged;
|
||||
@@ -236,7 +236,7 @@ public:
|
||||
m_targetsChanged();
|
||||
}
|
||||
|
||||
void insert(const char* key, EntityKeyValues::Value& value)
|
||||
void insert(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
std::size_t index;
|
||||
if(readTargetKey(key, index))
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
targetsChanged();
|
||||
}
|
||||
}
|
||||
void erase(const char* key, EntityKeyValues::Value& value)
|
||||
void erase(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
std::size_t index;
|
||||
if(readTargetKey(key, index))
|
||||
@@ -328,7 +328,7 @@ public:
|
||||
class TargetableInstance :
|
||||
public SelectableInstance,
|
||||
public Targetable,
|
||||
public EntityKeyValues::Observer
|
||||
public Entity::Observer
|
||||
{
|
||||
mutable Vertex3f m_position;
|
||||
EntityKeyValues& m_entity;
|
||||
@@ -368,14 +368,14 @@ public:
|
||||
m_targeting.targetsChanged();
|
||||
}
|
||||
|
||||
void insert(const char* key, EntityKeyValues::Value& value)
|
||||
void insert(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
if(string_equal(key, g_targetable_nameKey))
|
||||
{
|
||||
value.attach(TargetedEntity::TargetnameChangedCaller(m_targeted));
|
||||
}
|
||||
}
|
||||
void erase(const char* key, EntityKeyValues::Value& value)
|
||||
void erase(const char* key, EntityKeyValue& value)
|
||||
{
|
||||
if(string_equal(key, g_targetable_nameKey))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user