iradiant.h

Go to the documentation of this file.
00001 /*
00002  Copyright (C) 1999-2006 Id Software, Inc. and contributors.
00003  For a list of contributors, see the accompanying CONTRIBUTORS file.
00004 
00005  This file is part of GtkRadiant.
00006 
00007  GtkRadiant is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU General Public License as published by
00009  the Free Software Foundation; either version 2 of the License, or
00010  (at your option) any later version.
00011 
00012  GtkRadiant is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU General Public License for more details.
00016 
00017  You should have received a copy of the GNU General Public License
00018  along with GtkRadiant; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 /* greebo: This is where the interface for other plugins is defined.
00023  * Functions that should be accessible via GlobalRadiant() are defined here
00024  * as function pointers. The class RadiantCoreAPI in plugin.cpp makes sure
00025  * that these variables are pointing to the correct functions. */
00026 
00027 #ifndef __QERPLUGIN_H__
00028 #define __QERPLUGIN_H__
00029 
00030 #include "generic/constant.h"
00031 #include "gtkutil/accelerator.h"
00032 #include <string>
00033 
00034 // ========================================
00035 // GTK+ helper functions
00036 
00037 // NOTE: parent can be 0 in all functions but it's best to set them
00038 
00039 // this API does not depend on gtk+ or glib
00040 typedef struct _GtkWidget GtkWidget;
00041 
00042 enum EMessageBoxType
00043 {
00044     eMB_OK, eMB_OKCANCEL, eMB_YESNO, eMB_YESNOCANCEL, eMB_NOYES,
00045 };
00046 
00047 enum EMessageBoxIcon
00048 {
00049     eMB_ICONDEFAULT, eMB_ICONERROR, eMB_ICONWARNING, eMB_ICONQUESTION, eMB_ICONASTERISK,
00050 };
00051 
00052 enum EMessageBoxReturn
00053 {
00054     eIDOK, eIDCANCEL, eIDYES, eIDNO,
00055 };
00056 
00057 // simple Message Box, see above for the 'type' flags
00058 
00059 typedef EMessageBoxReturn (* PFN_QERAPP_MESSAGEBOX) (GtkWidget *parent, const std::string& text,
00060         const std::string& caption, EMessageBoxType type, EMessageBoxIcon icon);
00061 
00062 // file and directory selection functions return null if the user hits cancel
00063 // - 'title' is the dialog title (can be null)
00064 // - 'path' is used to set the initial directory (can be null)
00065 // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples
00066 typedef const char* (* PFN_QERAPP_FILEDIALOG) (GtkWidget *parent, bool open, const std::string& title,
00067         const std::string& path, const std::string& pattern);
00068 
00069 // return true if the user closed the dialog with 'Ok'
00070 // 'color' is used to set the initial value and store the selected value
00071 template<typename Element> class BasicVector3;
00072 typedef BasicVector3<float> Vector3;
00073 typedef bool (* PFN_QERAPP_COLORDIALOG) (GtkWidget *parent, Vector3& color, const std::string& title);
00074 
00075 // load an image file and create a GtkWidget from it
00076 // NOTE: 'filename' is relative to <radiant_path>/bitmaps/
00077 typedef struct _GtkWidget GtkWidget;
00078 typedef GtkWidget* (* PFN_QERAPP_NEWIMAGE) (const std::string& filename);
00079 
00080 // ========================================
00081 
00082 // Forward declarations
00083 namespace scene
00084 {
00085     class Node;
00086 }
00087 
00088 class ModuleObserver;
00089 
00090 #include "signal/signalfwd.h"
00091 #include "windowobserver.h"
00092 #include "math/Vector3.h"
00093 
00094 typedef SignalHandler3<const WindowVector&, ButtonIdentifier, ModifierFlags> MouseEventHandler;
00095 typedef SignalFwd<MouseEventHandler>::handler_id_type MouseEventHandlerId;
00096 
00097 // Possible types of the orthogonal view window
00098 enum EViewType
00099 {
00100     YZ = 0, XZ = 1, XY = 2
00101 };
00102 
00103 typedef struct _GtkWindow GtkWindow;
00104 
00105 // the radiant core API
00106 // This contains pointers to all the core functions that should be available via GlobalRadiant()
00107 struct IRadiant
00108 {
00109         INTEGER_CONSTANT(Version, 1);
00110         STRING_CONSTANT(Name, "radiant");
00111 
00114         GtkWindow* (*getMainWindow) ();
00115         const std::string& (*getEnginePath) ();
00116         const std::string& (*getAppPath) ();
00117         const std::string& (*getSettingsPath) ();
00118         const std::string& (*getMapsPath) ();
00119         void (*commandInsert) (const std::string& name, const Callback& callback, const Accelerator& accelerator);
00120 
00121         const std::string (*getGamePath) ();
00122         const std::string& (*getGameName) ();
00126         const std::string (*getMapName) ();
00127         scene::Node& (*getMapWorldEntity) ();
00128         float (*getGridSize) ();
00129 
00130         const std::string& (*getGameDescriptionKeyValue) (const std::string& key);
00131         const std::string& (*getRequiredGameDescriptionKeyValue) (const std::string& key);
00132 
00133         void (*attachGameToolsPathObserver) (ModuleObserver& observer);
00134         void (*detachGameToolsPathObserver) (ModuleObserver& observer);
00135         void (*attachEnginePathObserver) (ModuleObserver& observer);
00136         void (*detachEnginePathObserver) (ModuleObserver& observer);
00137         void (*attachGameNameObserver) (ModuleObserver& observer);
00138         void (*detachGameNameObserver) (ModuleObserver& observer);
00139         void (*attachGameModeObserver) (ModuleObserver& observer);
00140         void (*detachGameModeObserver) (ModuleObserver& observer);
00141 
00142         SignalHandlerId (*XYWindowDestroyed_connect) (const SignalHandler& handler);
00143         void (*XYWindowDestroyed_disconnect) (SignalHandlerId id);
00144         MouseEventHandlerId (*XYWindowMouseDown_connect) (const MouseEventHandler& handler);
00145         void (*XYWindowMouseDown_disconnect) (MouseEventHandlerId id);
00146         EViewType (*XYWindow_getViewType) ();
00147         Vector3 (*XYWindow_windowToWorld) (const WindowVector& position);
00148         const char* (*TextureBrowser_getSelectedShader) ();
00149 
00150         // GTK+ functions
00151         PFN_QERAPP_MESSAGEBOX m_pfnMessageBox;
00152         PFN_QERAPP_FILEDIALOG m_pfnFileDialog;
00153         PFN_QERAPP_COLORDIALOG m_pfnColorDialog;
00154         PFN_QERAPP_NEWIMAGE m_pfnNewImage;
00155 };
00156 
00157 // _QERFuncTable_1 Module Definitions
00158 #include "modulesystem.h"
00159 
00160 template<typename Type>
00161 class GlobalModule;
00162 typedef GlobalModule<IRadiant> GlobalRadiantModule;
00163 
00164 template<typename Type>
00165 class GlobalModuleRef;
00166 typedef GlobalModuleRef<IRadiant> GlobalRadiantModuleRef;
00167 
00168 inline IRadiant& GlobalRadiant ()
00169 {
00170     return GlobalRadiantModule::getTable();
00171 }
00172 
00173 #endif

Generated by  doxygen 1.6.2