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
24 #include "qerplugin.h"
25 #include "signal/isignal.h"
26 #include "string/string.h"
29 #include "ScriptParser.h"
33 const int MAX_QPATH = 64;
35 typedef struct treeModel_s {
39 const int MAX_TP_MODELS = 256;
42 MouseEventHandlerId m_mouseDown;
43 SignalHandlerId m_destroyed;
45 SignalHandlerResult mouseDown(const WindowVector &position, ButtonIdentifier button, ModifierFlags modifiers);
47 typedef Member<DTreePlanter, SignalHandlerResult(const WindowVector &, ButtonIdentifier,
48 ModifierFlags), &DTreePlanter::mouseDown> MouseDownCaller;
52 m_mouseDown = MouseEventHandlerId();
53 m_destroyed = SignalHandlerId();
56 typedef Member<DTreePlanter, void(), &DTreePlanter::destroyed> DestroyedCaller;
71 m_world.LoadSelectedBrushes();
74 GetFilename(buffer, "bt/tp_ent.txt");
76 FILE *file = fopen(buffer, "rb");
78 fseek(file, 0, SEEK_END);
79 int len = ftell(file);
80 fseek(file, 0, SEEK_SET);
83 char *buf = new char[len + 1];
85 // parser will do the cleanup, dont delete.
87 assert(fread(buf, len, 1, file));
90 parser.SetScript(buf);
98 m_mouseDown = GlobalRadiant().XYWindowMouseDown_connect(makeSignalHandler3(MouseDownCaller(), *this));
99 m_destroyed = GlobalRadiant().XYWindowDestroyed_connect(makeSignalHandler(DestroyedCaller(), *this));
102 virtual ~DTreePlanter()
104 if (!m_mouseDown.isNull()) {
105 GlobalRadiant().XYWindowMouseDown_disconnect(m_mouseDown);
107 if (!m_destroyed.isNull()) {
108 GlobalRadiant().XYWindowDestroyed_disconnect(m_destroyed);
112 #define MT(t) string_equal_nocase( pToken, t )
113 #define GT pToken = pScriptParser->GetToken( true )
114 #define CT if ( !*pToken ) { return; }
116 void ReadConfig(CScriptParser *pScriptParser)
123 if (*pToken == '}') {
128 if (m_numModels >= MAX_TP_MODELS) {
135 strncpy(m_trees[m_numModels++].name, pToken, MAX_QPATH);
136 } else if (MT("link")) {
140 strncpy(m_linkName, pToken, MAX_QPATH);
143 } else if (MT("entity")) {
147 strncpy(m_entType, pToken, MAX_QPATH);
148 } else if (MT("offset")) {
152 m_offset = atoi(pToken);
153 } else if (MT("pitch")) {
157 m_minPitch = atoi(pToken);
162 m_maxPitch = atoi(pToken);
165 } else if (MT("yaw")) {
169 m_minYaw = atoi(pToken);
174 m_maxYaw = atoi(pToken);
177 } else if (MT("scale")) {
181 m_minScale = static_cast<float>( atof(pToken));
186 m_maxScale = static_cast<float>( atof(pToken));
189 } else if (MT("numlinks")) {
193 m_linkNum = atoi(pToken);
198 bool FindDropPoint(vec3_t in, vec3_t out);
200 void DropEntsToGround(void);
202 void MakeChain(int linkNum, const char *linkName);
204 void SelectChain(void);
209 treeModel_t m_trees[MAX_TP_MODELS];
218 char m_entType[MAX_QPATH];
219 char m_linkName[MAX_QPATH];