2 BobToolz plugin for GtkRadiant
3 Copyright (C) 2001 Gordon Biggans
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "../include/igl.h"
26 #include "ScriptParser.h"
30 typedef struct treeModel_s {
34 #define MAX_TP_MODELS 256
36 class DTreePlanter : public IWindowListener {
38 virtual bool OnMouseMove(guint32 nFlags, gdouble x, gdouble y);
39 virtual bool OnLButtonDown(guint32 nFlags, gdouble x, gdouble y);
40 virtual bool OnMButtonDown(guint32 nFlags, gdouble x, gdouble y);
41 virtual bool OnRButtonDown(guint32 nFlags, gdouble x, gdouble y);
42 virtual bool OnLButtonUp(guint32 nFlags, gdouble x, gdouble y);
43 virtual bool OnMButtonUp(guint32 nFlags, gdouble x, gdouble y);
44 virtual bool OnRButtonUp(guint32 nFlags, gdouble x, gdouble y);
45 virtual bool OnKeyPressed(char *s) { return false; }
46 virtual bool Paint() { return true; }
47 virtual void Close() { }
66 m_world.LoadSelectedBrushes();
69 GetFilename( buffer, "bt/tp_ent.txt" );
71 FILE* file = fopen( buffer, "rb" );
73 fseek( file, 0, SEEK_END );
74 int len = ftell( file );
75 fseek( file, 0, SEEK_SET );
78 char* buf = new char[len+1];
80 // parser will do the cleanup, dont delete.
82 fread( buf, len, 1, file );
85 parser.SetScript( buf );
87 ReadConfig( &parser );
94 #define MT(t) !stricmp( pToken, t )
95 #define GT pToken = pScriptParser->GetToken( true )
96 #define CT if(!*pToken) { return; }
98 void ReadConfig( CScriptParser* pScriptParser ) {
109 if(m_numModels >= MAX_TP_MODELS) {
115 strncpy( m_trees[m_numModels++].name, pToken, MAX_QPATH );
116 } else if(MT("link")) {
119 strncpy( m_linkName, pToken, MAX_QPATH );
122 } else if(MT("entity")) {
125 strncpy( m_entType, pToken, MAX_QPATH );
126 } else if(MT("offset")) {
129 m_offset = atoi(pToken);
130 } else if(MT("pitch")) {
133 m_minPitch = atoi(pToken);
137 m_maxPitch = atoi(pToken);
140 } else if(MT("yaw")) {
143 m_minYaw = atoi(pToken);
147 m_maxYaw = atoi(pToken);
150 } else if(MT("scale")) {
153 m_minScale = static_cast< float >( atof( pToken ) );
157 m_maxScale = static_cast< float >( atof( pToken ) );
160 } else if(MT("numlinks")) {
163 m_linkNum = atoi( pToken );
168 virtual ~DTreePlanter() {
172 virtual void IncRef() { m_refCount++; }
173 virtual void DecRef() { m_refCount--; if (m_refCount <= 0) delete this; }
177 g_MessageTable.m_pfnHookWindow( this );
178 m_XYWrapper = g_MessageTable.m_pfnGetXYWndWrapper();
185 g_MessageTable.m_pfnUnHookWindow( this );
191 bool FindDropPoint(vec3_t in, vec3_t out);
192 void DropEntsToGround( void );
193 void MakeChain( void );
194 void SelectChain( void );
197 IXYWndWrapper* m_XYWrapper;
200 treeModel_t m_trees[MAX_TP_MODELS];
210 char m_entType[MAX_QPATH];
211 char m_linkName[MAX_QPATH];