2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #ifndef __QERPLUGIN_H__
27 #define __QERPLUGIN_H__
29 #include "generic/constant.h"
32 // ========================================
33 // GTK+ helper functions
35 // NOTE: parent can be 0 in all functions but it's best to set them
37 // this API does not depend on gtk+ or glib
38 typedef struct _GtkWidget GtkWidget;
58 enum EMessageBoxReturn
66 // simple Message Box, see above for the 'type' flags
68 typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( GtkWidget *parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ );
70 // file and directory selection functions return null if the user hits cancel
71 // - 'title' is the dialog title (can be null)
72 // - 'path' is used to set the initial directory (can be null)
73 // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples
74 typedef const char* ( *PFN_QERAPP_FILEDIALOG )( GtkWidget *parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ );
76 // returns a gchar* string that must be g_free'd by the user
77 typedef char* ( *PFN_QERAPP_DIRDIALOG )( GtkWidget *parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ );
79 // return true if the user closed the dialog with 'Ok'
80 // 'color' is used to set the initial value and store the selected value
81 template<typename Element> class BasicVector3;
82 typedef BasicVector3<float> Vector3;
83 typedef bool ( *PFN_QERAPP_COLORDIALOG )( GtkWidget *parent, Vector3& color,
84 const char* title /* = "Choose Color"*/ );
86 // load a .bmp file and create a GtkImage widget from it
87 // NOTE: 'filename' is relative to <radiant_path>/plugins/bitmaps/
88 typedef struct _GtkImage GtkImage;
89 typedef GtkImage* ( *PFN_QERAPP_NEWIMAGE )( const char* filename );
91 // ========================================
100 #include "signal/signalfwd.h"
101 #include "windowobserver.h"
102 #include "generic/vector.h"
104 typedef SignalHandler3<const WindowVector&, ButtonIdentifier, ModifierFlags> MouseEventHandler;
105 typedef SignalFwd<MouseEventHandler>::handler_id_type MouseEventHandlerId;
114 // the radiant core API
115 struct _QERFuncTable_1
117 INTEGER_CONSTANT( Version, 1 );
118 STRING_CONSTANT( Name, "radiant" );
120 const char* ( *getEnginePath )( );
121 const char* ( *getLocalRcPath )( );
122 const char* ( *getGameToolsPath )( );
123 const char* ( *getAppPath )( );
124 const char* ( *getSettingsPath )( );
125 const char* ( *getMapsPath )( );
127 const char* ( *getGameName )( );
128 const char* ( *getGameMode )( );
130 const char* ( *getMapName )( );
131 scene::Node& ( *getMapWorldEntity )( );
132 float ( *getGridSize )();
134 const char* ( *getGameDescriptionKeyValue )(const char* key);
135 const char* ( *getRequiredGameDescriptionKeyValue )(const char* key);
137 void ( *attachGameToolsPathObserver )( ModuleObserver& observer );
138 void ( *detachGameToolsPathObserver )( ModuleObserver& observer );
139 void ( *attachEnginePathObserver )( ModuleObserver& observer );
140 void ( *detachEnginePathObserver )( ModuleObserver& observer );
141 void ( *attachGameNameObserver )( ModuleObserver& observer );
142 void ( *detachGameNameObserver )( ModuleObserver& observer );
143 void ( *attachGameModeObserver )( ModuleObserver& observer );
144 void ( *detachGameModeObserver )( ModuleObserver& observer );
146 SignalHandlerId ( *XYWindowDestroyed_connect )( const SignalHandler& handler );
147 void ( *XYWindowDestroyed_disconnect )( SignalHandlerId id );
148 MouseEventHandlerId ( *XYWindowMouseDown_connect )( const MouseEventHandler& handler );
149 void ( *XYWindowMouseDown_disconnect )( MouseEventHandlerId id );
150 VIEWTYPE ( *XYWindow_getViewType )();
151 Vector3 ( *XYWindow_windowToWorld )( const WindowVector& position );
152 const char* ( *TextureBrowser_getSelectedShader )( );
155 PFN_QERAPP_MESSAGEBOX m_pfnMessageBox;
156 PFN_QERAPP_FILEDIALOG m_pfnFileDialog;
157 PFN_QERAPP_DIRDIALOG m_pfnDirDialog;
158 PFN_QERAPP_COLORDIALOG m_pfnColorDialog;
159 PFN_QERAPP_NEWIMAGE m_pfnNewImage;
163 #include "modulesystem.h"
165 template<typename Type>
167 typedef GlobalModule<_QERFuncTable_1> GlobalRadiantModule;
169 template<typename Type>
170 class GlobalModuleRef;
171 typedef GlobalModuleRef<_QERFuncTable_1> GlobalRadiantModuleRef;
173 inline _QERFuncTable_1& GlobalRadiant(){
174 return GlobalRadiantModule::getTable();