2 This file is part of GtkRadiant.
4 GtkRadiant is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 GtkRadiant is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with GtkRadiant; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "ufoai_level.h"
21 #include "ufoai_gtk.h"
22 #include "ufoai_filters.h"
24 #include "debugging/debugging.h"
30 #include "string/string.h"
31 #include "modulesystem/singletonmodule.h"
35 #define PLUGIN_VERSION "0.4"
39 #include "iundo.h" // declaration of undo system
40 #include "ientity.h" // declaration of entity system
41 #include "iscenegraph.h" // declaration of datastructure of the map
42 #include "scenelib.h" // declaration of datastructure of the map
43 #include "qerplugin.h" // declaration to use other interfaces as a plugin
46 class UFOAIPluginDependencies :
47 public GlobalRadiantModuleRef, // basic class for all other module refs
48 public GlobalUndoModuleRef, // used to say radiant that something has changed and to undo that
49 public GlobalSceneGraphModuleRef, // necessary to handle data in the mapfile (change, retrieve data)
50 public GlobalEntityModuleRef, // to access and modify the entities
51 public GlobalEntityClassManagerModuleRef
54 UFOAIPluginDependencies( void ) :
55 GlobalEntityModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entities" ) ),
56 GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ){
62 ui::Window g_mainwnd{ui::null};
64 const char* init( void* hApp, void* pMainWidget ){
65 g_mainwnd = ui::Window::from(pMainWidget);
66 return "Initializing GTKRadiant UFOAI plugin";
68 const char* getName(){
71 const char* getCommandList(){
72 /*GlobalRadiant().getGameName()*/
73 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";
75 const char* getCommandTitleList(){
78 void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){
79 char const *message = NULL;
80 if ( string_equal( command, "About" ) ) {
81 char const *version_string = "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__
82 "\nRadiant version: " RADIANT_VERSION
83 "\nPlugin version: " PLUGIN_VERSION
84 "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n";
85 GlobalRadiant().m_pfnMessageBox( g_mainwnd,
86 version_string, "About",
87 eMB_OK, eMB_ICONDEFAULT );
89 else if ( string_equal( command, "Level 1" ) ) {
90 filter_level( CONTENTS_LEVEL1 );
92 else if ( string_equal( command, "Level 2" ) ) {
93 filter_level( CONTENTS_LEVEL2 );
95 else if ( string_equal( command, "Level 3" ) ) {
96 filter_level( CONTENTS_LEVEL3 );
98 else if ( string_equal( command, "Worldspawn" ) ) {
99 assign_default_values_to_worldspawn( false, &message );
101 else if ( string_equal( command, "Worldspawn reset" ) ) {
102 assign_default_values_to_worldspawn( true, &message );
104 else if ( string_equal( command, "Perform check" ) ) {
105 check_map_values( &message );
107 else if ( string_equal( command, "Level 4" ) ) {
108 filter_level( CONTENTS_LEVEL4 );
110 else if ( string_equal( command, "Level 5" ) ) {
111 filter_level( CONTENTS_LEVEL5 );
113 else if ( string_equal( command, "Level 6" ) ) {
114 filter_level( CONTENTS_LEVEL6 );
116 else if ( string_equal( command, "Level 7" ) ) {
117 filter_level( CONTENTS_LEVEL7 );
119 else if ( string_equal( command, "Level 8" ) ) {
120 filter_level( CONTENTS_LEVEL8 );
122 else if ( string_equal( command, "StepOn" ) ) {
125 else if ( string_equal( command, "ActorClip" ) ) {
128 else if ( string_equal( command, "WeaponClip" ) ) {
131 else if ( string_equal( command, "NoDraw" ) ) {
135 if ( message != NULL ) {
136 GlobalRadiant().m_pfnMessageBox( g_mainwnd,
138 eMB_OK, eMB_ICONDEFAULT );
145 class UFOAIModule : public TypeSystemRef
147 _QERPluginTable m_plugin;
149 typedef _QERPluginTable Type;
150 STRING_CONSTANT( Name, "UFO:AI" );
153 m_plugin.m_pfnQERPlug_Init = &UFOAI::init;
154 m_plugin.m_pfnQERPlug_GetName = &UFOAI::getName;
155 m_plugin.m_pfnQERPlug_GetCommandList = &UFOAI::getCommandList;
156 m_plugin.m_pfnQERPlug_GetCommandTitleList = &UFOAI::getCommandTitleList;
157 m_plugin.m_pfnQERPlug_Dispatch = &UFOAI::dispatch;
159 _QERPluginTable* getTable(){
164 typedef SingletonModule<UFOAIModule, UFOAIPluginDependencies> SingletonUFOAIModule;
166 SingletonUFOAIModule g_UFOAIModule;
169 class UFOAIToolbarDependencies : public ModuleRef<_QERPluginTable>
172 UFOAIToolbarDependencies() : ModuleRef<_QERPluginTable>( "UFO:AI" ){
176 class UFOAIToolbarModule : public TypeSystemRef
178 _QERPlugToolbarTable m_table;
180 typedef _QERPlugToolbarTable Type;
181 STRING_CONSTANT( Name, "UFO:AI" );
183 UFOAIToolbarModule(){
184 if ( !strcmp( GlobalRadiant().getGameDescriptionKeyValue( "name" ), "UFO:Alien Invasion" ) ) {
185 m_table.m_pfnToolbarButtonCount = ToolbarButtonCount;
186 m_table.m_pfnGetToolbarButton = GetToolbarButton;
190 m_table.m_pfnToolbarButtonCount = ToolbarNoButtons;
191 m_table.m_pfnGetToolbarButton = GetToolbarNoButton;
194 _QERPlugToolbarTable* getTable(){
199 typedef SingletonModule<UFOAIToolbarModule, UFOAIToolbarDependencies> SingletonUFOAIToolbarModule;
201 SingletonUFOAIToolbarModule g_UFOAIToolbarModule;
204 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
205 initialiseModule( server );
207 g_UFOAIModule.selfRegister();
208 g_UFOAIToolbarModule.selfRegister();