1 /*
2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
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.
11
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.
16
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
20 */
21
22 /* greebo: This is where the interface for other plugins is defined.
23 * Functions that should be accessible via GlobalRadiant() are defined here
24 * as function pointers. The class RadiantCoreAPI in plugin.cpp makes sure
25 * that these variables are pointing to the correct functions. */
26
27 #pragma once
28
29 #include "generic/constant.h"
30 #include "iclipper.h"
31 #include <string>
32
33 // ========================================
34 // GTK+ helper functions
35
36 // NOTE: parent can be 0 in all functions but it's best to set them
37
38 // this API does not depend on gtk+ or glib
39 typedef struct _GtkWidget GtkWidget;
40
41 enum EMessageBoxType
42 {
43 eMB_OK, eMB_OKCANCEL, eMB_YESNO, eMB_YESNOCANCEL, eMB_NOYES
44 };
45
46 enum EMessageBoxIcon
47 {
48 eMB_ICONDEFAULT, eMB_ICONERROR, eMB_ICONWARNING, eMB_ICONQUESTION, eMB_ICONASTERISK
49 };
50
51 enum EMessageBoxReturn
52 {
53 eIDOK, eIDCANCEL, eIDYES, eIDNO
54 };
55
56 // ========================================
57
58 // Forward declarations
59 namespace scene
60 {
61 class Node;
62 }
63
64 class ModuleObserver;
65
66 #include "signal/signalfwd.h"
67 #include "windowobserver.h"
68 #include "math/Vector3.h"
69 #include "math/Plane3.h"
70
71 typedef struct _GdkEventButton GdkEventButton;
72 typedef SignalHandler3<int, int, GdkEventButton*> MouseEventHandler;
73 typedef SignalFwd<MouseEventHandler>::handler_id_type MouseEventHandlerId;
74
75 typedef struct _GtkWindow GtkWindow;
76
77 /** greebo: An EventListener gets notified by the Radiant module
78 * on global events like shutdown, startup and such.
79 *
80 * EventListener classes must register themselves using
81 * the GlobalRadiant().addEventListener() method in order
82 * to get notified about the events.
83 *
84 * Note: Default implementations are empty, deriving classes are
85 * supposed to pick the events they want to listen to.
86 */
87 class RadiantEventListener {
88 public:
89 /** Destructor
90 */
~RadiantEventListener()91 virtual ~RadiantEventListener() {}
92
93 /** This gets called AFTER the MainFrame window has been constructed.
94 */
onRadiantStartup()95 virtual void onRadiantStartup() {}
96
97 /** Gets called when BEFORE the MainFrame window is destroyed.
98 * Note: After this call, the EventListeners are deregistered from the
99 * Radiant module, all the internally held shared_ptrs are cleared.
100 */
onRadiantShutdown()101 virtual void onRadiantShutdown() {}
102 };
103
104 enum CounterType {
105 counterBrushes,
106 counterEntities
107 };
108
109 class Counter;
110
111 /** greebo: This abstract class defines the interface to the core application.
112 * Use this to access methods from the main codebase in radiant/
113 */
114 struct IRadiant
115 {
116 INTEGER_CONSTANT(Version, 1);
117 STRING_CONSTANT(Name, "radiant");
118
~IRadiantIRadiant119 virtual ~IRadiant() {}
120
121 // Registers/de-registers an event listener class
122 virtual void addEventListener(RadiantEventListener* listener) = 0;
123 virtual void removeEventListener(RadiantEventListener* listener) = 0;
124
125 // Broadcasts a "shutdown" event to all the listeners, this also clears all listeners!
126 virtual void broadcastShutdownEvent() = 0;
127
128 // Broadcasts a "startup" event to all the listeners
129 virtual void broadcastStartupEvent() = 0;
130
131 /** Return the main application GtkWindow.
132 */
133 virtual GtkWindow* getMainWindow() = 0;
134 virtual const std::string& getEnginePath() = 0;
135 virtual const std::string& getGamePath() = 0;
136 virtual const std::string getFullGamePath() = 0;
137
138 // Returns the Counter object of the given type
139 virtual Counter& getCounter(CounterType counter) = 0;
140
141 /** greebo: Set the status text of the main window
142 */
143 virtual void setStatusText (const std::string& statusText) = 0;
144
145 virtual void attachGameToolsPathObserver (ModuleObserver& observer) = 0;
146 virtual void detachGameToolsPathObserver (ModuleObserver& observer) = 0;
147 virtual void attachGameModeObserver (ModuleObserver& observer) = 0;
148 virtual void detachGameModeObserver (ModuleObserver& observer) = 0;
149 };
150
151 // IRadiant Module Definitions
152 #include "modulesystem.h"
153
154 template<typename Type>
155 class GlobalModule;
156 typedef GlobalModule<IRadiant> GlobalRadiantModule;
157
158 template<typename Type>
159 class GlobalModuleRef;
160 typedef GlobalModuleRef<IRadiant> GlobalRadiantModuleRef;
161
GlobalRadiant()162 inline IRadiant& GlobalRadiant ()
163 {
164 return GlobalRadiantModule::getTable();
165 }
166