]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/bobtoolz/DTreePlanter.h
* fixed a lot of compiler warnings (mostly const char * stuff and use of uninitialize...
[xonotic/netradiant.git] / contrib / bobtoolz / DTreePlanter.h
index 61bc1e8950e50130b2a4a79250aa1954ce0e21d7..9048e60bacda13803996f832fcf961aa3187ff2d 100644 (file)
@@ -20,14 +20,10 @@ 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 "../include/igl.h"
 #include "DEntity.h"
-#include "scriptparser.h"
-#include "mathlib.h"
 #include "misc.h"
+#include "ScriptParser.h"
 
 #define MAX_QPATH 64
 
@@ -37,13 +33,23 @@ typedef struct treeModel_s {
 
 #define MAX_TP_MODELS 256
 
-class DTreePlanter {
-  MouseEventHandlerId m_mouseDown;
+class DTreePlanter : public IWindowListener {
 public:
-       SignalHandlerResult mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers);
-  typedef Member3<DTreePlanter, const WindowVector&, ButtonIdentifier, ModifierFlags, SignalHandlerResult, &DTreePlanter::mouseDown> MouseDownCaller;
-
-  DTreePlanter() {
+       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;
                m_numModels =   0;
                m_offset =              0;
                m_maxPitch =    0;
@@ -55,6 +61,8 @@ public:
                m_autoLink =    false;
                m_linkNum =             0;
 
+               Register();
+
                m_world.LoadSelectedBrushes();
 
                char buffer[256];
@@ -81,16 +89,9 @@ public:
 
                        fclose( file );
                }
-
-    m_mouseDown = GlobalRadiant().XYWindowMouseDown_connect(makeSignalHandler3(MouseDownCaller(), *this));
        }
 
-  virtual ~DTreePlanter()
-  {
-    GlobalRadiant().XYWindowMouseDown_disconnect(m_mouseDown);
-  }
-
-#define MT(t)  string_equal_nocase( pToken, t )
+#define MT(t)  !stricmp( pToken, t )
 #define GT             pToken = pScriptParser->GetToken( true )
 #define CT             if(!*pToken) { return; }
 
@@ -149,11 +150,11 @@ public:
                        } else if(MT("scale")) {
                                GT; CT;
 
-                               m_minScale = static_cast<float>(atof(pToken));
+                               m_minScale = static_cast< float >( atof( pToken ) );
 
                                GT; CT;
 
-                               m_maxScale = static_cast<float>(atof(pToken));
+                               m_maxScale = static_cast< float >( atof( pToken ) );
 
                                m_useScale = true;
                        } else if(MT("numlinks")) {
@@ -164,16 +165,41 @@ 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;
@@ -188,6 +214,7 @@ private:
        float                   m_minScale;
        float                   m_maxScale;
 
+       bool                    m_hooked;
        bool                    m_useScale;
        bool                    m_setAngles;
        bool                    m_autoLink;