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;
42 SignalHandlerId m_destroyed;
44 SignalHandlerResult mouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers );
45 typedef Member3<DTreePlanter, const WindowVector&, ButtonIdentifier, ModifierFlags, SignalHandlerResult, &DTreePlanter::mouseDown> MouseDownCaller;
47 m_mouseDown = MouseEventHandlerId();
48 m_destroyed = SignalHandlerId();
50 typedef Member<DTreePlanter, void, &DTreePlanter::destroyed> DestroyedCaller;
64 m_world.LoadSelectedBrushes();
67 GetFilename( buffer, "bt/tp_ent.txt" );
69 FILE* file = fopen( buffer, "rb" );
71 fseek( file, 0, SEEK_END );
72 int len = ftell( file );
73 fseek( file, 0, SEEK_SET );
76 char* buf = new char[len + 1];
78 // parser will do the cleanup, dont delete.
80 fread( buf, len, 1, file );
83 parser.SetScript( buf );
85 ReadConfig( &parser );
91 m_mouseDown = GlobalRadiant().XYWindowMouseDown_connect( makeSignalHandler3( MouseDownCaller(), *this ) );
92 m_destroyed = GlobalRadiant().XYWindowDestroyed_connect( makeSignalHandler( DestroyedCaller(), *this ) );
95 virtual ~DTreePlanter(){
96 if ( !m_mouseDown.isNull() ) {
97 GlobalRadiant().XYWindowMouseDown_disconnect( m_mouseDown );
99 if ( !m_destroyed.isNull() ) {
100 GlobalRadiant().XYWindowDestroyed_disconnect( m_destroyed );
104 #define MT( t ) string_equal_nocase( pToken, t )
105 #define GT pToken = pScriptParser->GetToken( true )
106 #define CT if ( !*pToken ) { return; }
108 void ReadConfig( CScriptParser* pScriptParser ) {
114 if ( *pToken == '}' ) {
118 if ( MT( "model" ) ) {
119 if ( m_numModels >= MAX_TP_MODELS ) {
125 strncpy( m_trees[m_numModels++].name, pToken, MAX_QPATH );
127 else if ( MT( "link" ) ) {
130 strncpy( m_linkName, pToken, MAX_QPATH );
134 else if ( MT( "entity" ) ) {
137 strncpy( m_entType, pToken, MAX_QPATH );
139 else if ( MT( "offset" ) ) {
142 m_offset = atoi( pToken );
144 else if ( MT( "pitch" ) ) {
147 m_minPitch = atoi( pToken );
151 m_maxPitch = atoi( pToken );
155 else if ( MT( "yaw" ) ) {
158 m_minYaw = atoi( pToken );
162 m_maxYaw = atoi( pToken );
166 else if ( MT( "scale" ) ) {
169 m_minScale = static_cast<float>( atof( pToken ) );
173 m_maxScale = static_cast<float>( atof( pToken ) );
177 else if ( MT( "numlinks" ) ) {
180 m_linkNum = atoi( pToken );
185 bool FindDropPoint( vec3_t in, vec3_t out );
186 void DropEntsToGround( void );
187 void MakeChain( int linkNum, const char* linkName );
188 void SelectChain( void );
193 treeModel_t m_trees[MAX_TP_MODELS];
202 char m_entType[MAX_QPATH];
203 char m_linkName[MAX_QPATH];