X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=contrib%2Fbobtoolz%2FDTreePlanter.h;h=104216608a1739c249ecba6091b626311ac7a68a;hp=87d0d6c8b71e76c084e0dbff99fa7e7c586f4b2d;hb=68159d9ed443f990fecf207847408a673eb641f7;hpb=12b372f89ce109a4db9d510884fbe7d05af79870 diff --git a/contrib/bobtoolz/DTreePlanter.h b/contrib/bobtoolz/DTreePlanter.h index 87d0d6c8..10421660 100644 --- a/contrib/bobtoolz/DTreePlanter.h +++ b/contrib/bobtoolz/DTreePlanter.h @@ -20,6 +20,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #ifndef __DTREE_H__ #define __DTREE_H__ +#include "qerplugin.h" +#include "signal/isignal.h" +#include "string/string.h" + +#include "DEntity.h" +#include "ScriptParser.h" +#include "mathlib.h" +#include "misc.h" #define MAX_QPATH 64 @@ -29,23 +37,20 @@ typedef struct treeModel_s { #define MAX_TP_MODELS 256 -class DTreePlanter : public IWindowListener { +class DTreePlanter { + MouseEventHandlerId m_mouseDown; + SignalHandlerId m_destroyed; public: - virtual bool OnMouseMove(guint32 nFlags, gdouble x, gdouble y); - virtual bool OnLButtonDown(guint32 nFlags, gdouble x, gdouble y); - virtual bool OnMButtonDown(guint32 nFlags, gdouble x, gdouble y); - virtual bool OnRButtonDown(guint32 nFlags, gdouble x, gdouble y); - virtual bool OnLButtonUp(guint32 nFlags, gdouble x, gdouble y); - virtual bool OnMButtonUp(guint32 nFlags, gdouble x, gdouble y); - virtual bool OnRButtonUp(guint32 nFlags, gdouble x, gdouble y); - virtual bool OnKeyPressed(char *s) { return false; } - virtual bool Paint() { return true; } - virtual void Close() { } - - DTreePlanter() { - m_refCount = 1; - m_hooked = false; - m_XYWrapper = NULL; + SignalHandlerResult mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers); + typedef Member3 MouseDownCaller; + void destroyed() + { + m_mouseDown = MouseEventHandlerId(); + m_destroyed = SignalHandlerId(); + } + typedef Member DestroyedCaller; + + DTreePlanter() { m_numModels = 0; m_offset = 0; m_maxPitch = 0; @@ -57,8 +62,6 @@ public: m_autoLink = false; m_linkNum = 0; - Register(); - m_world.LoadSelectedBrushes(); char buffer[256]; @@ -85,9 +88,24 @@ public: fclose( file ); } + + m_mouseDown = GlobalRadiant().XYWindowMouseDown_connect(makeSignalHandler3(MouseDownCaller(), *this)); + m_destroyed = GlobalRadiant().XYWindowDestroyed_connect(makeSignalHandler(DestroyedCaller(), *this)); } -#define MT(t) !stricmp( pToken, t ) + virtual ~DTreePlanter() + { + if(!m_mouseDown.isNull()) + { + GlobalRadiant().XYWindowMouseDown_disconnect(m_mouseDown); + } + if(!m_destroyed.isNull()) + { + GlobalRadiant().XYWindowDestroyed_disconnect(m_destroyed); + } + } + +#define MT(t) string_equal_nocase( pToken, t ) #define GT pToken = pScriptParser->GetToken( true ) #define CT if(!*pToken) { return; } @@ -161,41 +179,16 @@ public: } while( true ); } - virtual ~DTreePlanter() { - UnRegister(); - } - - virtual void IncRef() { m_refCount++; } - virtual void DecRef() { m_refCount--; if (m_refCount <= 0) delete this; } - - void Register() { - if(!m_hooked) { - g_MessageTable.m_pfnHookWindow( this ); - m_XYWrapper = g_MessageTable.m_pfnGetXYWndWrapper(); - m_hooked = true; - } - } - - void UnRegister() { - if(m_hooked) { - g_MessageTable.m_pfnUnHookWindow( this ); - m_XYWrapper = NULL; - m_hooked = false; - } - } - bool FindDropPoint(vec3_t in, vec3_t out); void DropEntsToGround( void ); void MakeChain( void ); void SelectChain( void ); private: - IXYWndWrapper* m_XYWrapper; DEntity m_world; treeModel_t m_trees[MAX_TP_MODELS]; - int m_refCount; int m_numModels; int m_offset; int m_maxPitch; @@ -210,7 +203,6 @@ private: float m_minScale; float m_maxScale; - bool m_hooked; bool m_useScale; bool m_setAngles; bool m_autoLink;