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
22 #include "dialogs/dialogs-gtk.h"
29 #include "funchandlers.h"
31 // for ctf texture changer
32 list<Str> clrList_Blue;
33 list<Str> clrList_Red;
35 BOOL clrLst1Loaded = FALSE;
36 BOOL clrLst2Loaded = FALSE;
40 //========================//
41 // Helper Functions //
42 //========================//
47 if ( !clrLst1Loaded ) {
48 clrLst1Loaded = LoadExclusionList( GetFilename( buffer, "plugins/bt/ctf-blue.txt" ), &clrList_Blue );
49 LoadExclusionList( GetFilename( buffer, "plugins/bt/blue.txt" ), &clrList_Blue );
51 if ( !clrLst2Loaded ) {
52 clrLst2Loaded = LoadExclusionList( GetFilename( buffer, "plugins/bt/ctf-red.txt" ), &clrList_Red );
53 LoadExclusionList( GetFilename( buffer, "plugins/bt/red.txt" ), &clrList_Red );
58 //========================//
60 //========================//
62 void DoCTFColourChanger(){
63 if ( !clrLst1Loaded || !clrLst2Loaded ) {
64 DoMessageBox( "CTF texture lists not found, this function will terminate.", "Error", MB_OK );
68 int ret = DoCTFColourChangeBox();
69 if ( ret == IDCANCEL ) {
73 int cnt = Min( clrList_Blue.size(), clrList_Red.size() );
75 list<Str>::const_iterator Texture_change;
76 list<Str>::const_iterator Texture_new;
80 int eCnt = g_FuncTable.m_pfnGetEntityCount();
83 world.LoadAll( TRUE );
86 Texture_change = clrList_Blue.begin();
87 Texture_new = clrList_Red.begin();
91 Texture_change = clrList_Red.begin();
92 Texture_new = clrList_Blue.begin();
95 for ( int i = 0; i < cnt; i++ )
97 world.ResetTextures( ( *Texture_change ).c_str(), fDummy, fDummy, 0, ( *Texture_new ).c_str(), TRUE );
108 for(list<DEntity*>::const_iterator loopEnt = world.entityList.begin(); loopEnt != world.entityList.end(); loopEnt++)
110 DEntity* e = (*loopEnt);
111 DEPair* epLightColour = e->FindEPairByKey("_color");
115 sscanf(epLightColour->value, "%f %f %f", &r, &g, &b);
116 sprintf(epLightColour->value, "%f %f %f", b, g, r);
117 DMap::RebuildEntity(e);
121 int cnt = g_FuncTable.m_pfnGetEntityCount();
123 for ( int i = 0; i < cnt; i++ )
125 void* ent = g_FuncTable.m_pfnGetEntityHandle( i );
127 for ( epair_t* epList = *g_FuncTable.m_pfnGetEntityKeyValList( ent ); epList; epList = epList->next )
129 if ( !stricmp( "_color", epList->key ) ) {
131 sscanf( epList->value, "%f %f %f", &r, &g, &b );
132 sprintf( epList->value, "%f %f %f", b, g, r );
138 void DoChangeAngles(){
139 int cnt = g_FuncTable.m_pfnGetEntityCount();
141 for ( int i = 0; i < cnt; i++ )
143 void* ent = g_FuncTable.m_pfnGetEntityHandle( i );
145 for ( epair_t* epList = *g_FuncTable.m_pfnGetEntityKeyValList( ent ); epList; epList = epList->next )
147 if ( !stricmp( "angle", epList->key ) ) {
149 sscanf( epList->value, "%f", &angle );
151 while ( angle > 360 )
154 sprintf( epList->value, "%f", angle );
161 int cnt = g_FuncTable.m_pfnGetEntityCount();
163 for ( int i = 0; i < cnt; i++ )
165 void* ent = g_FuncTable.m_pfnGetEntityHandle( i );
167 for ( epair_t* epList = *g_FuncTable.m_pfnGetEntityKeyValList( ent ); epList; epList = epList->next )
169 if ( !stricmp( "classname", epList->key ) ) {
170 if ( !strcmp( epList->value, "team_CTF_redplayer" ) ) {
171 sprintf( epList->value, "team_CTF_blueplayer" );
173 else if ( !strcmp( epList->value, "team_CTF_blueplayer" ) ) {
174 sprintf( epList->value, "team_CTF_redplayer" );
177 if ( !strcmp( epList->value, "team_CTF_redspawn" ) ) {
178 sprintf( epList->value, "team_CTF_bluespawn" );
180 else if ( !strcmp( epList->value, "team_CTF_bluespawn" ) ) {
181 sprintf( epList->value, "team_CTF_redspawn" );
184 if ( !strcmp( epList->value, "team_CTF_redflag" ) ) {
185 sprintf( epList->value, "team_CTF_blueflag" );
187 else if ( !strcmp( epList->value, "team_CTF_blueflag" ) ) {
188 sprintf( epList->value, "team_CTF_redflag" )
191 if ( !strcmp( epList->value, "team_redobelisk" ) ) {
192 sprintf( epList->value, "team_blueobelisk" );
194 else if ( !strcmp( epList->value, "team_blueobelisk" ) ) {
195 sprintf( epList->value, "team_redobelisk" );
207 for(list<DEntity*>::const_iterator ents = world.entityList.begin(); ents != world.entityList.end(); ents++)
209 (*ents)->RemoveFromRadiant();