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 "qerplugin.h"
24 #include "signal/isignal.h"
25 #include "string/string.h"
28 #include "scriptparser.h"
34 typedef struct treeModel_s {
38 #define MAX_TP_MODELS 256
41 MouseEventHandlerId m_mouseDown;
43 SignalHandlerResult mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers);
44 typedef Member3<DTreePlanter, const WindowVector&, ButtonIdentifier, ModifierFlags, SignalHandlerResult, &DTreePlanter::mouseDown> MouseDownCaller;
58 m_world.LoadSelectedBrushes();
61 GetFilename( buffer, "bt/tp_ent.txt" );
63 FILE* file = fopen( buffer, "rb" );
65 fseek( file, 0, SEEK_END );
66 int len = ftell( file );
67 fseek( file, 0, SEEK_SET );
70 char* buf = new char[len+1];
72 // parser will do the cleanup, dont delete.
74 fread( buf, len, 1, file );
77 parser.SetScript( buf );
79 ReadConfig( &parser );
85 m_mouseDown = GlobalRadiant().XYWindowMouseDown_connect(makeSignalHandler3(MouseDownCaller(), *this));
88 virtual ~DTreePlanter()
90 GlobalRadiant().XYWindowMouseDown_disconnect(m_mouseDown);
93 #define MT(t) string_equal_nocase( pToken, t )
94 #define GT pToken = pScriptParser->GetToken( true )
95 #define CT if(!*pToken) { return; }
97 void ReadConfig( CScriptParser* pScriptParser ) {
108 if(m_numModels >= MAX_TP_MODELS) {
114 strncpy( m_trees[m_numModels++].name, pToken, MAX_QPATH );
115 } else if(MT("link")) {
118 strncpy( m_linkName, pToken, MAX_QPATH );
121 } else if(MT("entity")) {
124 strncpy( m_entType, pToken, MAX_QPATH );
125 } else if(MT("offset")) {
128 m_offset = atoi(pToken);
129 } else if(MT("pitch")) {
132 m_minPitch = atoi(pToken);
136 m_maxPitch = atoi(pToken);
139 } else if(MT("yaw")) {
142 m_minYaw = atoi(pToken);
146 m_maxYaw = atoi(pToken);
149 } else if(MT("scale")) {
152 m_minScale = static_cast<float>(atof(pToken));
156 m_maxScale = static_cast<float>(atof(pToken));
159 } else if(MT("numlinks")) {
162 m_linkNum = atoi( pToken );
167 bool FindDropPoint(vec3_t in, vec3_t out);
168 void DropEntsToGround( void );
169 void MakeChain( void );
170 void SelectChain( void );
175 treeModel_t m_trees[MAX_TP_MODELS];
184 char m_entType[MAX_QPATH];
185 char m_linkName[MAX_QPATH];