]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/pluginapi.cpp
allow undo “make detail/structural”, <3 @SpiKe, thanks @Garux, fix #76
[xonotic/netradiant.git] / radiant / pluginapi.cpp
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 #include "pluginapi.h"
23
24 #include "modulesystem.h"
25 #include "qerplugin.h"
26
27 #include "generic/callback.h"
28 #include "math/vector.h"
29
30 #include "gtkmisc.h"
31
32 #include "camwindow.h"
33
34 #include "mainframe.h"
35
36
37 // camera API
38 void QERApp_GetCamera(Vector3 &origin, Vector3 &angles)
39 {
40     CamWnd &camwnd = *g_pParentWnd->GetCamWnd();
41     origin = Camera_getOrigin(camwnd);
42     angles = Camera_getAngles(camwnd);
43 }
44
45 void QERApp_SetCamera(const Vector3 &origin, const Vector3 &angles)
46 {
47     CamWnd &camwnd = *g_pParentWnd->GetCamWnd();
48     Camera_setOrigin(camwnd, origin);
49     Camera_setAngles(camwnd, angles);
50 }
51
52 void QERApp_GetCamWindowExtents(int *x, int *y, int *width, int *height)
53 {
54 #if 0
55     CamWnd* camwnd = g_pParentWnd->GetCamWnd();
56
57     gtk_window_get_position( camwnd->m_window, x, y );
58
59     *width = camwnd->Camera()->width;
60     *height = camwnd->Camera()->height;
61 #endif
62 }
63
64 #include "icamera.h"
65
66 class CameraAPI {
67     _QERCameraTable m_camera;
68 public:
69     typedef _QERCameraTable Type;
70
71     STRING_CONSTANT(Name, "*");
72
73     CameraAPI()
74     {
75         m_camera.m_pfnGetCamera = &QERApp_GetCamera;
76         m_camera.m_pfnSetCamera = &QERApp_SetCamera;
77         m_camera.m_pfnGetCamWindowExtents = &QERApp_GetCamWindowExtents;
78     }
79
80     _QERCameraTable *getTable()
81     {
82         return &m_camera;
83     }
84 };
85
86 #include "modulesystem/singletonmodule.h"
87 #include "modulesystem/moduleregistry.h"
88
89 typedef SingletonModule<CameraAPI> CameraModule;
90 typedef Static<CameraModule> StaticCameraModule;
91 StaticRegisterModule staticRegisterCamera(StaticCameraModule::instance());