X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=contrib%2Fufoaiplug%2Fufoai.cpp;h=392fc9e1a1f33e06cb7d6f79f0b481fb13573850;hb=3cc39e2cbe3639e4c3e6a0dff6b3d41bd6b4732c;hp=e2372dd0e0d44fece0d8942cee0a25e387414b56;hpb=5e882b271373293f57552853a963165fec9bba8f;p=xonotic%2Fnetradiant.git diff --git a/contrib/ufoaiplug/ufoai.cpp b/contrib/ufoaiplug/ufoai.cpp index e2372dd0..392fc9e1 100644 --- a/contrib/ufoaiplug/ufoai.cpp +++ b/contrib/ufoaiplug/ufoai.cpp @@ -1,20 +1,20 @@ /* -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "ufoai.h" #include "ufoai_level.h" @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#define PLUGIN_VERSION "0.1" +#define PLUGIN_VERSION "0.4" #include "ifilter.h" #include "ibrush.h" @@ -44,142 +44,121 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "ieclass.h" class UFOAIPluginDependencies : - public GlobalRadiantModuleRef, // basic class for all other module refs - public GlobalUndoModuleRef, // used to say radiant that something has changed and to undo that - public GlobalSceneGraphModuleRef, // necessary to handle data in the mapfile (change, retrieve data) - public GlobalEntityModuleRef, // to access and modify the entities - public GlobalEntityClassManagerModuleRef + public GlobalRadiantModuleRef, // basic class for all other module refs + public GlobalUndoModuleRef, // used to say radiant that something has changed and to undo that + public GlobalSceneGraphModuleRef, // necessary to handle data in the mapfile (change, retrieve data) + public GlobalEntityModuleRef, // to access and modify the entities + public GlobalEntityClassManagerModuleRef { public: - UFOAIPluginDependencies(void) : - GlobalEntityModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entities")), - GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass")) - { - } +UFOAIPluginDependencies( void ) : + GlobalEntityModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entities" ) ), + GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ){ +} }; namespace UFOAI { - GtkWindow* g_mainwnd; + ui::Window g_mainwnd; - const char* init(void* hApp, void* pMainWidget) - { - g_mainwnd = GTK_WINDOW(pMainWidget); - return "Initializing GTKRadiant UFOAI plugin"; +const char* init( void* hApp, void* pMainWidget ){ + g_mainwnd = ui::Window(GTK_WINDOW( pMainWidget )); + return "Initializing GTKRadiant UFOAI plugin"; +} +const char* getName(){ + return "UFO:AI"; +} +const char* getCommandList(){ + /*GlobalRadiant().getGameName()*/ + return "About;-;Worldspawn reset;Worldspawn;Perform check;-;Level 1;Level 2;Level 3;Level 4;Level 5;Level 6;Level 7;Level 8;-;StepOn;ActorClip;WeaponClip;Nodraw"; +} +const char* getCommandTitleList(){ + return ""; +} +void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ + char *message = NULL; + if ( string_equal( command, "About" ) ) { + std::string version_string = "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__ + "\nRadiant version: " +radiant::version()+ + "\nPlugin version: " PLUGIN_VERSION + "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n"; + GlobalRadiant().m_pfnMessageBox( g_mainwnd, + version_string.c_str(), "About", + eMB_OK, eMB_ICONDEFAULT ); } - const char* getName() - { - return "UFO:AI"; + else if ( string_equal( command, "Level 1" ) ) { + filter_level( CONTENTS_LEVEL1 ); } - const char* getCommandList() - { - /*GlobalRadiant().getGameName()*/ - return "About;-;Worldspawn reset (day);Worldspawn reset (night);Worldspawn (day);Worldspawn (night);Perform check;-;Level 1;Level 2;Level 3;Level 4;Level 5;Level 6;Level 7;Level 8;-;StepOn;ActorClip"; + else if ( string_equal( command, "Level 2" ) ) { + filter_level( CONTENTS_LEVEL2 ); } - const char* getCommandTitleList() - { - return ""; + else if ( string_equal( command, "Level 3" ) ) { + filter_level( CONTENTS_LEVEL3 ); } - void dispatch(const char* command, float* vMin, float* vMax, bool bSingleBrush) - { - char *message = NULL; - if(string_equal(command, "About")) - { - GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_mainwnd), - "UFO:AI Plugin (http://www.ufoai.net)\nBuild: " __DATE__ "\nRadiant version: " RADIANT_VERSION "\nPlugin version: " PLUGIN_VERSION "\n", "About", - eMB_OK, eMB_ICONDEFAULT); - } - else if(string_equal(command, "Level 1")) - { - filter_level(CONTENTS_LEVEL1); - } - else if(string_equal(command, "Level 2")) - { - filter_level(CONTENTS_LEVEL2); - } - else if(string_equal(command, "Level 3")) - { - filter_level(CONTENTS_LEVEL3); - } - else if(string_equal(command, "Worldspawn (day)")) - { - assign_default_values_to_worldspawn(false, true, &message); - } - else if(string_equal(command, "Worldspawn (night)")) - { - assign_default_values_to_worldspawn(false, false, &message); - } - else if(string_equal(command, "Worldspawn reset (day)")) - { - assign_default_values_to_worldspawn(true, true, &message); - } - else if(string_equal(command, "Worldspawn reset (night)")) - { - assign_default_values_to_worldspawn(true, false, &message); - } - else if(string_equal(command, "Perform check")) - { - check_map_values(&message); - } - else if(string_equal(command, "Level 4")) - { - filter_level(CONTENTS_LEVEL4); - } - else if(string_equal(command, "Level 5")) - { - filter_level(CONTENTS_LEVEL5); - } - else if(string_equal(command, "Level 6")) - { - filter_level(CONTENTS_LEVEL6); - } - else if(string_equal(command, "Level 7")) - { - filter_level(CONTENTS_LEVEL7); - } - else if(string_equal(command, "Level 8")) - { - filter_level(CONTENTS_LEVEL8); - } - else if(string_equal(command, "StepOn")) - { - filter_stepon(); - } - else if(string_equal(command, "ActorClip")) - { - filter_actorclip(); - } - - if (message != NULL) - { - GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_mainwnd), - message, "Note", - eMB_OK, eMB_ICONDEFAULT); - } - SceneChangeNotify(); + else if ( string_equal( command, "Worldspawn" ) ) { + assign_default_values_to_worldspawn( false, &message ); + } + else if ( string_equal( command, "Worldspawn reset" ) ) { + assign_default_values_to_worldspawn( true, &message ); + } + else if ( string_equal( command, "Perform check" ) ) { + check_map_values( &message ); + } + else if ( string_equal( command, "Level 4" ) ) { + filter_level( CONTENTS_LEVEL4 ); + } + else if ( string_equal( command, "Level 5" ) ) { + filter_level( CONTENTS_LEVEL5 ); + } + else if ( string_equal( command, "Level 6" ) ) { + filter_level( CONTENTS_LEVEL6 ); + } + else if ( string_equal( command, "Level 7" ) ) { + filter_level( CONTENTS_LEVEL7 ); + } + else if ( string_equal( command, "Level 8" ) ) { + filter_level( CONTENTS_LEVEL8 ); + } + else if ( string_equal( command, "StepOn" ) ) { + filter_stepon(); + } + else if ( string_equal( command, "ActorClip" ) ) { + filter_actorclip(); } + else if ( string_equal( command, "WeaponClip" ) ) { + filter_weaponclip(); + } + else if ( string_equal( command, "NoDraw" ) ) { + filter_nodraw(); + } + + if ( message != NULL ) { + GlobalRadiant().m_pfnMessageBox( g_mainwnd, + message, "Note", + eMB_OK, eMB_ICONDEFAULT ); + } + SceneChangeNotify(); +} } // namespace class UFOAIModule : public TypeSystemRef { - _QERPluginTable m_plugin; +_QERPluginTable m_plugin; public: - typedef _QERPluginTable Type; - STRING_CONSTANT(Name, "UFO:AI"); - - UFOAIModule() - { - m_plugin.m_pfnQERPlug_Init = &UFOAI::init; - m_plugin.m_pfnQERPlug_GetName = &UFOAI::getName; - m_plugin.m_pfnQERPlug_GetCommandList = &UFOAI::getCommandList; - m_plugin.m_pfnQERPlug_GetCommandTitleList = &UFOAI::getCommandTitleList; - m_plugin.m_pfnQERPlug_Dispatch = &UFOAI::dispatch; - } - _QERPluginTable* getTable() - { - return &m_plugin; - } +typedef _QERPluginTable Type; +STRING_CONSTANT( Name, "UFO:AI" ); + +UFOAIModule(){ + m_plugin.m_pfnQERPlug_Init = &UFOAI::init; + m_plugin.m_pfnQERPlug_GetName = &UFOAI::getName; + m_plugin.m_pfnQERPlug_GetCommandList = &UFOAI::getCommandList; + m_plugin.m_pfnQERPlug_GetCommandTitleList = &UFOAI::getCommandTitleList; + m_plugin.m_pfnQERPlug_Dispatch = &UFOAI::dispatch; +} +_QERPluginTable* getTable(){ + return &m_plugin; +} }; typedef SingletonModule SingletonUFOAIModule; @@ -190,34 +169,31 @@ SingletonUFOAIModule g_UFOAIModule; class UFOAIToolbarDependencies : public ModuleRef<_QERPluginTable> { public: - UFOAIToolbarDependencies() : ModuleRef<_QERPluginTable>("UFO:AI") - { - } +UFOAIToolbarDependencies() : ModuleRef<_QERPluginTable>( "UFO:AI" ){ +} }; class UFOAIToolbarModule : public TypeSystemRef { - _QERPlugToolbarTable m_table; +_QERPlugToolbarTable m_table; public: - typedef _QERPlugToolbarTable Type; - STRING_CONSTANT(Name, "UFO:AI"); +typedef _QERPlugToolbarTable Type; +STRING_CONSTANT( Name, "UFO:AI" ); - UFOAIToolbarModule() - { - if (!strcmp(GlobalRadiant().getGameDescriptionKeyValue("name"), "UFO:Alien Invasion")) { - m_table.m_pfnToolbarButtonCount = ToolbarButtonCount; - m_table.m_pfnGetToolbarButton = GetToolbarButton; - } - else - { - m_table.m_pfnToolbarButtonCount = ToolbarNoButtons; - m_table.m_pfnGetToolbarButton = GetToolbarNoButton; - } - } - _QERPlugToolbarTable* getTable() +UFOAIToolbarModule(){ + if ( !strcmp( GlobalRadiant().getGameDescriptionKeyValue( "name" ), "UFO:Alien Invasion" ) ) { + m_table.m_pfnToolbarButtonCount = ToolbarButtonCount; + m_table.m_pfnGetToolbarButton = GetToolbarButton; + } + else { - return &m_table; + m_table.m_pfnToolbarButtonCount = ToolbarNoButtons; + m_table.m_pfnGetToolbarButton = GetToolbarNoButton; } +} +_QERPlugToolbarTable* getTable(){ + return &m_table; +} }; typedef SingletonModule SingletonUFOAIToolbarModule; @@ -225,9 +201,8 @@ typedef SingletonModule SingletonU SingletonUFOAIToolbarModule g_UFOAIToolbarModule; -extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server) -{ - initialiseModule(server); +extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){ + initialiseModule( server ); g_UFOAIModule.selfRegister(); g_UFOAIToolbarModule.selfRegister();