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:
spog
2006-04-09 17:15:13 +00:00
parent ba55f1bbf6
commit 6ee91d153e
127 changed files with 3723 additions and 2092 deletions

View File

@@ -23,12 +23,81 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define INCLUDED_IBRUSH_H
#include "generic/constant.h"
#include "generic/callback.h"
#include "math/vector.h"
#include "itexdef.h"
namespace scene
{
class Node;
}
#if 0
class IBrushFace
{
public:
virtual const char* GetShader() const = 0;
virtual void SetShader(const char* name) = 0;
virtual const TextureProjection& GetTexdef() const = 0;
virtual void GetTexdef(TextureProjection& projection) const = 0;
virtual void SetTexdef(const TextureProjection& projection) = 0;
virtual void GetFlags(ContentsFlagsValue& flags) const = 0;
virtual void SetFlags(const ContentsFlagsValue& flags) = 0;
virtual void ShiftTexdef(float s, float t) = 0;
virtual void ScaleTexdef(float s, float t) = 0;
virtual void RotateTexdef(float angle) = 0;
virtual void FitTexture(float s_repeat, float t_repeat) = 0;
virtual bool isDetail() const = 0;
virtual void setDetail(bool detail) = 0;
};
class IBrush
{
public:
STRING_CONSTANT(Name, "IBrush");
virtual void reserve(std::size_t count) = 0;
virtual void clear() = 0;
virtual void copy(const IBrush& other) = 0;
virtual IBrushFace* addPlane(const Vector3& p0, const Vector3& p1, const Vector3& p2, const char* shader, const TextureProjection& projection) = 0;
virtual const AABB& localAABB() const = 0;
virtual void removeEmptyFaces() = 0;
};
class IBrushFaceInstance
{
public:
virtual IBrushFace& getFace() = 0;
virtual const IBrushFace& getFace() const = 0;
virtual bool isSelected() const = 0;
virtual void setSelected(SelectionSystem::EComponentMode mode, bool select) const = 0;
};
class IBrushInstance
{
public:
STRING_CONSTANT(Name, "IBrushInstance");
virtual void forEachFaceInstance(const BrushInstanceVisitor& visitor) = 0;
};
#endif
class _QERFaceData
{
public:
_QERFaceData() : contents(0), flags(0), value(0), m_shader("")
{
}
Vector3 m_p0;
Vector3 m_p1;
Vector3 m_p2;
texdef_t m_texdef;
const char* m_shader;
int contents;
int flags;
int value;
};
typedef Callback1<const _QERFaceData&> BrushFaceDataCallback;
class BrushCreator
{
public:
@@ -36,6 +105,8 @@ public:
STRING_CONSTANT(Name, "brush");
virtual scene::Node& createBrush() = 0;
virtual bool useAlternativeTextureProjection() const = 0;
virtual void forEachBrushFace(scene::Node& brush, const BrushFaceDataCallback& callback) = 0;
virtual bool addBrushFace(scene::Node& brush, const _QERFaceData& faceData) = 0;
};
#include "modulesystem.h"

View File

@@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define INCLUDED_ICAMERA_H
#include "generic/constant.h"
#include "generic/callbackfwd.h"
class Matrix4;
@@ -39,8 +40,6 @@ public:
virtual void setFieldOfView(float fieldOfView) = 0;
};
class Callback;
class CameraModel
{
public:

View File

@@ -29,11 +29,30 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
class EntityClass;
typedef Callback1<const char*> KeyObserver;
class EntityKeyValue
{
public:
virtual const char* c_str() const = 0;
virtual void assign(const char* other) = 0;
virtual void attach(const KeyObserver& observer) = 0;
virtual void detach(const KeyObserver& observer) = 0;
};
class Entity
{
public:
STRING_CONSTANT(Name, "Entity");
class Observer
{
public:
virtual void insert(const char* key, EntityKeyValue& value) = 0;
virtual void erase(const char* key, EntityKeyValue& value) = 0;
virtual void clear() { };
};
class Visitor
{
public:
@@ -45,6 +64,8 @@ public:
virtual void setKeyValue(const char* key, const char* value) = 0;
virtual const char* getKeyValue(const char* key) const = 0;
virtual bool isContainer() const = 0;
void attach(Observer& observer);
void detach(Observer& observer);
};
class EntityCopyingVisitor : public Entity::Visitor

View File

@@ -24,9 +24,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <cstddef>
#include "generic/constant.h"
#include "generic/callbackfwd.h"
template<typename FirstArgument>
class Callback1;
typedef Callback1<const char*> ArchiveNameCallback;
typedef Callback1<const char*> FileNameCallback;

View File

@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define INCLUDED_IRENDER_H
#include "generic/constant.h"
#include "generic/callbackfwd.h"
// Rendering states to sort by.
@@ -88,9 +89,6 @@ public:
}
};
template<typename FirstArgument>
class Callback1;
class Renderable;
typedef Callback1<const Renderable&> RenderableCallback;

View File

@@ -24,14 +24,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <cstddef>
#include "generic/constant.h"
#include "signal/signalfwd.h"
template<typename value_type>
class Stack;
template<typename Contained>
class Reference;
class Callback;
namespace scene
{
class Instance;
@@ -105,15 +104,15 @@ namespace scene
virtual void sceneChanged() = 0;
/// \brief Add a \p callback to be invoked when the scene changes.
/// \todo Move to a separate class.
virtual void addSceneChangedCallback(const Callback& callback) = 0;
virtual void addSceneChangedCallback(const SignalHandler& handler) = 0;
/// \brief Invokes all bounds-changed callbacks. Called when the bounds of any instance in the scene change.
/// \todo Move to a separate class.
virtual void boundsChanged() = 0;
/// \brief Add a \p callback to be invoked when the bounds of any instance in the scene change.
virtual void addBoundsChangedCallback(const Callback& callback) = 0;
virtual SignalHandlerId addBoundsChangedCallback(const SignalHandler& boundsChanged) = 0;
/// \brief Remove a \p callback to be invoked when the bounds of any instance in the scene change.
virtual void removeBoundsChangedCallback(const Callback& callback) = 0;
virtual void removeBoundsChangedCallback(SignalHandlerId id) = 0;
virtual TypeId getNodeTypeId(const char* name) = 0;
virtual TypeId getInstanceTypeId(const char* name) = 0;
@@ -208,9 +207,9 @@ inline scene::Graph& GlobalSceneGraph()
return GlobalSceneGraphModule::getTable();
}
inline void AddSceneChangeCallback(const Callback& callback)
inline void AddSceneChangeCallback(const SignalHandler& handler)
{
GlobalSceneGraph().addSceneChangedCallback(callback);
GlobalSceneGraph().addSceneChangedCallback(handler);
}
inline void SceneChangeNotify()
{

View File

@@ -24,15 +24,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <cstddef>
#include "generic/constant.h"
#include "generic/callbackfwd.h"
#include "signal/signalfwd.h"
class Renderer;
class View;
class Callback;
template<typename FirstArgument>
class Callback1;
class Selectable
{
public:
@@ -61,6 +58,7 @@ class Matrix4;
typedef Vector4 Quaternion;
typedef Callback1<const Selectable&> SelectionChangeCallback;
typedef SignalHandler1<const Selectable&> SelectionChangeHandler;
class SelectionSystem
{
@@ -117,7 +115,7 @@ public:
virtual void foreachSelected(const Visitor& visitor) const = 0;
virtual void foreachSelectedComponent(const Visitor& visitor) const = 0;
virtual void addSelectionChangeCallback(const SelectionChangeCallback& callback) = 0;
virtual void addSelectionChangeCallback(const SelectionChangeHandler& handler) = 0;
virtual void NudgeManipulator(const Vector3& nudge, const Vector3& view) = 0;

View File

@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define INCLUDED_ISHADERS_H
#include "generic/constant.h"
#include "generic/callbackfwd.h"
enum
{
@@ -78,8 +79,6 @@ public:
virtual float alphaTest() const = 0;
};
template<typename FirstArgument>
class Callback1;
typedef Callback1<const ShaderLayer&> ShaderLayerCallback;
@@ -133,7 +132,6 @@ public:
virtual qtexture_t* lightFalloffImage() const = 0;
};
class Callback;
typedef struct _GSList GSList;
typedef Callback1<const char*> ShaderNameCallback;

View File

@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <cstddef>
#include "generic/constant.h"
#include "generic/callbackfwd.h"
class UndoMemento
{
@@ -47,8 +48,6 @@ public:
virtual void save(Undoable* undoable) = 0;
};
class Callback;
class UndoTracker
{
public:

View File

@@ -25,8 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <limits>
#include "iscenegraph.h"
class Callback;
#include "generic/callbackfwd.h"
const std::size_t MAPFILE_MAX_CHANGES = std::numeric_limits<std::size_t>::max();

View File

@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define INCLUDED_MODELSKIN_H
#include "generic/constant.h"
#include "generic/callbackfwd.h"
class SkinRemap
{
@@ -34,8 +35,6 @@ public:
}
};
template<typename FirstArgument>
class Callback1;
typedef Callback1<SkinRemap> SkinRemapCallback;
class ModuleObserver;

View File

@@ -23,9 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define INCLUDED_NAMEABLE_H
#include "generic/constant.h"
#include "generic/callbackfwd.h"
template<typename FirstArgument>
class Callback1;
typedef Callback1<const char*> NameCallback;
class Nameable

View File

@@ -23,9 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define INCLUDED_NAMESPACE_H
#include "generic/constant.h"
#include "generic/callbackfwd.h"
template<typename FirstArgument>
class Callback1;
typedef Callback1<const char*> NameCallback;
typedef Callback1<const NameCallback&> NameCallbackCallback;

View File

@@ -23,9 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define INCLUDED_PREFERENCESYSTEM_H
#include "generic/constant.h"
#include "generic/callbackfwd.h"
template<typename FirstArgument>
class Callback1;
typedef Callback1<const char*> StringImportCallback;
typedef Callback1<const StringImportCallback&> StringExportCallback;

View File

@@ -90,8 +90,27 @@ typedef GtkImage* (* PFN_QERAPP_NEWIMAGE) (const char* filename);
// ========================================
namespace scene
{
class Node;
}
class ModuleObserver;
#include "signal/signalfwd.h"
#include "windowobserver.h"
#include "math/vector.h"
typedef SignalHandler3<const WindowVector&, ButtonIdentifier, ModifierFlags> MouseEventHandler;
typedef SignalFwd<MouseEventHandler>::handler_id_type MouseEventHandlerId;
enum VIEWTYPE
{
YZ = 0,
XZ = 1,
XY = 2
};
// the radiant core API
struct _QERFuncTable_1
{
@@ -107,6 +126,8 @@ struct _QERFuncTable_1
const char* (*getGameMode)();
const char* (*getMapName)();
scene::Node& (*getMapWorldEntity)();
float (*getGridSize)();
const char* (*getGameDescriptionKeyValue)(const char* key);
const char* (*getRequiredGameDescriptionKeyValue)(const char* key);
@@ -120,6 +141,12 @@ struct _QERFuncTable_1
void (*attachGameModeObserver)(ModuleObserver& observer);
void (*detachGameModeObserver)(ModuleObserver& observer);
MouseEventHandlerId (*XYWindowMouseDown_connect)(const MouseEventHandler& handler);
void (*XYWindowMouseDown_disconnect)(MouseEventHandlerId id);
VIEWTYPE (*XYWindow_getViewType)();
Vector3 (*XYWindow_windowToWorld)(const WindowVector& position);
const char* (*TextureBrowser_getSelectedShader)();
// GTK+ functions
PFN_QERAPP_MESSAGEBOX m_pfnMessageBox;
PFN_QERAPP_FILEDIALOG m_pfnFileDialog;

View File

@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "math/vector.h"
#include "scenelib.h"
#include "generic/callbackfwd.h"
class SelectionIntersection
{
@@ -281,8 +282,6 @@ inline SelectionTestable* Instance_getSelectionTestable(scene::Instance& instanc
}
template<typename FirstArgument>
class Callback1;
class Plane3;
typedef Callback1<const Plane3&> PlaneCallback;